[gnome-settings-daemon] gconf: Add GConf<->GSettings bridge plugin



commit 5fe87fde4866b420073c3787eb645715df6f8806
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Fri Oct 22 13:37:36 2010 +0200

    gconf: Add GConf<->GSettings bridge plugin

 configure.ac                      |   28 +++++++++++
 plugins/Makefile.am               |    6 ++
 plugins/gconf/Makefile.am         |   34 +++++++++++++
 plugins/gconf/gsd-gconf-manager.c |   19 +++++++
 plugins/gconf/gsd-gconf-manager.h |   57 ++++++++++++++++++++++
 plugins/gconf/gsd-gconf-plugin.c  |   95 +++++++++++++++++++++++++++++++++++++
 plugins/gconf/gsd-gconf-plugin.h  |   59 +++++++++++++++++++++++
 7 files changed, 298 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9228ad4..6d791d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -224,6 +224,32 @@ PKG_CHECK_MODULES(GIOUNIX, [gio-unix-2.0])
 AC_SUBST(GIOUNIX_CFLAGS)
 AC_SUBST(GIOUNIX_LIBS)
 
+dnl ---------------------------------------------------------------------------
+dnl - GConf<->Gsettings bridge
+dnl ---------------------------------------------------------------------------
+build_gconf_bridge=false
+AC_ARG_ENABLE(gconf-bridge,
+  AC_HELP_STRING([--disable-gconf-bridge],
+                 [turn off GConf bridge plugin]),
+      [case "${enableval}" in
+              yes) WANT_GCONF_BRIDGE=yes ;;
+	      no) WANT_GCONF_BRIDGE=no ;;
+	      *) AC_MSG_ERROR(bad value ${enableval} for --disable-gconf-bridge) ;;
+      [esac],
+      [WANT_GCONF_BRIDGE=no]) dnl Default value
+
+if test x$WANT_GCONF_BRIDGE = xyes; then
+      GCONF_REQUIRED_VERSION=2.6.1
+      PKG_CHECK_MODULES(GCONF, gconf-2.0 >= $GCONF_REQUIRED_VERSION,
+            [have_gconf=true
+             AC_DEFINE(BUILD_GCONF_BRIDGE, 1, [Define if GConf bridge should be built])],
+	    [have_gconf=false])
+fi
+AM_CONDITIONAL(BUILD_GCONF_BRIDGE, test "x$have_gconf" = "xtrue")
+
+AC_SUBST(GCONF_CFLAGS)
+AC_SUBST(GCONF_LIBS)
+
 dnl ==============================================
 dnl PulseAudio section
 dnl ==============================================
@@ -429,6 +455,7 @@ plugins/clipboard/Makefile
 plugins/common/Makefile
 plugins/datetime/Makefile
 plugins/dummy/Makefile
+plugins/gconf/Makefile
 plugins/housekeeping/Makefile
 plugins/keybindings/Makefile
 plugins/keyboard/Makefile
@@ -484,6 +511,7 @@ echo "
         Libnotify support:        ${have_libnotify}
         PulseAudio support:       ${have_pulse}
         Smartcard support:        ${have_smartcard_support}
+	GConf bridge support:     ${have_gconf}
 ${NSS_DATABASE:+\
         System nssdb:             ${NSS_DATABASE}
 }\
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index d17a9f6..78cd83e 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -19,6 +19,12 @@ enabled_plugins =	\
 
 disabled_plugins = $(NULL)
 
+if BUILD_GCONF_BRIDGE
+enabled_plugins += gconf
+else
+disabled_plugins += gconf
+fi
+
 if SMARTCARD_SUPPORT
 enabled_plugins += smartcard
 else
