[easytag] Add settings to control padding of disc numbers
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Add settings to control padding of disc numbers
- Date: Mon, 29 Jul 2013 13:42:17 +0000 (UTC)
commit 20aa21b2bd68275cec5fbd9e36186b4c7e6eb14f
Author: Mathias Reineke <saihtam gmx net>
Date: Mon Jul 8 10:42:15 2013 +0200
Add settings to control padding of disc numbers
src/misc.c | 11 +++++++++
src/misc.h | 1 +
src/prefs.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/prefs.h | 2 +
src/setting.c | 6 +++++
src/setting.h | 2 +
6 files changed, 90 insertions(+), 0 deletions(-)
---
diff --git a/src/misc.c b/src/misc.c
index 4f39bf7..1ac93e8 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -3698,6 +3698,17 @@ et_playlist_on_response (GtkDialog *dialog, gint response_id,
}
gchar *
+et_disc_number_to_string (const guint disc_number)
+{
+ if (PAD_DISC_NUMBER)
+ {
+ return g_strdup_printf ("%.*d", PAD_DISC_NUMBER_DIGITS, disc_number);
+ }
+
+ return g_strdup_printf ("%d", disc_number);
+}
+
+gchar *
et_track_number_to_string (const guint track_number)
{
return NUMBER_TRACK_FORMATED ? g_strdup_printf ("%.*d",
diff --git a/src/misc.h b/src/misc.h
index 1844e0a..cdddf86 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -108,6 +108,7 @@ void Search_File_Window_Apply_Changes (void);
void Open_Load_Filename_Window (void);
void Load_Filename_Window_Apply_Changes (void);
+gchar * et_disc_number_to_string (const guint disc_number);
gchar * et_track_number_to_string (const guint track_number);
#endif /* __MISC_H__ */
diff --git a/src/prefs.c b/src/prefs.c
index 2a11541..1922080 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -58,6 +58,10 @@ static void Set_Default_Comment_Check_Button_Toggled (void);
static void Number_Track_Formatted_Toggled (void);
static void Number_Track_Formatted_Spin_Button_Changed (GtkWidget *Label,
GtkWidget *SpinButton);
+static void et_prefs_on_pad_disc_number_toggled (void);
+static void et_prefs_on_pad_disc_number_spinbutton_changed (GtkWidget *label,
+ GtkWidget *spinbutton);
+
static void Change_Id3_Settings_Toggled (void);
static void Use_Non_Standard_Id3_Reading_Character_Set_Toggled (void);
static void Scanner_Convert_Check_Button_Toggled_1 (GtkWidget *object_rec,
@@ -545,6 +549,7 @@ void Open_OptionsWindow (void)
"only the last numerals of the date (for instance, if the current year is 2005: "
"5 => 2005, 4 => 2004, 6 => 1996, 95 => 1995…)."));
+ /* Track formatting. */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BOX_SPACING);
gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
@@ -566,6 +571,35 @@ void Open_OptionsWindow (void)
g_signal_connect_swapped(G_OBJECT(NumberTrackFormatedSpinButton),"changed",G_CALLBACK(Number_Track_Formatted_Spin_Button_Changed),G_OBJECT(Label));
g_signal_emit_by_name(G_OBJECT(NumberTrackFormatedSpinButton),"changed",NULL);
+ /* Disc formatting. */
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BOX_SPACING);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+
+ 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);
+ gtk_widget_set_tooltip_text (pad_disc_number,
+ _("Whether to pad the disc field with leading zeroes"));
+
+ pad_disc_number_spinbutton = gtk_spin_button_new_with_range (1.0, 6.0,
+ 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_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");
+
+ /* Label to show the example. */
+ Label = gtk_label_new ("");
+ gtk_box_pack_start (GTK_BOX (hbox), Label, FALSE, FALSE, BOX_SPACING);
+ g_signal_connect_swapped (G_OBJECT (pad_disc_number_spinbutton), "changed",
+ G_CALLBACK (et_prefs_on_pad_disc_number_spinbutton_changed),
+ Label);
+ g_signal_emit_by_name (G_OBJECT (pad_disc_number_spinbutton), "changed");
+
// Separator line
Separator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
gtk_box_pack_start(GTK_BOX(vbox),Separator,FALSE,FALSE,0);
@@ -1408,6 +1442,40 @@ Number_Track_Formatted_Spin_Button_Changed (GtkWidget *Label,
}
static void
+et_prefs_on_pad_disc_number_toggled (void)
+{
+ gtk_widget_set_sensitive (pad_disc_number_spinbutton,
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pad_disc_number)));
+ /* Update the example. */
+ g_signal_emit_by_name (G_OBJECT (pad_disc_number_spinbutton), "changed",
+ NULL);
+}
+
+static void
+et_prefs_on_pad_disc_number_spinbutton_changed (GtkWidget *label,
+ GtkWidget *spinbutton)
+{
+ gchar *tmp;
+ guint val;
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pad_disc_number)))
+ {
+ val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spinbutton));
+ }
+ else
+ {
+ val = 1;
+ }
+
+ /* Translators: please do NOT translate '%.*d' in this string. */
+ tmp = g_strdup_printf (_("(Example: disc_%.*d_of_10/Track_name_1.mp3)"),
+ val, 1);
+
+ gtk_label_set_text (GTK_LABEL (label), tmp);
+ g_free (tmp);
+}
+
+static void
Use_Non_Standard_Id3_Reading_Character_Set_Toggled (void)
{
gtk_widget_set_sensitive(FileReadingId3v1v2CharacterSetCombo,
diff --git a/src/prefs.h b/src/prefs.h
index a389998..5e8442e 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -107,6 +107,8 @@ GtkWidget *LabelId3v2Version;
GtkWidget *DateAutoCompletion;
GtkWidget *NumberTrackFormated;
GtkWidget *NumberTrackFormatedSpinButton;
+GtkWidget *pad_disc_number;
+GtkWidget *pad_disc_number_spinbutton;
GtkWidget *SetFocusToSameTagField;
GtkWidget *SetFocusToFirstTagField;
GtkWidget *LogMaxLinesSpinButton;
diff --git a/src/setting.c b/src/setting.c
index 503bcdd..49520ce 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -135,6 +135,8 @@ static const tConfigVariable Config_Variables[] =
{"date_auto_completion", CV_TYPE_BOOL, &DATE_AUTO_COMPLETION },
{"number_track_formated", CV_TYPE_BOOL, &NUMBER_TRACK_FORMATED },
{"number_track_formated_spin_button", CV_TYPE_INT, &NUMBER_TRACK_FORMATED_SPIN_BUTTON },
+ {"pad_disc_number", CV_TYPE_BOOL, &PAD_DISC_NUMBER },
+ {"pad_disc_number_digits", CV_TYPE_INT, &PAD_DISC_NUMBER_DIGITS },
{"set_focus_to_same_tag_field", CV_TYPE_BOOL, &SET_FOCUS_TO_SAME_TAG_FIELD },
{"set_focus_to_first_tag_field", CV_TYPE_BOOL, &SET_FOCUS_TO_FIRST_TAG_FIELD },
{"sorting_file_mode", CV_TYPE_INT, &SORTING_FILE_MODE },
@@ -378,6 +380,8 @@ void Init_Config_Variables (void)
DATE_AUTO_COMPLETION = 1;
NUMBER_TRACK_FORMATED = 1;
NUMBER_TRACK_FORMATED_SPIN_BUTTON = 2;
+ PAD_DISC_NUMBER = 1;
+ PAD_DISC_NUMBER_DIGITS = 1;
SET_FOCUS_TO_SAME_TAG_FIELD = 1;
SET_FOCUS_TO_FIRST_TAG_FIELD = 0;
SORTING_FILE_MODE = SORTING_BY_ASCENDING_FILENAME;
@@ -667,6 +671,8 @@ Apply_Changes_Of_Preferences_Window (void)
DATE_AUTO_COMPLETION =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(DateAutoCompletion));
NUMBER_TRACK_FORMATED =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(NumberTrackFormated));
NUMBER_TRACK_FORMATED_SPIN_BUTTON =
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(NumberTrackFormatedSpinButton));
+ 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));
SET_FOCUS_TO_SAME_TAG_FIELD =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(SetFocusToSameTagField));
SET_FOCUS_TO_FIRST_TAG_FIELD =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(SetFocusToFirstTagField));
diff --git a/src/setting.h b/src/setting.h
index c8b85a4..3da0d8b 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -126,6 +126,8 @@ gint VORBIS_SPLIT_FIELD_ORIG_ARTIST;
gint DATE_AUTO_COMPLETION;
gint NUMBER_TRACK_FORMATED;
gint NUMBER_TRACK_FORMATED_SPIN_BUTTON;
+gint PAD_DISC_NUMBER;
+gint PAD_DISC_NUMBER_DIGITS;
gint SET_FOCUS_TO_SAME_TAG_FIELD;
gint SET_FOCUS_TO_FIRST_TAG_FIELD;
gint LOG_MAX_LINES;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]