mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-04 17:52:29 +00:00
tools: gst-play: sort directory entries
When adding a directory to the playlist, the order would be whatever g_dir_read_name returned. Sorting these using natural sort order. https://bugzilla.gnome.org/show_bug.cgi?id=750585
This commit is contained in:
parent
6221c95d48
commit
4fdbe215dc
1 changed files with 25 additions and 3 deletions
|
@ -588,6 +588,21 @@ do_play (GstPlay * play)
|
||||||
g_main_loop_run (play->loop);
|
g_main_loop_run (play->loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
compare (gconstpointer a, gconstpointer b)
|
||||||
|
{
|
||||||
|
gchar *a1, *b1;
|
||||||
|
gint ret;
|
||||||
|
|
||||||
|
a1 = g_utf8_collate_key_for_filename ((gchar *) a, -1);
|
||||||
|
b1 = g_utf8_collate_key_for_filename ((gchar *) b, -1);
|
||||||
|
ret = strcmp (a1, b1);
|
||||||
|
g_free (a1);
|
||||||
|
g_free (b1);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_to_playlist (GPtrArray * playlist, const gchar * filename)
|
add_to_playlist (GPtrArray * playlist, const gchar * filename)
|
||||||
{
|
{
|
||||||
|
@ -601,17 +616,24 @@ add_to_playlist (GPtrArray * playlist, const gchar * filename)
|
||||||
|
|
||||||
if ((dir = g_dir_open (filename, 0, NULL))) {
|
if ((dir = g_dir_open (filename, 0, NULL))) {
|
||||||
const gchar *entry;
|
const gchar *entry;
|
||||||
|
GList *l, *files = NULL;
|
||||||
|
|
||||||
/* FIXME: sort entries for each directory? */
|
|
||||||
while ((entry = g_dir_read_name (dir))) {
|
while ((entry = g_dir_read_name (dir))) {
|
||||||
gchar *path;
|
gchar *path;
|
||||||
|
|
||||||
path = g_strconcat (filename, G_DIR_SEPARATOR_S, entry, NULL);
|
path = g_strconcat (filename, G_DIR_SEPARATOR_S, entry, NULL);
|
||||||
add_to_playlist (playlist, path);
|
files = g_list_insert_sorted (files, path, compare);
|
||||||
g_free (path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_dir_close (dir);
|
g_dir_close (dir);
|
||||||
|
|
||||||
|
for (l = files; l != NULL; l = l->next) {
|
||||||
|
gchar *path = (gchar *) l->data;
|
||||||
|
|
||||||
|
add_to_playlist (playlist, path);
|
||||||
|
g_free (path);
|
||||||
|
}
|
||||||
|
g_list_free (files);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue