gui: Handle pause counts from the GSTDriver

I think it makes sense to handle this directly from the driver, rather
than going through a callback.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2014-12-20 15:24:04 -05:00
parent cd8c76e1b2
commit 50147ef070
3 changed files with 16 additions and 14 deletions

View File

@ -124,6 +124,8 @@ static gboolean on_gst_message(GstBus *bus, GstMessage *message, gpointer data)
break; break;
case GST_MESSAGE_EOS: case GST_MESSAGE_EOS:
gst_driver->eos(); gst_driver->eos();
on_pause_count_changed(audio :: pause_enabled(),
audio :: pause_count());
break; break;
default: default:
break; break;

View File

@ -2,7 +2,6 @@
* Copyright 2014 (c) Anna Schumaker. * Copyright 2014 (c) Anna Schumaker.
*/ */
#include <core/audio.h> #include <core/audio.h>
#include <core/callback.h>
#include <core/deck.h> #include <core/deck.h>
#include <core/driver.h> #include <core/driver.h>
#include <core/playlist.h> #include <core/playlist.h>
@ -16,20 +15,24 @@
static sigc::connection fav_connection; static sigc::connection fav_connection;
static sigc::connection ban_connection; static sigc::connection ban_connection;
Gtk::SpinButton *count;
Gtk::CheckButton *enabled;
/* /*
* Control functions * Control functions
*/ */
static void on_config_pause() static void on_config_pause_enabled()
{ {
Gtk::SpinButton *count = lib :: get_widget<Gtk::SpinButton>("o_pause_count");
Gtk::CheckButton *enabled = lib :: get_widget<Gtk::CheckButton>("o_pause_enabled");
audio :: pause_after(enabled->get_active(), count->get_value()); audio :: pause_after(enabled->get_active(), count->get_value());
} }
static void on_config_pause_count()
{
enabled->set_active(true);
}
static void set_label_text(Gtk::Label *label, const std::string &size, static void set_label_text(Gtk::Label *label, const std::string &size,
const std::string &text) const std::string &text)
{ {
@ -64,7 +67,7 @@ void on_track_loaded(Track *track)
fav_connection.unblock(); fav_connection.unblock();
} }
static void on_pause_count_changed(bool enabled, unsigned int count) void on_pause_count_changed(bool enabled, unsigned int count)
{ {
Gtk::CheckButton *p_enabled = lib :: get_widget<Gtk::CheckButton>("o_pause_enabled"); Gtk::CheckButton *p_enabled = lib :: get_widget<Gtk::CheckButton>("o_pause_enabled");
Gtk::SpinButton *p_count = lib :: get_widget<Gtk::SpinButton>("o_pause_count");; Gtk::SpinButton *p_count = lib :: get_widget<Gtk::SpinButton>("o_pause_count");;
@ -108,16 +111,12 @@ void connect_button(const std::string &name, void (*func)())
Gtk::Window *setup_gui() Gtk::Window *setup_gui()
{ {
struct Callbacks *cb = get_callbacks();
/* Controls */ /* Controls */
Gtk::SpinButton *count = lib :: get_widget<Gtk::SpinButton>("o_pause_count"); count = lib :: get_widget<Gtk::SpinButton>("o_pause_count");
Gtk::CheckButton *enabled = lib :: get_widget<Gtk::CheckButton>("o_pause_enabled"); enabled = lib :: get_widget<Gtk::CheckButton>("o_pause_enabled");
cb->on_pause_count_changed = on_pause_count_changed; count->signal_changed().connect(sigc::ptr_fun(on_config_pause_count));
enabled->signal_toggled().connect(sigc::ptr_fun(on_config_pause_enabled));
count->signal_changed().connect(sigc::ptr_fun(on_config_pause));
enabled->signal_toggled().connect(sigc::ptr_fun(on_config_pause));
/* Favorite and ban buttons */ /* Favorite and ban buttons */

View File

@ -18,6 +18,7 @@ Gtk::Window *ocarina_init(int *, char ***);
/* gui.cpp */ /* gui.cpp */
void connect_button(const std::string &, void (*func)()); void connect_button(const std::string &, void (*func)());
void on_pause_count_changed(bool, unsigned int);
Gtk::Window *setup_gui(); Gtk::Window *setup_gui();
void on_pq_created(Queue *, unsigned int); void on_pq_created(Queue *, unsigned int);