gui/queue: Add a text field to the gui queue

The sidebar is going to look at this when setting queue sizes.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2016-01-13 16:48:43 -05:00
parent f85ad3a9c3
commit 2d6e42832b
3 changed files with 12 additions and 3 deletions

View File

@ -3,11 +3,12 @@
*/ */
#include <gui/queue.h> #include <gui/queue.h>
void *gui_queue_alloc(struct queue *queue) struct gui_queue *gui_queue_alloc(struct queue *queue, const gchar *text)
{ {
struct gui_queue *gq = g_malloc(sizeof(struct gui_queue)); struct gui_queue *gq = g_malloc(sizeof(struct gui_queue));
gq->gq_queue = queue; gq->gq_queue = queue;
gq->gq_text = g_strdup(text);
return gq; return gq;
} }
@ -16,5 +17,7 @@ void gui_queue_free(struct queue *queue)
struct gui_queue *gq = gui_queue(queue); struct gui_queue *gq = gui_queue(queue);
queue->q_private = NULL; queue->q_private = NULL;
g_free(gq->gq_text);
g_free(gq); g_free(gq);
} }

View File

@ -8,11 +8,12 @@
struct gui_queue { struct gui_queue {
struct queue *gq_queue; struct queue *gq_queue;
gchar *gq_text;
}; };
/* Called to allocate a new struct gui_queue. */ /* Called to allocate a new struct gui_queue. */
void *gui_queue_alloc(struct queue *); struct gui_queue *gui_queue_alloc(struct queue *, const gchar *);
/* Called to free a struct gui_queue. */ /* Called to free a struct gui_queue. */
void gui_queue_free(struct queue *); void gui_queue_free(struct queue *);

View File

@ -4,10 +4,15 @@
#include <gui/queue.h> #include <gui/queue.h>
#include <tests/test.h> #include <tests/test.h>
static void *test_queue_init(struct queue *queue)
{
return gui_queue_alloc(queue, "Test Queue");
}
void __test_queue_clear(struct queue *queue, unsigned int n) {} void __test_queue_clear(struct queue *queue, unsigned int n) {}
static const struct queue_ops test_ops = { static const struct queue_ops test_ops = {
.qop_init = gui_queue_alloc, .qop_init = test_queue_init,
.qop_deinit = gui_queue_free, .qop_deinit = gui_queue_free,
.qop_cleared = __test_queue_clear, .qop_cleared = __test_queue_clear,
}; };