[easytag/wip/application-window] Store disc padding preferences in GSettings



commit b56b1de30297eb0397755e39e24dc5ea951aac91
Author: David King <amigadave amigadave com>
Date:   Fri May 9 21:18:26 2014 +0100

    Store disc padding preferences in GSettings

 data/org.gnome.EasyTAG.gschema.xml |   15 +++++++++++++++
 src/misc.c                         |    7 +++++--
 src/preferences_dialog.c           |    9 +++++----
 src/setting.c                      |    6 ------
 src/setting.h                      |    3 ---
 5 files changed, 25 insertions(+), 15 deletions(-)
---
diff --git a/data/org.gnome.EasyTAG.gschema.xml b/data/org.gnome.EasyTAG.gschema.xml
index de1e5d4..d4f530e 100644
--- a/data/org.gnome.EasyTAG.gschema.xml
+++ b/data/org.gnome.EasyTAG.gschema.xml
@@ -370,6 +370,21 @@
       <default>true</default>
     </key>
 
+    <key name="tag-disc-padded" type="b">
+      <summary>Pad the disc number tag field</summary>
+      <description>Whether the disc number tag field should be padded with
+      leading zeroes</description>
+      <default>true</default>
+    </key>
+
+    <key name="tag-disc-length" type="u">
+      <summary>The length of the disc number field</summary>
+      <description>The length of the disc number field, which controls if the
+      field is padded with leading zeroes</description>
+      <default>2</default>
+      <range min="0" max="6" />
+    </key>
+
     <key name="tag-number-padded" type="b">
       <summary>Pad the track number tag field</summary>
       <description>Whether the track number tag field should be padded with
diff --git a/src/misc.c b/src/misc.c
index e514df4..041eb76 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -890,9 +890,12 @@ et_get_file_size (const gchar *filename)
 gchar *
 et_disc_number_to_string (const guint disc_number)
 {
-    if (PAD_DISC_NUMBER)
+    if (g_settings_get_boolean (MainSettings, "tag-disc-padded"))
     {
-        return g_strdup_printf ("%.*d", PAD_DISC_NUMBER_DIGITS, disc_number);
+        return g_strdup_printf ("%.*d",
+                                g_settings_get_uint (MainSettings,
+                                                     "tag-disc-length"),
+                                disc_number);
     }
 
     return g_strdup_printf ("%d", disc_number);
diff --git a/src/preferences_dialog.c b/src/preferences_dialog.c
index a4048ff..ef6158c 100644
--- a/src/preferences_dialog.c
+++ b/src/preferences_dialog.c
@@ -653,8 +653,8 @@ create_preferences_dialog (EtPreferencesDialog *self)
 
     pad_disc_number = gtk_check_button_new_with_label (_("Write the disc field with the following number of 
digits:"));
     gtk_box_pack_start (GTK_BOX (hbox), pad_disc_number, FALSE, FALSE, 0);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pad_disc_number),
-                                  PAD_DISC_NUMBER);
+    g_settings_bind (MainSettings, "tag-number-padded", pad_disc_number,
+                     "active", G_SETTINGS_BIND_DEFAULT);
     gtk_widget_set_tooltip_text (pad_disc_number,
                                  _("Whether to pad the disc field with leading zeroes"));
 
@@ -662,8 +662,9 @@ create_preferences_dialog (EtPreferencesDialog *self)
                                                                  1.0);
     gtk_box_pack_start (GTK_BOX (hbox), pad_disc_number_spinbutton, FALSE,
                         FALSE, 0);
-    gtk_spin_button_set_value (GTK_SPIN_BUTTON (pad_disc_number_spinbutton),
-                               (gfloat)PAD_DISC_NUMBER_DIGITS);
+    g_settings_bind (MainSettings, "tag-number-length",
+                     pad_disc_number_spinbutton, "value",
+                     G_SETTINGS_BIND_DEFAULT);
     g_signal_connect (G_OBJECT (pad_disc_number), "toggled",
                       G_CALLBACK (et_prefs_on_pad_disc_number_toggled), NULL);
     g_signal_emit_by_name (G_OBJECT (pad_disc_number), "toggled");
diff --git a/src/setting.c b/src/setting.c
index e9cc3f4..e2fd44d 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -117,8 +117,6 @@ static const tConfigVariable Config_Variables[] =
 {
     {"default_path_to_mp3",                 CV_TYPE_STRING,  &DEFAULT_PATH_TO_MP3               },
 
-    {"pad_disc_number", CV_TYPE_BOOL, &PAD_DISC_NUMBER },
-    {"pad_disc_number_digits", CV_TYPE_INT, &PAD_DISC_NUMBER_DIGITS },
     {"sorting_file_case_sensitive",          CV_TYPE_BOOL,    &SORTING_FILE_CASE_SENSITIVE              },
 
     {"file_reading_id3v1v2_character_set",             CV_TYPE_STRING,&FILE_READING_ID3V1V2_CHARACTER_SET},
@@ -200,8 +198,6 @@ void Init_Config_Variables (void)
     /*
      * Misc
      */
-    PAD_DISC_NUMBER = 1;
-    PAD_DISC_NUMBER_DIGITS = 1;
 #ifdef G_OS_WIN32
     SORTING_FILE_CASE_SENSITIVE             = 1;
 #else /* !G_OS_WIN32 */
@@ -321,8 +317,6 @@ Apply_Changes_Of_Preferences_Window (void)
 #endif /* G_OS_WIN32 */
 #endif
         /* Misc */
-        PAD_DISC_NUMBER = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pad_disc_number));
-        PAD_DISC_NUMBER_DIGITS = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON 
(pad_disc_number_spinbutton));
         SORTING_FILE_CASE_SENSITIVE            = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(SortingFileCaseSensitive));
 
         temp_sort = gtk_combo_box_get_active (GTK_COMBO_BOX (SortingFileCombo));
diff --git a/src/setting.h b/src/setting.h
index bed6f40..2a084e0 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -172,9 +172,6 @@ gchar  *FILE_WRITING_ID3V2_NO_UNICODE_CHARACTER_SET;
 
 gchar  *FILE_WRITING_ID3V1_CHARACTER_SET;
 
-gint PAD_DISC_NUMBER;
-gint PAD_DISC_NUMBER_DIGITS;
-
 /* Scanner */
 gint    FTS_CONVERT_UNDERSCORE_AND_P20_INTO_SPACE;
 gint    FTS_CONVERT_SPACE_INTO_UNDERSCORE;


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