gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] branch master updated: introduce proper dispatch l


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated: introduce proper dispatch logic
Date: Sun, 07 Mar 2021 22:44:53 +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 5c5f6b6  introduce proper dispatch logic
5c5f6b6 is described below

commit 5c5f6b625a14308a1f89ad324eaa1caa790169b8
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Mar 7 22:44:50 2021 +0100

    introduce proper dispatch logic
---
 configure.ac                                       |   1 -
 contrib/anastasis_gtk_main_window.glade            |   1 +
 src/Makefile.am                                    |   2 +-
 src/anastasis/Makefile.am                          |  12 +-
 src/anastasis/anastasis-gtk.c                      | 326 +--------------
 src/anastasis/anastasis-gtk.h                      |  55 +++
 src/anastasis/anastasis-gtk_action.c               | 338 +++++++++++++++
 src/anastasis/anastasis-gtk_action.h               |  48 +++
 src/anastasis/anastasis-gtk_backup.c               |  45 +-
 src/anastasis/anastasis-gtk_dispatch.c             |  40 ++
 src/anastasis/anastasis-gtk_dispatch.h             |  53 +++
 .../anastasis-gtk_handle-backup-button-clicked.c   |  52 +++
 .../anastasis-gtk_handle-continent-activated.c     |  74 ++++
 .../anastasis-gtk_handle-continent-unselected.c    |  59 +++
 .../anastasis-gtk_handle-country-activated.c       |  49 +++
 .../anastasis-gtk_handle-country-unselected.c      |  51 +++
 ...anastasis-gtk_handle-main-window-back-clicked.c |  51 +++
 ...stasis-gtk_handle-main-window-forward-clicked.c | 212 ++++++++++
 ...stasis-gtk_handle-main-window-forward-clicked.h |  33 ++
 src/anastasis/anastasis-gtk_helper.c               | 461 +++++----------------
 src/{include => anastasis}/anastasis-gtk_helper.h  | 105 ++---
 src/include/Makefile.am                            |   8 -
 22 files changed, 1287 insertions(+), 789 deletions(-)

diff --git a/configure.ac b/configure.ac
index 09f31c6..f22013f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -402,7 +402,6 @@ doc/Makefile
 doc/doxygen/Makefile
 src/Makefile
 src/anastasis/Makefile
-src/include/Makefile
 pixmaps/Makefile
 po/Makefile.in
 po/Makefile
diff --git a/contrib/anastasis_gtk_main_window.glade 
b/contrib/anastasis_gtk_main_window.glade
index 33fac2e..fe56068 100644
--- a/contrib/anastasis_gtk_main_window.glade
+++ b/contrib/anastasis_gtk_main_window.glade
@@ -261,6 +261,7 @@
                                           <object class="GtkTreeView" 
id="anastasis_gtk_country_treeview">
                                             <property 
name="visible">True</property>
                                             <property 
name="can-focus">True</property>
+                                            <property 
name="model">country_liststore</property>
                                             <property 
name="enable-search">False</property>
                                             <property 
name="search-column">0</property>
                                             <property 
name="activate-on-single-click">True</property>
diff --git a/src/Makefile.am b/src/Makefile.am
index d3dd731..25f4e29 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,2 +1,2 @@
 # This Makefile.am is in the public domain
-SUBDIRS = . include anastasis
+SUBDIRS = . anastasis
diff --git a/src/anastasis/Makefile.am b/src/anastasis/Makefile.am
index 34fc75b..652a8ad 100644
--- a/src/anastasis/Makefile.am
+++ b/src/anastasis/Makefile.am
@@ -12,9 +12,19 @@ bin_PROGRAMS = anastasis-gtk
 
 anastasis_gtk_SOURCES = \
   anastasis-gtk.c \
-  anastasis-gtk_helper.c \
+  anastasis-gtk_action.c anastasis-gtk_action.h \
   anastasis-gtk_about.c \
   anastasis-gtk_backup.c \
+  anastasis-gtk_dispatch.c anastasis-gtk_dispatch.h \
+  anastasis-gtk_handle-backup-button-clicked.c \
+  anastasis-gtk_handle-continent-activated.c \
+  anastasis-gtk_handle-continent-unselected.c \
+  anastasis-gtk_handle-country-activated.c \
+  anastasis-gtk_handle-country-unselected.c \
+  anastasis-gtk_handle-main-window-forward-clicked.c \
+  anastasis-gtk_handle-main-window-forward-clicked.h \
+  anastasis-gtk_handle-main-window-back-clicked.c \
+  anastasis-gtk_helper.c  anastasis-gtk_helper.h \
   os_installation.c
 
 anastasis_gtk_LDADD = \
diff --git a/src/anastasis/anastasis-gtk.c b/src/anastasis/anastasis-gtk.c
index 2c3d748..1955ad2 100644
--- a/src/anastasis/anastasis-gtk.c
+++ b/src/anastasis/anastasis-gtk.c
@@ -37,17 +37,17 @@ struct GNUNET_GTK_MainLoop *ml;
 /**
  * Our configuration.
  */
-struct GNUNET_CONFIGURATION_Handle *cfg;
+const struct GNUNET_CONFIGURATION_Handle *cfg;
 
 /**
  * Closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
  */
-struct GNUNET_CURL_RescheduleContext *rc;
+static struct GNUNET_CURL_RescheduleContext *rc;
 
 /**
  * Curl context for communication with taler backend
  */
