[recipes/chef-bio: 2/5] Add some information about dietary restrictions



commit cdc616fdcdeea443a3ea51970bf49da162de7b9c
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Dec 11 21:18:47 2016 -0500

    Add some information about dietary restrictions
    
    Similar to the bio section for chefs, show some general
    information for each dietary restriction.

 src/gr-category-tile.c |   35 +++++++++++++++++++++++++++++++++++
 src/gr-category-tile.h |    3 +++
 src/gr-list-page.c     |   24 +++++++++++++++++-------
 src/gr-list-page.ui    |   11 ++++++++++-
 4 files changed, 65 insertions(+), 8 deletions(-)
---
diff --git a/src/gr-category-tile.c b/src/gr-category-tile.c
index 4607fe2..5786bba 100644
--- a/src/gr-category-tile.c
+++ b/src/gr-category-tile.c
@@ -70,6 +70,41 @@ get_category_title (GrDiets diet)
         return label;
 }
 
+const char *
+gr_diet_get_label (GrDiets diet)
+{
+        return get_category_title (diet);
+}
+
+const char *
+gr_diet_get_description (GrDiets diet)
+{
+        const char *label;
+
+       switch (diet) {
+       case GR_DIET_GLUTEN_FREE:
+               label = _("A gluten-free diet is a diet that excludes gluten, a protein composite found in 
wheat, barley, rye, and all their species and hybrids (such as spelt, kamut, and triticale). The inclusion of 
oats in a gluten-free diet remains controversial. Avenin present in oats may also be toxic for coeliac 
people; its toxicity depends on the cultivar consumed.Furthermore, oats are frequently cross-contaminated 
with cereals containing gluten.");
+               break;
+       case GR_DIET_NUT_FREE:
+               label = _("A tree nut allergy is a hypersensitivity to dietary substances from tree nuts and 
edible tree seeds causing an overreaction of the immune system which may lead to severe physical symptoms. 
Tree nuts include, but are not limited to, almonds, Brazil nuts, cashews, chestnuts, filberts/hazelnuts, 
macadamia nuts, pecans, pistachios, pine nuts,[2] shea nuts and walnuts.");
+               break;
+       case GR_DIET_VEGAN:
+               label = _("Veganism is both the practice of abstaining from the use of animal products, 
particularly in diet, and an associated philosophy that rejects the commodity status of animals.");
+               break;
+       case GR_DIET_VEGETARIAN:
+               label = _("Vegetarian cuisine is based on food that meets vegetarian standards by not 
including meat and animal tissue products (such as gelatin or animal-derived rennet). For lacto-ovo 
vegetarianism (the most common type of vegetarianism in the Western world), eggs and dairy products such as 
milk and cheese are permitted. For lacto vegetarianism, the earliest known type of vegetarianism (recorded in 
India), dairy products such as milk and cheese are permitted.[1] The strictest forms of vegetarianism are 
veganism and fruitarianism, which exclude all animal products, including dairy products as well as honey, and 
even some refined sugars if filtered and whitened with bone char.");
+               break;
+       case GR_DIET_MILK_FREE:
+               label = _("Lactose intolerance is a condition in which people have symptoms due to the 
decreased ability to digest lactose, a sugar found in milk products. Those affected vary in the amount of 
lactose they can tolerate before symptoms develop. Symptoms may include abdominal pain, bloating, diarrhea, 
gas, and nausea. These typically start between half and two hours after drinking milk. Severity depends on 
the amount a person eats or drinks. It does not cause damage to the gastrointestinal tract.");
+               break;
+       default:
+               label = _("Other dietary restrictions");
+               break;
+       }
+
+        return label;
+}
+
 static const char *colors[] = {
         "#215d9c",
         "#297bcc",
diff --git a/src/gr-category-tile.h b/src/gr-category-tile.h
index 3f84535..0205118 100644
--- a/src/gr-category-tile.h
+++ b/src/gr-category-tile.h
@@ -36,4 +36,7 @@ GrDiets          gr_category_tile_get_diet       (GrCategoryTile *tile);
 const char      *gr_category_tile_get_category   (GrCategoryTile *tile);
 const char      *gr_category_tile_get_label      (GrCategoryTile *tile);
 
+const char      *gr_diet_get_label (GrDiets diet);
+const char      *gr_diet_get_description (GrDiets diet);
+
 G_END_DECLS
diff --git a/src/gr-list-page.c b/src/gr-list-page.c
index fa6d451..8f01d83 100644
--- a/src/gr-list-page.c
+++ b/src/gr-list-page.c
@@ -30,6 +30,7 @@
 #include "gr-app.h"
 #include "gr-utils.h"
 #include "gr-season.h"
+#include "gr-category-tile.h"
 
 
 struct _GrListPage
@@ -51,7 +52,8 @@ struct _GrListPage
         GtkWidget *chef_fullname;
         GtkWidget *chef_name;
         GtkWidget *chef_description;
-        GtkWidget *chef_heading;
+        GtkWidget *heading;
+        GtkWidget *diet_description;
 };
 
 G_DEFINE_TYPE (GrListPage, gr_list_page, GTK_TYPE_BOX)
@@ -104,7 +106,8 @@ gr_list_page_class_init (GrListPageClass *klass)
         gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, chef_fullname);
         gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, chef_name);
         gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, chef_description);
-        gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, chef_heading);
+        gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, heading);
+        gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, diet_description);
 }
 
 GtkWidget *
