From: Kalle Wallin Date: Thu, 16 Jun 2005 23:32:47 +0000 (+0000) Subject: sort artists and albums (metalist) X-Git-Tag: v0.12_alpha1~411 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=330597ae6f18695bba58fbc64b27e21e69e33e68;p=ncmpc.git sort artists and albums (metalist) git-svn-id: https://svn.musicpd.org/ncmpc/trunk@3361 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- diff --git a/src/screen_artist.c b/src/screen_artist.c index 8909638..085c6aa 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);