[easytag/wip/gsettings: 3/5] Store location of main window in GSettings



commit 483d475c747e1301aedfb5f3d4382f39882e82be
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 ff3c150..b612ffa 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -350,8 +350,14 @@ int main (int argc, char *argv[])
     MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     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);
@@ -423,7 +429,13 @@ int main (int argc, char *argv[])
     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 */
@@ -5086,14 +5098,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 ad37198..e7d8b61 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             },
@@ -266,10 +262,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;
@@ -572,7 +564,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 af16e0d..d994b6a 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]