aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKalle Wallin <kaw@linux.se>2005-06-16 23:32:47 +0000
committerKalle Wallin <kaw@linux.se>2005-06-16 23:32:47 +0000
commit330597ae6f18695bba58fbc64b27e21e69e33e68 (patch)
tree9a9ad1b362d9abf5b1de93f555b8721ffe76a5c3 /src
parente4c13d522d7a417f1c42c9d4587f423530bc3ca7 (diff)
downloadmpd-330597ae6f18695bba58fbc64b27e21e69e33e68.tar.gz
mpd-330597ae6f18695bba58fbc64b27e21e69e33e68.tar.xz
mpd-330597ae6f18695bba58fbc64b27e21e69e33e68.zip
sort artists and albums (metalist)
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@3361 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/screen_artist.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/screen_artist.c b/src/screen_artist.c
index 8909638b0..085c6aac1 100644
--- a/src/screen_artist.c
+++ b/src/screen_artist.c
@@ -50,6 +50,20 @@ static int metalist_length = 0;
static GList *metalist = NULL;
static list_window_state_t *lw_state = NULL;
+static gint
+compare_utf8(gconstpointer s1, gconstpointer s2)
+{
+ char *key1, *key2;
+ int n;
+
+ key1 = g_utf8_collate_key(s1,-1);
+ key2 = g_utf8_collate_key(s2,-1);
+ n = strcmp(key1,key2);
+ g_free(key1);
+ g_free(key2);
+ return n;
+}
+
/* list_window callback */
static char *
artist_lw_callback(int index, int *highlight, void *data)
@@ -131,6 +145,8 @@ update_metalist(mpdclient_t *c, char *m_artist, char *m_album)
{
artist = m_artist;
metalist = mpdclient_get_albums_utf8(c, m_artist);
+ /* sort list */
+ metalist = g_list_sort(metalist, compare_utf8);
/* add a dummy entry for ".." */
metalist = g_list_insert(metalist, g_strdup(".."), 0);
/* add a dummy entry for all songs */
@@ -140,6 +156,8 @@ update_metalist(mpdclient_t *c, char *m_artist, char *m_album)
else /* retreive artists... */
{
metalist = mpdclient_get_artists_utf8(c);
+ /* sort list */
+ metalist = g_list_sort(metalist, compare_utf8);
mode = LIST_ARTISTS;
}
metalist_length = g_list_length(metalist);