[easytag/wip/musicbrainz-support-merge: 51/75] Make libdiscid support optional



commit 7e999cb46ca6fa8bc3c6f239da0a85bec12cdbc7
Author: Abhinav <abhijangda hotmail com>
Date:   Tue Aug 12 17:02:16 2014 +0530

    Make libdiscid support optional

 configure.ac             |   13 +++++++++++++
 src/musicbrainz_dialog.c |   17 +++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9f4525d..14a1798 100644
--- a/configure.ac
+++ b/configure.ac
@@ -157,6 +157,9 @@ AC_ARG_ENABLE([nautilus_actions],
 AC_ARG_ENABLE([musicbrainz],
               [AS_HELP_STRING([--disable-musicbrainz], [Disable support for musicbrainz (default=auto)])])
 
+AC_ARG_ENABLE([libdiscid],
+              [AS_HELP_STRING([--disable-libdiscid], [Disable support for libdiscid (default=auto)])])
+
 dnl -------------------------------
 dnl Checks for libraries.
 dnl -------------------------------
@@ -175,6 +178,15 @@ AS_IF([test "x$have_musicbrainz" != "xno"],
 
 dnl libdiscid
 LIBDISCID_DEPS="libdiscid >= 0.2.2"
+AS_IF([test "x$enable_libdiscid" != "xno"],
+      [PKG_CHECK_EXISTS([$LIBDISCID_DEPS], [have_libdiscid=yes], [have_libdiscid=no])],
+      [have_libdiscid=no])
+
+AS_IF([test "x$have_libdiscid" != "xno"],
+      [AC_DEFINE([ENABLE_LIBDISCID], [], [Define for libdiscid support])],
+      [LIBDISCID_DEPS=""
+       AS_IF([test "x$enable_libdiscid" = "xyes"],
+             [AC_MSG_ERROR([libdiscid support requested but required dependencies ($LIBDISCID_DEPS) not 
found])])])
 
 dnl libsoup
 LIBSOUP_DEPS="libsoup-2.4 >= 2.4"
@@ -451,6 +463,7 @@ echo FLAC file support .......: $have_flac
 echo MP4 file support ........: $have_taglib
 echo WavPack support .........: $have_wavpack
 echo MusicBrainz support .....: $have_musicbrainz
+echo DiscID support ..........: $have_libdiscid
 echo NLS/gettext .............: $USE_NLS
 echo Nautilus actions ........: $have_libnautilus_extension
 echo Tests during make check .: $testing_utilities
diff --git a/src/musicbrainz_dialog.c b/src/musicbrainz_dialog.c
index 8a10697..202342d 100755
--- a/src/musicbrainz_dialog.c
+++ b/src/musicbrainz_dialog.c
@@ -265,12 +265,16 @@ static void
 btn_selected_find_clicked (GtkWidget *widget, gpointer user_data);
 static void
 get_first_selected_file (ET_File  **et_file);
+
+#ifdef ENABLE_libdiscid
 static void
 discid_search_callback (GObject *source, GAsyncResult *res,
                         gpointer user_data);
 static void
 discid_search_thread_func (GSimpleAsyncResult *res, GObject *obj,
                            GCancellable *cancellable);
+#endif /* ENABLE_libdiscid */
+
 static void
 btn_discid_search_clicked (GtkWidget *button, gpointer data);
 static void
@@ -1209,6 +1213,7 @@ get_first_selected_file (ET_File  **et_file)
     }
 }
 
+#ifdef ENABLE_libdiscid
 /*
  * discid_search_callback:
  * @source: Source Object
@@ -1321,6 +1326,8 @@ discid_search_thread_func (GSimpleAsyncResult *res, GObject *obj,
                                                TRUE);
 }
 
+#endif /* ENABLE_libdiscid */
+
 /*
  * btn_discid_search_clicked:
  * @button: GtkButton
@@ -1331,6 +1338,7 @@ discid_search_thread_func (GSimpleAsyncResult *res, GObject *obj,
 static void
 btn_discid_search_clicked (GtkWidget *button, gpointer data)
 {
+#ifdef ENABLE_libdiscid
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
     EtMusicBrainzDialog *dlg;
     DiscIDSearchThreadData *thread_data;
@@ -1350,6 +1358,15 @@ btn_discid_search_clicked (GtkWidget *button, gpointer data)
                                          discid_search_thread_func, 0,
                                          mb5_search_cancellable);
     et_music_brainz_dialog_stop_set_sensitive (TRUE);
+#else
+    GtkWidget *msg_dialog;
+    
+    msg_dialog = gtk_message_dialog_new (GTK_WINDOW (mbDialog), GTK_DIALOG_MODAL, 
+                                         GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
+                                         _("libdiscid is not installed. Please install it to use DiscID 
Search"));
+    gtk_dialog_run (GTK_DIALOG (msg_dialog));
+    gtk_widget_destroy (msg_dialog);
+#endif /* ENABLE_libdiscid */
 }
 
 /*


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