Support dconf 0.13.4
authorfujiwarat <takao.fujiwara1@gmail.com>
Thu, 19 Jul 2012 00:57:01 +0000 (09:57 +0900)
committerfujiwarat <takao.fujiwara1@gmail.com>
Thu, 19 Jul 2012 00:57:01 +0000 (09:57 +0900)
TEST=Manually

Review URL: https://codereview.appspot.com/6426044

conf/dconf/Makefile.am
conf/dconf/config-private.h [new file with mode: 0644]
conf/dconf/config.c
conf/dconf/config.h [deleted file]
conf/dconf/main.c
configure.ac

index 148ba621f10cf345221614b2444ee0896d6c2334..f0e24b0a4552216f83cc215dc4cdde591e862ad4 100644 (file)
@@ -29,7 +29,7 @@ libexec_PROGRAMS = \
 ibus_dconf_SOURCES = \
        main.c \
        config.c \
-       config.h \
+       config-private.h \
        $(NULL)
 ibus_dconf_CFLAGS = \
        @GLIB2_CFLAGS@ \
diff --git a/conf/dconf/config-private.h b/conf/dconf/config-private.h
new file mode 100644 (file)
index 0000000..9ba4fd5
--- /dev/null
@@ -0,0 +1,56 @@
+/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
+/* vim:set et sts=4: */
+/* ibus - The Input Bus
+ * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
+ * Copyright (C) 2008-2010 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __CONFIG_DCONF_H__
+#define __CONFIG_DCONF_H__
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <ibus.h>
+#ifdef DCONF_0_13_4
+#  include <client/dconf-client.h>
+#  include <common/dconf-paths.h>
+#else
+#  include <dconf/dconf.h>
+#endif
+
+#define IBUS_TYPE_CONFIG_DCONF            \
+    (ibus_config_dconf_get_type ())
+#define IBUS_CONFIG_DCONF(obj)            \
+    (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_CONFIG_DCONF, IBusConfigDConf))
+#define IBUS_CONFIG_DCONF_CLASS(klass)     \
+    (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_CONFIG_DCONF, IBusConfigDConfClass))
+#define IBUS_IS_CONFIG_DCONF(obj)          \
+    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_CONFIG_DCONF))
+#define IBUS_IS_CONFIG_DCONF_CLASS(klass)  \
+    (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_CONFIG_DCONF))
+#define IBUS_CONFIG_DCONF_GET_CLASS(obj)   \
+    (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_CONFIG_DCONF, IBusConfigDConfClass))
+
+typedef struct _IBusConfigDConf IBusConfigDConf;
+typedef struct _IBusConfigDConfClass IBusConfigDConfClass;
+
+GType            ibus_config_dconf_get_type (void);
+IBusConfigDConf *ibus_config_dconf_new      (GDBusConnection *connection);
+
+#endif
index faca9328d8b5e276116fcabde80c1ddbea2168ba..44d70318f2b4a0a9b23825848214ef8bc86afefd 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <string.h>
 #include <ibus.h>
-#include "config.h"
+#include "config-private.h"
 
 #define DCONF_PREFIX "/desktop/ibus"
 #define DCONF_PRESERVE_NAME_PREFIXES_KEY \
@@ -159,12 +159,19 @@ static void
 _watch_func (DConfClient         *client,
              const gchar         *gpath,
              const gchar * const *items,
+#ifndef DCONF_0_13_4
              gint                 n_items,
+#endif
              const gchar         *tag,
              IBusConfigDConf     *config)
 {
     gchar **gkeys = NULL;
     gint i;
+#ifdef DCONF_0_13_4
+    gint n_items;
+
+    n_items = g_strv_length ((gchar **)items);
+#endif
 
     g_return_if_fail (gpath != NULL);
     g_return_if_fail (n_items >= 0);
@@ -231,6 +238,14 @@ static void
 ibus_config_dconf_init (IBusConfigDConf *config)
 {
     GVariant *variant;
+#ifdef DCONF_0_13_4
+    config->client = dconf_client_new ();
+
+    g_signal_connect (config->client, "changed",
+                      G_CALLBACK (_watch_func), config);
+
+    dconf_client_watch_fast (config->client, DCONF_PREFIX"/");
+#else
     GError *error;
 
     config->client = dconf_client_new ("ibus",
@@ -241,6 +256,7 @@ ibus_config_dconf_init (IBusConfigDConf *config)
     error = NULL;
     if (!dconf_client_watch (config->client, DCONF_PREFIX"/", NULL, &error))
         g_warning ("Can not watch dconf path %s", DCONF_PREFIX"/");
+#endif
 
     config->preserve_name_prefixes = NULL;
     variant = dconf_client_read (config->client,
@@ -265,9 +281,13 @@ static void
 ibus_config_dconf_destroy (IBusConfigDConf *config)
 {
     if (config->client) {
+#ifdef DCONF_0_13_4
+        dconf_client_unwatch_fast (config->client, DCONF_PREFIX"/");
+#else
         GError *error = NULL;
         if (!dconf_client_unwatch (config->client, DCONF_PREFIX"/", NULL, &error))
             g_warning ("Can not unwatch dconf path %s", DCONF_PREFIX"/");
+#endif
 
         g_object_unref (config->client);
         config->client = NULL;
@@ -307,12 +327,16 @@ ibus_config_dconf_set_value (IBusConfigService *config,
         g_free (gname);
     }
 
+#ifdef DCONF_0_13_4
+    retval = dconf_client_write_fast (client, gkey, value, error);
+#else
     retval = dconf_client_write (client,
                                  gkey,
                                  value,
                                  NULL,   /* tag */
                                  NULL,   /* cancellable */
                                  error);
