[easytag/wip/gsettings: 7/23] Store GtkPaned positions in GSettings



commit 0384556c47f2df7b43a0a753896ceeabd2548677
Author: David King <amigadave amigadave com>
Date:   Sat Mar 2 23:32:24 2013 +0000

    Store GtkPaned positions in GSettings

 src/browser.c |   16 ++++++++++++++--
 src/easytag.c |   29 +++++++++++++++++++++--------
 src/setting.c |   10 ----------
 src/setting.h |    5 -----
 4 files changed, 35 insertions(+), 25 deletions(-)
---
diff --git a/src/browser.c b/src/browser.c
index 7912f4a..4ec8114 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -3317,7 +3317,13 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
 
     gtk_paned_pack1(GTK_PANED(ArtistAlbumVPaned),ScrollWindowArtistList,TRUE,TRUE); // Top side
     gtk_paned_pack2(GTK_PANED(ArtistAlbumVPaned),ScrollWindowAlbumList,TRUE,TRUE);   // Bottom side
-    gtk_paned_set_position(GTK_PANED(ArtistAlbumVPaned),PANE_HANDLE_POSITION3);
+    {
+        gint pos3;
+
+        g_settings_get (ETSettings, "pane-positions", "(uuuu)", NULL, NULL,
+                        &pos3, NULL);
+        gtk_paned_set_position (GTK_PANED (ArtistAlbumVPaned), pos3);
+    }
 
 
     /*
@@ -3603,7 +3609,13 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
     gtk_box_pack_start(GTK_BOX(VerticalBox),BrowserHPaned,TRUE,TRUE,0);
     gtk_paned_pack1(GTK_PANED(BrowserHPaned),BrowserNoteBook,TRUE,TRUE);   // Left side
     gtk_paned_pack2(GTK_PANED(BrowserHPaned),ScrollWindowFileList,TRUE,TRUE); // Right side
-    gtk_paned_set_position(GTK_PANED(BrowserHPaned),PANE_HANDLE_POSITION2);
+    {
+        gint pos2;
+
+        g_settings_get (ETSettings, "pane-positions", "(uuuu)", NULL, &pos2,
+                        NULL, NULL);
+        gtk_paned_set_position (GTK_PANED (BrowserHPaned), pos2);
+    }
 
     gtk_widget_show_all(VerticalBox);
 
diff --git a/src/easytag.c b/src/easytag.c
index b540081..4021978 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -389,7 +389,13 @@ activate (GApplication *application, gpointer user_data)
     /* The two panes: BrowserArea on the left, FileArea+TagArea on the right */
     MainWindowHPaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
     //gtk_box_pack_start(GTK_BOX(MainVBox),MainWindowHPaned,TRUE,TRUE,0);
-    gtk_paned_set_position(GTK_PANED(MainWindowHPaned),PANE_HANDLE_POSITION1);
+    {
+        gint pos1;
+
+        g_settings_get (ETSettings, "pane-positions", "(uuuu)", &pos1, NULL,
+                        NULL, NULL);
+        gtk_paned_set_position (GTK_PANED (MainWindowHPaned), pos1);
+    }
     gtk_widget_show(MainWindowHPaned);
 
     /* Browser (Tree + File list + Entry) */
@@ -413,7 +419,12 @@ activate (GApplication *application, gpointer user_data)
     MainWindowVPaned = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
     gtk_box_pack_start(GTK_BOX(MainVBox),MainWindowVPaned,TRUE,TRUE,0);
     gtk_paned_pack1(GTK_PANED(MainWindowVPaned),MainWindowHPaned,TRUE,FALSE);
-    gtk_paned_set_position(GTK_PANED(MainWindowVPaned),PANE_HANDLE_POSITION4);
+    {
+        gint pos4;
+        g_settings_get (ETSettings, "pane-positions", "(uuuu)", NULL, NULL,
+                        NULL, &pos4);
+        gtk_paned_set_position (GTK_PANED (MainWindowVPaned), pos4);
+    }
     gtk_widget_show(MainWindowVPaned);
 
 
