[recipes/shopping-list: 5/15] Add a Shopping List button to the action bar



commit dbfe9f117de2f96949f8d96907a8b87f3814ac48
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jan 8 08:50:06 2017 -0500

    Add a Shopping List button to the action bar
    
    We will have separate favorites and shopping lists.
    
    This commit changes alls the right-hand-side buttons on the
    action bar to be image buttons.

 src/gr-details-page.c  |   13 ++++++++++++
 src/gr-details-page.ui |   51 ++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 58 insertions(+), 6 deletions(-)
---
diff --git a/src/gr-details-page.c b/src/gr-details-page.c
index 9fc5041..be972c9 100644
--- a/src/gr-details-page.c
+++ b/src/gr-details-page.c
@@ -512,6 +512,18 @@ cook_it_later (GrDetailsPage *page)
 }
 
 static void
+shop_it (GrDetailsPage *page)
+{
+        GrRecipeStore *store;
+
+        store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
+        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (page->favorite_button)))
+                gr_recipe_store_add_to_shopping (store, page->recipe);
+        else
+                gr_recipe_store_remove_from_shopping (store, page->recipe);
+}
+
+static void
 details_page_finalize (GObject *object)
 {
         GrDetailsPage *self = GR_DETAILS_PAGE (object);
@@ -752,6 +764,7 @@ gr_details_page_class_init (GrDetailsPageClass *klass)
         gtk_widget_class_bind_template_callback (widget_class, time_spin_output);
         gtk_widget_class_bind_template_callback (widget_class, check_clicked);
         gtk_widget_class_bind_template_callback (widget_class, cook_it_later);
+        gtk_widget_class_bind_template_callback (widget_class, shop_it);
         gtk_widget_class_bind_template_callback (widget_class, activate_link);
         gtk_widget_class_bind_template_callback (widget_class, dismiss_error);
 }
diff --git a/src/gr-details-page.ui b/src/gr-details-page.ui
index 83630f4..fd71bfc 100644
--- a/src/gr-details-page.ui
+++ b/src/gr-details-page.ui
@@ -455,11 +455,36 @@ followed</property>
           </object>
         </child>
         <child>
+          <object class="GtkToggleButton" id="shop_button">
+            <property name="visible">1</property>
+            <property name="tooltip-text" translatable="yes">Shopping list</property>
+            <style> <class name="image-button"/> </style>
+            <signal name="toggled" handler="shop_it" swapped="yes"/>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">1</property>
+                <property name="icon-name">shoppingcart</property>
+                <property name="icon-size">1</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="pack-type">end</property>
+          </packing>
+        </child>
+        <child>
           <object class="GtkToggleButton" id="favorite_button">
             <property name="visible">1</property>
-            <property name="use-underline">1</property>
-            <property name="label" translatable="yes">_Cook it later</property>
+            <property name="tooltip-text" translatable="yes">Favorites</property>
+            <style> <class name="image-button"/> </style>
             <signal name="toggled" handler="cook_it_later" swapped="yes"/>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">1</property>
+                <property name="icon-name">emblem-favorite-symbolic</property>
+                <property name="icon-size">1</property>
+              </object>
+            </child>
           </object>
           <packing>
             <property name="pack-type">end</property>
@@ -467,9 +492,16 @@ followed</property>
         </child>
         <child>
           <object class="GtkButton" id="export_button">
-            <property name="use-underline">1</property>
-            <property name="label" translatable="yes">_Export</property>
+            <property name="tooltip-text" translatable="yes">Export</property>
             <signal name="clicked" handler="export_recipe" swapped="yes"/>
+            <style> <class name="image-button"/> </style>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">1</property>
+                <property name="icon-name">emblem-shared-symbolic</property>
+                <property name="icon-size">1</property>
+              </object>
+            </child>
           </object>
           <packing>
             <property name="pack-type">end</property>
@@ -478,9 +510,16 @@ followed</property>
         <child>
           <object class="GtkButton">
             <property name="visible">1</property>
-            <property name="use-underline">1</property>
-            <property name="label" translatable="yes">_Print</property>
+            <property name="tooltip-text" translatable="yes">Print</property>
             <signal name="clicked" handler="print_recipe" swapped="yes"/>
+            <style> <class name="image-button"/> </style>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">1</property>
+                <property name="icon-name">printer-symbolic</property>
+                <property name="icon-size">1</property>
+              </object>
+            </child>
           </object>
           <packing>
             <property name="pack-type">end</property>


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