gui: Set up QueueWindow from a single place

I can't pack it directly into the tab_vbox because playlists need a way
to pack in their special window.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-04-19 09:52:27 -04:00
parent d0212d47aa
commit 9ddae1275f
6 changed files with 28 additions and 75 deletions

View File

@ -5,32 +5,22 @@
#include <core/playlist.h>
#include <gui/tabs.h>
#include <gui/queue/label.h>
#include <gui/queue/window.h>
class CollectionTab : public Tab {
private:
CollectionLabel *collection_label;
QueueWindow *collection_window;
public:
CollectionTab() : Tab(library::get_queue())
{
tab_builder->add_from_file(gui :: share_file("QueueWindow.ui"));
tab_builder->add_from_file(gui :: share_file("QueueLabel.ui"));
tab_builder->get_widget_derived("CollectionLabel", collection_label);
tab_builder->get_widget_derived("QueueWindow", collection_window);
tab_toolbar->init(tab_pq, collection_label, tab_window, T_RANDOM);
tab_toolbar->init(tab_pq, collection_label, collection_window, T_RANDOM);
collection_window->init(tab_pq);
tab_vbox.pack_start(*tab_window, true, true);
tab_vbox.pack_start(*collection_window, true, true);
tab_model = collection_window->q_model;
tab_filter = collection_window->q_filter;
tab_size = collection_label->collection_size;
tab_treeview = collection_window->q_treeview;
tab_finish_init();
gui :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(tab_vbox, *collection_label, 0);

View File

@ -4,32 +4,22 @@
#include <core/deck.h>
#include <gui/tabs.h>
#include <gui/queue/label.h>
#include <gui/queue/window.h>
class HistoryTab : public Tab {
private:
HistoryLabel *history_label;
QueueWindow *history_window;
public:
HistoryTab() : Tab(deck :: get_queue())
{
tab_builder->add_from_file(gui :: share_file("QueueWindow.ui"));
tab_builder->add_from_file(gui :: share_file("QueueLabel.ui"));
tab_builder->get_widget_derived("HistoryLabel", history_label);
tab_builder->get_widget_derived("QueueWindow", history_window);
tab_toolbar->init(tab_pq, history_label, tab_window, 0);
tab_toolbar->init(tab_pq, history_label, history_window, 0);
history_window->init(tab_pq);
tab_vbox.pack_start(*tab_window, true, true);
tab_vbox.pack_start(*history_window, true, true);
tab_model = history_window->q_model;
tab_filter = history_window->q_filter;
tab_size = history_label->history_size;
tab_treeview = history_window->q_treeview;
tab_finish_init();
gui :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(tab_vbox, *history_label, 0);

View File

@ -5,7 +5,6 @@
#include <core/playlist.h>
#include <gui/tabs.h>
#include <gui/queue/label.h>
#include <gui/queue/window.h>
static Gtk::ToggleButton *o_ban;
@ -74,31 +73,24 @@ private:
PlaylistLabel *playlist_label;
PlaylistWindow *playlist_window;
QueueWindow *playlist_tracks;
public:
PlaylistTab() : Tab(playlist :: get_queue())
{
tab_builder->add_from_file(gui :: share_file("QueueWindow.ui"));
tab_builder->add_from_file(gui :: share_file("QueueLabel.ui"));
tab_builder->add_from_file(gui :: share_file("PlaylistWindow.ui"));
tab_builder->get_widget_derived("PlaylistLabel", playlist_label);
tab_builder->get_widget_derived("PlaylistWindow", playlist_window);
tab_builder->get_widget_derived("QueueWindow", playlist_tracks);
tab_toolbar->init(tab_pq, playlist_label, playlist_tracks, 0);
playlist_tracks->init(tab_pq);
tab_toolbar->init(tab_pq, playlist_label, tab_window, 0);
playlist_hbox.pack_start(*playlist_window, false, true);
playlist_hbox.pack_start(*playlist_tracks, true, true);
playlist_hbox.pack_start(*tab_window, true, true);
playlist_hbox.show();
tab_vbox.pack_start(playlist_hbox, true, true);
tab_model = playlist_tracks->q_model;
tab_filter = playlist_tracks->q_filter;
tab_treeview = playlist_tracks->q_treeview;
tab_finish_init();
gui :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(tab_vbox, *playlist_label, 0);

View File

@ -5,7 +5,6 @@
#include <core/string.h>
#include <gui/tabs.h>
#include <gui/queue/label.h>
#include <gui/queue/window.h>
static void renumber_queues();
@ -39,10 +38,6 @@ private:
*/
TempLabel *q_label;
/* Treeview widgets */
QueueWindow *q_window;
public:
QueueTab(Queue *, unsigned int num);
~QueueTab();
@ -70,9 +65,7 @@ static std::map<Gtk::Widget *, QueueTab *> queue_mapping;
QueueTab :: QueueTab(Queue *pq, unsigned int num)
: Tab(pq)
{
tab_builder->add_from_file(gui :: share_file("QueueWindow.ui"));
tab_builder->add_from_file(gui :: share_file("QueueLabel.ui"));
tab_builder->add_from_file(gui :: share_file("QueueToolbar.ui"));
/*
* Create our tab widget
@ -86,34 +79,24 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num)
queue_set_number(num);
/*
* And the treeview with scrolled window
*/
tab_builder->get_widget_derived("QueueWindow", q_window);
q_window->init(pq);
/*
* Now set up the toolbar
*/
tab_toolbar->init(pq, q_label, q_window, T_RANDOM | T_REPEAT | T_SWITCH);
tab_toolbar->init(pq, q_label, tab_window, T_RANDOM | T_REPEAT | T_SWITCH);
/*
* Fill in the page!
*/
tab_vbox.pack_start(*q_window, true, true);
tab_vbox.pack_start(*tab_window, true, true);
/*
* Set generic tab widgets
*/
tab_model = q_window->q_model;
tab_filter = q_window->q_filter;
tab_size = q_label->temp_size;
tab_treeview = q_window->q_treeview;
tab_finish_init();
queue_mapping[&tab_vbox] = this;
@ -156,12 +139,12 @@ bool QueueTab :: on_key_press_event(const std::string &key)
* tab_selected_ids() returns track_ids and not
* playlist_ids,so we can't use it here =(
*/
Glib::RefPtr<Gtk::TreeSelection> sel = tab_treeview->get_selection();
Glib::RefPtr<Gtk::TreeSelection> sel = tab_window->q_treeview->get_selection();
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
Gtk::TreeModel::Path path;
for (unsigned int i = 0; i < rows.size(); i++) {
path = tab_filter->convert_path_to_child_path(rows[i]);
path = tab_window->q_filter->convert_path_to_child_path(rows[i]);
ids.push_back(path[0]);
}

View File

@ -34,7 +34,11 @@ Tab :: Tab(Queue *pq)
tab_builder = Gtk::Builder::create();
tab_builder->add_from_file(gui :: share_file("QueueToolbar.ui"));
tab_builder->add_from_file(gui :: share_file("QueueWindow.ui"));
tab_builder->get_widget_derived("QueueToolbar", tab_toolbar);
tab_builder->get_widget_derived("QueueWindow", tab_window);
tab_window->init(tab_pq);
tab_vbox.set_margin_start(1);
tab_vbox.set_margin_end(1);
@ -48,12 +52,12 @@ Tab :: ~Tab() {}
void Tab :: tab_finish_init()
{
tab_treeview->signal_key_press_event().connect(sigc::mem_fun(*this,
tab_window->q_treeview->signal_key_press_event().connect(sigc::mem_fun(*this,
&Tab :: on_key_pressed));
tab_treeview->signal_button_press_event().connect(sigc::mem_fun(*this,
tab_window->q_treeview->signal_button_press_event().connect(sigc::mem_fun(*this,
&Tab :: on_button_pressed), false);
std::vector<Gtk::TreeViewColumn *> columns = tab_treeview->get_columns();
std::vector<Gtk::TreeViewColumn *> columns = tab_window->q_treeview->get_columns();
for (unsigned int i = 0; i < columns.size(); i++) {
columns[i]->signal_clicked().connect(sigc::bind<unsigned int> (
sigc::mem_fun(*this, &Tab::on_column_clicked), i));
@ -72,21 +76,21 @@ void Tab :: tab_finish_init()
void Tab :: on_track_added(unsigned int row)
{
tab_model->on_row_inserted(row);
tab_window->q_model->on_row_inserted(row);
tab_set_size();
tab_runtime_changed();
}
void Tab :: on_track_removed(unsigned int row)
{
tab_model->on_row_deleted(row);
tab_window->q_model->on_row_deleted(row);
tab_set_size();
tab_runtime_changed();
}
void Tab :: on_track_updated(unsigned int row)
{
tab_model->on_row_changed(row);
tab_window->q_model->on_row_changed(row);
tab_runtime_changed();
}
@ -147,13 +151,13 @@ void Tab :: tab_focus_search()
void Tab :: tab_selected_ids(std::vector<unsigned int> &ids)
{
Glib::RefPtr<Gtk::TreeSelection> sel = tab_treeview->get_selection();
Glib::RefPtr<Gtk::TreeSelection> sel = tab_window->q_treeview->get_selection();
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
Gtk::TreeModel::Path path;
for (unsigned int i = 0; i < rows.size(); i++) {
path = tab_filter->convert_path_to_child_path(rows[i]);
ids.push_back(tab_model->path_to_id(path));
path = tab_window->q_filter->convert_path_to_child_path(rows[i]);
ids.push_back(tab_window->q_model->path_to_id(path));
}
sel->unselect_all();
}
@ -279,7 +283,7 @@ bool Tab :: on_key_pressed(GdkEventKey *event)
void Tab :: on_column_clicked(unsigned int col)
{
if (tab_sorting_count == 0) {
tab_sorting_title = tab_treeview->get_column(col)->get_title();
tab_sorting_title = tab_window->q_treeview->get_column(col)->get_title();
tab_pq->sort(sort_fields[col], true);
} else
tab_pq->sort(sort_fields[col], false);
@ -296,8 +300,8 @@ bool Tab :: on_button_pressed(GdkEventButton *button)
return false;
Gtk::TreeModel::Path path;
if (tab_treeview->get_path_at_pos(button->x, button->y, path))
tab_treeview->get_selection()->select(path);
if (tab_window->q_treeview->get_path_at_pos(button->x, button->y, path))
tab_window->q_treeview->get_selection()->select(path);
on_show_rc_menu();
gui :: get_widget<Gtk::Menu>("o_rc_menu")->popup(button->button, button->time);

View File

@ -7,6 +7,7 @@
#include <gui/ocarina.h>
#include <gui/queue/model.h>
#include <gui/queue/toolbar.h>
#include <gui/queue/window.h>
#include <core/queue.h>
class Tab : public QNotifier {
@ -20,14 +21,7 @@ protected:
Gtk::VBox tab_vbox;
QueueToolbar *tab_toolbar;
/**
* Widgets that MUST be set by a child class
*/
Glib::RefPtr<QueueModel> tab_model;
Glib::RefPtr<Gtk::TreeModelFilter> tab_filter;
Gtk::TreeView *tab_treeview;
QueueWindow *tab_window;
/**
* Optional widgets that MAY be set