[gedit-plugins] Use an schema file for gconf in the drawspaces plugin. Fixes bug #603346.



commit a3526b925419820c3621e703fa40249d3ee1fb45
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue Dec 1 17:18:03 2009 +0100

    Use an schema file for gconf in the drawspaces plugin. Fixes bug #603346.

 plugins/drawspaces/Makefile.am                 |   24 +++++-
 plugins/drawspaces/gedit-drawspaces-plugin.c   |   44 ++++--------
 plugins/drawspaces/gedit-drawspaces.schemas.in |   91 ++++++++++++++++++++++++
 3 files changed, 126 insertions(+), 33 deletions(-)
---
diff --git a/plugins/drawspaces/Makefile.am b/plugins/drawspaces/Makefile.am
index dfe297d..6d846ff 100644
--- a/plugins/drawspaces/Makefile.am
+++ b/plugins/drawspaces/Makefile.am
@@ -27,9 +27,25 @@ plugin_in_files = drawspaces.gedit-plugin.desktop.in
 
 plugin_DATA = $(plugin_in_files:.gedit-plugin.desktop.in=.gedit-plugin)
 
-EXTRA_DIST = $(plugin_in_files) $(ui_DATA)
-
-CLEANFILES = $(plugin_DATA)
-DISTCLEANFILES = $(plugin_DATA)
+schemasdir	 = $(GCONF_SCHEMA_FILE_DIR)
+schemas_in_files = gedit-drawspaces.schemas.in
+schemas_DATA 	 = $(schemas_in_files:.schemas.in=.schemas)
+ INTLTOOL_SCHEMAS_RULE@
+
+if GCONF_SCHEMAS_INSTALL
+install-data-local:
+	        if test -z "$(DESTDIR)" ; then \
+	                for p in $(schemas_DATA) ; do \
+	                        GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/plugins/drawspaces/$$p ; \
+	                done \
+	        fi
+else
+install-data-local:
+endif
+
+EXTRA_DIST = $(plugin_in_files) $(ui_DATA) $(schemas_in_files)
+
+CLEANFILES = $(plugin_DATA) $(schemas_DATA)
+DISTCLEANFILES = $(plugin_DATA) $(schemas_DATA)
 
 -include $(top_srcdir)/git.mk
diff --git a/plugins/drawspaces/gedit-drawspaces-plugin.c b/plugins/drawspaces/gedit-drawspaces-plugin.c
index a2552d5..44841aa 100644
--- a/plugins/drawspaces/gedit-drawspaces-plugin.c
+++ b/plugins/drawspaces/gedit-drawspaces-plugin.c
@@ -125,17 +125,21 @@ free_action_data (gpointer data)
 }
 
 static void
-set_enable_draw (GeditDrawspacesPlugin *plugin,
-		 gboolean value)
+set_draw_gconf (GeditDrawspacesPlugin *plugin,
+                gchar const           *key,
+                gboolean               value)
 {
-	if (gconf_client_key_is_writable (plugin->priv->gconf_client,
-					   GCONF_KEY_ENABLE,
-					   NULL))
+	GError *error = NULL;
+	
+	gconf_client_set_bool (plugin->priv->gconf_client,
+			       key,
+			       value,
+			       &error);
+
+	if (error != NULL)
 	{
-		gconf_client_set_bool (plugin->priv->gconf_client,
-				       GCONF_KEY_ENABLE,
-				       value,
-				       NULL);
+		g_warning ("%s", error->message);
+		g_error_free (error);
 	}
 }
 
@@ -153,7 +157,7 @@ on_active_toggled (GtkToggleAction *action,
 	value = gtk_toggle_action_get_active (action);
 	data->enable = value;
 
-	set_enable_draw (action_data->plugin, value);
+	set_draw_gconf (action_data->plugin, GCONF_KEY_ENABLE, value);
 
 	draw_spaces_in_window (action_data->window, action_data->plugin);
 }
@@ -493,24 +497,6 @@ impl_deactivate	(GeditPlugin *plugin,
 }
 
 static void
