ocarina: Added automatic pause controls

Right now I just pause after the current song, but I eventually plan on
adding controls to pause after N songs.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-04-02 08:28:58 -04:00
parent 2cdfbde9be
commit 9d271740aa
4 changed files with 58 additions and 0 deletions

View File

@ -25,11 +25,13 @@ namespace ocarina
void set_now_playing();
void update_controls();
void update_automatic_pause();
void set_length_label_text(string &);
GtkWidget *playlist_init();
GtkWidget *footer_init();
GtkWidget *now_playing_page();
GtkWidget *pause_page();
GtkWidget *general_page();
GtkWidget *library_page();
}

View File

@ -144,6 +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("Library", library_page());
add_page("Settings", general_page());

View File

@ -71,6 +71,7 @@ namespace ocarina
return;
current = cur;
refresh_widgets();
update_automatic_pause();
println("Current track changed");
}

54
ocarina/body/pause.cpp Normal file
View File

@ -0,0 +1,54 @@
// Copyright (c) 2012 Bryan Schumaker
#include <ocarina/ocarina.h>
#include <ocarina/body.h>
#include <libsaria/deck.h>
static GtkWidget *no_pause;
static GtkWidget *after_n;
static void on_toggle(GtkWidget *b, gpointer d)
{
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);
}
namespace ocarina
{
GtkWidget *body::pause_page()
{
GtkWidget *box = gtk_vbox_new(FALSE, 0);
GtkWidget *label = gtk_label_new("Pause after current song");
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);
g_signal_connect(after_n, "toggled", G_CALLBACK(on_toggle), NULL);
gtk_widget_show_all(box);
return box;
}
void body::update_automatic_pause()
{
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:
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(after_n), true);
break;
}
}
}; /* Namespace: ocarina */