-struct GNUNET_CURL_Context *ctx;
+static struct GNUNET_CURL_Context *ctx;
 
 /**
  * Handle to an ongoing action.
@@ -222,309 +222,6 @@ anastasis_gtk_ia_full_name_entry_changed_cb 
(GtkCellEditable *cell_editable,
 }
 
 
-/**
- * Callback invoked if a continent is selected (row-activated signal).
- *
- * @param tree_view the object on which the signal is emitted
- * @param path the GtkTreePath for the activated row
- * @param column the GtkTreeViewColumn in which the activation occurred
- * @param user_data user data set when the signal handler was connected 
(unused)
- */
-void
-anastasis_gtk_continent_activated (GtkTreeView *tree_view,
-                                   GtkTreePath *path,
-                                   GtkTreeViewColumn *column,
-                                   gpointer user_data)
-{
-  GtkTreeIter iter;
-  GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
-  GtkListStore *country_liststore = GTK_LIST_STORE (GCG_get_main_window_object 
(
-                                                      "country_liststore"));
-
-  gtk_list_store_clear (country_liststore);
-  gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
-                                          
"anastasis_gtk_main_window_forward_button")),
-                            false);
-
-  if (gtk_tree_model_get_iter (model, &iter, path))
-  {
-    gchar *continent_name;
-    json_t *arguments = json_object ();
-
-    GNUNET_assert (NULL != arguments);
-    gtk_tree_model_get (model,
-                        &iter,
-                        0, &continent_name,
-                        -1);
-    GNUNET_assert (0 ==
-                   json_object_set_new (arguments,
-                                        "continent",
-                                        json_string (continent_name)));
-    ra = ANASTASIS_redux_action (redux_state,
-                                 "select_continent",
-                                 arguments,
-                                 &action_cb,
-                                 NULL);
-    g_free (continent_name);
-  }
-}
-
-
-/**
- * Callback invoked if a country is selected (row-activated signal).
- *
- * @param tree_view the object on which the signal is emitted
- * @param path the GtkTreePath for the activated row
- * @param column the GtkTreeViewColumn in which the activation occurred
- * @param user_data user data set when the signal handler was connected 
(unused)
- */
-void
-anastasis_gtk_country_activated (GtkTreeView *tree_view,
-                                 GtkTreePath *path,
-                                 GtkTreeViewColumn *column,
-                                 gpointer user_data)
-{
-  GtkTreeIter iter;
-  GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
-
-  if (gtk_tree_model_get_iter (model, &iter, path))
-  {
-    gchar *country_name;
-    gchar *country_code;
-    gchar *country_currency;
-    json_t *arguments = json_object ();
-
-    if (NULL == arguments)
-    {
-      GNUNET_break (0);
-    }
-    gtk_tree_model_get (model, &iter,
-                        0, &country_name,
-                        1, &country_code,
-                        2, &country_currency,
-                        -1);
-    json_object_set (arguments, "country", json_string (country_name));
-    json_object_set (arguments, "country_code", json_string (country_code));
-    json_object_set (arguments, "currency", json_string (country_currency));
-
-    reset_authentication_providers ();
-    ra = ANASTASIS_redux_action (redux_state,
-                                 "select_country",
-                                 arguments,
-                                 &action_cb,
-                                 NULL);
-
-    g_free (country_name);
-    g_free (country_code);
-    g_free (country_currency);
-  }
-}
-
-
-/**
- * Callback invoked if a country is unselected (unselected signal).
- *
- * @param selection A GtkTreeSelection.
- * @param user_data user data set when the signal handler was connected.
- */
-void
-anastasis_gtk_continent_unselected (GtkTreeSelection *selection,
-                                    gpointer user_data)
-{
-  GtkTreeModel *model;
-
-  if (! gtk_tree_selection_get_selected (selection,
-                                         &model,
-                                         NULL))
-    ra = ANASTASIS_redux_action (redux_state,
-                                 "unselect_continent",
-                                 NULL,
-                                 &action_cb,
-                                 NULL);
-}
-
-
-/**
- * Callback invoked if a country is unselected (unselected signal).
- *
- * @param selection A GtkTreeSelection.
- * @param user_data user data set when the signal handler was connected.
- */
-void
-anastasis_gtk_country_unselected (GtkTreeSelection *selection,
-                                  gpointer user_data)
-{
-  GtkTreeModel *model;
-
-  if (! gtk_tree_selection_get_selected (selection,
-                                         &model,
-                                         NULL))
-    ra = ANASTASIS_redux_action (redux_state,
-                                 "unselect_country",
-                                 NULL,
-                                 &action_cb,
-                                 NULL);
-}
-
-
-/**
- * Callback invoked if the the "back"-button is clicked.
- *
- * @param object
- * @param user_data unused
- */
-void
-anastasis_gtk_main_window_back_clicked (GObject *object,
-                                        gpointer user_data)
-{
-  ra = ANASTASIS_redux_action (redux_state,
-                               "back",
-                               NULL,
-                               &action_cb,
-                               NULL);
-  // show identity frame, hide authentication frame
-  if (check_state (redux_state,
-                   "USER_ATTRIBUTES_COLLECTION") &&
-      gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
-                                           
"anastasis_gtk_b_authentication_frame"))))
-  {
-    anastasis_gtk_hide_all_frames ();
-    gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                   "anastasis_gtk_identity_frame")));
-    gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                   "anastasis_gtk_user_attributes_image")));
-  }
-}
-
-
-/**
- * Callback invoked if the the "forward"-button is clicked.
- *
- * @param object
- * @param user_data unused
- */
-void
-anastasis_gtk_main_window_forward_clicked (GObject *object,
-                                           gpointer user_data)
-{
-  // show identity frame, hide continent frame
-  if (check_state (redux_state,
-                   "USER_ATTRIBUTES_COLLECTION") &&
-      gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
-                                           "anastasis_gtk_continent_frame"))))
-  {
-    anastasis_gtk_hide_all_frames ();
-    gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                   "anastasis_gtk_identity_frame")));
-    gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
-                                            
"anastasis_gtk_main_window_forward_button")),
-                              false);
-    gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                   "anastasis_gtk_user_attributes_image")));
-  }
-
-  // show backup authentication methods frame, hide identity frame
-  if (gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
-                                           "anastasis_gtk_identity_frame"))) &&
-      check_attributes_fullfilled ())
-  {
-    GList *children, *iter;
-    json_t *arguments = json_object ();
-    json_t *id_attr = json_object ();
-
-    children = gtk_container_get_children (GTK_CONTAINER (
-                                             GCG_get_main_window_object (
-                                               
"anastasis_gtk_identity_vbox")));
-    for (iter = children; iter != NULL; iter = g_list_next (iter))
-    {
-      char *entry_widget;
-      char *cal_widget;
-      const char *widget = gtk_buildable_get_name (iter->data);
-
-      GNUNET_asprintf (&entry_widget,
-                       "%s_entry",
-                       widget);
-      GNUNET_asprintf (&cal_widget,
-                       "%s_cal",
-                       widget);
-
-      if (GCG_get_main_window_object (entry_widget))
-      {
-        const char *value = gtk_entry_get_text (GTK_ENTRY (
-                                                  GCG_get_main_window_object (
-                                                    entry_widget)));
-        if (0 == strlen (value))
-          break;
-        if (strstr (widget, "ia_ahv"))
-          json_object_set_new (id_attr, "ahv_number", json_string (value));
-        if (strstr (widget, "ia_ssn"))
-          json_object_set_new (id_attr, "social_security_number", json_string (
-                                 value));
-        if (strstr (widget, "ia_full_name"))
-          json_object_set_new (id_attr, "full_name", json_string (value));
-      }
-      if (GCG_get_main_window_object (cal_widget))
-      {
-        guint day;
-        guint month;
-        guint year;
-
-        gtk_calendar_get_date (GTK_CALENDAR (GCG_get_main_window_object (
-                                               cal_widget)),
-                               &year,
-                               &month,
-                               &day);
-        json_object_set_new (id_attr, "birth_year", json_integer (year));
-        json_object_set_new (id_attr, "birth_month", json_integer (month));
-        json_object_set_new (id_attr, "birth_day", json_integer (day));
-      }
-      GNUNET_free (entry_widget);
-      GNUNET_free (cal_widget);
-    }
-    json_object_set_new (arguments, "identity_attributes", id_attr);
-
-    if (check_state (redux_state,
-                     "USER_ATTRIBUTES_COLLECTION"))
-    {
-      json_t *auth_providers = get_authentication_providers ();
-      if (NULL != auth_providers)
-        json_object_set_new (arguments,
-                             "authentication_providers",
-                             auth_providers);
-      ra = ANASTASIS_redux_action (redux_state,
-                                   "enter_user_attributes",
-                                   arguments,
-                                   &action_cb,
-                                   NULL);
-    }
-
-    gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
-                                            
"anastasis_gtk_main_window_forward_button")),
-                              false);
-    g_list_free (children);
-  }
-
-  // show backup policy frame, hide backup authentication methods frame
-  if (gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
-                                           
"anastasis_gtk_b_authentication_frame"))))
-  {
-    if (check_state (redux_state,
-                     "AUTHENTICATIONS_EDITING"))
-    {
-      json_t *auth_methods = json_object_get (redux_state,
-                                              "authentication_methods");
-
-      if (json_array_size (auth_methods) > 0)
-        ra = ANASTASIS_redux_action (redux_state,
-                                     "next",
-                                     NULL,
-                                     &action_cb,
-                                     NULL);
-    }
-  }
-}
-
-
 /**
  * Task run on shutdown.
  *
@@ -533,18 +230,17 @@ anastasis_gtk_main_window_forward_clicked (GObject 
*object,
 static void
 shutdown_task (void *cls)
 {
+  (void) cls;
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Shutdown initiated\n");
   ANASTASIS_redux_done ();
   GNUNET_GTK_main_loop_quit (ml);
   ml = NULL;
-
   if (NULL != ra)
   {
-    GNUNET_free (ra);
+    ANASTASIS_redux_action_cancel (ra);
     ra = NULL;
   }
-
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Shutdown complete\n");
 }
@@ -580,7 +276,7 @@ run (void *cls)
       GNUNET_GTK_main_loop_build_window (ml,
                                          NULL))
     return;
-  cfg = GNUNET_CONFIGURATION_dup (GNUNET_GTK_main_loop_get_configuration (ml));
+  cfg = GNUNET_GTK_main_loop_get_configuration (ml);
   GNUNET_GTK_set_icon_search_path ();
   GNUNET_GTK_setup_nls ();
   /* setup main window */
@@ -601,14 +297,15 @@ run (void *cls)
 
 
 /**
- * Main function of gnunet-conversation-gtk.
+ * Main function of anastasis-gtk.
  *
  * @param argc number of arguments
  * @param argv arguments
  * @return 0 on success
  */
 int
-main (int argc, char *const *argv)
+main (int argc,
+      char *const *argv)
 {
   struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_OPTION_END
@@ -626,11 +323,6 @@ main (int argc, char *const *argv)
     ret = 1;
   else
     ret = 0;
-  if (NULL != cfg)
-  {
-    GNUNET_CONFIGURATION_destroy (cfg);
-    cfg = NULL;
-  }
   return ret;
 }
 
