[gedit] Use enums provided by gsettings.



commit ea26ea07ae8f52c07d5e080026a7bbf35dd0803d
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue Jun 29 13:18:02 2010 +0200

    Use enums provided by gsettings.

 plugins/time/gedit-time-plugin.c                   |   49 ++------------------
 .../time/org.gnome.gedit.time.gschema.xml.in.in    |   11 ++++-
 2 files changed, 14 insertions(+), 46 deletions(-)
---
diff --git a/plugins/time/gedit-time-plugin.c b/plugins/time/gedit-time-plugin.c
index 6920dfc..c243ea0 100644
--- a/plugins/time/gedit-time-plugin.c
+++ b/plugins/time/gedit-time-plugin.c
@@ -304,56 +304,17 @@ gedit_time_plugin_update_state (GeditWindowActivatable *activatable,
 static GeditTimePluginPromptType
 get_prompt_type (GeditTimePlugin *plugin)
 {
-	gchar *prompt_type;
-	GeditTimePluginPromptType res;
-
-	prompt_type = g_settings_get_string (plugin->priv->settings,
-					     PROMPT_TYPE_KEY);
-
-	if (prompt_type == NULL)
-		return PROMPT_SELECTED_FORMAT;
-
-	if (strcmp (prompt_type, "USE_SELECTED_FORMAT") == 0)
-		res = USE_SELECTED_FORMAT;
-	else if (strcmp (prompt_type, "USE_CUSTOM_FORMAT") == 0)
-		res = USE_CUSTOM_FORMAT;
-	else if (strcmp (prompt_type, "PROMPT_CUSTOM_FORMAT") == 0)
-		res = PROMPT_CUSTOM_FORMAT;
-	else
-		res = PROMPT_SELECTED_FORMAT;
-
-	g_free (prompt_type);
-
-	return res;
+	return g_settings_get_enum (plugin->priv->settings,
+				    PROMPT_TYPE_KEY);
 }
 
 static void
 set_prompt_type (GeditTimePlugin           *plugin,
 		 GeditTimePluginPromptType  prompt_type)
 {
-	const gchar * str;
-
-	switch (prompt_type)
-	{
-		case USE_SELECTED_FORMAT:
-			str = "USE_SELECTED_FORMAT";
-			break;
-		case USE_CUSTOM_FORMAT:
-			str = "USE_CUSTOM_FORMAT";
-			break;
-		case PROMPT_CUSTOM_FORMAT:
-			str = "PROMPT_CUSTOM_FORMAT";
-			break;
-		default:
-			str = "PROMPT_SELECTED_FORMAT";
-	}
-
-	g_warning (g_settings_get_string (plugin->priv->settings,
-			       PROMPT_TYPE_KEY));
-
-	g_settings_set_string (plugin->priv->settings,
-			       PROMPT_TYPE_KEY,
-			       str);
+	g_settings_set_enum (plugin->priv->settings,
+			     PROMPT_TYPE_KEY,
+			     prompt_type);
 }
 
 /* The selected format in the list */
diff --git a/plugins/time/org.gnome.gedit.time.gschema.xml.in.in b/plugins/time/org.gnome.gedit.time.gschema.xml.in.in
index 4d3af69..913df5f 100644
--- a/plugins/time/org.gnome.gedit.time.gschema.xml.in.in
+++ b/plugins/time/org.gnome.gedit.time.gschema.xml.in.in
@@ -1,7 +1,14 @@
 <schemalist>
+  <enum id="org.gnome.gedit.plugins.time.PromptType">
+    <value nick="prompt-selected-format" value="0"/>
+    <value nick="prompt-custom-format" value="1"/>
+    <value nick="use-selected-format" value="2"/>
+    <value nick="use-custom-format" value="3"/>
+  </enum>
+
   <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gedit.plugins.time" path="/apps/gedit/plugins/time/">
-    <key name="prompt-type" type="s">
-      <default>'USE_SELECTED_FORMAT'</default>
+    <key name="prompt-type" enum="org.gnome.gedit.plugins.time.PromptType">
+      <default>'use-selected-format'</default>
       <_summary>Prompt Type</_summary>
       <_description>If the user should be prompted for a format or if the selected or custom format should be used.</_description>
     </key>



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