From d76bf34640dfb0c9b0ec6d15c1a597175b460503 Mon Sep 17 00:00:00 2001 From: Evgeny Shulgin Date: Thu, 20 Apr 2017 19:26:12 +0300 Subject: [PATCH] edit-dialog: sort the list of calendars in alphabetical order Since gcal_manager_get_sources() returns a GList of ESource received from the hash table, they are not sorted alphabetically. Because of this, edit-dialog shows the unsorted list. I added a function for sorting this GList that is case-insensitive. https://bugzilla.gnome.org/show_bug.cgi?id=781231 --- src/gcal-edit-dialog.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gcal-edit-dialog.c b/src/gcal-edit-dialog.c index f54ebf1a..0b3ac225 100644 --- a/src/gcal-edit-dialog.c +++ b/src/gcal-edit-dialog.c @@ -147,6 +147,18 @@ const GActionEntry action_entries[] = { "select-calendar", on_calendar_selected, "s" }, }; +static gint +sources_menu_sort_func (gconstpointer a, + gconstpointer b) +{ + ESource *source1, *source2; + + source1 = E_SOURCE (a); + source2 = E_SOURCE (b); + + return g_ascii_strcasecmp (e_source_get_display_name (source1), e_source_get_display_name (source2)); +} + static void fill_sources_menu (GcalEditDialog *dialog) { @@ -159,6 +171,8 @@ fill_sources_menu (GcalEditDialog *dialog) list = gcal_manager_get_sources (dialog->manager); dialog->sources_menu = g_menu_new (); + g_list_sort (list, sources_menu_sort_func); + for (aux = list; aux != NULL; aux = aux->next) { ESource *source;