[Xfce4-commits] <thunar:master> Fix sorting of applications in chooser dialog.

Nick Schermer noreply at xfce.org
Sat Jan 21 15:48:03 CET 2012


Updating branch refs/heads/master
         to 401223479151f999a6913bdaf10ce7bff70dc822 (commit)
       from 3106972b15457365118e43c646c247c5e1821ff5 (commit)

commit 401223479151f999a6913bdaf10ce7bff70dc822
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Jan 21 15:46:10 2012 +0100

    Fix sorting of applications in chooser dialog.
    
    We could use GtkTreeSortable here, but that will also
    sort the main categories, so only sort the "other applications"
    list.

 thunar/thunar-chooser-dialog.c |    1 -
 thunar/thunar-chooser-model.c  |   19 +++++++++++++++----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/thunar/thunar-chooser-dialog.c b/thunar/thunar-chooser-dialog.c
index 296d0b9..a7fe4bb 100644
--- a/thunar/thunar-chooser-dialog.c
+++ b/thunar/thunar-chooser-dialog.c
@@ -244,7 +244,6 @@ thunar_chooser_dialog_init (ThunarChooserDialog *dialog)
                                        "weight", THUNAR_CHOOSER_MODEL_COLUMN_WEIGHT,
                                        "weight-set", THUNAR_CHOOSER_MODEL_COLUMN_WEIGHT_SET,
                                        NULL);
-  gtk_tree_view_column_set_sort_column_id (column, THUNAR_CHOOSER_MODEL_COLUMN_NAME);
   gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->tree_view), column);
 
   /* don't show the expanders */
diff --git a/thunar/thunar-chooser-model.c b/thunar/thunar-chooser-model.c
index 5861cc4..ec41b5c 100644
--- a/thunar/thunar-chooser-model.c
+++ b/thunar/thunar-chooser-model.c
@@ -261,6 +261,16 @@ compare_app_infos (gconstpointer a,
 
 
 
+static gint
+sort_app_infos (gconstpointer a,
+                gconstpointer b)
+{
+  return g_utf8_collate (g_app_info_get_name (G_APP_INFO (a)),
+                         g_app_info_get_name (G_APP_INFO (b)));
+}
+
+
+
 static void
 thunar_chooser_model_reload (ThunarChooserModel *model)
 {
@@ -284,17 +294,18 @@ thunar_chooser_model_reload (ThunarChooserModel *model)
                                recommended);
 
   all = g_app_info_get_all ();
-  for (lp = g_list_last (all); lp != NULL; lp = lp->prev)
+  for (lp = all; lp != NULL; lp = lp->next)
     {
-      if (g_list_find_custom (recommended, 
-                              lp->data, 
-                              (GCompareFunc) compare_app_infos) == NULL)
+      if (g_list_find_custom (recommended,
+                              lp->data,
+                              compare_app_infos) == NULL)
         {
           other = g_list_prepend (other, lp->data);
         }
     }
 
   /* append the other applications */
+  other = g_list_sort (other, sort_app_infos);
   thunar_chooser_model_append (model,
                                _("Other Applications"),
                                "gnome-applications",


More information about the Xfce4-commits mailing list