Implemented vertical layout for commit view

This layout is conform to gitx where the stage/unstage areas are
respectively on the left and right of the commit message
This commit is contained in:
Jesse van den Kieboom 2009-07-05 12:49:27 +02:00
parent 9ca7a51589
commit fcff4dfb93
7 changed files with 367 additions and 250 deletions

View file

@ -93,7 +93,7 @@ struct _GitgCommitViewPrivate
static void gitg_commit_view_buildable_iface_init(GtkBuildableIface *iface);
G_DEFINE_TYPE_EXTENDED(GitgCommitView, gitg_commit_view, GTK_TYPE_HPANED, 0,
G_DEFINE_TYPE_EXTENDED(GitgCommitView, gitg_commit_view, GTK_TYPE_VPANED, 0,
G_IMPLEMENT_INTERFACE(GTK_TYPE_BUILDABLE, gitg_commit_view_buildable_iface_init));
static GtkBuildableIface parent_iface;
@ -946,6 +946,7 @@ gitg_commit_view_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
self->priv->comment_view, "right-margin-position");
self->priv->hscale_context = GTK_HSCALE(gtk_builder_get_object(builder, "hscale_context"));
gtk_range_set_value (GTK_RANGE (self->priv->hscale_context), 3);
initialize_dnd_staged(self);
initialize_dnd_unstaged(self);

View file

@ -41,13 +41,13 @@ typedef struct _GitgCommitViewClass GitgCommitViewClass;
typedef struct _GitgCommitViewPrivate GitgCommitViewPrivate;
struct _GitgCommitView {
GtkHPaned parent;
GtkVPaned parent;
GitgCommitViewPrivate *priv;
};
struct _GitgCommitViewClass {
GtkHPanedClass parent_class;
GtkVPanedClass parent_class;
};
GType gitg_commit_view_get_type (void) G_GNUC_CONST;

View file

@ -47,8 +47,11 @@ G_BEGIN_DECLS
#define gitg_settings_set_vpaned_main_position(settings, value) gitg_settings_set_integer(settings, "vpaned-main-position", value)
#define gitg_settings_get_vpaned_main_position(settings, def) gitg_settings_get_integer(settings, "vpaned-main-position", def)
#define gitg_settings_set_hpaned_commit_position(settings, value) gitg_settings_set_integer(settings, "hpaned-commit-position", value)
#define gitg_settings_get_hpaned_commit_position(settings, def) gitg_settings_get_integer(settings, "hpaned-commit-position", def)
#define gitg_settings_set_hpaned_commit1_position(settings, value) gitg_settings_set_integer(settings, "hpaned-commit1-position", value)
#define gitg_settings_get_hpaned_commit1_position(settings, def) gitg_settings_get_integer(settings, "hpaned-commit1-position", def)
#define gitg_settings_set_hpaned_commit2_position(settings, value) gitg_settings_set_integer(settings, "hpaned-commit2-position", value)
#define gitg_settings_get_hpaned_commit2_position(settings, def) gitg_settings_get_integer(settings, "hpaned-commit2-position", def)
#define gitg_settings_set_vpaned_commit_position(settings, value) gitg_settings_set_integer(settings, "vpaned-commit-position", value)
#define gitg_settings_get_vpaned_commit_position(settings, def) gitg_settings_get_integer(settings, "vpaned-commit-position", def)

View file

@ -544,3 +544,65 @@ gitg_utils_find_cell_at_pos (GtkTreeView *tree_view, GtkTreeViewColumn *column,
g_list_free (cells);
return ret;
}
typedef struct
{
gint position;
gboolean reversed;
} PanedRestoreInfo;
static void
free_paned_restore_info (PanedRestoreInfo *info)
{
g_slice_free (PanedRestoreInfo, info);
}
static void
paned_set_position (GtkPaned *paned, gint position, gboolean reversed)
{
if (position == -1)
{
return;
}
if (!reversed)
{
gtk_paned_set_position (paned, position);
}
else
{
gtk_paned_set_position (paned, GTK_WIDGET (paned)->allocation.width - position);
}
}
static void
on_paned_mapped (GtkPaned *paned, PanedRestoreInfo *info)
{
paned_set_position (paned, info->position, info->reversed);
g_signal_handlers_disconnect_by_func (paned, on_paned_mapped, info);
}
void
gitg_utils_restore_pane_position (GtkPaned *paned, gint position, gboolean reversed)
{
g_return_if_fail (GTK_IS_PANED (paned));
if (GTK_WIDGET_MAPPED (paned))
{
paned_set_position (paned, position, reversed);
return;
}
PanedRestoreInfo *info = g_slice_new (PanedRestoreInfo);
info->position = position;
info->reversed = reversed;
g_signal_connect_data (paned,
"map",
G_CALLBACK (on_paned_mapped),
info,
(GClosureNotify)free_paned_restore_info,
G_CONNECT_AFTER);
}

