gui: Set up the random button from inside the toolbar
This lets me change this variable to be completely internal to the QueueToolbar. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
acbafd2361
commit
fa2bf4637a
|
@ -29,8 +29,7 @@ public:
|
|||
builder->get_widget_derived("CollectionLabel", collection_label);
|
||||
builder->get_widget_derived("QueueToolbar", collection_toolbar);
|
||||
builder->get_widget_derived("QueueWindow", collection_window);
|
||||
|
||||
collection_toolbar->init(T_RANDOM);
|
||||
collection_toolbar->init(tab_pq, T_RANDOM);
|
||||
|
||||
collection_vbox.set_margin_left(1);
|
||||
collection_vbox.set_margin_right(1);
|
||||
|
@ -39,7 +38,6 @@ public:
|
|||
collection_vbox.pack_start(*collection_window, true, true);
|
||||
collection_vbox.show();
|
||||
|
||||
tab_random = collection_toolbar->q_random;
|
||||
tab_repeat = collection_toolbar->q_repeat;
|
||||
tab_search = collection_toolbar->q_search;
|
||||
tab_size = collection_label->collection_size;
|
||||
|
@ -55,11 +53,6 @@ public:
|
|||
tab_unmap();
|
||||
}
|
||||
|
||||
void on_post_init()
|
||||
{
|
||||
tab_init_random();
|
||||
}
|
||||
|
||||
bool on_key_press_event(const std::string &key)
|
||||
{
|
||||
std::vector<unsigned int> ids;
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
builder->get_widget_derived("HistoryLabel", history_label);
|
||||
builder->get_widget_derived("QueueToolbar", history_toolbar);
|
||||
builder->get_widget_derived("QueueWindow", history_window);
|
||||
history_toolbar->init(tab_pq, 0);
|
||||
|
||||
history_vbox.set_margin_left(1);
|
||||
history_vbox.set_margin_right(1);
|
||||
|
@ -36,7 +37,6 @@ public:
|
|||
history_vbox.pack_start(*history_window, true, true);
|
||||
history_vbox.show();
|
||||
|
||||
tab_random = history_toolbar->q_random;
|
||||
tab_repeat = history_toolbar->q_repeat;
|
||||
tab_search = history_toolbar->q_search;
|
||||
tab_size = history_label->history_size;
|
||||
|
|
|
@ -93,6 +93,7 @@ public:
|
|||
builder->get_widget_derived("PlaylistWindow", playlist_window);
|
||||
builder->get_widget_derived("QueueToolbar", playlist_toolbar);
|
||||
builder->get_widget_derived("QueueWindow", playlist_tracks);
|
||||
playlist_toolbar->init(tab_pq, 0);
|
||||
|
||||
playlist_hbox.pack_start(*playlist_window, false, true);
|
||||
playlist_hbox.pack_start(*playlist_tracks, true, true);
|
||||
|
@ -105,7 +106,6 @@ public:
|
|||
playlist_vbox.pack_start(playlist_hbox, true, true);
|
||||
playlist_vbox.show();
|
||||
|
||||
tab_random = playlist_toolbar->q_random;
|
||||
tab_repeat = playlist_toolbar->q_repeat;
|
||||
tab_search = playlist_toolbar->q_search;
|
||||
tab_treeview = playlist_tracks->q_treeview;
|
||||
|
|
|
@ -108,7 +108,7 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num)
|
|||
* Now set up the toolbar
|
||||
*/
|
||||
builder->get_widget_derived("QueueToolbar", q_toolbar);
|
||||
q_toolbar->init(T_RANDOM | T_REPEAT | T_SWITCH);
|
||||
q_toolbar->init(pq, T_RANDOM | T_REPEAT | T_SWITCH);
|
||||
|
||||
/*
|
||||
* And the treeview with scrolled window
|
||||
|
@ -132,7 +132,6 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num)
|
|||
* Set generic tab widgets
|
||||
*/
|
||||
|
||||
tab_random = q_toolbar->q_random;
|
||||
tab_repeat = q_toolbar->q_repeat;
|
||||
tab_search = q_toolbar->q_search;
|
||||
tab_size = q_label->temp_size;
|
||||
|
@ -171,7 +170,6 @@ void QueueTab :: on_track_removed(unsigned int row)
|
|||
|
||||
void QueueTab :: on_post_init()
|
||||
{
|
||||
tab_init_random();
|
||||
tab_init_repeat();
|
||||
|
||||
bool active = (tab_pq->has_flag(Q_ENABLED));
|
||||
|
|
|
@ -10,19 +10,36 @@ 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_random", q_random);
|
||||
_builder->get_widget("q_random", _q_random);
|
||||
}
|
||||
|
||||
QueueToolbar :: ~QueueToolbar()
|
||||
{
|
||||
}
|
||||
|
||||
void QueueToolbar :: init(unsigned int flags)
|
||||
void QueueToolbar :: init(Queue *queue, unsigned int flags)
|
||||
{
|
||||
_queue = queue;
|
||||
|
||||
if (flags & T_SWITCH)
|
||||
q_switch->show();
|
||||
if (flags & T_RANDOM)
|
||||
q_random->show();
|
||||
|
||||
if (flags & T_RANDOM) {
|
||||
_q_random->set_active(_queue->has_flag(Q_RANDOM));
|
||||
_q_random->signal_toggled().connect(sigc::mem_fun(*this,
|
||||
&QueueToolbar::on_random_toggled));
|
||||
_q_random->show();
|
||||
}
|
||||
|
||||
|
||||
if (flags & T_REPEAT)
|
||||
q_repeat->show();
|
||||
}
|
||||
|
||||
void QueueToolbar :: on_random_toggled()
|
||||
{
|
||||
if (_q_random->get_active())
|
||||
_queue->set_flag(Q_RANDOM);
|
||||
else
|
||||
_queue->unset_flag(Q_RANDOM);
|
||||
}
|
||||
|
|
12
gui/tabs.cpp
12
gui/tabs.cpp
|
@ -99,13 +99,6 @@ void Tab :: on_track_updated(unsigned int row)
|
|||
*
|
||||
*/
|
||||
|
||||
void Tab :: tab_init_random()
|
||||
{
|
||||
tab_random->set_active(tab_pq->has_flag(Q_RANDOM));
|
||||
tab_random->signal_toggled().connect(sigc::mem_fun(*this,
|
||||
&Tab::on_random_toggled));
|
||||
}
|
||||
|
||||
void Tab :: tab_init_repeat()
|
||||
{
|
||||
tab_repeat->set_active(tab_pq->has_flag(Q_REPEAT));
|
||||
|
@ -290,11 +283,6 @@ void Tab :: on_show_rc_menu()
|
|||
*
|
||||
*/
|
||||
|
||||
void Tab :: on_random_toggled()
|
||||
{
|
||||
tab_toggle_button(tab_random, Q_RANDOM);
|
||||
}
|
||||
|
||||
void Tab :: on_repeat_toggled()
|
||||
{
|
||||
tab_toggle_button(tab_repeat, Q_REPEAT);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#ifndef OCARINA_GUI_QUEUE_TOOLBAR_H
|
||||
#define OCARINA_GUI_QUEUE_TOOLBAR_H
|
||||
|
||||
#include <core/queue.h>
|
||||
#include <gtkmm.h>
|
||||
|
||||
enum toolbar_flags {
|
||||
|
@ -16,16 +17,21 @@ enum toolbar_flags {
|
|||
class QueueToolbar : public Gtk::HBox {
|
||||
private:
|
||||
Glib::RefPtr<Gtk::Builder> _builder;
|
||||
Queue *_queue;
|
||||
|
||||
Gtk::ToggleButton *_q_random;
|
||||
|
||||
public:
|
||||
Gtk::SearchEntry *q_search;
|
||||
Gtk::Switch *q_switch;
|
||||
Gtk::ToggleButton *q_repeat;
|
||||
Gtk::ToggleButton *q_random;
|
||||
|
||||
QueueToolbar(BaseObjectType *, const Glib::RefPtr<Gtk::Builder>);
|
||||
~QueueToolbar();
|
||||
void init(unsigned int);
|
||||
|
||||
void init(Queue *, unsigned int);
|
||||
|
||||
void on_random_toggled();
|
||||
};
|
||||
|
||||
#endif /* OCARINA_GUI_QUEUE_TOOLBAR_H */
|
||||
|
|
|
@ -31,7 +31,6 @@ protected:
|
|||
/**
|
||||
* Optional widgets that MAY be set
|
||||
*/
|
||||
Gtk::ToggleButton *tab_random;
|
||||
Gtk::ToggleButton *tab_repeat;
|
||||
Gtk::Label *tab_size;
|
||||
|
||||
|
@ -39,7 +38,6 @@ protected:
|
|||
/**
|
||||
* Class helper functions
|
||||
*/
|
||||
void tab_init_random();
|
||||
void tab_init_repeat();
|
||||
void tab_toggle_button(Gtk::ToggleButton *, queue_flags);
|
||||
void tab_dec_sort_count();
|
||||
|
@ -84,7 +82,6 @@ public:
|
|||
/**
|
||||
* GTK-MM callback functions
|
||||
*/
|
||||
void on_random_toggled();
|
||||
void on_repeat_toggled();
|
||||
void on_row_activated(const Gtk::TreePath &, Gtk::TreeViewColumn *);
|
||||
bool on_key_pressed(GdkEventKey *);
|
||||
|
|
Loading…
Reference in New Issue