[recipes/todoist: 3/3] onClick Add service, switch_dialog_contents(function doesn't work yet) gets called



commit 98577a8ce496a1036c2d41e3ccb4ce50bcdf39fa
Author: Ekta Nandwani <mailnandwaniekta gmail com>
Date:   Tue Jul 4 23:55:11 2017 +0530

    onClick Add service, switch_dialog_contents(function doesn't work yet) gets called

 src/gr-ingredients-exporter.c      |  100 +++++++++------
 src/ingredients-exporter-dialog.ui |  255 ++++++++++++++++--------------------
 2 files changed, 174 insertions(+), 181 deletions(-)
---
diff --git a/src/gr-ingredients-exporter.c b/src/gr-ingredients-exporter.c
index 76a328d..fd2ac06 100644
--- a/src/gr-ingredients-exporter.c
+++ b/src/gr-ingredients-exporter.c
@@ -23,7 +23,7 @@
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
 #include <gtk/gtk.h>
- #include <goa/goa.h>
+#include <goa/goa.h>
 
 #include "gr-ingredients-exporter.h"
 
@@ -75,15 +75,30 @@ gr_ingredients_exporter_new (GtkWindow *parent)
 }
 
 static void
+switch_dialog_contents (GrIngredientsExporter *exporter,
+                                               GtkBuilder *builder)
+{
+       g_print("do_something");
+       GtkWidget *accounts_box;
+
+       accounts_box = GTK_WIDGET (gtk_builder_get_object (builder, "accounts_box"));
+       gtk_widget_set_visible (accounts_box, FALSE);
+}
+
+static void
 show_export_dialog (GrIngredientsExporter *exporter)
 {
         g_autoptr(GtkBuilder) builder = NULL;
         GtkWidget *dialog;
+        GObject *add_service;
 
 
-                builder = gtk_builder_new_from_resource 
("/org/gnome/Recipes/ingredients-exporter-dialog.ui");
+        builder = gtk_builder_new_from_resource ("/org/gnome/Recipes/ingredients-exporter-dialog.ui");
         dialog = GTK_WIDGET (gtk_builder_get_object (builder, "dialog"));
-        exporter->todoist_row = GTK_WIDGET (gtk_builder_get_object (builder, "todoist_row"));
+        exporter->todoist_row = GTK_WIDGET (gtk_builder_get_object (builder, "todoist_account_row"));
+        add_service = gtk_builder_get_object (builder, "add_service");
+
+        g_signal_connect (add_service, "activate-link", G_CALLBACK (switch_dialog_contents), builder);
 
 
         GoaClient *client;
@@ -93,47 +108,52 @@ show_export_dialog (GrIngredientsExporter *exporter)
 
            client = goa_client_new_sync (NULL, &error);
            
-  if (!client) {
-    g_error ("Could not create GoaClient: %s", error->message);
-    return 1;
-  }
-
-  accounts = goa_client_get_accounts (client);
-  for (l = accounts; l != NULL; l = l->next) {
-    GoaOAuth2Based *oauth2 = NULL;
-
-    account = goa_object_get_account (GOA_OBJECT (l->data));
-    if (strcmp (goa_account_get_provider_name (account), "Todoist"))
-    {
-       gtk_widget_set_visible (exporter->todoist_row, TRUE);
-    }
-    g_print ("%s at %s (%s)\n",
-             goa_account_get_presentation_identity (account),
-             goa_account_get_provider_name (account),
-             goa_account_get_provider_type (account));
-    oauth2 = goa_object_get_oauth2_based (GOA_OBJECT (l->data));
-    if (oauth2) {
-      gchar *access_token;
-      if (goa_oauth2_based_call_get_access_token_sync (oauth2,
-                                                       &access_token,
-                                                       NULL,
-                                                       NULL,
-                                                       NULL)) {
-        g_print ("\tAccessToken: %s\n", access_token);
-        g_free (access_token);
-      }
-      g_print ("\tClientId: %s\n\tClientSecret: %s\n",
-               goa_oauth2_based_get_client_id (oauth2),
-               goa_oauth2_based_get_client_secret (oauth2));
-    }
-    g_clear_object (&oauth2);
-  }
+           if (!client)
+           {
+                       g_error ("Could not create GoaClient: %s", error->message);
+                       return;
+               }
+
+               accounts = goa_client_get_accounts (client);
+               for (l = accounts; l != NULL; l = l->next)
+               {
+                       GoaOAuth2Based *oauth2 = NULL;
+
+                       account = goa_object_get_account (GOA_OBJECT (l->data));
+                           if (strcmp (goa_account_get_provider_name (account), "Todoist"))
+                           {
+                               gtk_widget_set_visible (exporter->todoist_row, TRUE);
+                           }
+                           g_print ("%s at %s (%s)\n",
+                                    goa_account_get_presentation_identity (account),
+                                    goa_account_get_provider_name (account),
+                                    goa_account_get_provider_type (account));
+                           oauth2 = goa_object_get_oauth2_based (GOA_OBJECT (l->data));
+                       if (oauth2)
+                       {
+                                       gchar *access_token;
+                                       if (goa_oauth2_based_call_get_access_token_sync (oauth2,
+                                                                                      &access_token,
+                                                                                      NULL,
+                                                                                      NULL,
+                                                                                      NULL))
+                                       {
+                                       g_print ("\tAccessToken: %s\n", access_token);
+                                       g_free (access_token);
+                                       }
+                                       g_print ("\tClientId: %s\n\tClientSecret: %s\n",
+                               goa_oauth2_based_get_client_id (oauth2),
+                               goa_oauth2_based_get_client_secret (oauth2));
+                       }
+                       g_clear_object (&oauth2);
+               }
 
         //GtkWidget *list;
-
-
         //gtk_widget_set_visible (exporter->todoist_row, TRUE);
 
+        //gtk_builder_add_callback_symbol (GtkBuilder *builder, const gchar *callback_name,
+        //                         GCallback callback_symbol);
+
         gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (exporter->window));
         gtk_widget_show (dialog);
 }
