[easytag/wip/application-window: 3/3] Move tags preferences page to GtkBuilder



commit 5b613e04ff4f12250affa6efe6994709e7c75820
Author: David King <amigadave amigadave com>
Date:   Sat Aug 16 10:28:24 2014 +0100

    Move tags preferences page to GtkBuilder

 data/preferences_dialog.ui |  186 ++++++++++++++++++++++++++++++++++++++++++++
 src/preferences_dialog.c   |  164 +++++++--------------------------------
 2 files changed, 214 insertions(+), 136 deletions(-)
---
diff --git a/data/preferences_dialog.ui b/data/preferences_dialog.ui
index 9e7c9d4..ff9dd99 100644
--- a/data/preferences_dialog.ui
+++ b/data/preferences_dialog.ui
@@ -5,6 +5,16 @@
         <property name="step-increment">10.0</property>
         <property name="upper">1500.0</property>
     </object>
+    <object class="GtkAdjustment" id="tags_disc_adjustment">
+        <property name="lower">1.0</property>
+        <property name="step-increment">1.0</property>
+        <property name="upper">6.0</property>
+    </object>
+    <object class="GtkAdjustment" id="tags_track_adjustment">
+        <property name="lower">2.0</property>
+        <property name="step-increment">1.0</property>
+        <property name="upper">6.0</property>
+    </object>
     <object class="GtkGrid" id="ui_grid">
         <property name="border-width">12</property>
         <property name="orientation">vertical</property>
@@ -295,6 +305,182 @@
             </object>
         </child>
     </object>
