84 lines
1.9 KiB
C
84 lines
1.9 KiB
C
/*
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/playlist.h>
|
|
#include <core/string.h>
|
|
#include <gui/builder.h>
|
|
#include <gui/filter.h>
|
|
#include <gui/model.h>
|
|
#include <gui/queue.h>
|
|
#include <gui/view.h>
|
|
|
|
static struct gui_queue *gq_queue = NULL;
|
|
|
|
static void __queue_toggle_flag(bool active, GtkWidget *widget,
|
|
enum queue_flags flag)
|
|
{
|
|
if (gq_queue == NULL)
|
|
return;
|
|
|
|
if (active)
|
|
queue_set_flag(gq_queue->gq_queue, flag);
|
|
else
|
|
queue_unset_flag(gq_queue->gq_queue, flag);
|
|
}
|
|
|
|
void __queue_random(GtkToggleButton *button, gpointer data)
|
|
{
|
|
__queue_toggle_flag(gtk_toggle_button_get_active(button),
|
|
gtk_button_get_image(GTK_BUTTON(button)),
|
|
Q_RANDOM);
|
|
if (gq_queue && gq_queue->gq_playlist) {
|
|
playlist_set_random(gq_queue->gq_playlist->pl_type,
|
|
gq_queue->gq_playlist->pl_name,
|
|
gtk_toggle_button_get_active(button));
|
|
}
|
|
}
|
|
|
|
void gui_queue_init(void)
|
|
{
|
|
}
|
|
|
|
struct gui_queue *gui_queue_alloc(struct playlist *playlist, struct queue *queue,
|
|
const gchar *text, unsigned int flags)
|
|
{
|
|
struct gui_queue *gq = g_malloc(sizeof(struct gui_queue));
|
|
|
|
gq->gq_flags = flags;
|
|
gq->gq_text = g_strdup(text);
|
|
gq->gq_playlist = playlist;
|
|
gq->gq_queue = queue;
|
|
|
|
return gq;
|
|
}
|
|
|
|
void gui_queue_free(struct queue *queue)
|
|
{
|
|
struct gui_queue *gq = gui_queue(queue);
|
|
|
|
queue->q_private = NULL;
|
|
|
|
if (gq_queue == gq)
|
|
gui_view_set_playlist(NULL);
|
|
g_free(gq->gq_text);
|
|
g_free(gq);
|
|
}
|
|
|
|
void gui_queue_show(struct gui_queue *queue)
|
|
{
|
|
GtkButton *random = GTK_BUTTON(gui_builder_widget("o_random"));
|
|
bool has_random = false;
|
|
|
|
gq_queue = queue;
|
|
|
|
gtk_widget_set_sensitive(GTK_WIDGET(random), gui_queue_can_random(queue));
|
|
|
|
if (queue) {
|
|
has_random = queue_has_flag(queue->gq_queue, Q_RANDOM);
|
|
gui_view_set_playlist(queue->gq_playlist);
|
|
} else
|
|
gui_view_set_playlist(NULL);
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(random), has_random);
|
|
}
|