diff --git a/src/ingredients-exporter-dialog.ui b/src/ingredients-exporter-dialog.ui
index c716699..1182504 100644
--- a/src/ingredients-exporter-dialog.ui
+++ b/src/ingredients-exporter-dialog.ui
@@ -20,180 +20,153 @@
         <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">
-        <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="GtkStack" id="dialog_stack">
+        <property name="visible">1</property>
+        <child internal-child="vbox">
+          <object class="GtkBox" id="accounts_box">
+            <property name="margin">20</property>
+            <property name="spacing">20</property>
             <child>
-              <object class="GtkListBoxRow" id="google_stub_row">
+              <object class="GtkListBox" id="accounts_list">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
+                <property name="selection_mode">none</property>
                 <child>
-                  <object class="GtkGrid" id="google_stub_grid">
+                  <object class="GtkListBoxRow">
                     <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>
+                    <property name="can_focus">True</property>
                     <child>
-                      <object class="GtkLabel" id="google_account_label">
+                      <object class="GtkGrid">
                         <property name="visible">True</property>
-                        <property name="label" translatable="yes">Email</property>
-                        <property name="xalign">0</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">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">
+                            <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>
-                      <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>
+                  <object class="GtkListBoxRow" id="todoist_account_row">
+                    <!-- <property name="visible">True</property> -->
+                    <property name="can_focus">True</property>
                     <child>
-                      <object class="GtkImage" id="todoist_image">
+                      <object class="GtkGrid">
                         <property name="visible">True</property>
-                        <property name="pixel_size">32</property>
-                        <property name="icon_name">goa-account-todoist</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">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>
-                      <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 class="GtkLabel" id="add_service">
+                <property name="label">&lt;a href=&quot;&quot;&gt;Add service&lt;/a&gt;</property>
+                 <property name="visible">True</property>
+                 <property name="use_markup">True</property>
+                 <property name="use_underline">0</property>
               </object>
             </child>
+          </object>
+        </child>
+        <child internal-child="vbox">
+          <object class="GtkBox" id="providers_box">
             <child>
-              <object class="GtkListBoxRow" id="owncloud_stub_row">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
+              <object class="GtkListBox" id="providers_list">
+                <property name="selection_mode">none</property>
                 <child>
-                  <object class="GtkGrid" id="owncloud_stub_grid">
+                  <object class="GtkListBoxRow" id="todoist_provider_row">
                     <property name="visible">True</property>
-                    <property name="border_width">6</property>
-                    <property name="margin_end">18</property>
-                    <property name="column_spacing">12</property>
+                    <property name="can_focus">True</property>
                     <child>
-                      <object class="GtkImage" id="owncloud_account_image">
+                      <object class="GtkGrid" >
                         <property name="visible">True</property>
-                        <property name="pixel_size">32</property>
-                        <property name="icon_name">goa-account-todoist</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">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">
+                            <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>
-                      <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>
+            </object>
+          </child>
+        </object>
+      </child>
+    </object>
   </child>
     <action-widgets>
       <action-widget response="cancel">button_later</action-widget>


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