[easytag/wip/application-window] WIP Move scanner page of preferences dialog to GtkBuilder



commit f44c8d4543fc8f7735cb9c730ceed0f873e26550
Author: David King <amigadave amigadave com>
Date:   Fri Aug 15 22:48:37 2014 +0100

    WIP Move scanner page of preferences dialog to GtkBuilder
    
    Still TODO: Reduce height of page.

 data/org.gnome.EasyTAG.gresource.xml |    1 +
 data/preferences_dialog.ui           |  179 ++++++++++++++++++++++++++++++++++
 src/preferences_dialog.c             |  135 ++++++++------------------
 3 files changed, 219 insertions(+), 96 deletions(-)
---
diff --git a/data/org.gnome.EasyTAG.gresource.xml b/data/org.gnome.EasyTAG.gresource.xml
index f68ec89..562af2b 100644
--- a/data/org.gnome.EasyTAG.gresource.xml
+++ b/data/org.gnome.EasyTAG.gresource.xml
@@ -2,6 +2,7 @@
 <gresources>
     <gresource prefix='/org/gnome/EasyTAG'>
         <file preprocess='xml-stripblanks'>menus.ui</file>
+        <file preprocess='xml-stripblanks'>preferences_dialog.ui</file>
         <file preprocess='xml-stripblanks'>toolbar.ui</file>
         <file preprocess='to-pixdata'>images/all-lowercase.png</file>
         <file preprocess='to-pixdata'>images/all-uppercase.png</file>
diff --git a/data/preferences_dialog.ui b/data/preferences_dialog.ui
new file mode 100644
index 0000000..af88582
--- /dev/null
+++ b/data/preferences_dialog.ui
@@ -0,0 +1,179 @@
+<interface domain="easytag">
+    <requires lib="gtk+" version="3.4"/>
+    <object class="GtkGrid" id="scanner_grid">
+        <property name="orientation">vertical</property>
+        <property name="row-spacing">6</property>
+        <property name="visible">True</property>
+        <child>
+            <object class="GtkLabel" id="character_conversion_label">
+                <attributes>
+                    <attribute name="weight" value="bold"/>
+                </attributes>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Character Conversion</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkLabel" id="fill_tag_scanner_label">
+                <attributes>
+                    <attribute name="weight" value="bold"/>
+                </attributes>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Fill Tag Scanner</property>
+                <property name="margin-left">12</property>
+                <property name="margin-top">12</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkRadioButton" id="fts_underscore_p20_radio">
+                <property name="label" translatable="yes">Convert underscores and '%20' to spaces</property>
+                <property name="margin-left">24</property>
+                <property name="name">spaces</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkRadioButton" id="fts_spaces_radio">
+                <property name="group">fts_underscore_p20_radio</property>
+                <property name="label" translatable="yes">Convert spaces and '%20' to underscores</property>
+                <property name="margin-left">24</property>
+                <property name="name">underscores</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkRadioButton" id="fts_none_radio">
+                <property name="group">fts_underscore_p20_radio</property>
+                <property name="label" translatable="yes">No conversion</property>
+                <property name="margin-left">24</property>
+                <property name="name">no-change</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkLabel" id="rename_file_directory_scanner_label">
+                <attributes>
+                    <attribute name="weight" value="bold"/>
+                </attributes>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Rename File and Directory Scanner</property>
+                <property name="margin-left">12</property>
+                <property name="margin-top">12</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkRadioButton" id="rfs_underscore_p20_radio">
+                <property name="label" translatable="yes">Convert underscores and '%20' to spaces</property>
+                <property name="margin-left">24</property>
+                <property name="name">spaces</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkRadioButton" id="rfs_spaces_radio">
+                <property name="group">rfs_underscore_p20_radio</property>
+                <property name="label" translatable="yes">Convert spaces and '%20' to underscores</property>
+                <property name="margin-left">24</property>
+                <property name="name">underscores</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkRadioButton" id="rfs_remove_radio">
+                <property name="group">rfs_underscore_p20_radio</property>
+                <property name="label" translatable="yes">No conversion</property>
+                <property name="margin-left">24</property>
+                <property name="name">remove</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkLabel" id="process_fields_scanner_label">
+                <attributes>
+                    <attribute name="weight" value="bold"/>
+                </attributes>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Process Fields Scanner</property>
+                <property name="margin-left">12</property>
+                <property name="margin-top">12</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkCheckButton" id="pfs_uppercase_prep_check">
+                <property name="label" translatable="yes">Upper-case the first letters of all words, 
including prepositions and articles</property>
+                <property name="margin-left">24</property>
+                <property name="tooltip-text" translatable="yes">Whether to upper-case the first letter of 
prepositions and some other short words such as "feat." when processing tag fields</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkLabel" id="scanner_dialog_label">
+                <attributes>
+                    <attribute name="weight" value="bold"/>
+                </attributes>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Scanner Dialog</property>
+                <property name="margin-top">12</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkCheckButton" id="scanner_dialog_startup_check">
+                <property name="label" translatable="yes">Show the scanner dialog on startup</property>
+                <property name="margin-left">12</property>
+                <property name="tooltip-text" translatable="yes">Whether to show the scanner window on 
application startup</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkLabel" id="fields_label">
+                <attributes>
+                    <attribute name="weight" value="bold"/>
+                </attributes>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Fields</property>
+                <property name="margin-top">12</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkCheckButton" id="overwrite_fields_check">
+                <property name="label" translatable="yes">Overwrite fields when scanning tags</property>
+                <property name="margin-left">12</property>
+                <property name="tooltip-text" translatable="yes">Whether to overwrite the tag field values 
when filling tags. Otherwise, only blank tag fields will be filled</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkBox" id="default_comment_box">
+                <property name="margin-left">12</property>
+                <property name="spacing">12</property>
+                <property name="visible">True</property>
+                <child>
+                    <object class="GtkCheckButton" id="default_comment_check">
+                        <property name="label" translatable="yes">Set this text as default 
comment:</property>
+                        <property name="tooltip-text" translatable="yes">Whether to set the comment tag 
field to the provided default value when filling tags</property>
+                        <property name="visible">True</property>
+                    </object>
+                </child>
+                <child>
+                    <object class="GtkEntry" id="default_comment_entry">
+                        <property name="visible">True</property>
+                    </object>
+                </child>
+            </object>
+        </child>
+        <child>
+            <object class="GtkCheckButton" id="crc32_default_check">
+                <property name="label" translatable="yes">Use CRC32 as the default comment (for files with 
ID3 tags only)</property>
+                <property name="margin-left">12</property>
+                <property name="tooltip-text" translatable="yes">Whether to use the CRC-32 of the audio file 
data as the default comment, for files with ID3 tags only</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+    </object>
+</interface>
diff --git a/src/preferences_dialog.c b/src/preferences_dialog.c
index 986024a..83772ac 100644
--- a/src/preferences_dialog.c
+++ b/src/preferences_dialog.c
@@ -296,6 +296,8 @@ create_preferences_dialog (EtPreferencesDialog *self)
     GtkWidget *FilenameExtensionLowerCase;
     GtkWidget *FilenameExtensionUpperCase;
     GtkWidget *default_path_button;
