From 27a4cc23ed2f55afda81f9b4b72f05a09fc6ceb5 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 21 Jan 2016 10:10:56 -0500 Subject: [PATCH] gui: Remove C++ collection tab code Signed-off-by: Anna Schumaker --- gui/collection.c | 1 + gui/collection_tab.cpp | 40 +++------------------------------------ gui/queue/label.cpp | 17 ----------------- gui/sidebar.c | 3 +++ gui/tabs.cpp | 1 - include/gui/queue/label.h | 10 ---------- include/gui/tabs.h | 1 - 7 files changed, 7 insertions(+), 66 deletions(-) diff --git a/gui/collection.c b/gui/collection.c index a6ed67a7..1f6f57ee 100644 --- a/gui/collection.c +++ b/gui/collection.c @@ -209,6 +209,7 @@ void gui_collection_init() gtk_tree_view_get_selection(treeview), gui_sidebar_on_select, NULL, NULL); + gui_sidebar_set_size(gui_queue(collection_get_queue())); gui_collection_idle_enable(); } diff --git a/gui/collection_tab.cpp b/gui/collection_tab.cpp index c3380b6c..9506cf37 100644 --- a/gui/collection_tab.cpp +++ b/gui/collection_tab.cpp @@ -6,39 +6,12 @@ extern "C" { #include #include #include +#include } #include #include -class CollectionTab : public Tab { -private: - CollectionLabel *collection_label; - -public: - CollectionTab() : Tab(collection_get_queue()) - { - tab_builder->add_from_file(gui :: share_file("QueueLabel.ui")); - tab_builder->get_widget_derived("CollectionLabel", collection_label); - - collection_label->init(tab_pq); - tab_label = collection_label; - - tab_vbox.pack_start(*tab_window, true, true); - - Glib::wrap(GTK_NOTEBOOK(gui_builder_widget("o_notebook")), - false)->insert_page(tab_vbox, *collection_label, 0); - } - - ~CollectionTab() - { - tab_unmap(); - } -}; - - -static CollectionTab *collection_tab; - static void *collection_init(struct queue *queue) { return gui_queue_alloc(queue, "Collection", GQ_CAN_RANDOM); @@ -46,9 +19,8 @@ static void *collection_init(struct queue *queue) static void collection_added(struct queue *queue, unsigned int pos) { - if (collection_tab) - collection_tab->on_track_added(pos); gui_queue_added(queue, pos); + gui_sidebar_set_size(gui_queue(queue)); } static bool collection_erase(struct queue *queue, struct track *track) @@ -58,9 +30,8 @@ static bool collection_erase(struct queue *queue, struct track *track) static void collection_removed(struct queue *queue, unsigned int pos) { - if (collection_tab) - collection_tab->on_track_removed(pos); gui_queue_removed(queue, pos); + gui_sidebar_set_size(gui_queue(queue)); } struct queue_ops collection_ops = { @@ -73,8 +44,3 @@ struct queue_ops collection_ops = { collection_save, gui_queue_updated, }; - -void init_collection_tab() -{ - collection_tab = new CollectionTab; -} diff --git a/gui/queue/label.cpp b/gui/queue/label.cpp index 407c13bc..56b93bde 100644 --- a/gui/queue/label.cpp +++ b/gui/queue/label.cpp @@ -27,23 +27,6 @@ void QueueLabel :: init(queue *queue) -CollectionLabel :: CollectionLabel(BaseObjectType *cobject, - const Glib::RefPtr builder) - : QueueLabel(cobject, builder) -{ - _builder->get_widget("collection_size", collection_size); -} - -void CollectionLabel :: set_size() -{ - gchar *size = g_strdup_printf("%u", queue_size(_queue)); - collection_size->set_text(size); - gui_sidebar_set_size(gui_queue(_queue)); - g_free(size); -} - - - TempLabel :: TempLabel(BaseObjectType *cobject, const Glib::RefPtr builder) : QueueLabel(cobject, builder) diff --git a/gui/sidebar.c b/gui/sidebar.c index e7c853ba..b0f17ebc 100644 --- a/gui/sidebar.c +++ b/gui/sidebar.c @@ -198,6 +198,9 @@ void gui_sidebar_set_size(struct gui_queue *queue) { GtkTreeIter iter; + if (!GTK_IS_TREE_MODEL(sb_store)) + return; + if (__sidebar_find_queue(queue, &iter)) __sidebar_set_size(&iter, queue->gq_text, queue_size(queue->gq_queue)); diff --git a/gui/tabs.cpp b/gui/tabs.cpp index e721c142..173a2d63 100644 --- a/gui/tabs.cpp +++ b/gui/tabs.cpp @@ -178,7 +178,6 @@ void init_tabs() Gtk::Window *window = Glib :: wrap(GTK_WINDOW(gui_builder_widget("o_window")), false); /* Initialize other tabs */ - init_collection_tab(); init_queue_tabs(); /* Setup keyboard shortcuts */ diff --git a/include/gui/queue/label.h b/include/gui/queue/label.h index ed20487f..2f17c010 100644 --- a/include/gui/queue/label.h +++ b/include/gui/queue/label.h @@ -23,16 +23,6 @@ public: -class CollectionLabel : public QueueLabel { -public: - Gtk::Label *collection_size; - - CollectionLabel(BaseObjectType *, const Glib::RefPtr); - void set_size(); -}; - - - class TempLabel : public QueueLabel { public: Gtk::Label *temp_number; diff --git a/include/gui/tabs.h b/include/gui/tabs.h index b326e320..a12c6ca1 100644 --- a/include/gui/tabs.h +++ b/include/gui/tabs.h @@ -62,7 +62,6 @@ void post_init_tabs(); void cleanup_tabs(); -void init_collection_tab(); void init_queue_tabs(); #endif /* OCARINA_TABS_H */