[gedit] Port checkupdate plugin to gsettings



commit eee5a21a81c2a154048940ad5a0659792f008db5
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sat May 8 12:11:46 2010 +0200

    Port checkupdate plugin to gsettings

 plugins/checkupdate/Makefile.am                    |   10 +++++
 plugins/checkupdate/gedit-check-update-plugin.c    |   36 ++++++-------------
 plugins/checkupdate/gedit-check-update.schemas.in  |   13 -------
 .../org.gnome.gedit.checkupdate.gschema.in         |    4 ++
 4 files changed, 26 insertions(+), 37 deletions(-)
---
diff --git a/plugins/checkupdate/Makefile.am b/plugins/checkupdate/Makefile.am
index 72aff58..e6b93de 100644
--- a/plugins/checkupdate/Makefile.am
+++ b/plugins/checkupdate/Makefile.am
@@ -18,12 +18,22 @@ libcheckupdate_la_SOURCES = \
 libcheckupdate_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
 libcheckupdate_la_LIBADD = $(GEDIT_LIBS) $(LIBSOUP_LIBS)
 
+gsettingsschema_in_files = org.gnome.gedit.checkupdate.gschema.in
+gsettingsschema_DATA = $(gsettingsschema_in_files:.gschema.in=.gschema.xml)
+org.gnome.gedit.checkupdate.gschema.xml: org.gnome.gedit.checkupdate.gschema.in
+	gsettings-schema-convert -f $< -o $@
+
 plugin_in_files = checkupdate.gedit-plugin.desktop.in
 
 %.gedit-plugin: %.gedit-plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
 
 plugin_DATA = $(plugin_in_files:.gedit-plugin.desktop.in=.gedit-plugin)
 
+if GSETTINGS_SCHEMAS_INSTALL
+install-data-hook:
+	$(GLIB_COMPILE_SCHEMAS) $(gsettingsschemadir)
+endif
+
 EXTRA_DIST = $(plugin_in_files)
 
 CLEANFILES = $(plugin_DATA)
diff --git a/plugins/checkupdate/gedit-check-update-plugin.c b/plugins/checkupdate/gedit-check-update-plugin.c
index e13387f..21df3ec 100644
--- a/plugins/checkupdate/gedit-check-update-plugin.c
+++ b/plugins/checkupdate/gedit-check-update-plugin.c
@@ -31,14 +31,12 @@
 
 #include <gedit/gseal-gtk-compat.h>
 
-#include <gconf/gconf-client.h>
-
 #if !GTK_CHECK_VERSION(2, 17, 1)
 #include <gedit/gedit-message-area.h>
 #endif
 
-#define GCONF_KEY_BASE "/apps/gedit-2/plugins/checkupdate"
-#define GCONF_KEY_IGNORE_VERSION   GCONF_KEY_BASE "/ignore_version"
+#define CHECKUPDATE_BASE_SETTINGS	"org.gnome.gedit.plugins.checkupdate"
+#define CHECKUPDATE_KEY_IGNORE_VERSION	"ignore-version"
 
 #define WINDOW_DATA_KEY "GeditCheckUpdatePluginWindowData"
 
@@ -67,7 +65,7 @@ struct _GeditCheckUpdatePluginPrivate
 {
 	SoupSession *session;
 
-	GConfClient *gconf_client;
+	GSettings *settings;
 };
 
 typedef struct
@@ -103,12 +101,7 @@ gedit_check_update_plugin_init (GeditCheckUpdatePlugin *plugin)
 
 	plugin->priv->session = soup_session_async_new ();
 
-	plugin->priv->gconf_client = gconf_client_get_default ();
-
-	gconf_client_add_dir (plugin->priv->gconf_client,
-			      GCONF_KEY_BASE,
-			      GCONF_CLIENT_PRELOAD_ONELEVEL,
-			      NULL);
+	plugin->priv->settings = g_settings_new (CHECKUPDATE_BASE_SETTINGS);
 }
 
 static void
@@ -122,13 +115,10 @@ gedit_check_update_plugin_dispose (GObject *object)
 		plugin->priv->session = NULL;
 	}
 
-	if (plugin->priv->gconf_client != NULL)
+	if (plugin->priv->settings != NULL)
 	{
-		gconf_client_suggest_sync (plugin->priv->gconf_client, NULL);
-
-		g_object_unref (G_OBJECT (plugin->priv->gconf_client));
-		
-		plugin->priv->gconf_client = NULL;
+		g_object_unref (plugin->priv->settings);
+		plugin->priv->settings = NULL;
 	}
 
 	gedit_debug_message (DEBUG_PLUGINS,
@@ -268,10 +258,9 @@ on_response_cb (GtkWidget   *infobar,
 		
 		data = g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
 
-		gconf_client_set_string (data->plugin->priv->gconf_client,
-					 GCONF_KEY_IGNORE_VERSION,
-					 data->version,
-					 NULL);
+		g_settings_set_string (data->plugin->priv->settings,
+				       CHECKUPDATE_KEY_IGNORE_VERSION,
+				       data->version);
 	}
 
 	g_object_set_data (G_OBJECT (window),
@@ -469,9 +458,8 @@ parse_file_version (const gchar *file)
 static gchar *
 get_ignore_version (GeditCheckUpdatePlugin *plugin)
 {
-	return gconf_client_get_string (plugin->priv->gconf_client,
-					GCONF_KEY_IGNORE_VERSION,
-					NULL);
+	return g_settings_get_string (plugin->priv->settings,
+				      CHECKUPDATE_KEY_IGNORE_VERSION);
 }
 
 static void
diff --git a/plugins/checkupdate/org.gnome.gedit.checkupdate.gschema.in b/plugins/checkupdate/org.gnome.gedit.checkupdate.gschema.in
new file mode 100644
index 0000000..cb25ee3
--- /dev/null
+++ b/plugins/checkupdate/org.gnome.gedit.checkupdate.gschema.in
@@ -0,0 +1,4 @@
+schema org.gnome.gedit.plugins.checkupdate:
+  path /apps/gedit/plugins/checkupdate
+
+  key ignore-version = @s ''



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