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



commit 2192bc3b218df4ebe4cae7e9a182f088157ed6f3
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 7c3948f..7e020fc 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…"));
 
@@ -1762,22 +1769,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 caa81cd..4010ed0 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -201,10 +201,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                   }
-
 };
 
 
@@ -360,13 +356,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 8436839..3738296 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -157,12 +157,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]