+#endif
     g_free (gkey);
 
     return retval;
diff --git a/conf/dconf/config.h b/conf/dconf/config.h
deleted file mode 100644 (file)
index 9f602d6..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
-/* vim:set et sts=4: */
-/* ibus - The Input Bus
- * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
- * Copyright (C) 2008-2010 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __CONFIG_DCONF_H__
-#define __CONFIG_DCONF_H__
-
-#include <ibus.h>
-#include <dconf/dconf.h>
-
-#define IBUS_TYPE_CONFIG_DCONF            \
-    (ibus_config_dconf_get_type ())
-#define IBUS_CONFIG_DCONF(obj)            \
-    (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_CONFIG_DCONF, IBusConfigDConf))
-#define IBUS_CONFIG_DCONF_CLASS(klass)     \
-    (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_CONFIG_DCONF, IBusConfigDConfClass))
-#define IBUS_IS_CONFIG_DCONF(obj)          \
-    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_CONFIG_DCONF))
-#define IBUS_IS_CONFIG_DCONF_CLASS(klass)  \
-    (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_CONFIG_DCONF))
-#define IBUS_CONFIG_DCONF_GET_CLASS(obj)   \
-    (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_CONFIG_DCONF, IBusConfigDConfClass))
-
-typedef struct _IBusConfigDConf IBusConfigDConf;
-typedef struct _IBusConfigDConfClass IBusConfigDConfClass;
-
-GType            ibus_config_dconf_get_type (void);
-IBusConfigDConf *ibus_config_dconf_new      (GDBusConnection *connection);
-
-#endif
index 1b69baa3b2f6e27884dc1fb9d211415b119a7fb3..bffe9833bd29bf22941c29c44cc9aaa24b792af4 100644 (file)
@@ -23,7 +23,7 @@
 #include <ibus.h>
 #include <stdlib.h>
 #include <locale.h>
-#include "config.h"
+#include "config-private.h"
 
 static IBusBus *bus = NULL;
 static IBusConfigDConf *config = NULL;
index 8498efe2e9b3734f727c7952f8da51c89625d1d0..cc7d0e0cebd0617a60a9598f8da5d184ee428837 100644 (file)
@@ -327,6 +327,9 @@ if test x"$enable_dconf" = x"yes"; then
         [dconf >= 0.7.5], ,
         enable_dconf=no
     )
+    PKG_CHECK_EXISTS([dconf >= 0.13.4],
+        [AC_DEFINE(DCONF_0_13_4, TRUE, [dconf is 0.13.4 or later])],
+        [])
     # check glib-compile-schemas
     GLIB_GSETTINGS
 fi