diff --git a/plugins/gconf/Makefile.am b/plugins/gconf/Makefile.am
new file mode 100644
index 0000000..0401361
--- /dev/null
+++ b/plugins/gconf/Makefile.am
@@ -0,0 +1,34 @@
+plugin_LTLIBRARIES = libgconf.la
+
+libgconf_la_SOURCES =		\
+	gsd-gconf-plugin.c	\
+	gsd-gconf-plugin.h	\
+	gsd-gconf-manager.c	\
+	gsd-gconf-manager.h
+
+libgconf_la_CPPFLAGS =						\
+	-I$(top_srcdir)/gnome-settings-daemon			\
+	-DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\"	\
+        -DLIBEXECDIR=\""$(libexecdir)"\"			\
+        $(AM_CPPFLAGS)
+
+libgconf_la_CFLAGS =			\
+	$(GCONF_CFLAGS)			\
+	$(SETTINGS_PLUGIN_CFLAGS)	\
+	$(AM_CFLAGS)
+
+libgconf_la_LDFLAGS = $(GSD_PLUGIN_LDFLAGS)
+
+libgconf_la_LIBADD =		\
+	$(GCONF_LIBS)		\
+	$(SETTINGS_PLUGIN_LIBS)
+
+plugin_in_files = gconf.gnome-settings-plugin.in
+
+plugins_DATA = $(plugin_in_files:.gnome-settings-plugin.in=.gnome-settings-plugin)
+
+EXTRA_DIST = $(plugin_in_files)
+CLEANFILES = $(plugin_DATA)
+DISTCLEANFILES = $(plugin_DATA)
+
+ GSD_INTLTOOL_PLUGIN_RULE@
\ No newline at end of file
diff --git a/plugins/gconf/gsd-gconf-manager.c b/plugins/gconf/gsd-gconf-manager.c
new file mode 100644
index 0000000..7d760eb
--- /dev/null
+++ b/plugins/gconf/gsd-gconf-manager.c
@@ -0,0 +1,19 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Rodrigo Moya <rodrigo gnome org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
diff --git a/plugins/gconf/gsd-gconf-manager.h b/plugins/gconf/gsd-gconf-manager.h
new file mode 100644
index 0000000..c55f4d0
--- /dev/null
+++ b/plugins/gconf/gsd-gconf-manager.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Rodrigo Moya <rodrigo gnome org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSD_GCONF_MANAGER_H
+#define __GSD_GCONF_MANAGER_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_GCONF_MANAGER         (gsd_gconf_manager_get_type ())
+#define GSD_GCONF_MANAGER(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_GCONF_MANAGER, GsdGconfManager))
+#define GSD_GCONF_MANAGER_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_GCONF_MANAGER, GsdGconfManagerClass))
+#define GSD_IS_GCONF_MANAGER(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_GCONF_MANAGER))
+#define GSD_IS_GCONF_MANAGER_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_GCONF_MANAGER))
+#define GSD_GCONF_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_GCONF_MANAGER, GsdGconfManagerClass))
+
+typedef struct GsdGconfManagerPrivate GsdGconfManagerPrivate;
+
+typedef struct
+{
+        GObject                     parent;
+        GsdGconfManagerPrivate *priv;
+} GsdGconfManager;
+
+typedef struct
+{
+        GObjectClass   parent_class;
+} GsdGconfManagerClass;
+
+GType                   gsd_gconf_manager_get_type            (void);
+
+GsdGconfManager *       gsd_gconf_manager_new                 (void);
+gboolean                gsd_gconf_manager_start               (GsdGconfManager *manager,
+                                                               GError         **error);
+void                    gsd_gconf_manager_stop                (GsdGconfManager *manager);
+
+G_END_DECLS
+
+#endif /* __GSD_GCONF_MANAGER_H */
diff --git a/plugins/gconf/gsd-gconf-plugin.c b/plugins/gconf/gsd-gconf-plugin.c
new file mode 100644
index 0000000..eae5378
--- /dev/null
+++ b/plugins/gconf/gsd-gconf-plugin.c
@@ -0,0 +1,95 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Rodrigo Moya <rodrigo gnome org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+#include <gmodule.h>
+#include "gnome-settings-plugin.h"
+#include "gsd-gconf-plugin.h"
+#include "gsd-gconf-manager.h"
+
+struct GsdGconfPluginPrivate {
+	GsdGconfManager *manager;
+};
+
+#define GSD_GCONF_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_GCONF_PLUGIN, GsdGconfPluginPrivate))
+
+GNOME_SETTINGS_PLUGIN_REGISTER(GsdGconfPlugin, gsd_gconf_plugin)
+
+static void
+gsd_gconf_plugin_init (GsdGconfPlugin *plugin)
+{
+	plugin->priv = GSD_GCONF_PLUGIN_GET_PRIVATE (plugin);
+	plugin->priv->manager = gsd_gconf_manager_new ();
+}
+
+static void
+gsd_gconf_plugin_finalize (GObject *object)
+{
+	GsdGconfPlugin *plugin;
+
+	plugin = GSD_GCONF_PLUGIN (object);
+
+	g_return_if_fail (plugin->priv != NULL);
+
+	if (plugin->priv->manager != NULL)
+		g_object_unref (plugin->priv->manager);
+
+	G_OBJECT_CLASS (gsd_gconf_plugin_parent_class)->finalize (object);
+}
+
+static void
+impl_activate (GnomeSettingsPlugin *plugin)
+{
+	gboolean res;
+	GError *error = NULL;
+
+	g_debug ("Starting GConf bridge plugin");
+	res = gsd_gconf_manager_start (GSD_GCONF_PLUGIN (plugin)->priv->manager, &error);
+	if (!res) {
+		g_warning ("Unable to start GConf manager: %s", error->message);
+		g_error_free (error);
+	}
+}
+
+static void
+impl_deactivate (GnomeSettingsPlugin *plugin)
+{
+	g_debug ("Stopping GConf bridge plugin");
+	gsd_gconf_manager_stop (GSD_GCONF_PLUGIN (plugin)->priv->manager);
+}
+
+static void
+gsd_gconf_plugin_class_init (GsdGconfPluginClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS (klass);
+
+	object_class->finalize = gsd_gconf_plugin_finalize;
+
+	plugin_class->activate = impl_activate;
+	plugin_class->deactivate = impl_deactivate;
+
+	g_type_class_add_private (klass, sizeof (GsdGconfPluginPrivate));
+}
+
+static void
+gsd_gconf_plugin_class_finalize (GsdGconfPluginClass *klass)
+{
+}
diff --git a/plugins/gconf/gsd-gconf-plugin.h b/plugins/gconf/gsd-gconf-plugin.h
new file mode 100644
index 0000000..0259adf
--- /dev/null
+++ b/plugins/gconf/gsd-gconf-plugin.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Rodrigo Moya <rodrigo gnome-db org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSD_GCONF_PLUGIN_H__
+#define __GSD_GCONF_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gmodule.h>
+
+#include "gnome-settings-plugin.h"
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_GCONF_PLUGIN                (gsd_gconf_plugin_get_type ())
+#define GSD_GCONF_PLUGIN(o)                  (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_GCONF_PLUGIN, GsdGconfPlugin))
+#define GSD_GCONF_PLUGIN_CLASS(k)            (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_GCONF_PLUGIN, GsdGconfPluginClass))
+#define GSD_IS_GCONF_PLUGIN(o)               (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_GCONF_PLUGIN))
+#define GSD_IS_GCONF_PLUGIN_CLASS(k)         (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_GCONF_PLUGIN))
+#define GSD_GCONF_PLUGIN_GET_CLASS(o)        (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_GCONF_PLUGIN, GsdGconfPluginClass))
+
+typedef struct GsdGconfPluginPrivate GsdGconfPluginPrivate;
+
+typedef struct
+{
+        GnomeSettingsPlugin    parent;
+        GsdGconfPluginPrivate *priv;
+} GsdGconfPlugin;
+
+typedef struct
+{
+        GnomeSettingsPluginClass parent_class;
+} GsdGconfPluginClass;
+
+GType   gsd_gconf_plugin_get_type            (void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT GType register_gnome_settings_plugin (GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __GSD_GCONF_PLUGIN_H__ */



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