lib: Initialize the GtkBuilder from the middle layer
This will provide an interface for accessing widgets, and make it easier to swap out different builder files. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
4ed36c79df
commit
194a09bed4
|
@ -23,6 +23,7 @@ class OEnvironment(Environment):
|
|||
|
||||
def __init__(self, CCFLAGS = CONFIG_CCFLAGS):
|
||||
Environment.__init__(self, CCFLAGS = CCFLAGS)
|
||||
self.Append(ENV = os.environ)
|
||||
self.Append(CPPPATH = os.path.abspath("include"))
|
||||
self.Append(CXXCOMSTR = "C++ $TARGET")
|
||||
self.Append(LINKCOMSTR = "Linking $TARGET")
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
#!/usr/bin/python
|
||||
Import("env")
|
||||
|
||||
env.UsePackage("gtkmm-3.0")
|
||||
|
||||
res = Glob("*.cpp")
|
||||
Return("res")
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <core/library.h>
|
||||
#include <core/playlist.h>
|
||||
#include <gui/tabs.h>
|
||||
#include <lib/lib.h>
|
||||
|
||||
|
||||
class CollectionTab : public Tab {
|
||||
|
@ -19,11 +20,11 @@ public:
|
|||
CollectionTab :: CollectionTab()
|
||||
: Tab(library::get_queue())
|
||||
{
|
||||
tab_random = get_widget<Gtk::ToggleButton>("o_collection_random");
|
||||
tab_search = get_widget<Gtk::SearchEntry>("o_collection_entry");
|
||||
tab_size = get_widget<Gtk::Label>("o_collection_size");
|
||||
tab_treeview = get_widget<Gtk::TreeView>("o_collection_pq_treeview");
|
||||
tab_widget = get_widget<Gtk::Widget>("o_collection_page");
|
||||
tab_random = lib :: get_widget<Gtk::ToggleButton>("o_collection_random");
|
||||
tab_search = lib :: get_widget<Gtk::SearchEntry>("o_collection_entry");
|
||||
tab_size = lib :: get_widget<Gtk::Label>("o_collection_size");
|
||||
tab_treeview = lib :: get_widget<Gtk::TreeView>("o_collection_pq_treeview");
|
||||
tab_widget = lib :: get_widget<Gtk::Widget>("o_collection_page");
|
||||
|
||||
tab_finish_init();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
|
||||
static Glib::RefPtr<Gtk::ListStore> get_collection_list()
|
||||
{
|
||||
return get_object<Gtk::ListStore>("o_collection_dirs");
|
||||
return lib :: get_object<Gtk::ListStore>("o_collection_dirs");
|
||||
}
|
||||
|
||||
static void on_collection_ok()
|
||||
|
@ -28,7 +28,7 @@ static void on_collection_ok()
|
|||
std::string path;
|
||||
Gtk::FileChooserWidget *chooser;
|
||||
|
||||
chooser = get_widget<Gtk::FileChooserWidget>("o_collection_chooser");
|
||||
chooser = lib :: get_widget<Gtk::FileChooserWidget>("o_collection_chooser");
|
||||
path = chooser->get_filename();
|
||||
Library *library = library::add(path);
|
||||
enable_idle();
|
||||
|
@ -44,7 +44,7 @@ static void on_collection_update()
|
|||
static void on_collection_row_activated(const Gtk::TreePath &path,
|
||||
Gtk::TreeViewColumn *col)
|
||||
{
|
||||
Gtk::FileChooser *chooser = get_widget<Gtk::FileChooser>("o_collection_chooser");
|
||||
Gtk::FileChooser *chooser = lib :: get_widget<Gtk::FileChooser>("o_collection_chooser");
|
||||
Glib::RefPtr<Gtk::ListStore> list = get_collection_list();
|
||||
|
||||
Gtk::TreeModel::Row row = *(list->get_iter(path));
|
||||
|
@ -59,7 +59,7 @@ void do_collection_delete()
|
|||
{
|
||||
Gtk::TreePath path;
|
||||
Gtk::TreeViewColumn *col;
|
||||
Gtk::TreeView *treeview = get_widget<Gtk::TreeView>("o_collection_treeview");
|
||||
Gtk::TreeView *treeview = lib :: get_widget<Gtk::TreeView>("o_collection_treeview");
|
||||
|
||||
treeview->get_cursor(path, col);
|
||||
if (path) {
|
||||
|
@ -120,11 +120,11 @@ static void on_library_update(unsigned int id, Library *library)
|
|||
|
||||
void collection_mgr_init()
|
||||
{
|
||||
Gtk::TreeView *treeview = get_widget<Gtk::TreeView>("o_collection_treeview");
|
||||
Gtk::TreeView *treeview = lib :: get_widget<Gtk::TreeView>("o_collection_treeview");
|
||||
Glib::RefPtr<Gtk::ListStore> list = get_collection_list();
|
||||
Glib::RefPtr<Gtk::CellRendererToggle> toggle;
|
||||
|
||||
toggle = get_object<Gtk::CellRendererToggle>("o_collection_toggle");
|
||||
toggle = lib :: get_object<Gtk::CellRendererToggle>("o_collection_toggle");
|
||||
|
||||
connect_button("o_collection_ok", on_collection_ok);
|
||||
connect_button("o_collection_update", on_collection_update);
|
||||
|
|
66
gui/gui.cpp
66
gui/gui.cpp
|
@ -14,7 +14,6 @@
|
|||
#include <gui/tabs.h>
|
||||
|
||||
static bool audio_playing = false;
|
||||
static Glib::RefPtr<Gtk::Builder> builder;
|
||||
static sigc::connection fav_connection;
|
||||
static sigc::connection ban_connection;
|
||||
void enable_timeout();
|
||||
|
@ -26,24 +25,24 @@ void enable_timeout();
|
|||
*/
|
||||
static void on_config_pause()
|
||||
{
|
||||
Gtk::SpinButton *count = get_widget<Gtk::SpinButton>("o_pause_count");
|
||||
Gtk::CheckButton *enabled = get_widget<Gtk::CheckButton>("o_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());
|
||||
}
|
||||
|
||||
static void on_play()
|
||||
{
|
||||
get_widget<Gtk::Button>("o_play")->hide();
|
||||
get_widget<Gtk::Button>("o_pause")->show();
|
||||
lib :: get_widget<Gtk::Button>("o_play")->hide();
|
||||
lib :: get_widget<Gtk::Button>("o_pause")->show();
|
||||
audio_playing = true;
|
||||
enable_timeout();
|
||||
}
|
||||
|
||||
static void on_pause()
|
||||
{
|
||||
get_widget<Gtk::Button>("o_play")->show();
|
||||
get_widget<Gtk::Button>("o_pause")->hide();
|
||||
lib :: get_widget<Gtk::Button>("o_play")->show();
|
||||
lib :: get_widget<Gtk::Button>("o_pause")->hide();
|
||||
audio_playing = false;
|
||||
}
|
||||
|
||||
|
@ -68,12 +67,12 @@ static void set_label_text(Gtk::Label *label, const std::string &size,
|
|||
|
||||
static void on_track_loaded(Track *track)
|
||||
{
|
||||
Gtk::ToggleButton *ban = get_widget<Gtk::ToggleButton>("o_ban");
|
||||
Gtk::ToggleButton *fav = get_widget<Gtk::ToggleButton>("o_favorite");
|
||||
Gtk::Label *title = get_widget<Gtk::Label>("o_title");
|
||||
Gtk::Label *artist = get_widget<Gtk::Label>("o_artist");
|
||||
Gtk::Label *album = get_widget<Gtk::Label>("o_album");
|
||||
Gtk::Label *duration = get_widget<Gtk::Label>("o_total_time");
|
||||
Gtk::ToggleButton *ban = lib :: get_widget<Gtk::ToggleButton>("o_ban");
|
||||
Gtk::ToggleButton *fav = lib :: get_widget<Gtk::ToggleButton>("o_favorite");
|
||||
Gtk::Label *title = lib :: get_widget<Gtk::Label>("o_title");
|
||||
Gtk::Label *artist = lib :: get_widget<Gtk::Label>("o_artist");
|
||||
Gtk::Label *album = lib :: get_widget<Gtk::Label>("o_album");
|
||||
Gtk::Label *duration = lib :: get_widget<Gtk::Label>("o_total_time");
|
||||
|
||||
set_label_text(title, "xx-large", track->title);
|
||||
set_label_text(artist, "x-large", "By: " + track->artist->name);
|
||||
|
@ -95,8 +94,8 @@ static void on_track_loaded(Track *track)
|
|||
|
||||
static void on_pause_count_changed(bool enabled, unsigned int count)
|
||||
{
|
||||
Gtk::CheckButton *p_enabled = get_widget<Gtk::CheckButton>("o_pause_enabled");
|
||||
Gtk::SpinButton *p_count = get_widget<Gtk::SpinButton>("o_pause_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);
|
||||
|
@ -106,7 +105,7 @@ static void on_pause_count_changed(bool enabled, unsigned int count)
|
|||
|
||||
static void on_ban_toggled()
|
||||
{
|
||||
Gtk::ToggleButton *ban = get_widget<Gtk::ToggleButton>("o_ban");
|
||||
Gtk::ToggleButton *ban = lib :: get_widget<Gtk::ToggleButton>("o_ban");
|
||||
|
||||
if (ban->get_active() == true)
|
||||
playlist :: add(audio :: current_track(), "Banned");
|
||||
|
@ -116,7 +115,7 @@ static void on_ban_toggled()
|
|||
|
||||
static void on_fav_toggled()
|
||||
{
|
||||
Gtk::ToggleButton *fav = get_widget<Gtk::ToggleButton>("o_favorite");
|
||||
Gtk::ToggleButton *fav = lib :: get_widget<Gtk::ToggleButton>("o_favorite");
|
||||
|
||||
if (fav->get_active() == true)
|
||||
playlist :: add(audio::current_track(), "Favorites");
|
||||
|
@ -131,8 +130,8 @@ static void on_fav_toggled()
|
|||
*/
|
||||
static bool on_window_key_pressed(GdkEventKey *event)
|
||||
{
|
||||
Gtk::Notebook *notebook = get_widget<Gtk::Notebook>("o_notebook");
|
||||
Gtk::Window *window = get_widget<Gtk::Window>("o_window");
|
||||
Gtk::Notebook *notebook = lib :: get_widget<Gtk::Notebook>("o_notebook");
|
||||
Gtk::Window *window = lib :: get_widget<Gtk::Window>("o_window");
|
||||
std::string key = gdk_keyval_name(event->keyval);
|
||||
|
||||
if (key.size() >= 3) {
|
||||
|
@ -186,7 +185,7 @@ static bool on_window_key_released(GdkEventKey *event)
|
|||
*/
|
||||
bool on_idle()
|
||||
{
|
||||
Gtk::ProgressBar *prog = get_widget<Gtk::ProgressBar>("o_idle_progress");
|
||||
Gtk::ProgressBar *prog = lib :: get_widget<Gtk::ProgressBar>("o_idle_progress");
|
||||
bool ret = idle::run_task();
|
||||
|
||||
if (ret == false)
|
||||
|
@ -212,8 +211,8 @@ void enable_idle()
|
|||
*/
|
||||
bool on_timeout()
|
||||
{
|
||||
Gtk::Label *position = get_widget<Gtk::Label>("o_cur_position");
|
||||
Glib::RefPtr<Gtk::Adjustment> bar = get_object<Gtk::Adjustment>("o_progress");
|
||||
Gtk::Label *position = lib :: get_widget<Gtk::Label>("o_cur_position");
|
||||
Glib::RefPtr<Gtk::Adjustment> bar = lib :: get_object<Gtk::Adjustment>("o_progress");
|
||||
|
||||
position->set_text(audio :: position_str());
|
||||
bar->set_upper(audio :: duration());
|
||||
|
@ -231,28 +230,19 @@ void enable_timeout()
|
|||
/*
|
||||
* Ocarina functions
|
||||
*/
|
||||
Glib::RefPtr<Gtk::Builder> &get_builder()
|
||||
{
|
||||
return builder;
|
||||
}
|
||||
|
||||
void connect_button(const std::string &name, void (*func)())
|
||||
{
|
||||
get_widget<Gtk::Button>(name)->signal_clicked().connect(sigc::ptr_fun(func));
|
||||
lib :: get_widget<Gtk::Button>(name)->signal_clicked().connect(sigc::ptr_fun(func));
|
||||
}
|
||||
|
||||
Gtk::Window *setup_gui()
|
||||
{
|
||||
struct Callbacks *cb = get_callbacks();
|
||||
|
||||
builder = Gtk::Builder::create();
|
||||
builder->add_from_file(lib :: share_file("ocarina6.glade"));
|
||||
|
||||
|
||||
/* Controls */
|
||||
Gtk::SpinButton *count = get_widget<Gtk::SpinButton>("o_pause_count");
|
||||
Gtk::CheckButton *enabled = get_widget<Gtk::CheckButton>("o_pause_enabled");
|
||||
Gtk::Scale *position = get_widget<Gtk::Scale>("o_position_scale");
|
||||
Gtk::SpinButton *count = lib :: get_widget<Gtk::SpinButton>("o_pause_count");
|
||||
Gtk::CheckButton *enabled = lib :: get_widget<Gtk::CheckButton>("o_pause_enabled");
|
||||
Gtk::Scale *position = lib :: get_widget<Gtk::Scale>("o_position_scale");
|
||||
|
||||
cb->on_play = on_play;
|
||||
cb->on_pause = on_pause;
|
||||
|
@ -271,7 +261,7 @@ Gtk::Window *setup_gui()
|
|||
|
||||
|
||||
/* Keyboard shortcuts */
|
||||
Gtk::Window *window = get_widget<Gtk::Window>("o_window");
|
||||
Gtk::Window *window = lib :: get_widget<Gtk::Window>("o_window");
|
||||
|
||||
window->signal_key_press_event().connect(sigc::ptr_fun(on_window_key_pressed));
|
||||
window->signal_key_release_event().connect(sigc::ptr_fun(on_window_key_released));
|
||||
|
@ -280,8 +270,8 @@ Gtk::Window *setup_gui()
|
|||
|
||||
|
||||
/* Favorite and ban buttons */
|
||||
Gtk::ToggleButton *ban = get_widget<Gtk::ToggleButton>("o_ban");
|
||||
Gtk::ToggleButton *fav = get_widget<Gtk::ToggleButton>("o_favorite");
|
||||
Gtk::ToggleButton *ban = lib :: get_widget<Gtk::ToggleButton>("o_ban");
|
||||
Gtk::ToggleButton *fav = lib :: get_widget<Gtk::ToggleButton>("o_favorite");
|
||||
|
||||
ban_connection = ban->signal_toggled().connect(sigc::ptr_fun(on_ban_toggled));
|
||||
fav_connection = fav->signal_toggled().connect(sigc::ptr_fun(on_fav_toggled));
|
||||
|
|
|
@ -15,10 +15,10 @@ public:
|
|||
HistoryTab :: HistoryTab()
|
||||
: Tab(deck :: get_queue())
|
||||
{
|
||||
tab_search = get_widget<Gtk::SearchEntry>("o_history_entry");
|
||||
tab_size = get_widget<Gtk::Label>("o_history_size");
|
||||
tab_treeview = get_widget<Gtk::TreeView>("o_history_treeview");
|
||||
tab_widget = get_widget<Gtk::Widget>("o_history_page");
|
||||
tab_search = lib :: get_widget<Gtk::SearchEntry>("o_history_entry");
|
||||
tab_size = lib :: get_widget<Gtk::Label>("o_history_size");
|
||||
tab_treeview = lib :: get_widget<Gtk::TreeView>("o_history_treeview");
|
||||
tab_widget = lib :: get_widget<Gtk::Widget>("o_history_page");
|
||||
|
||||
tab_finish_init();
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
Gtk::Window *ocarina_init(int *argc, char ***argv)
|
||||
{
|
||||
|
||||
lib :: init(argc, argv, "ocarina6.glade");
|
||||
|
||||
Gtk::Window *window = setup_gui();
|
||||
|
||||
lib :: init(argc, argv);
|
||||
|
||||
playlist :: select("Favorites");
|
||||
post_init_tabs();
|
||||
collection_mgr_init2();
|
||||
|
|
|
@ -22,9 +22,9 @@ public:
|
|||
PlaylistTab :: PlaylistTab()
|
||||
: Tab(playlist :: get_queue())
|
||||
{
|
||||
tab_search = get_widget<Gtk::SearchEntry>("o_playlist_entry");
|
||||
tab_treeview = get_widget<Gtk::TreeView>("o_playlist_pq_treeview");
|
||||
tab_widget = get_widget<Gtk::Widget>("o_playlist_page");
|
||||
tab_search = lib :: get_widget<Gtk::SearchEntry>("o_playlist_entry");
|
||||
tab_treeview = lib :: get_widget<Gtk::TreeView>("o_playlist_pq_treeview");
|
||||
tab_widget = lib :: get_widget<Gtk::Widget>("o_playlist_page");
|
||||
|
||||
tab_finish_init();
|
||||
}
|
||||
|
@ -95,8 +95,8 @@ static PlaylistTab *playlist_tab;
|
|||
void init_playlist_tab()
|
||||
{
|
||||
playlist_tab = new PlaylistTab;
|
||||
playlist_ls = get_object<Gtk::ListStore>("o_playlists");
|
||||
playlist_tv = get_widget<Gtk::TreeView>("o_playlist_treeview");
|
||||
playlist_ls = lib :: get_object<Gtk::ListStore>("o_playlists");
|
||||
playlist_tv = lib :: get_widget<Gtk::TreeView>("o_playlist_treeview");
|
||||
|
||||
playlist_tv->signal_cursor_changed().connect(sigc::ptr_fun(on_playlist_cursor_changed));
|
||||
playlist_tv->signal_button_press_event().connect(sigc::ptr_fun(on_playlist_clicked));
|
||||
|
|
|
@ -165,8 +165,8 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num)
|
|||
tab_finish_init();
|
||||
queue_mapping[tab_widget] = this;
|
||||
|
||||
get_widget<Gtk::Notebook>("o_notebook")->insert_page(q_vbox, q_tab_box, num);
|
||||
get_widget<Gtk::Notebook>("o_notebook")->set_tab_reorderable(q_vbox);
|
||||
lib :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(q_vbox, q_tab_box, num);
|
||||
lib :: get_widget<Gtk::Notebook>("o_notebook")->set_tab_reorderable(q_vbox);
|
||||
q_vbox.show_all();
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ QueueTab :: ~QueueTab()
|
|||
{
|
||||
queue_mapping.erase(tab_widget);
|
||||
tab_unmap();
|
||||
get_widget<Gtk::Notebook>("o_notebook")->remove_page(q_vbox);
|
||||
lib :: get_widget<Gtk::Notebook>("o_notebook")->remove_page(q_vbox);
|
||||
}
|
||||
|
||||
|
||||
|
@ -336,7 +336,7 @@ static void on_pq_removed(Queue *pq)
|
|||
|
||||
static void on_page_reordered(Gtk::Widget *page, int num)
|
||||
{
|
||||
Gtk::Notebook *notebook = get_widget<Gtk::Notebook>("o_notebook");
|
||||
Gtk::Notebook *notebook = lib :: get_widget<Gtk::Notebook>("o_notebook");
|
||||
|
||||
if ((unsigned int)num >= deck :: get_queues().size()) {
|
||||
notebook->reorder_child(*page, deck::get_queues().size() - 1);
|
||||
|
@ -356,7 +356,7 @@ void init_queue_tabs()
|
|||
struct Callbacks *cb = get_callbacks();
|
||||
cb->on_pq_removed = on_pq_removed;
|
||||
|
||||
Gtk::Notebook *notebook = get_widget<Gtk::Notebook>("o_notebook");
|
||||
Gtk::Notebook *notebook = lib :: get_widget<Gtk::Notebook>("o_notebook");
|
||||
notebook->signal_page_reordered().connect(sigc::ptr_fun(on_page_reordered));
|
||||
}
|
||||
|
||||
|
|
40
gui/tabs.cpp
40
gui/tabs.cpp
|
@ -93,20 +93,20 @@ void Tab :: tab_toggle_button(Gtk::ToggleButton *button, queue_flags flag)
|
|||
|
||||
int Tab :: tab_page_num()
|
||||
{
|
||||
Gtk::Notebook *notebook = get_widget<Gtk::Notebook>("o_notebook");
|
||||
Gtk::Notebook *notebook = lib :: get_widget<Gtk::Notebook>("o_notebook");
|
||||
return notebook->page_num(*tab_widget);
|
||||
}
|
||||
|
||||
bool Tab :: tab_is_cur()
|
||||
{
|
||||
Gtk::Notebook *notebook = get_widget<Gtk::Notebook>("o_notebook");
|
||||
Gtk::Notebook *notebook = lib :: get_widget<Gtk::Notebook>("o_notebook");
|
||||
return notebook->page_num(*tab_widget) == notebook->get_current_page();
|
||||
}
|
||||
|
||||
void Tab :: tab_runtime_changed()
|
||||
{
|
||||
if (tab_is_cur())
|
||||
get_widget<Gtk::Label>("o_queue_time")->set_text(tab_pq->length_str());
|
||||
lib :: get_widget<Gtk::Label>("o_queue_time")->set_text(tab_pq->length_str());
|
||||
}
|
||||
|
||||
void Tab :: tab_display_sorting()
|
||||
|
@ -114,7 +114,7 @@ void Tab :: tab_display_sorting()
|
|||
std::string text = "";
|
||||
if ((tab_sorting_count > 0) && tab_is_cur())
|
||||
text = "Sorting within " + tab_sorting_title;
|
||||
get_widget<Gtk::Label>("o_sorting_indicator")->set_text(text);
|
||||
lib :: get_widget<Gtk::Label>("o_sorting_indicator")->set_text(text);
|
||||
}
|
||||
|
||||
void Tab :: tab_dec_sort_count()
|
||||
|
@ -255,23 +255,23 @@ void Tab :: on_show_rc_menu()
|
|||
unsigned int size = deck :: get_queues().size();
|
||||
|
||||
if (size == 0) {
|
||||
get_widget<Gtk::MenuItem>("o_add_to_pq")->hide();
|
||||
lib :: get_widget<Gtk::MenuItem>("o_add_to_pq")->hide();
|
||||
return;
|
||||
}
|
||||
get_widget<Gtk::MenuItem>("o_add_to_pq")->show();
|
||||
lib :: get_widget<Gtk::MenuItem>("o_add_to_pq")->show();
|
||||
|
||||
if (size == 10)
|
||||
get_widget<Gtk::MenuItem>("o_new_pq")->hide();
|
||||
lib :: get_widget<Gtk::MenuItem>("o_new_pq")->hide();
|
||||
else
|
||||
get_widget<Gtk::MenuItem>("o_new_pq")->show();
|
||||
lib :: get_widget<Gtk::MenuItem>("o_new_pq")->show();
|
||||
|
||||
for (unsigned int i = 0; i < 10; i++) {
|
||||
item = "o_pq_";
|
||||
item += '0' + i;
|
||||
if (i < size)
|
||||
get_widget<Gtk::MenuItem>(item)->show();
|
||||
lib :: get_widget<Gtk::MenuItem>(item)->show();
|
||||
else
|
||||
get_widget<Gtk::MenuItem>(item)->hide();
|
||||
lib :: get_widget<Gtk::MenuItem>(item)->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,7 @@ bool Tab :: on_button_pressed(GdkEventButton *button)
|
|||
tab_treeview->get_selection()->select(path);
|
||||
|
||||
on_show_rc_menu();
|
||||
get_widget<Gtk::Menu>("o_rc_menu")->popup(button->button, button->time);
|
||||
lib :: get_widget<Gtk::Menu>("o_rc_menu")->popup(button->button, button->time);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -437,12 +437,12 @@ static void on_switch_page(Gtk::Widget *page, int num)
|
|||
tab->tab_runtime_changed();
|
||||
tab->tab_display_sorting();
|
||||
} else
|
||||
get_widget<Gtk::Label>("o_queue_time")->set_text("");
|
||||
lib :: get_widget<Gtk::Label>("o_queue_time")->set_text("");
|
||||
}
|
||||
|
||||
void tab_focus_search()
|
||||
{
|
||||
int page = get_widget<Gtk::Notebook>("o_notebook")->get_current_page();
|
||||
int page = lib :: get_widget<Gtk::Notebook>("o_notebook")->get_current_page();
|
||||
Tab *tab = find_tab(page);
|
||||
if (tab)
|
||||
tab->tab_focus_search();
|
||||
|
@ -479,7 +479,7 @@ static void on_add_to_queue(unsigned int n)
|
|||
static void init_menu_item(const std::string &pq, unsigned int n)
|
||||
|
||||
{
|
||||
get_widget<Gtk::MenuItem>(pq)->signal_activate().connect(
|
||||
lib :: get_widget<Gtk::MenuItem>(pq)->signal_activate().connect(
|
||||
sigc::bind<unsigned int> (sigc::ptr_fun(on_add_to_queue), n));
|
||||
}
|
||||
|
||||
|
@ -491,16 +491,16 @@ void init_tabs()
|
|||
cb->on_queue_track_changed = on_track_changed;
|
||||
|
||||
/* Notebook signals */
|
||||
struct Gtk::Notebook *notebook = get_widget<Gtk::Notebook>("o_notebook");
|
||||
struct Gtk::Notebook *notebook = lib :: get_widget<Gtk::Notebook>("o_notebook");
|
||||
notebook->signal_switch_page().connect(sigc::ptr_fun(on_switch_page));
|
||||
|
||||
/* Menu signals */
|
||||
get_widget<Gtk::Menu>("o_rc_menu")->show_all();
|
||||
get_widget<Gtk::MenuItem>("o_new_pq")->signal_activate().connect(
|
||||
lib :: get_widget<Gtk::Menu>("o_rc_menu")->show_all();
|
||||
lib :: get_widget<Gtk::MenuItem>("o_new_pq")->signal_activate().connect(
|
||||
sigc::ptr_fun(on_new_pq));
|
||||
get_widget<Gtk::MenuItem>("o_add_to_favorites")->signal_activate().connect(
|
||||
lib :: get_widget<Gtk::MenuItem>("o_add_to_favorites")->signal_activate().connect(
|
||||
sigc::ptr_fun(on_add_to_favs));
|
||||
get_widget<Gtk::MenuItem>("o_add_to_banned")->signal_activate().connect(
|
||||
lib :: get_widget<Gtk::MenuItem>("o_add_to_banned")->signal_activate().connect(
|
||||
sigc::ptr_fun(on_add_to_banned));
|
||||
for (unsigned int i = 0; i < 10; i++) {
|
||||
std::string pq = "o_pq_";
|
||||
|
@ -528,7 +528,7 @@ void post_init_tabs()
|
|||
if ((deck :: get(tab)->has_flag(Q_ENABLED)))
|
||||
break;
|
||||
}
|
||||
get_widget<Gtk::Notebook>("o_notebook")->set_current_page(tab);
|
||||
lib :: get_widget<Gtk::Notebook>("o_notebook")->set_current_page(tab);
|
||||
}
|
||||
|
||||
void cleanup_tabs()
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#define OCARINA_H
|
||||
|
||||
#include <core/queue.h>
|
||||
#include <gtkmm.h>
|
||||
#include <lib/lib.h>
|
||||
|
||||
|
||||
/* collection_mgr.cpp */
|
||||
|
@ -61,21 +61,6 @@ public:
|
|||
void enable_idle();
|
||||
void connect_button(const std::string &, void (*func)());
|
||||
Gtk::Window *setup_gui();
|
||||
Glib::RefPtr<Gtk::Builder> &get_builder();
|
||||
|
||||
template <class T>
|
||||
static T *get_widget(const std::string &name)
|
||||
{
|
||||
T *widget;
|
||||
get_builder()->get_widget(name, widget);
|
||||
return widget;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static Glib::RefPtr<T> get_object(const std::string &name)
|
||||
{
|
||||
return Glib::RefPtr<T>::cast_static(get_builder()->get_object(name));
|
||||
}
|
||||
|
||||
void on_pq_created(Queue *, unsigned int);
|
||||
void post_init_queue_tabs();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#ifndef OCARINA_TABS_H
|
||||
#define OCARINA_TABS_H
|
||||
|
||||
#include <lib/lib.h>
|
||||
#include <gui/ocarina.h>
|
||||
#include <core/queue.h>
|
||||
#include <set>
|
||||
|
|
|
@ -1,12 +1,33 @@
|
|||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef OCARINA_LIB_LIB_H
|
||||
#define OCARINA_LIB_LIB_H
|
||||
|
||||
#include <string>
|
||||
#include <gtkmm.h>
|
||||
|
||||
namespace lib
|
||||
{
|
||||
|
||||
void init(int *, char ***);
|
||||
void init(int *, char ***, const std::string &);
|
||||
const std::string share_file(const std::string &);
|
||||
Glib::RefPtr<Gtk::Builder> &get_builder();
|
||||
|
||||
template <class T>
|
||||
static inline T *get_widget(const std::string &name)
|
||||
{
|
||||
T *widget;
|
||||
get_builder()->get_widget(name, widget);
|
||||
return widget;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static inline Glib::RefPtr<T> get_object(const std::string &name)
|
||||
{
|
||||
return Glib::RefPtr<T>::cast_static(get_builder()->get_object(name));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* OCARINA_LIB_LIB_H */
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
Import("env")
|
||||
env.UsePackage("gtkmm-3.0")
|
||||
res = Glob("*.cpp")
|
||||
Return("res")
|
||||
|
|
13
lib/lib.cpp
13
lib/lib.cpp
|
@ -8,7 +8,9 @@
|
|||
#include <core/print.h>
|
||||
#include <core/tags.h>
|
||||
#include <lib/lib.h>
|
||||
#include <gtkmm.h>
|
||||
|
||||
static Glib::RefPtr<Gtk::Builder> builder;
|
||||
static std::string share_dir = "";
|
||||
|
||||
static void setup_share(const std::string &path)
|
||||
|
@ -19,10 +21,14 @@ static void setup_share(const std::string &path)
|
|||
share_dir = "./share/ocarina/";
|
||||
}
|
||||
|
||||
void lib :: init(int *argc, char ***argv)
|
||||
void lib :: init(int *argc, char ***argv, const std::string >k_xml)
|
||||
{
|
||||
setup_share((*argv)[0]);
|
||||
|
||||
builder = Gtk::Builder::create();
|
||||
if (!builder->add_from_file(lib :: share_file(gtk_xml)))
|
||||
exit(1);
|
||||
|
||||
tagdb :: init();
|
||||
library :: init();
|
||||
playlist :: init();
|
||||
|
@ -34,3 +40,8 @@ const std::string lib :: share_file(const std::string &f)
|
|||
{
|
||||
return share_dir + f;
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gtk::Builder> &lib :: get_builder()
|
||||
{
|
||||
return builder;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class OTest:
|
|||
cmd = "%s | tee %s.out" % (path, path)
|
||||
if test_env.Valgrind == True:
|
||||
cmd = "%s %s" % (valgrind, cmd)
|
||||
test = Command("%s.out" % self.Name, [], "set -x pipefail; %s" % cmd)
|
||||
test = test_env.Command("%s.out" % self.Name, [], "set -x pipefail; %s" % cmd)
|
||||
|
||||
Depends(test, prog)
|
||||
if (check_depends == True) and (OTest.Prev != None):
|
||||
|
|
|
@ -12,8 +12,8 @@ for f in Glob("../../core/*.cpp"):
|
|||
class LibTest(OTest):
|
||||
Objs = core
|
||||
|
||||
def __init__(self, src):
|
||||
OTest.__init__(self, src)
|
||||
def __init__(self, src, pkg = None):
|
||||
OTest.__init__(self, src, pkg = pkg)
|
||||
|
||||
def get_program(self):
|
||||
path = "../../lib/%s" % self.Src
|
||||
|
@ -23,7 +23,7 @@ class LibTest(OTest):
|
|||
|
||||
res = TestList("lib", [
|
||||
|
||||
LibTest("lib.cpp"),
|
||||
LibTest("lib.cpp", "gtkmm-3.0"),
|
||||
|
||||
]).prepare()
|
||||
|
||||
|
|
|
@ -4,20 +4,27 @@
|
|||
#include <core/deck.h>
|
||||
#include <lib/lib.h>
|
||||
#include <tests/test.h>
|
||||
#include <gtkmm.h>
|
||||
|
||||
static void test_init(int argc, char **argv)
|
||||
static void test_init(int *argc, char ***argv)
|
||||
{
|
||||
Gtk::Window *window;
|
||||
|
||||
test_equal(deck :: get_queues().size(), (size_t)0);
|
||||
|
||||
test :: cp_data_dir();
|
||||
lib :: init(&argc, &argv);
|
||||
lib :: init(argc, argv, "ocarina6.glade");
|
||||
|
||||
test_equal(deck :: get_queues().size(), (size_t)2);
|
||||
test_equal(lib :: share_file("saria"), (std::string)"./share/ocarina/saria");
|
||||
|
||||
window = lib :: get_widget<Gtk::Window>("o_window");
|
||||
test_not_equal(window, (Gtk::Window *)NULL);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
run_test("Lib Test", test_init, argc, argv);
|
||||
Gtk::Main ocarina(&argc, &argv);
|
||||
run_test("Lib Test", test_init, &argc, &argv);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue