gui/collection: Move collection_ops into collection.c

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2016-01-21 10:16:37 -05:00
parent 27a4cc23ed
commit bd22c8da6d
4 changed files with 37 additions and 47 deletions

View File

@ -3,6 +3,7 @@
*/
#include <core/collection.h>
#include <core/idle.h>
#include <core/playlist.h>
#include <core/tempq.h>
#include <gui/builder.h>
#include <gui/collection.h>
@ -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,
};

View File

@ -1,46 +0,0 @@
/*
* Copyright 2014 (c) Anna Schumaker.
*/
extern "C" {
#include <core/collection.h>
#include <core/playlist.h>
#include <gui/builder.h>
#include <gui/queue.h>
#include <gui/sidebar.h>
}
#include <gui/tabs.h>
#include <gui/queue/label.h>
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,
};

View File

@ -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 */

View File

@ -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);