-set_draw_gconf (GeditDrawspacesPlugin *plugin,
-                gchar const           *key,
-                gboolean               value)
-{
-	if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
-					   key,
-					   NULL))
-	{
-		return;
-	}
-	
-	gconf_client_set_bool (plugin->priv->gconf_client,
-			       key,
-			       value,
-			       NULL);
-}
-
-static void
 on_draw_tabs_toggled (GtkToggleButton       *button,
                       GeditDrawspacesPlugin *plugin)
 {
@@ -807,5 +793,5 @@ gedit_drawspaces_plugin_class_init (GeditDrawspacesPluginClass *klass)
 
 	plugin_class->activate = impl_activate;
 	plugin_class->deactivate = impl_deactivate;
-	plugin_class->create_configure_dialog = impl_create_configure_dialog;	
+	plugin_class->create_configure_dialog = impl_create_configure_dialog;
 }
diff --git a/plugins/drawspaces/gedit-drawspaces.schemas.in b/plugins/drawspaces/gedit-drawspaces.schemas.in
new file mode 100644
index 0000000..039f5ee
--- /dev/null
+++ b/plugins/drawspaces/gedit-drawspaces.schemas.in
@@ -0,0 +1,91 @@
+<gconfschemafile>
+  <schemalist>
+    <schema>
+      <key>/schemas/apps/gedit-2/plugins/drawspaces/enable</key>
+      <applyto>/apps/gedit-2/plugins/drawspaces/enable</applyto>
+      <owner>gedit</owner>
+      <type>bool</type>
+      <default>TRUE</default>
+      <locale name="C">
+	<short>Show White Spaces</short>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/gedit-2/plugins/drawspaces/draw_tabs</key>
+      <applyto>/apps/gedit-2/plugins/drawspaces/draw_tabs</applyto>
+      <owner>gedit</owner>
+      <type>bool</type>
+      <default>TRUE</default>
+      <locale name="C">
+	<short>Draw Tabs</short>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/gedit-2/plugins/drawspaces/draw_spaces</key>
+      <applyto>/apps/gedit-2/plugins/drawspaces/draw_spaces</applyto>
+      <owner>gedit</owner>
+      <type>bool</type>
+      <default>TRUE</default>
+      <locale name="C">
+	<short>Draw Spaces</short>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/gedit-2/plugins/drawspaces/draw_newline</key>
+      <applyto>/apps/gedit-2/plugins/drawspaces/draw_newline</applyto>
+      <owner>gedit</owner>
+      <type>bool</type>
+      <default>FALSE</default>
+      <locale name="C">
+	<short>Draw New lines</short>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/gedit-2/plugins/drawspaces/draw_nbsp</key>
+      <applyto>/apps/gedit-2/plugins/drawspaces/draw_nbsp</applyto>
+      <owner>gedit</owner>
+      <type>bool</type>
+      <default>FALSE</default>
+      <locale name="C">
+	<short>Draw Non-Breaking Spaces</short>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/gedit-2/plugins/drawspaces/draw_leading</key>
+      <applyto>/apps/gedit-2/plugins/drawspaces/draw_leading</applyto>
+      <owner>gedit</owner>
+      <type>bool</type>
+      <default>TRUE</default>
+      <locale name="C">
+	<short>Draw Leading Spaces</short>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/gedit-2/plugins/drawspaces/draw_text</key>
+      <applyto>/apps/gedit-2/plugins/drawspaces/draw_text</applyto>
+      <owner>gedit</owner>
+      <type>bool</type>
+      <default>TRUE</default>
+      <locale name="C">
+	<short>Draw Spaces in Text</short>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/gedit-2/plugins/drawspaces/draw_trailing</key>
+      <applyto>/apps/gedit-2/plugins/drawspaces/draw_trailing</applyto>
+      <owner>gedit</owner>
+      <type>bool</type>
+      <default>TRUE</default>
+      <locale name="C">
+	<short>Draw Trailing Spaces</short>
+      </locale>
+    </schema>
+  </schemalist>
+</gconfschemafile>



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