gui/filter: Add a function for loading a track from a tree path
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
ac3c316d9a
commit
3fc19275f3
10
gui/filter.c
10
gui/filter.c
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/audio.h>
|
||||
#include <core/string.h>
|
||||
#include <gui/filter.h>
|
||||
#include <gui/model.h>
|
||||
|
@ -124,6 +125,15 @@ struct track *gui_filter_path_get_track(GtkTreePath *path)
|
|||
return track;
|
||||
}
|
||||
|
||||
void gui_filter_path_load_track(GtkTreePath *path)
|
||||
{
|
||||
struct track *track = gui_filter_path_get_track(path);
|
||||
unsigned int index = gtk_tree_path_get_indices(path)[0];
|
||||
|
||||
audio_load(track);
|
||||
queue_selected(&gui_model_get_playlist()->pl_queue, index);
|
||||
}
|
||||
|
||||
unsigned int gui_filter_path_get_index(GtkTreePath *path)
|
||||
{
|
||||
GtkTreePath *real = __gui_filter_convert_path(path);
|
||||
|
|
|
@ -32,6 +32,9 @@ GtkTreeModelFilter *gui_filter_get();
|
|||
/* Called to convert a filter model path into a track. */
|
||||
struct track *gui_filter_path_get_track(GtkTreePath *);
|
||||
|
||||
/* Called to load the track at path. */
|
||||
void gui_filter_path_load_track(GtkTreePath *);
|
||||
|
||||
/* Called to convert a filter model path into a queue index. */
|
||||
unsigned int gui_filter_path_get_index(GtkTreePath *);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/audio.h>
|
||||
#include <core/core.h>
|
||||
#include <core/idle.h>
|
||||
#include <gui/filter.h>
|
||||
|
@ -31,8 +32,19 @@ struct queue_ops test_ops = {
|
|||
.qop_updated = test_queue_update,
|
||||
};
|
||||
|
||||
void test_on_load(struct track *track) {}
|
||||
void test_on_state_change(GstState state) {}
|
||||
void test_on_config_pause(int count) {}
|
||||
|
||||
struct audio_ops test_audio_ops = {
|
||||
.on_load = test_on_load,
|
||||
.on_state_change = test_on_state_change,
|
||||
.on_config_pause = test_on_config_pause,
|
||||
};
|
||||
|
||||
struct core_init_data init_data = {
|
||||
.playlist_ops = &test_ops,
|
||||
.audio_ops = &test_audio_ops,
|
||||
};
|
||||
|
||||
void test_filter()
|
||||
|
@ -70,6 +82,9 @@ void test_filter()
|
|||
track = gui_filter_path_get_track(path);
|
||||
g_assert_nonnull(track);
|
||||
g_assert_cmpuint(track->tr_track, ==, i + 1);
|
||||
|
||||
gui_filter_path_load_track(path);
|
||||
g_assert(audio_cur_track() == track);
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
path = gui_filter_path_from_index(i);
|
||||
|
|
Loading…
Reference in New Issue