gui: Build QueueToolbar from a separate file
This should help clean up the code a bit, especially once I convert all queues to load with the template files. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
1e29ba8cc6
commit
da89012c7b
|
@ -4,6 +4,7 @@
|
|||
#include <core/deck.h>
|
||||
#include <core/string.h>
|
||||
#include <gui/tabs.h>
|
||||
#include <gui/queue/toolbar.h>
|
||||
#include <gui/queue/view.h>
|
||||
|
||||
|
||||
|
@ -52,11 +53,7 @@ private:
|
|||
/**
|
||||
* Toolbar widgets
|
||||
*/
|
||||
Gtk::HBox q_toolbar_box;
|
||||
Gtk::SearchEntry q_search;
|
||||
Gtk::ToggleButton q_random;
|
||||
Gtk::ToggleButton q_repeat;
|
||||
Gtk::Switch q_switch;
|
||||
QueueToolbar *q_toolbar;
|
||||
|
||||
/* Treeview widgets */
|
||||
Gtk::ScrolledWindow q_window;
|
||||
|
@ -96,6 +93,7 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num)
|
|||
{
|
||||
builder = Gtk::Builder::create();
|
||||
builder->add_from_file(gui :: share_file("QueueView.ui"));
|
||||
builder->add_from_file(gui :: share_file("QueueToolbar.ui"));
|
||||
|
||||
/*
|
||||
* Create our tab widget
|
||||
|
@ -119,19 +117,7 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num)
|
|||
/*
|
||||
* Now set up the toolbar
|
||||
*/
|
||||
q_repeat.set_image_from_icon_name("media-playlist-repeat", Gtk::ICON_SIZE_BUTTON);
|
||||
q_random.set_image_from_icon_name("media-playlist-shuffle", Gtk::ICON_SIZE_BUTTON);
|
||||
|
||||
q_toolbar_box.set_margin_left(5);
|
||||
q_toolbar_box.set_margin_right(5);
|
||||
q_toolbar_box.set_spacing(5);
|
||||
q_toolbar_box.set_homogeneous(false);
|
||||
|
||||
q_toolbar_box.pack_start(q_search, true, true);
|
||||
q_toolbar_box.pack_start(q_switch, false, true);
|
||||
q_toolbar_box.pack_start(q_repeat, false, true);
|
||||
q_toolbar_box.pack_start(q_random, false, true);
|
||||
|
||||
builder->get_widget_derived("QueueToolbar", q_toolbar);
|
||||
|
||||
/*
|
||||
* And the treeview with scrolled window
|
||||
|
@ -151,7 +137,7 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num)
|
|||
q_vbox.set_margin_left(1);
|
||||
q_vbox.set_margin_right(1);
|
||||
q_vbox.set_homogeneous(false);
|
||||
q_vbox.pack_start(q_toolbar_box, false, true, 2);
|
||||
q_vbox.pack_start(*q_toolbar, false, true, 2);
|
||||
q_vbox.pack_start(q_window, true, true);
|
||||
|
||||
|
||||
|
@ -159,9 +145,9 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num)
|
|||
* Set generic tab widgets
|
||||
*/
|
||||
|
||||
tab_random = &q_random;
|
||||
tab_repeat = &q_repeat;
|
||||
tab_search = &q_search;
|
||||
tab_random = q_toolbar->q_random;
|
||||
tab_repeat = q_toolbar->q_repeat;
|
||||
tab_search = q_toolbar->q_search;
|
||||
tab_size = &q_tab_size;
|
||||
tab_treeview = q_treeview;
|
||||
tab_widget = &q_vbox;
|
||||
|
@ -203,8 +189,8 @@ void QueueTab :: on_post_init()
|
|||
tab_init_repeat();
|
||||
|
||||
bool active = (tab_pq->has_flag(Q_ENABLED));
|
||||
q_switch.set_active(active);
|
||||
q_switch.property_active().signal_changed().connect(
|
||||
q_toolbar->q_switch->set_active(active);
|
||||
q_toolbar->q_switch->property_active().signal_changed().connect(
|
||||
sigc::mem_fun(*this, &QueueTab :: on_switch_changed));
|
||||
queue_set_sensitive(active);
|
||||
}
|
||||
|
@ -281,7 +267,7 @@ void QueueTab :: on_close_clicked()
|
|||
|
||||
void QueueTab :: on_switch_changed()
|
||||
{
|
||||
if (q_switch.get_active()) {
|
||||
if (q_toolbar->q_switch->get_active()) {
|
||||
tab_pq->set_flag(Q_ENABLED);
|
||||
queue_set_sensitive(true);
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright 2015 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <gui/queue/toolbar.h>
|
||||
|
||||
QueueToolbar :: QueueToolbar(BaseObjectType *cobject,
|
||||
const Glib::RefPtr<Gtk::Builder> builder)
|
||||
: Gtk::HBox(cobject), _builder(builder)
|
||||
{
|
||||
_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);
|
||||
}
|
||||
|
||||
QueueToolbar :: ~QueueToolbar()
|
||||
{
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright 2015 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef OCARINA_GUI_QUEUE_TOOLBAR_H
|
||||
#define OCARINA_GUI_QUEUE_TOOLBAR_H
|
||||
|
||||
#include <gtkmm.h>
|
||||
|
||||
class QueueToolbar : public Gtk::HBox {
|
||||
private:
|
||||
Glib::RefPtr<Gtk::Builder> _builder;
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
#endif /* OCARINA_GUI_QUEUE_TOOLBAR_H */
|
|
@ -0,0 +1,79 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.18.3 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.12"/>
|
||||
<object class="GtkBox" id="QueueToolbar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="q_search">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="primary_icon_name">edit-find-symbolic</property>
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="q_switch">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="state">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="q_repeat">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="focus_on_click">False</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">media-playlist-repeat</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="q_random">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="focus_on_click">False</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">media-playlist-shuffle</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
Loading…
Reference in New Issue