ocarina: Add a progress bar

This commit is contained in:
Bryan Schumaker 2011-10-29 17:24:21 -04:00
parent 8987dddade
commit 0eff7df5c4
1 changed files with 37 additions and 8 deletions

View File

@ -1,22 +1,51 @@
#include <ocarina/gtk.h>
#include <ocarina/button.h>
#include <libsaria/audio.h>
#include "footer.h"
static GtkWidget *controls = NULL;
static GtkWidget *progress = NULL;
static GtkWidget *make_buttons()
{
GtkWidget *buttons = gtk_hbox_new(FALSE, 0);
gtk_widget_show(buttons);
box_pack_end(buttons, make_volume_button(), FALSE, FALSE, 0);
box_pack_end(buttons, make_stop_button(), FALSE, FALSE, 0);
box_pack_end(buttons, make_pause_button(), FALSE, FALSE, 0);
box_pack_end(buttons, make_play_button(), FALSE, FALSE, 0);
box_pack_end(buttons, make_forward_button(), FALSE, FALSE, 0);
box_pack_end(buttons, make_rewind_button(), FALSE, FALSE, 0);
box_pack_end(buttons, make_open_button(), FALSE, FALSE, 0);
return buttons;
}
static gboolean update_progress(gpointer data)
{
gtk_range_set_value(GTK_RANGE(progress), libsaria::audio::get_progress());
return TRUE;
}
static GtkWidget *make_progress()
{
progress = gtk_hscale_new_with_range(0, 101, 1);
gtk_scale_set_draw_value(GTK_SCALE(progress), FALSE);
gtk_widget_show(progress);
gtk_timeout_add(500, update_progress, NULL);
return progress;
}
static void make_controls()
{
controls = gtk_hbox_new(FALSE, 0);
controls = gtk_vbox_new(FALSE, 0);
gtk_widget_show(controls);
box_pack_end(controls, make_volume_button(), FALSE, FALSE, 0);
box_pack_end(controls, make_stop_button(), FALSE, FALSE, 0);
box_pack_end(controls, make_pause_button(), FALSE, FALSE, 0);
box_pack_end(controls, make_play_button(), FALSE, FALSE, 0);
box_pack_end(controls, make_forward_button(), FALSE, FALSE, 0);
box_pack_end(controls, make_rewind_button(), FALSE, FALSE, 0);
box_pack_end(controls, make_open_button(), FALSE, FALSE, 0);
box_pack_start(controls, make_buttons(), FALSE, FALSE, 0);
box_pack_start(controls, make_progress(), FALSE, FALSE, 0);
}
GtkWidget *get_controls()