[easytag/wip/musicbrainz-dialog: 2/3] Add skeleton MusicBrainz query context
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/musicbrainz-dialog: 2/3] Add skeleton MusicBrainz query context
- Date: Sun, 30 Aug 2015 20:04:24 +0000 (UTC)
commit 06798119c0d8d454c1005f2033eab294e3d6084b
Author: David King <amigadave amigadave com>
Date: Sun Nov 2 22:27:37 2014 +0000
Add skeleton MusicBrainz query context
Makefile.am | 3 ++
README | 3 +-
configure.ac | 20 ++++++++++-
src/musicbrainz.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++
src/musicbrainz.h | 55 +++++++++++++++++++++++++++++
src/musicbrainz_dialog.c | 36 +++++++++++++++++--
src/musicbrainz_dialog.h | 6 +++
7 files changed, 204 insertions(+), 6 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index d1e525a..7f3fc8b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,6 +9,7 @@ DISTCHECK_CONFIGURE_FLAGS = \
--enable-man \
--enable-mp3 \
--enable-mp4 \
+ --enable-musicbrainz \
--enable-nautilus-actions \
--enable-speex \
--enable-tests \
@@ -60,6 +61,7 @@ easytag_SOURCES = \
src/log.c \
src/main.c \
src/misc.c \
+ src/musicbrainz.c \
src/musicbrainz_dialog.c \
src/picture.c \
src/playlist_dialog.c \
@@ -122,6 +124,7 @@ easytag_headers = \
src/load_files_dialog.h \
src/log.h \
src/misc.h \
+ src/musicbrainz.h \
src/musicbrainz_dialog.h \
src/picture.h \
src/playlist_dialog.h \
diff --git a/README b/README
index 4a2bcf0..e6d3eef 100644
--- a/README
+++ b/README
@@ -63,7 +63,8 @@ Installation
* id3lib version greater than 3.7.12 (http://id3lib.sourceforge.net) (Recommended: id3lib-3.8.3) (if not
deactivated by './configure --disable-id3v23')
* flac (http://flac.sourceforge.net) (if not deactivated by './configure --disable-flac')
* libogg and libvorbis (http://www.vorbis.com) (if not deactivated by './configure --disable-ogg')
-* libnautilus-extension (https://wiki.gnome.org/Apps/Nautilus) (if not deactivated by ./configure
--disable-nautilus-actions')
+* libnautilus-extension (https://wiki.gnome.org/Apps/Nautilus) (if not deactivated by './configure
--disable-nautilus-actions')
+* musicbrainz5 (https://wiki.musicbrainz.org/libmusicbrainz) (if not deactivated by './configure
--disable-musicbrainz')
* opus and opusfile (http://www.opus-codec.org/) (if not deactivated by './configure --disable-opus')
* taglib (http://taglib.github.com/) (if not deactivated by './configure --disable-mp4')
* wavpack (http://www.wavpack.com/) (if not deactivated by './configure --disable-wavpack')
diff --git a/configure.ac b/configure.ac
index ba390db..7838343 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,6 +161,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], [do not build MusicBrainz query support
(default=auto)])])
dnl -------------------------------
@@ -333,6 +335,21 @@ AS_IF([test "x$have_libnautilus_extension" = "xno"],
AM_CONDITIONAL([ENABLE_NAUTILUS_ACTIONS], [test x"$have_libnautilus_extension" != x"no"])
+dnl ################################################
+dnl # MusicBrainz
+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 Check the pkg-config dependencies
GIO_DEPS="gio-2.0 >= 2.38.0"
AC_SUBST([GLIB_DEPRECATION_FLAGS],
@@ -340,7 +357,7 @@ AC_SUBST([GLIB_DEPRECATION_FLAGS],
GTK_DEPS="gtk+-3.0 >= 3.10.0"
AC_SUBST([GTK_DEPRECATION_FLAGS],
["-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_10 -DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_10"])
-PKG_CHECK_MODULES([EASYTAG], [$GIO_DEPS $GTK_DEPS $OPUS_DEPS $OGG_DEPS $SPEEX_DEPS $FLAC_DEPS $ID3TAG_DEPS
$TAGLIB_DEPS $WAVPACK_DEPS])
+PKG_CHECK_MODULES([EASYTAG], [$GIO_DEPS $GTK_DEPS $MUSICBRAINZ_DEPS $OPUS_DEPS $OGG_DEPS $SPEEX_DEPS
$FLAC_DEPS $ID3TAG_DEPS $TAGLIB_DEPS $WAVPACK_DEPS])
dnl Check for winsock
AC_SEARCH_LIBS([gethostbyname], [nsl socket], [],
@@ -392,6 +409,7 @@ echo FLAC file support .......: $have_flac
echo MP4 file support ........: $have_taglib
echo WavPack support .........: $have_wavpack
echo NLS/gettext .............: $USE_NLS
+echo MusicBrainz search ......: $have_musicbrainz
echo Nautilus actions ........: $have_libnautilus_extension
echo Tests during make check .: $testing_utilities
echo Install prefix ..........: $prefix
diff --git a/src/musicbrainz.c b/src/musicbrainz.c
new file mode 100644
index 0000000..edff047
--- /dev/null
+++ b/src/musicbrainz.c
@@ -0,0 +1,87 @@
+/* EasyTAG - tag editor for audio files
+ * Copyright (C) 2015 David King <amigadave amigadave 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"
+
+#ifdef ENABLE_MUSICBRAINZ
+
+#include "musicbrainz.h"
+
+#include <glib/gi18n.h>
+#include <musicbrainz5/mb5_c.h>
+
+typedef struct
+{
+ Mb5Query query;
+} EtMusicbrainzPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (EtMusicbrainz, et_musicbrainz, G_TYPE_OBJECT)
+
+static void
+et_musicbrainz_finalize (GObject *object)
+{
+ EtMusicbrainz *self;
+ EtMusicbrainzPrivate *priv;
+
+ self = ET_MUSICBRAINZ (object);
+ priv = et_musicbrainz_get_instance_private (self);
+
+ if (priv->query)
+ {
+ mb5_query_delete (priv->query);
+ priv->query = NULL;
+ }
+
+ G_OBJECT_CLASS (et_musicbrainz_parent_class)->finalize (object);
+}
+
+static void
+et_musicbrainz_init (EtMusicbrainz *self)
+{
+ EtMusicbrainzPrivate *priv;
+
+ priv = et_musicbrainz_get_instance_private (self);
+
+ priv->query = mb5_query_new (PACKAGE_NAME "/" PACKAGE_VERSION " ( "
+ PACKAGE_URL " )", NULL, 0);
+}
+
+static void
+et_musicbrainz_class_init (EtMusicbrainzClass *klass)
+{
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = et_musicbrainz_finalize;
+}
+
+/*
+ * et_musicbrainz_dialog_new:
+ *
+ * Create a new EtMusicbrainz instance.
+ *
+ * Returns: a new #EtMusicbrainz
+ */
+EtMusicbrainz *
+et_musicbrainz_new (void)
+{
+ return g_object_new (ET_TYPE_MUSICBRAINZ, NULL);
+}
+
+#endif /* ENABLE_MUSICBRAINZ */
diff --git a/src/musicbrainz.h b/src/musicbrainz.h
new file mode 100644
index 0000000..a24adca
--- /dev/null
+++ b/src/musicbrainz.h
@@ -0,0 +1,55 @@
+/* EasyTAG - tag editor for audio files
+ * Copyright (C) 2015 David King <amigadave amigadave 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_H_
+#define ET_MUSICBRAINZ_H_
+
+#include "config.h"
+
+#ifdef ENABLE_MUSICBRAINZ
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define ET_TYPE_MUSICBRAINZ (et_musicbrainz_get_type ())
+#define ET_MUSICBRAINZ(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ET_TYPE_MUSICBRAINZ, EtMusicbrainz))
+
+typedef struct _EtMusicbrainz EtMusicbrainz;
+typedef struct _EtMusicbrainzClass EtMusicbrainzClass;
+
+struct _EtMusicbrainz
+{
+ /*< private >*/
+ GObject parent_instance;
+};
+
+struct _EtMusicbrainzClass
+{
+ /*< private >*/
+ GObjectClass parent_class;
+};
+
+GType et_musicbrainz_get_type (void);
+EtMusicbrainz *et_musicbrainz_new (void);
+
+G_END_DECLS
+
+#endif /* ENABLE_MUSICBRAINZ */
+
+#endif /* !ET_MUSICBRAINZ_H_ */
diff --git a/src/musicbrainz_dialog.c b/src/musicbrainz_dialog.c
index f50f432..0237413 100644
--- a/src/musicbrainz_dialog.c
+++ b/src/musicbrainz_dialog.c
@@ -19,15 +19,19 @@
#include "config.h"
+#ifdef ENABLE_MUSICBRAINZ
+
#include "musicbrainz_dialog.h"
#include <glib/gi18n.h>
+#include "musicbrainz.h"
+
static guint BOX_SPACING = 6;
typedef struct
{
- gpointer unused;
+ EtMusicbrainz *mb;
} EtMusicbrainzDialogPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (EtMusicbrainzDialog, et_musicbrainz_dialog, GTK_TYPE_DIALOG)
@@ -35,14 +39,11 @@ G_DEFINE_TYPE_WITH_PRIVATE (EtMusicbrainzDialog, et_musicbrainz_dialog, GTK_TYPE
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",
@@ -71,14 +72,39 @@ create_musicbrainz_dialog (EtMusicbrainzDialog *self)
}
static void
+et_musicbrainz_dialog_finalize (GObject *object)
+{
+ EtMusicbrainzDialog *self;
+ EtMusicbrainzDialogPrivate *priv;
+
+ self = ET_MUSICBRAINZ_DIALOG (object);
+ priv = et_musicbrainz_dialog_get_instance_private (self);
+
+ g_clear_object (&priv->mb);
+
+ G_OBJECT_CLASS (et_musicbrainz_dialog_parent_class)->finalize (object);
+}
+
+static void
et_musicbrainz_dialog_init (EtMusicbrainzDialog *self)
{
+ EtMusicbrainzDialogPrivate *priv;
+
+ priv = et_musicbrainz_dialog_get_instance_private (self);
+
+ priv->mb = et_musicbrainz_new ();
+
create_musicbrainz_dialog (self);
}
static void
et_musicbrainz_dialog_class_init (EtMusicbrainzDialogClass *klass)
{
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = et_musicbrainz_dialog_finalize;
}
/*
@@ -96,3 +122,5 @@ et_musicbrainz_dialog_new (GtkWindow *parent)
return g_object_new (ET_TYPE_MUSICBRAINZ_DIALOG, "transient-for", parent,
NULL);
}
+
+#endif /* ENABLE_MUSICBRAINZ */
diff --git a/src/musicbrainz_dialog.h b/src/musicbrainz_dialog.h
index 72947de..01ee77b 100644
--- a/src/musicbrainz_dialog.h
+++ b/src/musicbrainz_dialog.h
@@ -20,6 +20,10 @@
#ifndef ET_MUSICBRAINZ_DIALOG_H_
#define ET_MUSICBRAINZ_DIALOG_H_
+#include "config.h"
+
+#ifdef ENABLE_MUSICBRAINZ
+
#include <gtk/gtk.h>
G_BEGIN_DECLS
@@ -47,4 +51,6 @@ EtMusicbrainzDialog *et_musicbrainz_dialog_new (GtkWindow *parent);
G_END_DECLS
+#endif /* ENABLE_MUSICBRAINZ */
+
#endif /* !ET_MUSICBRAINZ_DIALOG_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]