+    <object class="GtkGrid" id="tags_grid">
+        <property name="border-width">12</property>
+        <property name="orientation">vertical</property>
+        <property name="row-spacing">6</property>
+        <property name="visible">True</property>
+        <child>
+            <object class="GtkLabel" id="tags_label">
+                <attributes>
+                    <attribute name="weight" value="bold"/>
+                </attributes>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">General</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkCheckButton" id="tags_auto_date_check">
+                <property name="label" translatable="yes">Automatically complete date field</property>
+                <property name="margin-left">12</property>
+                <property name="tooltip-text" translatable="yes">Whether to automatically complete the date 
tag</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkCheckButton" id="tags_preserve_focus_check">
+                <property name="label" translatable="yes">Preserve the tag field focus</property>
+                <property name="margin-left">12</property>
+                <property name="tooltip-text" translatable="yes">Whether to preserve focus on the current 
tag field when switching file</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkBox" id="tags_disc_box">
+                <property name="margin-left">12</property>
+                <property name="spacing">12</property>
+                <property name="visible">True</property>
+                <child>
+                    <object class="GtkCheckButton" id="tags_disc_check">
+                        <property name="label" translatable="yes">Whether to pad the disc field to this 
number of digits:</property>
+                        <property name="tooltip-text" translatable="yes">Whether the disc number tag field 
should be padded with leading zeroes</property>
+                        <property name="visible">True</property>
+                    </object>
+                </child>
+                <child>
+                    <object class="GtkSpinButton" id="tags_disc_button">
+                        <property name="adjustment">tags_disc_adjustment</property>
+                        <property name="visible">True</property>
+                    </object>
+                </child>
+            </object>
+        </child>
+        <child>
+            <object class="GtkBox" id="tags_track_box">
+                <property name="margin-left">12</property>
+                <property name="spacing">12</property>
+                <property name="visible">True</property>
+                <child>
+                    <object class="GtkCheckButton" id="tags_track_check">
+                        <property name="label" translatable="yes">Whether to pad the track field to this 
number of digits:</property>
+                        <property name="tooltip-text" translatable="yes">Whether the track number tag field 
should be padded with leading zeroes</property>
+                        <property name="visible">True</property>
+                    </object>
+                </child>
+                <child>
+                    <object class="GtkSpinButton" id="tags_track_button">
+                        <property name="adjustment">tags_track_adjustment</property>
+                        <property name="visible">True</property>
+                    </object>
+                </child>
+            </object>
+        </child>
+        <child>
+            <object class="GtkLabel" id="tags_splitting_label">
+                <attributes>
+                    <attribute name="weight" value="bold"/>
+                </attributes>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Splitting</property>
+                <property name="margin-top">12</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkLabel" id="tags_splitting_description_label">
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">For Vorbis tags, selected fields will be split at 
dashes and saved as separate tags</property>
+                <property name="margin-left">12</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkGrid" id="tags_splitting_grid">
+                <property name="column-spacing">18</property>
+                <property name="margin-left">12</property>
+                <property name="row-spacing">6</property>
+                <property name="visible">True</property>
+                <child>
+                    <object class="GtkCheckButton" id="split_title_check">
+                        <property name="label" translatable="yes">Title</property>
+                        <property name="tooltip-text" translatable="yes">Whether to split title fields at a 
" - " separator in Ogg comments</property>
+                        <property name="visible">True</property>
+                    </object>
+                    <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                    </packing>
+                </child>
+                <child>
+                    <object class="GtkCheckButton" id="split_artist_check">
+                        <property name="label" translatable="yes">Artist</property>
+                        <property name="tooltip-text" translatable="yes">Whether to split artist fields at a 
" - " separator in Ogg comments</property>
+                        <property name="visible">True</property>
+                    </object>
+                    <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                    </packing>
+                </child>
+                <child>
+                    <object class="GtkCheckButton" id="split_album_check">
+                        <property name="label" translatable="yes">Album</property>
+                        <property name="tooltip-text" translatable="yes">Whether to split album fields at a 
" - " separator in Ogg comments</property>
+                        <property name="visible">True</property>
+                    </object>
+                    <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                    </packing>
+                </child>
+                <child>
+                    <object class="GtkCheckButton" id="split_genre_check">
+                        <property name="label" translatable="yes">Genre</property>
+                        <property name="tooltip-text" translatable="yes">Whether to split genre fields at a 
" - " separator in Ogg comments</property>
+                        <property name="visible">True</property>
+                    </object>
+                    <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">3</property>
+                    </packing>
+                </child>
+                <child>
+                    <object class="GtkCheckButton" id="split_comment_check">
+                        <property name="label" translatable="yes">Comment</property>
+                        <property name="tooltip-text" translatable="yes">Whether to split comment fields at 
a " - " separator in Ogg comments</property>
+                        <property name="visible">True</property>
+                    </object>
+                    <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                    </packing>
+                </child>
+                <child>
+                    <object class="GtkCheckButton" id="split_composer_check">
+                        <property name="label" translatable="yes">Composer</property>
+                        <property name="tooltip-text" translatable="yes">Whether to split composer fields at 
a " - " separator in Ogg comments</property>
+                        <property name="visible">True</property>
+                    </object>
+                    <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
+                    </packing>
+                </child>
+                <child>
+                    <object class="GtkCheckButton" id="split_orig_artist_check">
+                        <property name="label" translatable="yes">Original artist</property>
+                        <property name="tooltip-text" translatable="yes">Whether to split original artist 
fields at a " - " separator in Ogg comments</property>
+                        <property name="visible">True</property>
+                    </object>
+                    <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">2</property>
+                    </packing>
+                </child>
+            </object>
+        </child>
+    </object>
     <object class="GtkGrid" id="scanner_grid">
         <property name="border-width">12</property>
         <property name="orientation">vertical</property>
diff --git a/src/preferences_dialog.c b/src/preferences_dialog.c
index fd09877..4e5ac17 100644
--- a/src/preferences_dialog.c
+++ b/src/preferences_dialog.c
@@ -87,11 +87,6 @@ struct _EtPreferencesDialogPrivate
  * Prototypes *
  **************/
 /* Options window */
-static void Number_Track_Formatted_Spin_Button_Changed (GtkWidget *Label,
-                                                        GtkWidget *SpinButton);
-static void et_prefs_on_pad_disc_number_spinbutton_changed (GtkWidget *label,
-                                                            GtkWidget *spinbutton);
-
 static void Change_Id3_Settings_Toggled (GtkWidget *blah, EtPreferencesDialog *self);
 
 static void et_preferences_on_response (GtkDialog *dialog, gint response_id,
@@ -224,7 +219,6 @@ create_preferences_dialog (EtPreferencesDialog *self)
     GtkWidget *Table;
     GtkWidget *VBox, *vbox;
     GtkWidget *hbox, *id3v1v2hbox;
-    GtkWidget *Separator;
     GtkWidget *LoadOnStartup;
     GtkWidget *BrowseSubdir;
     GtkWidget *OpenSelectedBrowserNode;
@@ -502,38 +496,24 @@ create_preferences_dialog (EtPreferencesDialog *self)
     /*
      * Tag Settings
      */
-    Label = gtk_label_new (_("Tag Settings"));
-    VBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, BOX_SPACING);
+    Label = gtk_label_new (_("Tags"));
+    VBox = GTK_WIDGET (gtk_builder_get_object (builder, "tags_grid"));
     gtk_notebook_append_page (GTK_NOTEBOOK (priv->options_notebook), VBox, Label);
