gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] branch master updated: fix ugly challenge selectio


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated: fix ugly challenge selection buttons
Date: Sat, 26 Jun 2021 19:34:19 +0200

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 a04d2c2  fix ugly challenge selection buttons
a04d2c2 is described below

commit a04d2c2668e732809c900476e38c9ce6ae8176c2
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Jun 26 19:34:16 2021 +0200

    fix ugly challenge selection buttons
---
 contrib/anastasis_gtk_main_window.glade            | 199 ++++++-------
 src/anastasis/anastasis-gtk_action.c               | 331 +++++++++++----------
 .../anastasis-gtk_handle-challenge-row-activated.c |  95 ++++--
 .../anastasis-gtk_handle-policy-version-changed.c  |  24 --
 src/anastasis/anastasis-gtk_helper.h               |  18 +-
 5 files changed, 350 insertions(+), 317 deletions(-)

diff --git a/contrib/anastasis_gtk_main_window.glade 
b/contrib/anastasis_gtk_main_window.glade
index 7f0e1a1..7a2e6b6 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
 
@@ -87,6 +87,12 @@ Author: Christian Grothoff, Dennis Neufeld
       <column type="gchararray"/>
       <!-- column-name have_redirect -->
       <column type="gboolean"/>
+      <!-- column-name not_solved -->
+      <column type="gboolean"/>
+      <!-- column-name type -->
+      <column type="gchararray"/>
+      <!-- column-name instructions -->
+      <column type="gchararray"/>
     </columns>
   </object>
   <object class="GtkListStore" id="continent_liststore">
@@ -1340,128 +1346,83 @@ Author: Christian Grothoff, Dennis Neufeld
                                             <property 
name="visible">True</property>
                                             <property 
name="can-focus">False</property>
                                             <child>
-                                              <object class="GtkBox">
+                                              <!-- n-columns=2 n-rows=2 -->
+                                              <object class="GtkGrid" 
id="anastasis_gtk_policy_selection_grid">
                                                 <property 
name="visible">True</property>
                                                 <property 
name="can-focus">False</property>
+                                                <property 
name="row-spacing">5</property>
+                                                <property 
name="column-spacing">5</property>
+                                                <property 
name="row-homogeneous">True</property>
                                                 <child>
-                                                  <object 
class="GtkScrolledWindow">
+                                                  <object class="GtkLabel">
+                                                    <property 
name="visible">True</property>
+                                                    <property 
name="can-focus">False</property>
+                                                    <property 
name="tooltip-text" translatable="yes">This is the URL of the provider from 
which we downloaded the recovery document.</property>
+                                                    <property name="label" 
translatable="yes">Provider URL:</property>
+                                                  </object>
+                                                  <packing>
+                                                    <property 
name="left-attach">0</property>
+                                                    <property 
name="top-attach">0</property>
+                                                  </packing>
+                                                </child>
+                                                <child>
+                                                  <object class="GtkLabel">
+                                                    <property 
name="visible">True</property>
+                                                    <property 
name="can-focus">False</property>
+                                                    <property 
name="tooltip-text" translatable="yes">This is the version of the backup at the 
provider. By default, the latest available backup version is 
obtained.</property>
+                                                    <property name="label" 
translatable="yes">Backup version:</property>
+                                                  </object>
+                                                  <packing>
+                                                    <property 
name="left-attach">0</property>
+                                                    <property 
name="top-attach">1</property>
+                                                  </packing>
+                                                </child>
+                                                <child>
+                                                  <object 
class="GtkSpinButton" id="anastasis_gtk_policy_version_spin_button">
                                                     <property 
name="visible">True</property>
                                                     <property 
name="can-focus">True</property>
-                                                    <property 
name="vscrollbar-policy">never</property>
-                                                    <property 
name="shadow-type">in</property>
-                                                    <child>
-                                                      <object 
class="GtkViewport">
-                                                        <property 
name="visible">True</property>
-                                                        <property 
name="can-focus">False</property>
-                                                        <child>
-                                                          <object 
class="GtkBox" id="anastasis_gtk_challenge_list_box">
-                                                            <property 
name="visible">True</property>
-                                                            <property 
name="can-focus">False</property>
-                                                            <property 
name="margin-top">5</property>
-                                                            <property 
name="margin-bottom">5</property>
-                                                            <child>
-                                                            <placeholder/>
-                                                            </child>
-                                                          </object>
-                                                        </child>
-                                                      </object>
-                                                    </child>
+                                                    <property 
name="margin-right">5</property>
+                                                    <property 
name="margin-end">5</property>
+                                                    <property name="text" 
translatable="yes">0</property>
+                                                    <property 
name="input-purpose">number</property>
+                                                    <property 
name="adjustment">policy_version_adjustment</property>
+                                                    <property 
name="climb-rate">1</property>
+                                                    <property 
name="numeric">True</property>
+                                                    <signal name="changed" 
handler="anastasis_gtk_policy_version_spin_button_changed_cb" swapped="no"/>
                                                   </object>
                                                   <packing>
