gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] branch master updated (9ca91ba -> 560ddb0)


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated (9ca91ba -> 560ddb0)
Date: Tue, 15 Sep 2020 19:27:10 +0200

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

dennis-neufeld pushed a change to branch master
in repository anastasis-gtk.

    from 9ca91ba  added helper
     new 670d2b4  show continent list
     new 292c0a2  worked on select country
     new c7f23ef  fix continent selection
     new 82f470a  fix country list
     new 55536d3  add prev-/forward-button functionality
     new 57f44e7  fix country selection
     new 560ddb0  start with identity attributes

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 contrib/anastasis_gtk_main_window.glade | 172 ++++++++++++++-
 src/anastasis/Makefile.am               |   2 +
 src/anastasis/anastasis-gtk.c           |  14 +-
 src/anastasis/anastasis-gtk_backup.c    |  55 ++---
 src/anastasis/anastasis-gtk_helper.c    | 362 ++++++++++++++++++++++++++++++++
 src/include/anastasis-gtk_helper.h      |  92 ++++++++
 6 files changed, 639 insertions(+), 58 deletions(-)
 create mode 100644 src/anastasis/anastasis-gtk_helper.c

diff --git a/contrib/anastasis_gtk_main_window.glade 
b/contrib/anastasis_gtk_main_window.glade
index c1bc601..ee59fa3 100644
--- a/contrib/anastasis_gtk_main_window.glade
+++ b/contrib/anastasis_gtk_main_window.glade
@@ -8,7 +8,13 @@
     <property name="stock">gtk-go-up</property>
     <property name="icon_size">6</property>
   </object>
-  <object class="GtkListStore" id="continent_Europa_liststore">
+  <object class="GtkListStore" id="continent_liststore">
+    <columns>
+      <!-- column-name continent_name -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
+  <object class="GtkListStore" id="country_liststore">
     <columns>
       <!-- column-name country_name -->
       <column type="gchararray"/>
@@ -22,12 +28,6 @@
       </row>
     </data>
   </object>
-  <object class="GtkListStore" id="continent_liststore">
-    <columns>
-      <!-- column-name continent_name -->
-      <column type="gchararray"/>
-    </columns>
-  </object>
   <object class="GtkImage" id="restore_image">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -207,6 +207,8 @@
                                         <property 
name="model">continent_liststore</property>
                                         <property 
name="enable_search">False</property>
                                         <property 
name="search_column">0</property>
+                                        <property 
name="activate_on_single_click">True</property>
+                                        <signal name="row-activated" 
handler="anastasis_gtk_continent_activated" swapped="no"/>
                                         <child internal-child="selection">
                                           <object class="GtkTreeSelection"/>
                                         </child>
@@ -232,7 +234,10 @@
                                       <object class="GtkTreeView" 
id="anastasis_gtk_country_treeview">
                                         <property 
name="visible">True</property>
                                         <property 
name="can_focus">True</property>
+                                        <property 
name="enable_search">False</property>
                                         <property 
name="search_column">0</property>
+                                        <property 
name="activate_on_single_click">True</property>
+                                        <signal name="row-activated" 
handler="anastasis_gtk_country_activated" swapped="no"/>
                                         <child internal-child="selection">
                                           <object class="GtkTreeSelection"/>
                                         </child>
@@ -273,7 +278,157 @@
                           </packing>
                         </child>
                         <child>
