[easytag/wip/application-window: 84/95] Move playlist dialog to GtkBuilder



commit 3d74a8fd07939215340c414a2eabb343eb6c81fe
Author: David King <amigadave amigadave com>
Date:   Sun Aug 17 09:24:47 2014 +0100

    Move playlist dialog to GtkBuilder

 data/org.gnome.EasyTAG.gresource.xml |    1 +
 data/playlist_dialog.ui              |  143 ++++++++++++++++++++++++++++++++++
 po/POTFILES.in                       |    1 +
 src/playlist_dialog.c                |  120 ++++++++++-------------------
 4 files changed, 186 insertions(+), 79 deletions(-)
---
diff --git a/data/org.gnome.EasyTAG.gresource.xml b/data/org.gnome.EasyTAG.gresource.xml
index 562af2b..3afc746 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'>playlist_dialog.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>
diff --git a/data/playlist_dialog.ui b/data/playlist_dialog.ui
new file mode 100644
index 0000000..dbb5fe7
--- /dev/null
+++ b/data/playlist_dialog.ui
@@ -0,0 +1,143 @@
+<interface domain="easytag">
+    <requires lib="gtk+" version="3.4"/>
+    <object class="GtkGrid" id="playlist_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="name_label">
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Filename</property>
+                <property name="visible">True</property>
+                <attributes>
+                    <attribute name="weight" value="bold"/>
+                </attributes>
+            </object>
+        </child>
+        <child>
+            <object class="GtkBox" id="name_mask_box">
+                <property name="margin-left">12</property>
+                <property name="spacing">12</property>
+                <property name="visible">True</property>
+                <child>
+                    <object class="GtkRadioButton" id="name_mask_radio">
+                        <property name="label" translatable="yes">Use mask:</property>
+                        <property name="visible">True</property>
+                    </object>
+                </child>
+                <child>
+                    <object class="GtkEntry" id="name_mask_entry">
+                        <property name="visible">True</property>
+                    </object>
+                </child>
+            </object>
+        </child>
+        <child>
+            <object class="GtkRadioButton" id="name_directory_radio">
+                <property name="group">name_mask_radio</property>
+                <property name="label" translatable="yes">Use directory name</property>
+                <property name="margin-left">12</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkLabel" id="options_label">
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Options</property>
+                <property name="margin-top">12</property>
+                <property name="visible">True</property>
+                <attributes>
+                    <attribute name="weight" value="bold"/>
+                </attributes>
+            </object>
+        </child>
+        <child>
+            <object class="GtkCheckButton" id="selected_files_check">
+                <property name="label" translatable="yes">Include only the selected files</property>
+                <property name="margin-left">12</property>
+                <property name="tooltip-text" translatable="yes">Whether to use only the selected files or 
all files when creating playlists</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkRadioButton" id="path_full_radio">
+                <property name="label" translatable="yes">Use full path for files in playlist</property>
+                <property name="margin-left">12</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkRadioButton" id="path_relative_radio">
+                <property name="group">path_full_radio</property>
+                <property name="label" translatable="yes">Use relative path for files in playlist</property>
+                <property name="margin-left">12</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkCheckButton" id="playlist_parent_check">
+                <property name="label" translatable="yes">Create playlist in the parent directory</property>
+                <property name="margin-left">12</property>
+                <property name="tooltip-text" translatable="yes">Whether to create the playlist in the 
parent directory</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkCheckButton" id="playlist_dos_check">
+                <property name="label" translatable="yes">Use DOS directory separator</property>
+                <property name="margin-left">12</property>
+                <property name="tooltip-text" translatable="yes">Whether to use DOS path separators when 
generating playlists</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkLabel" id="content_label">
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Content</property>
+                <property name="margin-top">12</property>
+                <property name="visible">True</property>
+                <attributes>
+                    <attribute name="weight" value="bold"/>
+                </attributes>
+            </object>
+        </child>
+        <child>
+            <object class="GtkRadioButton" id="content_filenames_radio">
+                <property name="label" translatable="yes">Write only list of files</property>
+                <property name="margin-left">12</property>
+                <property name="name">filenames</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkRadioButton" id="content_extended_radio">
+                <property name="group">content_filenames_radio</property>
+                <property name="label" translatable="yes">Write information using filename</property>
+                <property name="name">extended</property>
+                <property name="margin-left">12</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
+            <object class="GtkBox" id="content_box">
+                <property name="margin-left">12</property>
+                <property name="spacing">12</property>
+                <property name="visible">True</property>
+                <child>
+                    <object class="GtkRadioButton" id="content_extended_mask_radio">
+                        <property name="group">content_filenames_radio</property>
+                        <property name="label" translatable="yes">Write information using:</property>
+                        <property name="name">extended-mask</property>
+                        <property name="visible">True</property>
+                    </object>
+                </child>
+                <child>
+                    <object class="GtkEntry" id="content_mask_entry">
+                        <property name="visible">True</property>
+                    </object>
+                </child>
+            </object>
+        </child>
+    </object>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7cf5da4..1de91be 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,7 @@
 data/easytag.appdata.xml.in
 data/easytag.desktop.in
 [type: gettext/glade]data/menus.ui
