ocarina: Use pause_count

This allows me to say "pause in N songs" instead of limiting it pausing
only after the next song.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-04-04 07:47:56 -04:00
parent dc57109d9e
commit 8869b2aaed
2 changed files with 31 additions and 6 deletions

View File

@ -144,7 +144,7 @@ namespace ocarina
gtk_box_pack_start(GTK_BOX(footer), bottom_box, FALSE, FALSE, 0);
add_page("Now Playing", now_playing_page());
add_page("Pause", pause_page());
add_page("AutoPause", pause_page());
add_page("Library", library_page());
add_page("Settings", general_page());

View File

@ -6,16 +6,30 @@
static GtkWidget *no_pause;
static GtkWidget *after_n;
static GtkWidget *pause_counter;
static void counter_changed(GtkWidget *b, GtkScrollType *s, gpointer d)
{
unsigned short count;
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(after_n)))
return;
count = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(pause_counter));
libsaria::deck::set_pause_type(PS_AFTER_N, count);
}
static void on_toggle(GtkWidget *b, gpointer d)
{
unsigned short count;
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b)))
return;
if (b == no_pause)
libsaria::deck::set_pause_type(PS_NONE, 0);
else if (b == after_n)
libsaria::deck::set_pause_type(PS_AFTER_N, 0);
else if (b == after_n) {
count = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(pause_counter));
libsaria::deck::set_pause_type(PS_AFTER_N, count);
}
}
namespace ocarina
@ -24,15 +38,23 @@ namespace ocarina
GtkWidget *body::pause_page()
{
GtkWidget *box = gtk_vbox_new(FALSE, 0);
GtkWidget *label = gtk_label_new("Pause after current song");
GtkWidget *after_n_box = gtk_hbox_new(FALSE, 0);
GtkWidget *label1 = gtk_label_new("Pause after ");
GtkWidget *label2 = gtk_label_new(" song(s)");
no_pause = gtk_radio_button_new_with_label(NULL, "No automatic pause");
gtk_box_pack_start(GTK_BOX(box), no_pause, TRUE, TRUE, 0);
g_signal_connect(no_pause, "toggled", G_CALLBACK(on_toggle), NULL);
after_n = gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(no_pause));
gtk_container_add(GTK_CONTAINER(after_n), label);
gtk_box_pack_start(GTK_BOX(box), after_n, TRUE, TRUE, 0);
pause_counter = gtk_spin_button_new_with_range(0, 65535, 1);
gtk_box_pack_start(GTK_BOX(after_n_box), after_n, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(after_n_box), label1, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(after_n_box), pause_counter, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(after_n_box), label2, FALSE, FALSE, 0);
g_signal_connect(pause_counter, "value-changed", G_CALLBACK(counter_changed), NULL);
gtk_box_pack_start(GTK_BOX(box), after_n_box, TRUE, TRUE, 0);
g_signal_connect(after_n, "toggled", G_CALLBACK(on_toggle), NULL);
gtk_widget_show_all(box);
@ -41,12 +63,15 @@ namespace ocarina
void body::update_automatic_pause()
{
unsigned short count;
switch (libsaria::deck::get_pause_type()) {
case PS_NONE:
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(no_pause), true);
break;
case PS_AFTER_N:
count = libsaria::deck::get_pause_count();
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(after_n), true);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(pause_counter), count);
break;
}
}