-                          <placeholder/>
+                          <object class="GtkFrame" 
id="anastasis_gtk_identity_frame">
+                            <property name="can_focus">False</property>
+                            <property name="label_xalign">0</property>
+                            <property name="shadow_type">none</property>
+                            <child>
+                              <object class="GtkAlignment">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <object class="GtkBox" 
id="anastasis_gtk_identity_vbox">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property 
name="orientation">vertical</property>
+                                    <child>
+                                      <object class="GtkBox" 
id="anastasis_gtk_id_attr_full_name">
+                                        <property 
name="name">anastasis_gtk_id_attr_full_name</property>
+                                        <property 
name="visible">True</property>
+                                        <property 
name="can_focus">False</property>
+                                        <child>
+                                          <object class="GtkLabel" 
id="label_id_attr_full_name">
+                                            <property 
name="visible">True</property>
+                                            <property 
name="can_focus">False</property>
+                                            <property 
name="halign">start</property>
+                                            <property 
name="valign">center</property>
+                                            <property 
name="margin_start">10</property>
+                                            <property 
name="hexpand">True</property>
+                                            <property name="label" 
translatable="yes">Full name:</property>
+                                          </object>
+                                          <packing>
+                                            <property 
name="expand">False</property>
+                                            <property 
name="fill">True</property>
+                                            <property 
name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkEntry">
+                                            <property 
name="visible">True</property>
+                                            <property 
name="can_focus">True</property>
+                                            <property 
name="hexpand">True</property>
+                                            <property name="placeholder_text" 
translatable="yes">Max Mustermann</property>
+                                          </object>
+                                          <packing>
+                                            <property 
name="expand">False</property>
+                                            <property 
name="fill">True</property>
+                                            <property 
name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property 
name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkBox">
+                                        <property 
name="visible">True</property>
+                                        <property 
name="can_focus">False</property>
+                                        <child>
+                                          <object class="GtkLabel">
+                                            <property 
name="visible">True</property>
+                                            <property 
name="can_focus">False</property>
+                                            <property 
name="halign">start</property>
+                                            <property 
name="valign">center</property>
+                                            <property 
name="margin_start">10</property>
+                                            <property 
name="hexpand">True</property>
+                                            <property name="label" 
translatable="yes">AHV number:</property>
+                                          </object>
+                                          <packing>
+                                            <property 
name="expand">False</property>
+                                            <property 
name="fill">True</property>
+                                            <property 
name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkEntry">
+                                            <property 
name="visible">True</property>
+                                            <property 
name="can_focus">True</property>
+                                            <property 
name="hexpand">True</property>
+                                            <property name="placeholder_text" 
translatable="yes">123456789</property>
+                                          </object>
+                                          <packing>
+                                            <property 
name="expand">False</property>
+                                            <property 
name="fill">True</property>
+                                            <property 
name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property 
name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkBox">
+                                        <property 
name="visible">True</property>
+                                        <property 
name="can_focus">False</property>
+                                        <child>
+                                          <object class="GtkLabel">
+                                            <property 
name="visible">True</property>
+                                            <property 
name="can_focus">False</property>
+                                            <property 
name="halign">start</property>
+                                            <property 
name="valign">center</property>
+                                            <property 
name="margin_start">10</property>
+                                            <property 
name="hexpand">True</property>
+                                            <property name="label" 
translatable="yes">Social security number:</property>
+                                          </object>
+                                          <packing>
+                                            <property 
name="expand">False</property>
+                                            <property 
name="fill">True</property>
+                                            <property 
name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkEntry">
+                                            <property 
name="visible">True</property>
+                                            <property 
name="can_focus">True</property>
+                                            <property 
name="hexpand">True</property>
+                                            <property name="placeholder_text" 
translatable="yes">123456789</property>
+                                          </object>
+                                          <packing>
+                                            <property 
name="expand">False</property>
+                                            <property 
name="fill">True</property>
+                                            <property 
name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property 
name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">2</property>
+                                      </packing>
+                                    </child>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                            <child type="label">
+                              <object class="GtkLabel">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Who 
are you?</property>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">2</property>
+                          </packing>
                         </child>
                         <child>
                           <placeholder/>
@@ -401,6 +556,7 @@
               <object class="GtkButton" 
id="anastasis_gtk_main_window_forward_button">
                 <property name="label">gtk-go-forward</property>
                 <property name="visible">True</property>
+                <property name="sensitive">False</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_stock">True</property>
diff --git a/src/anastasis/Makefile.am b/src/anastasis/Makefile.am
index 3d50473..be38f24 100644
--- a/src/anastasis/Makefile.am
+++ b/src/anastasis/Makefile.am
@@ -12,6 +12,7 @@ bin_PROGRAMS = anastasis-gtk
 
 anastasis_gtk_SOURCES = \
   anastasis-gtk.c \
+  anastasis-gtk_helper.c \
   anastasis-gtk_about.c \
   anastasis-gtk_backup.c \
   os_installation.c
@@ -22,6 +23,7 @@ anastasis_gtk_LDADD = \
   -lanastasisredux \
   -lgnunetgtk \
   -lgnunetutil \
+  -ljansson \
   $(INTLLIBS)
 anastasis_gtk_LDFLAGS = \
   -export-dynamic
