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



commit c8c9e84f7327cbc8d36968e72e07dacc69e57b08
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 fd7ea4a..a4e6fa5 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…"));
 
@@ -1760,22 +1767,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 3934198..1263031 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -204,10 +204,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                   }
-
 };
 
 
@@ -366,13 +362,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 7e91fd8..215a1e5 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -160,12 +160,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]