diff options
-rw-r--r-- | configure.ac | 10 | ||||
-rw-r--r-- | plugins/pltbrowser/Makefile.am | 48 | ||||
-rw-r--r-- | plugins/pltbrowser/pltbrowser.c | 182 | ||||
-rwxr-xr-x | scripts/quickinstall.sh | 1 |
4 files changed, 240 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 2e511b6c..a752aec8 100644 --- a/configure.ac +++ b/configure.ac @@ -112,6 +112,7 @@ AC_ARG_ENABLE(mono2stereo, [AS_HELP_STRING([--enable-mono2stereo ], [b AC_ARG_ENABLE(shellexecui, [AS_HELP_STRING([--enable-shellexecui ], [build shellexec GTK UI plugin (default: auto)])], [enable_shellexecui=$enableval], [enable_shellexecui=yes]) AC_ARG_ENABLE(alac, [AS_HELP_STRING([--enable-alac ], [build ALAC plugin (default: auto)])], [enable_alac=$enableval], [enable_alac=yes]) AC_ARG_ENABLE(wma, [AS_HELP_STRING([--enable-wma ], [build WMA plugin (default: auto)])], [enable_wma=$enableval], [enable_wma=yes]) +AC_ARG_ENABLE(pltbrowser, [AS_HELP_STRING([--enable-pltbrowser ], [build playlist browser gui plugin (default: auto)])], [enable_pltbrowser=$enableval], [enable_pltbrowser=yes]) AC_ARG_ENABLE(abstract_socket, [AS_HELP_STRING([--enable-abstract-socket ], [use abstract UNIX socket for IPC (default: disabled)])], [enable_abstract_socket=$enableval], [enable_abstract_socket=no]) AS_IF([test "${enable_staticlink}" != "no"], [ @@ -615,7 +616,11 @@ AS_IF([test "${enable_wma}" != "no"], [ HAVE_WMA=yes ]) -PLUGINS_DIRS="plugins/lastfm plugins/mpgmad plugins/vorbis plugins/flac plugins/wavpack plugins/sndfile plugins/vfs_curl plugins/cdda plugins/gtkui plugins/alsa plugins/ffmpeg plugins/hotkeys plugins/oss plugins/artwork plugins/adplug plugins/ffap plugins/sid plugins/nullout plugins/supereq plugins/vtx plugins/gme plugins/pulse plugins/notify plugins/musepack plugins/wildmidi plugins/tta plugins/dca plugins/aac plugins/mms plugins/shellexec plugins/dsp_libsrc plugins/m3u plugins/vfs_zip plugins/converter plugins/dumb plugins/shn plugins/ao plugins/mono2stereo plugins/shellexecui plugins/alac plugins/medialib plugins/wma" +AS_IF([test "${enable_pltbrowser}" != "no"], [ + HAVE_PLTBROWSER=yes +]) + +PLUGINS_DIRS="plugins/lastfm plugins/mpgmad plugins/vorbis plugins/flac plugins/wavpack plugins/sndfile plugins/vfs_curl plugins/cdda plugins/gtkui plugins/alsa plugins/ffmpeg plugins/hotkeys plugins/oss plugins/artwork plugins/adplug plugins/ffap plugins/sid plugins/nullout plugins/supereq plugins/vtx plugins/gme plugins/pulse plugins/notify plugins/musepack plugins/wildmidi plugins/tta plugins/dca plugins/aac plugins/mms plugins/shellexec plugins/dsp_libsrc plugins/m3u plugins/vfs_zip plugins/converter plugins/dumb plugins/shn plugins/ao plugins/mono2stereo plugins/shellexecui plugins/alac plugins/medialib plugins/wma plugins/pltbrowser" AM_CONDITIONAL(HAVE_VORBIS, test "x$HAVE_VORBISPLUGIN" = "xyes") AM_CONDITIONAL(HAVE_FLAC, test "x$HAVE_FLACPLUGIN" = "xyes") @@ -666,6 +671,7 @@ AM_CONDITIONAL(HAVE_SM, test "x$HAVE_SM" = "xyes") AM_CONDITIONAL(HAVE_ICE, test "x$HAVE_ICE" = "xyes") AM_CONDITIONAL(HAVE_ALAC, test "x$HAVE_ALAC" = "xyes") AM_CONDITIONAL(HAVE_WMA, test "x$HAVE_WMA" = "xyes") +AM_CONDITIONAL(HAVE_PLTBROWSER, test "x$HAVE_PLTBROWSER" = "xyes") AM_CONDITIONAL(STATICLINK, test "x$STATICLINK" = "xyes") AM_CONDITIONAL(PORTABLE, test "x$PORTABLE" = "xyes") AM_CONDITIONAL(PORTABLE_FULL, test "x$PORTABLE_FULL" = "xyes") @@ -739,6 +745,7 @@ PRINT_PLUGIN_INFO([mono2stereo],[mono2stereo DSP plugin],[test "x$HAVE_MONO2STER PRINT_PLUGIN_INFO([shellexecui],[GTK user interface for configuring shellexec plugin],[test "x$HAVE_SHELLEXECUI" = "xyes"]) PRINT_PLUGIN_INFO([alac],[ALAC plugin],[test "x$HAVE_ALAC" = "xyes"]) PRINT_PLUGIN_INFO([wma],[WMA plugin],[test "x$HAVE_WMA" = "xyes"]) +PRINT_PLUGIN_INFO([pltbrowser],[playlist browser gui plugin],[test "x$HAVE_PLTBROWSER" = "xyes"]) echo @@ -788,6 +795,7 @@ plugins/mono2stereo/Makefile plugins/shellexecui/Makefile plugins/alac/Makefile plugins/wma/Makefile +plugins/pltbrowser/Makefile intl/Makefile po/Makefile.in deadbeef.desktop diff --git a/plugins/pltbrowser/Makefile.am b/plugins/pltbrowser/Makefile.am new file mode 100644 index 00000000..73923b55 --- /dev/null +++ b/plugins/pltbrowser/Makefile.am @@ -0,0 +1,48 @@ +if HAVE_PLTBROWSER + +if HAVE_GTK2 +if HAVE_GTK3 +pkglib_LTLIBRARIES = pltbrowser_gtk2.la pltbrowser_gtk3.la +else +pkglib_LTLIBRARIES = pltbrowser_gtk2.la +endif +else +if HAVE_GTK3 +pkglib_LTLIBRARIES = pltbrowser_gtk3.la +endif +endif + +AM_CFLAGS = $(CFLAGS) -std=c99 -fPIC + +if HAVE_GTK2 +pltbrowser_gtk2_la_SOURCES = pltbrowser.c +pltbrowser_gtk2_la_LDFLAGS = -module +if STATICLINK +GTK_ROOT=@top_srcdir@/$(LIB)/gtk-2.12.12/usr + +pltbrowser_gtk2_la_LIBADD = $(LDADD) -L$(GTK_ROOT)/lib $(GTK_ROOT)/lib/libgtk-x11-2.0.la $(GTK_ROOT)/lib/libgdk-x11-2.0.la $(GTK_ROOT)/lib/libpangoft2-1.0.la $(GTK_ROOT)/lib/libpangocairo-1.0.la $(GTK_ROOT)/lib/libgdk_pixbuf-2.0.la -lm $(GTK_ROOT)/lib/libcairo.la $(GTK_ROOT)/lib/libpango-1.0.la $(GTK_ROOT)/lib/libgobject-2.0.la $(GTK_ROOT)/lib/libgmodule-2.0.la $(GTK_ROOT)/lib/libgthread-2.0.la -lrt $(GTK_ROOT)/lib/libglib-2.0.la + +pltbrowser_gtk2_la_CFLAGS = -std=c99 -I $(GTK_ROOT)/include -I $(GTK_ROOT)/lib/gtk-2.0/include -I $(GTK_ROOT)/include/glib-2.0 -I $(GTK_ROOT)/include/gtk-2.0 -I $(GTK_ROOT)/include/cairo -I $(GTK_ROOT)/lib/glib-2.0/include/ -I $(GTK_ROOT)/include/pango-1.0 -I $(GTK_ROOT)/include/atk-1.0 -DULTRA_COMPATIBLE=1 +else +pltbrowser_gtk2_la_LIBADD = $(LDADD) $(GTK2_DEPS_LIBS) +pltbrowser_gtk2_la_CFLAGS = -std=c99 $(GTK2_DEPS_CFLAGS) +endif +endif + +if HAVE_GTK3 +pltbrowser_gtk3_la_SOURCES = pltbrowser.c +pltbrowser_gtk3_la_LDFLAGS = -module +if STATICLINK +GTK_ROOT_300=@top_srcdir@/$(LIB)/gtk-3.0.0 + +pltbrowser_gtk3_la_LIBADD = $(LDADD) -L$(GTK_ROOT_300)/lib -lgtk-3 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0 -lfreetype -lfontconfig $(SM_LIBADD) + +pltbrowser_gtk3_la_CFLAGS = -std=c99 -I$(GTK_ROOT_300)/include/gtk-3.0 -I$(GTK_ROOT_300)/include/pango-1.0 -I$(GTK_ROOT_300)/include/gio-unix-2.0/ -I$(GTK_ROOT_300)/include/atk-1.0 -I$(GTK_ROOT_300)/include/cairo -I$(GTK_ROOT_300)/include/gdk-pixbuf-2.0 -I$(GTK_ROOT_300)/include/freetype2 -I$(GTK_ROOT_300)/include/glib-2.0 -I$(GTK_ROOT_300)/lib/glib-2.0/include $(SM_CFLAGS) + +else +pltbrowser_gtk3_la_LIBADD = $(LDADD) $(GTK3_DEPS_LIBS) +pltbrowser_gtk3_la_CFLAGS = -std=c99 $(GTK3_DEPS_CFLAGS) +endif +endif + +endif diff --git a/plugins/pltbrowser/pltbrowser.c b/plugins/pltbrowser/pltbrowser.c new file mode 100644 index 00000000..25513d96 --- /dev/null +++ b/plugins/pltbrowser/pltbrowser.c @@ -0,0 +1,182 @@ +/* + DeaDBeeF -- the music player + Copyright (C) 2009-2012 Alexey Yakovenko and other contributors + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../deadbeef.h" +#include <gtk/gtk.h> +#include <stdlib.h> +#include <string.h> +#ifdef HAVE_CONFIG_H +#include "../../config.h" +#endif +#include "../gtkui/gtkui_api.h" +#include "../../gettext.h" + +DB_functions_t *deadbeef; +static ddb_gtkui_t *gtkui_plugin; + +typedef struct { + ddb_gtkui_widget_t base; + GtkWidget *tree; +} w_pltbrowser_t; + +static gboolean +fill_pltbrowser_cb (gpointer data) { + w_pltbrowser_t *w = data; + deadbeef->pl_lock (); + GtkListStore *store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (w->tree))); + gtk_list_store_clear (store); + int n = deadbeef->plt_get_count (); + int curr = deadbeef->plt_get_curr_idx (); + for (int i = 0; i < n; i++) { + ddb_playlist_t *plt = deadbeef->plt_get_for_idx (i); + GtkTreeIter iter; + gtk_list_store_append (store, &iter); + char buf[1000]; + deadbeef->plt_get_title (plt, buf, sizeof (buf)); + gtk_list_store_set (store, &iter, 0, buf, -1); + } + if (curr != -1) { + GtkTreePath *path = gtk_tree_path_new_from_indices (curr, -1); + gtk_tree_view_set_cursor (GTK_TREE_VIEW (w->tree), path, NULL, FALSE); + gtk_tree_path_free (path); + } + deadbeef->pl_unlock (); + return FALSE; +} + +static int +pltbrowser_message (ddb_gtkui_widget_t *w, uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) { + switch (id) { + case DB_EV_PLAYLISTSWITCHED: + g_idle_add (fill_pltbrowser_cb, w); + break; + } + return 0; +} + + +static void +w_pltbrowser_init (struct ddb_gtkui_widget_s *w) { + fill_pltbrowser_cb (w); +} + +static ddb_gtkui_widget_t * +w_pltbrowser_create (void) { + w_pltbrowser_t *w = malloc (sizeof (w_pltbrowser_t)); + memset (w, 0, sizeof (w_pltbrowser_t)); + + w->base.widget = gtk_scrolled_window_new (NULL, NULL); + w->base.init = w_pltbrowser_init; + w->base.message = pltbrowser_message; + + gtk_widget_set_can_focus (w->base.widget, FALSE); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (w->base.widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + w->tree = gtk_tree_view_new (); + gtk_widget_show (w->tree); + gtk_tree_view_set_enable_search (GTK_TREE_VIEW (w->tree), FALSE); + gtk_container_add (GTK_CONTAINER (w->base.widget), w->tree); + + GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING); + gtk_tree_view_set_model (GTK_TREE_VIEW (w->tree), GTK_TREE_MODEL (store)); + gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (w->tree), TRUE); + + GtkCellRenderer *rend1 = gtk_cell_renderer_text_new (); + GtkTreeViewColumn *col1 = gtk_tree_view_column_new_with_attributes (_("Key"), rend1, "text", 0, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (w->tree), col1); + gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (w->tree), TRUE); + gtkui_plugin->w_override_signals (w->base.widget, w); + + return (ddb_gtkui_widget_t *)w; +} + +static gboolean +pltbrowser_connect_cb (void *ctx) { + return FALSE; +} + +static int +pltbrowser_connect (void) { +#if GTK_CHECK_VERSION(3,0,0) + gtkui_plugin = (ddb_gtkui_t *)deadbeef->plug_get_for_id ("gtkui3"); +#else + gtkui_plugin = (ddb_gtkui_t *)deadbeef->plug_get_for_id ("gtkui"); +#endif + if(!gtkui_plugin) { + return -1; + } + gtkui_plugin->w_reg_widget ("pltbrowser", _("Playlist browser"), w_pltbrowser_create); + // need to do it in gtk thread + g_idle_add (pltbrowser_connect_cb, NULL); + + return 0; +} + +static int +pltbrowser_disconnect (void) { + gtkui_plugin->w_unreg_widget ("pltbrowser"); + return 0; +} + +static DB_misc_t plugin = { + .plugin.api_vmajor = 1, + .plugin.api_vminor = 5, + .plugin.version_major = 1, + .plugin.version_minor = 0, + .plugin.type = DB_PLUGIN_MISC, + .plugin.id = "pltbrowser", + .plugin.descr = "Playlist browser", + .plugin.copyright = + "DeaDBeeF -- the music player\n" + "Copyright (C) 2009-2012 Alexey Yakovenko and other contributors\n" + "\n" + "This software is provided 'as-is', without any express or implied\n" + "warranty. In no event will the authors be held liable for any damages\n" + "arising from the use of this software.\n" + "\n" + "Permission is granted to anyone to use this software for any purpose,\n" + "including commercial applications, and to alter it and redistribute it\n" + "freely, subject to the following restrictions:\n" + "\n" + "1. The origin of this software must not be misrepresented; you must not\n" + " claim that you wrote the original software. If you use this software\n" + " in a product, an acknowledgment in the product documentation would be\n" + " appreciated but is not required.\n" + "\n" + "2. Altered source versions must be plainly marked as such, and must not be\n" + " misrepresented as being the original software.\n" + "\n" + "3. This notice may not be removed or altered from any source distribution.\n" + , + .plugin.website = "http://deadbeef.sf.net", + .plugin.connect = pltbrowser_connect, + .plugin.disconnect = pltbrowser_disconnect, +}; + +DB_plugin_t * +#if GTK_CHECK_VERSION(3,0,0) +pltbrowser_gtk3_load (DB_functions_t *api) { +#else +pltbrowser_gtk2_load (DB_functions_t *api) { +#endif + deadbeef = api; + return DB_PLUGIN(&plugin); +} diff --git a/scripts/quickinstall.sh b/scripts/quickinstall.sh index d372ecde..395bd45d 100755 --- a/scripts/quickinstall.sh +++ b/scripts/quickinstall.sh @@ -49,3 +49,4 @@ cp ./plugins/medialib/.libs/medialib.so /usr/local/lib/deadbeef/ cp ./plugins/mono2stereo/.libs/ddb_mono2stereo.so /usr/local/lib/deadbeef/ cp ./plugins/alac/.libs/alac.so /usr/local/lib/deadbeef/ cp ./plugins/wma/.libs/wma.so /usr/local/lib/deadbeef/ +cp ./plugins/pltbrowser/.libs/pltbrowser_gtk2.so /usr/local/lib/deadbeef/ |