[seahorse-nautilus] Migrate from GConf to GSettings



commit ecc8717bc14ec239e83f2ac58de96c437f1f31e3
Author: Stef Walter <stefw gnome org>
Date:   Fri Jun 29 08:33:04 2012 +0200

    Migrate from GConf to GSettings

 .gitignore                                         |    1 +
 Makefile.am                                        |    1 +
 configure.ac                                       |    4 +-
 data/Makefile.am                                   |   15 ++
 data/org.gnome.seahorse.nautilus.convert           |    4 +
 data/org.gnome.seahorse.nautilus.gschema.xml       |   19 ++
 .../org.gnome.seahorse.nautilus.window.gschema.xml |   14 ++
 tool/Makefile.am                                   |    1 -
 tool/seahorse-gconf.c                              |  183 --------------------
 tool/seahorse-gconf.h                              |   55 ------
 tool/seahorse-tool-files.c                         |    9 +-
 tool/seahorse-tool.c                               |   12 +-
 tool/seahorse-tool.h                               |    2 +
 tool/seahorse-util.c                               |    1 -
 tool/seahorse-widget.c                             |  107 +++++-------
 tool/seahorse-widget.h                             |    1 +
 16 files changed, 116 insertions(+), 313 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 5868b0e..b7c28fd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@
 *.o
 *.pot
 *.tar.gz
+*.valid
 
 .deps
 .project
diff --git a/Makefile.am b/Makefile.am
index aa1b051..f06ea43 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,7 @@
 ACLOCAL_AMFLAGS = -I m4
 
 SUBDIRS = \
+	data \
 	tool \
 	nautilus-ext \
 	po
diff --git a/configure.ac b/configure.ac
index 1fb6a9a..a2c0b96 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,10 +39,9 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Name of the gettext dom
 # -----------------------------------------------------------------------------
 # GLib and GTK+ stuff
 
-AM_GCONF_SOURCE_2
+GLIB_GSETTINGS
 AM_GLIB_GNU_GETTEXT
 
-PKG_CHECK_MODULES(GCONF, gconf-2.0)
 PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.0 gio-2.0)
 
 AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
