From e4ea9947280739d6f42edd3924afbe7705f2c316 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sat, 4 Apr 2015 10:09:30 -0400 Subject: [PATCH] gui: QueueTabs should implement the on_remove() notification Signed-off-by: Anna Schumaker --- gui/queue.cpp | 20 +++++++------------- gui/tabs.cpp | 2 ++ include/gui/tabs.h | 1 + 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/gui/queue.cpp b/gui/queue.cpp index c8019957..b383ebf4 100644 --- a/gui/queue.cpp +++ b/gui/queue.cpp @@ -7,6 +7,7 @@ #include +static void renumber_queues(); static unsigned int q_col_width[] = { 20, 300, 60, 100, 100, 45, 100, 60, 1 }; static class QueueColumns : public Gtk::TreeModelColumnRecord { @@ -64,6 +65,7 @@ private: public: QueueTab(Queue *, unsigned int num); ~QueueTab(); + void on_remove(); /** * Helper functions @@ -169,11 +171,15 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num) q_vbox.show_all(); } -QueueTab :: ~QueueTab() +QueueTab :: ~QueueTab() {} + +void QueueTab :: on_remove() { queue_mapping.erase(tab_widget); tab_unmap(); gui :: get_widget("o_notebook")->remove_page(q_vbox); + renumber_queues(); + delete this; } @@ -324,15 +330,6 @@ void on_pq_created(Queue *pq, unsigned int num) tab->on_post_init(); } -static void on_pq_removed(Queue *pq) -{ - Tab *tab = find_tab(pq); - if (tab) { - delete tab; - renumber_queues(); - } -} - static void on_page_reordered(Gtk::Widget *page, int num) { Gtk::Notebook *notebook = gui :: get_widget("o_notebook"); @@ -352,9 +349,6 @@ static void on_page_reordered(Gtk::Widget *page, int num) void init_queue_tabs() { - struct Callbacks *cb = get_callbacks(); - cb->on_pq_removed = on_pq_removed; - Gtk::Notebook *notebook = gui :: get_widget("o_notebook"); notebook->signal_page_reordered().connect(sigc::ptr_fun(on_page_reordered)); } diff --git a/gui/tabs.cpp b/gui/tabs.cpp index 6608d91b..fb267d21 100644 --- a/gui/tabs.cpp +++ b/gui/tabs.cpp @@ -73,6 +73,8 @@ void Tab :: tab_finish_init() * */ +void Tab :: on_remove() {} + void Tab :: on_track_added(unsigned int row) { tab_model->on_row_inserted(row); diff --git a/include/gui/tabs.h b/include/gui/tabs.h index 6f3f359d..b4fdf773 100644 --- a/include/gui/tabs.h +++ b/include/gui/tabs.h @@ -53,6 +53,7 @@ public: /** * QNotifier implementation */ + virtual void on_remove(); void on_track_added(unsigned int); void on_track_removed(unsigned int); void on_track_updated(unsigned int);