-                                                    <property 
name="expand">True</property>
-                                                    <property 
name="fill">True</property>
-                                                    <property 
name="padding">5</property>
-                                                    <property 
name="position">0</property>
+                                                    <property 
name="left-attach">1</property>
+                                                    <property 
name="top-attach">1</property>
                                                   </packing>
                                                 </child>
                                                 <child>
-                                                  <!-- n-columns=2 n-rows=2 -->
-                                                  <object class="GtkGrid" 
id="anastasis_gtk_policy_selection_grid">
+                                                  <object 
class="GtkComboBoxText" id="anastasis_gtk_provider_url_combo_box_text">
                                                     <property 
name="visible">True</property>
                                                     <property 
name="can-focus">False</property>
-                                                    <property 
name="row-spacing">5</property>
-                                                    <property 
name="column-spacing">5</property>
-                                                    <child>
-                                                      <object class="GtkLabel">
-                                                        <property 
name="visible">True</property>
+                                                    <property 
name="margin-left">5</property>
+                                                    <property 
name="margin-right">5</property>
+                                                    <property 
name="margin-start">5</property>
+                                                    <property 
name="margin-end">5</property>
+                                                    <property 
name="margin-top">5</property>
+                                                    <property 
name="margin-bottom">5</property>
+                                                    <property 
name="has-entry">True</property>
+                                                    <child 
internal-child="entry">
+                                                      <object class="GtkEntry" 
id="anastasis_gtk_provider_url_entry">
                                                         <property 
name="can-focus">False</property>
-                                                        <property 
name="tooltip-text" translatable="yes">This is the URL of the provider from 
which we downloaded the recovery document.</property>
-                                                        <property name="label" 
translatable="yes">Provider URL:</property>
                                                       </object>
-                                                      <packing>
-                                                        <property 
name="left-attach">0</property>
-                                                        <property 
name="top-attach">0</property>
-                                                      </packing>
-                                                    </child>
-                                                    <child>
-                                                      <object class="GtkLabel">
-                                                        <property 
name="visible">True</property>
-                                                        <property 
name="can-focus">False</property>
-                                                        <property 
name="tooltip-text" translatable="yes">This is the version of the backup at the 
provider. By default, the latest available backup version is 
obtained.</property>
-                                                        <property name="label" 
translatable="yes">Backup version:</property>
-                                                      </object>
-                                                      <packing>
-                                                        <property 
name="left-attach">0</property>
-                                                        <property 
name="top-attach">1</property>
-                                                      </packing>
-                                                    </child>
-                                                    <child>
-                                                      <object 
class="GtkSpinButton" id="anastasis_gtk_policy_version_spin_button">
-                                                        <property 
name="visible">True</property>
-                                                        <property 
name="can-focus">True</property>
-                                                        <property 
name="margin-end">5</property>
-                                                        <property name="text" 
translatable="yes">0</property>
-                                                        <property 
name="input-purpose">number</property>
-                                                        <property 
name="adjustment">policy_version_adjustment</property>
-                                                        <property 
name="climb-rate">1</property>
-                                                        <property 
name="numeric">True</property>
-                                                        <signal name="changed" 
handler="anastasis_gtk_policy_version_spin_button_changed_cb" swapped="no"/>
-                                                      </object>
-                                                      <packing>
-                                                        <property 
name="left-attach">1</property>
-                                                        <property 
name="top-attach">1</property>
-                                                      </packing>
-                                                    </child>
-                                                    <child>
-                                                      <object 
class="GtkComboBoxText" id="anastasis_gtk_provider_url_combo_box_text">
-                                                        <property 
name="visible">True</property>
-                                                        <property 
name="can-focus">False</property>
-                                                        <property 
name="margin-start">5</property>
-                                                        <property 
name="margin-end">5</property>
-                                                        <property 
name="margin-top">5</property>
-                                                        <property 
name="margin-bottom">5</property>
-                                                        <property 
name="has-entry">True</property>
-                                                        <child 
internal-child="entry">
-                                                          <object 
class="GtkEntry" id="anastasis_gtk_provider_url_entry">
-                                                            <property 
name="can-focus">False</property>
-                                                            <property 
name="buffer">provider_url_entrybuffer</property>
-                                                            <property 
name="width-chars">32</property>
-                                                            <property 
name="primary-icon-stock">gtk-network</property>
-                                                            <property 
name="placeholder-text" translatable="yes">https://</property>
-                                                            <property 
name="input-purpose">url</property>
-                                                            <signal 
name="changed" handler="anastasis_gtk_provider_url_entry_changed_cb" 
swapped="no"/>
-                                                          </object>
-                                                        </child>
-                                                      </object>
-                                                      <packing>
-                                                        <property 
name="left-attach">1</property>
-                                                        <property 
name="top-attach">0</property>
-                                                      </packing>
                                                     </child>
                                                   </object>
                                                   <packing>
