[gnome-system-tools] Migrate to GSettings



commit dcb0f5cd71f2c06e37cd87a8c15e5542c4654802
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Fri Apr 23 15:16:26 2010 +0200

    Migrate to GSettings
    
    Remove gst-conf.{ch} which is now useless, since it was only wrapping getters and setters around GConf's API. Create a GSettings object in GstUsersTool, since it's the only tool to use settings. Migrate schemas and update configure.in and Makefile.am accordingly.
    
    Raise dependency on GLib to 2.25.3 (needed for GLIB_GSETTINGS m4 macro), and make GIO a "core" dependency (it was separated most likely for historical reasons).
    
    intltool support is not yet here, so we'll have to wait for keys' descriptions to be translated.

 Makefile.am                        |   17 ++-
 configure.in                       |   37 +-----
 org.gnome.system-tools.gschema.xml |   14 ++
 po/POTFILES.in                     |    1 -
 src/common/Makefile.am             |    1 -
 src/common/gst-conf.c              |  249 ------------------------------------
 src/common/gst-conf.h              |   40 ------
 src/common/gst-dialog.c            |    1 -
 src/common/gst-tool.c              |    5 -
 src/common/gst-tool.h              |    2 -
 src/common/gst.h                   |    1 -
 src/users/users-tool.c             |   33 +++--
 src/users/users-tool.h             |    6 +-
 13 files changed, 49 insertions(+), 358 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 740eb10..109f2f5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,13 +17,15 @@ EXTRA_DIST = \
 	gnome-system-tools.pc.in
 
 
-schema_in_files = gnome-system-tools.schemas.in
-schemadir = @GCONF_SCHEMA_FILE_DIR@
-schema_DATA = $(schema_in_files:.schemas.in=.schemas)
- INTLTOOL_SCHEMAS_RULE@
-
-install-data-local:
-	-GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/$(schema_DATA)
+# gsettingsschemadir and gschema_compile are defined by the GLIB_GSETTINGS
+# macro in configure.in
+gsettingsschema_DATA = org.gnome.system-tools.gschema.xml
+# This rule will check your schemas for validity before installation
+ GSETTINGS_CHECK_RULE@
+if GSETTINGS_SCHEMAS_INSTALL
+install-data-hook:
+	$(gschema_compile) $(DESTDIR)$(gsettingsschemadir)
+endif
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = gnome-system-tools.pc
@@ -35,7 +37,6 @@ DISTCLEANFILES = \
 	backends/intltool-extract \
 	backends/intltool-merge \
 	backends/intltool-update \
-	gnome-system-tools.schemas \
 	gnome-doc-utils.make \
 	gnome-system-tools.pc
 
diff --git a/configure.in b/configure.in
index ed231bc..fb01ec2 100644
--- a/configure.in
+++ b/configure.in
@@ -28,11 +28,12 @@ AC_PROG_MAKE_SET
 dnl glib-genmarshal
 AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
 
+GLIB_GSETTINGS
+
 STB_REQUIRED=2.9.4
 LIBOOBS_REQUIRED=2.29.91
 GTK_REQUIRED=2.19.7
-GLIB_REQUIRED=2.15.2
-GCONF_REQUIRED=2.2.0
+GLIB_REQUIRED=2.25.3
 DBUS_REQUIRED=0.32
 POLICYKIT_GTK_REQUIRED=0.92
 
@@ -79,8 +80,8 @@ dnl =====================================================
 PKG_CHECK_MODULES(GST_DEPENDS,[
 			   gtk+-2.0 >= $GTK_REQUIRED
 			   gmodule-export-2.0
+			   gio-2.0 >= $GLIB_REQUIRED
 			   pango
-			   gconf-2.0 >= $GCONF_REQUIRED
 			   liboobs-1 >= $LIBOOBS_REQUIRED
 			   system-tools-backends-2.0 >= $STB_REQUIRED
 			   ])
@@ -172,22 +173,7 @@ dnl ========================================================
 dnl END : Translations
 dnl ========================================================
 
-dnl =====================================================
-dnl GCONF
-dnl =====================================================
 
-AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
-
-if test x"$GCONFTOOL" = xno; then
-AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
-fi
-     
-AM_GCONF_SOURCE_2
-
-dnl =====================================================
-dnl END: GCONF
-dnl =====================================================
-    
 dnl =====================================================
 dnl GST_LIBS & GST_CFLAGS 
 dnl =====================================================
@@ -271,21 +257,6 @@ dnl END: GST_LIBS & GST_FLAGS
 dnl ==================================
 
 dnl ==================================
