From 2d45e9e5c46ef9fae0d3224734ff1e4a4777b724 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 24 Dec 2015 13:27:18 -0500 Subject: [PATCH] gui/audio: Pass the progress bar to __audio_timeout Signed-off-by: Anna Schumaker --- gui/audio.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/gui/audio.c b/gui/audio.c index 9527be71..9e28e976 100644 --- a/gui/audio.c +++ b/gui/audio.c @@ -10,7 +10,6 @@ static GtkSpinButton *o_count; static GtkToggleButton *o_enabled; -static GtkAdjustment *o_progress; const gchar *TITLE_FMT = "%s"; const gchar *ARTIST_FMT = "By: %s"; @@ -72,6 +71,17 @@ void __audio_seek(GtkScrollType type, double value) audio_seek(value); } +static int __audio_timeout(gpointer data) +{ + GtkAdjustment *progress = data; + + gtk_adjustment_set_upper(progress, audio_duration()); + gtk_adjustment_set_value(progress, audio_position()); + __audio_set_time_label("o_position", audio_position() / GST_SECOND); + + return G_SOURCE_CONTINUE; +} + struct audio_ops audio_ops = { __audio_load, @@ -94,22 +104,13 @@ static void on_pause_enabled() audio_pause_after(gtk_spin_button_get_value(o_count)); } -static int on_timeout(gpointer data) -{ - gtk_adjustment_set_upper(o_progress, audio_duration()); - gtk_adjustment_set_value(o_progress, audio_position()); - __audio_set_time_label("o_position", audio_position() / GST_SECOND); - return true; -} - 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")); - o_progress = GTK_ADJUSTMENT(gui_builder_object("o_progress")); 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, on_timeout, NULL); + g_timeout_add(500, __audio_timeout, gui_builder_object("o_progress")); }