-                                                    <property 
name="expand">False</property>
-                                                    <property 
name="fill">True</property>
-                                                    <property 
name="padding">5</property>
-                                                    <property 
name="pack-type">end</property>
-                                                    <property 
name="position">4</property>
+                                                    <property 
name="left-attach">1</property>
+                                                    <property 
name="top-attach">0</property>
                                                   </packing>
                                                 </child>
                                               </object>
                                               <packing>
-                                                <property 
name="expand">True</property>
+                                                <property 
name="expand">False</property>
                                                 <property 
name="fill">True</property>
                                                 <property 
name="padding">5</property>
+                                                <property 
name="pack-type">end</property>
                                                 <property 
name="position">0</property>
                                               </packing>
                                             </child>
@@ -1493,7 +1454,7 @@ Author: Christian Grothoff, Dennis Neufeld
                                                       <object 
class="GtkTreeView" id="anastasis_gtk_challenge_status_treeview">
                                                         <property 
name="visible">True</property>
                                                         <property 
name="can-focus">True</property>
-                                                        <property 
name="tooltip-text" translatable="yes">Here you can see your progress in 
satisfying authorization challenges and possible next steps.</property>
+                                                        <property 
name="tooltip-text" translatable="yes">Here you can see your progress in 
satisfying authorization challenges and can select the next challenge to 
solve.</property>
                                                         <property 
name="model">challenge_status_liststore</property>
                                                         <signal 
name="row-activated" 
handler="anastasis_gtk_challenge_status_treeview_row_activated_cb" 
swapped="no"/>
                                                         <child 
internal-child="selection">
@@ -1507,10 +1468,11 @@ Author: Christian Grothoff, Dennis Neufeld
                                                             <property 
name="sort-column-id">0</property>
                                                             <child>
                                                             <object 
class="GtkCellRendererToggle" id="solved">
-                                                            <property 
name="activatable">False</property>
+                                                            <signal 
name="toggled" handler="anastasis_gtk_challenge_status_solved_toggled_cb" 
swapped="no"/>
                                                             </object>
                                                             <attributes>
-                                                            <attribute 
name="visible">2</attribute>
+                                                            <attribute 
name="sensitive">12</attribute>
+                                                            <attribute 
name="activatable">12</attribute>
                                                             <attribute 
name="active">2</attribute>
                                                             </attributes>
                                                             </child>
@@ -1533,6 +1495,17 @@ Author: Christian Grothoff, Dennis Neufeld
                                                             </child>
                                                           </object>
                                                         </child>
+                                                        <child>
+                                                          <object 
class="GtkTreeViewColumn" id="type1">
+                                                            <property 
name="title" translatable="yes">Type</property>
+                                                            <child>
+                                                            <object 
class="GtkCellRendererText" id="type_column"/>
+                                                            <attributes>
+                                                            <attribute 
name="text">13</attribute>
+                                                            </attributes>
+                                                            </child>
+                                                          </object>
+                                                        </child>
                                                         <child>
                                                           <object 
class="GtkTreeViewColumn">
                                                             <property 
