gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] branch master updated: work on payment logic


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated: work on payment logic
Date: Fri, 12 Mar 2021 19:25:46 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository anastasis-gtk.

The following commit(s) were added to refs/heads/master by this push:
     new f5c5490  work on payment logic
f5c5490 is described below

commit f5c5490c95ad5f819b90d691c54cc571fb7f927c
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Mar 12 19:25:43 2021 +0100

    work on payment logic
---
 contrib/anastasis_gtk_main_window.glade            |  82 ++--------------
 src/anastasis/anastasis-gtk_action.c               | 105 ++++++++++++++++++---
 ...anastasis-gtk_handle-main-window-back-clicked.c |   6 ++
 3 files changed, 108 insertions(+), 85 deletions(-)

diff --git a/contrib/anastasis_gtk_main_window.glade 
b/contrib/anastasis_gtk_main_window.glade
index 0df7746..4472c4e 100644
--- a/contrib/anastasis_gtk_main_window.glade
+++ b/contrib/anastasis_gtk_main_window.glade
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.38.2
+<!-- Generated with glade 3.38.2 
 
 Copyright (C) Anastasis SARL
 
@@ -79,6 +79,10 @@ Author: Christian Grothoff, Dennis Neufeld
     <columns>
       <!-- column-name qr -->
       <column type="GdkPixbuf"/>
+      <!-- column-name url -->
+      <column type="gchararray"/>
+      <!-- column-name provider -->
+      <column type="gchararray"/>
     </columns>
   </object>
   <object class="GtkTreeStore" id="policy_review_treestore">
@@ -103,6 +107,10 @@ Author: Christian Grothoff, Dennis Neufeld
     <columns>
       <!-- column-name qr -->
       <column type="GdkPixbuf"/>
+      <!-- column-name url -->
+      <column type="gchararray"/>
+      <!-- column-name provider -->
+      <column type="gchararray"/>
     </columns>
   </object>
   <object class="GtkWindow" id="anastasis_gtk_main_window">
@@ -1428,78 +1436,6 @@ Author: Christian Grothoff, Dennis Neufeld
                                             <property 
name="position">1</property>
                                           </packing>
                                         </child>
-                                        <child>
-                                          <object class="GtkBox">
-                                            <property 
name="visible">True</property>
-                                            <property 
name="can-focus">False</property>
-                                            <property 
name="orientation">vertical</property>
-                                            <child>
-                                              <object class="GtkLabel">
-                                                <property 
name="visible">True</property>
-                                                <property 
name="can-focus">False</property>
-                                                <property name="label" 
translatable="yes">Paid:</property>
-                                              </object>
-                                              <packing>
-                                                <property 
name="expand">False</property>
-                                                <property 
name="fill">False</property>
-                                                <property 
name="padding">5</property>
-                                                <property 
name="position">0</property>
-                                              </packing>
-                                            </child>
-                                            <child>
-                                              <object 
class="GtkScrolledWindow">
-                                                <property 
name="visible">True</property>
-                                                <property 
name="can-focus">True</property>
-                                                <property 
name="vscrollbar-policy">never</property>
-                                                <property 
name="shadow-type">etched-out</property>
-                                                <child>
-                                                  <object class="GtkViewport">
-                                                    <property 
name="visible">True</property>
-                                                    <property 
name="can-focus">False</property>
-                                                    <child>
-                                                      <object 
class="GtkTreeView" id="paid_qr_treeview">
-                                                        <property 
name="visible">True</property>
-                                                        <property 
name="sensitive">False</property>
-                                                        <property 
name="can-focus">True</property>
-                                                        <property 
name="model">paid_qrcodes_liststore</property>
-                                                        <property 
name="headers-visible">False</property>
-                                                        <property 
name="enable-search">False</property>
-                                                        <child 
internal-child="selection">
-                                                          <object 
class="GtkTreeSelection">
-                                                            <property 
name="mode">none</property>
-                                                          </object>
-                                                        </child>
-                                                        <child>
-                                                          <object 
class="GtkTreeViewColumn" id="paid_qr_column">
-                                                            <property 
name="title" translatable="yes">Paid</property>
-                                                            <child>
-                                                            <object 
class="GtkCellRendererPixbuf" id="paid_pixbuf"/>
-                                                            <attributes>
-                                                            <attribute 
name="pixbuf">0</attribute>
-                                                            </attributes>
-                                                            </child>
-                                                          </object>
-                                                        </child>
-                                                      </object>
-                                                    </child>
-                                                  </object>
-                                                </child>
-                                              </object>
-                                              <packing>
-                                                <property 
name="expand">False</property>
-                                                <property 
name="fill">True</property>
-                                                <property 
name="padding">5</property>
-                                                <property 
name="position">1</property>
-                                              </packing>
-                                            </child>
-                                          </object>
-                                          <packing>
-                                            <property 
name="expand">False</property>
-                                            <property 
name="fill">True</property>
-                                            <property 
name="padding">5</property>
-                                            <property 
name="position">2</property>
-                                          </packing>
-                                        </child>
                                       </object>
                                     </child>
                                   </object>
diff --git a/src/anastasis/anastasis-gtk_action.c 
b/src/anastasis/anastasis-gtk_action.c
index cd506cc..02d7d68 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -26,6 +26,7 @@
  */
 #include <gnunet/platform.h>
 #include <gnunet/gnunet_util_lib.h>
