[gnome-terminal] profile: Build with newer DConf



commit 17240f7a2b36b717e1da26d9b431b9fff0cd76f4
Author: Christian Persch <chpe gnome org>
Date:   Mon Dec 17 16:06:17 2012 +0100

    profile: Build with newer DConf
    
    DConf broke API between 1.2 and 1.4 without changing its pkg-config name. Check
    for the API version in configure, and adapt the code. Only compile-tested not
    runtime-tested for dconf 1.4 !

 configure.ac       |    9 +++++++++
 src/terminal-app.c |   25 +++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8539d21..9f0fb43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,6 +85,15 @@ PKG_CHECK_MODULES([TERM],
    uuid
    $PLATFORM_DEPS])
 
+# DConf broke API without changing the pkgconfig name
+AC_MSG_CHECKING([old DConf])
+PKG_CHECK_EXISTS([dconf >= 0.14],[have_old_dconf=no],[have_old_dconf=yes])
+AC_MSG_RESULT([$have_old_dconf])
+
+if test "$have_old_dconf" = "yes"; then
+  AC_DEFINE([HAVE_DCONF_1_2],[1],[Define to 1 if DConf is version 1.2])
+fi
+
 # ****
 # DBus
 # ****
diff --git a/src/terminal-app.c b/src/terminal-app.c
index ae7b55b..5d85296 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -287,12 +287,20 @@ profile_clone (TerminalApp *app,
         TERMINAL_PROFILE_WORD_CHARS_KEY,
       };
       DConfClient *client;
+#ifndef HAVE_DCONF_1_2
+      DConfChangeset *changeset;
+#endif
       char *base_path;
       guint i;
 
       g_object_get (base_profile, "path", &base_path, NULL);
 
+#ifdef HAVE_DCONF_1_2
       client = dconf_client_new (NULL, NULL, NULL, NULL);
+#else
+      client = dconf_client_new ();
+      changeset = dconf_changeset_new ();
+#endif
 
       for (i = 0; i < G_N_ELEMENTS (keys); i++)
         {
@@ -300,18 +308,30 @@ profile_clone (TerminalApp *app,
           char *p;
 
           p = g_strconcat (base_path, keys[i], NULL);
+#ifdef HAVE_DCONF_1_2
           value = dconf_client_read_no_default (client, p);
+#else
+          value = dconf_client_read (client, p);
+#endif
           g_free (p);
 
           if (value)
             {
               p = g_strconcat (new_path, keys[i], NULL);
+#ifdef HAVE_DCONF_1_2
               dconf_client_write (client, p, value, NULL, NULL, NULL);
+#else
+              dconf_changeset_set (changeset, p, value);
+#endif
               g_free (p);
               g_variant_unref (value);
             }
         }
 
+#ifndef HAVE_DCONF_1_2
+      dconf_client_change_sync (client, changeset, NULL, NULL, NULL);
+      g_object_unref (changeset);
+#endif
       g_object_unref (client);
       g_free (base_path);
     }
@@ -361,8 +381,13 @@ profile_remove (TerminalApp *app,
   g_free (profiles);
 
   /* unset all keys under the profile's path */
+#ifdef HAVE_DCONF_1_2
   client = dconf_client_new (NULL, NULL, NULL, NULL);
   dconf_client_write (client, path, NULL, NULL, NULL, NULL);
+#else /* modern DConf */
+  client = dconf_client_new ();
+  dconf_client_write_sync (client, path, NULL, NULL, NULL, NULL);
+#endif
   g_object_unref (client);
 
   g_free (uuid);



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