diff --git a/gitg/gitg-commit-view.c b/gitg/gitg-commit-view.c
index 35aca782..6f90062e 100644
--- a/gitg/gitg-commit-view.c
+++ b/gitg/gitg-commit-view.c
@@ -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);
diff --git a/gitg/gitg-commit-view.h b/gitg/gitg-commit-view.h
index b2bb3cfa..2ec87aa8 100644
--- a/gitg/gitg-commit-view.h
+++ b/gitg/gitg-commit-view.h
@@ -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;
diff --git a/gitg/gitg-settings.h b/gitg/gitg-settings.h
index b6aa6bf6..0ad96094 100644
--- a/gitg/gitg-settings.h
+++ b/gitg/gitg-settings.h
@@ -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)
diff --git a/gitg/gitg-utils.c b/gitg/gitg-utils.c
index afabee3d..59e0e70b 100644
--- a/gitg/gitg-utils.c
+++ b/gitg/gitg-utils.c
@@ -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);
+}
diff --git a/gitg/gitg-utils.h b/gitg/gitg-utils.h
index 05fb90a0..1dd2ad88 100644
--- a/gitg/gitg-utils.h
+++ b/gitg/gitg-utils.h
@@ -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__ */
diff --git a/gitg/gitg-window.c b/gitg/gitg-window.c
index 6d42003d..56f7d3d4 100644
--- a/gitg/gitg-window.c
+++ b/gitg/gitg-window.c
@@ -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;
@@ -442,22 +443,26 @@ restore_state(GitgWindow *window)
gtk_window_set_default_size(GTK_WINDOW(window),
gitg_settings_get_window_width(settings, dw),
gitg_settings_get_window_height(settings, dh));
+
+ gitg_utils_restore_pane_position (GTK_PANED(window->priv->vpaned_main),
+ gitg_settings_get_vpaned_main_position(settings, -1),
+ FALSE);
- 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));
-
- 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);
diff --git a/gitg/gitg-window.ui b/gitg/gitg-window.ui
index aa0509b9..99b41361 100644
--- a/gitg/gitg-window.ui
+++ b/gitg/gitg-window.ui
@@ -4,10 +4,6 @@
-