View file

@ -66,4 +66,6 @@ gchar *gitg_utils_timestamp_to_str(guint64 timestamp);
GtkBuilder *gitg_utils_new_builder(gchar const *filename);
GtkCellRenderer *gitg_utils_find_cell_at_pos (GtkTreeView *tree_view, GtkTreeViewColumn *column, GtkTreePath *path, gint x);
void gitg_utils_restore_pane_position (GtkPaned *paned, gint position, gboolean reversed);
#endif /* __GITG_UTILS_H__ */

View file

@ -73,7 +73,8 @@ struct _GitgWindowPrivate
GtkUIManager *menus_ui_manager;
GtkWidget *vpaned_main;
GtkWidget *hpaned_commit;
GtkWidget *hpaned_commit1;
GtkWidget *hpaned_commit2;
GtkWidget *vpaned_commit;
GtkActionGroup *edit_group;
@ -443,21 +444,25 @@ restore_state(GitgWindow *window)
gitg_settings_get_window_width(settings, dw),
gitg_settings_get_window_height(settings, dh));
gint orig = gtk_paned_get_position(GTK_PANED(window->priv->vpaned_main));
gtk_paned_set_position(GTK_PANED(window->priv->vpaned_main),
gitg_settings_get_vpaned_main_position(settings, orig));
gitg_utils_restore_pane_position (GTK_PANED(window->priv->vpaned_main),
gitg_settings_get_vpaned_main_position(settings, -1),
FALSE);
orig = gtk_paned_get_position(GTK_PANED(window->priv->vpaned_commit));
gtk_paned_set_position(GTK_PANED(window->priv->vpaned_commit),
gitg_settings_get_vpaned_commit_position(settings, orig));
gitg_utils_restore_pane_position (GTK_PANED(window->priv->vpaned_commit),
gitg_settings_get_vpaned_commit_position(settings, -1),
FALSE);
orig = gtk_paned_get_position(GTK_PANED(window->priv->hpaned_commit));
gtk_paned_set_position(GTK_PANED(window->priv->hpaned_commit),
gitg_settings_get_hpaned_commit_position(settings, orig));
gitg_utils_restore_pane_position (GTK_PANED(window->priv->hpaned_commit1),
gitg_settings_get_hpaned_commit1_position(settings, 200),
FALSE);
orig = gtk_paned_get_position(GTK_PANED(window->priv->revision_tree_view));
gtk_paned_set_position(GTK_PANED(window->priv->revision_tree_view),
gitg_settings_get_revision_tree_view_position(settings, orig));
gitg_utils_restore_pane_position (GTK_PANED(window->priv->hpaned_commit2),
gitg_settings_get_hpaned_commit2_position(settings, 200),
TRUE);
gitg_utils_restore_pane_position (GTK_PANED(window->priv->revision_tree_view),
gitg_settings_get_revision_tree_view_position(settings, -1),
FALSE);
}
static void
@ -573,7 +578,8 @@ gitg_window_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
g_object_unref(b);
window->priv->vpaned_main = GTK_WIDGET(gtk_builder_get_object(builder, "vpaned_main"));
window->priv->hpaned_commit = GTK_WIDGET(gtk_builder_get_object(builder, "hpaned_commit"));
window->priv->hpaned_commit1 = GTK_WIDGET(gtk_builder_get_object(builder, "hpaned_commit1"));
window->priv->hpaned_commit2 = GTK_WIDGET(gtk_builder_get_object(builder, "hpaned_commit2"));
window->priv->vpaned_commit = GTK_WIDGET(gtk_builder_get_object(builder, "vpaned_commit"));
window->priv->notebook_main = GTK_NOTEBOOK(gtk_builder_get_object(builder, "notebook_main"));
@ -581,7 +587,7 @@ gitg_window_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
window->priv->statusbar = GTK_STATUSBAR(gtk_builder_get_object(builder, "statusbar"));
window->priv->revision_view = GITG_REVISION_VIEW(gtk_builder_get_object(builder, "revision_view"));
window->priv->revision_tree_view = GITG_REVISION_TREE_VIEW(gtk_builder_get_object(builder, "revision_tree_view"));
window->priv->commit_view = GITG_COMMIT_VIEW(gtk_builder_get_object(builder, "hpaned_commit"));
window->priv->commit_view = GITG_COMMIT_VIEW(gtk_builder_get_object(builder, "vpaned_commit"));
restore_state(window);
@ -628,9 +634,16 @@ save_state(GitgWindow *window)
gitg_settings_set_window_width(settings, allocation->width);
gitg_settings_set_window_height(settings, allocation->height);
gitg_settings_set_vpaned_main_position(settings, gtk_paned_get_position(GTK_PANED(window->priv->vpaned_main)));
gitg_settings_set_vpaned_commit_position(settings, gtk_paned_get_position(GTK_PANED(window->priv->vpaned_commit)));
gitg_settings_set_hpaned_commit_position(settings, gtk_paned_get_position(GTK_PANED(window->priv->hpaned_commit)));
gitg_settings_set_vpaned_main_position (settings,
gtk_paned_get_position(GTK_PANED(window->priv->vpaned_main)));
gitg_settings_set_vpaned_commit_position (settings,
gtk_paned_get_position(GTK_PANED(window->priv->vpaned_commit)));
gitg_settings_set_hpaned_commit1_position (settings,
gtk_paned_get_position(GTK_PANED(window->priv->hpaned_commit1)));
gitg_settings_set_hpaned_commit2_position (settings,
GTK_WIDGET (window->priv->hpaned_commit2)->allocation.width -
gtk_paned_get_position(GTK_PANED(window->priv->hpaned_commit2)));
gitg_settings_set_revision_tree_view_position(settings, gtk_paned_get_position(GTK_PANED(window->priv->revision_tree_view)));
gitg_settings_save(settings);