+    GtkBuilder *builder;
+    GError *error = NULL;
 
     priv = et_preferences_dialog_get_instance_private (self);
 
@@ -1148,7 +1150,18 @@ create_preferences_dialog (EtPreferencesDialog *self)
      * Scanner
      */
     Label = gtk_label_new (_("Scanner"));
-    VBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, BOX_SPACING);
+    builder = gtk_builder_new ();
+    gtk_builder_add_from_resource (builder,
+                                   "/org/gnome/EasyTAG/preferences_dialog.ui",
+                                   &error);
+
+    if (error != NULL)
+    {
+        g_error ("Unable to get scanner page from resource: %s",
+                 error->message);
+    }
+
+    VBox = GTK_WIDGET (gtk_builder_get_object (builder, "scanner_grid"));
     gtk_notebook_append_page (GTK_NOTEBOOK(priv->options_notebook), VBox, Label);
     gtk_container_set_border_width (GTK_CONTAINER (VBox), BOX_SPACING);
 
@@ -1157,25 +1170,11 @@ create_preferences_dialog (EtPreferencesDialog *self)
                                                             VBox);
 
     /* Character conversion for the 'Fill Tag' scanner (=> FTS...) */
-    Frame = gtk_frame_new (_("Fill Tag Scanner - Character Conversion"));
-    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);
-
-    FTSConvertUnderscoreAndP20IntoSpace = gtk_radio_button_new_with_label_from_widget (NULL,
-       _("Convert underscore character '_' and string '%20' to space ' '"));
-    gtk_widget_set_name (FTSConvertUnderscoreAndP20IntoSpace, "spaces");
-    FTSConvertSpaceIntoUnderscore = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON 
(FTSConvertUnderscoreAndP20IntoSpace),
-                                                                                 _("Convert space ' ' to 
underscore '_'"));
-    gtk_widget_set_name (FTSConvertSpaceIntoUnderscore, "underscores");
-    FTSConvertSpaceNoChange = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON 
(FTSConvertUnderscoreAndP20IntoSpace),
-                                                                           _("No conversion"));
-    gtk_widget_set_name (FTSConvertSpaceNoChange, "no-change");
-    gtk_box_pack_start(GTK_BOX(vbox),FTSConvertUnderscoreAndP20IntoSpace,FALSE,FALSE,0);
-    gtk_box_pack_start(GTK_BOX(vbox),FTSConvertSpaceIntoUnderscore,      FALSE,FALSE,0);
-    gtk_box_pack_start (GTK_BOX (vbox), FTSConvertSpaceNoChange, FALSE, FALSE,
-                        0);
+    FTSConvertUnderscoreAndP20IntoSpace = GTK_WIDGET (gtk_builder_get_object (builder, 
"fts_underscore_p20_radio"));
+    FTSConvertSpaceIntoUnderscore = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                        "fts_spaces_radio"));
+    FTSConvertSpaceNoChange = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                  "fts_none_radio"));
     g_settings_bind_with_mapping (MainSettings, "fill-convert-spaces",
                                   FTSConvertUnderscoreAndP20IntoSpace,
                                   "active", G_SETTINGS_BIND_DEFAULT,
@@ -1194,28 +1193,14 @@ create_preferences_dialog (EtPreferencesDialog *self)
                                   et_settings_enum_radio_get,
                                   et_settings_enum_radio_set,
                                   FTSConvertSpaceNoChange, NULL);
