ocarina: Move the progress bar
I put it above the current song display and taking up the full width of the window. I think a big progress bar is more useful than a small one.
This commit is contained in:
parent
c75d832934
commit
0db7c0cf6b
|
@ -1,11 +1,9 @@
|
|||
|
||||
#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()
|
||||
{
|
||||
|
@ -23,29 +21,12 @@ static GtkWidget *make_buttons()
|
|||
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_vbox_new(FALSE, 0);
|
||||
gtk_widget_show(controls);
|
||||
|
||||
box_pack_start(controls, make_buttons(), FALSE, FALSE, 0);
|
||||
box_pack_start(controls, make_progress(), FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
GtkWidget *get_controls()
|
||||
|
|
|
@ -10,8 +10,9 @@ static void make_footer()
|
|||
GtkWidget *content = gtk_hbox_new(FALSE, 5);
|
||||
|
||||
footer = gtk_vbox_new(FALSE, 0);
|
||||
box_pack_start(footer, sep, FALSE, FALSE, 0);
|
||||
box_pack_start(footer, content, FALSE, FALSE, 0);
|
||||
box_pack_start(footer, sep, FALSE, FALSE, 0);
|
||||
box_pack_start(footer, get_progress(), FALSE, FALSE, 0);
|
||||
box_pack_start(footer, content, FALSE, FALSE, 0);
|
||||
/*
|
||||
* The pause button begins life hidden, so show everything up until
|
||||
* this point, and then add the controls
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
|
||||
GtkWidget *get_controls();
|
||||
GtkWidget *get_nowplaying();
|
||||
GtkWidget *get_progress();
|
||||
|
||||
#endif /* OCARINA_FOOTER_PRIVATE_H */
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
#include <ocarina/gtk.h>
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/print.h>
|
||||
#include "footer.h"
|
||||
|
||||
static GtkWidget *progress = NULL;
|
||||
|
||||
static gboolean update_progress(gpointer data)
|
||||
{
|
||||
gtk_range_set_range(GTK_RANGE(progress), 0, libsaria::audio::duration() + 1);
|
||||
gtk_range_set_value(GTK_RANGE(progress), libsaria::audio::position());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void make_progress()
|
||||
{
|
||||
progress = gtk_hscale_new_with_range(0, 1, 1);
|
||||
|
||||
gtk_scale_set_draw_value(GTK_SCALE(progress), FALSE);
|
||||
gtk_widget_show(progress);
|
||||
gtk_timeout_add(100, update_progress, NULL);
|
||||
}
|
||||
|
||||
GtkWidget *get_progress()
|
||||
{
|
||||
if (progress == NULL)
|
||||
make_progress();
|
||||
return progress;
|
||||
}
|
Loading…
Reference in New Issue