[easytag/wip/musicbrainz-dialog: 42/43] Add skeleton MusicBrainz search dialog



commit 7713673e3497cf0c8450fb39147dfdb1f2fe8d01
Author: David King <amigadave amigadave com>
Date:   Sun Nov 2 00:42:41 2014 +0000

    Add skeleton MusicBrainz search dialog

 Makefile.am                          |    2 +
 data/menus.ui                        |    5 ++
 data/musicbrainz_dialog.ui           |  123 ++++++++++++++++++++++++++++++++++
 data/org.gnome.EasyTAG.gresource.xml |    1 +
 data/toolbar.ui                      |    8 ++
 src/application_window.c             |   49 +++++++++++++
 src/musicbrainz_dialog.c             |  105 +++++++++++++++++++++++++++++
 src/musicbrainz_dialog.h             |   52 ++++++++++++++
 8 files changed, 345 insertions(+), 0 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index d208a8f..7f2d532 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,6 +54,7 @@ easytag_SOURCES = \
        src/log.c \
        src/main.c \
        src/misc.c \
+       src/musicbrainz_dialog.c \
        src/picture.c \
        src/playlist_dialog.c \
        src/preferences_dialog.c \
@@ -106,6 +107,7 @@ easytag_headers = \
        src/load_files_dialog.h \
        src/log.h \
        src/misc.h \
+       src/musicbrainz_dialog.h \
        src/picture.h \
        src/playlist_dialog.h \
        src/preferences_dialog.h \
diff --git a/data/menus.ui b/data/menus.ui
index 365e7fd..80ae914 100644
--- a/data/menus.ui
+++ b/data/menus.ui
@@ -454,6 +454,11 @@
                 <attribute name="label" translatable="yes">CDD_B Search…</attribute>
             </item>
             <item>
+                <attribute name="accel">&lt;Primary&gt;m</attribute>
+                <attribute name="action">win.show-musicbrainz</attribute>
+                <attribute name="label" translatable="yes">MusicBrainz Search…</attribute>
+            </item>
+            <item>
                 <attribute name="accel">&lt;Primary&gt;t</attribute>
                 <attribute name="action">win.show-load-filenames</attribute>
                 <attribute name="label" translatable="yes">Load Filenames From a Text File…</attribute>
