[gnome-settings-daemon] gconf: Fix building



commit 54607e1aa4fe46bcea9983d6874f484832c402ac
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Fri Oct 22 16:41:07 2010 +0200

    gconf: Fix building

 plugins/gconf/Makefile.am                    |   11 +++--
 plugins/gconf/conf-watcher.c                 |   64 +++++++++++++++++++++++++
 plugins/gconf/conf-watcher.h                 |   55 +++++++++++++++++++++
 plugins/gconf/gconf.gnome-settings-plugin.in |    8 +++
 plugins/gconf/gsd-gconf-manager.c            |   66 +++++++++++++++++++++++++-
 plugins/gconf/gsd-gconf-manager.h            |    2 +-
 6 files changed, 200 insertions(+), 6 deletions(-)
---
diff --git a/plugins/gconf/Makefile.am b/plugins/gconf/Makefile.am
index 550a62c..31fb3c3 100644
--- a/plugins/gconf/Makefile.am
+++ b/plugins/gconf/Makefile.am
@@ -1,15 +1,18 @@
 plugin_LTLIBRARIES = libgconf.la
 
 libgconf_la_SOURCES =		\
+	conf-watcher.c		\
+	conf-watcher.h		\
 	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)"\"			\
+libgconf_la_CPPFLAGS =							\
+	-I$(top_srcdir)/gnome-settings-daemon				\
+	-DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\"		\
+	-DGCONF_SETTINGS_CONVERTDIR=\""$(datadir)/GConf/gsettings"\"	\
+        -DLIBEXECDIR=\""$(libexecdir)"\"				\
         $(AM_CPPFLAGS)
 
 libgconf_la_CFLAGS =			\
diff --git a/plugins/gconf/conf-watcher.c b/plugins/gconf/conf-watcher.c
new file mode 100644
index 0000000..32e572a
--- /dev/null
+++ b/plugins/gconf/conf-watcher.c
@@ -0,0 +1,64 @@
+/* -*- 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.
+ *
+ */
+
+#include "config.h"
+#include "conf-watcher.h"
+
+G_DEFINE_TYPE(ConfWatcher, conf_watcher, G_TYPE_OBJECT)
+
+static void
+conf_watcher_finalize (GObject *object)
+{
+	ConfWatcher *watcher = CONF_WATCHER (object);
+
+	if (watcher->settings_id != NULL)
+		g_free (watcher->settings_id);
+
+	if (watcher->keys_hash != NULL)
+		g_hash_table_destroy (watcher->keys_hash);
+
+	G_OBJECT_CLASS (conf_watcher_parent_class)->finalize (object);
+}
+
+static void
+conf_watcher_class_init (ConfWatcherClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = conf_watcher_finalize;
+}
+
+static void
+conf_watcher_init (ConfWatcher *watcher)
+{
+}
+
+ConfWatcher *
+conf_watcher_new (const gchar *settings_id, GHashTable *keys_hash)
+{
+	ConfWatcher *watcher;
+
+	g_return_val_if_fail (settings_id != NULL, NULL);
+	g_return_val_if_fail (keys_hash != NULL, NULL);
+
+	watcher = g_object_new (TYPE_CONF_WATCHER, NULL);
+
+	return watcher;
+}
diff --git a/plugins/gconf/conf-watcher.h b/plugins/gconf/conf-watcher.h
new file mode 100644
index 0000000..d86ffeb
--- /dev/null
+++ b/plugins/gconf/conf-watcher.h
@@ -0,0 +1,55 @@
+/* -*- 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 __CONF_WATCHER_H
+#define __CONF_WATCHER_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define TYPE_CONF_WATCHER         (conf_watcher_get_type ())
+#define CONF_WATCHER(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_CONF_WATCHER, ConfWatcher))
+#define CONF_WATCHER_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), TYPE_CONF_WATCHER, ConfWatcherClass))
+#define IS_CONF_WATCHER(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_CONF_WATCHER))
+#define IS_CONF_WATCHER_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_CONF_WATCHER))
+#define CONF_WATCHER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_CONF_WATCHER, ConfWatcherClass))
+
+typedef struct ConfWatcherPrivate ConfWatcherPrivate;
+
+typedef struct
+{
+        GObject parent;
+	gchar *settings_id;
+	GHashTable *keys_hash;
+} ConfWatcher;
+
+typedef struct
+{
+        GObjectClass   parent_class;
+} ConfWatcherClass;
+
+GType        conf_watcher_get_type (void);
+
+ConfWatcher *conf_watcher_new      (const gchar *settings_id, GHashTable *keys_hash);
+
+G_END_DECLS
+
+#endif /* __CONF_WATCHER_H */
diff --git a/plugins/gconf/gconf.gnome-settings-plugin.in b/plugins/gconf/gconf.gnome-settings-plugin.in
new file mode 100644
index 0000000..966d821
--- /dev/null
+++ b/plugins/gconf/gconf.gnome-settings-plugin.in
@@ -0,0 +1,8 @@
+[GNOME Settings Plugin]
+Module=gconf
+IAge=0
+_Name=GConf
+_Description=GConf/GSettings bridge
+Authors=Rodrigo Moya <rodrigo gnome org>
+Copyright=Copyright © 2010 
+Website=
diff --git a/plugins/gconf/gsd-gconf-manager.c b/plugins/gconf/gsd-gconf-manager.c
index dc0924f..fa57963 100644
--- a/plugins/gconf/gsd-gconf-manager.c
+++ b/plugins/gconf/gsd-gconf-manager.c
@@ -19,11 +19,13 @@
  */
 
 #include "config.h"