diff --git a/src/anastasis/anastasis-gtk.h b/src/anastasis/anastasis-gtk.h
new file mode 100644
index 0000000..fae5077
--- /dev/null
+++ b/src/anastasis/anastasis-gtk.h
@@ -0,0 +1,55 @@
+/*
+     This file is part of anastasis-gtk.
+     Copyright (C) 2020 Anastasis SARL
+
+     Anastasis is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     Anastasis is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with Anastasis; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+
+/**
+ * @file src/include/anastasis-gtk_helper.h
+ * @brief Definition of helpers.
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ */
+#ifndef ANASTASIS_GTK_H
+#define ANASTASIS_GTK_H
+#include <gnunet-gtk/gnunet_gtk.h>
+#include <gtk/gtk.h>
+#include <anastasis/anastasis_service.h>
+#include <anastasis/anastasis_redux.h>
+
+/**
+ * Handle to our main loop.
+ */
+extern struct GNUNET_GTK_MainLoop *ml;
+
+/**
+ * Our configuration.
+ */
+extern const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+/**
+ * Actual state.
+ */
+extern json_t *redux_state;
+
+/**
+ * Handle to an ongoing action.
+ */
+extern struct ANASTASIS_ReduxAction *ra;
+
+
+#endif
diff --git a/src/anastasis/anastasis-gtk_action.c 
b/src/anastasis/anastasis-gtk_action.c
new file mode 100644
index 0000000..1fc4cc7
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -0,0 +1,338 @@
+/*
+     This file is part of anastasis-gtk.
+     Copyright (C) 2020 Anastasis SARL
+
+     Anastasis is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     Anastasis is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with Anastasis; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+
+/**
+ * @file src/anastasis/anastasis-gtk_action.c
+ * @brief Handle redux action results
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ */
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_util_lib.h>
+#include "anastasis-gtk_dispatch.h"
+#include "anastasis-gtk_helper.h"
+#include <jansson.h>
+
+
+/**
+ * Function to persist a state.
+ * FIXME: Don't use this like its used right now (=>PRIVACY)!
+ *
+ * @param state state to persist
+ */
+static int
+persist_state (json_t *state)
+{
+  char *dn;
+
+  {
+    char *path;
+    char *mode;
+
+    if (NULL != json_object_get (state,
+                                 "backup_state"))
+      mode = "backup";
+    else if (NULL != json_object_get (state,
+                                      "recovery_state"))
+      mode = "recovery";
+    else
+    {
+      GNUNET_break (0);
+      return GNUNET_SYSERR;
+    }
+
+    path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_PREFIX);
+    if (NULL == path)
+    {
+      GNUNET_break (0);
+      return GNUNET_SYSERR;
+    }
+    GNUNET_asprintf (&dn,
+                     "%s/share/anastasis/%s_state.json",
+                     path,
+                     mode);
+    GNUNET_free (path);
+  }
+  return json_dump_file (state,
+                         dn,
+                         JSON_COMPACT);
+}
+
+
+/**
+ * Prepare window for selection of the continent.
+ */
+static void
+action_continent_selecting (void)
+{
+  GtkListStore *country_liststore = GTK_LIST_STORE (
+    GCG_get_main_window_object ("country_liststore"));
+
+  AG_hide_all_frames ();
+  gtk_list_store_clear (country_liststore);
+  AG_insensitive ("anastasis_gtk_main_window_forward_button");
+  {
+    GtkListStore *continent_liststore;
+    json_t *continents;
+
+    continent_liststore
+      = GTK_LIST_STORE (
+          GCG_get_main_window_object ("continent_liststore"));
+    gtk_list_store_clear (continent_liststore);
+    continents = json_object_get (redux_state,
+                                  "continents");
+    if (NULL != continents)
+    {
+      json_t *continent;
+      size_t index;
+
+      json_array_foreach (continents,
+                          index,
+                          continent)
+      {
+        gtk_list_store_insert_with_values (continent_liststore,
+                                           NULL,
+                                           -1,
+                                           0, json_string_value (continent),
+                                           -1);
+      }
+    }
+  }
+
+  AG_show ("anastasis_gtk_main_control_vbox");
+  AG_show ("anastasis_gtk_continent_frame");
+  AG_show ("anastasis_gtk_continent_selection_image");
+}
+
+
+/**
+ * Prepare window for selection of the country.
+ */
+static void
+action_country_selecting (void)
+{
+  const char *continent;
+  GtkListStore *country_liststore;
+  json_t *countries;
+
+  AG_hide_all_frames ();
+  continent = json_string_value (json_object_get (
+                                   redux_state,
+                                   "selected_continent"));
+  countries = json_object_get (redux_state,
+                               "countries");
+  country_liststore = GTK_LIST_STORE (
+    GCG_get_main_window_object ("country_liststore"));
+  gtk_list_store_clear (country_liststore);
+  {
+    json_t *country;
+    size_t index;
+
+    json_array_foreach (countries, index, country)
+    {
+      GtkTreeIter iter;
+
+      /* FIXME: use proper enum for columns instead of 0/1/2 */
+      gtk_list_store_insert_with_values (
+        country_liststore,
+        &iter,
+        -1,
+        0,
+        json_string_value (json_object_get (country, "name")),
+        1,
+        json_string_value (json_object_get (country, "code")),
+        2,
+        json_string_value (json_object_get (country, "currency")),
+        -1);
+      /* FIXME: select this country IF state says so! */
+    }
+  }
+
+  AG_insensitive ("anastasis_gtk_main_window_forward_button");
+  AG_show ("anastasis_gtk_country_selection_image");
+  AG_show ("anastasis_gtk_continent_frame");
+  AG_show ("anastasis_gtk_continent_selection_image");
+  AG_show ("anastasis_gtk_country_selection_image");
+}
+
+
+static void
+action_user_attributes_collecting (void)
+{
+  const char *country;
+  const json_t *id_attributes;
+
+  AG_hide_all_frames ();
+  AG_show ("anastasis_gtk_identity_frame");
+  AG_insensitive ("anastasis_gtk_main_window_forward_button");
+  AG_show ("anastasis_gtk_user_attributes_image");
+
+  country = json_string_value (json_object_get (redux_state,
+                                                "selected_country"));
+  GNUNET_assert (NULL != country);
+  id_attributes = json_object_get (redux_state,
+                                   "required_attributes");
+  GNUNET_assert (NULL != id_attributes);
+
+  {
+    GList *children;
+
+    children = gtk_container_get_children (GTK_CONTAINER (
+                                             GCG_get_main_window_object (
+                                               
"anastasis_gtk_identity_vbox")));
+    for (GList *iter = children; iter != NULL; iter = g_list_next (iter))
+      gtk_widget_hide (GTK_WIDGET (iter->data));
+    g_list_free (children);
+  }
+
+  {
+    size_t index;
+    json_t *id_attr;
+
+    json_array_foreach (id_attributes, index, id_attr)
+    {
+      const char *widget_name = json_string_value (json_object_get (id_attr,
+                                                                    "widget"));
+      const char *attr_type = json_string_value (json_object_get (id_attr,
+                                                                  "type"));
+      // const char *attr_name = json_string_value (json_object_get (id_attr, 
"name"));
+      const char *attr_label = json_string_value (json_object_get (id_attr,
+                                                                   "label"));
+
+      if (widget_name)
+      {
+        char *label_widget;
+
+        GNUNET_asprintf (&label_widget,
+                         "%s_label",
+                         widget_name);
+        gtk_label_set_text (GTK_LABEL (GCG_get_main_window_object (
+                                         label_widget)),
+                            attr_label);
+        AG_show (widget_name);
+        GNUNET_free (label_widget);
+      }
+      else if (0 == strcmp (attr_type, "string"))
+      {
+        /**
+         * FIXME: create new widget
+         */
+      }
+      else if (0 == strcmp (attr_type, "date"))
+      {
+        /**
+         * FIXME: create new widget
+         */
+      }
+      /**
+       * FIXME: handle other types
+       */
+    }
+  }
+
+  AG_sensitive ("anastasis_gtk_main_window_forward_button");
+}
+
+
+static void
+action_authentications_editing (void)
+{
+  if (json_object_get (redux_state, "backup_state"))
+  {
+    AG_hide_all_frames ();
+    gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+                                   "anastasis_gtk_b_authentication_frame")));
+    gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+                                   
"anastasis_gtk_b_authentication_methods_image")));
+    init_b_auth_methods (redux_state);
+  }
+}
+
+
+static void
+action_policies_reviewing (void)
+{
+  if (gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
+                                           
"anastasis_gtk_b_authentication_frame"))))
+  {
+    if (json_object_get (redux_state, "backup_state"))
+    {
+      AG_hide_all_frames ();
+      init_b_policy (redux_state);
+      AG_show ("anastasis_gtk_b_policy_frame");
+      AG_show ("anastasis_gtk_b_policies_image");
+      set_policy_check_buttons (redux_state);
+    }
+  }
+}
+
+
+/**
+ * Function called with the results of #ANASTASIS_redux_action.
+ *
+ * @param cls closure
+ * @param error_code Error code
+ * @param response new state as result or config information of a provider
+ */
+void
+AG_action_cb (void *cls,
+              enum TALER_ErrorCode error_code,
+              json_t *response)
+{
+  struct DispatchItem actions[] = {
+    { .state = "CONTINENT_SELECTING",
+      .action = &action_continent_selecting },
+    { .state = "COUNTRY_SELECTING",
+      .action = &action_country_selecting },
+    { .state = "USER_ATTRIBUTES_COLLECTING",
+      .action = &action_user_attributes_collecting },
+    { .state = "AUTHENTICATIONS_EDITING",
+      .action = &action_authentications_editing },
+    { .state = "POLICIES_REVIEWING",
+      .action = &action_policies_reviewing },
+    { .state = "TBD",
+      .action = NULL },
+    { .state = NULL,
+      .action = NULL }
+  };
+
+  ra = NULL;
+  AG_thaw ();
+  if (TALER_EC_NONE != error_code)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Error: %d\n",
+                error_code);
+    /* FIXME: show error nicely in UI! */
+  }
+  else
+  {
+    json_decref (redux_state);
+    redux_state = json_deep_copy (response);
+    GNUNET_assert (0 == persist_state (redux_state));
+  }
+  AG_dispatch (actions);
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+              "Unhandled state, terminating\n");
+  json_dumpf (redux_state,
+              stderr,
+              JSON_INDENT (2));
+  GNUNET_SCHEDULER_shutdown ();
+}
diff --git a/src/anastasis/anastasis-gtk_action.h 
b/src/anastasis/anastasis-gtk_action.h
new file mode 100644
index 0000000..62c0778
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_action.h
@@ -0,0 +1,48 @@
+/*
+     This file is part of anastasis-gtk.
+     Copyright (C) 2020 Anastasis SARL
+
+     Anastasis is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     Anastasis is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with Anastasis; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+
+/**
+ * @file src/include/anastasis-gtk_action.h
+ * @brief Definition of redux action result handler
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ */
+#ifndef ANASTASIS_GTK_ACTION_H
+#define ANASTASIS_GTK_ACTION_H
+#include <gnunet-gtk/gnunet_gtk.h>
+#include <gtk/gtk.h>
+#include <anastasis/anastasis_service.h>
+#include <anastasis/anastasis_redux.h>
+
+
+/**
+ * Function called with the results of #ANASTASIS_redux_action.
+ *
+ * @param cls closure
+ * @param error_code Error code
+ * @param response new state as result or config information of provider
+ */
+void
+AG_action_cb (void *cls,
+              enum TALER_ErrorCode error_code,
+              json_t *response);
+
+
+#endif
diff --git a/src/anastasis/anastasis-gtk_backup.c 
b/src/anastasis/anastasis-gtk_backup.c
index 5891dcb..29d5a47 100644
--- a/src/anastasis/anastasis-gtk_backup.c
+++ b/src/anastasis/anastasis-gtk_backup.c
@@ -26,6 +26,7 @@
  */
 #include <gnunet/platform.h>
 #include <gnunet/gnunet_util_lib.h>