+#include "anastasis-gtk_action.h"
 #include "anastasis-gtk_dispatch.h"
 #include "anastasis-gtk_helper.h"
 #include "anastasis-gtk_handle-identity-changed.h"
@@ -995,15 +996,73 @@ setup_qrcode (const char *widget,
 static void
 action_truths_paying (void)
 {
+  json_t *pprs;
+  size_t index;
+  json_t *pt;
+
   AG_hide_all_frames ();
-  GNUNET_break (0);
-  // FIXME: show payment QR codes!
-  AG_sensitive ("anastasis_gtk_main_window_prev_button");
 
+  pprs = json_object_get (redux_state,
+                          "payments");
+  json_array_foreach (pprs, index, pt)
+  {
+    const char *payto = json_string_value (pt);
+    GdkPixbuf *pb;
+
+    if (NULL == payto)
+    {
+      GNUNET_break (0);
+      continue;
+    }
+    pb = setup_qrcode ("anastasis_gtk_pay_qrcode_image",
+                       payto);
+    if (NULL == pb)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  _ ("Failed to initialize QR-code pixbuf for `%s'\n"),
+                  payto);
+      continue;
+    }
+
+    {
+      GtkListStore *ls;
+
+      ls = GTK_LIST_STORE (GCG_get_main_window_object (
+                             "unpaid_qrcodes_liststore"));
+      gtk_list_store_insert_with_values (ls,
+                                         NULL,
+                                         -1, /* append */
+                                         0, pb,
+                                         1, payto,
+                                         2, "",
+                                         -1);
+    }
+    if (0 == index)
+    {
+      GtkImage *image;
+      json_t *args;
+
+      image = GTK_IMAGE (GCG_get_main_window_object (
+                           "anastasis_gtk_pay_qrcode_image"));
+      gtk_image_set_from_pixbuf (image,
+                                 pb);
+      GNUNET_assert (NULL == ra);
+      args = json_pack ("{s:s}",
+                        "payto_uri",
+                        payto);
+      ra = ANASTASIS_redux_action (redux_state,
+                                   "await_payment",
+                                   args,
+                                   &AG_action_cb,
+                                   NULL);
+      json_decref (args);
+    }
+    g_object_unref (pb);
+  }
   AG_show ("anastasis_gtk_pay_frame");
   AG_show ("anastasis_gtk_pay_image");
   AG_show ("anastasis_gtk_main_control_vbox");
-  AG_show ("anastasis_gtk_main_window_prev_button");
+  AG_hide ("anastasis_gtk_main_window_prev_button");
   AG_hide ("anastasis_gtk_main_window_forward_button");
 }
 
@@ -1039,9 +1098,7 @@ action_policies_paying (void)
       GNUNET_break (0);
       continue;
     }
-    // FIXME: show payment QR codes!
-
-    pb = setup_qrcode ("wiget_name",
+    pb = setup_qrcode ("anastasis_gtk_pay_qrcode_image",
                        payto);
     if (NULL == pb)
     {
@@ -1051,21 +1108,45 @@ action_policies_paying (void)
       continue;
     }
 
+    {
+      GtkListStore *ls;
+
+      ls = GTK_LIST_STORE (GCG_get_main_window_object (
+                             "unpaid_qrcodes_liststore"));
+      gtk_list_store_insert_with_values (ls,
+                                         NULL,
+                                         -1, /* append */
+                                         0, pb,
+                                         1, payto,
+                                         2, provider,
+                                         -1);
+    }
+    if (0 == index)
     {
       GtkImage *image;
+      json_t *args;
 
-      image = NULL; // FIXME!
+      image = GTK_IMAGE (GCG_get_main_window_object (
+                           "anastasis_gtk_pay_qrcode_image"));
       gtk_image_set_from_pixbuf (image,
                                  pb);
-      g_object_unref (pb);
+      GNUNET_assert (NULL == ra);
+      args = json_pack ("{s:s}",
+                        "payto_uri",
+                        payto);
+      ra = ANASTASIS_redux_action (redux_state,
+                                   "await_payment",
+                                   args,
+                                   &AG_action_cb,
+                                   NULL);
+      json_decref (args);
     }
+    g_object_unref (pb);
   }
-  AG_sensitive ("anastasis_gtk_main_window_prev_button");
-
   AG_show ("anastasis_gtk_pay_frame");
   AG_show ("anastasis_gtk_pay_image");
   AG_show ("anastasis_gtk_main_control_vbox");
-  AG_show ("anastasis_gtk_main_window_prev_button");
+  AG_hide ("anastasis_gtk_main_window_prev_button");
   AG_hide ("anastasis_gtk_main_window_forward_button");
 }
 
diff --git a/src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c 
b/src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c
index 41cb512..45cf903 100644
--- a/src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c
+++ b/src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c
@@ -42,6 +42,12 @@ anastasis_gtk_main_window_back_clicked (GObject *object,
                                         gpointer user_data)
 {
   AG_freeze ();
+  if (NULL != ra)
+  {
+    /* This happens if we were long polling for payment */
+    ANASTASIS_redux_action_cancel (ra);
+    ra = NULL;
+  }
   ra = ANASTASIS_redux_action (redux_state,
                                "back",
                                NULL,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]