-    gtk_container_set_border_width (GTK_CONTAINER (VBox), BOX_SPACING);
 
     /* Tag Options */
-    Frame = gtk_frame_new (_("Tag Options"));
-    gtk_box_pack_start(GTK_BOX(VBox),Frame,FALSE,FALSE,0);
-    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, BOX_SPACING);
-    gtk_container_add(GTK_CONTAINER(Frame),vbox);
-    gtk_container_set_border_width (GTK_CONTAINER (vbox), BOX_SPACING);
-
-    DateAutoCompletion = gtk_check_button_new_with_label(_("Auto completion of date if not complete"));
-    gtk_box_pack_start(GTK_BOX(vbox),DateAutoCompletion,FALSE,FALSE,0);
+    DateAutoCompletion = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                             "tags_auto_date_check"));
     g_settings_bind (MainSettings, "tag-date-autocomplete", DateAutoCompletion,
                      "active", G_SETTINGS_BIND_DEFAULT);
-    gtk_widget_set_tooltip_text (DateAutoCompletion,
-                                 _("Whether to automatically complete the date tag"));
 
     /* Track formatting. */
-    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BOX_SPACING);
-    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
-
-    NumberTrackFormated = gtk_check_button_new_with_label(_("Write the track field with the following number 
of digits:"));
-    gtk_box_pack_start(GTK_BOX(hbox),NumberTrackFormated,FALSE,FALSE,0);
+    NumberTrackFormated = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                              "tags_track_check"));
     g_settings_bind (MainSettings, "tag-number-padded", NumberTrackFormated,
                      "active", G_SETTINGS_BIND_DEFAULT);
-    gtk_widget_set_tooltip_text (NumberTrackFormated,
-                                 _("Whether the track number tag field should be padded with leading 
zeroes"));
 
-    NumberTrackFormatedSpinButton = gtk_spin_button_new_with_range(2.0,6.0,1.0);
-    gtk_box_pack_start(GTK_BOX(hbox),NumberTrackFormatedSpinButton,FALSE,FALSE,0);
+    NumberTrackFormatedSpinButton = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                        "tags_track_button"));
     g_settings_bind (MainSettings, "tag-number-length",
                      NumberTrackFormatedSpinButton, "value",
                      G_SETTINGS_BIND_DEFAULT);
@@ -541,28 +521,14 @@ create_preferences_dialog (EtPreferencesDialog *self)
                      NumberTrackFormatedSpinButton, "sensitive",
                      G_SETTINGS_BIND_DEFAULT);
 
-    Label = gtk_label_new(""); // Label to show the example
-    gtk_box_pack_start(GTK_BOX(hbox),Label,FALSE,FALSE,4);
-    g_signal_connect_swapped (NumberTrackFormatedSpinButton, "changed",
-                              G_CALLBACK (Number_Track_Formatted_Spin_Button_Changed),
-                              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);
+    pad_disc_number = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                          "tags_disc_check"));
     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"));
 
-    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);
+    pad_disc_number_spinbutton = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                     "tags_disc_button"));
     g_settings_bind (MainSettings, "tag-number-length",
                      pad_disc_number_spinbutton, "value",
                      G_SETTINGS_BIND_DEFAULT);
@@ -571,56 +537,27 @@ create_preferences_dialog (EtPreferencesDialog *self)
                      G_SETTINGS_BIND_GET);
     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 ((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);
-
     /* Tag field focus */
-    SetFocusToSameTagField = gtk_check_button_new_with_label (_("Preserve the tag field focus"));
-    gtk_box_pack_start (GTK_BOX (vbox), SetFocusToSameTagField, FALSE, FALSE,
-                        0);
+    SetFocusToSameTagField = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                 "tags_preserve_focus_check"));
     g_settings_bind (MainSettings, "tag-preserve-focus", SetFocusToSameTagField,
                      "active", G_SETTINGS_BIND_DEFAULT);
-    gtk_widget_set_tooltip_text (SetFocusToSameTagField,
-                                 _("hether to preserve focus on the current tag field when switching file"));
 
     /* Tag Splitting */