@@ -288,6 +287,7 @@ AC_SUBST(SEAHORSE_LIBS)
 
 AC_OUTPUT([
 Makefile
+data/Makefile
 po/Makefile.in
 tool/Makefile
 tool/seahorse-pgp-encrypted.desktop.in
diff --git a/data/Makefile.am b/data/Makefile.am
new file mode 100644
index 0000000..c3efc91
--- /dev/null
+++ b/data/Makefile.am
@@ -0,0 +1,15 @@
+gsettings_SCHEMAS = \
+	org.gnome.seahorse.nautilus.gschema.xml \
+	org.gnome.seahorse.nautilus.window.gschema.xml
+
+ GSETTINGS_RULES@
+
+convert_DATA = \
+	org.gnome.seahorse.nautilus.convert
+
+convertdir = \
+	$(datarootdir)/GConf/gsettings
+
+EXTRA_DIST = \
+	$(convert_DATA) \
+	$(gsettings_SCHEMAS)
\ No newline at end of file
diff --git a/data/org.gnome.seahorse.nautilus.convert b/data/org.gnome.seahorse.nautilus.convert
new file mode 100644
index 0000000..54618da
--- /dev/null
+++ b/data/org.gnome.seahorse.nautilus.convert
@@ -0,0 +1,4 @@
+[org.gnome.seahorse.nautilus]
+package-extension = /desktop/pgp/package_extension
+separate-files = /desktop/pgp/multi_seperate
+armor-mode = /desktop/pgp/ascii_armor
diff --git a/data/org.gnome.seahorse.nautilus.gschema.xml b/data/org.gnome.seahorse.nautilus.gschema.xml
new file mode 100644
index 0000000..634c458
--- /dev/null
+++ b/data/org.gnome.seahorse.nautilus.gschema.xml
@@ -0,0 +1,19 @@
+<schemalist>
+	<schema id="org.gnome.seahorse.nautilus" path="/org/gnome/seahorse/nautilus/">
+		<key name="package-extension" type="s">
+			<default>'.zip'</default>
+			<summary>File extension for packages</summary>
+			<description>File extension for packages when handling mulitple files.</description>
+		</key>
+		<key name="separate-files" type="b">
+			<default>false</default>
+			<summary>Handle multiple files separately</summary>
+			<description>When handling multiple files, don't package them but process separately.</description>
+		</key>
+		<key name="armor-mode" type="b">
+			<default>false</default>
+			<summary>Use armor mode when encrypting</summary>
+			<description>Use PGP ASCII armor mode when encrypting or signing files.</description>
+		</key>
+	</schema>
+</schemalist>
diff --git a/data/org.gnome.seahorse.nautilus.window.gschema.xml b/data/org.gnome.seahorse.nautilus.window.gschema.xml
new file mode 100644
index 0000000..9263a25
--- /dev/null
+++ b/data/org.gnome.seahorse.nautilus.window.gschema.xml
@@ -0,0 +1,14 @@
+<schemalist>
+	<schema id="org.gnome.seahorse.window">
+		<key name="width" type="i">
+			<default>-1</default>
+			<summary>Width of the window</summary>
+			<description>Width (in pixels) of the window.</description>
+		</key>
+		<key name="height" type="i">
+			<default>-1</default>
+			<summary>Height of the window</summary>
+			<description>Height (in pixels) of the window.</description>
+		</key>
+	</schema>
+</schemalist>
diff --git a/tool/Makefile.am b/tool/Makefile.am
index f2cc9d5..ae79697 100644
--- a/tool/Makefile.am
+++ b/tool/Makefile.am
@@ -16,7 +16,6 @@ BUILT_SOURCES = \
 	seahorse-marshal.c seahorse-marshal.h
 
 seahorse_tool_SOURCES = \
-	seahorse-gconf.c seahorse-gconf.h \
 	seahorse-libdialogs.h \
 	seahorse-notification.c \
 	seahorse-operation.c seahorse-operation.h \
diff --git a/tool/seahorse-tool-files.c b/tool/seahorse-tool-files.c
index 4742f40..1f8a404 100644
--- a/tool/seahorse-tool-files.c
+++ b/tool/seahorse-tool-files.c
@@ -34,7 +34,6 @@
 #include "seahorse-tool.h"
 #include "seahorse-util.h"
 #include "seahorse-widget.h"
-#include "seahorse-gconf.h"
 #include "seahorse-vfs-data.h"
 
 #define ONE_GIGABYTE 1024 * 1024 * 1024
@@ -406,7 +405,7 @@ prepare_dialog (FilesCtx *ctx, guint nfolders, guint nfiles, GFileInfo *info, gc
     /* The local stuff */
     } else {
 
-        sep = seahorse_gconf_get_boolean (MULTI_SEPERATE_KEY);
+        sep = g_settings_get_boolean (seahorse_tool_settings, "separate-files");
 
         /* Setup the package */
         w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "package-name"));
@@ -469,7 +468,7 @@ get_results (SeahorseWidget *swidget)
 
     w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "do-separate"));
     sep = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
-    seahorse_gconf_set_boolean (MULTI_SEPERATE_KEY, sep);
+    g_settings_set_boolean (seahorse_tool_settings, "separate-files", sep);
 
     /* no packaging */
     if(!sep) {
@@ -496,7 +495,7 @@ get_results (SeahorseWidget *swidget)
         full_name = g_strdup_printf("%s%s", name, ext);
 
         /* Save the extension */
-        seahorse_gconf_set_string (MULTI_EXTENSION_KEY, ext);
+        g_settings_set_string (seahorse_tool_settings, "package-extension", ext);
 
         return full_name;
     }