+#include "anastasis-gtk_action.h"
 #include "anastasis-gtk_helper.h"
 #include <jansson.h>
 
@@ -98,7 +99,7 @@ delete_auth_method (gpointer user_data)
             ra = ANASTASIS_redux_action (redux_state,
                                          "delete_authentication",
                                          arguments,
-                                         &action_cb,
+                                         &AG_action_cb,
                                          NULL);
           }
           index++;
@@ -122,38 +123,6 @@ anastasis_gtk_b_auth_method_btn_edit_clicked_cb (GObject 
*object,
                                                  gpointer user_data);
 
 
-/**
- * Callback invoked if the the "backup"-button is clicked.
- *
- * @param object
- * @param user_data unused
- */
-void
-anastasis_gtk_backup_button_clicked (GObject *object,
-                                     gpointer user_data)
-{
-  fprintf (stderr,
-           "BACKUP clicked\n");
-  redux_state = ANASTASIS_backup_start (cfg);
-  GNUNET_assert (0 == persist_state (redux_state));
-
-  if (check_state (redux_state,
-                   "CONTINENT_SELECTION"))
-  {
-    init_continent_list (redux_state);
-
-    gtk_widget_hide (GTK_WIDGET (GCG_get_main_window_object (
-                                   "anastasis_gtk_start_frame")));
-    gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                   "anastasis_gtk_main_control_vbox")));
-    gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                   "anastasis_gtk_continent_frame")));
-    gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                   
"anastasis_gtk_continent_selection_image")));
-  }
-}
-
-
 /**
  * Callback invoked if the the "backup"-button is clicked.
  *
@@ -247,7 +216,7 @@ anastasis_gtk_b_question_dialog_btn_ok_clicked_cb (GObject 
*object,
     ra = ANASTASIS_redux_action (redux_state,
                                  "add_authentication",
                                  arguments,
-                                 &action_cb,
+                                 &AG_action_cb,
                                  NULL);
   }
 
@@ -412,7 +381,7 @@ anastasis_gtk_b_post_dialog_btn_ok_clicked_cb (GObject 
*object,
     ra = ANASTASIS_redux_action (redux_state,
                                  "add_authentication",
                                  arguments,
-                                 &action_cb,
+                                 &AG_action_cb,
                                  NULL);
   }
 
@@ -579,7 +548,7 @@ anastasis_gtk_b_video_dialog_btn_ok_clicked_cb (GObject 
*object,
     ra = ANASTASIS_redux_action (redux_state,
                                  "add_authentication",
                                  arguments,
-                                 &action_cb,
+                                 &AG_action_cb,
                                  NULL);
   }
 
@@ -716,7 +685,7 @@ anastasis_gtk_b_sms_dialog_btn_ok_clicked_cb (GObject 
*object,
     ra = ANASTASIS_redux_action (redux_state,
                                  "add_authentication",
                                  arguments,
-                                 &action_cb,
+                                 &AG_action_cb,
                                  NULL);
   }
 
@@ -851,7 +820,7 @@ anastasis_gtk_b_email_dialog_btn_ok_clicked_cb (GObject 
*object,
     ra = ANASTASIS_redux_action (redux_state,
                                  "add_authentication",
                                  arguments,
-                                 &action_cb,
+                                 &AG_action_cb,
                                  NULL);
   }
 
diff --git a/src/anastasis/anastasis-gtk_dispatch.c 
b/src/anastasis/anastasis-gtk_dispatch.c
new file mode 100644
index 0000000..b20d6b3
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_dispatch.c
@@ -0,0 +1,40 @@
+/*
+     This file is part of anastasis-gtk.
+     Copyright (C) 2021 Anastasis SARL
+
+     Anastasis is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     Anastasis is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with Anastasis; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file src/anastasis/anastasis-gtk_dispatch.c
+ * @brief Generic state dispatcher
+ * @author Christian Grothoff
+ */
+#include <gnunet/platform.h>
+#include "anastasis-gtk_helper.h"
+#include "anastasis-gtk_dispatch.h"
+
+void
+AG_dispatch (const struct DispatchItem *dt)
+{
+  for (unsigned int i = 0; NULL != dt[i].state; i++)
+  {
+    if (! AG_check_state (redux_state,
+                          dt[i].state))
+      continue;
+    dt[i].action ();
+    return;
+  }
+}
diff --git a/src/anastasis/anastasis-gtk_dispatch.h 
b/src/anastasis/anastasis-gtk_dispatch.h
new file mode 100644
index 0000000..df00309
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_dispatch.h
@@ -0,0 +1,53 @@
+/*
+     This file is part of anastasis-gtk.
+     Copyright (C) 2020 Anastasis SARL
+
+     Anastasis is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     Anastasis is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with Anastasis; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file src/anastasis/anastasis-gtk_dispatch.h
+ * @brief Generic state dispatcher
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ */
+#ifndef ANASTASIS_GTK_DISPATCH_H
+#define ANASTASIS_GTK_DISPATCH_H
+
+/**
+ * Dispatch table item.
+ */
+struct DispatchItem
+{
+  /**
+   * State in which to run @a action.
+   */
+  const char *state;
+
+  /**
+   * The action function to execute.
+   */
+  void (*action)(void);
+};
+
+
+/**
+ * Run actions as per the given dispatch table based on the
+ * current #redux_state.
+ */
+void
+AG_dispatch (const struct DispatchItem *dt);
+
+#endif
diff --git a/src/anastasis/anastasis-gtk_handle-backup-button-clicked.c 
b/src/anastasis/anastasis-gtk_handle-backup-button-clicked.c
new file mode 100644
index 0000000..9f06c81
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_handle-backup-button-clicked.c
@@ -0,0 +1,52 @@
+/*
+     This file is part of anastasis-gtk.
+     Copyright (C) 2020 Anastasis SARL
+
+     Anastasis is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     Anastasis is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with Anastasis; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+
+/**
+ * @file src/anastasis/anastasis-gtk_backup.c
+ * @brief Main function of anastasis-gtk
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ */
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_util_lib.h>
+#include "anastasis-gtk_action.h"
+#include "anastasis-gtk_helper.h"
+#include <jansson.h>
+
+
+/**
+ * Callback invoked if the the "backup"-button is clicked.
+ *
+ * @param object
+ * @param user_data unused
+ */
+void
+anastasis_gtk_backup_button_clicked (GObject *object,
+                                     gpointer user_data)
+{
+  json_t *j;
+
+  AG_freeze ();
+  j = ANASTASIS_backup_start (cfg);
+  AG_action_cb (NULL,
+                TALER_EC_NONE,
+                j);
+  json_decref (j);
+}
diff --git a/src/anastasis/anastasis-gtk_handle-continent-activated.c 
b/src/anastasis/anastasis-gtk_handle-continent-activated.c
new file mode 100644
index 0000000..b70fa66
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_handle-continent-activated.c
@@ -0,0 +1,74 @@
+/*
+     This file is part of anastasis-gtk.
+     Copyright (C) 2020 Anastasis SARL
+
+     Anastasis is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     Anastasis is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with Anastasis; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file src/anastasis/anastasis-gtk_handle-continent-activated.c
+ * @brief
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ */
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_util_lib.h>
+#include "anastasis-gtk_helper.h"
+#include "anastasis-gtk_action.h"
+#include <jansson.h>
+
+
+/**
+ * Callback invoked if a continent is selected (row-activated signal).
+ *
+ * @param tree_view the object on which the signal is emitted
+ * @param path the GtkTreePath for the activated row
+ * @param column the GtkTreeViewColumn in which the activation occurred
+ * @param user_data user data set when the signal handler was connected 
(unused)
+ */
+void
+anastasis_gtk_continent_activated (GtkTreeView *tree_view,
+                                   GtkTreePath *path,
+                                   GtkTreeViewColumn *column,
+                                   gpointer user_data)
+{
+  GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
+  GtkTreeIter iter;
+  gchar *continent_name;
+  json_t *arguments;
+
+  if (! gtk_tree_model_get_iter (model, &iter, path))
+  {
+    GNUNET_break (0);
+    return;
+  }
+  gtk_tree_model_get (model,
+                      &iter,
+                      0, &continent_name,
+                      -1);
+  arguments = json_pack ("{s:s}",
+                         "continent",
+                         continent_name);
+  GNUNET_assert (NULL != arguments);
+  g_free (continent_name);
+  AG_freeze ();
+  ra = ANASTASIS_redux_action (redux_state,
+                               "select_continent",
+                               arguments,
+                               &AG_action_cb,
+                               NULL);
+  GNUNET_assert (NULL != ra);
+  json_decref (arguments);
+}
diff --git a/src/anastasis/anastasis-gtk_handle-continent-unselected.c 
b/src/anastasis/anastasis-gtk_handle-continent-unselected.c
new file mode 100644
index 0000000..2c5f532
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_handle-continent-unselected.c
@@ -0,0 +1,59 @@
+/*
+     This file is part of anastasis-gtk.
+     Copyright (C) 2020 Anastasis SARL
+
+     Anastasis is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     Anastasis is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with Anastasis; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file src/anastasis/anastasis-gtk_handle-continent-unselected.c
+ * @brief
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ */
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_util_lib.h>
+#include "anastasis-gtk_helper.h"
+#include "anastasis-gtk_action.h"
+#include <jansson.h>
+
+
+/**
+ * Callback invoked if a continent is unselected (unselected signal).
+ *
+ * @param selection A GtkTreeSelection.
+ * @param user_data user data set when the signal handler was connected.
+ */
+void
+anastasis_gtk_continent_unselected (GtkTreeSelection *selection,
+                                    gpointer user_data)
+{
+  GtkTreeModel *model;
+
+  if (gtk_tree_selection_get_selected (selection,
+                                       &model,
+                                       NULL))
+  {
+    GNUNET_break (0);
+    return;
+  }
+  AG_freeze ();
+  ra = ANASTASIS_redux_action (redux_state,
+                               "unselect_continent",
+                               NULL,
+                               &AG_action_cb,
+                               NULL);
+  GNUNET_assert (NULL != ra);
+}
diff --git a/src/anastasis/anastasis-gtk_handle-country-activated.c 
b/src/anastasis/anastasis-gtk_handle-country-activated.c
new file mode 100644
index 0000000..0ad33bf
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_handle-country-activated.c
@@ -0,0 +1,49 @@
+/*
+     This file is part of anastasis-gtk.
+     Copyright (C) 2020 Anastasis SARL
+
+     Anastasis is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     Anastasis is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with Anastasis; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file src/anastasis/anastasis-gtk_handle-country-activated.c
+ * @brief
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ */
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_util_lib.h>
+#include "anastasis-gtk_helper.h"
+#include "anastasis-gtk_action.h"
+#include "anastasis-gtk_handle-main-window-forward-clicked.h"
+#include <jansson.h>
+
+
+/**
+ * Callback invoked if a country is activated (row-activated signal).
+ *
+ * @param tree_view the object on which the signal is emitted
+ * @param path the GtkTreePath for the activated row
+ * @param column the GtkTreeViewColumn in which the activation occurred
+ * @param user_data user data set when the signal handler was connected 
(unused)
+ */
+void
+anastasis_gtk_country_activated (GtkTreeView *tree_view,
+                                 GtkTreePath *path,
+                                 GtkTreeViewColumn *column,
+                                 gpointer user_data)
+{
+  AG_forward_country_selecting ();
+}
diff --git a/src/anastasis/anastasis-gtk_handle-country-unselected.c 
b/src/anastasis/anastasis-gtk_handle-country-unselected.c
new file mode 100644
index 0000000..5ddbc17
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_handle-country-unselected.c
@@ -0,0 +1,51 @@
+/*
+     This file is part of anastasis-gtk.
+     Copyright (C) 2020 Anastasis SARL
+
+     Anastasis is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     Anastasis is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with Anastasis; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file src/anastasis/anastasis-gtk_handle-country-unselected.c
+ * @brief
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ */
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_util_lib.h>
+#include "anastasis-gtk_action.h"
+#include "anastasis-gtk_helper.h"
+#include <jansson.h>
+
+
+/**
+ * Callback invoked if a country is unselected (unselected signal).
+ *
+ * @param selection A GtkTreeSelection.
+ * @param user_data user data set when the signal handler was connected.
+ */
+void
+anastasis_gtk_country_unselected (GtkTreeSelection *selection,
+                                  gpointer user_data)
+{
+  GtkTreeModel *model;
+
+  if (gtk_tree_selection_get_selected (selection,
+                                       &model,
+                                       NULL))
+    AG_sensitive ("anastasis_gtk_main_window_forward_button");
+  else
+    AG_insensitive ("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
new file mode 100644
index 0000000..a3c0279
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c
@@ -0,0 +1,51 @@
+/*
+     This file is part of anastasis-gtk.
+     Copyright (C) 2020 Anastasis SARL
+
+     Anastasis is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     Anastasis is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with Anastasis; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+
+/**
+ * @file src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c
+ * @brief
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ */
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_util_lib.h>
+#include "anastasis-gtk_action.h"
+#include "anastasis-gtk_helper.h"
+#include <jansson.h>
+
+
+/**
+ * Callback invoked if the the "back"-button is clicked.
+ *
+ * @param object
+ * @param user_data unused
+ */
+void
+anastasis_gtk_main_window_back_clicked (GObject *object,
+                                        gpointer user_data)
+{
+  AG_freeze ();
+  ra = ANASTASIS_redux_action (redux_state,
+                               "back",
+                               NULL,
+                               &AG_action_cb,
+                               NULL);
+  GNUNET_assert (NULL != ra);
+}
diff --git a/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c 
b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
new file mode 100644
index 0000000..dba558b
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
@@ -0,0 +1,212 @@
+/*
+     This file is part of anastasis-gtk.
+     Copyright (C) 2020 Anastasis SARL
+
+     Anastasis is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     Anastasis is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with Anastasis; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
+ * @brief
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ */
+#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 <jansson.h>
+
+
+void
+AG_forward_country_selecting (void)
+{
+  GtkTreeIter iter;
+  GtkTreeModel *model;
+  gchar *country_name;
+  gchar *country_code;
+  gchar *country_currency;
+  json_t *arguments;
+
+  model = GTK_TREE_MODEL (GCG_get_main_window_object ("country_liststore"));
+  gtk_tree_model_get (model,
+                      &iter,
+                      0, &country_name,
+                      1, &country_code,
+                      2, &country_currency,
+                      -1);
+  arguments = json_pack ("{s:s, s:s, s:s}",
+                         "country", country_name,
+                         "country_code", country_code,
+                         "currency", country_currency);
+  GNUNET_assert (NULL != arguments);
+  g_free (country_name);
+  g_free (country_code);
+  g_free (country_currency);
+  AG_freeze ();
+  ra = ANASTASIS_redux_action (redux_state,
+                               "select_country",
+                               arguments,
+                               &AG_action_cb,
+                               NULL);
+  GNUNET_assert (NULL != ra);
+  json_decref (arguments);
+}
+
+
+static void
+forward_user_attributes_collecting (void)
+{
+
+}
+
+
+static void
+forward_authentications_editing (void)
+{
+  GList *children;
+  GList *iter;
+  json_t *arguments = json_object ();
+  json_t *id_attr = json_object ();
+
+  if (! check_attributes_fullfilled ())
+  {
+    GNUNET_break (0);
+    return;
+  }
+  children = gtk_container_get_children (GTK_CONTAINER (
+                                           GCG_get_main_window_object (
+                                             "anastasis_gtk_identity_vbox")));
+  for (iter = children; iter != NULL; iter = g_list_next (iter))
+  {
+    char *entry_widget;
+    char *cal_widget;
+    const char *widget = gtk_buildable_get_name (iter->data);
+
+    GNUNET_asprintf (&entry_widget,
+                     "%s_entry",
+                     widget);
+    GNUNET_asprintf (&cal_widget,
+                     "%s_cal",
+                     widget);
+
+    if (GCG_get_main_window_object (entry_widget))
+    {
+      const char *value = gtk_entry_get_text (GTK_ENTRY (
+                                                GCG_get_main_window_object (
+                                                  entry_widget)));
+      if (0 == strlen (value))
+        break;
+      if (strstr (widget, "ia_ahv"))
+        json_object_set_new (id_attr, "ahv_number", json_string (value));
+      if (strstr (widget, "ia_ssn"))
+        json_object_set_new (id_attr, "social_security_number", json_string (
+                               value));
+      if (strstr (widget, "ia_full_name"))
+        json_object_set_new (id_attr, "full_name", json_string (value));
+    }
+    if (GCG_get_main_window_object (cal_widget))
+    {
+      guint day;
+      guint month;
+      guint year;
+
+      gtk_calendar_get_date (GTK_CALENDAR (GCG_get_main_window_object (
+                                             cal_widget)),
+                             &year,
+                             &month,
+                             &day);
+      json_object_set_new (id_attr, "birth_year", json_integer (year));
+      json_object_set_new (id_attr, "birth_month", json_integer (month));
+      json_object_set_new (id_attr, "birth_day", json_integer (day));
+    }
+    GNUNET_free (entry_widget);
+    GNUNET_free (cal_widget);
+  }
+  json_object_set_new (arguments, "identity_attributes", id_attr);
+
+  if (AG_check_state (redux_state,
+                      "USER_ATTRIBUTES_COLLECTION"))
+  {
+#if FIXME
+    json_t *auth_providers = get_authentication_providers ();
+    if (NULL != auth_providers)
+      json_object_set_new (arguments,
+                           "authentication_providers",
+                           auth_providers);
+    ra = ANASTASIS_redux_action (redux_state,
+                                 "enter_user_attributes",
+                                 arguments,
+                                 &AG_action_cb,
+                                 NULL);
+#endif
+  }
+  g_list_free (children);
+
+  AG_insensitive ("anastasis_gtk_main_window_forward_button");
+
+  {
+    json_t *auth_methods = json_object_get (redux_state,
+                                            "authentication_methods");
+
+    if (json_array_size (auth_methods) > 0)
+    {
+      AG_freeze ();
+      ra = ANASTASIS_redux_action (redux_state,
+                                   "next",
+                                   NULL,
+                                   &AG_action_cb,
+                                   NULL);
+      GNUNET_assert (NULL != ra);
+    }
+  }
+}
+
+
+static void
+forward_policies_reviewing (void)
+{
+
+}
+
+
+/**
+ * Callback invoked if the the "forward"-button is clicked.
+ *
+ * @param object
+ * @param user_data unused
+ */
+void
+anastasis_gtk_main_window_forward_clicked (GObject *object,
+                                           gpointer user_data)
+{
+  struct DispatchItem actions[] = {
+    { .state = "COUNTRY_SELECTING",
+      .action = &AG_forward_country_selecting },
+    { .state = "USER_ATTRIBUTES_COLLECTING",
+      .action = &forward_user_attributes_collecting },
+    { .state = "AUTHENTICATIONS_EDITING",
+      .action = &forward_authentications_editing },
+    { .state = "POLICIES_REVIEWING",
+      .action = &forward_policies_reviewing },
+    { .state = "TBD",
+      .action = NULL },
+    { .state = NULL,
+      .action = NULL }
+  };
+
+  AG_dispatch (actions);
+}
diff --git a/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.h 
b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.h
new file mode 100644
index 0000000..49513b6
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.h
@@ -0,0 +1,33 @@
+/*
+     This file is part of anastasis-gtk.
+     Copyright (C) 2020 Anastasis SARL
+
+     Anastasis is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     Anastasis is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with Anastasis; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.h
+ * @brief
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ */
+#ifndef ANASTASIS_GTK_HANDLE_MAIN_WINDOW_FORDWARD_CLICKED_H
+#define ANASTASIS_GTK_HANDLE_MAIN_WINDOW_FORDWARD_CLICKED_H
+
+
+void
+AG_forward_country_selecting (void);
+
+#endif
diff --git a/src/anastasis/anastasis-gtk_helper.c 
b/src/anastasis/anastasis-gtk_helper.c
index 992974a..458f925 100644
--- a/src/anastasis/anastasis-gtk_helper.c
+++ b/src/anastasis/anastasis-gtk_helper.c
@@ -29,51 +29,129 @@
 #include "anastasis-gtk_helper.h"
 #include <jansson.h>
 
-/**
- * List of authentication methods and their supporting providers.
- */
-static json_t*providers;
 
-/**
- * List of providers we do not have a config response yet.
- */
-static json_t*missing_providers;
+void
+AG_thaw ()
+{
+  GNUNET_assert (NULL == ra);
+}
 
 
-/**
- * Returs the authentication providers.
- *
- * @return json_t
- */
-json_t *
-get_authentication_providers ()
+void
+AG_freeze ()
 {
-  json_t *auth_providers = json_object_get (providers,
-                                            "authentication_providers");
-  return auth_providers;
+  GNUNET_assert (NULL == ra);
 }
 
 
-/**
- * Reset the list of authentication providers.
- */
 void
-reset_authentication_providers ()
+AG_sensitive (const char *name)
 {
-  if (NULL != providers)
-    GNUNET_assert (0 == json_object_clear (providers));
+  GtkWidget *w;
+
+  w = GTK_WIDGET (GCG_get_main_window_object (name));
+  if (NULL == w)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Widget `%s' not found, cannot make it sensitive!\n",
+                name);
+    return;
+  }
+  gtk_widget_set_sensitive (w,
+                            true);
 }
 
 
-/**
- * Returs the providers which did not respond yet.
- *
- * @return json_t
- */
-json_t *
-get_missing_providers ()
+void
+AG_insensitive (const char *name)
 {
-  return missing_providers;
+  GtkWidget *w;
+
+  w = GTK_WIDGET (GCG_get_main_window_object (name));
+  if (NULL == w)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Widget `%s' not found, cannot make it sensitive!\n",
+                name);
+    return;
+  }
+  gtk_widget_set_sensitive (w,
+                            false);
+}
+
+
+void
+AG_hide (const char *name)
+{
+  GtkWidget *w;
+
+  w = GTK_WIDGET (GCG_get_main_window_object (name));
+  if (NULL == w)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Widget `%s' not found, cannot hide it!\n",
+                name);
+    return;
+  }
+  gtk_widget_hide (w);
+}
+
+
+void
+AG_show (const char *name)
+{
+  GtkWidget *w;
+
+  w = GTK_WIDGET (GCG_get_main_window_object (name));
+  if (NULL == w)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Widget `%s' not found, cannot show it!\n",
+                name);
+    return;
+  }
+  gtk_widget_show (w);
+}
+
+
+void
+AG_hide_all_frames (void)
+{
+  GList *children;
+  GList *iter;
+
+  AG_hide ("anastasis_gtk_start_frame");
+  /* hide frames */
+  children = gtk_container_get_children (GTK_CONTAINER (
+                                           GCG_get_main_window_object (
+                                             "anastasis_gtk_super_vbox")));
+  for (iter = children; NULL != iter; iter = g_list_next (iter))
+    gtk_widget_hide (GTK_WIDGET (iter->data));
+  g_list_free (children);
+
+  /* hide illustrations */
+  children = gtk_container_get_children (GTK_CONTAINER (
+                                           GCG_get_main_window_object (
+                                             
"anastasis_gtk_illustration_vbox")));
+  for (iter = children; NULL != iter; iter = g_list_next (iter))
+    gtk_widget_hide (GTK_WIDGET (iter->data));
+  g_list_free (children);
+}
+
+
+bool
+AG_check_state (json_t *state,
+                const char *expected_state)
+{
+  const char *state_name = json_string_value (json_object_get (state,
+                                                               
"backup_state"));
+  if (NULL == state_name)
+    state_name = json_string_value (json_object_get (state,
+                                                     "recovery_state"));
+  if (NULL == state_name)
+    return false;
+  return (0 == strcasecmp (state_name,
+                           expected_state));
 }
 
 
