diff --git a/gui/audio.c b/gui/audio.c index 9e28e976..870df5c8 100644 --- a/gui/audio.c +++ b/gui/audio.c @@ -8,9 +8,6 @@ #include -static GtkSpinButton *o_count; -static GtkToggleButton *o_enabled; - const gchar *TITLE_FMT = "%s"; const gchar *ARTIST_FMT = "By: %s"; const gchar *ALBUM_FMT = "From: %s"; @@ -58,12 +55,25 @@ static void __audio_change_state(GstState state) static void __audio_config_pause(int n) { - if (n == -1) - gtk_toggle_button_set_active(o_enabled, false); - else { - gtk_spin_button_set_value(o_count, n); - gtk_toggle_button_set_active(o_enabled, true); - } + GtkToggleButton *enabled = GTK_TOGGLE_BUTTON(gui_builder_widget("o_pause_enabled")); + + if (n >= 0) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(gui_builder_widget("o_pause_count")), n); + gtk_toggle_button_set_active(enabled, n >= 0); +} + +void __audio_pause_count(GtkSpinButton *count) +{ + audio_pause_after(gtk_spin_button_get_value(count)); +} + +void __audio_pause_enabled(GtkToggleButton *enabled, GtkSpinButton *count) +{ + int val = -1; + + if (gtk_toggle_button_get_active(enabled)) + val = gtk_spin_button_get_value(count); + audio_pause_after(val); } void __audio_seek(GtkScrollType type, double value) @@ -83,34 +93,14 @@ static int __audio_timeout(gpointer data) } + struct audio_ops audio_ops = { __audio_load, __audio_change_state, __audio_config_pause, }; - -static void on_pause_count() -{ - gtk_toggle_button_set_active(o_enabled, true); - audio_pause_after(gtk_spin_button_get_value(o_count)); -} - -static void on_pause_enabled() -{ - if (!gtk_toggle_button_get_active(o_enabled)) - audio_pause_after(-1); - else - audio_pause_after(gtk_spin_button_get_value(o_count)); -} - void gui_audio_init() { - o_count = GTK_SPIN_BUTTON(gui_builder_widget("o_pause_count")); - o_enabled = GTK_TOGGLE_BUTTON(gui_builder_widget("o_pause_enabled")); - - g_signal_connect(o_count, "changed", G_CALLBACK(on_pause_count), NULL); - g_signal_connect(o_enabled, "toggled", G_CALLBACK(on_pause_enabled), NULL); - g_timeout_add(500, __audio_timeout, gui_builder_object("o_progress")); } diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index 6f7f2092..0468a714 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -713,6 +713,7 @@ Manager False 0.5 True + False @@ -727,6 +728,7 @@ Manager False adjustment1 True + False