[recipes/todoist] Back Button: functional
- From: Ekta Nandwani <ektan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes/todoist] Back Button: functional
- Date: Sun, 9 Jul 2017 10:43:34 +0000 (UTC)
commit a578ba73483e6b92f06a514cb81cf275d6ea5538
Author: Ekta Nandwani <mailnandwaniekta gmail com>
Date: Sun Jul 9 16:12:40 2017 +0530
Back Button: functional
src/gr-ingredients-exporter.c | 55 +++++--
src/gr-ingredients-exporter.h | 4 +-
src/gr-shopping-page.c | 6 +-
src/ingredients-exporter-dialog.ui | 323 ++++++++++++++++++------------------
4 files changed, 208 insertions(+), 180 deletions(-)
---
diff --git a/src/gr-ingredients-exporter.c b/src/gr-ingredients-exporter.c
index 15bdb7f..1cfbf7c 100644
--- a/src/gr-ingredients-exporter.c
+++ b/src/gr-ingredients-exporter.c
@@ -33,7 +33,9 @@
GObject parent_instance;
GtkWindow *window;
- GtkWidget *export_button;
+ GtkWidget *export_button;
+ GtkWidget *cancel_button;
+ GtkWidget *back_button;
GtkWidget *todoist_row;
GtkWidget *accounts_box;
GtkWidget *providers_box;
@@ -80,23 +82,43 @@ gr_ingredients_exporter_new (GtkWindow *parent)
}
static void
-switch_dialog_contents (GtkLabel *label, const char *uri, GrIngredientsExporter *exporter)
+switch_dialog_contents (GrIngredientsExporter *exporter)
{
- g_print("do_something");
- //GtkWidget *accounts_box;
- gtk_widget_set_visible (exporter->accounts_box, FALSE);
- if (!exporter->providers_box)
+ if (gtk_stack_get_visible_child (GTK_STACK (exporter->dialog_stack)) == exporter->accounts_box)
{
- g_print("providers_box empty");
- //gtk_widget_set_visible (exporter->providers_box, TRUE);
+ if (!exporter->providers_box)
+ g_print("providers_box empty");
+ gtk_widget_set_visible (exporter->export_button, FALSE);
+ gtk_stack_set_visible_child_name (GTK_STACK (exporter->dialog_stack), "providers_box");
+ gtk_stack_set_visible_child_name (GTK_STACK (exporter->header_start_stack), "back");
+ gtk_header_bar_set_title (GTK_HEADER_BAR (exporter->header), "Add Account");
}
- gtk_widget_set_visible (exporter->export_button, FALSE);
- gtk_stack_set_visible_child_name (GTK_STACK (exporter->dialog_stack), "providers_box");
- gtk_stack_set_visible_child_name (GTK_STACK (exporter->header_start_stack), "back");
- gtk_header_bar_set_title (GTK_HEADER_BAR (exporter->header), "Add Account");
+ else
+ // if (gtk_stack_get_visible_child (GTK_STACK (exporter->dialog_stack)) == exporter->providers_box)
+ {
+ gtk_widget_set_visible (exporter->export_button, TRUE);
+ gtk_stack_set_visible_child (GTK_STACK (exporter->dialog_stack), exporter->accounts_box);
+ gtk_stack_set_visible_child_name (GTK_STACK (exporter->header_start_stack), "cancel_button");
+ gtk_header_bar_set_title (GTK_HEADER_BAR (exporter->header), "Export Ingredients");
+ }
+ //gtk_widget_set_visible (exporter->accounts_box, FALSE);
+
+}
+
+static void
+export_shopping_list (GtkLabel *label, const char *uri, GrIngredientsExporter *exporter)
+{
+ g_print ("export_shopping_list\n");
}
static void
+cancel_export (GrIngredientsExporter *exporter)
+{
+ g_print ("cancel_export\n");
+}
+
+
+static void
show_export_dialog (GrIngredientsExporter *exporter)
{
g_autoptr(GtkBuilder) builder = NULL;
@@ -109,14 +131,19 @@ show_export_dialog (GrIngredientsExporter *exporter)
exporter->todoist_row = GTK_WIDGET (gtk_builder_get_object (builder, "todoist_account_row"));
add_service = gtk_builder_get_object (builder, "add_service");
- exporter->export_button = GTK_WIDGET (gtk_builder_get_object (builder, "export_button"));
+ exporter->export_button = GTK_WIDGET (gtk_builder_get_object (builder, "export_button"));
+ exporter->cancel_button = GTK_WIDGET (gtk_builder_get_object (builder, "cancel_button"));
+ exporter->back_button = GTK_WIDGET (gtk_builder_get_object (builder, "back_button"));
exporter->accounts_box = GTK_WIDGET (gtk_builder_get_object (builder, "accounts_box"));
exporter->providers_box = GTK_WIDGET (gtk_builder_get_object (builder, "providers_box"));
exporter->dialog_stack = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_stack"));
exporter->header_start_stack = GTK_WIDGET (gtk_builder_get_object (builder, "header_start_stack"));
exporter->header = GTK_WIDGET (gtk_builder_get_object (builder, "header"));
- g_signal_connect (add_service, "activate-link", G_CALLBACK (switch_dialog_contents), exporter);
+ g_signal_connect_swapped (add_service, "activate-link", G_CALLBACK (switch_dialog_contents),
exporter);
+ g_signal_connect_swapped (exporter->back_button, "clicked", G_CALLBACK (switch_dialog_contents),
exporter);
+ g_signal_connect (exporter->export_button, "clicked", G_CALLBACK (export_shopping_list), exporter);
+ g_signal_connect (exporter->cancel_button, "clicked", G_CALLBACK (cancel_export), exporter);
diff --git a/src/gr-ingredients-exporter.h b/src/gr-ingredients-exporter.h
index b8986e8..3de3ec6 100644
--- a/src/gr-ingredients-exporter.h
+++ b/src/gr-ingredients-exporter.h
@@ -1,6 +1,6 @@
-/* gr-recipe-exporter.h:
+/* gr-ingredients-exporter.h:
*
- * Copyright (C) 2016 Matthias Clasen <mclasen redhat com>
+ * Copyright (C) 2017 Ekta Nandwani
*
* Licensed under the GNU General Public License Version 3
*
diff --git a/src/gr-shopping-page.c b/src/gr-shopping-page.c
index bb0c4c5..e30888d 100644
--- a/src/gr-shopping-page.c
+++ b/src/gr-shopping-page.c
@@ -779,7 +779,7 @@ mail_done (GObject *source,
// }
static void
-share_list (GrShoppingPage *page)
+open_export_shopping_list_dialog (GrShoppingPage *page)
{
g_print("inside share");
if (!page->exporter) {
@@ -788,9 +788,7 @@ share_list (GrShoppingPage *page)
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 ();
}
@@ -875,7 +873,7 @@ gr_shopping_page_class_init (GrShoppingPageClass *klass)
gtk_widget_class_bind_template_callback (widget_class, clear_list);
gtk_widget_class_bind_template_callback (widget_class, print_list);
- gtk_widget_class_bind_template_callback (widget_class, share_list);
+ gtk_widget_class_bind_template_callback (widget_class, open_export_shopping_list_dialog);
gtk_widget_class_bind_template_callback (widget_class, row_activated);
gtk_widget_class_bind_template_callback (widget_class, removed_row_activated);
}
diff --git a/src/ingredients-exporter-dialog.ui b/src/ingredients-exporter-dialog.ui
index e0b6f41..775a2ad 100644
--- a/src/ingredients-exporter-dialog.ui
+++ b/src/ingredients-exporter-dialog.ui
@@ -49,174 +49,177 @@
</object>
</child>
<child type="action">
- <object class="GtkButton" id="export_button">
- <property name="visible">1</property>
- <property name="use-underline">1</property>
- <property name="label" translatable="yes">Export</property>
- <signal name="clicked" handler="show_providers"/>
- </object>
- </child>
- <child internal-child="vbox">
- <object class="GtkBox">
- <child>
- <object class="GtkStack" id="dialog_stack">
+ <object class="GtkButton" id="export_button">
<property name="visible">1</property>
+ <property name="use-underline">1</property>
+ <property name="label" translatable="yes">Export</property>
+ <signal name="clicked" handler="show_providers"/>
+ </object>
+ </child>
+ <child internal-child="vbox">
+ <object class="GtkBox">
<child>
- <object class="GtkBox" id="accounts_box">
- <property name="margin">20</property>
- <property name="spacing">20</property>
+ <object class="GtkStack" id="dialog_stack">
<property name="visible">1</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkListBox" id="accounts_list">
- <property name="visible">1</property>
- <property name="selection_mode">none</property>
- <style>
- <class name="frame"/>
- </style>
- <child>
- <object class="GtkListBoxRow">
- <property name="visible">1</property>
- <property name="can_focus">1</property>
- <child>
- <object class="GtkGrid">
- <property name="visible">1</property>
- <property name="border_width">6</property>
- <property name="margin_end">18</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkImage">
- <property name="visible">1</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>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">1</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_account_row">
- <!-- <property name="visible">1</property> -->
- <property name="can_focus">1</property>
- <child>
- <object class="GtkGrid">
- <property name="visible">1</property>
- <property name="border_width">6</property>
- <property name="margin_end">18</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkImage">
- <property name="visible">1</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>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="todoist_label">
- <property name="visible">1</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>
+ <child>
+ <object class="GtkBox" id="accounts_box">
+ <property name="margin">20</property>
+ <property name="spacing">20</property>
+ <property name="visible">1</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkListBox" id="accounts_list">
+ <property name="visible">1</property>
+ <property name="selection_mode">single</property>
+ <style>
+ <class name="frame"/>
+ </style>
+ <child>
+ <object class="GtkListBoxRow">
+ <property name="visible">1</property>
+ <property name="can_focus">1</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">1</property>
+ <property name="border_width">6</property>
+ <property name="margin_end">18</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">1</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>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">1</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_account_row">
+ <!-- <property name="visible">1</property> -->
+ <property name="can_focus">1</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">1</property>
+ <property name="border_width">6</property>
+ <property name="margin_end">18</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">1</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>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="todoist_label">
+ <property name="visible">1</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="GtkLabel" id="add_service">
+ <property name="label"><a href="">Add service</a></property>
+ <property name="visible">1</property>
+ <property name="use_markup">1</property>
+ <property name="use_underline">0</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="name">accounts_box</property>
+ </packing >
+ </child>
+ <child>
+ <object class="GtkBox" id="providers_box">
+ <property name="margin">20</property>
+ <property name="spacing">20</property>
+ <property name="visible">1</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkListBox" id="providers_list">
+ <property name="selection_mode">single</property>
+ <property name="visible">1</property>
+ <style>
+ <class name="frame"/>
+ </style>
+ <child>
+ <object class="GtkListBoxRow" id="todoist_provider_row">
+ <property name="visible">1</property>
+ <property name="can_focus">1</property>
+ <child>
+ <object class="GtkGrid" >
+ <property name="visible">1</property>
+ <property name="border_width">6</property>
+ <property name="margin_end">18</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">1</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>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">1</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>
- <child>
- <object class="GtkLabel" id="add_service">
- <property name="label"><a href="">Add service</a></property>
- <property name="visible">1</property>
- <property name="use_markup">1</property>
- <property name="use_underline">0</property>
- </object>
+ <packing>
+ <property name="name">providers_box</property>
+ </packing >
</child>
</object>
</child>
- <child>
- <object class="GtkBox" id="providers_box">
- <property name="margin">20</property>
- <property name="spacing">20</property>
- <property name="visible">1</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkListBox" id="providers_list">
- <property name="selection_mode">none</property>
- <property name="visible">1</property>
- <style>
- <class name="frame"/>
- </style>
- <child>
- <object class="GtkListBoxRow" id="todoist_provider_row">
- <property name="visible">1</property>
- <property name="can_focus">1</property>
- <child>
- <object class="GtkGrid" >
- <property name="visible">1</property>
- <property name="border_width">6</property>
- <property name="margin_end">18</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkImage">
- <property name="visible">1</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>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">1</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>
- <packing>
- <property name="name">providers_box</property>
- </packing >
- </child>
- </object>
- </child>
-</object>
-</child>
+ </object>
+ </child>
</object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]