From e6ecea419494bf703f2c67c94dc36f105bb8b468 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enrico=20Tr=C3=B6ger?= Date: Sat, 18 Jul 2009 15:25:15 +0200 Subject: [PATCH] Sort the list of extensions in the side panel --- panels/midori-extensions.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/panels/midori-extensions.c b/panels/midori-extensions.c index 87bd2d88..1dec4d1b 100644 --- a/panels/midori-extensions.c +++ b/panels/midori-extensions.c @@ -444,6 +444,30 @@ midori_extensions_cell_renderer_toggled_cb (GtkCellRendererToggle* renderer, } } +static gint +midori_extensions_tree_sort_func (GtkTreeModel* model, + GtkTreeIter* a, + GtkTreeIter* b, + gpointer data) +{ + MidoriExtension* e1, *e2; + gchar* name1, *name2; + gint result = 0; + + gtk_tree_model_get (model, a, 0, &e1, -1); + gtk_tree_model_get (model, b, 0, &e2, -1); + + name1 = katze_object_get_string (e1, "name"); + name2 = katze_object_get_string (e2, "name"); + + result = g_strcmp0 (name1, name2); + + g_free (name1); + g_free (name2); + + return result; +} + static void midori_extensions_init (MidoriExtensions* extensions) { @@ -453,6 +477,10 @@ midori_extensions_init (MidoriExtensions* extensions) GtkCellRenderer* renderer_toggle; GtkListStore* liststore = gtk_list_store_new (1, G_TYPE_OBJECT); extensions->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (liststore)); + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (liststore), + 0, GTK_SORT_ASCENDING); + gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (liststore), + 0, midori_extensions_tree_sort_func, NULL, NULL); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (extensions->treeview), FALSE); column = gtk_tree_view_column_new (); renderer_toggle = gtk_cell_renderer_toggle_new (); -- 2.39.5