name="title" translatable="yes">Cost</property>
@@ -1544,11 +1517,27 @@ Author: Christian Grothoff, Dennis Neufeld
                                                             </child>
                                                           </object>
                                                         </child>
+                                                        <child>
+                                                          <object 
class="GtkTreeViewColumn" id="hint">
+                                                            <property 
name="title" translatable="yes">Instructions</property>
+                                                            <child>
+                                                            <object 
class="GtkCellRendererText" id="instructions_text">
+                                                            <property 
name="ellipsize">end</property>
+                                                            <property 
name="max-width-chars">20</property>
+                                                            </object>
+                                                            <attributes>
+                                                            <attribute 
name="text">14</attribute>
+                                                            </attributes>
+                                                            </child>
+                                                          </object>
+                                                        </child>
                                                         <child>
                                                           <object 
class="GtkTreeViewColumn">
                                                             <property 
name="title" translatable="yes">Details</property>
                                                             <child>
-                                                            <object 
class="GtkCellRendererText" id="emsg"/>
+                                                            <object 
class="GtkCellRendererText" id="emsg">
+                                                            <property 
name="foreground">red</property>
+                                                            </object>
                                                             <attributes>
                                                             <attribute 
name="visible">8</attribute>
                                                             <attribute 
name="text">5</attribute>
@@ -1585,7 +1574,7 @@ Author: Christian Grothoff, Dennis Neufeld
                                                 <property 
name="margin-end">5</property>
                                                 <property 
name="margin-top">5</property>
                                                 <property 
name="margin-bottom">5</property>
-                                                <property name="label" 
translatable="yes">Challenge status:</property>
+                                                <property name="label" 
translatable="yes">Select open challenge to solve:</property>
                                               </object>
                                             </child>
                                           </object>
diff --git a/src/anastasis/anastasis-gtk_action.c 
b/src/anastasis/anastasis-gtk_action.c
index dfb5d12..344d5be 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -1336,53 +1336,6 @@ action_backup_finished (void)
 }
 
 
-/**
- * The user clicked one of the challenge buttons, select the
- * challenge.
- *
- * @param button the button that was clicked
- * @param user_data a `json *` with the challenge
- */
-static void
-challenge_button_clicked_cb (GtkButton *button,
-                             gpointer user_data)
-{
-  json_t *challenge = user_data;
-  json_t *uuid = json_object_get (challenge,
-                                  "uuid");
-  json_t *args = json_pack ("{s:O}",
-                            "uuid",
-                            uuid);
-
-  GNUNET_assert (NULL != uuid);
-  GNUNET_assert (NULL != args);
-  AG_freeze ();
-  AG_ra = ANASTASIS_redux_action (AG_redux_state,
-                                  "select_challenge",
-                                  args,
-                                  &AG_action_cb,
-                                  NULL);
-  json_decref (args);
-}
-
-
-/**
- * Removes @a child from the container in @a user_data.
- *
- * @param child a child to remove
- * @param user_data a `GtkContainer` to remove child from
- */
-static void
-remove_child (GtkWidget *child,
-              gpointer user_data)
-{
-  GtkContainer *c = user_data;
-
-  gtk_container_remove (c,
-                        child);
-}
-
-
 static const json_t *
 find_challenge_by_uuid (const char *uuid)
 {
@@ -1524,6 +1477,47 @@ translate_state (const char *state)
 }
 
 
+/**
+ * Test if the given @a uuid is already in @a model,
+ * and if so, return the position at @a iter.
+ *
+ * @param model the list store with the challenges
+ * @param uuid challenge UUID to look for
+ * @param[out] iter iter to set
+ * @return true if @a iter was set
+ */
+static bool
+challenge_ls_has_uuid (GtkTreeModel *model,
+                       const char *uuid,
+                       GtkTreeIter *iter)
+{
+  GtkTreeIter pos;
+
+  if (gtk_tree_model_get_iter_first (model,
+                                     &pos))
+    do {
+      char *u;
+
+      gtk_tree_model_get (model,
+                          &pos,
+                          AG_CSM_CHALLENGE_UUID, &u,
+                          -1);
+      if (0 == strcmp (uuid,
+                       u))
+      {
+        g_free (u);
+        if (NULL != iter)
+          *iter = pos;
+        return true;
+      }
+      g_free (u);
+    }
+    while (gtk_tree_model_iter_next (model,
+                                     &pos));
+  return false;
+}
+
+
 /**
  * Update the list store with the challenge feedback.
  */