@@ -199,321 +277,6 @@ GCG_get_main_window_object (const char *name)
 {
   if (NULL == ml)
     return NULL;
-  return GNUNET_GTK_main_loop_get_object (ml, name);
-}
-
-
-/**
- * Function to persist a state.
- * FIXME: Don't use this like its used right now (=>PRIVACY)!
- *
- * @param state state to persist
- */
-int
-persist_state (json_t *state)
-{
-  char *dn;
-
-  {
-    char *path;
-    char *mode;
-
-    if (NULL != json_object_get (state, "backup_state"))
-      mode = "backup";
-    else if (NULL != json_object_get (state, "recovery_state"))
-      mode = "recovery";
-    else
-    {
-      GNUNET_break (0);
-      return GNUNET_SYSERR;
-    }
-
-    path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_PREFIX);
-    if (NULL == path)
-    {
-      GNUNET_break (0);
-      return GNUNET_SYSERR;
-    }
-    GNUNET_asprintf (&dn,
-                     "%s/share/anastasis/%s_state.json",
-                     path,
-                     mode);
-    GNUNET_free (path);
-  }
-  return json_dump_file (state, dn, JSON_COMPACT);
-}
-
-
-/**
- * Hides all frames;
- */
-void
-anastasis_gtk_hide_all_frames ()
-{
-  GList *children, *iter;
-
-  // hide frames
-  children = gtk_container_get_children (GTK_CONTAINER (
-                                           GCG_get_main_window_object (
-                                             "anastasis_gtk_super_vbox")));
-  for (iter = children; iter != NULL; iter = g_list_next (iter))
-  {
-    gtk_widget_hide (GTK_WIDGET (iter->data));
-  }
-  g_list_free (children);
-
-  // hide illustrations
-  children = gtk_container_get_children (GTK_CONTAINER (
-                                           GCG_get_main_window_object (
-                                             
"anastasis_gtk_illustration_vbox")));
-  for (iter = children; iter != NULL; iter = g_list_next (iter))
-  {
-    gtk_widget_hide (GTK_WIDGET (iter->data));
-  }
-  g_list_free (children);
-}
-
-
-/**
- * Function called with the results of #ANASTASIS_redux_action.
- *
- * @param cls closure
- * @param error_code Error code
- * @param response new state as result or config information of a provider
- */
-void
-action_cb (void *cls,
-           enum TALER_ErrorCode error_code,
-           json_t *response)
-{
-  if (NULL != response)
-    redux_state = json_deep_copy (response);
-  else
-  {
-    GNUNET_SCHEDULER_shutdown ();
-    return;
-  }
-  if (check_state (redux_state,
-                   "CONTINENT_SELECTION"))
-  {
-    GtkListStore *country_liststore = GTK_LIST_STORE (
-      GCG_get_main_window_object ("country_liststore"));
-
-    anastasis_gtk_hide_all_frames ();
-    gtk_list_store_clear (country_liststore);
-    gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
-                                            
"anastasis_gtk_main_window_forward_button")),
-                              false);
-    gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                   
"anastasis_gtk_continent_selection_image")));
-  }
-  if (check_state (redux_state,
-                   "COUNTRY_SELECTION"))
-  {
-    anastasis_gtk_hide_all_frames ();
-    init_country_list (redux_state, json_string_value (json_object_get (
-                                                         redux_state,
-                                                         
"selected_continent")));
-    gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                   "anastasis_gtk_country_selection_image")));
-    gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                   "anastasis_gtk_continent_frame")));
-    gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
-                                            
"anastasis_gtk_main_window_forward_button")),
-                              false);
-    gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                   
"anastasis_gtk_continent_selection_image")));
-    gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                   "anastasis_gtk_country_selection_image")));
-  }
-  if (check_state (redux_state,
-                   "USER_ATTRIBUTES_COLLECTION"))
-  {
-    gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
-                                            
"anastasis_gtk_main_window_forward_button")),
-                              true);
-    init_id_attr (redux_state, json_string_value (json_object_get (redux_state,
-                                                                   
"selected_country")));
-  }
-  if (check_state (redux_state,
-                   "AUTHENTICATIONS_EDITING"))
-  {
-    if (json_object_get (redux_state, "backup_state"))
-    {
-      anastasis_gtk_hide_all_frames ();
-      gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                     "anastasis_gtk_b_authentication_frame")));
-      gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                     
"anastasis_gtk_b_authentication_methods_image")));
-      init_b_auth_methods (redux_state);
-    }
-  }
-  if (check_state (redux_state,
-                   "POLICIES_REVIEWING")
-      && gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
-                                              
"anastasis_gtk_b_authentication_frame"))))
-  {
-    if (json_object_get (redux_state, "backup_state"))
-    {
-      anastasis_gtk_hide_all_frames ();
-      init_b_policy (redux_state);
-      gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                     "anastasis_gtk_b_policy_frame")));
-      gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-                                     "anastasis_gtk_b_policies_image")));
-      set_policy_check_buttons (redux_state);
-    }
-  }
-  /** FIXME: Don't use this like this; now used to check if json state is 
build correctly */
-  if (0 == persist_state (redux_state))
-    return;
-  else
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Failed to persist new state! \n");
-
-
-  /** FIXME: see above
-   * GNUNET_SCHEDULER_shutdown (); */
-}
-
-
-bool
-check_state (json_t *state, const char *expected_state)
-{
-  const char *state_name = json_string_value (json_object_get (state,
-                                                               
"backup_state"));
-  if (NULL == state_name)
-    state_name = json_string_value (json_object_get (state, "recovery_state"));
-  if (0 == strcmp (state_name, expected_state))
-    return true;
-  else
-    return false;
-}
-
-
-/**
- * Initialize the continent list.
- *
- * @param init_state the initial state to get the continents from
- */
-void
-init_continent_list (json_t *init_state)
-{
-  GtkListStore *continent_liststore;
-  GtkTreeIter iter;
-  json_t *continent;
-  size_t index;
-  json_t *continents = json_object_get (init_state, "continents");
-
-  continent_liststore = GTK_LIST_STORE (
-    GCG_get_main_window_object ("continent_liststore"));
-  gtk_list_store_clear (continent_liststore);
-  json_array_foreach (continents, index, continent)
-  {
-    gtk_list_store_append (continent_liststore, &iter);
-    gtk_list_store_set (continent_liststore, &iter,
-                        0, json_string_value (continent),
-                        -1);
-  }
-}
-
-
-/**
- * Initialize the country list in dependence of selected continent.
- *
- * @param state the state to get the countries from
- * @param continent name of the selected continent
- */
-void
-init_country_list (json_t *state,
-                   const char *continent)
-{
-  GtkTreeView *tree_view;
-  GtkListStore *country_liststore;
-  GtkTreeIter iter;
-  json_t *country;
-  size_t index;
-  json_t *countries = json_object_get (state, "countries");
-
-  country_liststore = GTK_LIST_STORE (
-    GCG_get_main_window_object ("country_liststore"));
-  tree_view = GTK_TREE_VIEW (GCG_get_main_window_object (
-                               "anastasis_gtk_country_treeview"));
-  gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL (country_liststore));
-  gtk_list_store_clear (country_liststore);
-  json_array_foreach (countries, index, country)
-  {
-    gtk_list_store_append (country_liststore, &iter);
-    gtk_list_store_set (country_liststore, &iter,
-                        0, json_string_value (json_object_get (country,
-                                                               "name")),       
       // FIXME implement i18n
-                        1, json_string_value (json_object_get (country,
-                                                               "code")),
-                        2, json_string_value (json_object_get (country,
-                                                               "currency")),
-                        -1);
-  }
-}
-
-
-/**
- * Initialize the identity attributes in dependence of selected country.
- *
- * @param state the state to get the attributes from
- * @param country name of the selected country
- */
-void
-init_id_attr (json_t *state,
-              const char *country)
-{
-  GList *children, *iter;
-  size_t index;
-  json_t *id_attr;
-  json_t *id_attributes = json_object_get (state, "required_attributes");
-
-  children = gtk_container_get_children (GTK_CONTAINER (
-                                           GCG_get_main_window_object (
-                                             "anastasis_gtk_identity_vbox")));
-  for (iter = children; iter != NULL; iter = g_list_next (iter))
-    gtk_widget_hide (GTK_WIDGET (iter->data));
-  g_list_free (children);
-
-  json_array_foreach (id_attributes, index, id_attr)
-  {
-    const char *widget_name = json_string_value (json_object_get (id_attr,
-                                                                  "widget"));
-    const char *attr_type = json_string_value (json_object_get (id_attr,
-                                                                "type"));
-    // const char *attr_name = json_string_value (json_object_get (id_attr, 
"name"));
-    const char *attr_label = json_string_value (json_object_get (id_attr,
-                                                                 "label"));
-
-    if (widget_name)
-    {
-      char *label_widget;
-      GNUNET_asprintf (&label_widget,
-                       "%s_label",
-                       widget_name);
-      gtk_label_set_text (GTK_LABEL (GCG_get_main_window_object 
(label_widget)),
-                          attr_label);                                         
                     // FIXME: i18n
-      gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (widget_name)));
-
-      GNUNET_free (label_widget);
-    }
-    else if (0 == strcmp (attr_type, "string"))
-    {
-      /**
-       * FIXME: create new widget
-       */
-    }
-    else if (0 == strcmp (attr_type, "date"))
-    {
-      /**
-       * FIXME: create new widget
-       */
-    }
-    /**
-     * FIXME: handle other types
-     */
-  }
+  return GNUNET_GTK_main_loop_get_object (ml,
+                                          name);
 }