diff --git a/src/anastasis/anastasis-gtk.c b/src/anastasis/anastasis-gtk.c
index 0071f00..18ab3ab 100644
--- a/src/anastasis/anastasis-gtk.c
+++ b/src/anastasis/anastasis-gtk.c
@@ -28,6 +28,7 @@
 #include <gnunet/gnunet_util_lib.h>
 #include <gnunet-gtk/gnunet_gtk.h>
 #include "anastasis-gtk_helper.h"
+#include <jansson.h>
 
 /**
  * Handle to our main loop.
@@ -40,18 +41,9 @@ struct GNUNET_GTK_MainLoop *ml;
 struct GNUNET_CONFIGURATION_Handle *cfg;
 
 /**
- * Get an object from the main window.
- *
- * @param name name of the object
- * @return NULL on error
+ * Actual state.
  */
-GObject *
-GCG_get_main_window_object (const char *name)
-{
-  if (NULL == ml)
-    return NULL;
-  return GNUNET_GTK_main_loop_get_object (ml, name);
-}
+json_t *redux_state;
 
 
 /**
diff --git a/src/anastasis/anastasis-gtk_backup.c 
b/src/anastasis/anastasis-gtk_backup.c
index 6dde733..7046f43 100644
--- a/src/anastasis/anastasis-gtk_backup.c
+++ b/src/anastasis/anastasis-gtk_backup.c
@@ -27,8 +27,9 @@
 #include <gnunet/platform.h>
 #include <gnunet/gnunet_util_lib.h>
 #include <gnunet-gtk/gnunet_gtk.h>
+#include <gtk/gtk.h>
 #include "anastasis-gtk_helper.h"
-#include <anastasis/anastasis_redux.h>
+#include <jansson.h>
 
 
 /**
@@ -41,44 +42,20 @@ void
 anastasis_gtk_backup_button_clicked (GObject *object,
                                      gpointer user_data)
 {
-     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")));
-
-     json_t *init_state = ANASTASIS_backup_start (cfg);
-
-     gtk_tree
-}
-
-
-/**
- * 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)
-{
-
-}
-
-
-/**
- * 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)
-{
-
+     redux_state = ANASTASIS_backup_start (cfg);
+     GNUNET_assert (0 == persist_state (redux_state));
+
+     if (check_state (redux_state, "ReduxInitialBackupState"))
+     {
+          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")));
+     }
 }
 
 
diff --git a/src/anastasis/anastasis-gtk_helper.c 
b/src/anastasis/anastasis-gtk_helper.c
new file mode 100644
index 0000000..ddd0f01
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_helper.c
@@ -0,0 +1,362 @@
+/*
+     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_helper.c
+ * @brief Helper functions of anastasis-gtk
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ */
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet-gtk/gnunet_gtk.h>
+#include <gtk/gtk.h>
+#include "anastasis-gtk_helper.h"
+#include <jansson.h>
+
+
+/**
+ * Get an object from the main window.
+ *
+ * @param name name of the object
+ * @return NULL on error
+ */
+GObject *
+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.
+ * 
+ * @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);
+}
+
+
+/**
+ * Function called with the results of #ANASTASIS_backup_action
+ * or #ANASTASIS_recovery_action.
+ *
+ * @param cls closure
+ * @param error_code Error code
+ * @param new_state new state as result
+ */
+static void
+action_cb (void *cls,
+           enum ANASTASIS_ErrorCode error_code,
+           json_t *result_state)
+{
+    if (NULL != result_state)
+    {
+        redux_state = json_deep_copy (result_state);
+        if (check_state (redux_state, "ReduxContinentSelectedState"))
+            init_country_list (redux_state, json_string_value (json_object_get 
(redux_state, "selected_continent")));
+        if (check_state (redux_state, "ReduxCountrySelectedState"))
+            gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
+                                        
"anastasis_gtk_main_window_forward_button")), true);
+
+        if (0 == persist_state (redux_state))
+            return;
+        else
+            GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Failed to persist new state! \n");
+    }
+    GNUNET_SCHEDULER_shutdown ();
+}
+
+
+/**
+ * Checks the actual state. True, if state is correct, else false.
+ * 
+ * @param state the state to check
+ * @param state_name the expected state
+ * @return bool
+ */
+bool
+check_state (json_t *state, char *expected_state)
+{
+    const char *state_name = json_string_value (json_object_get (state, 
"backup-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")),
+                            -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)
+{
+    json_t *id_attributes = json_object_get (state, "required_attributes");
+}
+
+
+/**
+ * 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);
+
+        if (gtk_tree_model_get_iter(model, &iter, path))
+        {
+            gchar *continent_name;
+            json_t *arguments = json_object ();
+
+            if (NULL == arguments)
+            {
+                GNUNET_break (0);
+            }
+            gtk_tree_model_get (model, &iter, 0, &continent_name, -1);
+            json_object_set (arguments, "continent", json_string 
(continent_name));
+
+            if (check_state (redux_state, "ReduxContinentSelectedState"))
+                redux_state = ANASTASIS_backup_start (cfg);
+            ANASTASIS_backup_action (redux_state,
+                                     "selection_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;
+            json_t *arguments = json_object ();
+
+            if (NULL == arguments)
+            {
+                GNUNET_break (0);
+            }
+            gtk_tree_model_get (model, &iter, 
+                                0, &country_name, 
+                                1, &country_code, 
+                                -1);
+            json_object_set (arguments, "country", json_string (country_name));
+            json_object_set (arguments, "country_code", json_string 
(country_code));
+
+            if (check_state (redux_state, "ReduxCountrySelectedState"))
+            {
+                /** FIXME: Do something (modify json state) */
+            }
+            ANASTASIS_backup_action (redux_state,
+                                     "selection_country",
+                                     arguments,
+                                     &action_cb,
+                                     NULL);
+            g_free(country_name);
+            g_free(country_code);
+        }
+}
+
+
+/**
+ * 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)
+{
+    char *state = json_string_value (json_object_get (redux_state, 
"backup-state"));
+    if (!state)
+        state = json_string_value (json_object_get (redux_state, 
"recovery-state"));
+    GNUNET_assert (state);
+
+    if (gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
+                                        "anastasis_gtk_continent_frame"))))
+    {
+        /** FIXME: Show warning in this case, because state is lost afterwards 
*/
+        gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+                                        "anastasis_gtk_start_frame")));
+        gtk_widget_hide (GTK_WIDGET (GCG_get_main_window_object (
+                                        "anastasis_gtk_main_control_vbox")));
+        gtk_widget_hide (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);
+    }
+    if (gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
+                                        "anastasis_gtk_identity_frame"))))
+    {
+        gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+                                        "anastasis_gtk_continent_frame")));
+        gtk_widget_hide (GTK_WIDGET (GCG_get_main_window_object (
+                                        "anastasis_gtk_identity_frame")));
+    }
+}
+
+
+/**
+ * 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)
+{
+    if (check_state (redux_state, "ReduxCountrySelectedState"))
+    {
+        gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+                                        "anastasis_gtk_identity_frame")));
+        gtk_widget_hide (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);
+    }
+}
\ No newline at end of file
diff --git a/src/include/anastasis-gtk_helper.h 
b/src/include/anastasis-gtk_helper.h
index 1363a4c..d2e1aab 100644
--- a/src/include/anastasis-gtk_helper.h
+++ b/src/include/anastasis-gtk_helper.h
@@ -26,6 +26,7 @@
  */
 
 #include <gnunet-gtk/gnunet_gtk.h>
