gui: Begin yet another tab framework
This one is based on inheritance, and I think it will be the best way to create several tab types that do things just slightly differently. Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
e3612b6e38
commit
4ce08ef22e
|
@ -2,105 +2,43 @@
|
||||||
* Copyright 2014 (c) Anna Schumaker.
|
* Copyright 2014 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
#include <deck.h>
|
#include <deck.h>
|
||||||
#include <ocarina.h>
|
|
||||||
#include <tabs.h>
|
#include <tabs.h>
|
||||||
|
|
||||||
static Glib::RefPtr<PlayqueueModel> model;
|
|
||||||
|
|
||||||
|
class CollectionTab : public Tab {
|
||||||
/*
|
public:
|
||||||
* Basic helper functions
|
CollectionTab();
|
||||||
*/
|
~CollectionTab();
|
||||||
static inline Playqueue *library_pq()
|
void on_post_init();
|
||||||
{
|
|
||||||
return deck::get_library_pq();
|
|
||||||
}
|
|
||||||
|
|
||||||
static Gtk::ToggleButton *get_random_button()
|
|
||||||
{
|
|
||||||
return get_widget<Gtk::ToggleButton>("o_collection_random");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void set_queue_size()
|
|
||||||
{
|
|
||||||
Gtk::Label *label = get_widget<Gtk::Label>("o_collection_size");
|
|
||||||
label->set_text(itoa(library_pq()->size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Gtk signal functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void on_random_toggled()
|
|
||||||
{
|
|
||||||
if (get_random_button()->get_active())
|
|
||||||
library_pq()->set_flag(PQ_RANDOM);
|
|
||||||
else
|
|
||||||
library_pq()->unset_flag(PQ_RANDOM);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Functions exposed through a TabFuncs structure
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void collection_init_late()
|
|
||||||
{
|
|
||||||
set_queue_size();
|
|
||||||
get_random_button()->set_active(library_pq()->get_flags() & PQ_RANDOM);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void collection_cleanup() {}
|
|
||||||
|
|
||||||
static bool collection_has_queue(Playqueue *pq)
|
|
||||||
{
|
|
||||||
return pq == library_pq();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void collection_track_added(Playqueue *pq, unsigned int row)
|
|
||||||
{
|
|
||||||
model->on_row_inserted(row);
|
|
||||||
set_queue_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void collection_track_deleted(Playqueue *pq, unsigned int row)
|
|
||||||
{
|
|
||||||
model->on_row_deleted(row);
|
|
||||||
set_queue_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static struct TabType collection_funcs = {
|
|
||||||
.init_late = collection_init_late,
|
|
||||||
.cleanup = collection_cleanup,
|
|
||||||
|
|
||||||
.has_queue = collection_has_queue,
|
|
||||||
.track_added = collection_track_added,
|
|
||||||
.track_deleted = collection_track_deleted,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct FilterDesc filter_desc;
|
|
||||||
|
CollectionTab :: CollectionTab()
|
||||||
|
: Tab(deck::get_library_pq())
|
||||||
|
{
|
||||||
|
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_finish_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
CollectionTab :: ~CollectionTab()
|
||||||
|
{
|
||||||
|
tab_unmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CollectionTab :: on_post_init()
|
||||||
|
{
|
||||||
|
tab_init_random();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
static CollectionTab *collection_tab;
|
||||||
* Basic tab setup
|
|
||||||
*/
|
|
||||||
|
|
||||||
void init_collection_tab()
|
void init_collection_tab()
|
||||||
{
|
{
|
||||||
model = Glib::RefPtr<PlayqueueModel>(new PlayqueueModel(library_pq()));
|
collection_tab = new CollectionTab;
|
||||||
|
|
||||||
filter_desc.model = model;
|
|
||||||
filter_desc.entry = get_widget<Gtk::SearchEntry>("o_collection_entry");
|
|
||||||
init_filter(&filter_desc);
|
|
||||||
|
|
||||||
get_widget<Gtk::TreeView>("o_collection_pq_treeview")->set_model(filter_desc.filter);
|
|
||||||
|
|
||||||
get_random_button()->signal_toggled().connect(sigc::ptr_fun(on_random_toggled));
|
|
||||||
|
|
||||||
register_tab_type(&collection_funcs);
|
|
||||||
}
|
}
|
||||||
|
|
100
gui/history.cpp
100
gui/history.cpp
|
@ -2,94 +2,36 @@
|
||||||
* Copyright 2014 (c) Anna Schumaker.
|
* Copyright 2014 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
#include <audio.h>
|
#include <audio.h>
|
||||||
#include <filter.h>
|
|
||||||
#include <ocarina.h>
|
|
||||||
#include <tabs.h>
|
#include <tabs.h>
|
||||||
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
static std::set<unsigned int> visible_ids;
|
class HistoryTab : public Tab {
|
||||||
static Glib::RefPtr<Gtk::TreeModelFilter> history_filter;
|
public:
|
||||||
static Glib::RefPtr<PlayqueueModel> model;
|
HistoryTab();
|
||||||
|
~HistoryTab();
|
||||||
|
|
||||||
/*
|
|
||||||
* Basic helper functions
|
|
||||||
*/
|
|
||||||
static inline Playqueue *history_pq()
|
|
||||||
{
|
|
||||||
return audio::get_recent_pq();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void set_queue_size()
|
|
||||||
{
|
|
||||||
Gtk::Label *label = get_widget<Gtk::Label>("o_history_size");
|
|
||||||
label->set_text(itoa(history_pq()->size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Gtk signal functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Functions exposed through a TabFuncs structure
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void history_init_late()
|
|
||||||
{
|
|
||||||
set_queue_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void history_cleanup() {}
|
|
||||||
|
|
||||||
static bool history_has_queue(Playqueue *pq)
|
|
||||||
{
|
|
||||||
return pq == history_pq();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void history_track_added(Playqueue *pq, unsigned int row)
|
|
||||||
{
|
|
||||||
model->on_row_inserted(row);
|
|
||||||
set_queue_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void history_track_deleted(Playqueue *pq, unsigned int row)
|
|
||||||
{
|
|
||||||
model->on_row_deleted(row);
|
|
||||||
set_queue_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static struct TabType history_funcs = {
|
|
||||||
.init_late = history_init_late,
|
|
||||||
.cleanup = history_cleanup,
|
|
||||||
|
|
||||||
.has_queue = history_has_queue,
|
|
||||||
.track_added = history_track_added,
|
|
||||||
.track_deleted = history_track_deleted,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct FilterDesc filter_desc;
|
|
||||||
|
HistoryTab :: HistoryTab()
|
||||||
|
: Tab(audio::get_recent_pq())
|
||||||
|
{
|
||||||
|
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_finish_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryTab :: ~HistoryTab()
|
||||||
|
{
|
||||||
|
tab_unmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
static HistoryTab *history_tab;
|
||||||
* Basic tab setup
|
|
||||||
*/
|
|
||||||
|
|
||||||
void init_history_tab()
|
void init_history_tab()
|
||||||
{
|
{
|
||||||
model = Glib::RefPtr<PlayqueueModel>(new PlayqueueModel(history_pq()));
|
history_tab = new HistoryTab;
|
||||||
|
|
||||||
filter_desc.model = model;
|
|
||||||
filter_desc.entry = get_widget<Gtk::SearchEntry>("o_history_entry");
|
|
||||||
init_filter(&filter_desc);
|
|
||||||
|
|
||||||
get_widget<Gtk::TreeView>("o_history_treeview")->set_model(filter_desc.filter);
|
|
||||||
|
|
||||||
register_tab_type(&history_funcs);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <deck.h>
|
#include <deck.h>
|
||||||
#include <ocarina.h>
|
#include <ocarina.h>
|
||||||
#include <playlist.h>
|
#include <playlist.h>
|
||||||
|
#include <tabs.h>
|
||||||
|
|
||||||
Gtk::Window *ocarina_init(int *argc, char ***argv)
|
Gtk::Window *ocarina_init(int *argc, char ***argv)
|
||||||
{
|
{
|
||||||
|
@ -14,7 +15,7 @@ Gtk::Window *ocarina_init(int *argc, char ***argv)
|
||||||
library::init();
|
library::init();
|
||||||
playlist::init();
|
playlist::init();
|
||||||
|
|
||||||
init_tabs2();
|
post_init_tabs();
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -731,7 +731,7 @@
|
||||||
<property name="margin_right">1</property>
|
<property name="margin_right">1</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSearchEntry" id="searchentry3">
|
<object class="GtkSearchEntry" id="o_playlist_entry">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="margin_left">5</property>
|
<property name="margin_left">5</property>
|
||||||
|
|
121
gui/playlist.cpp
121
gui/playlist.cpp
|
@ -2,10 +2,39 @@
|
||||||
* Copyright 2014 (c) Anna Schumaker.
|
* Copyright 2014 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
#include <playlist.h>
|
#include <playlist.h>
|
||||||
#include <ocarina.h>
|
|
||||||
#include <tabs.h>
|
#include <tabs.h>
|
||||||
|
|
||||||
static Glib::RefPtr<PlayqueueModel> model;
|
|
||||||
|
/**
|
||||||
|
* Playlist tab stuff
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PlaylistTab : public Tab {
|
||||||
|
public:
|
||||||
|
PlaylistTab();
|
||||||
|
~PlaylistTab();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
PlaylistTab :: PlaylistTab()
|
||||||
|
: Tab(playlist :: get_pq())
|
||||||
|
{
|
||||||
|
tab_search = get_widget<Gtk::SearchEntry>("o_playlist_entry");
|
||||||
|
tab_treeview = get_widget<Gtk::TreeView>("o_playlist_pq_treeview");
|
||||||
|
|
||||||
|
tab_finish_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
PlaylistTab :: ~PlaylistTab()
|
||||||
|
{
|
||||||
|
tab_unmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Playlist "sidebar" stuff
|
||||||
|
*/
|
||||||
|
|
||||||
static class PlaylistColumns : public Gtk::TreeModelColumnRecord {
|
static class PlaylistColumns : public Gtk::TreeModelColumnRecord {
|
||||||
public:
|
public:
|
||||||
|
@ -15,42 +44,19 @@ public:
|
||||||
Gtk::TreeModelColumn<std::string> plist_col_name;
|
Gtk::TreeModelColumn<std::string> plist_col_name;
|
||||||
} plist_cols;
|
} plist_cols;
|
||||||
|
|
||||||
|
static Glib::RefPtr<Gtk::ListStore> playlist_ls;
|
||||||
|
static Gtk::TreeView *playlist_tv;
|
||||||
|
|
||||||
/*
|
|
||||||
* Basic helper functions
|
|
||||||
*/
|
|
||||||
static inline Playqueue *playlist_pq()
|
|
||||||
{
|
|
||||||
return playlist::get_pq();
|
|
||||||
}
|
|
||||||
|
|
||||||
static Gtk::TreeView *get_playlist_treeview()
|
|
||||||
{
|
|
||||||
return get_widget<Gtk::TreeView>("o_playlist_treeview");
|
|
||||||
}
|
|
||||||
|
|
||||||
static Glib::RefPtr<Gtk::ListStore> get_playlists()
|
|
||||||
{
|
|
||||||
return get_object<Gtk::ListStore>("o_playlists");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Gtk signal functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void on_playlist_cursor_changed()
|
static void on_playlist_cursor_changed()
|
||||||
{
|
{
|
||||||
Gtk::TreePath path;
|
Gtk::TreePath path;
|
||||||
Gtk::TreeViewColumn *col;
|
Gtk::TreeViewColumn *col;
|
||||||
Gtk::TreeModel::Row row;
|
playlist_tv->get_cursor(path, col);
|
||||||
|
|
||||||
get_playlist_treeview()->get_cursor(path, col);
|
Gtk::TreeModel::Row row = *(playlist_ls->get_iter(path));
|
||||||
row = *(get_playlists()->get_iter(path));
|
std::string res = row[plist_cols.plist_col_name];
|
||||||
|
playlist::select(res);
|
||||||
print("%s\n", row[plist_cols.plist_col_name]);
|
|
||||||
//playlist::select(row[plist_cols.plist_col_name]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool on_playlist_clicked(GdkEventButton *button)
|
static bool on_playlist_clicked(GdkEventButton *button)
|
||||||
|
@ -62,54 +68,15 @@ static bool on_playlist_clicked(GdkEventButton *button)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
static PlaylistTab *playlist_tab;
|
||||||
* Functions exposed through a TabFuncs structure
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void playlist_init_late() {}
|
|
||||||
static void playlist_cleanup() {}
|
|
||||||
|
|
||||||
static bool playlist_has_queue(Playqueue *pq)
|
|
||||||
{
|
|
||||||
return pq == playlist_pq();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void playlist_track_added(Playqueue *pq, unsigned int row)
|
|
||||||
{
|
|
||||||
model->on_row_inserted(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void playlist_track_deleted(Playqueue *pq, unsigned int row)
|
|
||||||
{
|
|
||||||
model->on_row_deleted(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static struct TabType playlist_funcs = {
|
|
||||||
.init_late = playlist_init_late,
|
|
||||||
.cleanup = playlist_cleanup,
|
|
||||||
|
|
||||||
.has_queue = playlist_has_queue,
|
|
||||||
.track_added = playlist_track_added,
|
|
||||||
.track_deleted = playlist_track_deleted,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Basic tab setup
|
|
||||||
*/
|
|
||||||
|
|
||||||
void init_playlist_tab()
|
void init_playlist_tab()
|
||||||
{
|
{
|
||||||
Gtk::TreeView *playlist = get_playlist_treeview();
|
playlist_tab = new PlaylistTab;
|
||||||
|
playlist_ls = get_object<Gtk::ListStore>("o_playlists");
|
||||||
|
playlist_tv = get_widget<Gtk::TreeView>("o_playlist_treeview");
|
||||||
|
|
||||||
model = Glib::RefPtr<PlayqueueModel>(new PlayqueueModel(playlist_pq()));
|
playlist_tv->signal_cursor_changed().connect(sigc::ptr_fun(on_playlist_cursor_changed));
|
||||||
get_widget<Gtk::TreeView>("o_playlist_pq_treeview")->set_model(model);
|
playlist_tv->signal_button_press_event().connect(sigc::ptr_fun(on_playlist_clicked));
|
||||||
|
playlist_tv->set_cursor(Gtk::TreePath("0"));
|
||||||
playlist->signal_cursor_changed().connect(sigc::ptr_fun(on_playlist_cursor_changed));
|
|
||||||
playlist->signal_button_press_event().connect(sigc::ptr_fun(on_playlist_clicked));
|
|
||||||
playlist->set_cursor(Gtk::TreePath("0"));
|
|
||||||
|
|
||||||
register_tab_type(&playlist_funcs);
|
|
||||||
}
|
}
|
||||||
|
|
351
gui/tabs.cpp
351
gui/tabs.cpp
|
@ -1,27 +1,197 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2014 (c) Anna Schumaker.
|
* Copyright 2014 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
#include <audio.h>
|
|
||||||
#include <callback.h>
|
#include <callback.h>
|
||||||
#include <deck.h>
|
|
||||||
#include <filter.h>
|
#include <filter.h>
|
||||||
#include <ocarina.h>
|
|
||||||
#include <playlist.h>
|
|
||||||
#include <playqueue.h>
|
|
||||||
#include <tabs.h>
|
#include <tabs.h>
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
|
static std::map<Playqueue *, Tab *> queue_mapping;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tab class basics
|
||||||
|
*/
|
||||||
|
|
||||||
|
Tab :: Tab(Playqueue *pq)
|
||||||
|
: tab_pq(pq), tab_size(NULL)
|
||||||
|
{
|
||||||
|
tab_model = Glib::RefPtr<PlayqueueModel>(new PlayqueueModel(tab_pq));
|
||||||
|
queue_mapping[tab_pq] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tab :: ~Tab() {}
|
||||||
|
|
||||||
|
void Tab :: tab_finish_init()
|
||||||
|
{
|
||||||
|
tab_filter = Gtk::TreeModelFilter::create(tab_model);
|
||||||
|
tab_filter->set_visible_func(sigc::mem_fun(*this,
|
||||||
|
&Tab::on_filter_visible));
|
||||||
|
tab_search->signal_key_release_event().connect(sigc::mem_fun(*this,
|
||||||
|
&Tab::on_entry_key_released));
|
||||||
|
tab_search->signal_changed().connect(sigc::mem_fun(*this,
|
||||||
|
&Tab::on_entry_changed));
|
||||||
|
|
||||||
|
tab_treeview->set_model(tab_filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tab class helper functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
void Tab :: tab_init_random()
|
||||||
|
{
|
||||||
|
tab_random->set_active(tab_pq->get_flags() & PQ_RANDOM);
|
||||||
|
tab_random->signal_toggled().connect(sigc::mem_fun(*this,
|
||||||
|
&Tab::on_random_toggled));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tab :: tab_set_size()
|
||||||
|
{
|
||||||
|
if (tab_size) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << tab_pq->size();
|
||||||
|
tab_size->set_text(ss.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tab :: tab_unmap()
|
||||||
|
{
|
||||||
|
queue_mapping.erase(tab_pq);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tab internal callback functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
void Tab :: on_post_init() {}
|
||||||
|
|
||||||
|
void Tab :: on_track_added(unsigned int row)
|
||||||
|
{
|
||||||
|
tab_model->on_row_inserted(row);
|
||||||
|
tab_set_size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tab :: on_track_deleted(unsigned int row)
|
||||||
|
{
|
||||||
|
tab_model->on_row_deleted(row);
|
||||||
|
tab_set_size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GTK-MM callback functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
void Tab :: on_random_toggled()
|
||||||
|
{
|
||||||
|
if (tab_random->get_active())
|
||||||
|
tab_pq->set_flag(PQ_RANDOM);
|
||||||
|
else
|
||||||
|
tab_pq->unset_flag(PQ_RANDOM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tab filtering functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool Tab :: on_filter_visible(const Gtk::TreeIter &iter)
|
||||||
|
{
|
||||||
|
unsigned int pq_id;
|
||||||
|
std::set<unsigned int>::iterator it;
|
||||||
|
|
||||||
|
if (tab_search->get_text_length() == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
pq_id = tab_model->iter_to_id(iter);
|
||||||
|
it = visible_ids.find(tab_pq->operator[](pq_id));
|
||||||
|
return it != visible_ids.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Tab :: on_entry_key_released(GdkEventKey *event)
|
||||||
|
{
|
||||||
|
std::string key = gdk_keyval_name(event->keyval);
|
||||||
|
return key == "space";
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tab :: on_entry_changed()
|
||||||
|
{
|
||||||
|
filter :: search(tab_search->get_text(), visible_ids);
|
||||||
|
tab_filter->refilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
Tab *find_tab(Playqueue *pq)
|
||||||
|
{
|
||||||
|
std::map<Playqueue *, Tab *>::iterator it;
|
||||||
|
it = queue_mapping.find(pq);
|
||||||
|
if (it != queue_mapping.end())
|
||||||
|
return it->second;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_track_added(Playqueue *pq, unsigned int row)
|
||||||
|
{
|
||||||
|
Tab *tab = find_tab(pq);
|
||||||
|
if (tab)
|
||||||
|
tab->on_track_added(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_track_deleted(Playqueue *pq, unsigned int row)
|
||||||
|
{
|
||||||
|
Tab *tab = find_tab(pq);
|
||||||
|
if (tab)
|
||||||
|
tab->on_track_deleted(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_tabs()
|
||||||
|
{
|
||||||
|
struct Callbacks *cb = get_callbacks();
|
||||||
|
|
||||||
|
cb->on_queue_track_add = on_track_added;
|
||||||
|
cb->on_queue_track_del = on_track_deleted;
|
||||||
|
|
||||||
|
/* Initialize other tabs */
|
||||||
|
init_collection_tab();
|
||||||
|
init_history_tab();
|
||||||
|
init_playlist_tab();
|
||||||
|
}
|
||||||
|
|
||||||
|
void post_init_tabs()
|
||||||
|
{
|
||||||
|
std::map<Playqueue *, Tab *>::iterator it;
|
||||||
|
for (it = queue_mapping.begin(); it != queue_mapping.end(); it++)
|
||||||
|
it->second->on_post_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cleanup_tabs()
|
||||||
|
{
|
||||||
|
while (queue_mapping.size() > 0)
|
||||||
|
delete queue_mapping.begin()->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic tab functions for filtering
|
* Generic tab functions for filtering
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static bool on_entry_key_released(GdkEventKey *event)
|
/*static bool on_entry_key_released(GdkEventKey *event)
|
||||||
{
|
{
|
||||||
std::string key = gdk_keyval_name(event->keyval);
|
std::string key = gdk_keyval_name(event->keyval);
|
||||||
return key == "space";
|
return key == "space";
|
||||||
|
@ -60,12 +230,12 @@ void init_filter(struct FilterDesc *filter)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
* Mostly legacy code ....
|
* Mostly legacy code ....
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class OcarinaPage;
|
/*class OcarinaPage;
|
||||||
static std::map<Playqueue *, OcarinaPage *> tab_map;
|
static std::map<Playqueue *, OcarinaPage *> tab_map;
|
||||||
static std::list<TabType *> tab_types;
|
static std::list<TabType *> tab_types;
|
||||||
static unsigned int sort_timeout_count = 0;
|
static unsigned int sort_timeout_count = 0;
|
||||||
|
@ -118,9 +288,9 @@ static Gtk::Widget *get_menu_widget(const std::string &name)
|
||||||
static void prepare_rc_menu()
|
static void prepare_rc_menu()
|
||||||
{
|
{
|
||||||
unsigned int size = deck::size();
|
unsigned int size = deck::size();
|
||||||
|
*/
|
||||||
/* Set widgets visible */
|
/* Set widgets visible */
|
||||||
switch (size) {
|
/* switch (size) {
|
||||||
case 10:
|
case 10:
|
||||||
get_menu_widget("o_pq_9")->show();
|
get_menu_widget("o_pq_9")->show();
|
||||||
case 9:
|
case 9:
|
||||||
|
@ -147,9 +317,9 @@ static void prepare_rc_menu()
|
||||||
get_menu_widget("o_new_pq")->show();
|
get_menu_widget("o_new_pq")->show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/* Set widgets invisible */
|
/* Set widgets invisible */
|
||||||
switch (size) {
|
/* switch (size) {
|
||||||
case 0:
|
case 0:
|
||||||
get_menu_widget("o_add_to_pq")->hide();
|
get_menu_widget("o_add_to_pq")->hide();
|
||||||
get_menu_widget("o_pq_0")->hide();
|
get_menu_widget("o_pq_0")->hide();
|
||||||
|
@ -177,12 +347,12 @@ static void prepare_rc_menu()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tab class definition
|
* Tab class definition
|
||||||
*/
|
*/
|
||||||
class OcarinaTab : public Gtk::HBox {
|
/*class OcarinaTab : public Gtk::HBox {
|
||||||
public:
|
public:
|
||||||
OcarinaTab();
|
OcarinaTab();
|
||||||
~OcarinaTab();
|
~OcarinaTab();
|
||||||
|
@ -235,23 +405,23 @@ void PQTab::set_number(unsigned int num)
|
||||||
ss << "<span size='x-large'>" << num << ". </span>";
|
ss << "<span size='x-large'>" << num << ". </span>";
|
||||||
number_label.set_markup(ss.str());
|
number_label.set_markup(ss.str());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ocarina class definition
|
* Ocarina class definition
|
||||||
*/
|
*/
|
||||||
class OcarinaPage : public Gtk::VBox {
|
/*class OcarinaPage : public Gtk::VBox {
|
||||||
private:
|
private:
|
||||||
unsigned int init_flags;
|
unsigned int init_flags;
|
||||||
Gtk::Notebook *notebook;
|
Gtk::Notebook *notebook;
|
||||||
OcarinaTab *tab;
|
OcarinaTab *tab;
|
||||||
|
*/
|
||||||
/* Filter state */
|
/* Filter state */
|
||||||
std::set<unsigned int> visible_ids;
|
// std::set<unsigned int> visible_ids;
|
||||||
|
|
||||||
/* Page widgets */
|
/* Page widgets */
|
||||||
Gtk::HBox page_toolbar;
|
/* Gtk::HBox page_toolbar;
|
||||||
Gtk::SearchEntry page_entry;
|
Gtk::SearchEntry page_entry;
|
||||||
Gtk::ToggleButton page_repeat;
|
Gtk::ToggleButton page_repeat;
|
||||||
Gtk::ScrolledWindow page_scroll;
|
Gtk::ScrolledWindow page_scroll;
|
||||||
|
@ -330,9 +500,9 @@ void OcarinaPage::setup_common(Playqueue *pq, unsigned int pg)
|
||||||
setup_treeview();
|
setup_treeview();
|
||||||
pack_start(page_viewbox);
|
pack_start(page_viewbox);
|
||||||
show_all();
|
show_all();
|
||||||
|
*/
|
||||||
/* Add to notebook */
|
/* Add to notebook */
|
||||||
notebook->insert_page(*this, *tab, pg);
|
/* notebook->insert_page(*this, *tab, pg);
|
||||||
tab_map[pq] = this;
|
tab_map[pq] = this;
|
||||||
set_tab_size();
|
set_tab_size();
|
||||||
}
|
}
|
||||||
|
@ -343,17 +513,17 @@ void OcarinaPage::setup_toolbar()
|
||||||
page_toolbar.pack_start(page_entry);
|
page_toolbar.pack_start(page_entry);
|
||||||
page_toolbar.set_margin_left(5);
|
page_toolbar.set_margin_left(5);
|
||||||
page_toolbar.set_margin_right(5);
|
page_toolbar.set_margin_right(5);
|
||||||
|
*/
|
||||||
/* Set up entry */
|
/* Set up entry */
|
||||||
page_entry.set_margin_top(5);
|
/* page_entry.set_margin_top(5);
|
||||||
page_entry.set_margin_bottom(5);
|
page_entry.set_margin_bottom(5);
|
||||||
page_entry.signal_changed().connect(sigc::mem_fun(*this,
|
page_entry.signal_changed().connect(sigc::mem_fun(*this,
|
||||||
&OcarinaPage::on_entry_changed));
|
&OcarinaPage::on_entry_changed));
|
||||||
page_entry.signal_key_release_event().connect(sigc::mem_fun(*this,
|
page_entry.signal_key_release_event().connect(sigc::mem_fun(*this,
|
||||||
&OcarinaPage::on_entry_key_released));
|
&OcarinaPage::on_entry_key_released));
|
||||||
|
*/
|
||||||
/* Make buttons */
|
/* Make buttons */
|
||||||
if (init_flags & PQ_RANDOM) {
|
/* if (init_flags & PQ_RANDOM) {
|
||||||
page_random.set_image_from_icon_name("media-playlist-shuffle");
|
page_random.set_image_from_icon_name("media-playlist-shuffle");
|
||||||
page_toolbar.pack_start(page_random, false, false);
|
page_toolbar.pack_start(page_random, false, false);
|
||||||
}
|
}
|
||||||
|
@ -366,9 +536,9 @@ void OcarinaPage::setup_toolbar()
|
||||||
}
|
}
|
||||||
|
|
||||||
void OcarinaPage::setup_treeview()
|
void OcarinaPage::setup_treeview()
|
||||||
{
|
{*/
|
||||||
/* Make page content */
|
/* Make page content */
|
||||||
page_view.append_column("#", queue_cols.q_col_track);
|
/*page_view.append_column("#", queue_cols.q_col_track);
|
||||||
page_view.append_column("Title", queue_cols.q_col_title);
|
page_view.append_column("Title", queue_cols.q_col_title);
|
||||||
page_view.append_column("Length", queue_cols.q_col_length);
|
page_view.append_column("Length", queue_cols.q_col_length);
|
||||||
page_view.append_column("Artist", queue_cols.q_col_artist);
|
page_view.append_column("Artist", queue_cols.q_col_artist);
|
||||||
|
@ -423,11 +593,6 @@ bool OcarinaPage::is_current_tab()
|
||||||
|
|
||||||
void OcarinaPage::check_pq_flags()
|
void OcarinaPage::check_pq_flags()
|
||||||
{
|
{
|
||||||
if (init_flags & PQ_RANDOM) {
|
|
||||||
page_random.set_active(model->queue->get_flags() & PQ_RANDOM);
|
|
||||||
page_random.signal_toggled().connect(sigc::mem_fun(*this,
|
|
||||||
&OcarinaPage::on_random_toggled));
|
|
||||||
}
|
|
||||||
if (init_flags & PQ_REPEAT) {
|
if (init_flags & PQ_REPEAT) {
|
||||||
page_repeat.set_active(model->queue->get_flags() & PQ_REPEAT);
|
page_repeat.set_active(model->queue->get_flags() & PQ_REPEAT);
|
||||||
page_repeat.signal_toggled().connect(sigc::mem_fun(*this,
|
page_repeat.signal_toggled().connect(sigc::mem_fun(*this,
|
||||||
|
@ -435,11 +600,6 @@ void OcarinaPage::check_pq_flags()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OcarinaPage::set_tab_size()
|
|
||||||
{
|
|
||||||
tab->set_size(model->queue->size());
|
|
||||||
}
|
|
||||||
|
|
||||||
void OcarinaPage::queue_selected(bool random)
|
void OcarinaPage::queue_selected(bool random)
|
||||||
{
|
{
|
||||||
Playqueue *pq;
|
Playqueue *pq;
|
||||||
|
@ -493,14 +653,6 @@ void OcarinaPage::on_runtime_changed()
|
||||||
label->set_text(model->queue->get_length_str());
|
label->set_text(model->queue->get_length_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void OcarinaPage::on_random_toggled()
|
|
||||||
{
|
|
||||||
if (page_random.get_active())
|
|
||||||
model->queue->set_flag(PQ_RANDOM);
|
|
||||||
else
|
|
||||||
model->queue->unset_flag(PQ_RANDOM);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OcarinaPage::on_repeat_toggled()
|
void OcarinaPage::on_repeat_toggled()
|
||||||
{
|
{
|
||||||
if (page_repeat.get_active())
|
if (page_repeat.get_active())
|
||||||
|
@ -531,30 +683,6 @@ void OcarinaPage::on_column_clicked(unsigned int col_index)
|
||||||
sigc::ptr_fun(dec_sort_timeout), 2);
|
sigc::ptr_fun(dec_sort_timeout), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OcarinaPage::on_entry_changed()
|
|
||||||
{
|
|
||||||
filter :: search(page_entry.get_text(), visible_ids);
|
|
||||||
filter->refilter();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OcarinaPage::on_entry_key_released(GdkEventKey *event)
|
|
||||||
{
|
|
||||||
std::string key = gdk_keyval_name(event->keyval);
|
|
||||||
return key == "space";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OcarinaPage::on_filter_visible(const Gtk::TreeIter &iter)
|
|
||||||
{
|
|
||||||
unsigned int pq_id;
|
|
||||||
std::set<unsigned int>::iterator it;
|
|
||||||
|
|
||||||
if (page_entry.get_text().size() == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
pq_id = model->iter_to_id(iter);
|
|
||||||
return visible_ids.find(model->queue->operator[](pq_id)) != visible_ids.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OcarinaPage::on_page_renumbered()
|
void OcarinaPage::on_page_renumbered()
|
||||||
{
|
{
|
||||||
tab->set_number(notebook->page_num(*this));
|
tab->set_number(notebook->page_num(*this));
|
||||||
|
@ -647,49 +775,13 @@ void OcarinaPage::on_focus_search()
|
||||||
{
|
{
|
||||||
page_entry.grab_focus();
|
page_entry.grab_focus();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do stuff with tabs
|
* Do stuff with tabs
|
||||||
*/
|
*/
|
||||||
static TabType *find_tab_funcs(Playqueue *pq)
|
/*
|
||||||
{
|
|
||||||
std::list<TabType *>::iterator tab_it;
|
|
||||||
for (tab_it = tab_types.begin(); tab_it != tab_types.end(); tab_it++) {
|
|
||||||
if ((*tab_it)->has_queue(pq))
|
|
||||||
return *tab_it;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void on_track_added(Playqueue *pq, unsigned int row)
|
|
||||||
{
|
|
||||||
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
|
||||||
|
|
||||||
it = tab_map.find(pq);
|
|
||||||
if (it != tab_map.end())
|
|
||||||
it->second->on_row_inserted(row);
|
|
||||||
|
|
||||||
struct TabType *tab;
|
|
||||||
tab = find_tab_funcs(pq);
|
|
||||||
if (tab)
|
|
||||||
tab->track_added(pq, row);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void on_track_deleted(Playqueue *pq, unsigned int row)
|
|
||||||
{
|
|
||||||
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
|
||||||
it = tab_map.find(pq);
|
|
||||||
if (it != tab_map.end())
|
|
||||||
it->second->on_row_deleted(row);
|
|
||||||
|
|
||||||
struct TabType *tab;
|
|
||||||
tab = find_tab_funcs(pq);
|
|
||||||
if (tab)
|
|
||||||
tab->track_deleted(pq, row);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void on_track_changed(Playqueue *pq, unsigned int row)
|
static void on_track_changed(Playqueue *pq, unsigned int row)
|
||||||
{
|
{
|
||||||
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
||||||
|
@ -768,7 +860,7 @@ void queue_selected(bool random)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/*static void on_new_queue()
|
/*static void on_new_queue()
|
||||||
{
|
{
|
||||||
queue_selected(false);
|
queue_selected(false);
|
||||||
|
@ -792,7 +884,7 @@ static void init_menu_item(const std::string &name, unsigned int num)
|
||||||
sigc::ptr_fun(on_add_to_queue), num));
|
sigc::ptr_fun(on_add_to_queue), num));
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
void focus_tab_search()
|
/*void focus_tab_search()
|
||||||
{
|
{
|
||||||
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
||||||
for (it = tab_map.begin(); it != tab_map.end(); it++) {
|
for (it = tab_map.begin(); it != tab_map.end(); it++) {
|
||||||
|
@ -810,11 +902,9 @@ void init_tabs()
|
||||||
|
|
||||||
get_callbacks()->on_pq_created = on_pq_created;
|
get_callbacks()->on_pq_created = on_pq_created;
|
||||||
get_callbacks()->on_pq_removed = on_pq_removed;
|
get_callbacks()->on_pq_removed = on_pq_removed;
|
||||||
get_callbacks()->on_queue_track_add = on_track_added;
|
|
||||||
get_callbacks()->on_queue_track_del = on_track_deleted;
|
|
||||||
get_callbacks()->on_queue_track_changed = on_track_changed;
|
get_callbacks()->on_queue_track_changed = on_track_changed;
|
||||||
|
|
||||||
|
*/
|
||||||
/*Glib::RefPtr<Gtk::MenuItem> new_pq = Glib::RefPtr<Gtk::MenuItem>::cast_static(get_builder()->get_object("o_new_pq"));
|
/*Glib::RefPtr<Gtk::MenuItem> new_pq = Glib::RefPtr<Gtk::MenuItem>::cast_static(get_builder()->get_object("o_new_pq"));
|
||||||
new_pq->signal_activate().connect(sigc::ptr_fun(on_new_queue));
|
new_pq->signal_activate().connect(sigc::ptr_fun(on_new_queue));
|
||||||
|
|
||||||
|
@ -828,38 +918,11 @@ void init_tabs()
|
||||||
init_menu_item("o_pq_7", 7);
|
init_menu_item("o_pq_7", 7);
|
||||||
init_menu_item("o_pq_8", 8);
|
init_menu_item("o_pq_8", 8);
|
||||||
init_menu_item("o_pq_9", 9);*/
|
init_menu_item("o_pq_9", 9);*/
|
||||||
|
/*
|
||||||
init_collection_tab();
|
|
||||||
init_history_tab();
|
init_history_tab();
|
||||||
init_playlist_tab();
|
init_playlist_tab();
|
||||||
|
|
||||||
notebook->signal_switch_page().connect(sigc::ptr_fun(on_switch_page));
|
notebook->signal_switch_page().connect(sigc::ptr_fun(on_switch_page));
|
||||||
notebook->signal_page_reordered().connect(sigc::ptr_fun(on_page_reordered));
|
notebook->signal_page_reordered().connect(sigc::ptr_fun(on_page_reordered));
|
||||||
notebook->set_current_page(0);
|
notebook->set_current_page(0);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void register_tab_type(struct TabType *tab)
|
|
||||||
{
|
|
||||||
tab_types.push_back(tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_tabs2()
|
|
||||||
{
|
|
||||||
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
|
||||||
for (it = tab_map.begin(); it != tab_map.end(); it++)
|
|
||||||
it->second->check_pq_flags();
|
|
||||||
|
|
||||||
std::list<TabType *>::iterator tab_it;
|
|
||||||
for (tab_it = tab_types.begin(); tab_it != tab_types.end(); tab_it++)
|
|
||||||
(*tab_it)->init_late();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cleanup_tabs()
|
|
||||||
{
|
|
||||||
while (tab_map.size() > 0)
|
|
||||||
delete tab_map.begin()->second;
|
|
||||||
|
|
||||||
std::list<TabType *>::iterator it;
|
|
||||||
for (it = tab_types.begin(); it != tab_types.end(); it++)
|
|
||||||
(*it)->cleanup();
|
|
||||||
}
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <ocarina.h>
|
#include <ocarina.h>
|
||||||
#include <print.h>
|
#include <print.h>
|
||||||
|
#include <tabs.h>
|
||||||
|
|
||||||
static bool audio_playing = false;
|
static bool audio_playing = false;
|
||||||
static Glib::RefPtr<Gtk::Builder> builder;
|
static Glib::RefPtr<Gtk::Builder> builder;
|
||||||
|
@ -142,8 +143,8 @@ static bool on_window_key_pressed(GdkEventKey *event)
|
||||||
|
|
||||||
if (key == "Escape")
|
if (key == "Escape")
|
||||||
window->set_focus(*window);
|
window->set_focus(*window);
|
||||||
else if (key == "slash")
|
//else if (key == "slash")
|
||||||
focus_tab_search();
|
// focus_tab_search();
|
||||||
else if (key >= "0" && key <= "9") {
|
else if (key >= "0" && key <= "9") {
|
||||||
unsigned int n = atoi(key.c_str());
|
unsigned int n = atoi(key.c_str());
|
||||||
if (n < deck::size())
|
if (n < deck::size())
|
||||||
|
@ -160,10 +161,10 @@ static bool on_window_key_pressed(GdkEventKey *event)
|
||||||
audio :: previous();
|
audio :: previous();
|
||||||
else if (key == "p")
|
else if (key == "p")
|
||||||
notebook->set_current_page(deck::size() + 2);
|
notebook->set_current_page(deck::size() + 2);
|
||||||
else if (key == "q")
|
//else if (key == "q")
|
||||||
queue_selected(false);
|
// queue_selected(false);
|
||||||
else if (key == "s")
|
//else if (key == "s")
|
||||||
queue_selected(true);
|
// queue_selected(true);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -56,11 +56,8 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/* tabs.cpp */
|
/* tabs.cpp */
|
||||||
void queue_selected(bool);
|
//void queue_selected(bool);
|
||||||
void focus_tab_search();
|
//void focus_tab_search();
|
||||||
void init_tabs();
|
|
||||||
void init_tabs2();
|
|
||||||
void cleanup_tabs();
|
|
||||||
|
|
||||||
|
|
||||||
/* wires.cpp */
|
/* wires.cpp */
|
||||||
|
|
|
@ -4,55 +4,71 @@
|
||||||
#ifndef OCARINA_TABS_H
|
#ifndef OCARINA_TABS_H
|
||||||
#define OCARINA_TABS_H
|
#define OCARINA_TABS_H
|
||||||
|
|
||||||
#include <gtkmm.h>
|
#include <ocarina.h>
|
||||||
#include <sstream>
|
#include <playqueue.h>
|
||||||
|
|
||||||
struct FilterDesc {
|
|
||||||
/*
|
|
||||||
* Set these variables
|
|
||||||
*/
|
|
||||||
Glib::RefPtr<PlayqueueModel> model;
|
|
||||||
Gtk::SearchEntry *entry;
|
|
||||||
|
|
||||||
/*
|
class Tab {
|
||||||
* These are configured automatically
|
private:
|
||||||
*/
|
|
||||||
Glib::RefPtr<Gtk::TreeModelFilter> filter;
|
|
||||||
std::set<unsigned int> visible_ids;
|
std::set<unsigned int> visible_ids;
|
||||||
|
Glib::RefPtr<Gtk::TreeModelFilter> tab_filter;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Playqueue *tab_pq;
|
||||||
|
Glib::RefPtr<PlayqueueModel> tab_model;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Widgets that MUST be set by a child class
|
||||||
|
*/
|
||||||
|
Gtk::SearchEntry *tab_search;
|
||||||
|
Gtk::TreeView *tab_treeview;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional widgets that MAY be set
|
||||||
|
*/
|
||||||
|
Gtk::ToggleButton *tab_random;
|
||||||
|
Gtk::Label *tab_size;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class helper functions
|
||||||
|
*/
|
||||||
|
void tab_init_random();
|
||||||
|
void tab_set_size();
|
||||||
|
void tab_unmap();
|
||||||
|
|
||||||
|
public:
|
||||||
|
Tab(Playqueue *);
|
||||||
|
virtual ~Tab();
|
||||||
|
void tab_finish_init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* internal callback functions
|
||||||
|
*/
|
||||||
|
virtual void on_post_init();
|
||||||
|
virtual void on_track_added(unsigned int);
|
||||||
|
virtual void on_track_deleted(unsigned int);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GTK-MM callback functions
|
||||||
|
*/
|
||||||
|
void on_random_toggled();
|
||||||
|
|
||||||
|
/* Filtering functions */
|
||||||
|
bool on_filter_visible(const Gtk::TreeIter &);
|
||||||
|
bool on_entry_key_released(GdkEventKey *);
|
||||||
|
void on_entry_changed();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct TabType {
|
void init_tabs();
|
||||||
void (*init_late)();
|
void post_init_tabs();
|
||||||
void (*cleanup)();
|
void cleanup_tabs();
|
||||||
|
|
||||||
bool (*has_queue)(Playqueue *);
|
|
||||||
void (*track_added)(Playqueue *, unsigned int);
|
|
||||||
void (*track_deleted)(Playqueue *, unsigned int);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static inline std::string itoa(unsigned int i)
|
|
||||||
{
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << i;
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* collection.cpp */
|
|
||||||
void init_collection_tab();
|
void init_collection_tab();
|
||||||
|
|
||||||
/* history.cpp */
|
|
||||||
void init_history_tab();
|
void init_history_tab();
|
||||||
|
|
||||||
/* playlist.cpp */
|
|
||||||
void init_playlist_tab();
|
void init_playlist_tab();
|
||||||
|
|
||||||
/* tabs.cpp */
|
|
||||||
void init_filter(struct FilterDesc *);
|
|
||||||
void register_tab_type(struct TabType *);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* OCARINA_TABS_H */
|
#endif /* OCARINA_TABS_H */
|
||||||
|
|
Loading…
Reference in New Issue