@@ -1537,7 +1531,6 @@ show_challenge_feedback (void)
 
   ls = GTK_LIST_STORE (GCG_get_main_window_object (
                          "challenge_status_liststore"));
-  gtk_list_store_clear (ls);
   cf = json_object_get (AG_redux_state,
                         "challenge_feedback");
   json_object_foreach (cf, uuid, f)
@@ -1616,24 +1609,51 @@ show_challenge_feedback (void)
                        json_string_value (json_object_get (details,
                                                            "hint")));
     }
-    gtk_list_store_insert_with_values (
-      ls,
-      NULL,
-      -1,                                  /* append */
-      AG_CSM_CHALLENGE_OFFSET, off,
-      AG_CSM_CHALLENGE_UUID, uuid,
-      AG_CSM_SOLVED, 0 == strcmp (state, "solved"),
-      AG_CSM_STATUS, translate_state (state),
-      AG_CSM_PAYMENT_QR_CODE, qr,
-      AG_CSM_ERROR_MESSAGE, emsg,
-      AG_CSM_PAYTO_URI, taler_pay_uri,
-      AG_CSM_PAYING, NULL != taler_pay_uri,
-      AG_CSM_HAS_ERROR, NULL != emsg,
-      AG_CSM_COST, TALER_amount2s (&cost),
-      AG_CSM_REDIRECT_URL, redirect_url,
-      AG_CSM_HAVE_REDIRECT, NULL != redirect_url,
-      -1);
-    GNUNET_JSON_parse_free (spec);
+    {
+      GtkTreeIter iter;
+      bool found;
+
+      found = challenge_ls_has_uuid (GTK_TREE_MODEL (ls),
+                                     uuid,
+                                     &iter);
+      GNUNET_break (found);
+      if (found)
+        gtk_list_store_set (
+          ls,
+          &iter,
+          AG_CSM_SOLVED, 0 == strcmp (state, "solved"),
+          AG_CSM_STATUS, translate_state (state),
+          AG_CSM_PAYMENT_QR_CODE, qr,
+          AG_CSM_ERROR_MESSAGE, emsg,
+          AG_CSM_PAYTO_URI, taler_pay_uri,
+          AG_CSM_PAYING, NULL != taler_pay_uri,
+          AG_CSM_HAS_ERROR, NULL != emsg,
+          AG_CSM_COST, TALER_amount2s (&cost),
+          AG_CSM_REDIRECT_URL, redirect_url,
+          AG_CSM_HAVE_REDIRECT, NULL != redirect_url,
+          AG_CSM_NOT_SOLVED, 0 != strcmp (state, "solved"),
+          -1);
+      else
+        gtk_list_store_insert_with_values (
+          ls,
+          NULL,
+          -1,                              /* append */
+          AG_CSM_CHALLENGE_OFFSET, off,
+          AG_CSM_CHALLENGE_UUID, uuid,
+          AG_CSM_SOLVED, 0 == strcmp (state, "solved"),
+          AG_CSM_STATUS, translate_state (state),
+          AG_CSM_PAYMENT_QR_CODE, qr,
+          AG_CSM_ERROR_MESSAGE, emsg,
+          AG_CSM_PAYTO_URI, taler_pay_uri,
+          AG_CSM_PAYING, NULL != taler_pay_uri,
+          AG_CSM_HAS_ERROR, NULL != emsg,
+          AG_CSM_COST, TALER_amount2s (&cost),
+          AG_CSM_REDIRECT_URL, redirect_url,
+          AG_CSM_HAVE_REDIRECT, NULL != redirect_url,
+          AG_CSM_NOT_SOLVED, 0 != strcmp (state, "solved"),
+          -1);
+      GNUNET_JSON_parse_free (spec);
+    }
   }
 }
 
@@ -1641,16 +1661,11 @@ show_challenge_feedback (void)
 static void
 action_challenge_selecting (void)
 {
-  json_t *challenges;
-  size_t index;
-  json_t *challenge;
-  GtkBox *box;
   json_t *rd;
   json_t *ri;
   json_t *re;
 
   AG_hide_all_frames ();
-  show_challenge_feedback ();
   {
     GtkComboBoxText *bt;
     json_t *aps;
@@ -1670,6 +1685,7 @@ action_challenge_selecting (void)
                                       -1, /* append */
                                       provider_url);
     }
