[recipes/todoist: 1/3] visual elements in place



commit dc4dc9f73709b897b24e3b353725b78c76f03b0f
Author: Ekta Nandwani <mailnandwaniekta gmail com>
Date:   Sat Jul 1 19:17:49 2017 +0530

    visual elements in place

 data/gschemas.compiled             |  Bin 0 -> 904 bytes
 meson.build                        |    1 +
 src/gr-ingredients-exporter.c      |   90 ++++++++++++++++
 src/gr-ingredients-exporter.h      |   36 +++++++
 src/gr-recipe-exporter.c           |   61 ++++++-----
 src/gr-shopping-page.c             |   56 +++++++---
 src/ingredients-exporter-dialog.ui |  203 ++++++++++++++++++++++++++++++++++++
 src/meson.build                    |    1 +
 src/recipes.gresource.xml          |    1 +
 9 files changed, 407 insertions(+), 42 deletions(-)
---
diff --git a/data/gschemas.compiled b/data/gschemas.compiled
new file mode 100644
index 0000000..27bfa4e
Binary files /dev/null and b/data/gschemas.compiled differ
diff --git a/meson.build b/meson.build
index 8c14e25..ed3d7ca 100644
--- a/meson.build
+++ b/meson.build
@@ -82,6 +82,7 @@ endif
 deps = [ dependency('gtk+-3.0', version : '>=3.22'),
          dependency('gmodule-export-2.0'),
          dependency('libsoup-2.4'),
+         dependency('goa-1.0'),
          autoar_dep,
          gspell_dep,
          canberra_dep,
diff --git a/src/gr-ingredients-exporter.c b/src/gr-ingredients-exporter.c
new file mode 100644
index 0000000..5add85c
--- /dev/null
+++ b/src/gr-ingredients-exporter.c
@@ -0,0 +1,90 @@
+/* gr-ingredients-exporter.c:
+ *
+ *
+ * Licensed under the GNU General Public License Version 3
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+#include <gtk/gtk.h>
+
+#include "gr-ingredients-exporter.h"
+
+ struct _GrIngredientsExporter
+{
+        GObject parent_instance;
+        GtkWindow *window;
+};
+
+
+G_DEFINE_TYPE (GrIngredientsExporter, gr_ingredients_exporter, G_TYPE_OBJECT)
+
+static void
+gr_ingredients_exporter_finalize (GObject *object)
+{
+        GrIngredientsExporter *exporter = GR_INGREDIENTS_EXPORTER (object);
+
+        G_OBJECT_CLASS (gr_ingredients_exporter_parent_class)->finalize (object);
+}
+
+
+static void
+gr_ingredients_exporter_class_init (GrIngredientsExporterClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->finalize = gr_ingredients_exporter_finalize;
+}
+
+static void
+gr_ingredients_exporter_init (GrIngredientsExporter *self)
+{
+}
+
+GrIngredientsExporter *
+gr_ingredients_exporter_new (GtkWindow *parent)
+{
+        GrIngredientsExporter *exporter;
+
+        exporter = g_object_new (GR_TYPE_INGREDIENTS_EXPORTER, NULL);
+
+        exporter->window = parent;
+
+        return exporter;
+}
+
+static void
+show_export_dialog (GrIngredientsExporter *exporter)
+{
+        g_autoptr(GtkBuilder) builder = NULL;
+        GtkWidget *dialog;
+        //GtkWidget *list;
+
+        builder = gtk_builder_new_from_resource ("/org/gnome/Recipes/ingredients-exporter-dialog.ui");
+        dialog = GTK_WIDGET (gtk_builder_get_object (builder, "dialog"));
+
+        gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (exporter->window));
+        gtk_widget_show (dialog);
+}
+
+void
+gr_ingredients_exporter_export (GrIngredientsExporter *exporter)
+{
+
+        show_export_dialog (exporter);
+}
diff --git a/src/gr-ingredients-exporter.h b/src/gr-ingredients-exporter.h
new file mode 100644
index 0000000..b8986e8
--- /dev/null
+++ b/src/gr-ingredients-exporter.h
@@ -0,0 +1,36 @@
+/* gr-recipe-exporter.h:
+ *
+ * Copyright (C) 2016 Matthias Clasen <mclasen redhat com>
+ *
+ * Licensed under the GNU General Public License Version 3
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+#include "gr-recipe.h"
+
+G_BEGIN_DECLS
+
+#define GR_TYPE_INGREDIENTS_EXPORTER (gr_ingredients_exporter_get_type())
+
+G_DECLARE_FINAL_TYPE (GrIngredientsExporter, gr_ingredients_exporter, GR, INGREDIENTS_EXPORTER, GObject)
+
+GrIngredientsExporter *gr_ingredients_exporter_new    (GtkWindow        *window);
+
+void              gr_ingredients_exporter_export (GrIngredientsExporter *exporter);
+
+G_END_DECLS
\ No newline at end of file
diff --git a/src/gr-recipe-exporter.c b/src/gr-recipe-exporter.c
index 7c21328..7c2e83c 100644
--- a/src/gr-recipe-exporter.c
+++ b/src/gr-recipe-exporter.c
@@ -1,23 +1,23 @@
-/* gr-recipe-exporter.c:
- *
- * Copyright (C) 2016 Matthias Clasen <mclasen redhat com>
- *
- * Licensed under the GNU General Public License Version 3
-    <file preprocess="xml-stripblanks">gr-big-cuisine-tile.ui</file>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
+    /* gr-recipe-exporter.c:
+     *
+     * Copyright (C) 2016 Matthias Clasen <mclasen redhat com>
+     *
+     * Licensed under the GNU General Public License Version 3
+        <file preprocess="xml-stripblanks">gr-big-cuisine-tile.ui</file>
+     *
+     * This program is free software: you can redistribute it and/or modify
+     * it under the terms of the GNU General Public License as published by
+     * the Free Software Foundation, either version 3 of the License, or
+     * (at your option) any later version.
+     *
+     * This program is distributed in the hope that it will be useful,
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+     * GNU General Public License for more details.
+     *
+     * You should have received a copy of the GNU General Public License
+     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+     */
 
 #include "config.h"
 
@@ -83,7 +83,8 @@ static guint done_signal;
 
 static void
 gr_recipe_exporter_class_init (GrRecipeExporterClass *klass)
-{
+{       
+        g_print("gr_recipe_exporter_class_init\n");
         GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
         object_class->finalize = gr_recipe_exporter_finalize;
@@ -100,11 +101,13 @@ gr_recipe_exporter_class_init (GrRecipeExporterClass *klass)
 static void
 gr_recipe_exporter_init (GrRecipeExporter *self)
 {
+        g_print("gr_recipe_exporter_init\n");
 }
 
 GrRecipeExporter *
 gr_recipe_exporter_new (GtkWindow *parent)
-{
+{   
+        g_print("gr_recipe_exporter_new\n");
         GrRecipeExporter *exporter;
 
         exporter = g_object_new (GR_TYPE_RECIPE_EXPORTER, NULL);
@@ -117,6 +120,7 @@ gr_recipe_exporter_new (GtkWindow *parent)
 static void
 cleanup_export (GrRecipeExporter *exporter)
 {
+    g_print("cleanup_export\n");
 #ifdef ENABLE_AUTOAR
         g_clear_object (&exporter->compressor);
 #endif
@@ -139,7 +143,8 @@ static void
 file_chooser_response (GtkNativeDialog  *self,
                        int               response_id,
                        GrRecipeExporter *exporter)
-{
+{       
+    g_print("file_chooser_response\n");
         if (response_id == GTK_RESPONSE_ACCEPT) {
                 g_autoptr(GFile) file = NULL;
 
@@ -156,7 +161,8 @@ static void
 mail_done (GObject      *source,
            GAsyncResult *result,
            gpointer      data)
-{
+{       
+    g_print("mail_done\n");
         GrRecipeExporter *exporter = data;
         g_autoptr(GError) error = NULL;
 
@@ -185,6 +191,7 @@ static void
 completed_cb (AutoarCompressor *compressor,
               GrRecipeExporter *exporter)
 {
+        g_print("completed_cb\n");
         g_autofree char *path = NULL;
         const char *address;
         const char *subject;
@@ -259,7 +266,7 @@ export_one_recipe (GrRecipeExporter  *exporter,
                    GrRecipe          *recipe,
                    GKeyFile          *keyfile,
                    GError           **error)
-{
+{       g_print("export_one_recipe\n");
         const char *key;
         const char *name;
         const char *author;
@@ -381,7 +388,7 @@ export_one_chef (GrRecipeExporter  *exporter,
                  GrChef            *chef,
                  GKeyFile          *keyfile,
                  GError           **error)
-{
+{       g_print("export_one_chef\n");
         const char *key;
         const char *name;
         const char *fullname;
@@ -431,7 +438,7 @@ export_one_chef (GrRecipeExporter  *exporter,
 static gboolean
 prepare_export (GrRecipeExporter  *exporter,
                 GError           **error)
-{
+{g_print("prepare_export\n");
 #ifndef ENABLE_AUTOAR
         g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                      _("This build does not support exporting"));
diff --git a/src/gr-shopping-page.c b/src/gr-shopping-page.c
index ba3387c..bb0c4c5 100644
--- a/src/gr-shopping-page.c
+++ b/src/gr-shopping-page.c
@@ -18,10 +18,13 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#define GOA_API_IS_SUBJECT_TO_CHANGE 
+
 #include "config.h"
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
+#include <goa/goa.h>
 
 #include "gr-shopping-page.h"
 #include "gr-shopping-tile.h"
@@ -34,6 +37,9 @@
 #include "gr-shopping-list-printer.h"
 #include "gr-shopping-list-formatter.h"
 #include "gr-mail.h"
+#include "gr-ingredients-exporter.h"
+
+
 
 
 struct _GrShoppingPage
@@ -50,6 +56,7 @@ struct _GrShoppingPage
         int ingredient_count;
         int recipe_count;
         GrRecipeSearch *search;
+        GrIngredientsExporter *exporter;
 
         GtkSizeGroup *group;
         GHashTable *ingredients;
@@ -746,28 +753,47 @@ mail_done (GObject      *source,
         }
 }
 
-static void
-share_list (GrShoppingPage *page)
-{
-        GList *recipes, *items;
-        g_autofree char *text = NULL;
-        GtkWidget *window;
+// static void
+// share_list (GrShoppingPage *page)
+// {
+//         // GtkWidget *test = gtk_dialog_new();
+//         // gtk_widget_show (test);
 
-        recipes = get_recipes (page);
-        items = get_ingredients (page);
+//         GList *recipes, *items;
+//         g_autofree char *text = NULL;
+//         GtkWidget *window;
 
-        text = gr_shopping_list_format (recipes, items);
+//         recipes = get_recipes (page);
+//         items = get_ingredients (page);
 
-        window = gtk_widget_get_ancestor (GTK_WIDGET (page), GTK_TYPE_APPLICATION_WINDOW);
+//         text = gr_shopping_list_format (recipes, items);
 
-        gr_send_mail (GTK_WINDOW (window),
-                      NULL, _("Shopping List"), text, NULL,
-                      mail_done, page);
+//         window = gtk_widget_get_ancestor (GTK_WIDGET (page), GTK_TYPE_APPLICATION_WINDOW);
 
-        g_list_free_full (recipes, g_object_unref);
-        g_list_free_full (items, item_free);
+//         gr_send_mail (GTK_WINDOW (window),
+//                       NULL, _("Shopping List"), text, NULL,
+//                       mail_done, page);
+
+//         g_list_free_full (recipes, g_object_unref);
+//         g_list_free_full (items, item_free);
+// }
+
+static void
+share_list (GrShoppingPage *page)
+{
+    g_print("inside share");
+     if (!page->exporter) {
+                GtkWidget *window;
+
+                window = gtk_widget_get_ancestor (GTK_WIDGET (page), GTK_TYPE_APPLICATION_WINDOW);
+                page->exporter = gr_ingredients_exporter_new(GTK_WINDOW (window));
+        }
+
+        gr_ingredients_exporter_export (page->exporter);
+        //gr_ingredients_exporter_new ();
 }
 
+
 static void
 gr_shopping_page_init (GrShoppingPage *page)
 {
diff --git a/src/ingredients-exporter-dialog.ui b/src/ingredients-exporter-dialog.ui
new file mode 100644
index 0000000..c716699
--- /dev/null
+++ b/src/ingredients-exporter-dialog.ui
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="gnome-recipes">
+  <object class="GtkDialog" id="dialog">
+    <property name="use-header-bar">1</property>
+    <property name="modal">1</property>
+    <property name="resizable">0</property>
+    <property name="destroy-with-parent">1</property>
+    <property name="default-width">420</property>
+    <property name="default-height">280</property>
+    <property name="title"> Export Ingredients</property>
+    <child type="action">
+      <object class="GtkButton" id="button_later">
+        <property name="visible">1</property>
+        <property name="use-underline">1</property>
+        <property name="label" translatable="yes">_Cancel</property>
+      </object>
+    </child>
+    <child type="action">
+      <object class="GtkButton" id="button_now">
+        <property name="visible">1</property>
+        <property name="use-underline">1</property>
+        <property name="label" translatable="yes">Export</property>
+      </object>
+    </child>
+    <child internal-child="vbox">
+      <object class="GtkBox">
+        <property name="margin">20</property>
+        <property name="spacing">20</property>
+                <child>
+          <object class="GtkStack" id="unit_stack">
+            <property name="visible">1</property>
+        <child>
+          <object class="GtkListBox" id="online_accounts_listbox">
+            <property name="visible">True</property>
+            <property name="selection_mode">none</property>
+            <signal name="row-activated" handler="online_accounts_listbox_row_activated" 
object="GcalSourceDialog" swapped="no"/>
+            <child>
+              <object class="GtkListBoxRow" id="google_stub_row">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <child>
+                  <object class="GtkGrid" id="google_stub_grid">
+                    <property name="visible">True</property>
+                    <property name="border_width">6</property>
+                    <property name="margin_end">18</property>
+                    <property name="column_spacing">12</property>
+                    <child>
+                      <object class="GtkImage" id="google_account_image">
+                        <property name="visible">True</property>
+                        <property name="pixel_size">32</property>
+                        <property name="icon_name">mail-unread-symbolic</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                        <property name="height">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="google_account_label">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Email</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkListBoxRow" id="todoist_row">
+                <!-- <property name="visible">True</property> -->
+                <property name="can_focus">True</property>
+                <child>
+                  <object class="GtkGrid">
+                    <property name="visible">True</property>
+                    <property name="border_width">6</property>
+                    <property name="margin_end">18</property>
+                    <property name="column_spacing">12</property>
+                    <child>
+                      <object class="GtkImage" id="todoist_image">
+                        <property name="visible">True</property>
+                        <property name="pixel_size">32</property>
+                        <property name="icon_name">goa-account-todoist</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                        <property name="height">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="todoist_label">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Todoist</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+<!--         <child>
+          <object class="GtkListBox" id="online_accounts_listbox2">
+            <property name="visible">True</property>
+            <property name="selection_mode">none</property>
+            <signal name="row-activated" handler="online_accounts_listbox_row_activated" 
object="GcalSourceDialog" swapped="no"/>
+            <child>
+              <object class="GtkListBoxRow" id="google_stub_row">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <child>
+                  <object class="GtkGrid" id="google_stub_grid">
+                    <property name="visible">True</property>
+                    <property name="border_width">6</property>
+                    <property name="margin_end">18</property>
+                    <property name="column_spacing">12</property>
+                    <child>
+                      <object class="GtkImage" id="google_account_image">
+                        <property name="visible">True</property>
+                        <property name="pixel_size">32</property>
+                        <property name="icon_name">mail-unread-symbolic</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                        <property name="height">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="google_account_label">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Email</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkListBoxRow" id="owncloud_stub_row">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <child>
+                  <object class="GtkGrid" id="owncloud_stub_grid">
+                    <property name="visible">True</property>
+                    <property name="border_width">6</property>
+                    <property name="margin_end">18</property>
+                    <property name="column_spacing">12</property>
+                    <child>
+                      <object class="GtkImage" id="owncloud_account_image">
+                        <property name="visible">True</property>
+                        <property name="pixel_size">32</property>
+                        <property name="icon_name">goa-account-todoist</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                        <property name="height">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="owncloud_account_label">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Todoist</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child> -->
+      </object>
+    </child>
+  </object>
+  </child>
+    <action-widgets>
+      <action-widget response="cancel">button_later</action-widget>
+      <action-widget response="ok">button_now</action-widget>
+    </action-widgets>
+  </object>
+</interface>
diff --git a/src/meson.build b/src/meson.build
index e9c7195..ad75754 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -66,6 +66,7 @@ src += ['main.c',
        'gr-image-page.c',
        'gr-ingredient.c',
        'gr-ingredient-row.c',
+       'gr-ingredients-exporter.c',
        'gr-ingredients-list.c',
        'gr-ingredients-viewer.c',
        'gr-ingredients-viewer-row.c',
diff --git a/src/recipes.gresource.xml b/src/recipes.gresource.xml
index dab6a2b..af31cbf 100644
--- a/src/recipes.gresource.xml
+++ b/src/recipes.gresource.xml
@@ -29,6 +29,7 @@
     <file preprocess="xml-stripblanks">gr-query-editor.ui</file>
     <file preprocess="xml-stripblanks">gr-window.ui</file>
     <file preprocess="xml-stripblanks">chef-conflict-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ingredients-exporter-dialog.ui</file>
     <file preprocess="xml-stripblanks">recipe-conflict-dialog.ui</file>
     <file preprocess="xml-stripblanks">recipe-export-dialog.ui</file>
     <file preprocess="xml-stripblanks">recipe-whats-new-dialog.ui</file>


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