gui: Move tempq operations into tempq.c
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
bd22c8da6d
commit
c0a6c663d1
|
@ -11,6 +11,7 @@ extern "C" {
|
||||||
#include <gui/playlist.h>
|
#include <gui/playlist.h>
|
||||||
#include <gui/settings.h>
|
#include <gui/settings.h>
|
||||||
#include <gui/sidebar.h>
|
#include <gui/sidebar.h>
|
||||||
|
#include <gui/tempq.h>
|
||||||
#include <gui/view.h>
|
#include <gui/view.h>
|
||||||
#include <gui/window.h>
|
#include <gui/window.h>
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,6 @@ bool __sidebar_keypress(GtkTreeView *treeview, GdkEventKey *event, gpointer data
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
tempq_free(queue->gq_queue);
|
tempq_free(queue->gq_queue);
|
||||||
gtk_list_store_remove(sb_store, &iter);
|
|
||||||
gtk_notebook_remove_page(notebook, page);
|
gtk_notebook_remove_page(notebook, page);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
@ -184,6 +183,7 @@ void gui_sidebar_add(struct gui_queue *queue)
|
||||||
SB_IMAGE_SZ, GTK_ICON_SIZE_BUTTON,
|
SB_IMAGE_SZ, GTK_ICON_SIZE_BUTTON,
|
||||||
SB_TEXT, text,
|
SB_TEXT, text,
|
||||||
SB_QUEUE, queue, -1);
|
SB_QUEUE, queue, -1);
|
||||||
|
__sidebar_set_size(&iter, queue->gq_text, queue_size(queue->gq_queue));
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui_sidebar_remove(struct gui_queue *queue)
|
void gui_sidebar_remove(struct gui_queue *queue)
|
||||||
|
|
44
gui/tabs.cpp
44
gui/tabs.cpp
|
@ -18,50 +18,6 @@ extern "C" {
|
||||||
|
|
||||||
static std::map<queue *, Tab *> queue_mapping;
|
static std::map<queue *, Tab *> queue_mapping;
|
||||||
|
|
||||||
static void *tempq_init(struct queue *queue)
|
|
||||||
{
|
|
||||||
struct gui_queue *gq = gui_queue_alloc(queue, "Queued Tracks",
|
|
||||||
GQ_CAN_RANDOM | GQ_CAN_REPEAT | GQ_CAN_DISABLE);
|
|
||||||
queue->q_private = gq;
|
|
||||||
on_pq_created(queue, tempq_index(queue));
|
|
||||||
gui_sidebar_add(gq);
|
|
||||||
return gq;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void tempq_added(struct queue *queue, unsigned int pos)
|
|
||||||
{
|
|
||||||
Tab *tab = find_tab(queue);
|
|
||||||
if (tab) {
|
|
||||||
tab->on_track_added(pos);
|
|
||||||
tempq_save(queue, Q_ENABLED);
|
|
||||||
}
|
|
||||||
gui_queue_added(queue, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool tempq_erase(struct queue *queue, struct track *track)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void tempq_removed(struct queue *queue, unsigned int pos)
|
|
||||||
{
|
|
||||||
find_tab(queue)->on_track_removed(pos);
|
|
||||||
tempq_save(queue, Q_ENABLED);
|
|
||||||
gui_queue_removed(queue, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct queue_ops tempq_ops = {
|
|
||||||
tempq_init,
|
|
||||||
gui_queue_free,
|
|
||||||
tempq_added,
|
|
||||||
tempq_erase,
|
|
||||||
tempq_removed,
|
|
||||||
gui_queue_cleared,
|
|
||||||
tempq_save,
|
|
||||||
gui_queue_updated,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Tab class basics
|
* Tab class basics
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2016 (c) Anna Schumaker.
|
||||||
|
*/
|
||||||
|
#include <core/tempq.h>
|
||||||
|
#include <gui/queue.h>
|
||||||
|
#include <gui/sidebar.h>
|
||||||
|
|
||||||
|
#define TEMPQ_FLAGS (GQ_CAN_RANDOM | GQ_CAN_REPEAT | GQ_CAN_DISABLE)
|
||||||
|
|
||||||
|
static void *__tempq_init(struct queue *queue)
|
||||||
|
{
|
||||||
|
struct gui_queue *gq;
|
||||||
|
|
||||||
|
gq = gui_queue_alloc(queue, "Queued Tracks", TEMPQ_FLAGS);
|
||||||
|
gui_sidebar_add(gq);
|
||||||
|
return gq;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __tempq_deinit(struct queue *queue)
|
||||||
|
{
|
||||||
|
gui_sidebar_remove(gui_queue(queue));
|
||||||
|
gui_queue_free(queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __tempq_added(struct queue *queue, unsigned int pos)
|
||||||
|
{
|
||||||
|
gui_queue_added(queue, pos);
|
||||||
|
gui_sidebar_set_size(gui_queue(queue));
|
||||||
|
tempq_save(queue, Q_ENABLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool __tempq_erase(struct queue *queue, struct track *track)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __tempq_removed(struct queue *queue, unsigned int pos)
|
||||||
|
{
|
||||||
|
gui_queue_removed(queue, pos);
|
||||||
|
gui_sidebar_set_size(gui_queue(queue));
|
||||||
|
tempq_save(queue, Q_ENABLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __tempq_cleared(struct queue *queue, unsigned int n)
|
||||||
|
{
|
||||||
|
gui_queue_cleared(queue, n);
|
||||||
|
gui_sidebar_set_size(gui_queue(queue));
|
||||||
|
tempq_save(queue, Q_ENABLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct queue_ops tempq_ops = {
|
||||||
|
.qop_init = __tempq_init,
|
||||||
|
.qop_deinit = __tempq_deinit,
|
||||||
|
.qop_added = __tempq_added,
|
||||||
|
.qop_erase = __tempq_erase,
|
||||||
|
.qop_removed = __tempq_removed,
|
||||||
|
.qop_cleared = __tempq_cleared,
|
||||||
|
.qop_save = tempq_save,
|
||||||
|
.qop_updated = gui_queue_updated,
|
||||||
|
};
|
|
@ -14,8 +14,6 @@ namespace gui
|
||||||
const std::string share_file(const std::string &);
|
const std::string share_file(const std::string &);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern struct queue_ops tempq_ops;
|
|
||||||
|
|
||||||
void on_pq_created(queue *, unsigned int);
|
void on_pq_created(queue *, unsigned int);
|
||||||
void post_init_queue_tabs();
|
void post_init_queue_tabs();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2016 (c) Anna Schumaker.
|
||||||
|
*/
|
||||||
|
#ifndef OCARINA_GUI_TEMPQ_H
|
||||||
|
#define OCARINA_GUI_TEMPQ_H
|
||||||
|
|
||||||
|
/* Temporary queue operations passed to core_init() */
|
||||||
|
extern struct queue_ops tempq_ops;
|
||||||
|
|
||||||
|
#endif /* OCARINA_GUI_TEMPQ_H */
|
Loading…
Reference in New Issue