summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-03-23 22:39:49 +0100
committerGravatar waker <wakeroid@gmail.com>2011-03-23 22:39:49 +0100
commit7a1ab660f054d7a3974d0e2c7fe640f475a0e864 (patch)
treefdc1805646dd1c0aadf717dab453d9d49755c659
parentfd302d7abc36942e7ff14b22fae1e72b4495bef1 (diff)
renamed gtkui plugin into ddb_gui_GTK2;
changed the way gui plugins must be named; added selection of gui plugin to preferences window; only 1 gui plugin is loaded at a time
-rw-r--r--deadbeef.h1
-rw-r--r--plugins.c165
-rw-r--r--plugins.h3
-rw-r--r--plugins/gtkui/Makefile.am20
-rw-r--r--plugins/gtkui/callbacks.c1
-rw-r--r--plugins/gtkui/callbacks.h4
-rw-r--r--plugins/gtkui/deadbeef.glade52
-rw-r--r--plugins/gtkui/gtkui.c2
-rw-r--r--plugins/gtkui/interface.c21
-rw-r--r--plugins/gtkui/prefwin.c21
-rwxr-xr-xscripts/quickinstall.sh2
11 files changed, 246 insertions, 46 deletions
diff --git a/deadbeef.h b/deadbeef.h
index 364db17a..85071b75 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -544,6 +544,7 @@ typedef struct {
struct DB_dsp_s **(*plug_get_dsp_list) (void);
struct DB_playlist_s **(*plug_get_playlist_list) (void);
struct DB_plugin_s **(*plug_get_list) (void);
+ const char **(*plug_get_gui_names) (void);
const char * (*plug_get_decoder_id) (const char *id);
void (*plug_remove_decoder_id) (const char *id);
struct DB_plugin_s *(*plug_get_for_id) (const char *id);
diff --git a/plugins.c b/plugins.c
index 2a8732db..58204a6c 100644
--- a/plugins.c
+++ b/plugins.c
@@ -264,6 +264,7 @@ static DB_functions_t deadbeef_api = {
.plug_get_dsp_list = plug_get_dsp_list,
.plug_get_playlist_list = plug_get_playlist_list,
.plug_get_list = plug_get_list,
+ .plug_get_gui_names = plug_get_gui_names,
.plug_get_decoder_id = plug_get_decoder_id,
.plug_remove_decoder_id = plug_remove_decoder_id,
.plug_get_for_id = plug_get_for_id,
@@ -323,6 +324,10 @@ plug_volume_set_amp (float amp) {
#define MAX_PLUGINS 100
DB_plugin_t *g_plugins[MAX_PLUGINS+1];
+#define MAX_GUI_PLUGINS 10
+char *g_gui_names[MAX_GUI_PLUGINS+1];
+int g_num_gui_names;
+
DB_decoder_t *g_decoder_plugins[MAX_DECODER_PLUGINS+1];
#define MAX_VFS_PLUGINS 10
@@ -601,6 +606,92 @@ plug_remove_plugin (void *p) {
}
}
+// d_name must be writable w/o sideeffects; contain valid .so name
+// l must be strlen(d_name)
+static int
+load_plugin (const char *plugdir, char *d_name, int l) {
+ char fullname[PATH_MAX];
+ snprintf (fullname, PATH_MAX, "%s/%s", plugdir, d_name);
+ trace ("loading plugin %s/%s\n", plugdir, d_name);
+ void *handle = dlopen (fullname, RTLD_NOW);
+ if (!handle) {
+ trace ("dlopen error: %s\n", dlerror ());
+#ifdef ANDROID
+ break;
+#else
+ strcpy (fullname + strlen(fullname) - 3, ".fallback.so");
+ trace ("trying %s...\n", fullname);
+ handle = dlopen (fullname, RTLD_NOW);
+ if (!handle) {
+ trace ("dlopen error: %s\n", dlerror ());
+ return -1;
+ }
+ else {
+ fprintf (stderr, "successfully started fallback plugin %s\n", fullname);
+ }
+#endif
+ }
+ d_name[l-3] = 0;
+ strcat (d_name, "_load");
+#ifndef ANDROID
+ DB_plugin_t *(*plug_load)(DB_functions_t *api) = dlsym (handle, d_name);
+#else
+ DB_plugin_t *(*plug_load)(DB_functions_t *api) = dlsym (handle, d_name+3);
+#endif
+ if (!plug_load) {
+ trace ("dlsym error: %s\n", dlerror ());
+ dlclose (handle);
+ return -1;
+ }
+ if (plug_init_plugin (plug_load, handle) < 0) {
+ d_name[l-3] = 0;
+ trace ("plugin %s is incompatible with current version of deadbeef, please upgrade the plugin\n", d_name);
+ dlclose (handle);
+ return -1;
+ }
+ return 0;
+}
+
+static int
+load_gui_plugin (const char **plugdirs) {
+ const char *conf_gui_plug = conf_get_str ("gui_plugin", "GTK2");
+ char name[100];
+
+ // try to load selected plugin
+ for (int i = 0; g_gui_names[i]; i++) {
+ trace ("checking GUI plugin: %s\n", g_gui_names[i]);
+ if (!strcmp (g_gui_names[i], conf_gui_plug)) {
+ trace ("found selected GUI plugin: %s\n", g_gui_names[i]);
+ for (int n = 0; plugdirs[n]; n++) {
+ snprintf (name, sizeof (name), "ddb_gui_%s.so", conf_gui_plug);
+ if (!load_plugin (plugdirs[n], name, strlen (name))) {
+ return 0;
+ }
+ snprintf (name, sizeof (name), "ddb_gui_%s.fallback.so", conf_gui_plug);
+ if (!load_plugin (plugdirs[n], name, strlen (name))) {
+ return 0;
+ }
+ }
+ break;
+ }
+ }
+
+ // try any plugin
+ for (int i = 0; g_gui_names[i]; i++) {
+ for (int n = 0; plugdirs[n]; n++) {
+ snprintf (name, sizeof (name), "ddb_gui_%s.so", g_gui_names[i]);
+ if (!load_plugin (plugdirs[n], name, strlen (name))) {
+ return 0;
+ }
+ snprintf (name, sizeof (name), "ddb_gui_%s.fallback.so", g_gui_names[i]);
+ if (!load_plugin (plugdirs[n], name, strlen (name))) {
+ return 0;
+ }
+ }
+ }
+ return -1;
+}
+
int
load_plugin_dir (const char *plugdir) {
int n = 0;
@@ -663,45 +754,38 @@ load_plugin_dir (const char *plugdir) {
break;
}
#endif
- char fullname[PATH_MAX];
- snprintf (fullname, PATH_MAX, "%s/%s", plugdir, d_name);
- trace ("loading plugin %s\n", d_name);
- void *handle = dlopen (fullname, RTLD_NOW);
- if (!handle) {
- trace ("dlopen error: %s\n", dlerror ());
-#ifdef ANDROID
- break;
-#else
- strcpy (fullname + strlen(fullname) - 3, ".fallback.so");
- trace ("trying %s...\n", fullname);
- handle = dlopen (fullname, RTLD_NOW);
- if (!handle) {
- trace ("dlopen error: %s\n", dlerror ());
+
+ // FIXME: don't load duplicates (by names)
+
+ // add gui plugin names
+ if (!strncmp (d_name, "ddb_gui_", 8)) {
+ trace ("found gui plugin %s\n", d_name);
+ if (g_num_gui_names >= MAX_GUI_PLUGINS) {
+ fprintf (stderr, "too many gui plugins\n");
+ break; // no more gui plugins allowed
+ }
+ char *nm = d_name + 8;
+ char *e = strrchr (nm, '.');
+ if (!e) {
break;
}
- else {
- fprintf (stderr, "successfully started fallback plugin %s\n", fullname);
+ if (strcmp (e, ".so")) {
+ break;
}
-#endif
- }
- d_name[l-3] = 0;
- strcat (d_name, "_load");
-#ifndef ANDROID
- DB_plugin_t *(*plug_load)(DB_functions_t *api) = dlsym (handle, d_name);
-#else
- DB_plugin_t *(*plug_load)(DB_functions_t *api) = dlsym (handle, d_name+3);
-#endif
- if (!plug_load) {
- trace ("dlsym error: %s\n", dlerror ());
- dlclose (handle);
- break;
- }
- if (plug_init_plugin (plug_load, handle) < 0) {
- d_name[l-3] = 0;
- trace ("plugin %s is incompatible with current version of deadbeef, please upgrade the plugin\n", d_name);
- dlclose (handle);
+ *e = 0;
+ // ignore fallbacks
+ e = strrchr (nm, '.');
+ if (e && !strcasecmp (e, ".fallback")) {
+ break;
+ }
+ // add to list
+ g_gui_names[g_num_gui_names++] = strdup (nm);
+ g_gui_names[g_num_gui_names] = NULL;
+ trace ("added %s gui plugin\n", nm);
break;
}
+
+ load_plugin (plugdir, d_name, l);
break;
}
free (namelist[i]);
@@ -786,6 +870,10 @@ plug_load_all (void) {
}
#endif
+
+ // load gui plugin
+ load_gui_plugin (plugins_dirs);
+
// load all compiled-in modules
#define PLUG(n) extern DB_plugin_t * n##_load (DB_functions_t *api);
#include "moduleconf.h"
@@ -967,6 +1055,10 @@ plug_unload_all (void) {
free (plugins);
plugins = next;
}
+ for (int i = 0; g_gui_names[i]; i++) {
+ free (g_gui_names[i]);
+ g_gui_names[i] = NULL;
+ }
plugins_tail = NULL;
trace ("all plugins had been unloaded\n");
}
@@ -1010,6 +1102,11 @@ plug_get_list (void) {
return g_plugins;
}
+const char **
+plug_get_gui_names (void) {
+ return (const char **)g_gui_names;
+}
+
DB_output_t *
plug_get_output (void) {
return output_plugin;
diff --git a/plugins.h b/plugins.h
index a7006397..8451a2cf 100644
--- a/plugins.h
+++ b/plugins.h
@@ -140,4 +140,7 @@ plug_get_for_id (const char *id);
int
plug_is_local_file (const char *fname);
+const char **
+plug_get_gui_names (void);
+
#endif // __PLUGINS_H
diff --git a/plugins/gtkui/Makefile.am b/plugins/gtkui/Makefile.am
index 4cdab339..3cfc1cce 100644
--- a/plugins/gtkui/Makefile.am
+++ b/plugins/gtkui/Makefile.am
@@ -43,27 +43,27 @@ sdk_HEADERS = gtkui_api.h
EXTRA_DIST = $(gtkui_VALASOURCES) deadbeef.glade
if STATICLINK
-pkglib_LTLIBRARIES = gtkui.la gtkui.fallback.la
+pkglib_LTLIBRARIES = ddb_gui_GTK2.la ddb_gui_GTK2.fallback.la
else
-pkglib_LTLIBRARIES = gtkui.la
+pkglib_LTLIBRARIES = ddb_gui_GTK2.la
endif
# normal lib
-gtkui_la_SOURCES = $(gtkui_VALABUILTSOURCES) $(GTKUI_SOURCES)
-gtkui_la_LDFLAGS = -module
-gtkui_la_LIBADD = $(LDADD) $(GTKUI_DEPS_LIBS)
-gtkui_la_CFLAGS = -std=c99 $(GTKUI_DEPS_CFLAGS)
+ddb_gui_GTK2_la_SOURCES = $(gtkui_VALABUILTSOURCES) $(GTKUI_SOURCES)
+ddb_gui_GTK2_la_LDFLAGS = -module
+ddb_gui_GTK2_la_LIBADD = $(LDADD) $(GTKUI_DEPS_LIBS)
+ddb_gui_GTK2_la_CFLAGS = -std=c99 $(GTKUI_DEPS_CFLAGS)
# fallback lib
if STATICLINK
GTK_ROOT=../../../deadbeef-deps/gtk-debian/usr
-gtkui_fallback_la_SOURCES = $(gtkui_VALABUILTSOURCES) $(GTKUI_SOURCES)
-gtkui_fallback_la_LDFLAGS = -module
+ddb_gui_GTK2_fallback_la_SOURCES = $(gtkui_VALABUILTSOURCES) $(GTKUI_SOURCES)
+ddb_gui_GTK2_fallback_la_LDFLAGS = -module
-gtkui_fallback_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
+ddb_gui_GTK2_fallback_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
-gtkui_fallback_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
+ddb_gui_GTK2_fallback_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
endif
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c
index 71ad353f..00ff70c6 100644
--- a/plugins/gtkui/callbacks.c
+++ b/plugins/gtkui/callbacks.c
@@ -1170,3 +1170,4 @@ create_plugin_weblink (gchar *widget_name, gchar *string1, gchar *string2,
gtk_widget_set_sensitive (link, FALSE);
return link;
}
+
diff --git a/plugins/gtkui/callbacks.h b/plugins/gtkui/callbacks.h
index de5bfd75..3f8863fc 100644
--- a/plugins/gtkui/callbacks.h
+++ b/plugins/gtkui/callbacks.h
@@ -1107,3 +1107,7 @@ on_replaygain_preamp_value_changed (GtkRange *range,
void
on_tabstrip_text_color_set (GtkColorButton *colorbutton,
gpointer user_data);
+
+void
+on_gui_plugin_changed (GtkComboBox *combobox,
+ gpointer user_data);
diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade
index b9535fd8..37499d5e 100644
--- a/plugins/gtkui/deadbeef.glade
+++ b/plugins/gtkui/deadbeef.glade
@@ -3374,6 +3374,58 @@ Album</property>
<property name="fill">False</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox101">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">8</property>
+
+ <child>
+ <widget class="GtkLabel" id="label128">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">GUI Plugin (changing requires restart):</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="gui_plugin">
+ <property name="visible">True</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ <signal name="changed" handler="on_gui_plugin_changed" last_modification_time="Wed, 23 Mar 2011 20:30:20 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="tab_expand">False</property>
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index 22f94aff..15afcf6b 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -1232,7 +1232,7 @@ gtkui_get_mainwin (void) {
}
DB_plugin_t *
-gtkui_load (DB_functions_t *api) {
+ddb_gui_GTK2_load (DB_functions_t *api) {
deadbeef = api;
return DB_PLUGIN (&plugin);
}
diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c
index 71113e3a..5b74ba55 100644
--- a/plugins/gtkui/interface.c
+++ b/plugins/gtkui/interface.c
@@ -1696,6 +1696,9 @@ create_prefwin (void)
GtkWidget *hbox65;
GtkWidget *label102;
GtkWidget *titlebar_format_stopped;
+ GtkWidget *hbox101;
+ GtkWidget *label128;
+ GtkWidget *gui_plugin;
GtkWidget *label2;
GtkWidget *notebook4;
GtkWidget *vbox21;
@@ -2025,6 +2028,18 @@ create_prefwin (void)
gtk_box_pack_start (GTK_BOX (hbox65), titlebar_format_stopped, TRUE, TRUE, 0);
gtk_entry_set_invisible_char (GTK_ENTRY (titlebar_format_stopped), 8226);
+ hbox101 = gtk_hbox_new (FALSE, 8);
+ gtk_widget_show (hbox101);
+ gtk_box_pack_start (GTK_BOX (vbox9), hbox101, FALSE, FALSE, 0);
+
+ label128 = gtk_label_new (_("GUI Plugin (changing requires restart):"));
+ gtk_widget_show (label128);
+ gtk_box_pack_start (GTK_BOX (hbox101), label128, FALSE, FALSE, 0);
+
+ gui_plugin = gtk_combo_box_new_text ();
+ gtk_widget_show (gui_plugin);
+ gtk_box_pack_start (GTK_BOX (hbox101), gui_plugin, TRUE, TRUE, 0);
+
label2 = gtk_label_new (_("GUI"));
gtk_widget_show (label2);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 3), label2);
@@ -2525,6 +2540,9 @@ create_prefwin (void)
g_signal_connect ((gpointer) titlebar_format_stopped, "changed",
G_CALLBACK (on_titlebar_format_stopped_changed),
NULL);
+ g_signal_connect ((gpointer) gui_plugin, "changed",
+ G_CALLBACK (on_gui_plugin_changed),
+ NULL);
g_signal_connect ((gpointer) override_bar_colors, "toggled",
G_CALLBACK (on_override_bar_colors_toggled),
NULL);
@@ -2658,6 +2676,9 @@ create_prefwin (void)
GLADE_HOOKUP_OBJECT (prefwin, hbox65, "hbox65");
GLADE_HOOKUP_OBJECT (prefwin, label102, "label102");
GLADE_HOOKUP_OBJECT (prefwin, titlebar_format_stopped, "titlebar_format_stopped");
+ GLADE_HOOKUP_OBJECT (prefwin, hbox101, "hbox101");
+ GLADE_HOOKUP_OBJECT (prefwin, label128, "label128");
+ GLADE_HOOKUP_OBJECT (prefwin, gui_plugin, "gui_plugin");
GLADE_HOOKUP_OBJECT (prefwin, label2, "label2");
GLADE_HOOKUP_OBJECT (prefwin, notebook4, "notebook4");
GLADE_HOOKUP_OBJECT (prefwin, vbox21, "vbox21");
diff --git a/plugins/gtkui/prefwin.c b/plugins/gtkui/prefwin.c
index 57e817d1..7b67a0a8 100644
--- a/plugins/gtkui/prefwin.c
+++ b/plugins/gtkui/prefwin.c
@@ -527,6 +527,16 @@ on_preferences_activate (GtkMenuItem *menuitem,
// resume last session
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (w, "resume_last_session")), deadbeef->conf_get_int ("resume_last_session", 0));
+ // fill gui plugin list
+ combobox = GTK_COMBO_BOX (lookup_widget (w, "gui_plugin"));
+ const char **names = deadbeef->plug_get_gui_names ();
+ for (int i = 0; names[i]; i++) {
+ gtk_combo_box_append_text (combobox, names[i]);
+ if (!strcmp (names[i], deadbeef->conf_get_str ("gui_plugin", "GTK2"))) {
+ gtk_combo_box_set_active (combobox, i);
+ }
+ }
+
// override bar colors
int override = deadbeef->conf_get_int ("gtkui.override_bar_colors", 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (prefwin, "override_bar_colors")), override);
@@ -1280,3 +1290,14 @@ on_prefwin_realize (GtkWidget *widget,
wingeom_restore (widget, "prefwin", -1, -1, -1, -1, 0);
}
+void
+on_gui_plugin_changed (GtkComboBox *combobox,
+ gpointer user_data)
+{
+ gchar *txt = gtk_combo_box_get_active_text (combobox);
+ if (txt) {
+ deadbeef->conf_set_str ("gui_plugin", txt);
+ g_free (txt);
+ }
+}
+
diff --git a/scripts/quickinstall.sh b/scripts/quickinstall.sh
index 22a308aa..2ccd599d 100755
--- a/scripts/quickinstall.sh
+++ b/scripts/quickinstall.sh
@@ -17,7 +17,7 @@ cp ./plugins/ffmpeg/.libs/ffmpeg.so /usr/local/lib/deadbeef/
cp ./plugins/lastfm/.libs/lastfm.so /usr/local/lib/deadbeef/
cp ./plugins/sid/.libs/sid.so /usr/local/lib/deadbeef/
cp ./plugins/adplug/.libs/adplug.so /usr/local/lib/deadbeef/
-cp ./plugins/gtkui/.libs/gtkui.so /usr/local/lib/deadbeef/
+cp ./plugins/gtkui/.libs/ddb_gui_GTK2.so /usr/local/lib/deadbeef/
cp ./plugins/sndfile/.libs/sndfile.so /usr/local/lib/deadbeef/
cp ./plugins/pulse/.libs/pulse.so /usr/local/lib/deadbeef/
cp ./plugins/artwork/.libs/artwork.so /usr/local/lib/deadbeef/