Package: gworldclock
Version: 1.4.4-10
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu yakkety ubuntu-patch
Dear Maintainer,
As reported in Ubuntu a while back [1], gworldclock orders the countries by
country code instead of name, whereas only the country name is exposed in the
GUI.
Accordingly, we've been carrying a patch (attached) that sorts the countries
by name in gworldclock, as opposed to the country code.
Thanks for considering the patch.
Logan Rosen
diff -u gworldclock-1.4.4/zones.c gworldclock-1.4.4/zones.c
--- gworldclock-1.4.4/zones.c
+++ gworldclock-1.4.4/zones.c
@@ -120,6 +120,16 @@
return FALSE;
}
+/* GList GCompareFunc to sort list after name */
+gint alphabetical_GCompareFunc(gconstpointer a, gconstpointer b)
+{
+ NameCodeType *aentry = ((NameCodeType *) a);
+ NameCodeType *bentry = ((NameCodeType *) b);
+
+ return strcmp(aentry->name, bentry->name);
+}
+
+
GSList* AddNameCodeEntry(gchar *code, gchar *name, GSList *List)
{
NameCodeType *entry;
@@ -129,7 +139,7 @@
g_print(_("Could not create list: %s"),g_strerror(errno));
entry->name = g_strdup(name);
entry->code = g_strdup(code);
- List = g_slist_append(List, (gpointer)entry);
+ List = g_slist_insert_sorted(List, (gpointer)entry, alphabetical_GCompareFunc);
/* we don't free entry here do we? It's on record and is only to be freed when
the item is released from the list */