View file

@ -4,10 +4,6 @@
<!-- interface-requires gitg 0.2 -->
<!-- interface-requires sourceview2 0.0 -->
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkImage" id="image_commit">
<property name="visible">True</property>
<property name="stock">gtk-apply</property>
</object>
<object class="GtkAdjustment" id="adjustment_context">
<property name="value">3</property>
<property name="lower">1</property>
@ -40,6 +36,7 @@
<child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="border_width">6</property>
<child>
<object class="GtkHBox" id="hbox_top">
<property name="visible">True</property>
@ -155,6 +152,7 @@
<object class="GtkNotebook" id="notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="border_width">6</property>
<child>
<object class="GitgRevisionView" id="revision_view">
<property name="visible">True</property>
@ -394,7 +392,7 @@
</object>
</child>
<child type="tab">
<object class="GtkLabel" id="label1">
<object class="GtkLabel" id="label_details">
<property name="visible">True</property>
<property name="label" translatable="yes">Details</property>
</object>
@ -408,7 +406,7 @@
<property name="can_focus">True</property>
<property name="position">200</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<object class="GtkScrolledWindow" id="scrolled_window_revision_tree">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
@ -469,7 +467,7 @@
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label2">
<object class="GtkLabel" id="label_tree">
<property name="visible">True</property>
<property name="label" translatable="yes">Tree</property>
</object>
@ -501,134 +499,17 @@
</packing>
</child>
<child>
<object class="GitgCommitView" id="hpaned_commit">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">200</property>
<child>
<object class="GtkVBox" id="vbox_staging">
<property name="visible">True</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="label_unstaged">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="label" translatable="yes">_Unstaged</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">tree_view_unstaged</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolled_window_unstaged">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">etched-in</property>
<child>
<object class="GtkTreeView" id="tree_view_unstaged">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<child>
<object class="GtkTreeViewColumn" id="unstaged_column_icon">
<property name="sizing">fixed</property>
<property name="fixed_width">20</property>
<child>
<object class="GtkCellRendererPixbuf" id="unstaged_cell_renderer_icon"/>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="unstaged_column_name">
<property name="resizable">True</property>
<property name="title">Unstaged</property>
<child>
<object class="GtkCellRendererText" id="unstaged_cell_renderer"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_staged">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Staged</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">tree_view_staged</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolled_window_staged">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">etched-in</property>
<child>
<object class="GtkTreeView" id="tree_view_staged">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<child>
<object class="GtkTreeViewColumn" id="staged_column_icon">
<property name="sizing">fixed</property>
<property name="fixed_width">20</property>
<child>
<object class="GtkCellRendererPixbuf" id="staged_cell_renderer_icon"/>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="staged_column_name">
<property name="resizable">True</property>
<child>
<object class="GtkCellRendererText" id="staged_cell_renderer_name"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<object class="GtkVPaned" id="vpaned_commit">
<object class="GitgCommitView" id="vpaned_commit">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="border_width">6</property>
<property name="orientation">vertical</property>
<property name="position">450</property>
<property name="position_set">True</property>
<child>
<object class="GtkVBox" id="vbox_changes">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkHBox" id="hbox_changes">
@ -662,6 +543,7 @@
<object class="GtkHScale" id="hscale_context">
<property name="width_request">200</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment_context</property>
<property name="digits">0</property>
<property name="value_pos">right</property>
@ -687,7 +569,10 @@
<property name="shadow_type">etched-in</property>
<child>
<object class="GitgDiffView" id="source_view_changes">
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="left_margin">2</property>
<property name="right_margin">2</property>
<property name="cursor_visible">False</property>
<property name="show_line_numbers">True</property>
<property name="tab_width">4</property>
@ -704,9 +589,84 @@
<property name="shrink">True</property>
</packing>
</child>
<child>
<object class="GtkHPaned" id="hpaned_commit1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkVBox" id="vbox_unstaged">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="label_unstaged">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="xpad">1</property>
<property name="label" translatable="yes">_Unstaged</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">tree_view_unstaged</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolled_window_unstaged">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">etched-in</property>
<child>
<object class="GtkTreeView" id="tree_view_unstaged">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<child>
<object class="GtkTreeViewColumn" id="unstaged_column_icon">
<property name="sizing">fixed</property>
<property name="fixed_width">20</property>
<child>
<object class="GtkCellRendererPixbuf" id="unstaged_cell_renderer_icon"/>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="unstaged_column_name">
<property name="resizable">True</property>
<property name="title">Unstaged</property>
<child>
<object class="GtkCellRendererText" id="unstaged_cell_renderer"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">False</property>
</packing>
</child>
<child>
<object class="GtkHPaned" id="hpaned_commit2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkVBox" id="vbox_comment">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="label_comment">
@ -734,6 +694,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="wrap_mode">word-char</property>
<property name="left_margin">2</property>
<property name="right_margin">2</property>
</object>
</child>
</object>
@ -748,7 +710,7 @@
<child>
<object class="GtkCheckButton" id="check_button_signed_off_by">
<property name="label" translatable="yes">Add signed-off-by</property>
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
@ -780,7 +742,77 @@
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
<property name="shrink">False</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox_staged">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="label_staged">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Staged</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">tree_view_staged</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolled_window_staged">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">etched-in</property>
<child>
<object class="GtkTreeView" id="tree_view_staged">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<child>
<object class="GtkTreeViewColumn" id="staged_column_icon">
<property name="sizing">fixed</property>
<property name="fixed_width">20</property>
<child>
<object class="GtkCellRendererPixbuf" id="staged_cell_renderer_icon"/>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="staged_column_name">
<property name="resizable">True</property>
<child>
<object class="GtkCellRendererText" id="staged_cell_renderer_name"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">False</property>
</packing>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">False</property>
</packing>
</child>
</object>
@ -822,4 +854,8 @@
</object>
</child>
</object>
<object class="GtkImage" id="image_commit">
<property name="visible">True</property>
<property name="stock">gtk-apply</property>
</object>
</interface>