gui: Set the runtime label for each tab
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
4ce08ef22e
commit
99e849a106
|
@ -20,6 +20,7 @@ CollectionTab :: CollectionTab()
|
|||
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_finish_init();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ HistoryTab :: HistoryTab()
|
|||
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_finish_init();
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@
|
|||
<property name="scrollable">True</property>
|
||||
<property name="enable_popup">True</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box15">
|
||||
<object class="GtkBox" id="o_collection_page">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">1</property>
|
||||
|
@ -464,7 +464,7 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box16">
|
||||
<object class="GtkBox" id="o_history_page">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">1</property>
|
||||
|
@ -724,7 +724,7 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box17">
|
||||
<object class="GtkBox" id="o_playlist_page">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">1</property>
|
||||
|
|
|
@ -21,6 +21,7 @@ PlaylistTab :: PlaylistTab()
|
|||
{
|
||||
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_finish_init();
|
||||
}
|
||||
|
|
133
gui/tabs.cpp
133
gui/tabs.cpp
|
@ -41,7 +41,7 @@ void Tab :: tab_finish_init()
|
|||
|
||||
|
||||
/**
|
||||
* Tab class helper functions
|
||||
* Tab internal helper functions
|
||||
*/
|
||||
|
||||
void Tab :: tab_init_random()
|
||||
|
@ -51,6 +51,24 @@ void Tab :: tab_init_random()
|
|||
&Tab::on_random_toggled));
|
||||
}
|
||||
|
||||
int Tab :: tab_page_num()
|
||||
{
|
||||
Gtk::Notebook *notebook = 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");
|
||||
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->get_length_str());
|
||||
}
|
||||
|
||||
void Tab :: tab_set_size()
|
||||
{
|
||||
if (tab_size) {
|
||||
|
@ -68,7 +86,7 @@ void Tab :: tab_unmap()
|
|||
|
||||
|
||||
/**
|
||||
* Tab internal callback functions
|
||||
* Tab callback functions
|
||||
*/
|
||||
|
||||
void Tab :: on_post_init() {}
|
||||
|
@ -77,12 +95,14 @@ void Tab :: on_track_added(unsigned int row)
|
|||
{
|
||||
tab_model->on_row_inserted(row);
|
||||
tab_set_size();
|
||||
tab_runtime_changed();
|
||||
}
|
||||
|
||||
void Tab :: on_track_deleted(unsigned int row)
|
||||
{
|
||||
tab_model->on_row_deleted(row);
|
||||
tab_set_size();
|
||||
tab_runtime_changed();
|
||||
}
|
||||
|
||||
|
||||
|
@ -159,13 +179,29 @@ void on_track_deleted(Playqueue *pq, unsigned int row)
|
|||
tab->on_track_deleted(row);
|
||||
}
|
||||
|
||||
void on_switch_page(Gtk::Widget *page, int num)
|
||||
{
|
||||
std::map<Playqueue *, Tab *>::iterator it;
|
||||
for (it = queue_mapping.begin(); it != queue_mapping.end(); it++) {
|
||||
if (it->second->tab_page_num() == num) {
|
||||
it->second->tab_runtime_changed();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
get_widget<Gtk::Label>("o_queue_time")->set_text("");
|
||||
}
|
||||
|
||||
void init_tabs()
|
||||
{
|
||||
struct Callbacks *cb = get_callbacks();
|
||||
|
||||
cb->on_queue_track_add = on_track_added;
|
||||
cb->on_queue_track_del = on_track_deleted;
|
||||
|
||||
/* Notebook signals */
|
||||
struct Gtk::Notebook *notebook = get_widget<Gtk::Notebook>("o_notebook");
|
||||
notebook->signal_switch_page().connect(sigc::ptr_fun(on_switch_page));
|
||||
|
||||
/* Initialize other tabs */
|
||||
init_collection_tab();
|
||||
init_history_tab();
|
||||
|
@ -187,50 +223,6 @@ void cleanup_tabs()
|
|||
|
||||
|
||||
|
||||
/*
|
||||
* Generic tab functions for filtering
|
||||
*/
|
||||
|
||||
/*static bool on_entry_key_released(GdkEventKey *event)
|
||||
{
|
||||
std::string key = gdk_keyval_name(event->keyval);
|
||||
return key == "space";
|
||||
}
|
||||
|
||||
static void on_entry_changed(struct FilterDesc *f)
|
||||
{
|
||||
filter :: search(f->entry->get_text(), f->visible_ids);
|
||||
f->filter->refilter();
|
||||
}
|
||||
|
||||
static bool on_filter_visible(const Gtk::TreeIter &iter, struct FilterDesc *f)
|
||||
{
|
||||
unsigned int pq_id;
|
||||
std::set<unsigned int>::iterator it;
|
||||
|
||||
if (f->entry->get_text().size() == 0)
|
||||
return true;
|
||||
|
||||
pq_id = f->model->iter_to_id(iter);
|
||||
it = f->visible_ids.find(f->model->queue->operator[](pq_id));
|
||||
return it != f->visible_ids.end();
|
||||
}
|
||||
|
||||
void init_filter(struct FilterDesc *filter)
|
||||
{
|
||||
filter->filter = Gtk::TreeModelFilter::create(filter->model);
|
||||
filter->entry->signal_key_release_event().connect(sigc::ptr_fun(on_entry_key_released));
|
||||
filter->entry->signal_changed().connect(sigc::bind<struct FilterDesc *>(
|
||||
sigc::ptr_fun(on_entry_changed),
|
||||
filter));
|
||||
filter->filter->set_visible_func(sigc::bind<struct FilterDesc *>(
|
||||
sigc::ptr_fun(on_filter_visible),
|
||||
filter));
|
||||
}
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/*
|
||||
* Mostly legacy code ....
|
||||
*/
|
||||
|
@ -586,11 +578,6 @@ void OcarinaPage::setup_columns()
|
|||
}
|
||||
}
|
||||
|
||||
bool OcarinaPage::is_current_tab()
|
||||
{
|
||||
return notebook->page_num(*this) == notebook->get_current_page();
|
||||
}
|
||||
|
||||
void OcarinaPage::check_pq_flags()
|
||||
{
|
||||
if (init_flags & PQ_REPEAT) {
|
||||
|
@ -623,22 +610,6 @@ void OcarinaPage::on_close_clicked()
|
|||
deck :: remove(notebook->page_num(*this));
|
||||
}
|
||||
|
||||
void OcarinaPage::on_row_inserted(unsigned int row)
|
||||
{
|
||||
model->on_row_inserted(row);
|
||||
set_tab_size();
|
||||
if (is_current_tab())
|
||||
on_runtime_changed();
|
||||
}
|
||||
|
||||
void OcarinaPage::on_row_deleted(unsigned int row)
|
||||
{
|
||||
model->on_row_deleted(row);
|
||||
set_tab_size();
|
||||
if (is_current_tab())
|
||||
on_runtime_changed();
|
||||
}
|
||||
|
||||
void OcarinaPage::on_row_changed(unsigned int row)
|
||||
{
|
||||
model->on_row_changed(row);
|
||||
|
@ -646,13 +617,6 @@ void OcarinaPage::on_row_changed(unsigned int row)
|
|||
on_runtime_changed();
|
||||
}
|
||||
|
||||
void OcarinaPage::on_runtime_changed()
|
||||
{
|
||||
Gtk::Label *label;
|
||||
get_builder()->get_widget("o_queue_time", label);
|
||||
label->set_text(model->queue->get_length_str());
|
||||
}
|
||||
|
||||
void OcarinaPage::on_repeat_toggled()
|
||||
{
|
||||
if (page_repeat.get_active())
|
||||
|
@ -790,25 +754,6 @@ static void on_track_changed(Playqueue *pq, unsigned int row)
|
|||
it->second->on_row_changed(row);
|
||||
}
|
||||
|
||||
static void on_switch_page(Gtk::Widget *page, int num)
|
||||
{
|
||||
Gtk::Label *label;
|
||||
Gtk::Notebook *notebook;
|
||||
OcarinaPage *tab = (OcarinaPage *)page;
|
||||
|
||||
get_builder()->get_widget("o_queue_time", label);
|
||||
get_builder()->get_widget("o_notebook", notebook);
|
||||
|
||||
if (num >= notebook->get_n_pages() - 4)
|
||||
label->hide();
|
||||
else {
|
||||
tab->on_runtime_changed();
|
||||
label->show();
|
||||
}
|
||||
|
||||
sort_timeout_count = 0;
|
||||
}
|
||||
|
||||
static void renumber_pqs()
|
||||
{
|
||||
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
||||
|
|
|
@ -23,6 +23,7 @@ protected:
|
|||
*/
|
||||
Gtk::SearchEntry *tab_search;
|
||||
Gtk::TreeView *tab_treeview;
|
||||
Gtk::Widget *tab_widget;
|
||||
|
||||
/**
|
||||
* Optional widgets that MAY be set
|
||||
|
@ -35,13 +36,20 @@ protected:
|
|||
* Class helper functions
|
||||
*/
|
||||
void tab_init_random();
|
||||
bool tab_is_cur();
|
||||
void tab_set_size();
|
||||
void tab_unmap();
|
||||
|
||||
public:
|
||||
Tab(Playqueue *);
|
||||
virtual ~Tab();
|
||||
|
||||
/**
|
||||
* More helper functions
|
||||
*/
|
||||
void tab_finish_init();
|
||||
int tab_page_num();
|
||||
void tab_runtime_changed();
|
||||
|
||||
/**
|
||||
* internal callback functions
|
||||
|
|
Loading…
Reference in New Issue