summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 70d9d7d)
raw | patch | inline | side by side (parent: 70d9d7d)
author | Andreas Obergrusberger <tradiaz@yahoo.de> | |
Sat, 28 Oct 2006 08:36:46 +0000 (08:36 +0000) | ||
committer | Andreas Obergrusberger <tradiaz@yahoo.de> | |
Sat, 28 Oct 2006 08:36:46 +0000 (08:36 +0000) |
git-svn-id: https://svn.musicpd.org/ncmpc/branches/tradiaz@4953 09075e82-0dd4-0310-85a5-a0d7c8717e4f
ChangeLog | patch | blob | history | |
src/main.c | patch | blob | history | |
src/mpdclient.c | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 6d9722b801ad459d4a5f5710fc9fa9bd8196f9e4..bf4ec543116e473b5431109d044dffaf252ba86b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-10-28 Anderas Obergrusberger <tradiaz@yahoo.de>
+ * Daniel has added sorting by caring about LC_COLLATE
+
2006-10-26 Andreas Obergrusberger <tradiaz@yahoo.de>
* updated the galician translation
by Johám-Luís Miguéns Vila
diff --git a/src/main.c b/src/main.c
index 35e343be73f230b7c509cc6864d497a9698c8d45..02311ad483637852639895e5bf54fb33f6013790 100644 (file)
--- a/src/main.c
+++ b/src/main.c
#ifdef HAVE_LOCALE_H
/* time and date formatting */
setlocale(LC_TIME,"");
+ /* care about sorting order etc */
+ setlocale(LC_COLLATE,"");
/* charset */
setlocale(LC_CTYPE,"");
/* initialize charset conversions */
diff --git a/src/mpdclient.c b/src/mpdclient.c
index 88330b2a9fc2e3a87d8904698e29420af8487fda..b13146f385baaf30191ecd39e0d382d4ee544d50 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
/* from utils.c */
extern GList *string_list_free(GList *string_list);
+
+/* filelist sorting functions */
+static gint
+compare_filelistentry_dir(gconstpointer filelist_entry1, gconstpointer filelist_entry2)
+{
+ mpd_InfoEntity *e1, *e2;
+ char *key1, *key2;
+ int n = 0;
+
+ e1 = ((filelist_entry_t *)filelist_entry1)->entity;
+ e2 = ((filelist_entry_t *)filelist_entry2)->entity;
+ if (e1 && e2 &&
+ e1->type == MPD_INFO_ENTITY_TYPE_DIRECTORY &&
+ e2->type == MPD_INFO_ENTITY_TYPE_DIRECTORY)
+ {
+ key1 = g_utf8_collate_key(e1->info.directory->path,-1);
+ key2 = g_utf8_collate_key(e2->info.directory->path,-1);
+ n = strcmp(key1,key2);
+ g_free(key1);
+ g_free(key2);
+ }
+ return n;
+}
+
+
/* Error callbacks */
static gint
error_cb(mpdclient_t *c, gint error, gchar *msg)
mpdclient_filelist_t *filelist;
mpd_InfoEntity *entity;
gchar *path_utf8 = locale_to_utf8(path);
+ gboolean has_dirs_only = TRUE;
D("mpdclient_filelist_get(%s)\n", path);
mpd_sendLsInfoCommand(c->connection, path_utf8);
entry->entity = entity;
filelist->list = g_list_append(filelist->list, (gpointer) entry);
filelist->length++;
+
+ if (has_dirs_only && entity->type != MPD_INFO_ENTITY_TYPE_DIRECTORY)
+ {
+ has_dirs_only = FALSE;
+ }
}
/* If there's an error, ignore it. We'll return an empty filelist. */
filelist->path = g_strdup(path);
filelist->updated = TRUE;
+ // If there are only directory entities in the filelist, we sort it
+ if (has_dirs_only)
+ {
+ D("mpdclient_filelist_get: only dirs; sorting!\n");
+ filelist->list = g_list_sort(filelist->list, compare_filelistentry_dir);
+ }
+
return filelist;
}