[gnome-software] sources dialog: Make sorting work



commit 37895772a66a80d2f6a743457248da88e29e579c
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 ad15da5..63b2c58 100644
--- a/src/gs-sources-dialog.c
+++ b/src/gs-sources-dialog.c
@@ -140,6 +140,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);
 }
@@ -227,7 +232,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
@@ -251,6 +260,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]