+#include "conf-watcher.h"
 #include "gsd-gconf-manager.h"
 
 #define GSD_GCONF_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_GCONF_MANAGER, GsdGconfManagerPrivate))
 
 struct GsdGconfManagerPrivate {
+	GHashTable *conf_watchers;
 };
 
 GsdGconfManager *manager_object = NULL;
@@ -37,6 +39,9 @@ gsd_gconf_manager_finalize (GObject *object)
 
 	g_return_if_fail (manager->priv != NULL);
 
+	if (manager->priv->conf_watchers != NULL)
+		g_hash_table_destroy (manager->priv->conf_watchers);
+
 	G_OBJECT_CLASS (gsd_gconf_manager_parent_class)->finalize (object);
 }
 
@@ -63,7 +68,7 @@ gsd_gconf_manager_new (void)
 		g_object_ref (manager_object);
 	} else {
 		manager_object = g_object_new (GSD_TYPE_GCONF_MANAGER, NULL);
-		g_object_add_weak_pointer (manager_object,
+		g_object_add_weak_pointer ((gpointer) manager_object,
 					   (gpointer *) &manager_object);
 	}
 
@@ -73,9 +78,68 @@ gsd_gconf_manager_new (void)
 gboolean
 gsd_gconf_manager_start (GsdGconfManager *manager, GError **error)
 {
+	GDir *convertdir;
+	gboolean result = FALSE;
+
+	/* Read all conversion files from GCONF_SETTINGS_CONVERTDIR */
+	convertdir = g_dir_open (GCONF_SETTINGS_CONVERTDIR, 0, error);
+	if (convertdir) {
+		const gchar *filename;
+
+		while ((filename = g_dir_read_name (convertdir))) {
+			gchar *path, **groups;
+			gsize group_len, i;
+			GKeyFile *key_file = g_key_file_new ();
+
+			path = g_build_filename (GCONF_SETTINGS_CONVERTDIR, filename, NULL);
+			if (!g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, error)) {
+				g_free (path);
+				g_key_file_free (key_file);
+				result = FALSE;
+				break;
+			}
+
+			/* Load the groups in the file */
+			groups = g_key_file_get_groups (key_file, &group_len);
+			for (i = 0; i < group_len; i++) {
+				gchar **keys;
+				gsize key_len, j;
+				GHashTable *keys_hash = NULL;
+
+				keys = g_key_file_get_keys (key_file, groups[i], &key_len, error);
+				for (j = 0; j < key_len; j++) {
+					if (keys_hash == NULL)
+						keys_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+					g_hash_table_insert (keys_hash, g_strdup (keys[j]),
+							     g_strdup (g_key_file_get_value (key_file, groups[i], keys[j], error)));
+				}
+
+				g_strfreev (keys);
+
+				if (keys_hash != NULL) {
+					g_hash_table_insert (manager->priv->conf_watchers,
+							     g_strdup (groups[i]),
+							     conf_watcher_new (groups[i], keys_hash));
+				}
+			}
+
+			/* Free all memory */
+			g_free (path);
+			g_strfreev (groups);
+
+			result = TRUE;
+		}
+
+		g_dir_close (convertdir);
+	}
+
+	return result;
 }
 
 void
 gsd_gconf_manager_stop (GsdGconfManager *manager)
 {
+	g_hash_table_destroy (manager->priv->conf_watchers);
+	manager->priv->conf_watchers = NULL;
 }
diff --git a/plugins/gconf/gsd-gconf-manager.h b/plugins/gconf/gsd-gconf-manager.h
index c55f4d0..25c38b6 100644
--- a/plugins/gconf/gsd-gconf-manager.h
+++ b/plugins/gconf/gsd-gconf-manager.h
@@ -36,7 +36,7 @@ typedef struct GsdGconfManagerPrivate GsdGconfManagerPrivate;
 
 typedef struct
 {
-        GObject                     parent;
+        GObject                 parent;
         GsdGconfManagerPrivate *priv;
 } GsdGconfManager;
 



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