[easytag/wip/application-window] WIP Save application window paned state



commit 6b572d162cfc7ee54f8ea243d65df5d4dd574165
Author: David King <amigadave amigadave com>
Date:   Thu Jul 17 08:31:19 2014 +0100

    WIP Save application window paned state
    
    TODO Does not seem to restore state correctly, is the paned position set
    too early?
    
    Browser paned should be managed by EtBrowser.

 src/application_window.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/src/application_window.c b/src/application_window.c
index dde830e..4709b4d 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -147,6 +147,9 @@ save_state (EtApplicationWindow *self)
                             priv->height);
     g_key_file_set_boolean (keyfile, "EtApplicationWindow", "is_maximized",
                             priv->is_maximized);
+    g_key_file_set_integer (keyfile, "EtApplicationWindow", "paned_position",
+                            gtk_paned_get_position (GTK_PANED (priv->hpaned)));
+
 
     /* TODO; Use g_key_file_save_to_file() in GLib 2.40. */
     buffer = g_key_file_to_data (keyfile, &length, NULL);
@@ -170,6 +173,7 @@ restore_state (EtApplicationWindow *self)
     GKeyFile *keyfile;
     gchar *path;
     GError *error = NULL;
+    gint paned_position;
 
     priv = et_application_window_get_instance_private (self);
     window = GTK_WINDOW (self);
@@ -198,6 +202,8 @@ restore_state (EtApplicationWindow *self)
     priv->is_maximized = g_key_file_get_boolean (keyfile,
                                                  "EtApplicationWindow",
                                                  "is_maximized", NULL);
+    paned_position = g_key_file_get_integer (keyfile, "EtApplicationWindow",
+                                             "paned_position", NULL);
 
     gtk_window_set_default_size (window, priv->width, priv->height);
 
@@ -205,6 +211,11 @@ restore_state (EtApplicationWindow *self)
     {
         gtk_window_maximize (window);
     }
+
+    if (paned_position > 0)
+    {
+        gtk_paned_set_position (GTK_PANED (priv->hpaned), paned_position);
+    }
 }
 
 static gboolean
@@ -3131,8 +3142,6 @@ et_application_window_init (EtApplicationWindow *self)
     g_signal_connect (self, "window-state-event",
                       G_CALLBACK (on_window_state_event), NULL);
 
-    restore_state (self);
-
     /* Mainvbox for Menu bar + Tool bar + "Browser Area & FileArea & TagArea" + Log Area + "Status bar & 
Progress bar" */
     main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
     gtk_container_add (GTK_CONTAINER (self), main_vbox);
@@ -3180,9 +3189,6 @@ et_application_window_init (EtApplicationWindow *self)
     vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
     gtk_paned_pack2 (GTK_PANED (priv->hpaned), vbox, FALSE, FALSE);
 
-    /* TODO: Set a sensible default size for both widgets in the paned. */
-    gtk_paned_set_position (GTK_PANED (priv->hpaned), 600);
-
     /* File */
     priv->file_area = create_file_area ();
     gtk_box_pack_start (GTK_BOX (vbox), priv->file_area, FALSE, FALSE, 0);
@@ -3215,6 +3221,8 @@ et_application_window_init (EtApplicationWindow *self)
     widget = Create_Progress_Bar ();
     gtk_box_pack_end (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
 
+    restore_state (self);
+
     gtk_widget_show_all (GTK_WIDGET (main_vbox));
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]