diff --git a/src/include/anastasis-gtk_helper.h 
b/src/anastasis/anastasis-gtk_helper.h
similarity index 61%
rename from src/include/anastasis-gtk_helper.h
rename to src/anastasis/anastasis-gtk_helper.h
index ff7d0d1..235f41b 100644
--- a/src/include/anastasis-gtk_helper.h
+++ b/src/anastasis/anastasis-gtk_helper.h
@@ -24,79 +24,63 @@
  * @author Christian Grothoff
  * @author Dennis Neufeld
  */
-
+#ifndef ANASTASIS_GTK_HELPER_H
+#define ANASTASIS_GTK_HELPER_H
 #include <gnunet-gtk/gnunet_gtk.h>
 #include <gtk/gtk.h>
 #include <anastasis/anastasis_service.h>
 #include <anastasis/anastasis_redux.h>
+#include "anastasis-gtk.h"
 
-/**
- * Handle to our main loop.
- */
-extern struct GNUNET_GTK_MainLoop *ml;
-
-/**
- * Our configuration.
- */
-extern struct GNUNET_CONFIGURATION_Handle *cfg;
-
-/**
- * Actual state.
- */
-extern json_t *redux_state;
 
 /**
- * Curl context for communication with taler backend
+ * Hide widget of the given @a name of the main window
+ *
+ * @param name widget to hide
  */
