[gnome-calendar] edit-dialog: sort the list of calendars in alphabetical order



commit d76bf34640dfb0c9b0ec6d15c1a597175b460503
Author: Evgeny Shulgin <izarizar mail ru>
Date:   Thu Apr 20 19:26:12 2017 +0300

    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 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-edit-dialog.c b/src/gcal-edit-dialog.c
index f54ebf1..0b3ac22 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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]