@@ -537,7 +536,7 @@ step_process_multiple (FilesCtx *ctx,
         return TRUE;
 
     /* The package extension */
-    if ((ext = seahorse_gconf_get_string (MULTI_EXTENSION_KEY)) == NULL)
+    if ((ext = g_settings_get_string (seahorse_tool_settings, "package-extension")) == NULL)
         ext = g_strdup (".zip"); /* Yes this happens when the schema isn't installed */
 
     /* Figure out a good URI for our package */
diff --git a/tool/seahorse-tool.c b/tool/seahorse-tool.c
index 041b968..c0a375a 100644
--- a/tool/seahorse-tool.c
+++ b/tool/seahorse-tool.c
@@ -38,9 +38,10 @@
 #include "seahorse-util.h"
 #include "seahorse-vfs-data.h"
 #include "seahorse-libdialogs.h"
-#include "seahorse-gconf.h"
 #include "seahorse-util.h"
 
+GSettings *seahorse_tool_settings = NULL;
+
 #define IMPORT_BUFFER_SIZE 50*1<<10 /* 50 kB */
 
 /* -----------------------------------------------------------------------------
@@ -261,7 +262,7 @@ encrypt_sign_start (SeahorseToolMode *mode, const gchar *uri, gpgme_data_t urida
     g_object_set_data_full (G_OBJECT (pop), "cipher-data", cipher,
                             (GDestroyNotify)gpgme_data_release);
 
-    gpgme_set_armor (pop->gctx, seahorse_gconf_get_boolean (ARMOR_KEY));
+    gpgme_set_armor (pop->gctx, g_settings_get_boolean (seahorse_tool_settings, "armor-mode"));
     gpgme_set_textmode (pop->gctx, FALSE);
 
     /* Start actual encryption */
@@ -376,7 +377,7 @@ sign_start (SeahorseToolMode *mode, const gchar *uri, gpgme_data_t uridata,
     g_object_set_data_full (G_OBJECT (pop), "cipher-data", cipher,
                             (GDestroyNotify)gpgme_data_release);
 
-    gpgme_set_armor (pop->gctx, seahorse_gconf_get_boolean (ARMOR_KEY));
+    gpgme_set_armor (pop->gctx, g_settings_get_boolean (seahorse_tool_settings, "armor-mode"));
     gpgme_set_textmode (pop->gctx, FALSE);
 
     /* Start actual signage */
@@ -704,6 +705,8 @@ main (int argc, char **argv)
         return 2;
     }
 
+    seahorse_tool_settings = g_settings_new ("org.gnome.seahorse.nautilus");
+
     /* The basic settings for the operation */
     memset (&mode, 0, sizeof (mode));
 
@@ -770,6 +773,9 @@ main (int argc, char **argv)
     if (mode.signer)
         gpgme_key_unref (mode.signer);
 
+    g_object_unref (seahorse_tool_settings);
+    seahorse_tool_settings = NULL;
+
     g_strfreev (uris);
 
     return ret;
diff --git a/tool/seahorse-tool.h b/tool/seahorse-tool.h
index 2322bae..04b1842 100644
--- a/tool/seahorse-tool.h
+++ b/tool/seahorse-tool.h
@@ -31,6 +31,8 @@ extern gboolean mode_encrypt_sign;
 extern gboolean mode_decrypt;
 extern gboolean mode_verify;
 
+extern GSettings *seahorse_tool_settings;
+
 struct _SeahorseToolMode;
 typedef gboolean (*SeahorseToolCallback) (struct _SeahorseToolMode *mode, const gchar *uri,
                                           gpgme_data_t uridata, SeahorsePGPOperation *pop,
diff --git a/tool/seahorse-util.c b/tool/seahorse-util.c
index 7c8cfd7..3ad2c77 100644
--- a/tool/seahorse-util.c
+++ b/tool/seahorse-util.c
@@ -44,7 +44,6 @@
 #include <dbus/dbus-glib-bindings.h>
 
 #include "seahorse-util.h"
-#include "seahorse-gconf.h"
 #include "seahorse-vfs-data.h"
 
 #include <gpgme.h>
diff --git a/tool/seahorse-widget.c b/tool/seahorse-widget.c
index c88d04d..b37238b 100644
--- a/tool/seahorse-widget.c
+++ b/tool/seahorse-widget.c
@@ -27,7 +27,6 @@
 #include <glib/gi18n.h>
 
 #include "seahorse-widget.h"
-#include "seahorse-gconf.h"
 
 #define STATUS "status"
 
@@ -59,10 +58,6 @@ static void     object_get_property (GObject                *object,
                                      GValue                 *value,
                                      GParamSpec             *pspec);
 
-static GObject* seahorse_widget_constructor (GType                  type,
-                                             guint                  n_props,
-                                             GObjectConstructParam* props);
-
 /* signal functions */
 G_MODULE_EXPORT void on_widget_closed   (GtkWidget             *widget,
                                               SeahorseWidget        *swidget);
@@ -99,6 +94,31 @@ seahorse_widget_get_type (void)
 }
 
 static void
+seahorse_widget_constructed (GObject *object)
+{
+	SeahorseWidget *self = SEAHORSE_WIDGET (object);
+	GtkWindow *window;
+	gint width, height;
+	gchar *path;
+
+	G_OBJECT_CLASS (parent_class)->constructed (object);
+
+	/* Load window size for windows that aren't dialogs */
+	window = GTK_WINDOW (seahorse_widget_get_toplevel (self));
+	if (!GTK_IS_DIALOG (window)) {
+		path = g_strdup_printf ("/org/gnome/seahorse/nautilus/windows/%s/", self->name);
+		self->settings = g_settings_new_with_path ("org.gnome.seahorse.nautilus.window", path);
+		g_free (path);
+
+		width = g_settings_get_int (self->settings, "width");
+		height = g_settings_get_int (self->settings, "height");
+
+		if (width > 0 && height > 0)
+			gtk_window_resize (window, width, height);
+	}
+}
+
+static void
 class_init (SeahorseWidgetClass *klass)
 {
 	GObjectClass *gobject_class;
@@ -106,7 +126,7 @@ class_init (SeahorseWidgetClass *klass)
 	parent_class = g_type_class_peek_parent (klass);
 	gobject_class = G_OBJECT_CLASS (klass);
 
-	gobject_class->constructor = seahorse_widget_constructor;
+	gobject_class->constructed = seahorse_widget_constructed;
 	gobject_class->dispose = object_dispose;
 	gobject_class->finalize = object_finalize;
 	gobject_class->set_property = object_set_property;
@@ -127,38 +147,6 @@ object_init (SeahorseWidget *swidget)
 
 }
 
-static GObject*
-seahorse_widget_constructor (GType type, guint n_props, GObjectConstructParam* props)
-{
-    SeahorseWidget *swidget;
-    GObject *obj;
-
-    GtkWindow *window;
-    gint width, height;
-    gchar *widthkey, *heightkey;
-
-    obj = G_OBJECT_CLASS (parent_class)->constructor (type, n_props, props);
-    swidget = SEAHORSE_WIDGET (obj);
-
-    /* Load window size for windows that aren't dialogs */
-    window = GTK_WINDOW (seahorse_widget_get_toplevel (swidget));
-    if (!GTK_IS_DIALOG (window)) {
-	    widthkey = g_strdup_printf ("%s%s%s", WINDOW_SIZE, swidget->name, "_width");
-	    width = seahorse_gconf_get_integer (widthkey);
-
-	    heightkey = g_strdup_printf ("%s%s%s", WINDOW_SIZE, swidget->name, "_height");
-	    height = seahorse_gconf_get_integer (heightkey);
-
-	    if (width > 0 && height > 0)
-		    gtk_window_resize (window, width, height);
-
-	    g_free (widthkey);
-	    g_free (heightkey);
-    }
-
-    return obj;
-}
-
 static void
 object_dispose (GObject *object)
 {
@@ -197,6 +185,7 @@ object_finalize (GObject *gobject)
 	g_object_unref (swidget->gtkbuilder);
 	swidget->gtkbuilder = NULL;
 
+	g_clear_object (&swidget->settings);
 	g_free (swidget->name);
 
 	G_OBJECT_CLASS (parent_class)->finalize (gobject);
@@ -365,34 +354,26 @@ seahorse_widget_get_widget (SeahorseWidget *swidget, const char *identifier)
  * Unrefs @swidget.
  **/
 void
-seahorse_widget_destroy (SeahorseWidget *swidget)
+seahorse_widget_destroy (SeahorseWidget *self)
 {
-    GtkWidget *widget;
-    gchar *widthkey, *heightkey;
-    gint width, height;
+	GtkWidget *widget;
+	gint width, height;
 
-    g_return_if_fail (swidget != NULL && SEAHORSE_IS_WIDGET (swidget));
-    widget = seahorse_widget_get_toplevel (swidget);
+	g_return_if_fail (self != NULL && SEAHORSE_IS_WIDGET (self));
+	widget = seahorse_widget_get_toplevel (self);
 
-    /* Don't save window size for dialogs */
-    if (!GTK_IS_DIALOG (widget)) {
-
-	    /* Save window size */
-	    gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
-
-	    widthkey = g_strdup_printf ("%s%s%s", WINDOW_SIZE, swidget->name, "_width");
-	    seahorse_gconf_set_integer (widthkey, width);
-
-	    heightkey = g_strdup_printf ("%s%s%s", WINDOW_SIZE, swidget->name, "_height");
-	    seahorse_gconf_set_integer (heightkey, height);
+	/* Save window size */
+	if (self->settings) {
+		gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
+		g_settings_set_int (self->settings, "width", width);
+		g_settings_set_int (self->settings, "height", height);
+	}
 
-	    g_free (widthkey);
-	    g_free (heightkey);
-    }
+	/* Destroy Widget */
+	if (!self->destroying) {
+		self->destroying = TRUE;
+		gtk_widget_destroy (seahorse_widget_get_toplevel (self));
+		g_object_unref (self);
+	}
 
-    /* Destroy Widget */
-    if (!swidget->destroying) {
-        swidget->destroying = TRUE;
-        g_object_unref (swidget);
-    }
 }
diff --git a/tool/seahorse-widget.h b/tool/seahorse-widget.h
index bc19562..26fe5a6 100644
--- a/tool/seahorse-widget.h
+++ b/tool/seahorse-widget.h
@@ -65,6 +65,7 @@ struct _SeahorseWidget {
 	/*< private >*/
 	gboolean destroying;
 	gboolean in_destruction;
+	GSettings *settings;
 };
 
 struct _SeahorseWidgetClass {



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