[gitg] Correctly store/restore paned positions
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: svn-commits-list gnome org
- Subject: [gitg] Correctly store/restore paned positions
- Date: Sun, 5 Jul 2009 17:40:01 +0000 (UTC)
commit 16819b1a3393c76f0ca7dc3412ff4e058c1ccfdf
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Sun Jul 5 14:20:08 2009 +0200
Correctly store/restore paned positions
gitg/gitg-window.c | 51 ++++++++++++++++++++++++++++++++++++++++-----------
gitg/gitg.c | 4 ++--
2 files changed, 42 insertions(+), 13 deletions(-)
---
diff --git a/gitg/gitg-window.c b/gitg/gitg-window.c
index 56f7d3d..602ee11 100644
--- a/gitg/gitg-window.c
+++ b/gitg/gitg-window.c
@@ -634,21 +634,51 @@ 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_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)));
+ if (GTK_WIDGET_MAPPED (window->priv->vpaned_main))
+ {
+ gitg_settings_set_vpaned_main_position (settings,
+ gtk_paned_get_position(GTK_PANED(window->priv->vpaned_main)));
+ }
+
+ if (GTK_WIDGET_MAPPED (window->priv->vpaned_commit))
+ {
+ gitg_settings_set_vpaned_commit_position (settings,
+ gtk_paned_get_position(GTK_PANED(window->priv->vpaned_commit)));
+ }
+
+ if (GTK_WIDGET_MAPPED (window->priv->hpaned_commit1))
+ {
+ gitg_settings_set_hpaned_commit1_position (settings,
+ gtk_paned_get_position(GTK_PANED(window->priv->hpaned_commit1)));
+ }
+
+ if (GTK_WIDGET_MAPPED (window->priv->hpaned_commit2))
+ {
+ 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);
}
+static gboolean
+gitg_window_delete_event (GtkWidget *widget, GdkEventAny *event)
+{
+ save_state(GITG_WINDOW (widget));
+
+ if (GTK_WIDGET_CLASS (parent_class)->delete_event)
+ {
+ GTK_WIDGET_CLASS (parent_class)->delete_event (widget, event);
+ }
+ else
+ {
+ gtk_widget_destroy (widget);
+ }
+}
+
static void
gitg_window_destroy(GtkObject *object)
{
@@ -656,8 +686,6 @@ gitg_window_destroy(GtkObject *object)
if (!window->priv->destroy_has_run)
{
- save_state(window);
-
gtk_tree_view_set_model(window->priv->tree_view, NULL);
window->priv->destroy_has_run = TRUE;
}
@@ -696,6 +724,7 @@ gitg_window_class_init(GitgWindowClass *klass)
object_class->finalize = gitg_window_finalize;
gtkobject_class->destroy = gitg_window_destroy;
+ widget_class->delete_event = gitg_window_delete_event;
widget_class->window_state_event = gitg_window_window_state_event;
diff --git a/gitg/gitg.c b/gitg/gitg.c
index 1a21907..b16770c 100644
--- a/gitg/gitg.c
+++ b/gitg/gitg.c
@@ -68,7 +68,7 @@ parse_options(int *argc, char ***argv)
}
static gboolean
-on_window_delete_event(GtkWidget *widget, GdkEvent *event, gpointer userdata)
+on_window_delete_event(GtkWidget *widget, gpointer userdata)
{
gtk_main_quit();
return FALSE;
@@ -82,7 +82,7 @@ build_ui()
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
gtk_widget_show_all(window);
- g_signal_connect(window, "delete-event", G_CALLBACK(on_window_delete_event), NULL);
+ g_signal_connect_after(window, "destroy", G_CALLBACK(on_window_delete_event), NULL);
g_object_unref(builder);
return GITG_WINDOW(window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]