[metacity/matching] persistence



commit cd0d04ea9a03b3c99c30b4b1c77e7cef00efd3b4
Author: Thomas Thurman <tthurman gnome org>
Date:   Fri Jul 10 09:19:49 2009 -0400

    persistence

 src/core/matching.c |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/src/core/matching.c b/src/core/matching.c
index 78e7e3a..883be52 100644
--- a/src/core/matching.c
+++ b/src/core/matching.c
@@ -35,6 +35,13 @@
  * This is just for an example and may change.
  */
 GKeyFile *matching_keyfile = NULL;
+gchar *matching_keyfile_filename = NULL;
+
+static void
+matching_ensure_filename (void)
+{
+  matching_keyfile_filename = g_strdup ("/tmp/metacity-matching-2.conf");
+}
 
 static void
 load_matching_data (void)
@@ -42,9 +49,20 @@ load_matching_data (void)
   if (matching_keyfile)
     return;
 
-  /* load it, or... (stub) */
   matching_keyfile = g_key_file_new ();
-  /* FIXME: would be helpful to add a leading comment */
+  matching_ensure_filename ();
+
+  if (!g_key_file_load_from_file (matching_keyfile,
+                                 matching_keyfile_filename,
+                                 G_KEY_FILE_KEEP_COMMENTS,
+                                 NULL))
+    {
+      /* couldn't load, so prep the empty one for first use */
+      g_key_file_set_comment (matching_keyfile,
+                              NULL, NULL,
+                              "A set of window positions used by Metacity.",
+                              NULL);
+    }
 }
 
 static gchar*
@@ -79,6 +97,7 @@ meta_matching_load_from_role (MetaWindow *window)
   w = g_key_file_get_integer (matching_keyfile, role, "w", NULL);
   h = g_key_file_get_integer (matching_keyfile, role, "h", NULL);
 
+  /* FIXME this sets the position of the *client* window, not the frame */
   meta_window_move_resize (window,
                            FALSE,
                            x, y, w, h);
@@ -111,10 +130,11 @@ meta_matching_save_all (void)
   char *data = NULL;
 
   load_matching_data ();
-
+  matching_ensure_filename ();
+  
   data = g_key_file_to_data (matching_keyfile, NULL, NULL);
 
-  g_file_set_contents ("/tmp/metacity-matching.conf",
+  g_file_set_contents (matching_keyfile_filename,
                        data,
                        -1,
                        NULL);



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