From 70803cc19993789aafa2202996f7e5bb1aabbf8c Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Mon, 18 Jan 2016 08:54:24 -0500 Subject: [PATCH] gui/queue: Create a GuiQueueModel as part of the gui_queue Signed-off-by: Anna Schumaker --- gui/queue.c | 2 ++ include/gui/queue.h | 8 +++++--- tests/gui/queue.c | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gui/queue.c b/gui/queue.c index 8bda29a1..21537115 100644 --- a/gui/queue.c +++ b/gui/queue.c @@ -55,6 +55,7 @@ struct gui_queue *gui_queue_alloc(struct queue *queue, const gchar *text, gq->gq_flags = flags; gq->gq_text = g_strdup(text); + gq->gq_model = gui_queue_model_new(queue); gq->gq_queue = queue; return gq; @@ -66,6 +67,7 @@ void gui_queue_free(struct queue *queue) queue->q_private = NULL; + g_object_unref(gq->gq_model); g_free(gq->gq_text); g_free(gq); } diff --git a/include/gui/queue.h b/include/gui/queue.h index 10771d36..f996ea3f 100644 --- a/include/gui/queue.h +++ b/include/gui/queue.h @@ -5,6 +5,7 @@ #define OCARINA_GUI_QUEUE_H #include +#include enum gui_queue_flags { GQ_CAN_RANDOM = (1 << 0), /* Random button can be clicked. */ @@ -13,10 +14,11 @@ enum gui_queue_flags { }; struct gui_queue { - unsigned int gq_flags; - gchar *gq_text; + unsigned int gq_flags; + gchar *gq_text; - struct queue *gq_queue; + GuiQueueModel *gq_model; + struct queue *gq_queue; }; diff --git a/tests/gui/queue.c b/tests/gui/queue.c index ca926bc5..b18c9839 100644 --- a/tests/gui/queue.c +++ b/tests/gui/queue.c @@ -47,6 +47,9 @@ static void test_queue() /* Test initialization */ queue_init(&q, 0, &test_ops); gq = gui_queue(&q); + test_equal((void *)gq->gq_queue, (void *)&q); + test_not_equal((void *)gq->gq_model, NULL); + test_equal(gui_queue_can_random(gq), (bool)true); test_equal(gui_queue_can_repeat(gq), (bool)true); test_equal(gui_queue_can_disable(gq), (bool)true);