From: Jeffrey Middleton Date: Mon, 9 Mar 2009 19:32:07 +0000 (-0500) Subject: Sort plugins by filename X-Git-Tag: release-0.14~71 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f0cc4e8a8ed71c706e413a7781908dc8fe58e68f;p=ncmpc.git Sort plugins by filename Although previously the plugins appeared to be sorted by filename, that was only because they were installed in order by filename. Now the plugins are manually sorted by filename, providing for user modification (new plugins, reordering of plugins). --- diff --git a/src/plugin.c b/src/plugin.c index 6dc7bcc..0aa13b5 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -72,6 +72,19 @@ register_plugin(struct plugin_list *list, char *path) return true; } +static gint +plugin_compare_func_alpha(gconstpointer plugin1, gconstpointer plugin2) +{ + return strcmp(* (char * const *) plugin1, * (char * const *) plugin2); +} + +static void +plugin_list_sort(struct plugin_list *list, GCompareFunc compare_func) +{ + g_ptr_array_sort(list->plugins, + compare_func); +} + bool plugin_list_load_directory(struct plugin_list *list, const char *path) { @@ -92,6 +105,9 @@ plugin_list_load_directory(struct plugin_list *list, const char *path) } g_dir_close(dir); + + plugin_list_sort(list, plugin_compare_func_alpha); + return true; }