[recipes] cuisine: Sort sections alphabetically
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] cuisine: Sort sections alphabetically
- Date: Mon, 26 Jun 2017 02:33:49 +0000 (UTC)
commit 6841a95451f9e3665fb1a7920d00ebb21da6235a
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jun 25 22:32:13 2017 -0400
cuisine: Sort sections alphabetically
Some sorting is better than no sorting.
src/gr-cuisine-page.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-cuisine-page.c b/src/gr-cuisine-page.c
index ca9ae57..4bd6d98 100644
--- a/src/gr-cuisine-page.c
+++ b/src/gr-cuisine-page.c
@@ -116,6 +116,21 @@ cuisine_page_finalize (GObject *object)
G_OBJECT_CLASS (gr_cuisine_page_parent_class)->finalize (object);
}
+static int
+sort_func (GtkFlowBoxChild *child1,
+ GtkFlowBoxChild *child2,
+ gpointer data)
+{
+ GtkWidget *tile1 = gtk_bin_get_child (GTK_BIN (child1));
+ GtkWidget *tile2 = gtk_bin_get_child (GTK_BIN (child2));
+ GrRecipe *recipe1 = gr_recipe_tile_get_recipe (GR_RECIPE_TILE (tile1));
+ GrRecipe *recipe2 = gr_recipe_tile_get_recipe (GR_RECIPE_TILE (tile2));
+ const char *name1 = gr_recipe_get_name (recipe1);
+ const char *name2 = gr_recipe_get_name (recipe2);
+
+ return strcmp (name1, name2);
+}
+
static void
populate_initially (GrCuisinePage *self)
{
@@ -154,6 +169,8 @@ populate_initially (GrCuisinePage *self)
gtk_flow_box_set_max_children_per_line (GTK_FLOW_BOX (box), 3);
gtk_widget_show (box);
gtk_container_add (GTK_CONTAINER (self->category_box), box);
+ gtk_flow_box_set_sort_func (GTK_FLOW_BOX (box), sort_func, self, NULL);
+
self->categories[i].name = names[i];
self->categories[i].item = item;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]