core/playlist: Add playlist_sort() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
c7bc2062d2
commit
5d4de9c5b0
|
@ -58,6 +58,11 @@ bool playlist_get_random(const gchar *name)
|
||||||
return queue_has_flag(playlist_get_queue(name), Q_RANDOM);
|
return queue_has_flag(playlist_get_queue(name), Q_RANDOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void playlist_sort(const gchar *name, enum compare_t sort, bool reset)
|
||||||
|
{
|
||||||
|
pl_system.pl_sort(name, sort, reset);
|
||||||
|
}
|
||||||
|
|
||||||
struct queue *playlist_get_queue(const gchar *name)
|
struct queue *playlist_get_queue(const gchar *name)
|
||||||
{
|
{
|
||||||
return pl_system.pl_get_queue(name);
|
return pl_system.pl_get_queue(name);
|
||||||
|
|
|
@ -197,6 +197,13 @@ static void pl_system_set_flag(const gchar *name, enum queue_flags flag,
|
||||||
queue_unset_flag(__sys_pl_queue(plist), flag);
|
queue_unset_flag(__sys_pl_queue(plist), flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void pl_system_sort(const gchar *name, enum compare_t sort, bool reset)
|
||||||
|
{
|
||||||
|
enum sys_playlist_t plist = __sys_pl_convert(name);
|
||||||
|
|
||||||
|
queue_sort(__sys_pl_queue(plist), sort, reset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct playlist_type pl_system = {
|
struct playlist_type pl_system = {
|
||||||
.pl_get_queue = pl_system_get_queue,
|
.pl_get_queue = pl_system_get_queue,
|
||||||
|
@ -204,6 +211,7 @@ struct playlist_type pl_system = {
|
||||||
.pl_remove_track = pl_system_remove_track,
|
.pl_remove_track = pl_system_remove_track,
|
||||||
.pl_update = pl_system_update,
|
.pl_update = pl_system_update,
|
||||||
.pl_set_flag = pl_system_set_flag,
|
.pl_set_flag = pl_system_set_flag,
|
||||||
|
.pl_sort = pl_system_sort,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -168,12 +168,17 @@ void __view_column_clicked(GtkTreeViewColumn *col, gpointer data)
|
||||||
{
|
{
|
||||||
struct queue *queue = __view_filter_get_queue();
|
struct queue *queue = __view_filter_get_queue();
|
||||||
unsigned int index = __view_get_column_index(col);
|
unsigned int index = __view_get_column_index(col);
|
||||||
|
bool reset = view_sort_count == 0;
|
||||||
gchar *text;
|
gchar *text;
|
||||||
|
|
||||||
if (!queue || queue_has_flag(queue, Q_NO_SORT))
|
if (!queue || queue_has_flag(queue, Q_NO_SORT))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
queue_sort(queue, QUEUE_SORT[index], view_sort_count == 0);
|
if (playlist_get_queue(gui_queue(queue)->gq_text))
|
||||||
|
playlist_sort(gui_queue(queue)->gq_text, QUEUE_SORT[index], reset);
|
||||||
|
else
|
||||||
|
queue_sort(queue, QUEUE_SORT[index], reset);
|
||||||
|
|
||||||
if (view_sort_count == 0) {
|
if (view_sort_count == 0) {
|
||||||
text = g_strdup_printf("Sorting within %s",
|
text = g_strdup_printf("Sorting within %s",
|
||||||
gtk_tree_view_column_get_title(col));
|
gtk_tree_view_column_get_title(col));
|
||||||
|
|
|
@ -41,6 +41,9 @@ void playlist_set_random(const gchar *, bool);
|
||||||
/* Called to check the playlist's random flag. */
|
/* Called to check the playlist's random flag. */
|
||||||
bool playlist_get_random(const gchar *);
|
bool playlist_get_random(const gchar *);
|
||||||
|
|
||||||
|
/* Called to change the sort order of the playlist. */
|
||||||
|
void playlist_sort(const gchar *, enum compare_t, bool);
|
||||||
|
|
||||||
|
|
||||||
/* Called to access the playlist queue. */
|
/* Called to access the playlist queue. */
|
||||||
struct queue *playlist_get_queue(const gchar *);
|
struct queue *playlist_get_queue(const gchar *);
|
||||||
|
|
|
@ -33,6 +33,9 @@ struct playlist_type {
|
||||||
|
|
||||||
/* Called to set a playlist flag. */
|
/* Called to set a playlist flag. */
|
||||||
void (*pl_set_flag)(const gchar *, enum queue_flags, bool);
|
void (*pl_set_flag)(const gchar *, enum queue_flags, bool);
|
||||||
|
|
||||||
|
/* Called to sort a playlist. */
|
||||||
|
void (*pl_sort)(const gchar *, enum compare_t, bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue