[ghex] Use a custom enum type for group-data-by GSettings key



commit c5944e247699b3786d8f390cdd7d0f2fc90097e6
Author: Kalev Lember <kalevlember gmail com>
Date:   Mon Aug 8 21:27:11 2011 +0300

    Use a custom enum type for group-data-by GSettings key

 data/org.gnome.GHex.gschema.xml |   11 +++++++++--
 src/config.c                    |    4 ++--
 src/preferences.c               |    6 +++---
 3 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/data/org.gnome.GHex.gschema.xml b/data/org.gnome.GHex.gschema.xml
index e338df8..a73ca53 100644
--- a/data/org.gnome.GHex.gschema.xml
+++ b/data/org.gnome.GHex.gschema.xml
@@ -1,10 +1,17 @@
 <schemalist>
+
+  <enum id="org.gnome.GHex.GroupType">
+    <value nick="bytes" value="1"/>
+    <value nick="words" value="2"/>
+    <value nick="longwords" value="4"/>
+  </enum>
+
   <schema id="org.gnome.GHex" path="/org/gnome/ghex/">
     <key name="font" type="s">
       <default>'Monospace 12'</default>
     </key>
-    <key name="group-data-by" type="i">
-      <default>1</default>
+    <key name="group-data-by" enum="org.gnome.GHex.GroupType">
+      <default>'bytes'</default>
     </key>
     <key name="max-undo-depth" type="u">
       <default>100</default>
diff --git a/src/config.c b/src/config.c
index 608a056..0f7471f 100644
--- a/src/config.c
+++ b/src/config.c
@@ -75,7 +75,7 @@ void ghex_load_configuration () {
 	g_free (font_name);
 
 	/* Get the default group type -- SnM */
-	def_group_type = g_settings_get_int (settings, GHEX_PREF_GROUP);
+	def_group_type = g_settings_get_enum (settings, GHEX_PREF_GROUP);
 
 	/* Sanity check for group type */
 	if (def_group_type <= 0 )
@@ -150,7 +150,7 @@ group_changed_cb (GSettings   *settings,
                   const gchar *key,
                   gpointer     user_data)
 {
-    def_group_type = g_settings_get_int (settings, key);
+    def_group_type = g_settings_get_enum (settings, key);
 }
 
 static void
diff --git a/src/preferences.c b/src/preferences.c
index 87118fb..1f1ae4b 100644
--- a/src/preferences.c
+++ b/src/preferences.c
@@ -431,9 +431,9 @@ group_type_cb(GtkRadioButton *rd, PropertyUI *pui)
 			def_group_type = group_type[i];
 			break;
 		}
-	g_settings_set_int (settings,
-	                    GHEX_PREF_GROUP,
-	                    def_group_type);
+	g_settings_set_enum (settings,
+	                     GHEX_PREF_GROUP,
+	                     def_group_type);
 }
 
 static void



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