From bd22c8da6de48b7cc1944185bfdada49d48c643a Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 21 Jan 2016 10:16:37 -0500 Subject: [PATCH] gui/collection: Move collection_ops into collection.c Signed-off-by: Anna Schumaker --- gui/collection.c | 34 +++++++++++++++++++++++++++++ gui/collection_tab.cpp | 46 ---------------------------------------- include/gui/collection.h | 3 +++ include/gui/ocarina.h | 1 - 4 files changed, 37 insertions(+), 47 deletions(-) delete mode 100644 gui/collection_tab.cpp diff --git a/gui/collection.c b/gui/collection.c index 1f6f57ee..d05b3fbb 100644 --- a/gui/collection.c +++ b/gui/collection.c @@ -3,6 +3,7 @@ */ #include #include +#include #include #include #include @@ -180,6 +181,28 @@ static gboolean __collection_on_idle(gpointer data) } } +static void *__collection_init(struct queue *queue) +{ + return gui_queue_alloc(queue, "Collection", GQ_CAN_RANDOM); +} + +static void __collection_added(struct queue *queue, unsigned int pos) +{ + gui_queue_added(queue, pos); + gui_sidebar_set_size(gui_queue(queue)); +} + +static bool __collection_erase(struct queue *queue, struct track *track) +{ + return playlist_add(PL_HIDDEN, track); +} + +static void __collection_removed(struct queue *queue, unsigned int pos) +{ + gui_queue_removed(queue, pos); + gui_sidebar_set_size(gui_queue(queue)); +} + void gui_collection_init() { struct db_entry *library, *next; @@ -220,3 +243,14 @@ void gui_collection_idle_enable() gtk_widget_show(progress); g_idle_add(__collection_on_idle, progress); } + +struct queue_ops collection_ops = { + .qop_init = __collection_init, + .qop_deinit = gui_queue_free, + .qop_added = __collection_added, + .qop_erase = __collection_erase, + .qop_removed = __collection_removed, + .qop_cleared = gui_queue_cleared, + .qop_save = collection_save, + .qop_updated = gui_queue_updated, +}; diff --git a/gui/collection_tab.cpp b/gui/collection_tab.cpp deleted file mode 100644 index 9506cf37..00000000 --- a/gui/collection_tab.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2014 (c) Anna Schumaker. - */ -extern "C" { -#include -#include -#include -#include -#include -} -#include -#include - - -static void *collection_init(struct queue *queue) -{ - return gui_queue_alloc(queue, "Collection", GQ_CAN_RANDOM); -} - -static void collection_added(struct queue *queue, unsigned int pos) -{ - gui_queue_added(queue, pos); - gui_sidebar_set_size(gui_queue(queue)); -} - -static bool collection_erase(struct queue *queue, struct track *track) -{ - return playlist_add(PL_HIDDEN, track); -} - -static void collection_removed(struct queue *queue, unsigned int pos) -{ - gui_queue_removed(queue, pos); - gui_sidebar_set_size(gui_queue(queue)); -} - -struct queue_ops collection_ops = { - collection_init, - gui_queue_free, - collection_added, - collection_erase, - collection_removed, - gui_queue_cleared, - collection_save, - gui_queue_updated, -}; diff --git a/include/gui/collection.h b/include/gui/collection.h index 5c0af9ac..4cfaf641 100644 --- a/include/gui/collection.h +++ b/include/gui/collection.h @@ -10,4 +10,7 @@ void gui_collection_init(); /* Called to enable processing idle queue tasks. */ void gui_collection_idle_enable(); +/* Collection operations passed to core_init() */ +extern struct queue_ops collection_ops; + #endif /* OCARINA_GUI_COLLECTION_H */ diff --git a/include/gui/ocarina.h b/include/gui/ocarina.h index 23378ad7..23737629 100644 --- a/include/gui/ocarina.h +++ b/include/gui/ocarina.h @@ -14,7 +14,6 @@ namespace gui const std::string share_file(const std::string &); } -extern struct queue_ops collection_ops; extern struct queue_ops tempq_ops; void on_pq_created(queue *, unsigned int);