-dnl GIO
-dnl ==================================
-
-PKG_CHECK_MODULES(GIO,[
-		  gio-2.0 >= $GLIB_REQUIRED
-		  ])
-
-AC_SUBST(GIO_LIBS)
-AC_SUBST(GIO_CFLAGS)
-
-dnl ==================================
-dnl END: GIO
-dnl ==================================
-
-dnl ==================================
 dnl LIBIW DETECTION
 dnl ==================================
 
diff --git a/org.gnome.system-tools.gschema.xml b/org.gnome.system-tools.gschema.xml
new file mode 100644
index 0000000..e561117
--- /dev/null
+++ b/org.gnome.system-tools.gschema.xml
@@ -0,0 +1,14 @@
+<schemalist>
+  <schema id="org.gnome.system-tools.users" path="/org/gnome/system-tools/users/">
+    <key name="showall" type="b">
+      <default>false</default>
+      <summary>Show system users</summary>
+      <description>Whether the users-admin tool should show system users in the users list.</description>
+    </key>
+    <key name="showroot" type="b">
+      <default>false</default>
+      <summary>Show root user</summary>
+      <description>Whether the users-admin tool should show the root user in the users list.</description>
+    </key>
+  </schema>
+</schemalist>
\ No newline at end of file
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 702469c..e94cfce 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,7 +1,6 @@
 # List of source files containing translatable strings.
 # Please keep this file sorted alphabetically.
 [encoding: UTF-8]
-gnome-system-tools.schemas.in
 [type: gettext/glade]interfaces/common.ui
 [type: gettext/glade]interfaces/network.ui
 [type: gettext/glade]interfaces/services.ui
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 9da4113..6698b4d 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -14,7 +14,6 @@ libsetuptool_a_SOURCES = \
 	gst-dialog.c		gst-dialog.h \
 	gst-tool.c		gst-tool.h \
 	gst-platform-dialog.c	gst-platform-dialog.h \
-	gst-conf.c		gst-conf.h \
 	gst-filter.c		gst-filter.h \
 	gst-service-role.c	gst-service-role.h \
 	gst.h
diff --git a/src/common/gst-dialog.c b/src/common/gst-dialog.c
index 8fd3397..557ddef 100644
--- a/src/common/gst-dialog.c
+++ b/src/common/gst-dialog.c
@@ -28,7 +28,6 @@
 #include <stdlib.h>
 #include "gst-tool.h"
 #include "gst-dialog.h"
-#include "gst-conf.h"
 
 #ifdef HAVE_POLKIT
 #include <polkitgtk/polkitgtk.h>
diff --git a/src/common/gst-tool.c b/src/common/gst-tool.c
index 66c344a..a4b55a3 100644
--- a/src/common/gst-tool.c
+++ b/src/common/gst-tool.c
@@ -24,7 +24,6 @@
 #include <config.h>
 #include <glib.h>
 #include <glib/gi18n.h>
-#include <gconf/gconf-client.h>
 #include <time.h>
 
 #include <stdlib.h>
@@ -155,7 +154,6 @@ gst_tool_init (GstTool *tool)
 	tool->common_ui_path  = INTERFACES_DIR "/common.ui";
 
 	tool->session = oobs_session_get ();
-	tool->gconf_client = gconf_client_get_default ();
 
 	builder = gst_tool_load_common_ui (tool);
 
@@ -302,9 +300,6 @@ gst_tool_finalize (GObject *object)
 	if (tool->report_window)
 		gtk_widget_destroy (tool->report_window);
 
-	if (tool->gconf_client)
-		g_object_unref (tool->gconf_client);
-
 	g_ptr_array_free (tool->objects, FALSE);
 
 	(* G_OBJECT_CLASS (gst_tool_parent_class)->finalize) (object);
diff --git a/src/common/gst-tool.h b/src/common/gst-tool.h
index fcb0ade..3993fbf 100644
--- a/src/common/gst-tool.h
+++ b/src/common/gst-tool.h
@@ -28,7 +28,6 @@
 G_BEGIN_DECLS
 
 #include <oobs/oobs.h>
-#include <gconf/gconf-client.h>
 
 typedef struct _GstTool      GstTool;
 typedef struct _GstToolClass GstToolClass;
