[easytag/wip/gsettings: 14/21] Store load filenames window position in GSettings



commit f00ae94051a982b05c0ad0e4c6762c5f52ba7e24
Author: David King <amigadave amigadave com>
Date:   Sun Mar 3 11:22:09 2013 +0000

    Store load filenames window position in GSettings

 src/misc.c    |   38 ++++++++++++++++++++++++++------------
 src/setting.c |   13 -------------
 src/setting.h |    6 ------
 3 files changed, 26 insertions(+), 31 deletions(-)
---
diff --git a/src/misc.c b/src/misc.c
index 066f78a..f8fecaf 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -2776,7 +2776,14 @@ void Open_Load_Filename_Window (void)
 
     // Just center on mainwindow
     gtk_window_set_position(GTK_WINDOW(LoadFilenameWindow), GTK_WIN_POS_CENTER_ON_PARENT);
-    
gtk_window_set_default_size(GTK_WINDOW(LoadFilenameWindow),LOAD_FILE_WINDOW_WIDTH,LOAD_FILE_WINDOW_HEIGHT);
+    {
+        gint width, height;
+
+        g_settings_get (ETSettings, "load-filenames-position", "(iiii)", NULL,
+                        NULL, &width, &height);
+        gtk_window_set_default_size (GTK_WINDOW (LoadFilenameWindow), width,
+                                     height);
+    }
 
     Frame = gtk_frame_new(NULL);
     gtk_container_add(GTK_CONTAINER(LoadFilenameWindow),Frame);
@@ -3075,8 +3082,16 @@ void Open_Load_Filename_Window (void)
     g_signal_emit_by_name(G_OBJECT(gtk_bin_get_child(GTK_BIN(FileToLoadCombo))),"changed");
 
     gtk_widget_show_all(LoadFilenameWindow);
-    if (LOAD_FILE_WINDOW_X > 0 && LOAD_FILE_WINDOW_Y > 0)
-        gtk_window_move(GTK_WINDOW(LoadFilenameWindow),LOAD_FILE_WINDOW_X,LOAD_FILE_WINDOW_Y);
+    {
+        gint x, y;
+
+        g_settings_get (ETSettings, "load-filenames-position", "(iiii)", &x,
+                        &y, NULL, NULL);
+        if (x > 0 && y > 0)
+        {
+            gtk_window_move (GTK_WINDOW (LoadFilenameWindow), x, y);
+        }
+    }
 }
 
 static void
@@ -3101,21 +3116,20 @@ void Load_Filename_Window_Apply_Changes (void)
 {
     if (LoadFilenameWindow)
     {
-        gint x, y, width, height;
         GdkWindow *window;
 
         window = gtk_widget_get_window (LoadFilenameWindow);
 
         if ( window && gdk_window_is_visible(window) && 
gdk_window_get_state(window)!=GDK_WINDOW_STATE_MAXIMIZED )
         {
-            // Position and Origin of the window
-            gdk_window_get_root_origin(window,&x,&y);
-            LOAD_FILE_WINDOW_X = x;
-            LOAD_FILE_WINDOW_Y = y;
-            width = gdk_window_get_width(window);
-            height = gdk_window_get_height(window);
-            LOAD_FILE_WINDOW_WIDTH  = width;
-            LOAD_FILE_WINDOW_HEIGHT = height;
+            gint x, y, width, height;
+
+            /* Position and Origin of the 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, "load-filenames-position", "(iiii)", x,
+                            y, width, height);
         }
     }
 }
diff --git a/src/setting.c b/src/setting.c
index e409922..aff34d4 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -170,11 +170,6 @@ tConfigVariable Config_Variables[] =
     {"playlist_content_mask",                   CV_TYPE_BOOL,    &PLAYLIST_CONTENT_MASK                  },
     {"playlist_content_mask_value",             CV_TYPE_STRING,  &PLAYLIST_CONTENT_MASK_VALUE            },
 
-    {"load_file_window_x",                      CV_TYPE_INT,     &LOAD_FILE_WINDOW_X                     },
-    {"load_file_window_y",                      CV_TYPE_INT,     &LOAD_FILE_WINDOW_Y                     },
-    {"load_file_window_width",                  CV_TYPE_INT,     &LOAD_FILE_WINDOW_WIDTH                 },
-    {"load_file_window_height",                 CV_TYPE_INT,     &LOAD_FILE_WINDOW_HEIGHT                },
-
     {"cddb_local_path",                         CV_TYPE_STRING,  &CDDB_LOCAL_PATH                        },
 
     {"cddb_search_in_artist_field",             CV_TYPE_BOOL,    &CDDB_SEARCH_IN_ARTIST_FIELD            },
@@ -334,14 +329,6 @@ void Init_Config_Variables (void)
     PLAYLIST_CONTENT_MASK_VALUE     = g_strdup("%n/%l - %a - %b - %t");
 
     /*
-     * Load File window
-     */
-    LOAD_FILE_WINDOW_X        = -1;
-    LOAD_FILE_WINDOW_Y        = -1;
-    LOAD_FILE_WINDOW_WIDTH    = -1;
-    LOAD_FILE_WINDOW_HEIGHT   = -1;
-
-    /*
      * CDDB window
      */
     CDDB_LOCAL_PATH                         = NULL;
diff --git a/src/setting.h b/src/setting.h
index c887e77..3b3d4ee 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -121,12 +121,6 @@ gint    PLAYLIST_CONTENT_FILENAME;
 gint    PLAYLIST_CONTENT_MASK;
 gchar  *PLAYLIST_CONTENT_MASK_VALUE;
 
-/* "Load filenames from txt" window */
-gint    LOAD_FILE_WINDOW_X;
-gint    LOAD_FILE_WINDOW_Y;
-gint    LOAD_FILE_WINDOW_WIDTH;
-gint    LOAD_FILE_WINDOW_HEIGHT;
-
 /* CDDB in preferences window */
 gchar  *CDDB_LOCAL_PATH;
 


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