From d0212d47aafb9b5597eb3e1b35b5b68e6a3b4bdc Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 19 Apr 2015 09:36:31 -0400 Subject: [PATCH] gui: Create QueueToolbar from a single place Derived classes should already have this available to configure as they see fit. Signed-off-by: Anna Schumaker --- gui/collection.cpp | 8 +------- gui/history.cpp | 8 +------- gui/playlist.cpp | 8 +------- gui/queue.cpp | 11 +---------- gui/tabs.cpp | 6 +++++- include/gui/tabs.h | 4 +++- 6 files changed, 12 insertions(+), 33 deletions(-) diff --git a/gui/collection.cpp b/gui/collection.cpp index 804a8929..dbf21ba8 100644 --- a/gui/collection.cpp +++ b/gui/collection.cpp @@ -5,36 +5,30 @@ #include #include #include -#include #include class CollectionTab : public Tab { private: CollectionLabel *collection_label; - QueueToolbar *collection_toolbar; 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("QueueToolbar.ui")); tab_builder->add_from_file(gui :: share_file("QueueLabel.ui")); tab_builder->get_widget_derived("CollectionLabel", collection_label); - tab_builder->get_widget_derived("QueueToolbar", collection_toolbar); tab_builder->get_widget_derived("QueueWindow", collection_window); - collection_toolbar->init(tab_pq, collection_label, collection_window, T_RANDOM); + tab_toolbar->init(tab_pq, collection_label, collection_window, T_RANDOM); collection_window->init(tab_pq); - tab_vbox.pack_start(*collection_toolbar, false, true, 2); tab_vbox.pack_start(*collection_window, true, true); tab_model = collection_window->q_model; tab_filter = collection_window->q_filter; - tab_search = collection_toolbar->q_search; tab_size = collection_label->collection_size; tab_treeview = collection_window->q_treeview; tab_finish_init(); diff --git a/gui/history.cpp b/gui/history.cpp index b0f7e004..2e20ede6 100644 --- a/gui/history.cpp +++ b/gui/history.cpp @@ -4,36 +4,30 @@ #include #include #include -#include #include class HistoryTab : public Tab { private: HistoryLabel *history_label; - QueueToolbar *history_toolbar; 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("QueueToolbar.ui")); tab_builder->add_from_file(gui :: share_file("QueueLabel.ui")); tab_builder->get_widget_derived("HistoryLabel", history_label); - tab_builder->get_widget_derived("QueueToolbar", history_toolbar); tab_builder->get_widget_derived("QueueWindow", history_window); - history_toolbar->init(tab_pq, history_label, history_window, 0); + tab_toolbar->init(tab_pq, history_label, history_window, 0); history_window->init(tab_pq); - tab_vbox.pack_start(*history_toolbar, false, true, 2); tab_vbox.pack_start(*history_window, true, true); tab_model = history_window->q_model; tab_filter = history_window->q_filter; - tab_search = history_toolbar->q_search; tab_size = history_label->history_size; tab_treeview = history_window->q_treeview; tab_finish_init(); diff --git a/gui/playlist.cpp b/gui/playlist.cpp index 6b1d3c8a..a30030b0 100644 --- a/gui/playlist.cpp +++ b/gui/playlist.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include @@ -75,35 +74,30 @@ private: PlaylistLabel *playlist_label; PlaylistWindow *playlist_window; - QueueToolbar *playlist_toolbar; 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("QueueToolbar.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("QueueToolbar", playlist_toolbar); tab_builder->get_widget_derived("QueueWindow", playlist_tracks); - playlist_toolbar->init(tab_pq, playlist_label, playlist_tracks, 0); + tab_toolbar->init(tab_pq, playlist_label, playlist_tracks, 0); playlist_tracks->init(tab_pq); playlist_hbox.pack_start(*playlist_window, false, true); playlist_hbox.pack_start(*playlist_tracks, true, true); playlist_hbox.show(); - tab_vbox.pack_start(*playlist_toolbar, false, true, 2); tab_vbox.pack_start(playlist_hbox, true, true); tab_model = playlist_tracks->q_model; tab_filter = playlist_tracks->q_filter; - tab_search = playlist_toolbar->q_search; tab_treeview = playlist_tracks->q_treeview; tab_finish_init(); diff --git a/gui/queue.cpp b/gui/queue.cpp index d41ccf51..113b9337 100644 --- a/gui/queue.cpp +++ b/gui/queue.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include @@ -40,11 +39,6 @@ private: */ TempLabel *q_label; - /** - * Toolbar widgets - */ - QueueToolbar *q_toolbar; - /* Treeview widgets */ QueueWindow *q_window; @@ -102,15 +96,13 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num) /* * Now set up the toolbar */ - tab_builder->get_widget_derived("QueueToolbar", q_toolbar); - q_toolbar->init(pq, q_label, q_window, T_RANDOM | T_REPEAT | T_SWITCH); + tab_toolbar->init(pq, q_label, q_window, T_RANDOM | T_REPEAT | T_SWITCH); /* * Fill in the page! */ - tab_vbox.pack_start(*q_toolbar, false, true, 2); tab_vbox.pack_start(*q_window, true, true); @@ -120,7 +112,6 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num) tab_model = q_window->q_model; tab_filter = q_window->q_filter; - tab_search = q_toolbar->q_search; tab_size = q_label->temp_size; tab_treeview = q_window->q_treeview; diff --git a/gui/tabs.cpp b/gui/tabs.cpp index 884e578c..bb20fb3a 100644 --- a/gui/tabs.cpp +++ b/gui/tabs.cpp @@ -33,10 +33,14 @@ Tab :: Tab(Queue *pq) queue_mapping[tab_pq] = this; tab_builder = Gtk::Builder::create(); + tab_builder->add_from_file(gui :: share_file("QueueToolbar.ui")); + tab_builder->get_widget_derived("QueueToolbar", tab_toolbar); tab_vbox.set_margin_start(1); tab_vbox.set_margin_end(1); tab_vbox.set_homogeneous(false); + + tab_vbox.pack_start(*tab_toolbar, false, true, 2); tab_vbox.show(); } @@ -138,7 +142,7 @@ void Tab :: tab_unmap() void Tab :: tab_focus_search() { - tab_search->grab_focus(); + tab_toolbar->q_search->grab_focus(); } void Tab :: tab_selected_ids(std::vector &ids) diff --git a/include/gui/tabs.h b/include/gui/tabs.h index e5343e21..71781001 100644 --- a/include/gui/tabs.h +++ b/include/gui/tabs.h @@ -6,6 +6,7 @@ #include #include +#include #include class Tab : public QNotifier { @@ -18,13 +19,14 @@ protected: Queue *tab_pq; Gtk::VBox tab_vbox; + QueueToolbar *tab_toolbar; + /** * Widgets that MUST be set by a child class */ Glib::RefPtr tab_model; Glib::RefPtr tab_filter; - Gtk::SearchEntry *tab_search; Gtk::TreeView *tab_treeview; /**