@@ -52,7 +51,6 @@ struct _GstTool {
 
 	OobsSession *session;
 	GPtrArray   *objects;
-	GConfClient *gconf_client;
 
 	char *ui_path;
 	char *common_ui_path;
diff --git a/src/common/gst.h b/src/common/gst.h
index 3f390ba..3be8125 100644
--- a/src/common/gst.h
+++ b/src/common/gst.h
@@ -2,6 +2,5 @@
 #include <config.h>
 #include "gst-tool.h"
 #include "gst-dialog.h"
-#include "gst-conf.h"
 #include "gst-filter.h"
 #include "gst-service-role.h"
diff --git a/src/users/users-tool.c b/src/users/users-tool.c
index bd26f50..9da0d29 100644
--- a/src/users/users-tool.c
+++ b/src/users/users-tool.c
@@ -54,17 +54,16 @@ gst_users_tool_class_init (GstUsersToolClass *class)
 }
 
 static void
-on_option_changed (GConfClient *client,
-		    guint        conn_id,
-		    GConfEntry  *entry,
-		    gpointer     data)
+on_option_changed (GSettings  *settings,
+                   const char *key,
+                   gpointer    user_data)
 {
-	GstTool *tool = GST_TOOL (data);
+	GstTool *tool = GST_TOOL (user_data);
 	GtkWidget *widget;
 	GtkTreeModel *model;
 
-	GST_USERS_TOOL (tool)->showall = gst_conf_get_boolean (GST_TOOL (tool), "showall");
-	GST_USERS_TOOL (tool)->showroot = gst_conf_get_boolean (GST_TOOL (tool), "showroot");
+	GST_USERS_TOOL (tool)->showall = g_settings_get_boolean (settings, "showall");
+	GST_USERS_TOOL (tool)->showroot = g_settings_get_boolean (settings, "showroot");
 
 	widget = gst_dialog_get_widget (tool->main_dialog, "users_table");
 	model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
@@ -84,6 +83,8 @@ gst_users_tool_init (GstUsersTool *tool)
 	gst_tool_add_configuration_object (GST_TOOL (tool), tool->self_config, TRUE);
 
 	tool->profiles = gst_user_profiles_get ();
+
+	tool->settings = g_settings_new ("org.gnome.system-tools.users");
 }
 
 static GObject*
@@ -92,20 +93,21 @@ gst_users_tool_constructor (GType                  type,
 			    GObjectConstructParam *construct_params)
 {
 	GObject *object;
-	GstTool *tool;
+	GstUsersTool *tool;
 
 	object = (* G_OBJECT_CLASS (gst_users_tool_parent_class)->constructor) (type,
 										n_construct_properties,
 										construct_params);
 
-	tool = GST_TOOL (object);
-	GST_USERS_TOOL (tool)->showall = gst_conf_get_boolean (GST_TOOL (tool), "showall");
-	GST_USERS_TOOL (tool)->showroot = gst_conf_get_boolean (GST_TOOL (tool), "showroot");
+	tool = GST_USERS_TOOL (object);
+
+	g_signal_connect (tool->settings, "changed::showall",
+	                  (GCallback) on_option_changed, tool);
+	g_signal_connect (tool->settings, "changed::showroot",
+	                  (GCallback) on_option_changed, tool);
 
-	gst_conf_add_notify (GST_TOOL (tool), "showall",
-			     on_option_changed, tool);
-	gst_conf_add_notify (GST_TOOL (tool), "showroot",
-			     on_option_changed, tool);
+	tool->showall = g_settings_get_boolean (tool->settings, "showall");
+	tool->showroot = g_settings_get_boolean (tool->settings, "showroot");
 
 	return object;
 }
@@ -119,6 +121,7 @@ gst_users_tool_finalize (GObject *object)
 	g_object_unref (tool->self_config);
 	g_object_unref (tool->groups_config);
 	g_object_unref (tool->profiles);
+	g_object_unref (tool->settings);
 
 	/* Clear models to unreference OobsUsers and OobsGroups
 	 * to be sure they are finalized properly (passwords...) */
diff --git a/src/users/users-tool.h b/src/users/users-tool.h
index d08f144..207900b 100644
--- a/src/users/users-tool.h
+++ b/src/users/users-tool.h
@@ -46,13 +46,15 @@ struct _GstUsersTool {
 	OobsObject *users_config;
 	OobsObject *groups_config;
 	OobsObject *self_config;
+
 	gint minimum_uid;
 	gint maximum_uid;
 	gint minimum_gid;
 	gint maximum_gid;
 
-	gboolean showall;
-	gboolean showroot;
+	GSettings *settings;
+	gboolean   showall;
+	gboolean   showroot;
 };
 
 struct _GstUsersToolClass {



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