diff --git a/data/musicbrainz_dialog.ui b/data/musicbrainz_dialog.ui
new file mode 100644
index 0000000..f029b5a
--- /dev/null
+++ b/data/musicbrainz_dialog.ui
@@ -0,0 +1,123 @@
+<interface domain="easytag">
+    <requires lib="gtk+" version="3.4"/>
+    <object class="GtkGrid" id="musicbrainz_grid">
+        <property name="column-spacing">6</property>
+        <property name="row-spacing">6</property>
+        <child>
+            <object class="GtkLabel" id="search_label">
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Search</property>
+                <property name="visible">True</property>
+                <attributes>
+                    <attribute name="weight" value="bold"/>
+                </attributes>
+            </object>
+            <packing>
+                <property name="left-attach">0</property>
+                <property name="top-attach">0</property>
+            </packing>
+        </child>
+        <child>
+            <object class="GtkComboBoxText" id="search_combo">
+                <items>
+                    <item id="release_group" translatable="yes">Release Group</item>
+                    <item id="artist" translatable="yes">Artist</item>
+                </items>
+                <property name="active-id">release_group</property>
+                <property name="margin-left">12</property>
+                <property name="tooltip-text" translatable="yes">Select the type of search</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="GtkEntry" id="search_entry">
+                <property name="tooltip-text" translatable="yes">Enter the search terms</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="GtkBox" id="search_buttons_box">
+                <property name="orientation">horizontal</property>
+                <property name="visible">True</property>
+                <style>
+                    <class name="linked"/>
+                </style>
+                <child>
+                    <object class="GtkButton" id="search_button">
+                        <property name="label" translatable="yes">_Search</property>
+                        <property name="use-underline">True</property>
+                        <property name="visible">True</property>
+                    </object>
+                </child>
+                <child>
+                    <object class="GtkButton" id="stop_button">
+                        <property name="label" translatable="yes">S_top</property>
+                        <property name="sensitive">False</property>
+                        <property name="tooltip-text" translatable="yes">Stop the search</property>
+                        <property name="use-underline">True</property>
+                        <property name="visible">True</property>
+                    </object>
+                </child>
+            </object>
+            <packing>
+                <property name="left-attach">2</property>
+                <property name="top-attach">1</property>
+            </packing>
+        </child>
+        <child>
+            <object class="GtkLabel" id="results_label">
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Results</property>
+                <property name="margin-top">6</property>
+                <property name="visible">True</property>
+                <attributes>
+                    <attribute name="weight" value="bold"/>
+                </attributes>
+            </object>
+            <packing>
+                <property name="left-attach">0</property>
+                <property name="top-attach">2</property>
+            </packing>
+        </child>
+        <child>
+            <object class="GtkScrolledWindow" id="results_scrolled">
+                <property name="expand">True</property>
+                <property name="margin-left">12</property>
+                <property name="min-content-height">225</property>
+                <property name="min-content-width">225</property>
+                <property name="visible">True</property>
+                <child>
+                    <object class="GtkTreeView" id="results_view">
+                        <property name="visible">True</property>
+                    </object>
+                </child>
+            </object>
+            <packing>
+                <property name="left-attach">0</property>
+                <property name="top-attach">3</property>
+                <property name="width">4</property>
+            </packing>
+        </child>
+        <child>
+            <object class="GtkCheckButton" id="dlm_check">
+                <property name="label" translatable="yes">Match lines with the Levenshtein 
algorithm</property>
+                <property name="margin-left">12</property>
+                <property name="tooltip-text" translatable="yes">Whether to use the DLM algorithm to match 
MusicBrainz results to files</property>
+                <property name="visible">True</property>
+            </object>
+            <packing>
+                <property name="left-attach">0</property>
+                <property name="top-attach">4</property>
+                <property name="width">4</property>
+            </packing>
+        </child>
+    </object>
+</interface>
diff --git a/data/org.gnome.EasyTAG.gresource.xml b/data/org.gnome.EasyTAG.gresource.xml
index b49f6fd..9ef0c73 100644
--- a/data/org.gnome.EasyTAG.gresource.xml
+++ b/data/org.gnome.EasyTAG.gresource.xml
@@ -7,6 +7,7 @@
         <file preprocess='xml-stripblanks'>log_area.ui</file>
         <file preprocess='xml-stripblanks'>load_files_dialog.ui</file>
         <file preprocess='xml-stripblanks'>menus.ui</file>
+        <file preprocess='xml-stripblanks'>musicbrainz_dialog.ui</file>
         <file preprocess='xml-stripblanks'>playlist_dialog.ui</file>
         <file preprocess='xml-stripblanks'>preferences_dialog.ui</file>
         <file preprocess='xml-stripblanks'>scan_dialog.ui</file>
diff --git a/data/toolbar.ui b/data/toolbar.ui
index 6adb884..0487d29 100644
--- a/data/toolbar.ui
+++ b/data/toolbar.ui
@@ -145,6 +145,14 @@
             </object>
         </child>
         <child>
+            <object class="GtkToolButton" id="musicbrainz_button">
+                <property name="action-name">win.show-musicbrainz</property>
+                <property name="label" translatable="yes">MusicBrainz Search…</property>
+                <property name="tooltip-text" translatable="yes">MusicBrainz Search</property>
+                <property name="visible">True</property>
+            </object>
+        </child>
+        <child>
             <object class="GtkToolButton" id="playlist_button">
                 <property name="action-name">win.show-playlist</property>
                 <property name="icon-name">document-save-as</property>
diff --git a/src/application_window.c b/src/application_window.c
index 3d2a424..fd309e6 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -30,6 +30,7 @@
 #include "load_files_dialog.h"
 #include "log.h"
 #include "misc.h"
+#include "musicbrainz_dialog.h"
 #include "picture.h"
 #include "playlist_dialog.h"
 #include "preferences_dialog.h"
@@ -58,6 +59,9 @@ struct _EtApplicationWindowPrivate
 
     GtkWidget *cddb_dialog;
     GtkWidget *load_files_dialog;
+#ifdef ENABLE_MUSICBRAINZ
+    GtkWidget *musicbrainz_dialog;
+#endif /* ENABLE_MUSICBRAINZ */
     GtkWidget *playlist_dialog;
     GtkWidget *preferences_dialog;
     GtkWidget *scan_dialog;
