From 0def815524548951faa2fdff0c2ea914b72da6d3 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Fri, 9 Apr 2004 21:08:02 +0000 Subject: Sort the actions in the location entry autocompletion dropdown. Fixes bug 2004-04-09 Christian Persch * src/ephy-location-action.c: (compare_actions), (init_actions_list): Sort the actions in the location entry autocompletion dropdown. Fixes bug #139575. --- ChangeLog | 8 ++++++++ src/ephy-location-action.c | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 366c5934d..8bb09fc53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-04-09 Christian Persch + + * src/ephy-location-action.c: (compare_actions), + (init_actions_list): + + Sort the actions in the location entry autocompletion dropdown. + Fixes bug #139575. + 2004-04-09 Adam Hooper * embed/ephy-encodings.c: (ephy_encodings_init): diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c index 2d64cb09b..e34b2c1af 100644 --- a/src/ephy-location-action.c +++ b/src/ephy-location-action.c @@ -406,6 +406,40 @@ ephy_location_action_class_init (EphyLocationActionClass *class) g_type_class_add_private (object_class, sizeof (EphyLocationActionPrivate)); } +static int +compare_actions (gconstpointer a, + gconstpointer b) +{ + EphyNode *node_a = (EphyNode *)a; + EphyNode *node_b = (EphyNode *)b; + const char *title1, *title2; + int retval; + + title1 = ephy_node_get_property_string (node_a, EPHY_NODE_BMK_PROP_TITLE); + title2 = ephy_node_get_property_string (node_b, EPHY_NODE_BMK_PROP_TITLE); + + if (title1 == NULL) + { + retval = -1; + } + else if (title2 == NULL) + { + retval = 1; + } + else + { + char *str_a, *str_b; + + str_a = g_utf8_casefold (title1, -1); + str_b = g_utf8_casefold (title2, -1); + retval = g_utf8_collate (str_a, str_b); + g_free (str_a); + g_free (str_b); + } + + return retval; +} + static void init_actions_list (EphyLocationAction *action) { @@ -419,9 +453,12 @@ init_actions_list (EphyLocationAction *action) kid = g_ptr_array_index (children, i); - action->priv->actions = g_list_append + action->priv->actions = g_list_prepend (action->priv->actions, kid); } + + action->priv->actions = + g_list_sort (action->priv->actions, (GCompareFunc) compare_actions); } static void -- cgit