+[type: gettext/glade]data/playlist_dialog.ui
 [type: gettext/glade]data/preferences_dialog.ui
 [type: gettext/glade]data/toolbar.ui
 data/org.gnome.EasyTAG.gschema.xml
diff --git a/src/playlist_dialog.c b/src/playlist_dialog.c
index b3c3b4e..48b34d5 100644
--- a/src/playlist_dialog.c
+++ b/src/playlist_dialog.c
@@ -633,14 +633,12 @@ create_playlist_dialog (EtPlaylistDialog *self)
 {
     EtPlaylistDialogPrivate *priv;
     GtkDialog *dialog;
-    GtkWidget *frame;
     GtkWidget *content_area;
-    GtkWidget *hbox;
-    GtkWidget *vbox;
+    GtkBuilder *builder;
+    GError *error = NULL;
+    GtkWidget *grid;
     GtkWidget *playlist_use_mask_name;
-    GtkWidget *playlist_use_dir_name;
     GtkWidget *playlist_only_selected_files;
-    GtkWidget *playlist_full_path;
     GtkWidget *playlist_relative_path;
     GtkWidget *playlist_create_in_parent_dir;
     GtkWidget *playlist_use_dos_separator;
@@ -664,25 +662,25 @@ create_playlist_dialog (EtPlaylistDialog *self)
     content_area = gtk_dialog_get_content_area (dialog);
     gtk_box_set_spacing (GTK_BOX (content_area), BOX_SPACING);
     gtk_container_set_border_width (GTK_CONTAINER (content_area), BOX_SPACING);
+    builder = gtk_builder_new ();
+    gtk_builder_add_from_resource (builder,
+                                   "/org/gnome/EasyTAG/playlist_dialog.ui",
+                                   &error);
 
+    if (error != NULL)
+    {
+        g_error ("Unable to get scanner page from resource: %s",
+                 error->message);
+    }
+
+    grid = GTK_WIDGET (gtk_builder_get_object (builder, "playlist_grid"));
+    gtk_container_add (GTK_CONTAINER (content_area), grid);
 
     /* Playlist name */
-    frame = gtk_frame_new (_("M3U Playlist Name"));
-    gtk_box_pack_start (GTK_BOX (content_area), frame, TRUE, TRUE, 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), 4);
-
-    playlist_use_mask_name = gtk_radio_button_new_with_label(NULL, _("Use mask:"));
-    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BOX_SPACING);
-    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
-    gtk_box_pack_start(GTK_BOX(hbox),playlist_use_mask_name,FALSE,FALSE,0);
-    priv->name_mask_entry = gtk_entry_new ();
-    gtk_box_pack_start (GTK_BOX (hbox), priv->name_mask_entry, FALSE, FALSE,
-                        0);
-    playlist_use_dir_name = gtk_radio_button_new_with_label_from_widget(
-        GTK_RADIO_BUTTON(playlist_use_mask_name),_("Use directory name"));
-    gtk_box_pack_start(GTK_BOX(vbox),playlist_use_dir_name,FALSE,FALSE,0);
+    playlist_use_mask_name = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                 "name_mask_radio"));
+    priv->name_mask_entry = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                "name_mask_entry"));
     g_settings_bind (MainSettings, "playlist-filename-mask",
                      priv->name_mask_entry, "text", G_SETTINGS_BIND_DEFAULT);
     g_settings_bind (MainSettings, "playlist-use-mask", playlist_use_mask_name,
@@ -694,78 +692,40 @@ create_playlist_dialog (EtPlaylistDialog *self)
                       G_CALLBACK (entry_check_content_mask), NULL);
 
     /* Playlist options */
-    frame = gtk_frame_new (_("Playlist Options"));
-    gtk_box_pack_start (GTK_BOX (content_area), frame, TRUE, TRUE, 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);
-
-    playlist_only_selected_files = gtk_check_button_new_with_label(_("Include only the selected files"));
-    gtk_box_pack_start(GTK_BOX(vbox),playlist_only_selected_files,FALSE,FALSE,0);
+    playlist_only_selected_files = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                       "selected_files_check"));
     g_settings_bind (MainSettings, "playlist-selected-only",
                      playlist_only_selected_files, "active",
                      G_SETTINGS_BIND_DEFAULT);