-extern struct GNUNET_CURL_Context *ctx;
+void
+AG_hide (const char *name);
 
-/**
- * Closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
- */
-extern struct GNUNET_CURL_RescheduleContext *rc;
 
 /**
- * Handle to an ongoing action.
+ * Show widget of the given @a name of the main window
+ *
+ * @param name widget to show
  */
-extern struct ANASTASIS_ReduxAction *ra;
+void
+AG_show (const char *name);
 
 
 /**
- * Function called with the results of #ANASTASIS_redux_action.
+ * Make widget of the given @a name of the main window insensitive.
  *
- * @param cls closure
- * @param error_code Error code
- * @param response new state as result or config information of provider
+ * @param name widget to make insensitive
  */
 void
-action_cb (void *cls,
-           enum TALER_ErrorCode error_code,
-           json_t *response);
+AG_insensitive (const char *name);
 
 
 /**
- * Returs the authentication providers.
+ * Make widget of the given @a name of the main window sensitive.
  *
- * @return json_t
+ * @param name widget to make sensitive
  */
-json_t *
-get_authentication_providers (void);
+void
+AG_sensitive (const char *name);
 
 
 /**
- * Reset the list of authentication providers.
+ * Thaw the user interface.
  */
 void
-reset_authentication_providers (void);
+AG_thaw (void);
 
 
 /**
- * Function to persist a state.
- *
- * @param state state to persist
+ * Freeze the user interface while the action completes.
  */
