From: Max Kellermann Date: Sat, 3 Oct 2009 17:18:04 +0000 (+0200) Subject: mpdclient: moved compare_filelistentry() to filelist.c X-Git-Tag: release-0.16~196 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=402d7b6b0d00bbda3f41a4b2bd264068400d5f53;p=ncmpc.git mpdclient: moved compare_filelistentry() to filelist.c --- diff --git a/src/filelist.c b/src/filelist.c index 2ce928c..a8b8b3c 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -110,6 +110,35 @@ filelist_compare_indirect(gconstpointer ap, gconstpointer bp, gpointer data) return compare_func(a, b); } +gint +compare_filelist_entry_path(gconstpointer filelist_entry1, + gconstpointer filelist_entry2) +{ + const struct mpd_entity *e1, *e2; + int n = 0; + + e1 = ((const struct filelist_entry *)filelist_entry1)->entity; + e2 = ((const struct filelist_entry *)filelist_entry2)->entity; + + if (e1 != NULL && e2 != NULL && + mpd_entity_get_type(e1) == mpd_entity_get_type(e2)) { + switch (mpd_entity_get_type(e1)) { + case MPD_ENTITY_TYPE_UNKNOWN: + break; + case MPD_ENTITY_TYPE_DIRECTORY: + n = g_utf8_collate(mpd_directory_get_path(mpd_entity_get_directory(e1)), + mpd_directory_get_path(mpd_entity_get_directory(e2))); + break; + case MPD_ENTITY_TYPE_SONG: + break; + case MPD_ENTITY_TYPE_PLAYLIST: + n = g_utf8_collate(mpd_playlist_get_path(mpd_entity_get_playlist(e1)), + mpd_playlist_get_path(mpd_entity_get_playlist(e2))); + } + } + return n; +} + /* Sorts the whole filelist, at the moment used by filelist_search */ void filelist_sort_all(struct filelist *filelist, GCompareFunc compare_func) diff --git a/src/filelist.h b/src/filelist.h index ee6e606..a0805d1 100644 --- a/src/filelist.h +++ b/src/filelist.h @@ -68,6 +68,10 @@ filelist_prepend(struct filelist *filelist, struct mpd_entity *entity); void filelist_move(struct filelist *filelist, struct filelist *from); +gint +compare_filelist_entry_path(gconstpointer filelist_entry1, + gconstpointer filelist_entry2); + /* Sorts the whole filelist, at the moment used by filelist_search */ void filelist_sort_all(struct filelist *filelist, GCompareFunc compare_func); diff --git a/src/mpdclient.c b/src/mpdclient.c index c7b0168..d855715 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -41,36 +41,6 @@ MPD_ERROR(const struct mpdclient *client) mpd_connection_get_error(client->connection) != MPD_ERROR_SUCCESS; } -/* filelist sorting functions */ -static gint -compare_filelistentry(gconstpointer filelist_entry1, - gconstpointer filelist_entry2) -{ - const struct mpd_entity *e1, *e2; - int n = 0; - - e1 = ((const struct filelist_entry *)filelist_entry1)->entity; - e2 = ((const struct filelist_entry *)filelist_entry2)->entity; - - if (e1 != NULL && e2 != NULL && - mpd_entity_get_type(e1) == mpd_entity_get_type(e2)) { - switch (mpd_entity_get_type(e1)) { - case MPD_ENTITY_TYPE_UNKNOWN: - break; - case MPD_ENTITY_TYPE_DIRECTORY: - n = g_utf8_collate(mpd_directory_get_path(mpd_entity_get_directory(e1)), - mpd_directory_get_path(mpd_entity_get_directory(e2))); - break; - case MPD_ENTITY_TYPE_SONG: - break; - case MPD_ENTITY_TYPE_PLAYLIST: - n = g_utf8_collate(mpd_playlist_get_path(mpd_entity_get_playlist(e1)), - mpd_playlist_get_path(mpd_entity_get_playlist(e2))); - } - } - return n; -} - /* sort by list-format */ gint compare_filelistentry_format(gconstpointer filelist_entry1, @@ -724,7 +694,7 @@ mpdclient_filelist_get(struct mpdclient *c, const gchar *path) if (filelist == NULL) return NULL; - filelist_sort_dir_play(filelist, compare_filelistentry); + filelist_sort_dir_play(filelist, compare_filelist_entry_path); return filelist; }