-    gtk_widget_set_tooltip_text (playlist_only_selected_files,
-                                 _("Whether to use only the selected files or all files when creating 
playlists"));
-
-    playlist_full_path = gtk_radio_button_new_with_label(NULL,_("Use full path for files in playlist"));
-    gtk_box_pack_start(GTK_BOX(vbox),playlist_full_path,FALSE,FALSE,0);
-    playlist_relative_path = 
gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(playlist_full_path),
-        _("Use relative path for files in playlist"));
-    gtk_box_pack_start(GTK_BOX(vbox),playlist_relative_path,FALSE,FALSE,0);
+
+    playlist_relative_path = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                 "path_relative_radio"));
     g_settings_bind (MainSettings, "playlist-relative", playlist_relative_path,
                      "active", G_SETTINGS_BIND_DEFAULT);
 
-    // Create playlist in parent directory
-    playlist_create_in_parent_dir = gtk_check_button_new_with_label(_("Create playlist in the parent 
directory"));
-    gtk_box_pack_start(GTK_BOX(vbox),playlist_create_in_parent_dir,FALSE,FALSE,0);
+    /* Create playlist in parent directory. */
+    playlist_create_in_parent_dir = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                        "playlist_parent_check"));
     g_settings_bind (MainSettings, "playlist-parent-directory",
                      playlist_create_in_parent_dir, "active",
                      G_SETTINGS_BIND_DEFAULT);
-    gtk_widget_set_tooltip_text (playlist_create_in_parent_dir,
-                                 _("Whether to create the playlist in the parent directory"));
-
-    // DOS Separator
-    playlist_use_dos_separator = gtk_check_button_new_with_label(_("Use DOS directory separator"));
-#ifndef G_OS_WIN32
-    /* This makes no sense under Win32, so we do not display it. */
-    gtk_box_pack_start(GTK_BOX(vbox),playlist_use_dos_separator,FALSE,FALSE,0);
-#endif /* !G_OS_WIN32 */
+
+    /* DOS Separator. */
+    playlist_use_dos_separator = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                     "playlist_dos_check"));
     g_settings_bind (MainSettings, "playlist-dos-separator",
                      playlist_use_dos_separator, "active",
                      G_SETTINGS_BIND_DEFAULT);
-    gtk_widget_set_tooltip_text (playlist_use_dos_separator,
-                                 _("Whether to use DOS path separators when generating playlists"));
 
     /* Playlist content */
-    frame = gtk_frame_new (_("Playlist Content"));
-    gtk_box_pack_start (GTK_BOX (content_area), frame, TRUE, TRUE, 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);
-
-    playlist_content_filenames = gtk_radio_button_new_with_label (NULL,
-                                                                  _("Write only list of files"));
-    gtk_widget_set_name (playlist_content_filenames, "filenames");
-    gtk_box_pack_start (GTK_BOX (vbox), playlist_content_filenames, FALSE,
-                        FALSE,0);
-
-    playlist_content_extended = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON 
(playlist_content_filenames),
-                                                                             _("Write info using filename"));
-    gtk_widget_set_name (playlist_content_extended, "extended");
-    gtk_box_pack_start (GTK_BOX (vbox), playlist_content_extended, FALSE,
-                        FALSE, 0);
-
-    playlist_content_mask = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON 
(playlist_content_filenames),
-                                                                         _("Write info using:"));
-    gtk_widget_set_name (playlist_content_mask, "extended-mask");
-    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BOX_SPACING);
-    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
-    gtk_box_pack_start(GTK_BOX(hbox),playlist_content_mask,FALSE,FALSE,0);
-    // Set a label, a combobox and un editor button in the 3rd radio button
-    priv->content_mask_entry = gtk_entry_new ();
-    gtk_box_pack_start (GTK_BOX (hbox), priv->content_mask_entry, FALSE, FALSE,
-                        0);
+    playlist_content_filenames = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                     "content_filenames_radio"));
+    playlist_content_extended = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                    "content_extended_radio"));
+    playlist_content_mask = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                "content_extended_mask_radio"));
+    priv->content_mask_entry = GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                   "content_mask_entry"));
     g_settings_bind (MainSettings, "playlist-default-mask",
                      priv->content_mask_entry, "text",
                      G_SETTINGS_BIND_DEFAULT);
@@ -794,6 +754,8 @@ create_playlist_dialog (EtPlaylistDialog *self)
                                   et_settings_enum_radio_set,
                                   playlist_content_mask, NULL);
 
+    g_object_unref (builder);
+
     /* To initialize the mask status icon and visibility. */
     g_signal_emit_by_name (priv->name_mask_entry, "changed");
     g_signal_emit_by_name (priv->content_mask_entry, "changed");


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