gui/queue: Add functions to update the model

These are simple passthrough functions to convert a struct queue into a
GuiQueueModel.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2016-01-18 09:07:00 -05:00
parent 70803cc199
commit e8681e4c92
4 changed files with 40 additions and 2 deletions

View File

@ -2,6 +2,7 @@
* Copyright 2016 (c) Anna Schumaker.
*/
#include <gui/builder.h>
#include <gui/model.h>
#include <gui/queue.h>
static struct gui_queue *gq_queue = NULL;
@ -106,3 +107,23 @@ void gui_queue_show(struct gui_queue *queue)
gtk_widget_set_sensitive(GTK_WIDGET(search), queue != NULL);
gtk_entry_set_text(search, "");
}
void gui_queue_added(struct queue *queue, unsigned int row)
{
gui_queue_model_add(gui_queue(queue)->gq_model, row);
}
void gui_queue_removed(struct queue *queue, unsigned int row)
{
gui_queue_model_remove(gui_queue(queue)->gq_model, row);
}
void gui_queue_cleared(struct queue *queue, unsigned int n)
{
gui_queue_model_clear(gui_queue(queue)->gq_model, n);
}
void gui_queue_updated(struct queue *queue, unsigned int row)
{
gui_queue_model_update(gui_queue(queue)->gq_model, row);
}

View File

@ -3,6 +3,7 @@
*/
#ifndef OCARINA_GUI_MODEL_H
#define OCARINA_GUI_MODEL_H
#include <core/containers/queue.h>
#include <gtk/gtk.h>
#define GUI_QUEUE_MODEL_TYPE (gui_queue_model_get_type())

View File

@ -61,4 +61,16 @@ static inline bool gui_queue_can_disable(struct gui_queue *gq)
/* Called to set the correct state of the random and repeat buttons. */
void gui_queue_show(struct gui_queue *);
/* Called when a track is added to the queue. */
void gui_queue_added(struct queue *, unsigned int);
/* Called when a track is removed from the queue. */
void gui_queue_removed(struct queue *, unsigned int);
/* Called when a queue is cleared. */
void gui_queue_cleared(struct queue *, unsigned int);
/* Called when a track is updated. */
void gui_queue_updated(struct queue *, unsigned int);
#endif /* OCARINA_GUI_QUEUE_H */

View File

@ -17,12 +17,16 @@ static void *test_queue_init(struct queue *queue)
GQ_CAN_RANDOM | GQ_CAN_REPEAT | GQ_CAN_DISABLE);
}
void __test_queue_clear(struct queue *queue, unsigned int n) {}
static void test_queue_save(struct queue *queue, unsigned int row) {}
static const struct queue_ops test_ops = {
.qop_init = test_queue_init,
.qop_deinit = gui_queue_free,
.qop_cleared = __test_queue_clear,
.qop_cleared = gui_queue_cleared,
.qop_added = gui_queue_added,
.qop_removed = gui_queue_removed,
.qop_save = test_queue_save,
.qop_updated = gui_queue_updated,
};
static void test_queue()