[recipes] wip: recipe content warnings



commit 25e58b5b018191513ab0df58a98923d458f71532
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Dec 14 09:41:26 2016 -0500

    wip: recipe content warnings

 src/gr-details-page.c  |   23 +++++++++++++++++++++++
 src/gr-details-page.ui |   42 +++++++++++++++++++++++++++++++++++++++---
 2 files changed, 62 insertions(+), 3 deletions(-)
---
diff --git a/src/gr-details-page.c b/src/gr-details-page.c
index 4be6763..7edb4ef 100644
--- a/src/gr-details-page.c
+++ b/src/gr-details-page.c
@@ -115,6 +115,9 @@ struct _GrDetailsPage
         GtkWidget *prep_time_label;
         GtkWidget *cook_time_label;
         GtkWidget *serves_spin;
+        GtkWidget *warning_box;
+        GtkWidget *spicy_warning;
+        GtkWidget *garlic_warning;
         GtkWidget *ingredients_list;
         GtkWidget *instructions_label;
         GtkWidget *cooking_revealer;
@@ -544,6 +547,9 @@ gr_details_page_class_init (GrDetailsPageClass *klass)
         gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, prep_time_label);
         gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, cook_time_label);
         gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, serves_spin);
+        gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, warning_box);
+        gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, spicy_warning);
+        gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, garlic_warning);
         gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, ingredients_list);
         gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, instructions_label);
         gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, cooking_revealer);
@@ -591,6 +597,8 @@ populate_ingredients (GrDetailsPage *page,
         g_autoptr(GtkSizeGroup) group = NULL;
         g_auto(GStrv) ings = NULL;
         int i;
+        gboolean garlic = FALSE;
+        gboolean spicy = TRUE;
 
         group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
         container_remove_all (GTK_CONTAINER (page->ingredients_list));
@@ -601,6 +609,9 @@ populate_ingredients (GrDetailsPage *page,
                 GtkWidget *label;
                 g_autofree char *s = NULL;
 
+                if (strstr (ings[i], "garlic") || strstr (ings[i], "Garlic")) // FIXME
+                  garlic = TRUE;
+
                 box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
                 gtk_widget_show (box);
 
@@ -627,6 +638,18 @@ populate_ingredients (GrDetailsPage *page,
                 row = gtk_widget_get_parent (box);
                 gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), FALSE);
         }
+
+        gtk_widget_hide (page->warning_box);
+
+        if (garlic) {
+                gtk_widget_show (page->warning_box);
+                gtk_widget_show (page->garlic_warning);
+        }
+
+        if (spicy) {
+                gtk_widget_show (page->warning_box);
+                gtk_widget_show (page->spicy_warning);
+        }
 }
 
 void
diff --git a/src/gr-details-page.ui b/src/gr-details-page.ui
index 5df262d..d522021 100644
--- a/src/gr-details-page.ui
+++ b/src/gr-details-page.ui
@@ -124,10 +124,46 @@ followed</property>
                   </object>
                 </child>
                 <child>
-                  <object class="GtkListBox" id="ingredients_list">
+                  <object class="GtkBox">
                     <property name="visible">1</property>
-                    <property name="selection-mode">none</property>
-                    <style> <class name="frame"/> </style>
+                    <property name="orientation">vertical</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkBox" id="warning_box">
+                        <property name="orientation">horizontal</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkImage" id="garlic_warning">
+                            <property name="icon-name">garlic-content-symbolic</property>
+                            <property name="tooltip-text" translatable="yes">Contains garlic</property>
+                            <property name="icon-size">1</property>
+                          </object>
+                          <packing>
+                            <property name="pack-type">end</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkImage" id="spicy_warning">
+                            <property name="icon-name">spicy-content-symbolic</property>
+                            <property name="tooltip-text" translatable="yes">Spicy</property>
+                            <property name="icon-size">1</property>
+                          </object>
+                          <packing>
+                            <property name="pack-type">end</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="fill">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkListBox" id="ingredients_list">
+                        <property name="visible">1</property>
+                        <property name="selection-mode">none</property>
+                        <style> <class name="frame"/> </style>
+                      </object>
+                    </child>
                   </object>
                 </child>
               </object>


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