gui: Convert the collection tab use the new template files

I expect most of the new constructor code to disappear once I start
using the .ui files in the parent class.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-04-11 16:24:01 -04:00
parent 2f1d0a3bb8
commit a581b42649
5 changed files with 129 additions and 297 deletions

View File

@ -4,18 +4,51 @@
#include <core/library.h>
#include <core/playlist.h>
#include <gui/tabs.h>
#include <gui/queue/label.h>
#include <gui/queue/toolbar.h>
#include <gui/queue/window.h>
class CollectionTab : public Tab {
private:
Glib::RefPtr<Gtk::Builder> builder;
Gtk::VBox collection_vbox;
CollectionLabel *collection_label;
QueueToolbar *collection_toolbar;
QueueWindow *collection_window;
public:
CollectionTab() : Tab(library::get_queue())
{
tab_random = gui :: get_widget<Gtk::ToggleButton>("o_collection_random");
tab_search = gui :: get_widget<Gtk::SearchEntry>("o_collection_entry");
tab_size = gui :: get_widget<Gtk::Label>("o_collection_size");
tab_treeview = gui :: get_widget<Gtk::TreeView>("o_collection_pq_treeview");
tab_widget = gui :: get_widget<Gtk::Widget>("o_collection_page");
builder = Gtk::Builder::create();
builder->add_from_file(gui :: share_file("QueueWindow.ui"));
builder->add_from_file(gui :: share_file("QueueToolbar.ui"));
builder->add_from_file(gui :: share_file("QueueLabel.ui"));
builder->get_widget_derived("CollectionLabel", collection_label);
builder->get_widget_derived("QueueToolbar", collection_toolbar);
builder->get_widget_derived("QueueWindow", collection_window);
collection_toolbar->q_switch->hide();
collection_toolbar->q_repeat->hide();
collection_vbox.set_margin_left(1);
collection_vbox.set_margin_right(1);
collection_vbox.set_homogeneous(false);
collection_vbox.pack_start(*collection_toolbar, false, true, 2);
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;
tab_treeview = collection_window->q_treeview;
tab_widget = &collection_vbox;
tab_finish_init();
gui :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(collection_vbox, *collection_label, 0);
}
~CollectionTab()

View File

@ -3,6 +3,20 @@
*/
#include <gui/queue/label.h>
CollectionLabel :: CollectionLabel(BaseObjectType *cobject,
const Glib::RefPtr<Gtk::Builder> builder)
: Gtk::HBox(cobject), _builder(builder)
{
_builder->get_widget("collection_size", collection_size);
}
CollectionLabel :: ~CollectionLabel()
{
}
TempLabel :: TempLabel(BaseObjectType *cobject,
const Glib::RefPtr<Gtk::Builder> builder)
: Gtk::HBox(cobject), _builder(builder)

View File

@ -6,6 +6,20 @@
#include <gtkmm.h>
class CollectionLabel : public Gtk::HBox {
private:
Glib::RefPtr<Gtk::Builder> _builder;
public:
Gtk::Label *collection_size;
CollectionLabel(BaseObjectType *, const Glib::RefPtr<Gtk::Builder>);
~CollectionLabel();
};
class TempLabel : public Gtk::HBox {
private:
Glib::RefPtr<Gtk::Builder> _builder;

View File

@ -2,6 +2,62 @@
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkBox" id="CollectionLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">media-optical</property>
<property name="icon_size">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;big&gt;Collection&lt;/big&gt;</property>
<property name="use_markup">True</property>
<property name="justify">center</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="collection_size">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<object class="GtkBox" id="TempLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>

View File

@ -237,290 +237,6 @@
<property name="tab_pos">left</property>
<property name="scrollable">True</property>
<property name="enable_popup">True</property>
<child>
<object class="GtkBox" id="o_collection_page">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">1</property>
<property name="margin_right">1</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="box23">
<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="o_collection_entry">
<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="GtkToggleButton" id="o_collection_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="image17">
<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">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">2</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow4">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="margin_bottom">5</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="o_collection_pq_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="enable_search">False</property>
<property name="rubber_banding">True</property>
<property name="tooltip_column">9</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection2">
<property name="mode">multiple</property>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn4">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">20</property>
<property name="title" translatable="yes">#</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext3"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn5">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">300</property>
<property name="title" translatable="yes">Title</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext4"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn6">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">60</property>
<property name="title" translatable="yes">Length</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext5"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn7">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">100</property>
<property name="title" translatable="yes">Artist</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext6"/>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn8">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">100</property>
<property name="title" translatable="yes">Album</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext7"/>
<attributes>
<attribute name="text">4</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn9">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">45</property>
<property name="title" translatable="yes">Year</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext8"/>
<attributes>
<attribute name="text">5</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn10">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">100</property>
<property name="title" translatable="yes">Genre</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext9"/>
<attributes>
<attribute name="text">6</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn11">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">60</property>
<property name="title" translatable="yes">Count</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext10"/>
<attributes>
<attribute name="text">7</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn12">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">1</property>
<property name="title" translatable="yes">Played</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext11"/>
<attributes>
<attribute name="text">8</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="tab">
<object class="GtkBox" id="box18">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image14">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">media-optical</property>
<property name="icon_size">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box19">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_right">1</property>
<property name="label" translatable="yes">&lt;big&gt;Collection&lt;/big&gt;</property>
<property name="use_markup">True</property>
<property name="justify">center</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="o_collection_size">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkBox" id="o_history_page">
<property name="visible">True</property>
@ -711,9 +427,6 @@
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child type="tab">
<object class="GtkBox" id="box20">
@ -775,7 +488,6 @@
</child>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
@ -1021,7 +733,7 @@
</child>
</object>
<packing>
<property name="position">2</property>
<property name="position">1</property>
</packing>
</child>
<child type="tab">
@ -1059,7 +771,7 @@ Manager</property>
</child>
</object>
<packing>
<property name="position">2</property>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
@ -1268,7 +980,7 @@ Manager</property>
</child>
</object>
<packing>
<property name="position">3</property>
<property name="position">2</property>
</packing>
</child>
<child type="tab">
@ -1306,7 +1018,7 @@ Manager</property>
</child>
</object>
<packing>
<property name="position">3</property>
<property name="position">2</property>
<property name="tab_fill">False</property>
</packing>
</child>
@ -1620,6 +1332,7 @@ Manager</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;span size='xx-large'&gt;&lt;/span&gt;</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">True</property>
@ -1634,6 +1347,7 @@ Manager</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;span size='x-large'&gt;&lt;/span&gt;</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
@ -1648,6 +1362,7 @@ Manager</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;span size='x-large'&gt;&lt;/span&gt;</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">True</property>