diff options
Diffstat (limited to 'callbacks.c')
-rw-r--r-- | callbacks.c | 83 |
1 files changed, 73 insertions, 10 deletions
diff --git a/callbacks.c b/callbacks.c index 3a0858e9..95801fda 100644 --- a/callbacks.c +++ b/callbacks.c @@ -1357,6 +1357,27 @@ on_add_audio_cd_activate (GtkMenuItem *menuitem, static GtkWidget *prefwin; +static char alsa_device_names[100][64]; +static int num_alsa_devices; + +static void +gtk_enum_sound_callback (const char *name, const char *desc, void *userdata) { + if (num_alsa_devices >= 100) { + fprintf (stderr, "wtf!! more than 100 alsa devices??\n"); + return; + } + GtkComboBox *combobox = GTK_COMBO_BOX (userdata); + gtk_combo_box_append_text (combobox, desc); + + if (!strcmp (conf_get_str ("alsa_soundcard", "default"), name)) { + gtk_combo_box_set_active (combobox, num_alsa_devices); + } + + strncpy (alsa_device_names[num_alsa_devices], name, 63); + alsa_device_names[num_alsa_devices][63] = 0; + num_alsa_devices++; +} + void on_preferences_activate (GtkMenuItem *menuitem, gpointer user_data) @@ -1365,19 +1386,18 @@ on_preferences_activate (GtkMenuItem *menuitem, gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (mainwin)); // alsa_soundcard - // FIXME: get list of soundcards from alsa + const char *s = conf_get_str ("alsa_soundcard", "default"); GtkComboBox *combobox = GTK_COMBO_BOX (lookup_widget (w, "pref_soundcard")); - if (strcasecmp (s, "default")) { - gtk_combo_box_append_text (combobox, s); - gtk_combo_box_set_active (combobox, 1); - } - else { + 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"); + palsa_enum_soundcards (gtk_enum_sound_callback, combobox); // alsa resampling -// gtk_entry_set_text (GTK_ENTRY (lookup_widget (w, "pref_samplerate")), conf_get_str ("samplerate", "48000")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (w, "pref_alsa_resampling")), conf_get_int ("alsa.resample", 0)); // src_quality @@ -1417,17 +1437,20 @@ void on_pref_soundcard_changed (GtkComboBox *combobox, gpointer user_data) { - char *text = gtk_combo_box_get_active_text (combobox); - conf_set_str ("alsa_soundcard", text ? text : "default"); + int active = gtk_combo_box_get_active (combobox); + if (active >= 0 && active < num_alsa_devices) { + conf_set_str ("alsa_soundcard", alsa_device_names[active]); + messagepump_push (M_CONFIGCHANGED, 0, 0, 0); + } } - void on_pref_alsa_resampling_clicked (GtkButton *button, gpointer user_data) { int active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); conf_set_int ("alsa.resample", active); + messagepump_push (M_CONFIGCHANGED, 0, 0, 0); } @@ -1437,6 +1460,7 @@ on_pref_src_quality_changed (GtkComboBox *combobox, { int active = gtk_combo_box_get_active (combobox); conf_set_int ("src_quality", active == -1 ? 2 : active); + messagepump_push (M_CONFIGCHANGED, 0, 0, 0); } @@ -1446,6 +1470,7 @@ on_pref_replaygain_mode_changed (GtkComboBox *combobox, { int active = gtk_combo_box_get_active (combobox); conf_set_int ("replaygain_mode", active == -1 ? 0 : active); + messagepump_push (M_CONFIGCHANGED, 0, 0, 0); } void @@ -1454,6 +1479,7 @@ on_pref_replaygain_scale_clicked (GtkButton *button, { int active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); conf_set_int ("replaygain_scale", active); + messagepump_push (M_CONFIGCHANGED, 0, 0, 0); } @@ -1463,6 +1489,7 @@ on_pref_close_send_to_tray_clicked (GtkButton *button, { int active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); conf_set_int ("close_send_to_tray", active); + messagepump_push (M_CONFIGCHANGED, 0, 0, 0); } @@ -1564,3 +1591,39 @@ on_remove_column_activate (GtkMenuItem *menuitem, } + +void +on_pref_alsa_freewhenstopped_clicked (GtkButton *button, + gpointer user_data) +{ + int active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); + conf_set_int ("alsa.freeonstop", active); +} + + + + + +void +on_pref_network_proxyaddress_changed (GtkEditable *editable, + gpointer user_data) +{ + +} + + +void +on_pref_network_enableproxy_clicked (GtkButton *button, + gpointer user_data) +{ + +} + + +void +on_pref_network_proxyport_changed (GtkEditable *editable, + gpointer user_data) +{ + +} + |