-    Frame = gtk_frame_new (_("Tag Splitting"));
-    gtk_box_pack_start(GTK_BOX(VBox),Frame,FALSE,FALSE,0);
-
-    Table = et_grid_new (5, 2);
-    gtk_container_add(GTK_CONTAINER(Frame),Table);
-    gtk_container_set_border_width (GTK_CONTAINER (Table), BOX_SPACING);
-    gtk_grid_set_column_spacing (GTK_GRID (Table), BOX_SPACING);
-    gtk_grid_set_row_spacing (GTK_GRID (Table), BOX_SPACING);
-    
-    Label = gtk_label_new(_("For Vorbis tags, selected fields will be split at dashes and saved as separate 
tags"));
-    gtk_grid_attach (GTK_GRID (Table), Label, 0, 0, 2, 1);
-    gtk_widget_set_halign (Label, GTK_ALIGN_START);
-
-    VorbisSplitFieldTitle = gtk_check_button_new_with_label(_("Title"));
-    VorbisSplitFieldArtist = gtk_check_button_new_with_label(_("Artist"));
-    VorbisSplitFieldAlbum = gtk_check_button_new_with_label(_("Album"));
-    VorbisSplitFieldGenre = gtk_check_button_new_with_label(_("Genre"));
-    VorbisSplitFieldComment = gtk_check_button_new_with_label(_("Comment"));
-    VorbisSplitFieldComposer = gtk_check_button_new_with_label(_("Composer"));
-    VorbisSplitFieldOrigArtist = gtk_check_button_new_with_label(_("Original artist"));
-
-    gtk_grid_attach (GTK_GRID (Table), VorbisSplitFieldTitle, 0, 1, 1, 1);
-    gtk_grid_attach (GTK_GRID (Table), VorbisSplitFieldArtist, 0, 2, 1, 1);
-    gtk_grid_attach (GTK_GRID (Table), VorbisSplitFieldAlbum, 0, 3, 1, 1);
-    gtk_grid_attach (GTK_GRID (Table), VorbisSplitFieldGenre, 0, 4, 1, 1);
-    gtk_grid_attach (GTK_GRID (Table), VorbisSplitFieldComment, 1, 1, 1, 1);
-    gtk_grid_attach (GTK_GRID (Table), VorbisSplitFieldComposer, 1, 2, 1, 1);
-    gtk_grid_attach (GTK_GRID (Table), VorbisSplitFieldOrigArtist, 1, 3, 1, 1);
+    VorbisSplitFieldTitle = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                "split_title_check"));
+    VorbisSplitFieldArtist = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                 "split_artist_check"));
+    VorbisSplitFieldAlbum = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                "split_album_check"));
+    VorbisSplitFieldGenre = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                "split_genre_check"));
+    VorbisSplitFieldComment = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                  "split_comment_check"));
+    VorbisSplitFieldComposer = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                   "split_composer_check"));
+    VorbisSplitFieldOrigArtist = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                     "split_orig_artist_check"));
 
     g_settings_bind (MainSettings, "ogg-split-title", VorbisSplitFieldTitle,
                      "active", G_SETTINGS_BIND_DEFAULT);
@@ -1372,51 +1309,6 @@ create_preferences_dialog (EtPreferencesDialog *self)
 }
 
 static void
-Number_Track_Formatted_Spin_Button_Changed (GtkWidget *Label,
-                                            GtkWidget *SpinButton)
-{
-    gchar *tmp;
-    gint val;
-
-    if (g_settings_get_boolean (MainSettings, "tag-number-padded"))
-    {
-        val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (SpinButton));
-    }
-    else
-        val = 1;
-
-    // For translators : be aware to NOT translate '%.*d' in this string
-    tmp = g_strdup_printf(_("(Example: %.*d_-_Track_name_1.mp3)"),val,1);
-
-    gtk_label_set_text(GTK_LABEL(Label),tmp);
-    g_free(tmp);
-}
-
-static void
-et_prefs_on_pad_disc_number_spinbutton_changed (GtkWidget *label,
-                                                GtkWidget *spinbutton)
-{
-    gchar *tmp;
-    guint val;
-
-    if (g_settings_get_boolean (MainSettings, "tag-disc-padded"))
-    {
-        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
 Change_Id3_Settings_Toggled (GtkWidget *blah, EtPreferencesDialog *self)
 {
     EtPreferencesDialogPrivate *priv;


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