@@ -280,6 +284,27 @@ et_application_window_show_cddb_dialog (EtApplicationWindow *self)
     }
 }
 
+static void
+et_application_window_show_musicbrainz_dialog (EtApplicationWindow *self)
+{
+#ifdef ENABLE_MUSICBRAINZ
+    EtApplicationWindowPrivate *priv;
+
+    priv = et_application_window_get_instance_private (self);
+
+    if (priv->musicbrainz_dialog)
+    {
+        gtk_widget_show (priv->musicbrainz_dialog);
+    }
+    else
+    {
+        priv->musicbrainz_dialog = GTK_WIDGET (et_musicbrainz_dialog_new (GTK_WINDOW (self)));
+        gtk_widget_show_all (priv->musicbrainz_dialog);
+    }
+#endif /* ENABLE_MUSICBRAINZ */
+    /* FIXME: Show an error message, or remove the action entirely. */
+}
+
 /*
  * Delete the file ETFile
  */
@@ -1121,6 +1146,18 @@ on_show_cddb (GSimpleAction *action,
 }
 
 static void
+on_show_musicbrainz (GSimpleAction *action,
+                     GVariant *variant,
+                     gpointer user_data)
+{
+    EtApplicationWindow *self;
+
+    self = ET_APPLICATION_WINDOW (user_data);
+
+    et_application_window_show_musicbrainz_dialog (self);
+}
+
+static void
 on_show_load_filenames (GSimpleAction *action,
                         GVariant *variant,
                         gpointer user_data)
@@ -1557,6 +1594,7 @@ static const GActionEntry actions[] =
     /* { "browse-subdir", on_browse_subdir }, Created from GSetting. */
     /* Miscellaneous menu. */
     { "show-cddb", on_show_cddb },
+    { "show-musicbrainz", on_show_musicbrainz },
     { "show-load-filenames", on_show_load_filenames },
     { "show-playlist", on_show_playlist },
     /* Go menu. */
@@ -1606,6 +1644,14 @@ et_application_window_dispose (GObject *object)
         priv->load_files_dialog = NULL;
     }
 
+#ifdef ENABLE_MUSICBRAINZ
+    if (priv->musicbrainz_dialog)
+    {
+        gtk_widget_destroy (priv->musicbrainz_dialog);
+        priv->musicbrainz_dialog = NULL;
+    }
+#endif /* ENABLE_MUSICBRAINZ */
+
     if (priv->playlist_dialog)
     {
         gtk_widget_destroy (priv->playlist_dialog);
@@ -1722,6 +1768,9 @@ et_application_window_init (EtApplicationWindow *self)
         button = GTK_TOOL_BUTTON (gtk_builder_get_object (builder, "invert_selection_button"));
         gtk_tool_button_set_icon_widget (button,
                                          gtk_image_new_from_resource 
("/org/gnome/EasyTAG/images/invert-selection.png"));
+        button = GTK_TOOL_BUTTON (gtk_builder_get_object (builder, "musicbrainz_button"));
+        gtk_tool_button_set_icon_widget (button,
+                                         gtk_image_new_from_resource 
("/org/gnome/EasyTAG/images/musicbrainz.png"));
 
         g_object_unref (builder);
     }
