gui/model: Add a function for getting the current queue
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
a28b5c4ec5
commit
f58cc8da46
|
@ -321,6 +321,11 @@ void gui_queue_model_set_queue(GuiQueueModel *model, struct queue *queue)
|
|||
gui_queue_model_add(model, 0);
|
||||
}
|
||||
|
||||
struct queue *gui_queue_model_get_queue(void)
|
||||
{
|
||||
return queue_model->gqm_queue;
|
||||
}
|
||||
|
||||
struct track * gui_queue_model_path_get_track(GuiQueueModel *model,
|
||||
GtkTreePath *path)
|
||||
{
|
||||
|
|
26
gui/view.c
26
gui/view.c
|
@ -42,20 +42,6 @@ static GtkTreeModelFilter *view_filter = NULL;
|
|||
static unsigned int view_sort_count = 0;
|
||||
static bool view_no_scroll = false;
|
||||
|
||||
static inline GuiQueueModel *__view_filter_get_model()
|
||||
{
|
||||
if (view_filter == NULL)
|
||||
return NULL;
|
||||
return GUI_QUEUE_MODEL(gtk_tree_model_filter_get_model(view_filter));
|
||||
}
|
||||
|
||||
static inline struct queue *__view_filter_get_queue()
|
||||
{
|
||||
if (view_filter == NULL)
|
||||
return NULL;
|
||||
return __view_filter_get_model()->gqm_queue;
|
||||
}
|
||||
|
||||
static inline GtkTreePath *__view_filter_convert_path(GtkTreePath *orig)
|
||||
{
|
||||
return gtk_tree_model_filter_convert_path_to_child_path(view_filter, orig);
|
||||
|
@ -63,7 +49,7 @@ static inline GtkTreePath *__view_filter_convert_path(GtkTreePath *orig)
|
|||
|
||||
static struct track *__view_filter_get_track(GtkTreePath *orig)
|
||||
{
|
||||
GuiQueueModel *model = __view_filter_get_model();
|
||||
GuiQueueModel *model = gui_queue_model_get();
|
||||
GtkTreePath *real = __view_filter_convert_path(orig);
|
||||
struct track *track = gui_queue_model_path_get_track(model, real);
|
||||
|
||||
|
@ -109,7 +95,7 @@ static int __view_dec_sort(gpointer data)
|
|||
static void __view_set_column_sort_indicator(GtkTreeViewColumn *col,
|
||||
unsigned int index)
|
||||
{
|
||||
struct queue *queue = __view_filter_get_queue();
|
||||
struct queue *queue = gui_queue_model_get_queue();
|
||||
GSList *cur = queue ? queue->q_sort : NULL;
|
||||
unsigned int order = GTK_SORT_ASCENDING;
|
||||
bool show = false;
|
||||
|
@ -149,7 +135,7 @@ void __view_row_activated(GtkTreeView *treeview, GtkTreePath *path,
|
|||
{
|
||||
view_no_scroll = true;
|
||||
audio_load(__view_filter_get_track(path));
|
||||
queue_selected(__view_filter_get_model()->gqm_queue,
|
||||
queue_selected(gui_queue_model_get_queue(),
|
||||
gtk_tree_path_get_indices(path)[0]);
|
||||
view_no_scroll = false;
|
||||
}
|
||||
|
@ -165,7 +151,7 @@ void __view_column_resized(GtkTreeViewColumn *col, GParamSpec *pspec,
|
|||
|
||||
void __view_column_clicked(GtkTreeViewColumn *col, gpointer data)
|
||||
{
|
||||
struct queue *queue = __view_filter_get_queue();
|
||||
struct queue *queue = gui_queue_model_get_queue();
|
||||
unsigned int index = __view_get_column_index(col);
|
||||
bool reset = view_sort_count == 0;
|
||||
gchar *text;
|
||||
|
@ -205,7 +191,7 @@ static void __view_add_to_playlist(GtkTreeModel *model, GtkTreePath *path,
|
|||
|
||||
static void __view_delete_selection(GtkTreeSelection *selection)
|
||||
{
|
||||
struct queue *queue = __view_filter_get_queue();
|
||||
struct queue *queue = gui_queue_model_get_queue();
|
||||
GList *rows = gtk_tree_selection_get_selected_rows(selection, NULL);
|
||||
GList *cur = g_list_reverse(rows);
|
||||
|
||||
|
@ -355,7 +341,7 @@ void gui_view_set_model(GtkTreeModelFilter *filter)
|
|||
|
||||
void gui_view_scroll()
|
||||
{
|
||||
struct queue *queue = __view_filter_get_queue();
|
||||
struct queue *queue = gui_queue_model_get_queue();
|
||||
GtkTreePath *real, *path;
|
||||
|
||||
if (!queue || (int)queue->q_cur.it_pos < 0 || view_no_scroll)
|
||||
|
|
|
@ -69,6 +69,10 @@ void gui_queue_model_update(GuiQueueModel *, unsigned int);
|
|||
/* Called to change the queue represented by the model. */
|
||||
void gui_queue_model_set_queue(GuiQueueModel *, struct queue *);
|
||||
|
||||
/* Called to get the queue currently attached to the model. */
|
||||
struct queue *gui_queue_model_get_queue(void);
|
||||
|
||||
|
||||
/* Called to convert a GtkTreeIter into a struct track */
|
||||
static inline
|
||||
struct track *gui_queue_model_iter_get_track(GuiQueueModel *model,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <core/string.h>
|
||||
#include <gui/audio.h>
|
||||
#include <gui/builder.h>
|
||||
#include <gui/model.h>
|
||||
#include <gui/window.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
|
@ -61,6 +62,7 @@ static void test_audio()
|
|||
|
||||
gtk_init(&argc, NULL);
|
||||
gui_builder_init("share/ocarina/ocarina6.glade");
|
||||
gui_queue_model_init();
|
||||
|
||||
test_equal(gtk_widget_is_visible(gui_builder_widget("o_play")), true);
|
||||
test_equal(gtk_widget_is_visible(gui_builder_widget("o_pause")), false);
|
||||
|
@ -136,6 +138,7 @@ static void test_audio()
|
|||
audio_cur_track()->tr_length);
|
||||
|
||||
gui_window_deinit();
|
||||
gui_queue_model_deinit();
|
||||
gui_builder_deinit();
|
||||
}
|
||||
|
||||
|
|
|
@ -70,10 +70,12 @@ static void test_init()
|
|||
|
||||
gui_queue_model_init();
|
||||
model = gui_queue_model_get();
|
||||
test_equal((void *)gui_queue_model_get_queue(), NULL);
|
||||
gui_queue_model_set_queue(model, playlist_get_queue(PL_SYSTEM, "Collection"));
|
||||
test_not_equal((void *)model, NULL);
|
||||
test_equal(GTK_IS_TREE_MODEL(model), true);
|
||||
test_equal((void *)model->gqm_queue, (void *)playlist_get_queue(PL_SYSTEM, "Collection"));
|
||||
test_equal((void *)gui_queue_model_get_queue(),
|
||||
(void *)playlist_get_queue(PL_SYSTEM, "Collection"));
|
||||
|
||||
treemodel = GTK_TREE_MODEL(model);
|
||||
test_equal(gtk_tree_model_get_flags(treemodel), GTK_TREE_MODEL_LIST_ONLY);
|
||||
|
|
Loading…
Reference in New Issue