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
This commit is contained in:
Evgeny Shulgin
2017-04-24 09:54:17 -03:00
committed by Georges Basile Stavracas Neto
parent d5b61e32c5
commit d76bf34640
+14
View File
@@ -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;