ocarina/gui/gui.cpp

72 lines
1.5 KiB
C++

/*
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/audio.h>
#include <core/deck.h>
#include <core/playlist.h>
#include <core/print.h>
#include <lib/colmgr.h>
#include <lib/lib.h>
#include <gui/ocarina.h>
#include <gui/tabs.h>
Gtk::SpinButton *count;
Gtk::CheckButton *enabled;
/*
* Control functions
*/
static void on_config_pause_enabled()
{
audio :: pause_after(enabled->get_active(), count->get_value());
}
static void on_config_pause_count()
{
enabled->set_active(true);
}
void on_pause_count_changed(bool enabled, unsigned int count)
{
Gtk::CheckButton *p_enabled = lib :: get_widget<Gtk::CheckButton>("o_pause_enabled");
Gtk::SpinButton *p_count = lib :: get_widget<Gtk::SpinButton>("o_pause_count");;
if (p_enabled->get_active() != enabled)
p_enabled->set_active(enabled);
if (p_count->get_value() != count)
p_count->set_value(count);
}
/*
* Ocarina functions
*/
void connect_button(const std::string &name, void (*func)())
{
lib :: get_widget<Gtk::Button>(name)->signal_clicked().connect(sigc::ptr_fun(func));
}
Gtk::Window *setup_gui()
{
/* Controls */
count = lib :: get_widget<Gtk::SpinButton>("o_pause_count");
enabled = lib :: get_widget<Gtk::CheckButton>("o_pause_enabled");
count->signal_changed().connect(sigc::ptr_fun(on_config_pause_count));
enabled->signal_toggled().connect(sigc::ptr_fun(on_config_pause_enabled));
/* Favorite and ban buttons */
if (audio :: current_track())
on_track_loaded(audio :: current_track());
/* Set up other tabs */
collection_mgr_init();
init_tabs();
return window_init();
}