diff --git a/src/musicbrainz_dialog.c b/src/musicbrainz_dialog.c
new file mode 100644
index 0000000..1ecc1aa
--- /dev/null
+++ b/src/musicbrainz_dialog.c
@@ -0,0 +1,105 @@
+/* EasyTAG - tag editor for audio files
+ * Copyright (C) 2014  David King <amigadave amigadave com>
+ * Copyright (C) 2014  Abhinav Jangda <abhijangda hotmail com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include "musicbrainz_dialog.h"
+
+#include <glib/gi18n.h>
+
+/* TODO: Use G_DEFINE_TYPE_WITH_PRIVATE. */
+G_DEFINE_TYPE (EtMusicbrainzDialog, et_musicbrainz_dialog, GTK_TYPE_DIALOG)
+
+#define et_musicbrainz_dialog_get_instance_private(dialog) (dialog->priv)
+
+static guint BOX_SPACING = 6;
+
+struct _EtMusicbrainzDialogPrivate
+{
+    gpointer unused;
+};
+
+static void
+create_musicbrainz_dialog (EtMusicbrainzDialog *self)
+{
+    EtMusicbrainzDialogPrivate *priv;
+    GtkWidget *content_area;
+    GtkBuilder *builder;
+    GError *error = NULL;
+    GtkWidget *grid;
+
+    priv = et_musicbrainz_dialog_get_instance_private (self);
+
+    gtk_window_set_title (GTK_WINDOW (self), _("MusicBrainz Search"));
+    gtk_window_set_destroy_with_parent (GTK_WINDOW (self), TRUE);
+    g_signal_connect (self, "delete-event",
+                       G_CALLBACK (gtk_widget_hide_on_delete), NULL);
+
+    content_area = gtk_dialog_get_content_area (GTK_DIALOG (self));
+    gtk_box_set_spacing (GTK_BOX (content_area), BOX_SPACING);
+    gtk_container_set_border_width (GTK_CONTAINER (self),
+                                    BOX_SPACING);
+
+    builder = gtk_builder_new ();
+    gtk_builder_add_from_resource (builder,
+                                   "/org/gnome/EasyTAG/musicbrainz_dialog.ui",
+                                   &error);
+
+    if (error != NULL)
+    {
+        g_error ("Unable to get MusicBrainz dialog from resource: %s",
+                 error->message);
+    }
+
+    grid = GTK_WIDGET (gtk_builder_get_object (builder, "musicbrainz_grid"));
+    gtk_container_add (GTK_CONTAINER (content_area), grid);
+
+    g_object_unref (builder);
+}
+
+static void
+et_musicbrainz_dialog_init (EtMusicbrainzDialog *self)
+{
+    self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ET_TYPE_MUSICBRAINZ_DIALOG,
+                                              EtMusicbrainzDialogPrivate);
+
+    create_musicbrainz_dialog (self);
+}
+
+static void
+et_musicbrainz_dialog_class_init (EtMusicbrainzDialogClass *klass)
+{
+    g_type_class_add_private (klass, sizeof (EtMusicbrainzDialogPrivate));
+}
+
+/*
+ * et_musicbrainz_dialog_new:
+ *
+ * Create a new EtMusicbrainzDialog instance.
+ *
+ * Returns: a new #EtMusicbrainzDialog
+ */
+EtMusicbrainzDialog *
+et_musicbrainz_dialog_new (GtkWindow *parent)
+{
+    g_return_val_if_fail (GTK_WINDOW (parent), NULL);
+
+    return g_object_new (ET_TYPE_MUSICBRAINZ_DIALOG, "transient-for", parent,
+                         NULL);
+}
diff --git a/src/musicbrainz_dialog.h b/src/musicbrainz_dialog.h
new file mode 100644
index 0000000..39dff0c
--- /dev/null
+++ b/src/musicbrainz_dialog.h
@@ -0,0 +1,52 @@
+/* EasyTAG - tag editor for audio files
+ * Copyright (C) 2014  David King <amigadave amigadave com>
+ * Copyright (C) 2014  Abhinav Jangda <abhijangda hotmail com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#ifndef ET_MUSICBRAINZ_DIALOG_H_
+#define ET_MUSICBRAINZ_DIALOG_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define ET_TYPE_MUSICBRAINZ_DIALOG (et_musicbrainz_dialog_get_type ())
+#define ET_MUSICBRAINZ_DIALOG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ET_TYPE_MUSICBRAINZ_DIALOG, 
EtMusicbrainzDialog))
+
+typedef struct _EtMusicbrainzDialog EtMusicbrainzDialog;
+typedef struct _EtMusicbrainzDialogClass EtMusicbrainzDialogClass;
+typedef struct _EtMusicbrainzDialogPrivate EtMusicbrainzDialogPrivate;
+
+struct _EtMusicbrainzDialog
+{
+    /*< private >*/
+    GtkDialog parent_instance;
+    EtMusicbrainzDialogPrivate *priv;
+};
+
+struct _EtMusicbrainzDialogClass
+{
+    /*< private >*/
+    GtkDialogClass parent_class;
+};
+
+GType et_musicbrainz_dialog_get_type (void);
+EtMusicbrainzDialog *et_musicbrainz_dialog_new (GtkWindow *parent);
+
+G_END_DECLS
+
+#endif /* !ET_MUSICBRAINZ_DIALOG_H_ */


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