[gnome-software/gnome-3-14] sources dialog: Make sorting work



commit 680d3eea43792e6cf68d7ef60e97fe3ed17bfb1a
Author: Kalev Lember <kalevlember gmail com>
Date:   Mon May 25 21:56:47 2015 +0200

    sources dialog: Make sorting work

 src/gs-sources-dialog.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-sources-dialog.c b/src/gs-sources-dialog.c
index 3a40ddf..42e4001 100644
--- a/src/gs-sources-dialog.c
+++ b/src/gs-sources-dialog.c
@@ -117,6 +117,11 @@ add_source (GtkListBox *listbox, GsApp *app)
                                g_object_ref (app),
                                (GDestroyNotify) g_object_unref);
 
+       g_object_set_data_full (G_OBJECT (box),
+                               "sort",
+                               g_strdup (gs_app_get_name (app)),
+                               g_free);
+
        gtk_list_box_prepend (listbox, box);
        gtk_widget_show_all (box);
 }
@@ -200,7 +205,11 @@ list_sort_func (GtkListBoxRow *a,
                 GtkListBoxRow *b,
                 gpointer user_data)
 {
-       return a < b;
+       GObject *o1 = G_OBJECT (gtk_bin_get_child (GTK_BIN (a)));
+       GObject *o2 = G_OBJECT (gtk_bin_get_child (GTK_BIN (b)));
+       const gchar *key1 = g_object_get_data (o1, "sort");
+       const gchar *key2 = g_object_get_data (o2, "sort");
+       return g_strcmp0 (key1, key2);
 }
 
 static void
@@ -224,6 +233,11 @@ add_app (GtkListBox *listbox, GsApp *app)
        gtk_widget_show (widget);
        gtk_widget_show (box);
 
+       g_object_set_data_full (G_OBJECT (box),
+                               "sort",
+                               g_strdup (gs_app_get_name (app)),
+                               g_free);
+
        row = gtk_widget_get_parent (box);
        gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), FALSE);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]