-    gtk_widget_set_tooltip_text(FTSConvertUnderscoreAndP20IntoSpace,_("If activated, this conversion "
-        "will be used when applying a mask from the scanner for tags."));
-    gtk_widget_set_tooltip_text(FTSConvertSpaceIntoUnderscore,_("If activated, this conversion "
-        "will be used when applying a mask from the scanner for tags."));
     /* TODO: No change tooltip. */
 
     /* Character conversion for the 'Rename File' scanner (=> RFS...) */
-    Frame = gtk_frame_new (_("Rename File Scanner - Character Conversion"));
-    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);
-    RFSConvertUnderscoreAndP20IntoSpace = gtk_radio_button_new_with_label(NULL, _("Convert underscore " 
"character '_' and string '%20' to space ' '"));
-    RFSConvertSpaceIntoUnderscore = 
gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(RFSConvertUnderscoreAndP20IntoSpace), _("Convert 
space ' ' to underscore '_'"));
-    RFSRemoveSpaces = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON 
(RFSConvertUnderscoreAndP20IntoSpace),
-                                                                   _("Remove spaces"));
-    gtk_widget_set_name (RFSConvertUnderscoreAndP20IntoSpace, "spaces");
-    gtk_widget_set_name (RFSConvertSpaceIntoUnderscore, "underscores");
-    gtk_widget_set_name (RFSRemoveSpaces, "remove");
-    gtk_box_pack_start(GTK_BOX(vbox),RFSConvertUnderscoreAndP20IntoSpace,FALSE,FALSE,0);
-    gtk_box_pack_start(GTK_BOX(vbox),RFSConvertSpaceIntoUnderscore,      FALSE,FALSE,0);
-    gtk_box_pack_start (GTK_BOX (vbox), RFSRemoveSpaces, FALSE, FALSE, 0);
+    RFSConvertUnderscoreAndP20IntoSpace = GTK_WIDGET (gtk_builder_get_object (builder, 
"rfs_underscore_p20_radio"));
+    RFSConvertSpaceIntoUnderscore = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                        "rfs_spaces_radio"));
+    RFSRemoveSpaces = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                          "rfs_remove_radio"));
     g_settings_bind_with_mapping (MainSettings, "rename-convert-spaces",
                                   RFSConvertUnderscoreAndP20IntoSpace,
                                   "active", G_SETTINGS_BIND_DEFAULT,
@@ -1234,85 +1219,43 @@ create_preferences_dialog (EtPreferencesDialog *self)
                                   et_settings_enum_radio_get,
                                   et_settings_enum_radio_set, RFSRemoveSpaces,
                                   NULL);
