[easytag/wip/gsettings: 25/35] Store preferences window location in GSettings



commit 1ad49a522cb86fe5d458b0007bb05fef2c187f2a
Author: David King <amigadave amigadave com>
Date:   Sun Mar 3 13:51:17 2013 +0000

    Store preferences window location in GSettings

 src/prefs.c   |   27 ++++++++++++++++-----------
 src/setting.c |   11 -----------
 src/setting.h |    6 ------
 3 files changed, 16 insertions(+), 28 deletions(-)
---
diff --git a/src/prefs.c b/src/prefs.c
index 94795a8..503843f 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -108,7 +108,14 @@ void Open_OptionsWindow (void)
     gtk_window_set_position(GTK_WINDOW(OptionsWindow),GTK_WIN_POS_CENTER);
     gtk_window_set_transient_for(GTK_WINDOW(OptionsWindow),GTK_WINDOW(MainWindow));
     gtk_container_set_border_width(GTK_CONTAINER(OptionsWindow), 5);
-    gtk_window_set_default_size(GTK_WINDOW(OptionsWindow),OPTIONS_WINDOW_WIDTH,OPTIONS_WINDOW_HEIGHT);
+    {
+        gint width, height;
+
+        g_settings_get (ETSettings, "preferences-location", "(iiii)", NULL,
+                        NULL, &width, &height);
+        gtk_window_set_default_size (GTK_WINDOW (OptionsWindow), width,
+                                     height);
+    }
     /* Title */
     gtk_window_set_title(GTK_WINDOW(OptionsWindow),_("Preferences…"));
 
@@ -1735,22 +1742,20 @@ void OptionsWindow_Apply_Changes (void)
 {
     if (OptionsWindow)
     {
-        //gint x, y;
-        gint width, height;
         GdkWindow *window;
 
         window = gtk_widget_get_window(OptionsWindow);
 
         if ( window && gdk_window_is_visible(window) && 
gdk_window_get_state(window)!=GDK_WINDOW_STATE_MAXIMIZED )
         {
-            // Position and Origin of the preferences window
-            //gdk_window_get_root_origin(OptionsWindow->window,&x,&y);
-            //OPTIONS_WINDOW_X = x;
-            //OPTIONS_WINDOW_Y = y;
-            width = gdk_window_get_width(window);
-            height = gdk_window_get_height(window);
-            OPTIONS_WINDOW_WIDTH  = width;
-            OPTIONS_WINDOW_HEIGHT = height;
+            gint x, y, width, height;
+
+            /* Position and Origin of the preferences window. */
+            gdk_window_get_root_origin(window, &x, &y);
+            width = gdk_window_get_width (window);
+            height = gdk_window_get_height (window);
+            g_settings_set (ETSettings, "preferences-location", "(iiii)", x, y,
+                            width, height);
         }
 
         /* Save combobox history lists before exit */
diff --git a/src/setting.c b/src/setting.c
index 01b70b4..910594f 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -194,10 +194,6 @@ tConfigVariable Config_Variables[] =
     {"scan_tag_default_mask",                   CV_TYPE_STRING,  &SCAN_TAG_DEFAULT_MASK                  },
     {"rename_file_default_mask",                CV_TYPE_STRING,  &RENAME_FILE_DEFAULT_MASK               },
     {"rename_directory_default_mask",           CV_TYPE_STRING,  &RENAME_DIRECTORY_DEFAULT_MASK          },
-
-    {"options_window_height",                   CV_TYPE_INT,     &OPTIONS_WINDOW_HEIGHT                  },
-    {"options_window_width",                    CV_TYPE_INT,     &OPTIONS_WINDOW_WIDTH                   }
-
 };
 
 
@@ -347,13 +343,6 @@ void Init_Config_Variables (void)
     SCAN_TAG_DEFAULT_MASK           = NULL;
     RENAME_FILE_DEFAULT_MASK        = NULL;
     RENAME_DIRECTORY_DEFAULT_MASK   = NULL;
-
-    /*
-     * Other parameters
-     */
-    OPTIONS_WINDOW_HEIGHT = 300;
-    OPTIONS_WINDOW_WIDTH  = 400;
-
 }
 
 
diff --git a/src/setting.h b/src/setting.h
index 33d598b..6befea0 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -151,12 +151,6 @@ gchar  *RENAME_FILE_DEFAULT_MASK;
 gchar  *RENAME_DIRECTORY_DEFAULT_MASK;
 
 
-/* Other parameters */
-gint    OPTIONS_WINDOW_HEIGHT;
-gint    OPTIONS_WINDOW_WIDTH;
-
-
-
 /**************
  * Prototypes *
  **************/


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