]> spindle.queued.net Git - midori/commitdiff
Sort the list of extensions in the side panel
authorEnrico Tröger <enrico.troeger@uvena.de>
Sat, 18 Jul 2009 13:25:15 +0000 (15:25 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sat, 18 Jul 2009 13:25:15 +0000 (15:25 +0200)
panels/midori-extensions.c

index 87bd2d885be98dc752f4b7596bcbf1b9b250eba7..1dec4d1bec829a94ffc33133bf530adbdf8d9001 100644 (file)
@@ -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 ();