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



commit d203bd5a7565dcfab6ec7b9f5f2736f7d939c099
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 e593ca0..c8ead9a 100644
--- a/src/gs-sources-dialog.c
+++ b/src/gs-sources-dialog.c
@@ -138,6 +138,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);
 }
@@ -220,7 +225,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
@@ -244,6 +253,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]