+#include <anastasis/anastasis_redux.h>
 
 /**
  * Handle to our main loop.
@@ -37,6 +38,34 @@ extern struct GNUNET_GTK_MainLoop *ml;
  */
 extern struct GNUNET_CONFIGURATION_Handle *cfg;
 
+/**
+ * Actual state.
+ */
+extern json_t *redux_state;
+
+
+/**
+ * Function called with the results of #ANASTASIS_backup_action
+ * or #ANASTASIS_recovery_action.
+ *
+ * @param cls closure
+ * @param error_code Error code
+ * @param new_state new state as result
+ */
+static void
+action_cb (void *cls,
+           enum ANASTASIS_ErrorCode error,
+           json_t *new_state);
+
+
+/**
+ * Function to persist a state.
+ * 
+ * @param state state to persist
+ */
+int
+persist_state (json_t *state);
+
 
 /**
  * Get an object from the main window.
@@ -47,3 +76,66 @@ extern struct GNUNET_CONFIGURATION_Handle *cfg;
 GObject *
 GCG_get_main_window_object (const char *name);
 
+
+/**
+ * Checks the actual state. True, if state is correct, else false.
+ * 
+ * @param state the state to check
+ * @param state_name the expected state
+ * @return bool
+ */
+bool
+check_state (json_t *state, 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);
+
+
+/**
+ * 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);
+
+
+/**
+ * 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);
\ 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]