+    /* FIXME: #6910: tell combo box which entry to select! */
   }
   re = json_object_get (AG_redux_state,
                         "recovery_error");
@@ -1685,7 +1701,6 @@ action_challenge_selecting (void)
       GNUNET_JSON_spec_end ()
     };
     GtkTreeStore *ts;
-    GtkBox *box;
 
     if (GNUNET_OK !=
         GNUNET_JSON_parse (re,
@@ -1702,12 +1717,6 @@ action_challenge_selecting (void)
     ts = GTK_TREE_STORE (GCG_get_main_window_object (
                            "policy_review_treestore"));
     gtk_tree_store_clear (ts);
-    box = GTK_BOX (GCG_get_main_window_object (
-                     "anastasis_gtk_challenge_list_box"));
-    GNUNET_assert (NULL != box);
-    gtk_container_foreach (GTK_CONTAINER (box),
-                           &remove_child,
-                           box);
     AG_insensitive ("anastasis_gtk_review_policy_treeview");
     AG_show ("anastasis_gtk_open_challenge_box");
     AG_show ("anastasis_gtk_main_control_vbox");
@@ -1760,6 +1769,89 @@ action_challenge_selecting (void)
   }
   rd = json_object_get (AG_redux_state,
                         "recovery_document");
+  {
+    json_t *challenges;
+    size_t index;
+    json_t *challenge;
+    GtkListStore *ls;
+
+    ls = GTK_LIST_STORE (GCG_get_main_window_object (
+                           "challenge_status_liststore"));
+    challenges = json_object_get (rd,
+                                  "cs");
+    json_array_foreach (challenges, index, challenge)
+    {
+      const char *instructions;
+      const char *provider;
+      const char *type;
+      const char *uuid;
+      struct TALER_Amount cost;
+      struct GNUNET_JSON_Specification spec[] = {
+        GNUNET_JSON_spec_string ("instructions",
+                                 &instructions),
+        GNUNET_JSON_spec_string ("type",
+                                 &type),
+        GNUNET_JSON_spec_string ("url",
+                                 &provider),
+        GNUNET_JSON_spec_string ("uuid",
+                                 &uuid),
+        GNUNET_JSON_spec_end ()
+      };
+
+      {
+        const json_t *ks;
+
+        ks = json_object_get (challenge,
+                              "key_share");
+        if ( (NULL != ks) &&
+             (! json_is_null (ks)) )
+          continue; /* already solved */
+      }
+      if (GNUNET_OK !=
+          GNUNET_JSON_parse (challenge,
+                             spec,
+                             NULL, NULL))
+      {
+        GNUNET_break (0);
+        continue;
+      }
+      if (GNUNET_OK !=
+          lookup_recovery_cost (provider,
+                                type,
+                                &cost))
+      {
+        GNUNET_break (0);
+        continue;
+      }
+      if (challenge_ls_has_uuid (GTK_TREE_MODEL (ls),
+                                 uuid,
+                                 NULL))
+        continue;
+
+      gtk_list_store_insert_with_values (
+        ls,
+        NULL,
+        -1,                                /* append */
+        AG_CSM_CHALLENGE_OFFSET, (guint) index,
+        AG_CSM_CHALLENGE_UUID, uuid,
+        AG_CSM_SOLVED, false,
+        AG_CSM_STATUS, _ ("new"),
+        AG_CSM_PAYMENT_QR_CODE, NULL,
+        AG_CSM_ERROR_MESSAGE, NULL,
+        AG_CSM_PAYTO_URI, NULL,
+        AG_CSM_PAYING, false,
+        AG_CSM_HAS_ERROR, false,
+        AG_CSM_COST, TALER_amount2s (&cost),
+        AG_CSM_REDIRECT_URL, NULL,
+        AG_CSM_HAVE_REDIRECT, false,
+        AG_CSM_NOT_SOLVED, true,
+        AG_CSM_TYPE, type,
+        AG_CSM_INSTRUCTIONS, instructions,
+        -1);
+    }
+  }
+  show_challenge_feedback ();
+
   {
     GtkTreeStore *ts;
     json_t *policies;
@@ -1893,89 +1985,6 @@ action_challenge_selecting (void)
                           "anastasis_gtk_choose_policy_treeview"));
     gtk_tree_view_expand_all (tv);
   }