@@ -161,7 +164,11 @@ gr_list_page_populate_from_diet (GrListPage *self,
         self->diet = diet;
 
         gtk_widget_hide (self->chef_box);
-        gtk_widget_hide (self->chef_heading);
+        gtk_widget_show (self->diet_description);
+        gtk_widget_show (self->heading);
+
+        gtk_label_set_label (GTK_LABEL (self->heading), gr_diet_get_label (diet));
+        gtk_label_set_label (GTK_LABEL (self->diet_description), gr_diet_get_description (diet));
 
         container_remove_all (GTK_CONTAINER (self->flow_box));
         tmp = g_strdup_printf (_("No %s found"), get_category_title (diet));
@@ -212,7 +219,8 @@ gr_list_page_populate_from_chef (GrListPage *self,
         self->chef = chef;
 
         gtk_widget_show (self->chef_box);
-        gtk_widget_show (self->chef_heading);
+        gtk_widget_show (self->heading);
+        gtk_widget_hide (self->diet_description);
 
         gtk_label_set_label (GTK_LABEL (self->chef_fullname), gr_chef_get_fullname (chef));
         gtk_label_set_label (GTK_LABEL (self->chef_name), gr_chef_get_name (chef));
@@ -220,7 +228,7 @@ gr_list_page_populate_from_chef (GrListPage *self,
         pixbuf = load_pixbuf_fit_size (gr_chef_get_image (chef), 0, 64, 64, FALSE);
         gtk_image_set_from_pixbuf (GTK_IMAGE (self->chef_image), pixbuf);
         tmp = g_strdup_printf (_("Recipes by %s"), gr_chef_get_name (chef));
-        gtk_label_set_label (GTK_LABEL (self->chef_heading), tmp);
+        gtk_label_set_label (GTK_LABEL (self->heading), tmp);
         g_free (tmp);
 
         store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
@@ -277,7 +285,8 @@ gr_list_page_populate_from_season (GrListPage *self,
         self->season = tmp;
 
         gtk_widget_hide (self->chef_box);
-        gtk_widget_hide (self->chef_heading);
+        gtk_widget_hide (self->heading);
+        gtk_widget_hide (self->diet_description);
 
         container_remove_all (GTK_CONTAINER (self->flow_box));
         tmp = g_strdup_printf (_("No recipes for %s found"), gr_season_get_title (self->season));
@@ -321,7 +330,8 @@ gr_list_page_populate_from_favorites (GrListPage *self)
         self->favorites = TRUE;
 
         gtk_widget_hide (self->chef_box);
-        gtk_widget_hide (self->chef_heading);
+        gtk_widget_hide (self->heading);
+        gtk_widget_hide (self->diet_description);
 
         container_remove_all (GTK_CONTAINER (self->flow_box));
         gtk_label_set_label (GTK_LABEL (self->empty_title), _("No favorite recipes found"));
diff --git a/src/gr-list-page.ui b/src/gr-list-page.ui
index 3a35641..7fe9bf1 100644
--- a/src/gr-list-page.ui
+++ b/src/gr-list-page.ui
@@ -132,7 +132,16 @@
                   </object>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="chef_heading">
+                  <object class="GtkLabel" id="diet_description">
+                    <property name="visible">1</property>
+                    <property name="xalign">0</property>
+                    <property name="wrap">1</property>
+                    <property name="margin-top">20</property>
+                    <property name="margin-bottom">20</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="heading">
                     <property name="visible">1</property>
                     <property name="xalign">0</property>
                     <style>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]