gui: Set up the repeat button from inside the toolbar

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-04-16 09:03:12 -04:00
parent fa2bf4637a
commit 1423fe2b6e
8 changed files with 17 additions and 33 deletions

View File

@ -38,7 +38,6 @@ public:
collection_vbox.pack_start(*collection_window, true, true);
collection_vbox.show();
tab_repeat = collection_toolbar->q_repeat;
tab_search = collection_toolbar->q_search;
tab_size = collection_label->collection_size;
tab_treeview = collection_window->q_treeview;

View File

@ -37,7 +37,6 @@ public:
history_vbox.pack_start(*history_window, true, true);
history_vbox.show();
tab_repeat = history_toolbar->q_repeat;
tab_search = history_toolbar->q_search;
tab_size = history_label->history_size;
tab_treeview = history_window->q_treeview;

View File

@ -106,7 +106,6 @@ public:
playlist_vbox.pack_start(playlist_hbox, true, true);
playlist_vbox.show();
tab_repeat = playlist_toolbar->q_repeat;
tab_search = playlist_toolbar->q_search;
tab_treeview = playlist_tracks->q_treeview;
tab_widget = &playlist_vbox;

View File

@ -132,7 +132,6 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num)
* Set generic tab widgets
*/
tab_repeat = q_toolbar->q_repeat;
tab_search = q_toolbar->q_search;
tab_size = q_label->temp_size;
tab_treeview = q_window->q_treeview;
@ -170,8 +169,6 @@ void QueueTab :: on_track_removed(unsigned int row)
void QueueTab :: on_post_init()
{
tab_init_repeat();
bool active = (tab_pq->has_flag(Q_ENABLED));
q_toolbar->q_switch->set_active(active);
q_toolbar->q_switch->property_active().signal_changed().connect(

View File

@ -9,7 +9,7 @@ QueueToolbar :: QueueToolbar(BaseObjectType *cobject,
{
_builder->get_widget("q_search", q_search);
_builder->get_widget("q_switch", q_switch);
_builder->get_widget("q_repeat", q_repeat);
_builder->get_widget("q_repeat", _q_repeat);
_builder->get_widget("q_random", _q_random);
}
@ -32,8 +32,12 @@ void QueueToolbar :: init(Queue *queue, unsigned int flags)
}
if (flags & T_REPEAT)
q_repeat->show();
if (flags & T_REPEAT) {
_q_repeat->set_active(_queue->has_flag(Q_REPEAT));
_q_repeat->signal_toggled().connect(sigc::mem_fun(*this,
&QueueToolbar::on_repeat_toggled));
_q_repeat->show();
}
}
void QueueToolbar :: on_random_toggled()
@ -43,3 +47,11 @@ void QueueToolbar :: on_random_toggled()
else
_queue->unset_flag(Q_RANDOM);
}
void QueueToolbar :: on_repeat_toggled()
{
if (_q_repeat->get_active())
_queue->set_flag(Q_REPEAT);
else
_queue->unset_flag(Q_REPEAT);
}

View File

@ -99,21 +99,6 @@ void Tab :: on_track_updated(unsigned int row)
*
*/
void Tab :: tab_init_repeat()
{
tab_repeat->set_active(tab_pq->has_flag(Q_REPEAT));
tab_repeat->signal_toggled().connect(sigc::mem_fun(*this,
&Tab::on_repeat_toggled));
}
void Tab :: tab_toggle_button(Gtk::ToggleButton *button, queue_flags flag)
{
if (button->get_active())
tab_pq->set_flag(flag);
else
tab_pq->unset_flag(flag);
}
int Tab :: tab_page_num()
{
Gtk::Notebook *notebook = gui :: get_widget<Gtk::Notebook>("o_notebook");
@ -283,11 +268,6 @@ void Tab :: on_show_rc_menu()
*
*/
void Tab :: on_repeat_toggled()
{
tab_toggle_button(tab_repeat, Q_REPEAT);
}
void Tab :: on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col)
{
Gtk::TreePath model_path = tab_filter->convert_path_to_child_path(path);

View File

@ -20,11 +20,11 @@ private:
Queue *_queue;
Gtk::ToggleButton *_q_random;
Gtk::ToggleButton *_q_repeat;
public:
Gtk::SearchEntry *q_search;
Gtk::Switch *q_switch;
Gtk::ToggleButton *q_repeat;
QueueToolbar(BaseObjectType *, const Glib::RefPtr<Gtk::Builder>);
~QueueToolbar();
@ -32,6 +32,7 @@ public:
void init(Queue *, unsigned int);
void on_random_toggled();
void on_repeat_toggled();
};
#endif /* OCARINA_GUI_QUEUE_TOOLBAR_H */

View File

@ -31,15 +31,12 @@ protected:
/**
* Optional widgets that MAY be set
*/
Gtk::ToggleButton *tab_repeat;
Gtk::Label *tab_size;
/**
* Class helper functions
*/
void tab_init_repeat();
void tab_toggle_button(Gtk::ToggleButton *, queue_flags);
void tab_dec_sort_count();
virtual void tab_set_size();
void tab_unmap();