Code

mpdclient: moved compare_filelistentry() to filelist.c
authorMax Kellermann <max@duempel.org>
Sat, 3 Oct 2009 17:18:04 +0000 (19:18 +0200)
committerMax Kellermann <max@duempel.org>
Sat, 3 Oct 2009 17:18:04 +0000 (19:18 +0200)
src/filelist.c
src/filelist.h
src/mpdclient.c

index 2ce928cd4f73d7388bfb675a42d90b2896d41d3c..a8b8b3ca364b5445719873ac9c98c30078aa39ef 100644 (file)
@@ -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)
index ee6e60610fa7fc01803a52b3252f5f1b792b6793..a0805d16bbf25921538f03bcb2fa95e3fb581187 100644 (file)
@@ -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);
index c7b016845ae1746bb3018e8128565d0ae9c5d02c..d8557159ffb7e9fa667285e4a1a964ffd7cf58d2 100644 (file)
@@ -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;
 }