[gnome-terminal] profile: Remove all keys when removing the profile



commit b14ea4f00f61adc29b10af919ac02e7f69be92d6
Author: Christian Persch <chpe gnome org>
Date:   Sat Dec 15 22:41:45 2012 +0100

    profile: Remove all keys when removing the profile
    
    Use dconf directly to unset all the profile's keys when removing the profile.

 configure.ac       |    2 +-
 src/terminal-app.c |   28 +++++++++++++++++-----------
 2 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fcef150..5f22967 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,7 +38,7 @@ AM_GLIB_GNU_GETTEXT
 GLIB_REQUIRED=2.32.0
 GIO_REQUIRED=2.33.2
 GSETTINGS_DESKTOP_SCHEMAS_REQUIRED=0.1.0
-DCONF_REQUIRED=0.13.4
+DCONF_REQUIRED=0.12.0
 
 AC_MSG_CHECKING([which gtk+ version to compile against])
 AC_ARG_WITH([gtk],
diff --git a/src/terminal-app.c b/src/terminal-app.c
index 2086fd0..162ba40 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -45,6 +45,7 @@
 #include <time.h>
 
 #include <uuid.h>
+#include <dconf.h>
 
 #define DESKTOP_INTERFACE_SETTINGS_SCHEMA       "org.gnome.desktop.interface"
 
@@ -173,16 +174,15 @@ static char **
 strv_remove (char **strv,
              char *str)
 {
-  guint i;
-
-  for (i = 0; strv[i]; i++) {
-    if (strcmp (strv[i], str) != 0)
-      continue;
+  char **a, **b;
 
-    for ( ; strv[i]; i++)
-      strv[i] = strv[i+1];
-    strv[i-1] = NULL;
+  a = b = strv;
+  while (*a) {
+    if (strcmp (*a, str) != 0)
+      *b++ = *a;
+    a++;
   }
+  *b = NULL;
 
   return strv;
 }
@@ -271,19 +271,25 @@ static void
 profile_remove (TerminalApp *app,
                 GSettings *profile)
 {
-  char *uuid;
+  char *uuid, *path;
   char **profiles;
+  DConfClient *client;
 
   uuid = profile_get_uuid (profile);
+  g_object_get (profile, "path", &path, NULL);
 
   g_settings_get (app->global_settings, TERMINAL_SETTING_PROFILES_KEY, "^a&s", &profiles);
   profiles = strv_remove (profiles, uuid);
   g_settings_set_strv (app->global_settings, TERMINAL_SETTING_PROFILES_KEY, (const char * const *) profiles);
   g_free (profiles);
 
-  g_free (uuid);
+  /* unset all keys under the profile's path */
+  client = dconf_client_new (NULL, NULL, NULL, NULL);
+  dconf_client_write (client, path, NULL, NULL, NULL, NULL);
+  g_object_unref (client);
 
-  /* FIXME: recursively unset all keys under the profile's path? */
+  g_free (uuid);
+  g_free (path);
 }
 
 static void



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