[evolution/wip/gsettings: 7/15] Migrate prefer-plain plugin to GSettings



commit 3dc5ac02b4acf762c22a2f1980facdd0d01d678e
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Fri Oct 14 12:25:34 2011 +0200

    Migrate prefer-plain plugin to GSettings

 data/Makefile.am                                   |    1 +
 data/evolution.convert                             |    4 +++
 ...e.evolution.eplugin.prefer-plain.gschema.xml.in |   14 ++++++++++
 plugins/prefer-plain/prefer-plain.c                |   27 +++++++------------
 4 files changed, 29 insertions(+), 17 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index fb4c041..2a8b72a 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -23,6 +23,7 @@ gsettings_SCHEMAS =							\
 	org.gnome.evolution.eplugin.external-editor.gschema.xml		\
 	org.gnome.evolution.eplugin.face-picture.gschema.xml		\
 	org.gnome.evolution.eplugin.mail-notification.gschema.xml	\
+	org.gnome.evolution.eplugin.prefer-plain.gschema.xml.in		\
 	org.gnome.evolution.eplugin.templates.gschema.xml
 
 @INTLTOOL_XML_NOMERGE_RULE@
diff --git a/data/evolution.convert b/data/evolution.convert
index 075a24a..cb4308d 100644
--- a/data/evolution.convert
+++ b/data/evolution.convert
@@ -214,5 +214,9 @@ notify-sound-beep = /apps/evolution/eplugin/mail-notification/sound-beep
 notify-sound-file = /apps/evolution/eplugin/mail-notification/sound-file
 notify-sound-use-theme = /apps/evolution/eplugin/mail-notification/sound-use-theme
 
+[org.gnome.evolution.eplugin.prefer-plain]
+mode = /apps/evolution/eplugin/prefer_plain/mode"
+show-suppressed = /apps/evolution/eplugin/prefer_plain/show_suppressed
+
 [org.gnome.evolution.eplugin.templates]
 template-placeholders = /apps/evolution/mail/template_placeholders
diff --git a/data/org.gnome.evolution.eplugin.prefer-plain.gschema.xml.in b/data/org.gnome.evolution.eplugin.prefer-plain.gschema.xml.in
new file mode 100644
index 0000000..9d9b652
--- /dev/null
+++ b/data/org.gnome.evolution.eplugin.prefer-plain.gschema.xml.in
@@ -0,0 +1,14 @@
+<schemalist>
+  <schema gettext-domain="evolution" id="org.gnome.evolution.eplugin.prefer-plain" path="/orf/gnome/evolution/eplugin/prefer-plain/">
+    <key name="mode" type="s">
+      <default>'normal'</default>
+      <_summary>Mode to use when displaying mails</_summary>
+      <_description>The mode to use for displaying mails. "normal" makes Evolution choose the best part to show, "prefer_plain" makes it use the text part, if present, and "only_plain" forces Evolution to only show plain text</_description>
+    </key>
+    <key name="show-suppressed" type="b">
+      <default>true</default>
+      <_summary>Whether to show suppressed HTML output</_summary>
+      <_description>Whether to show suppressed HTML output</_description>
+    </key>
+  </schema>
+</schemalist>
diff --git a/plugins/prefer-plain/prefer-plain.c b/plugins/prefer-plain/prefer-plain.c
index 55f62f8..907e562 100644
--- a/plugins/prefer-plain/prefer-plain.c
+++ b/plugins/prefer-plain/prefer-plain.c
@@ -26,7 +26,6 @@
 
 #include <gtk/gtk.h>
 #include <glib/gi18n-lib.h>
-#include <gconf/gconf-client.h>
 #include <string.h>
 #include <stdio.h>
 
@@ -44,7 +43,7 @@ enum {
 	EPP_TEXT
 };
 
-static GConfClient *epp_gconf = NULL;
+static GSettings *epp_settings = NULL;
 static gint epp_mode = -1;
 static gboolean epp_show_suppressed = TRUE;
 
@@ -281,7 +280,7 @@ epp_mode_changed (GtkComboBox *dropdown,
 	if (epp_mode > 2)
 		epp_mode = 0;
 
-	gconf_client_set_string(epp_gconf, "/apps/evolution/eplugin/prefer_plain/mode", epp_options[epp_mode].key, NULL);
+	g_settings_set_string (epp_settings, "mode", epp_options[epp_mode].key);
 	update_info_label (info_label, epp_mode);
 }
 
@@ -292,7 +291,7 @@ epp_show_suppressed_toggled (GtkToggleButton *check,
 	g_return_if_fail (check != NULL);
 
 	epp_show_suppressed = gtk_toggle_button_get_active (check);
-	gconf_client_set_bool (epp_gconf, "/apps/evolution/eplugin/prefer_plain/show_suppressed", epp_show_suppressed, NULL);
+	g_settings_set_boolean (epp_settings, "show-suppressed", epp_show_suppressed);
 }
 
 GtkWidget *
@@ -363,14 +362,13 @@ e_plugin_lib_enable (EPlugin *ep,
 	gchar *key;
 	gint i;
 
-	if (epp_gconf || epp_mode != -1)
+	if (epp_settings || epp_mode != -1)
 		return 0;
 
 	if (enable) {
-		GConfValue *val;
 
-		epp_gconf = gconf_client_get_default ();
-		key = gconf_client_get_string(epp_gconf, "/apps/evolution/eplugin/prefer_plain/mode", NULL);
+		epp_settings = g_settings_new ("org.gnome.evolution.eplugin.prefer-plain");
+		key = g_settings_get_string (epp_settings, "mode");
 		if (key) {
 			for (i = 0; i < G_N_ELEMENTS (epp_options); i++) {
 				if (!strcmp (epp_options[i].key, key)) {
@@ -383,16 +381,11 @@ e_plugin_lib_enable (EPlugin *ep,
 			epp_mode = 0;
 		}
 
-		val = gconf_client_get (epp_gconf, "/apps/evolution/eplugin/prefer_plain/show_suppressed", NULL);
-		if (val) {
-			epp_show_suppressed = gconf_value_get_bool (val);
-			gconf_value_free (val);
-		} else
-			epp_show_suppressed = TRUE;
+		epp_show_suppressed = g_settings_get_boolean (epp_settings, "show-suppressed");
 	} else {
-		if (epp_gconf) {
-			g_object_unref (epp_gconf);
-			epp_gconf = NULL;
+		if (epp_settings) {
+			g_object_unref (epp_settings);
+			epp_settings = NULL;
 		}
 	}
 



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