summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-12-22 21:19:25 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-12-22 21:19:25 +0100
commitb98ce0097b2e661d9e69efc422701197b38c16d7 (patch)
tree6b867b71c73ba0ed54026a7091a4efa93330f066 /plugins
parent5a583de9f929865665853fb994ea04b95ce4bb17 (diff)
prefwindow output device list updates when output plugin changes
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gtkui/callbacks.c46
-rw-r--r--plugins/gtkui/callbacks.h5
-rw-r--r--plugins/gtkui/deadbeef.glade1
-rw-r--r--plugins/gtkui/gtkui.c16
-rw-r--r--plugins/gtkui/interface.c3
-rw-r--r--plugins/nullout/nullout.c10
6 files changed, 62 insertions, 19 deletions
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c
index 02f604f5..2138d2c7 100644
--- a/plugins/gtkui/callbacks.c
+++ b/plugins/gtkui/callbacks.c
@@ -1452,6 +1452,32 @@ on_plugin_active_toggled (GtkCellRendererToggle *cell_renderer, gchar *path, Gtk
}
void
+preferences_fill_soundcards (void) {
+ GtkWidget *w = prefwin;
+ if (!prefwin) {
+ return;
+ }
+ const char *s = deadbeef->conf_get_str ("alsa_soundcard", "default");
+ GtkComboBox *combobox = GTK_COMBO_BOX (lookup_widget (w, "pref_soundcard"));
+ GtkTreeModel *mdl = gtk_combo_box_get_model (combobox);
+ gtk_list_store_clear (GTK_LIST_STORE (mdl));
+
+ gtk_combo_box_append_text (combobox, "Default Audio Device");
+ if (!strcmp (s, "default")) {
+ gtk_combo_box_set_active (combobox, 0);
+ }
+ num_alsa_devices = 1;
+ strcpy (alsa_device_names[0], "default");
+ if (deadbeef->get_output ()->enum_soundcards) {
+ deadbeef->get_output ()->enum_soundcards (gtk_enum_sound_callback, combobox);
+ gtk_widget_set_sensitive (GTK_WIDGET (combobox), TRUE);
+ }
+ else {
+ gtk_widget_set_sensitive (GTK_WIDGET (combobox), FALSE);
+ }
+}
+
+void
on_preferences_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
@@ -1473,16 +1499,8 @@ on_preferences_activate (GtkMenuItem *menuitem,
}
// soundcard (output device) selection
+ preferences_fill_soundcards ();
- const char *s = deadbeef->conf_get_str ("alsa_soundcard", "default");
- combobox = GTK_COMBO_BOX (lookup_widget (w, "pref_soundcard"));
- gtk_combo_box_append_text (combobox, "Default Audio Device");
- if (!strcmp (s, "default")) {
- gtk_combo_box_set_active (combobox, 0);
- }
- num_alsa_devices = 1;
- strcpy (alsa_device_names[0], "default");
- deadbeef->get_output ()->enum_soundcards (gtk_enum_sound_callback, combobox);
// alsa resampling
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (w, "pref_alsa_resampling")), deadbeef->conf_get_int ("alsa.resample", 0));
@@ -1675,6 +1693,15 @@ on_pref_pluginlist_cursor_changed (GtkTreeView *treeview,
gtk_entry_set_text (e, p->website ? p->website : "");
}
+gboolean
+on_prefwin_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ printf ("destroyed\n");
+ prefwin = NULL;
+ return FALSE;
+}
void
@@ -2262,3 +2289,4 @@ on_properties1_activate (GtkMenuItem *menuitem,
}
+
diff --git a/plugins/gtkui/callbacks.h b/plugins/gtkui/callbacks.h
index a3b9b12b..f9c5c8a6 100644
--- a/plugins/gtkui/callbacks.h
+++ b/plugins/gtkui/callbacks.h
@@ -742,3 +742,8 @@ on_remove2_activate (GtkMenuItem *menuitem,
void
on_properties1_activate (GtkMenuItem *menuitem,
gpointer user_data);
+
+gboolean
+on_prefwin_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade
index fb4cd963..34076262 100644
--- a/plugins/gtkui/deadbeef.glade
+++ b/plugins/gtkui/deadbeef.glade
@@ -1385,6 +1385,7 @@
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<signal name="key_press_event" handler="on_prefwin_key_press_event" last_modification_time="Sat, 07 Nov 2009 15:47:40 GMT"/>
+ <signal name="delete_event" handler="on_prefwin_delete_event" last_modification_time="Tue, 22 Dec 2009 20:16:22 GMT"/>
<child>
<widget class="GtkNotebook" id="notebook2">
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index 9e8e3e0a..cc5f76b3 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -347,6 +347,20 @@ gtkui_on_configchanged (DB_event_t *ev, uintptr_t data) {
return 0;
}
+static gboolean
+outputchanged_cb (gpointer nothing) {
+ void preferences_fill_soundcards (void);
+ preferences_fill_soundcards ();
+ return FALSE;
+}
+
+static int
+gtkui_on_outputchanged (DB_event_t *ev, uintptr_t nothing) {
+ g_idle_add (outputchanged_cb, NULL);
+ return 0;
+}
+
+
void
gtkui_thread (void *ctx) {
// let's start some gtk
@@ -439,6 +453,7 @@ gtkui_start (void) {
deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_FRAMEUPDATE, DB_CALLBACK (gtkui_on_frameupdate), 0);
deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_VOLUMECHANGED, DB_CALLBACK (gtkui_on_volumechanged), 0);
deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_CONFIGCHANGED, DB_CALLBACK (gtkui_on_configchanged), 0);
+ deadbeef->ev_subscribe (DB_PLUGIN (&plugin), DB_EV_OUTPUTCHANGED, DB_CALLBACK (gtkui_on_outputchanged), 0);
// gtk must be running in separate thread
gtk_tid = deadbeef->thread_start (gtkui_thread, NULL);
@@ -462,6 +477,7 @@ gtkui_stop (void) {
deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_FRAMEUPDATE, DB_CALLBACK (gtkui_on_frameupdate), 0);
deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_VOLUMECHANGED, DB_CALLBACK (gtkui_on_volumechanged), 0);
deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_CONFIGCHANGED, DB_CALLBACK (gtkui_on_configchanged), 0);
+ deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_OUTPUTCHANGED, DB_CALLBACK (gtkui_on_outputchanged), 0);
trace ("quitting gtk\n");
g_idle_add (quit_gtk_cb, NULL);
trace ("waiting for gtk thread to finish\n");
diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c
index eeec2b07..fefd4c10 100644
--- a/plugins/gtkui/interface.c
+++ b/plugins/gtkui/interface.c
@@ -1547,6 +1547,9 @@ create_prefwin (void)
g_signal_connect ((gpointer) prefwin, "key_press_event",
G_CALLBACK (on_prefwin_key_press_event),
NULL);
+ g_signal_connect ((gpointer) prefwin, "delete_event",
+ G_CALLBACK (on_prefwin_delete_event),
+ NULL);
g_signal_connect ((gpointer) pref_soundcard, "changed",
G_CALLBACK (on_pref_soundcard_changed),
NULL);
diff --git a/plugins/nullout/nullout.c b/plugins/nullout/nullout.c
index ef14e367..05934abf 100644
--- a/plugins/nullout/nullout.c
+++ b/plugins/nullout/nullout.c
@@ -78,9 +78,6 @@ pnull_get_channels (void);
static int
pnull_get_endianness (void);
-static void
-pnull_enum_soundcards (void (*callback)(const char *name, const char *desc, void*), void *userdata);
-
int
pnull_init (void) {
state = OUTPUT_STATE_STOPPED;
@@ -208,12 +205,6 @@ pnull_callback (char *stream, int len) {
}
}
-// derived from null-utils/aplay.c
-void
-pnull_enum_soundcards (void (*callback)(const char *name, const char *desc, void *), void *userdata) {
- callback ("NULL output", "NULL output", userdata);
-}
-
int
pnull_get_state (void) {
return state;
@@ -261,5 +252,4 @@ static DB_output_t plugin = {
.bitspersample = pnull_get_bps,
.channels = pnull_get_channels,
.endianness = pnull_get_endianness,
- .enum_soundcards = pnull_enum_soundcards,
};