-  challenges = json_object_get (rd,
-                                "cs");
-  box = GTK_BOX (GCG_get_main_window_object (
-                   "anastasis_gtk_challenge_list_box"));
-  GNUNET_assert (NULL != box);
-  gtk_container_foreach (GTK_CONTAINER (box),
-                         &remove_child,
-                         box);
-  json_array_foreach (challenges, index, challenge)
-  {
-    GtkWidget *b;
-    const char *instructions;
-    const char *provider;
-    const char *type;
-    struct TALER_Amount cost;
-    struct GNUNET_JSON_Specification spec[] = {
-      GNUNET_JSON_spec_string ("instructions",
-                               &instructions),
-      GNUNET_JSON_spec_string ("type",
-                               &type),
-      GNUNET_JSON_spec_string ("url",
-                               &provider),
-      GNUNET_JSON_spec_end ()
-    };
-
-    {
-      const json_t *ks;
-
-      ks = json_object_get (challenge,
-                            "key_share");
-      if ( (NULL != ks) &&
-           (! json_is_null (ks)) )
-        continue; /* already solved */
-    }
-    if (GNUNET_OK !=
-        GNUNET_JSON_parse (challenge,
-                           spec,
-                           NULL, NULL))
-    {
-      GNUNET_break (0);
-      continue;
-    }
-    if (GNUNET_OK !=
-        lookup_recovery_cost (provider,
-                              type,
-                              &cost))
-    {
-      GNUNET_break (0);
-      continue;
-    }
-    {
-      char *ins_str;
-
-      GNUNET_asprintf (&ins_str,
-                       "#%u: %s",
-                       (unsigned int) index,
-                       gettext (type));
-      b = gtk_button_new_with_label (ins_str);
-      GNUNET_free (ins_str);
-    }
-    {
-      char *cost_str;
-
-      GNUNET_asprintf (&cost_str,
-                       _ ("%s\nPrice: %s"),
-                       instructions,
-                       TALER_amount2s (&cost));
-      gtk_widget_set_tooltip_text (b,
-                                   cost_str);
-      GNUNET_free (cost_str);
-    }
-    g_object_connect (G_OBJECT (b),
-                      "signal::clicked",
-                      &challenge_button_clicked_cb,
-                      challenge,
-                      NULL);
-    gtk_widget_show (GTK_WIDGET (b));
-    gtk_box_pack_start (box,
-                        b, /* child */
-                        false, /* expand */
-                        false, /* fill */
-                        5 /* padding */);
-  }
   AG_sensitive ("anastasis_gtk_review_policy_treeview");
   AG_show ("anastasis_gtk_open_challenge_box");
   AG_show ("anastasis_gtk_main_control_vbox");
diff --git a/src/anastasis/anastasis-gtk_handle-challenge-row-activated.c 
b/src/anastasis/anastasis-gtk_handle-challenge-row-activated.c
index c68b2b3..0f1023c 100644
--- a/src/anastasis/anastasis-gtk_handle-challenge-row-activated.c
+++ b/src/anastasis/anastasis-gtk_handle-challenge-row-activated.c
@@ -30,6 +30,39 @@
 #include <jansson.h>
 
 
