gui/audio: Pass the progress bar to __audio_timeout

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-12-24 13:27:18 -05:00
parent 36b8b29b0b
commit 2d45e9e5c4
1 changed files with 12 additions and 11 deletions

View File

@ -10,7 +10,6 @@
static GtkSpinButton *o_count;
static GtkToggleButton *o_enabled;
static GtkAdjustment *o_progress;
const gchar *TITLE_FMT = "<span size='xx-large'>%s</span>";
const gchar *ARTIST_FMT = "<span size='x-large'>By: %s</span>";
@ -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"));
}