[easytag/wip/gsettings: 9/25] Store location of main window in GSettings



commit 0cbe9f0ec9e46c38e0f2f70b16d0472cc747b429
Author: David King <amigadave amigadave com>
Date:   Sat Mar 2 23:02:00 2013 +0000

    Store location of main window in GSettings

 src/easytag.c |   26 ++++++++++++++++++--------
 src/setting.c |   11 ++---------
 src/setting.h |    4 ----
 3 files changed, 20 insertions(+), 21 deletions(-)
---
diff --git a/src/easytag.c b/src/easytag.c
index 8c2f414..ddce12f 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -359,8 +359,14 @@ activate (GApplication *application, gpointer user_data)
                                GTK_WINDOW (MainWindow));
     gtk_window_set_title (GTK_WINDOW (MainWindow),
                           PACKAGE_NAME " " PACKAGE_VERSION);
-    // This part is needed to set correctly the position of handle panes
-    gtk_window_set_default_size(GTK_WINDOW(MainWindow),MAIN_WINDOW_WIDTH,MAIN_WINDOW_HEIGHT);
+    /* This part is needed to correctly set the position of handle panes. */
+    {
+        int width, height;
+
+        g_settings_get (ETSettings, "window-location", "(iiii)", NULL, NULL,
+                        &width, &height);
+        gtk_window_set_default_size (GTK_WINDOW (MainWindow), width, height);
+    }
 
     g_signal_connect(G_OBJECT(MainWindow),"delete_event",G_CALLBACK(Quit_MainWindow),NULL);
     g_signal_connect(G_OBJECT(MainWindow),"destroy",G_CALLBACK(Quit_MainWindow),NULL);
@@ -432,7 +438,13 @@ activate (GApplication *application, gpointer user_data)
     gtk_widget_show(MainWindow);
 
     if (g_settings_get_boolean (ETSettings, "remember-location"))
-        gtk_window_move(GTK_WINDOW(MainWindow), MAIN_WINDOW_X, MAIN_WINDOW_Y);
+    {
+        int x, y;
+
+        g_settings_get (ETSettings, "window-location", "(iiii)", &x, &y, NULL,
+                        NULL);
+        gtk_window_move (GTK_WINDOW (MainWindow), x, y);
+    }
 
     /* Load the default dir when the UI is created and displayed
      * to the screen and open also the scanner window */
@@ -5084,14 +5096,12 @@ void MainWindow_Apply_Changes (void)
     {
         gint x, y, width, height;
 
-        // Position and Origin of the window
+        /* Position and Origin of the window. */
         gdk_window_get_root_origin(window,&x,&y);
-        MAIN_WINDOW_X = x;
-        MAIN_WINDOW_Y = y;
         width = gdk_window_get_width(window);
         height = gdk_window_get_height(window);
-        MAIN_WINDOW_WIDTH  = width;
-        MAIN_WINDOW_HEIGHT = height;
+        g_settings_set (ETSettings, "window-location", "(iiii)", x, y, width,
+                        height);
 
         // Handle panes position
         PANE_HANDLE_POSITION1 = gtk_paned_get_position(GTK_PANED(MainWindowHPaned));
diff --git a/src/setting.c b/src/setting.c
index ba41e87..7caecbc 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -111,10 +111,6 @@ tConfigVariable Config_Variables[] =
 {
     {"default_path_to_mp3",                 CV_TYPE_STRING,  &DEFAULT_PATH_TO_MP3               },
 
-    {"main_window_x",                       CV_TYPE_INT,     &MAIN_WINDOW_X                     },
-    {"main_window_y",                       CV_TYPE_INT,     &MAIN_WINDOW_Y                     },
-    {"main_window_height",                  CV_TYPE_INT,     &MAIN_WINDOW_HEIGHT                },
-    {"main_window_width",                   CV_TYPE_INT,     &MAIN_WINDOW_WIDTH                 },
     {"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             },
@@ -257,10 +253,6 @@ void Init_Config_Variables (void)
     /*
      * Misc
      */
-    MAIN_WINDOW_X                   = -1; // '-1' lets the Windows Manager to place the window
-    MAIN_WINDOW_Y                   = -1;
-    MAIN_WINDOW_WIDTH               = 1040;
-    MAIN_WINDOW_HEIGHT              = -1;
     PANE_HANDLE_POSITION1           = 660;
     PANE_HANDLE_POSITION2           = 360;
     PANE_HANDLE_POSITION3           = 300;
@@ -534,7 +526,8 @@ Apply_Changes_Of_UI (void)
      * Changes in user interface
      */
 
-    // Configuration of the main window (see easytag.c) - Function also called when destroying the window
+    /* Configuration of the main window (see easytag.c) - Function also called
+     * when destroying the window. */
     MainWindow_Apply_Changes();
 
     // Configuration of the preference window (see prefs.c) - Function also called when destroying the window
diff --git a/src/setting.h b/src/setting.h
index 4d99f81..ceb0fd3 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -55,10 +55,6 @@ gchar  *DEFAULT_PATH_TO_MP3;
 
 /* Misc */
 /* User Interface. */
-gint    MAIN_WINDOW_X;
-gint    MAIN_WINDOW_Y;
-gint    MAIN_WINDOW_HEIGHT;
-gint    MAIN_WINDOW_WIDTH;
 gint    PANE_HANDLE_POSITION1;
 gint    PANE_HANDLE_POSITION2;
 gint    PANE_HANDLE_POSITION3;


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