gui/queue: Add a new gui_queue struct
This will be used to store queue state once I no longer support notebook tabs. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
5bc9f65cd9
commit
f85ad3a9c3
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <gui/queue.h>
|
||||
|
||||
void *gui_queue_alloc(struct queue *queue)
|
||||
{
|
||||
struct gui_queue *gq = g_malloc(sizeof(struct gui_queue));
|
||||
|
||||
gq->gq_queue = queue;
|
||||
return gq;
|
||||
}
|
||||
|
||||
void gui_queue_free(struct queue *queue)
|
||||
{
|
||||
struct gui_queue *gq = gui_queue(queue);
|
||||
|
||||
queue->q_private = NULL;
|
||||
g_free(gq);
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef OCARINA_GUI_QUEUE_H
|
||||
#define OCARINA_GUI_QUEUE_H
|
||||
|
||||
#include <core/queue.h>
|
||||
|
||||
struct gui_queue {
|
||||
struct queue *gq_queue;
|
||||
};
|
||||
|
||||
|
||||
/* Called to allocate a new struct gui_queue. */
|
||||
void *gui_queue_alloc(struct queue *);
|
||||
|
||||
/* Called to free a struct gui_queue. */
|
||||
void gui_queue_free(struct queue *);
|
||||
|
||||
/* Called to access a the struct gui_queue attached to a queue. */
|
||||
static inline struct gui_queue *gui_queue(struct queue *queue)
|
||||
{
|
||||
return queue->q_private;
|
||||
}
|
||||
|
||||
#endif /* OCARINA_GUI_QUEUE_H */
|
|
@ -1,5 +1,6 @@
|
|||
builder
|
||||
settings
|
||||
queue
|
||||
window
|
||||
sidebar
|
||||
collection
|
||||
|
|
|
@ -26,6 +26,7 @@ def GuiTest(name):
|
|||
env.UsePackage("gmodule-export-2.0")
|
||||
res += [ GuiTest("builder") ]
|
||||
res += [ GuiTest("settings") ]
|
||||
res += [ GuiTest("queue") ]
|
||||
res += [ GuiTest("window") ]
|
||||
res += [ GuiTest("sidebar") ]
|
||||
res += [ GuiTest("collection") ]
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <gui/queue.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
void __test_queue_clear(struct queue *queue, unsigned int n) {}
|
||||
|
||||
static const struct queue_ops test_ops = {
|
||||
.qop_init = gui_queue_alloc,
|
||||
.qop_deinit = gui_queue_free,
|
||||
.qop_cleared = __test_queue_clear,
|
||||
};
|
||||
|
||||
static void test_queue()
|
||||
{
|
||||
struct gui_queue *gq;
|
||||
struct queue q;
|
||||
|
||||
queue_init(&q, 0, &test_ops);
|
||||
gq = gui_queue(&q);
|
||||
|
||||
test_not_equal((void *)gq, NULL);
|
||||
test_equal((void *)gq->gq_queue, (void *)&q);
|
||||
|
||||
queue_deinit(&q);
|
||||
test_equal((void *)gui_queue(&q), NULL);
|
||||
}
|
||||
|
||||
DECLARE_UNIT_TESTS(
|
||||
UNIT_TEST("Queue", test_queue),
|
||||
);
|
Loading…
Reference in New Issue