[sound-juicer/wip/gsettings] Paranoia values should be flags not enum



commit d1d74af8324a610c5ab33708e3d242ee6ecf53c4
Author: Phillip Wood <phillip wood dunelm org uk>
Date:   Wed Jan 22 12:14:36 2014 +0000

    Paranoia values should be flags not enum
    
    https://bugzilla.gnome.org/show_bug.cgi?id=625897

 data/org.gnome.sound-juicer.gschema.xml |   11 +++++------
 src/sj-main.c                           |   12 ++++++++----
 2 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/data/org.gnome.sound-juicer.gschema.xml b/data/org.gnome.sound-juicer.gschema.xml
index 83d0e0f..9a75d14 100644
--- a/data/org.gnome.sound-juicer.gschema.xml
+++ b/data/org.gnome.sound-juicer.gschema.xml
@@ -1,14 +1,13 @@
 <?xml version="1.0"?>
 <schemalist>
 
-  <enum id="org.gnome.sound-juicer.paranoia">
+  <flags id="org.gnome.sound-juicer.paranoia">
     <value nick="disable" value="0"/>
     <value nick="fragment" value="2"/>
     <value nick="overlap" value="4"/>
     <value nick="scratch" value="8"/>
     <value nick="repair" value="16"/>
-    <value nick="full" value="255"/>
-  </enum>
+  </flags>
 
   <schema gettext-domain="sound-juicer" id="org.gnome.sound-juicer" path="/org/gnome/sound-juicer/">
 
@@ -48,10 +47,10 @@
       <description>Do not specify an extension. Format specifiers: %at - album title; %aT - album title 
(lowercase); %aa - album artist; %aA - album artist (lowercase); %as - album artist (sortable); %aS - album 
artist (sortable lowercase); %ac - album composer; %aC - album composer (lowercase); %ap - album composer 
(sortable); %aP - album composer (sortable lowercase); %tn - track number (i.e 8); %tN - track number, zero 
padded (i.e 08); %tt - track title; %tT - track title (lowercase); %ta - track artist; %tA - track artist 
(lowercase); %ts - track artist (sortable); %tS - track artist (sortable lowercase); %tc - track composer; 
%tC - track composer (lowercase); %tp - track composer (sortable); %tP - track composer (sortable lowercase); 
%dn - disc and track number (i.e Disk 2 - 6, or 6); %dN - disc number, zero padded (i.e d02t06, or 
06)</description>
     </key>
 
-    <key name="paranoia" enum="org.gnome.sound-juicer.paranoia">
-      <default>'scratch'</default>
+    <key name="paranoia" flags="org.gnome.sound-juicer.paranoia">
+      <default>["fragment","overlap","scratch"]</default>
       <summary>The paranoia mode to use</summary>
-      <description>Paranoia mode: 0) disable; 2) fragment; 4) overlap; 8) scratch; 16) repair; 255) 
full</description>
+      <description>Paranoia flags: disable; fragment; overlap; scratch; repair</description>
     </key>
 
     <key name="strip-special" type="b">
diff --git a/src/sj-main.c b/src/sj-main.c
index bbbb093..a622da7 100644
--- a/src/sj-main.c
+++ b/src/sj-main.c
@@ -103,7 +103,7 @@ static char *device = NULL, **uris = NULL;
 
 static guint debug_flags = 0;
 
-#define DEFAULT_PARANOIA 4
+#define DEFAULT_PARANOIA 15
 #define RAISE_WINDOW "raise-window"
 #define SOURCE_BUILDER "../data/sound-juicer.ui"
 #define INSTALLED_BUILDER DATADIR"/sound-juicer/sound-juicer.ui"
@@ -1130,9 +1130,13 @@ static void paranoia_changed_cb (GSettings *settings, gchar *key, gpointer user_
 {
   int value;
   g_assert (strcmp (key, SJ_SETTINGS_PARANOIA) == 0);
-  value = g_settings_get_enum (settings, key);
-  if (value == 0 || value == 2 || value == 4 || value == 8 || value == 16 || value == 255) {
-    sj_extractor_set_paranoia (extractor, value);
+  value = g_settings_get_flags (settings, key);
+  if (value >= 0) {
+    if (value < 32) {
+      sj_extractor_set_paranoia (extractor, value);
+    } else {
+      sj_extractor_set_paranoia (extractor, DEFAULT_PARANOIA);
+    }
   }
 }
 


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