[easytag/wip/musicbrainz-support-merge: 19/76] FIXME (split) Made musicbrainz optional and added Close button
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/musicbrainz-support-merge: 19/76] FIXME (split) Made musicbrainz optional and added Close button
- Date: Thu, 28 Aug 2014 07:35:12 +0000 (UTC)
commit ca14093d8be89e706f2c11d2704c763a68e1be2b
Author: Abhinav <abhijangda hotmail com>
Date: Fri Aug 22 17:55:54 2014 +0530
FIXME (split) Made musicbrainz optional and added Close button
Made musicbrainz support optional in configure.ac. Added Close button.
configure.ac | 13 +++++++-
data/musicbrainz_dialog.ui | 26 +++++++++-------
src/application_window.c | 6 ++++
src/mb_search.c | 5 +++
src/mb_search.h | 5 +++
src/mbentityview.c | 18 +++--------
src/mbentityview.h | 7 ++++-
src/musicbrainz_dialog.c | 72 +++++++++++++++++++++++++-------------------
src/musicbrainz_dialog.h | 7 ++++-
9 files changed, 101 insertions(+), 58 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a84c883..6073180 100644
--- a/configure.ac
+++ b/configure.ac
@@ -154,7 +154,8 @@ AC_ARG_ENABLE([wavpack],
AC_ARG_ENABLE([nautilus_actions],
[AS_HELP_STRING([--disable-nautilus-actions], [do not build the nautilus context menu actions
(default=auto)])])
-
+AC_ARG_ENABLE([musicbrainz],
+ [AS_HELP_STRING([--disable-musicbrainz], [Disable support for musicbrainz (default=auto)])])
dnl -------------------------------
dnl Checks for libraries.
@@ -162,6 +163,15 @@ dnl -------------------------------
dnl libmusicbrainz5
MUSICBRAINZ_DEPS="libmusicbrainz5 >= 5.0"
+AS_IF([test "x$enable_musicbrainz" != "xno"],
+ [PKG_CHECK_EXISTS([$MUSICBRAINZ_DEPS], [have_musicbrainz=yes], [have_musicbrainz=no])],
+ [have_musicbrainz=no])
+
+AS_IF([test "x$have_musicbrainz" != "xno"],
+ [AC_DEFINE([ENABLE_MUSICBRAINZ], [], [Define for musicbrainz support])],
+ [MUSICBRAINZ_DEPS=""
+ AS_IF([test "x$enable_musicbrainz" = "xyes"],
+ [AC_MSG_ERROR([musicbrainz support requested but required dependencies ($MUSICBRAINZ_DEPS) not
found])])])
dnl libdiscid
LIBDISCID_DEPS="libdiscid >= 0.2.2"
@@ -439,6 +449,7 @@ echo Ogg Opus file support ...: $have_opus
echo FLAC file support .......: $have_flac
echo MP4 file support ........: $have_taglib
echo WavPack support .........: $have_wavpack
+echo MusicBrainz support .....: $have_musicbrainz
echo NLS/gettext .............: $USE_NLS
echo Nautilus actions ........: $have_libnautilus_extension
echo Tests during make check .: $testing_utilities
diff --git a/data/musicbrainz_dialog.ui b/data/musicbrainz_dialog.ui
index ed2a2fe..7531e14 100755
--- a/data/musicbrainz_dialog.ui
+++ b/data/musicbrainz_dialog.ui
@@ -1,6 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkImage" id="findimage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-find</property>
+ </object>
+ <object class="GtkImage" id="img_invert_selection">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">easytag-invert-selection</property>
+ </object>
<object class="GtkImage" id="img_red_lines">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -11,11 +21,6 @@
<property name="can_focus">False</property>
<property name="stock">easytag-unselect-all</property>
</object>
- <object class="GtkImage" id="findimage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-find</property>
- </object>
<object class="GtkImage" id="image10">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -52,11 +57,6 @@
<property name="can_focus">False</property>
<property name="stock">gtk-stop</property>
</object>
- <object class="GtkImage" id="img_invert_selection">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">easytag-invert-selection</property>
- </object>
<object class="GtkDialog" id="mbDialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
@@ -156,6 +156,7 @@
<child>
<object class="GtkButton" id="btnAutomaticStop">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">image9</property>
@@ -300,6 +301,7 @@
<child>
<object class="GtkButton" id="btnManualStop">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Stop Manual
Search</property>
@@ -377,6 +379,7 @@
<child>
<object class="GtkButton" id="btnSelectedStop">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">image11</property>
@@ -453,6 +456,7 @@
<child>
<object class="GtkButton" id="btnDiscStop">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">image13</property>
@@ -699,7 +703,7 @@
<property name="can_focus">False</property>
<property name="spacing">4</property>
<child>
- <object class="GtkButton" id="button9">
+ <object class="GtkButton" id="btnClose">
<property name="label" translatable="yes">Close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
diff --git a/src/application_window.c b/src/application_window.c
index 1ace460..ceaf61a 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -299,6 +299,7 @@ et_application_window_show_cddb_dialog (EtApplicationWindow *self)
}
}
+#ifdef ENABLE_MUSICBRAINZ
/*
* et_application_window_show_musicbrainz_dialog:
* @self: EtApplicationWindow
@@ -310,6 +311,7 @@ et_application_window_show_musicbrainz_dialog (EtApplicationWindow *self)
{
et_open_musicbrainz_dialog ();
}
+#endif
/*
* Delete the file ETFile
@@ -1151,6 +1153,7 @@ on_show_cddb (GSimpleAction *action,
et_application_window_show_cddb_dialog (self);
}
+#ifdef ENABLE_MUSICBRAINZ
static void
on_show_musicbrainz (GSimpleAction *action,
GVariant *variant,
@@ -1162,6 +1165,7 @@ on_show_musicbrainz (GSimpleAction *action,
et_application_window_show_musicbrainz_dialog (self);
}
+#endif
static void
on_show_load_filenames (GSimpleAction *action,
@@ -1570,7 +1574,9 @@ static const GActionEntry actions[] =
/* { "browse-subdir", on_browse_subdir }, Created from GSetting. */
/* Miscellaneous menu. */
{ "show-cddb", on_show_cddb },
+#ifdef ENABLE_MUSICBRAINZ
{ "show-musicbrainz", on_show_musicbrainz},
+#endif /* ENABLE_MUSICBRAINZ */
{ "show-load-filenames", on_show_load_filenames },
{ "show-playlist", on_show_playlist },
/* Go menu. */
diff --git a/src/mb_search.c b/src/mb_search.c
index acbfa1e..cf55876 100755
--- a/src/mb_search.c
+++ b/src/mb_search.c
@@ -18,6 +18,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include "config.h"
+
+#ifdef ENABLE_MUSICBRAINZ
+
#include <glib/gi18n.h>
#include "mb_search.h"
@@ -783,3 +787,4 @@ free_mb_tree (GNode *node)
g_node_destroy (node);
}
+#endif /* ENABLE_MUSICBRAINZ */
diff --git a/src/mb_search.h b/src/mb_search.h
index d4009f2..cc80137 100755
--- a/src/mb_search.h
+++ b/src/mb_search.h
@@ -21,6 +21,10 @@
#ifndef __MB_SEARCH_H__
#define __MB_SEARCH_H__
+#include "config.h"
+
+#ifdef ENABLE_MUSICBRAINZ
+
#include <gtk/gtk.h>
#include <musicbrainz5/mb5_c.h>
@@ -101,3 +105,4 @@ free_mb_tree (GNode *node);
void
et_set_cancel_error (GError **error);
#endif /* __MB_SEARCH_H__ */
+#endif /* ENABLE_MUSICBRAINZ */
diff --git a/src/mbentityview.c b/src/mbentityview.c
index 4facd26..5135801 100644
--- a/src/mbentityview.c
+++ b/src/mbentityview.c
@@ -18,6 +18,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include "config.h"
+
+#ifdef ENABLE_MUSICBRAINZ
+
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
@@ -1154,19 +1158,7 @@ et_mb_entity_view_finalize (GObject *object)
entity_view = ET_MB_ENTITY_VIEW (object);
priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
-<<<<<<< HEAD
-
- if (GTK_IS_LIST_STORE (priv->list_store))
- {
- g_object_unref (priv->list_store);
- }
-
- if (GTK_WIDGET_CLASS (et_mb_entity_view_parent_class)->destroy)
- {
- (*GTK_WIDGET_CLASS (et_mb_entity_view_parent_class)->destroy)(object);
- }
-=======
g_clear_object (&priv->list_store);
G_OBJECT_CLASS (et_mb_entity_view_parent_class)->finalize(object);
->>>>>>> 4b51406... Some Improvements after review
}
+#endif /* ENABLE_MUSICBRAINZ */
diff --git a/src/mbentityview.h b/src/mbentityview.h
index 8f63f3d..a2695b6 100755
--- a/src/mbentityview.h
+++ b/src/mbentityview.h
@@ -21,6 +21,10 @@
#ifndef __MB_ENTITY_VIEW_H__
#define __MB_ENTITY_VIEW_H__
+#include "config.h"
+
+#ifdef ENABLE_MUSICBRAINZ
+
G_BEGIN_DECLS
#include <gtk/gtk.h>
@@ -126,4 +130,5 @@ void
et_mb_entity_view_clear_all (EtMbEntityView *entity_view);
G_END_DECLS
-#endif /* __MB_ENTITY_VIEW_H__ */
\ No newline at end of file
+#endif /* __MB_ENTITY_VIEW_H__ */
+#endif /* ENABLE_MUSICBRAINZ */
diff --git a/src/musicbrainz_dialog.c b/src/musicbrainz_dialog.c
index a0917a1..9df31a5 100755
--- a/src/musicbrainz_dialog.c
+++ b/src/musicbrainz_dialog.c
@@ -20,6 +20,8 @@
#include "config.h"
+#ifdef ENABLE_MUSICBRAINZ
+
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
@@ -36,15 +38,15 @@
/***************
* Declaration *
***************/
-
-static GNode *mb_tree_root;
-static GSimpleAsyncResult *async_result;
+//static GSimpleAsyncResult *async_result;
typedef struct
{
GNode *mb_tree_root;
GSimpleAsyncResult *async_result;
-} MusicBrainzDialog;
+} MusicBrainzDialogPrivate;
+
+static MusicBrainzDialogPrivate *mb_dialog_priv;
typedef struct
{
@@ -85,13 +87,13 @@ manual_search_callback (GObject *source, GAsyncResult *res,
{
g_object_unref (res);
g_free (user_data);
- free_mb_tree (mb_tree_root);
- mb_tree_root = g_node_new (NULL);
+ free_mb_tree (mb_dialog_priv->mb_tree_root);
+ mb_dialog_priv->mb_tree_root = g_node_new (NULL);
return;
}
et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (entityView),
- mb_tree_root);
+ mb_dialog_priv->mb_tree_root);
gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder,
"statusbar")), 0, _("Searching Completed"));
g_object_unref (res);
@@ -211,7 +213,7 @@ manual_search_thread_func (GSimpleAsyncResult *res, GObject *obj,
}
if (!et_musicbrainz_search (thread_data->text_to_search,
- thread_data->type, mb_tree_root, &error,
+ thread_data->type, mb_dialog_priv->mb_tree_root, &error,
cancellable))
{
g_simple_async_report_gerror_in_idle (NULL,
@@ -258,10 +260,10 @@ btn_manual_find_clicked (GtkWidget *btn, gpointer user_data)
return;
}
- if (g_node_first_child (mb_tree_root))
+ if (g_node_first_child (mb_dialog_priv->mb_tree_root))
{
- free_mb_tree (mb_tree_root);
- mb_tree_root = g_node_new (NULL);
+ free_mb_tree (mb_dialog_priv->mb_tree_root);
+ mb_dialog_priv->mb_tree_root = g_node_new (NULL);
}
et_mb_entity_view_clear_all (ET_MB_ENTITY_VIEW (entityView));
@@ -273,10 +275,10 @@ btn_manual_find_clicked (GtkWidget *btn, gpointer user_data)
mb5_search_cancellable = g_cancellable_new ();
gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder,
"statusbar")), 0, _("Starting MusicBrainz Search"));
- async_result = g_simple_async_result_new (NULL, manual_search_callback,
+ mb_dialog_priv->async_result = g_simple_async_result_new (NULL, manual_search_callback,
thread_data,
btn_manual_find_clicked);
- g_simple_async_result_run_in_thread (async_result,
+ g_simple_async_result_run_in_thread (mb_dialog_priv->async_result,
manual_search_thread_func, 0,
mb5_search_cancellable);
}
@@ -419,13 +421,13 @@ selected_find_callback (GObject *source, GAsyncResult *res,
g_object_unref (res);
g_object_unref (((SelectedFindThreadData *)user_data)->hash_table);
g_free (user_data);
- free_mb_tree (mb_tree_root);
- mb_tree_root = g_node_new (NULL);
+ free_mb_tree (mb_dialog_priv->mb_tree_root);
+ mb_dialog_priv->mb_tree_root = g_node_new (NULL);
return;
}
et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (entityView),
- mb_tree_root);
+ mb_dialog_priv->mb_tree_root);
gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
0, _("Searching Completed"));
g_object_unref (res);
@@ -451,7 +453,7 @@ selected_find_thread_func (GSimpleAsyncResult *res, GObject *obj,
while (iter)
{
if (!et_musicbrainz_search ((gchar *)iter->data, MB_ENTITY_KIND_ALBUM,
- mb_tree_root, &error, cancellable))
+ mb_dialog_priv->mb_tree_root, &error, cancellable))
{
g_simple_async_report_gerror_in_idle (NULL,
mb5_search_error_callback,
@@ -560,10 +562,11 @@ bt_selected_find_clicked (GtkWidget *widget, gpointer user_data)
thread_data = g_malloc (sizeof (SelectedFindThreadData));
thread_data->hash_table = hash_table;
mb5_search_cancellable = g_cancellable_new ();
- async_result = g_simple_async_result_new (NULL, selected_find_callback,
- thread_data,
- bt_selected_find_clicked);
- g_simple_async_result_run_in_thread (async_result,
+ mb_dialog_priv->async_result = g_simple_async_result_new (NULL,
+ selected_find_callback,
+ thread_data,
+ bt_selected_find_clicked);
+ g_simple_async_result_run_in_thread (mb_dialog_priv->async_result,
selected_find_thread_func, 0,
mb5_search_cancellable);
gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
@@ -577,13 +580,13 @@ discid_search_callback (GObject *source, GAsyncResult *res,
if (!g_simple_async_result_get_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res)))
{
g_object_unref (res);
- free_mb_tree (mb_tree_root);
- mb_tree_root = g_node_new (NULL);
+ free_mb_tree (mb_dialog_priv->mb_tree_root);
+ mb_dialog_priv->mb_tree_root = g_node_new (NULL);
return;
}
et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (entityView),
- mb_tree_root);
+ mb_dialog_priv->mb_tree_root);
gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
0, _("Searching Completed"));
g_object_unref (res);
@@ -629,7 +632,7 @@ discid_search_thread_func (GSimpleAsyncResult *res, GObject *obj,
return;
}
- if (!et_musicbrainz_search (discid, MB_ENTITY_KIND_DISCID, mb_tree_root,
+ if (!et_musicbrainz_search (discid, MB_ENTITY_KIND_DISCID, mb_dialog_priv->mb_tree_root,
&error, cancellable))
{
g_simple_async_report_gerror_in_idle (NULL,
@@ -640,7 +643,7 @@ discid_search_thread_func (GSimpleAsyncResult *res, GObject *obj,
}
et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (entityView),
- mb_tree_root);
+ mb_dialog_priv->mb_tree_root);
discid_free (disc);
g_simple_async_result_set_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res),
TRUE);
@@ -652,10 +655,10 @@ btn_discid_search (GtkWidget *button, gpointer data)
mb5_search_cancellable = g_cancellable_new ();
gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
0, _("Starting MusicBrainz Search"));
- async_result = g_simple_async_result_new (NULL, discid_search_callback,
+ mb_dialog_priv->async_result = g_simple_async_result_new (NULL, discid_search_callback,
NULL,
btn_manual_find_clicked);
- g_simple_async_result_run_in_thread (async_result,
+ g_simple_async_result_run_in_thread (mb_dialog_priv->async_result,
discid_search_thread_func, 0,
mb5_search_cancellable);
}
@@ -663,7 +666,10 @@ btn_discid_search (GtkWidget *button, gpointer data)
static void
btn_close_clicked (GtkWidget *button, gpointer data)
{
- gtk_dialog_response (GTK_DIALOG (mbDialog), GTK_RESPONSE_CLOSE);
+ gtk_widget_destroy (mbDialog);
+ g_object_unref (G_OBJECT (builder));
+ free_mb_tree (mb_dialog_priv->mb_tree_root);
+ g_free (mb_dialog_priv);
}
/*
@@ -692,12 +698,14 @@ et_open_musicbrainz_dialog ()
return;
}
- mb_tree_root = g_node_new (NULL);
+ mb_dialog_priv = g_malloc (sizeof (MusicBrainzDialogPrivate));
+ mb_dialog_priv->mb_tree_root = g_node_new (NULL);
entityView = et_mb_entity_view_new ();
mbDialog = GTK_WIDGET (gtk_builder_get_object (builder, "mbDialog"));
gtk_widget_set_size_request (mbDialog, 600, 500);
gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (builder, "centralBox")),
entityView, TRUE, TRUE, 2);
+
g_signal_connect (gtk_builder_get_object (builder, "btnManualFind"),
"clicked", G_CALLBACK (btn_manual_find_clicked),
NULL);
@@ -759,5 +767,7 @@ et_open_musicbrainz_dialog ()
gtk_dialog_run (GTK_DIALOG (mbDialog));
gtk_widget_destroy (mbDialog);
g_object_unref (G_OBJECT (builder));
- free_mb_tree (mb_tree_root);
+ free_mb_tree (mb_dialog_priv->mb_tree_root);
+ g_free (mb_dialog_priv);
}
+#endif /* ENABLE_MUSICBRAINZ */
diff --git a/src/musicbrainz_dialog.h b/src/musicbrainz_dialog.h
index ed5f02f..0b8e290 100755
--- a/src/musicbrainz_dialog.h
+++ b/src/musicbrainz_dialog.h
@@ -21,6 +21,10 @@
#ifndef __MUSICBRAINZ_DIALOG_H__
#define __MUSICBRAINZ_DIALOG_H__
+#include "config.h"
+
+#ifdef ENABLE_MUSICBRAINZ
+
/****************
* Declarations *
****************/
@@ -40,4 +44,5 @@ mb5_search_error_callback (GObject *source, GAsyncResult *res,
gpointer user_data);
void
et_show_status_msg_in_idle (gchar *message);
-#endif /* __MUSICBRAINZ_DIALOG_H__ */
\ No newline at end of file
+#endif /* __MUSICBRAINZ_DIALOG_H__ */
+#endif /* ENABLE_MUSICBRAINZ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]