[recipes] Limit featured chefs to 6
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Limit featured chefs to 6
- Date: Sun, 29 Jan 2017 23:11:17 +0000 (UTC)
commit bc950fdb5f5cbcef475f7a95f1183993cba92bec
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jan 30 00:10:33 2017 +0100
Limit featured chefs to 6
Otherwise, we get more than 2 rows, and the page gets
too high then.
src/gr-recipes-page.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-recipes-page.c b/src/gr-recipes-page.c
index a586433..ef953f5 100644
--- a/src/gr-recipes-page.c
+++ b/src/gr-recipes-page.c
@@ -375,6 +375,7 @@ populate_chefs_from_store (GrRecipesPage *self)
g_autofree char **keys = NULL;
guint length;
int i;
+ int count;
gr_chef_tile_recreate_css ();
@@ -383,7 +384,20 @@ populate_chefs_from_store (GrRecipesPage *self)
store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
keys = gr_recipe_store_get_chef_keys (store, &length);
+ /* scramble the keys so we don't always get the same picks */
for (i = 0; i < length; i++) {
+ int r;
+ char *tmp;
+
+ r = g_random_int_range (0, length);
+
+ tmp = keys[i];
+ keys[i] = keys[r];
+ keys[r] = tmp;
+ }
+
+ count = 0;
+ for (i = 0; i < length && count < 6; i++) {
g_autoptr(GrChef) chef = NULL;
chef = gr_recipe_store_get_chef (store, keys[i]);
@@ -394,6 +408,8 @@ populate_chefs_from_store (GrRecipesPage *self)
tile = gr_chef_tile_new (chef);
gtk_widget_show (tile);
gtk_container_add (GTK_CONTAINER (self->chefs_box), tile);
+
+ count++;
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]