-int
-persist_state (json_t *state);
+void
+AG_freeze (void);
 
 
 /**
@@ -126,38 +110,8 @@ check_attributes_fullfilled ();
  * @return bool
  */
 bool
-check_state (json_t *state, const char *expected_state);
-
-
-/**
- * Initialize the continent list.
- *
- * @param init_state the initial state to get the continents from
- */
-void
-init_continent_list (json_t *init_state);
-
-
-/**
- * Initialize the country list in dependence of selected continent.
- *
- * @param state the state to get the countries from
- * @param continent name of the selected continent
- */
-void
-init_country_list (json_t *tate,
-                   const char *continent);
-
-
-/**
- * Initialize the identity attributes in dependence of selected country.
- *
- * @param state the state to get the attributes from
- * @param country name of the selected country
- */
-void
-init_id_attr (json_t *state,
-              const char *country);
+AG_check_state (json_t *state,
+                const char *expected_state);
 
 
 /**
@@ -225,4 +179,7 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
  * Hides all frames;
  */
 void
-anastasis_gtk_hide_all_frames ();
+AG_hide_all_frames (void);
+
+
+#endif
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
deleted file mode 100644
index 0ebb036..0000000
--- a/src/include/Makefile.am
+++ /dev/null
@@ -1,8 +0,0 @@
-# This Makefile.am is in the public domain
-EXTRA_DIST = \
-  platform.h
-
-anastasisgtkincludedir = $(includedir)/anastasis-gtk
-
-anastasisgtkinclude_HEADERS = \
-  anastasis-gtk_helper.h
\ No newline at end of file

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