From f0cc4e8a8ed71c706e413a7781908dc8fe58e68f Mon Sep 17 00:00:00 2001 From: Jeffrey Middleton Date: Mon, 9 Mar 2009 14:32:07 -0500 Subject: [PATCH] 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). --- src/plugin.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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; } -- 2.30.2