The attached patch makes Nautilus and eel sort all the applications it obtains for a particular file by their names. We could also arrange that the default handler is always displayed first (for the sidebar), but I'm not sure whether that's very important. It might be quiet odd to break alphabetical sorting. Reported as bug 310038 [1]. [1] http://bugzilla.gnome.org/show_bug.cgi?id=310038 -- Christian Neumair <chris gnome-de org>
Index: eel/eel-mime-application-chooser.c =================================================================== RCS file: /cvs/gnome/eel/eel/eel-mime-application-chooser.c,v retrieving revision 1.10 diff -u -p -r1.10 eel-mime-application-chooser.c --- eel/eel-mime-application-chooser.c 19 Jul 2005 08:08:18 -0000 1.10 +++ eel/eel-mime-application-chooser.c 12 Oct 2005 15:17:16 -0000 @@ -216,6 +216,9 @@ create_tree_view (EelMimeApplicationChoo GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), + COLUMN_NAME, + GTK_SORT_ASCENDING); gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store)); chooser->details->model = store;
Index: libnautilus-private/nautilus-mime-actions.c =================================================================== RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-mime-actions.c,v retrieving revision 1.117 diff -u -p -r1.117 nautilus-mime-actions.c --- libnautilus-private/nautilus-mime-actions.c 22 Aug 2005 19:16:22 -0000 1.117 +++ libnautilus-private/nautilus-mime-actions.c 12 Oct 2005 15:24:10 -0000 @@ -125,9 +125,17 @@ nautilus_mime_get_default_application_fo } static int -application_equal (GnomeVFSMimeApplication *app_a, GnomeVFSMimeApplication *app_b) +application_compare_by_name (const GnomeVFSMimeApplication *app_a, + const GnomeVFSMimeApplication *app_b) { - return gnome_vfs_mime_application_equal (app_a, app_b) ? 0 : 1; + return g_utf8_collate (app_a->name, app_b->name); +} + +static int +application_compare_by_id (const GnomeVFSMimeApplication *app_a, + const GnomeVFSMimeApplication *app_b) +{ + return strcmp (app_a->id, app_b->id); } static GList * @@ -142,6 +150,7 @@ get_open_with_mime_applications (Nautilu uri = nautilus_file_get_uri (file); result = gnome_vfs_mime_get_all_applications_for_uri (uri, mime_type); + g_list_sort (result, (GCompareFunc) application_compare_by_name); if (strcmp (guessed_mime_type, mime_type) != 0) { GList *result_2; @@ -150,8 +159,9 @@ get_open_with_mime_applications (Nautilu result_2 = gnome_vfs_mime_get_all_applications (guessed_mime_type); for (l = result_2; l != NULL; l = l->next) { if (!g_list_find_custom (result, l->data, - (GCompareFunc) application_equal)) { - result = g_list_prepend (result, l->data); + (GCompareFunc) application_compare_by_id)) { + result = g_list_insert_sorted (result, l->data, + (GCompareFunc) application_compare_by_name); } } g_list_free (result_2); @@ -161,7 +171,7 @@ get_open_with_mime_applications (Nautilu g_free (uri); g_free (guessed_mime_type); - return g_list_reverse (result); + return result; } /* Get a list of applications for the Open With menu. This is @@ -193,6 +203,7 @@ nautilus_mime_get_applications_for_file } mime_type = nautilus_file_get_mime_type (file); result = gnome_vfs_mime_get_all_applications (mime_type); + g_list_sort (result, (GCompareFunc) application_compare_by_name); return filter_nautilus_handler (result); }
Attachment:
signature.asc
Description: This is a digitally signed message part