diff options
author | Jon McCann <jmccann@redhat.com> | 2012-03-28 15:01:53 -0400 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2012-04-26 11:13:12 +0100 |
commit | 0bb2e2142a801178c44c23ccebb975e3987221bd (patch) | |
tree | 5e5f5a6d4cc4d50d27873821fbf901df8835451e | |
parent | a3055b3202ca4446f15fa7941c25811a7b4e2f7c (diff) | |
download | gnome-control-center-0bb2e2142a801178c44c23ccebb975e3987221bd.tar.gz |
background: Sort Pictures folder by name
https://bugzilla.gnome.org/show_bug.cgi?id=672925
-rw-r--r-- | panels/background/bg-pictures-source.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/panels/background/bg-pictures-source.c b/panels/background/bg-pictures-source.c index 80ffce7b1..e1e148399 100644 --- a/panels/background/bg-pictures-source.c +++ b/panels/background/bg-pictures-source.c @@ -128,6 +128,36 @@ bg_pictures_source_class_init (BgPicturesSourceClass *klass) object_class->finalize = bg_pictures_source_finalize; } +static int +sort_func (GtkTreeModel *model, + GtkTreeIter *a, + GtkTreeIter *b, + BgPicturesSource *bg_source) +{ + CcBackgroundItem *item_a; + CcBackgroundItem *item_b; + const char *name_a; + const char *name_b; + int retval; + + gtk_tree_model_get (model, a, + 1, &item_a, + -1); + gtk_tree_model_get (model, b, + 1, &item_b, + -1); + + name_a = cc_background_item_get_name (item_a); + name_b = cc_background_item_get_name (item_b); + + retval = g_utf8_collate (name_a, name_b); + + g_object_unref (item_a); + g_object_unref (item_b); + + return retval; +} + static void picture_scaled (GObject *source_object, GAsyncResult *res, @@ -146,6 +176,16 @@ picture_scaled (GObject *source_object, store = bg_source_get_liststore (BG_SOURCE (bg_source)); item = g_object_get_data (source_object, "item"); + gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store), + 1, + (GtkTreeIterCompareFunc)sort_func, + bg_source, + NULL); + + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), + 1, + GTK_SORT_ASCENDING); + pixbuf = gdk_pixbuf_new_from_stream_finish (res, &error); if (pixbuf == NULL) { @@ -167,6 +207,8 @@ picture_scaled (GObject *source_object, return; } + cc_background_item_load (item, NULL); + /* insert the item into the liststore */ gtk_list_store_insert_with_values (store, &iter, 0, 0, pixbuf, |