-    gtk_widget_set_tooltip_text(RFSConvertUnderscoreAndP20IntoSpace,_("If activated, this conversion "
-        "will be used when applying a mask from the scanner for filenames."));
-    gtk_widget_set_tooltip_text(RFSConvertSpaceIntoUnderscore,_("If activated, this conversion "
-        "will be used when applying a mask from the scanner for filenames."));
-    gtk_widget_set_tooltip_text(RFSRemoveSpaces,_("If activated, this conversion "        "will be used when 
applying a mask from the scanner for filenames."));
 
     /* Character conversion for the 'Process Fields' scanner (=> PFS...) */
-    Frame = gtk_frame_new (_("Process Fields Scanner - Character Conversion"));
-    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);
-
-    /* Don't convert some words like to, feat. first letter uppercase. */
-    PFSDontUpperSomeWords = gtk_check_button_new_with_label(_("Don't uppercase "
-        "first letter of words for some prepositions and articles."));
-    gtk_box_pack_start(GTK_BOX(vbox),PFSDontUpperSomeWords, FALSE, FALSE, 0);
+    PFSDontUpperSomeWords = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                "pfs_uppercase_prep_check"));
     g_settings_bind (MainSettings, "process-uppercase-prepositions",
                      PFSDontUpperSomeWords, "active",
-                     G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN);
-    gtk_widget_set_tooltip_text (PFSDontUpperSomeWords,
-                                 _("Whether to upper-case the first letter of prepositions and some other 
short words such as \"feat.\" when processing tag fields"));
+                     G_SETTINGS_BIND_DEFAULT);
 
     /* Properties of the scanner window */
-    Frame = gtk_frame_new (_("Scanner Window"));
-    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);
-
-    OpenScannerWindowOnStartup = gtk_check_button_new_with_label (_("Show the scanner window on startup"));
-    gtk_box_pack_start(GTK_BOX(vbox),OpenScannerWindowOnStartup,FALSE,FALSE,0);
+    OpenScannerWindowOnStartup = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                     "scanner_dialog_startup_check"));
     g_settings_bind (MainSettings, "scan-startup", OpenScannerWindowOnStartup,
                      "active", G_SETTINGS_BIND_DEFAULT);
-    gtk_widget_set_tooltip_text (OpenScannerWindowOnStartup,
-                                 _("Whether to show the scanner window on application startup"));
-
 
     /* Other options */
-    Frame = gtk_frame_new (_("Fields"));
-    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);
-
-    // Overwrite text into tag fields
-    OverwriteTagField = gtk_check_button_new_with_label(_("Overwrite fields when scanning tags"));
-    gtk_box_pack_start(GTK_BOX(vbox),OverwriteTagField,FALSE,FALSE,0);
+    OverwriteTagField = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                            "overwrite_fields_check"));
     g_settings_bind (MainSettings, "fill-overwrite-tag-fields",
                      OverwriteTagField, "active", G_SETTINGS_BIND_DEFAULT);
-    gtk_widget_set_tooltip_text (OverwriteTagField,
-                                 _("Whether to overwrite the tag field values when filling tags. Otherwise, 
only blank tag fields will be filled"));
 
     /* Set a default comment text or CRC-32 checksum. */
-    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BOX_SPACING);
-    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
-    SetDefaultComment = gtk_check_button_new_with_label(_("Set this text as default comment:"));
-    gtk_box_pack_start(GTK_BOX(hbox),SetDefaultComment,FALSE,FALSE,0);
+    SetDefaultComment = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                            "default_comment_check"));
+    DefaultComment = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                         "default_comment_entry"));
     g_settings_bind (MainSettings, "fill-set-default-comment",
                      SetDefaultComment, "active", G_SETTINGS_BIND_DEFAULT);
-    gtk_widget_set_tooltip_text (SetDefaultComment,
-                                 _("Whether to set the comment tag field to the provided default value when 
filling tags"));
-    DefaultComment = gtk_entry_new ();
-    gtk_box_pack_start(GTK_BOX(hbox),DefaultComment,FALSE,FALSE,0);
-    gtk_widget_set_size_request(GTK_WIDGET(DefaultComment), 250, -1);
     g_settings_bind (MainSettings, "fill-set-default-comment", DefaultComment,
                      "sensitive", G_SETTINGS_BIND_GET);
-
     g_settings_bind (MainSettings, "fill-default-comment", DefaultComment,
                      "text", G_SETTINGS_BIND_DEFAULT);
 
     /* CRC32 comment. */
-    Crc32Comment = gtk_check_button_new_with_label(_("Use CRC32 as the default "
-        "comment (for files with ID3 tags only)."));
-    gtk_box_pack_start(GTK_BOX(vbox),Crc32Comment,FALSE,FALSE,0);
-    g_settings_bind (MainSettings, "fill-crc32-comment", Crc32Comment, "active",
-                     G_SETTINGS_BIND_DEFAULT);
-    gtk_widget_set_tooltip_text (Crc32Comment,
-                                 _("Whether to use the CRC-32 of the audio file data as the default comment, 
for files with ID3 tags only"));
+    Crc32Comment = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                       "crc32_default_check"));
+    g_settings_bind (MainSettings, "fill-crc32-comment", Crc32Comment,
+                     "active", G_SETTINGS_BIND_DEFAULT);
 
     /*
      * CDDB


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