+static void
+start_solve (GtkTreeModel *model,
+             GtkTreeIter *iter)
+{
+  char *uuid;
+  gboolean solved;
+  json_t *args;
+
+  gtk_tree_model_get (model,
+                      iter,
+                      AG_CSM_CHALLENGE_UUID, &uuid,
+                      AG_CSM_SOLVED, &solved,
+                      -1);
+  if (solved)
+  {
+    g_free (uuid);
+    return;
+  }
+  args = json_pack ("{s:s}",
+                    "uuid",
+                    uuid);
+  g_free (uuid);
+  GNUNET_assert (NULL != args);
+  AG_freeze ();
+  AG_ra = ANASTASIS_redux_action (AG_redux_state,
+                                  "select_challenge",
+                                  args,
+                                  &AG_action_cb,
+                                  NULL);
+  json_decref (args);
+}
+
+
 /**
  * The user activated a row in the challenge list.
  * If the row contains an unsolved challenge, start
@@ -48,7 +81,6 @@ anastasis_gtk_challenge_status_treeview_row_activated_cb (
   GtkTreeModel *model;
   GtkTreeIter iter;
   GtkTreeSelection *selection;
-  json_t *args;
 
   (void) path;
   (void) column;
@@ -58,32 +90,43 @@ anastasis_gtk_challenge_status_treeview_row_activated_cb (
                                        &model,
                                        &iter))
   {
-    char *uuid;
-    gboolean solved;
-
-    gtk_tree_model_get (model,
-                        &iter,
-                        AG_CSM_CHALLENGE_UUID, &uuid,
-                        AG_CSM_SOLVED, &solved,
-                        -1);
-    if (solved)
-    {
-      g_free (uuid);
-      return;
-    }
-    args = json_pack ("{s:s}",
-                      "uuid",
-                      uuid);
-    g_free (uuid);
+    start_solve (model,
+                 &iter);
   }
-  GNUNET_assert (NULL != args);
-  AG_freeze ();
-  AG_ra = ANASTASIS_redux_action (AG_redux_state,
-                                  "select_challenge",
-                                  args,
-                                  &AG_action_cb,
-                                  NULL);
-  json_decref (args);
+  else
+  {
+    /* How can this be? */
+    GNUNET_break (0);
+  }
+}
+
+
+/**
+ * The user clicked one of the challenge buttons, select the
+ * challenge.
+ *
+ * @param button the button that was clicked
+ * @param user_data a `json *` with the challenge
+ */
+void
+anastasis_gtk_challenge_status_solved_toggled_cb (
+  GtkCellRendererToggle *cell_renderer,
+  gchar                 *path,
+  gpointer user_data)
+{
+  GtkTreePath *p;
+  GtkTreeIter iter;
+  GtkTreeModel *model;
+
+  model = GTK_TREE_MODEL (GCG_get_main_window_object (
+                            "challenge_status_liststore"));
+  p = gtk_tree_path_new_from_string (path);
+  gtk_tree_model_get_iter (model,
+                           &iter,
+                           p);
+  gtk_tree_path_free (p);
+  start_solve (model,
+               &iter);
 }
 
 
diff --git a/src/anastasis/anastasis-gtk_handle-policy-version-changed.c 
b/src/anastasis/anastasis-gtk_handle-policy-version-changed.c
index dd22c28..da56371 100644
--- a/src/anastasis/anastasis-gtk_handle-policy-version-changed.c
+++ b/src/anastasis/anastasis-gtk_handle-policy-version-changed.c
@@ -31,23 +31,6 @@
 #include <jansson.h>
 
 
-/**
- * Removes @a child from the container in @a user_data.
- *
- * @param child a child to remove
- * @param user_data a `GtkContainer` to remove child from
- */
-static void
-remove_child (GtkWidget *child,
-              gpointer user_data)
-{
-  GtkContainer *c = user_data;
-
-  gtk_container_remove (c,
-                        child);
-}
-
-
 /**
  * Function called with the results of #ANASTASIS_redux_action.
  *
@@ -135,17 +118,10 @@ update_policy (void)
 
   {
     GtkTreeStore *ts;
-    GtkBox *box;
 
     ts = GTK_TREE_STORE (GCG_get_main_window_object (
                            "policy_review_treestore"));
     gtk_tree_store_clear (ts);
-    box = GTK_BOX (GCG_get_main_window_object (
-                     "anastasis_gtk_challenge_list_box"));
-    GNUNET_assert (NULL != box);
-    gtk_container_foreach (GTK_CONTAINER (box),
-                           &remove_child,
-                           box);
   }
   sb = GTK_SPIN_BUTTON (GCG_get_main_window_object (
                           "anastasis_gtk_policy_version_spin_button"));
diff --git a/src/anastasis/anastasis-gtk_helper.h 
b/src/anastasis/anastasis-gtk_helper.h
index 1606b55..f388874 100644
--- a/src/anastasis/anastasis-gtk_helper.h
+++ b/src/anastasis/anastasis-gtk_helper.h
@@ -125,7 +125,23 @@ enum AG_ChallengeStatusModelColumns
   /**
    * A gboolean.
    */
-  AG_CSM_HAVE_REDIRECT = 11
+  AG_CSM_HAVE_REDIRECT = 11,
+
+  /**
+   * A gboolean
+   */
+  AG_CSM_NOT_SOLVED = 12,
+
+  /**
+   * A gchararray
+   */
+  AG_CSM_TYPE = 13,
+
+  /**
+   * A gchararray
+   */
+  AG_CSM_INSTRUCTIONS = 14
+
 };
 
 

-- 
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]