@@ -5010,6 +5021,7 @@ void MainWindow_Apply_Changes (void)
     if ( window && gdk_window_is_visible(window) && gdk_window_get_state(window)!=GDK_WINDOW_STATE_MAXIMIZED 
)
     {
         gint x, y, width, height;
+       gint pos1, pos2, pos3, pos4;
 
         /* Position and Origin of the window. */
         gdk_window_get_root_origin(window,&x,&y);
@@ -5018,11 +5030,12 @@ void MainWindow_Apply_Changes (void)
         g_settings_set (ETSettings, "window-location", "(iiii)", x, y, width,
                         height);
 
-        // Handle panes position
-        PANE_HANDLE_POSITION1 = gtk_paned_get_position(GTK_PANED(MainWindowHPaned));
-        PANE_HANDLE_POSITION2 = gtk_paned_get_position(GTK_PANED(BrowserHPaned));
-        PANE_HANDLE_POSITION3 = gtk_paned_get_position(GTK_PANED(ArtistAlbumVPaned));
-        PANE_HANDLE_POSITION4 = gtk_paned_get_position(GTK_PANED(MainWindowVPaned));
+        /* Handle panes position. */
+        pos1 = gtk_paned_get_position (GTK_PANED (MainWindowHPaned));
+        pos2 = gtk_paned_get_position (GTK_PANED (BrowserHPaned));
+        pos3 = gtk_paned_get_position (GTK_PANED (ArtistAlbumVPaned));
+        pos4 = gtk_paned_get_position (GTK_PANED (MainWindowVPaned));
+        g_settings_set (ETSettings, "pane-positions", "(uuuu)", pos1, pos2,
+                        pos3, pos4);
     }
-
 }
diff --git a/src/setting.c b/src/setting.c
index 7caecbc..2c3ddf8 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -111,11 +111,6 @@ tConfigVariable Config_Variables[] =
 {
     {"default_path_to_mp3",                 CV_TYPE_STRING,  &DEFAULT_PATH_TO_MP3               },
 
-    {"pane_handle_position1",               CV_TYPE_INT,     &PANE_HANDLE_POSITION1             },
-    {"pane_handle_position2",               CV_TYPE_INT,     &PANE_HANDLE_POSITION2             },
-    {"pane_handle_position3",               CV_TYPE_INT,     &PANE_HANDLE_POSITION3             },
-    {"pane_handle_position4",               CV_TYPE_INT,     &PANE_HANDLE_POSITION4             },
-
     {"sorting_file_mode",                    CV_TYPE_INT,     &SORTING_FILE_MODE                        },
     {"sorting_file_case_sensitive",          CV_TYPE_BOOL,    &SORTING_FILE_CASE_SENSITIVE              },
 
@@ -253,11 +248,6 @@ void Init_Config_Variables (void)
     /*
      * Misc
      */
-    PANE_HANDLE_POSITION1           = 660;
-    PANE_HANDLE_POSITION2           = 360;
-    PANE_HANDLE_POSITION3           = 300;
-    PANE_HANDLE_POSITION4           = 300;
-
     SORTING_FILE_MODE                       = SORTING_BY_ASCENDING_FILENAME;
 #ifdef G_OS_WIN32
     SORTING_FILE_CASE_SENSITIVE             = 1;
diff --git a/src/setting.h b/src/setting.h
index ceb0fd3..4ba69e6 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -55,11 +55,6 @@ gchar  *DEFAULT_PATH_TO_MP3;
 
 /* Misc */
 /* User Interface. */
-gint    PANE_HANDLE_POSITION1;
-gint    PANE_HANDLE_POSITION2;
-gint    PANE_HANDLE_POSITION3;
-gint    PANE_HANDLE_POSITION4;
-
 gint    SORTING_FILE_MODE;
 gint    SORTING_FILE_CASE_SENSITIVE;
 


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