[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis-gtk] branch master updated (c215876 -> 2527cca)
From: |
gnunet |
Subject: |
[taler-anastasis-gtk] branch master updated (c215876 -> 2527cca) |
Date: |
Fri, 09 Oct 2020 12:03:36 +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 c215876 fix
new 6d2b804 fix
new b4601ac fix
new 606f7c5 fix
new f5a4ed7 fix change continent
new 949d414 fix
new ff16378 fix country/continent unselect
new 2527cca rework add_authentication
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 | 11 +-
src/anastasis/anastasis-gtk.c | 226 ++++++++++++++++----------------
src/anastasis/anastasis-gtk_backup.c | 216 +++++++++++++++---------------
src/anastasis/anastasis-gtk_helper.c | 86 +++++++++---
src/include/anastasis-gtk_helper.h | 13 +-
5 files changed, 305 insertions(+), 247 deletions(-)
diff --git a/contrib/anastasis_gtk_main_window.glade
b/contrib/anastasis_gtk_main_window.glade
index 7c8cab4..c968a06 100644
--- a/contrib/anastasis_gtk_main_window.glade
+++ b/contrib/anastasis_gtk_main_window.glade
@@ -1010,11 +1010,14 @@
<column type="gchararray"/>
<!-- column-name country_code -->
<column type="gchararray"/>
+ <!-- column-name country_currency -->
+ <column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Germany</col>
<col id="1" translatable="yes">de</col>
+ <col id="2" translatable="yes">EUR</col>
</row>
</data>
</object>
@@ -1293,7 +1296,9 @@
<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"/>
+ <object class="GtkTreeSelection">
+ <signal name="changed"
handler="anastasis_gtk_continent_unselected" swapped="no"/>
+ </object>
</child>
<child>
<object
class="GtkTreeViewColumn" id="continent_column">
@@ -1322,7 +1327,9 @@
<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"/>
+ <object class="GtkTreeSelection">
+ <signal name="changed"
handler="anastasis_gtk_country_unselected" swapped="no"/>
+ </object>
</child>
<child>
<object
class="GtkTreeViewColumn" id="country_column">
diff --git a/src/anastasis/anastasis-gtk.c b/src/anastasis/anastasis-gtk.c
index c8a713b..8acb749 100644
--- a/src/anastasis/anastasis-gtk.c
+++ b/src/anastasis/anastasis-gtk.c
@@ -26,9 +26,7 @@
*/
#include <gnunet/platform.h>
#include <gnunet/gnunet_util_lib.h>
-#include <gnunet-gtk/gnunet_gtk.h>
-#include <gtk/gtk.h>
-#include <anastasis-gtk/anastasis-gtk_helper.h>
+#include "anastasis-gtk_helper.h"
#include <jansson.h>
/**
@@ -225,30 +223,29 @@ anastasis_gtk_continent_activated (GtkTreeView *tree_view,
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 ();
+ GtkTreeIter iter;
+ GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
+ GtkListStore *country_liststore = GTK_LIST_STORE
(GCG_get_main_window_object ("country_liststore"));
- 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));
+ 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 (check_state (redux_state, "ReduxContinentSelectedState"))
- redux_state = ANASTASIS_backup_start (cfg);
- ANASTASIS_redux_action (redux_state,
- "selection_continent",
- arguments,
- &action_cb,
- NULL);
- g_free(continent_name);
- }
+ 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);
+ json_object_set (arguments, "continent", json_string (continent_name));
+
+ ANASTASIS_redux_action (redux_state,
+ "select_continent",
+ arguments,
+ &action_cb,
+ NULL);
+ g_free(continent_name);
+ }
}
@@ -273,6 +270,7 @@ anastasis_gtk_country_activated (GtkTreeView *tree_view,
{
gchar *country_name;
gchar *country_code;
+ gchar *country_currency;
json_t *arguments = json_object ();
if (NULL == arguments)
@@ -281,28 +279,26 @@ anastasis_gtk_country_activated (GtkTreeView *tree_view,
}
gtk_tree_model_get (model, &iter,
0, &country_name,
- 1, &country_code,
+ 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));
- if (check_state (redux_state, "ReduxContinentSelectedState"))
+ if (check_state (redux_state, CountrySelectionState))
ANASTASIS_redux_action (redux_state,
- "selection_country",
+ "select_country",
arguments,
&action_cb,
NULL);
- else
- if (! (0 == strcmp (country_name, json_string_value (
- json_object_get (redux_state, "selected_country")))))
- {
- ANASTASIS_redux_action (redux_state,
- "changing_country",
- arguments,
- &action_cb,
- NULL);
- }
+ if (check_state (redux_state, UserAttributesCollectionState))
+ ANASTASIS_redux_action (redux_state,
+ "select_country",
+ arguments,
+ &action_cb,
+ NULL);
g_free(country_name);
g_free(country_code);
@@ -310,6 +306,49 @@ anastasis_gtk_country_activated (GtkTreeView *tree_view,
}
+/**
+ * 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)
+ && ! check_state (redux_state, ContinentSelectionState))
+ 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)
+ && check_state (redux_state, UserAttributesCollectionState))
+ ANASTASIS_redux_action (redux_state,
+ "unselect_country",
+ NULL,
+ &action_cb,
+ NULL);
+}
+
+
/**
* Callback invoked if the the "back"-button is clicked.
*
@@ -320,42 +359,21 @@ void
anastasis_gtk_main_window_back_clicked (GObject *object,
gpointer user_data)
{
- const 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")));
- }
- if (gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
+ ANASTASIS_redux_action (redux_state,
+ "back",
+ NULL,
+ &action_cb,
+ NULL);
+ //show identity frame, hide authentication frame
+ if (check_state (redux_state, UserAttributesCollectionState) &&
+ 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_hide (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_b_authentication_frame")));
- if (check_attributes_fullfilled ())
- gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_main_window_forward_button")), true);
+ gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+
"anastasis_gtk_user_attributes_image")));
}
}
@@ -371,20 +389,15 @@ anastasis_gtk_main_window_forward_clicked (GObject
*object,
gpointer user_data)
{
//show identity frame, hide continent frame
- if (check_state (redux_state, "ReduxCountrySelectedState") &&
+ if (check_state (redux_state, UserAttributesCollectionState) &&
gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
"anastasis_gtk_continent_frame"))))
{
- gtk_widget_hide (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_hide (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_continent_selection_image")));
- gtk_widget_hide (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_country_selection_image")));
gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
"anastasis_gtk_user_attributes_image")));
}
@@ -396,17 +409,15 @@ anastasis_gtk_main_window_forward_clicked (GObject
*object,
{
GList *children, *iter;
json_t *arguments = json_object ();
- json_t *attributes = json_array ();
+ 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))
{
- bool isset = false;
char *entry_widget;
char *cal_widget;
const char *widget = gtk_buildable_get_name (iter->data);
- json_t *id_attr = json_object ();
GNUNET_asprintf (&entry_widget,
"%s_entry",
@@ -418,17 +429,14 @@ anastasis_gtk_main_window_forward_clicked (GObject
*object,
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 (strlen (value) > 0)
- isset = true;
- json_object_set_new (id_attr, "type", json_string ("string"));
+ if (0 == strlen (value))
+ break;
if (strstr (widget, "ia_ahv"))
- json_object_set_new (id_attr, "name", json_string
("ahv_number"));
+ json_object_set_new (id_attr, "ahv_number", json_string
(value));
if (strstr (widget, "ia_ssn"))
- json_object_set_new (id_attr, "name", json_string
("social_security_number"));
+ json_object_set_new (id_attr, "social_security_number",
json_string (value));
if (strstr (widget, "ia_full_name"))
- json_object_set_new (id_attr, "name", json_string
("full_name"));
- json_object_set_new (id_attr, "value", json_string (value));
- json_object_set_new (id_attr, "widget", json_string
(entry_widget));
+ json_object_set_new (id_attr, "full_name", json_string
(value));
}
if (GCG_get_main_window_object (cal_widget))
{
@@ -436,57 +444,45 @@ anastasis_gtk_main_window_forward_clicked (GObject
*object,
guint month;
guint year;
- json_object_set_new (id_attr, "type", json_string ("date"));
gtk_calendar_get_date (GTK_CALENDAR
(GCG_get_main_window_object (cal_widget)),
&year,
&month,
&day);
- json_object_set_new (id_attr, "year", json_integer (year));
- json_object_set_new (id_attr, "month", json_integer (month));
- json_object_set_new (id_attr, "day", json_integer (day));
- json_object_set_new (id_attr, "widget", json_string
(cal_widget));
+ 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));
}
- if (isset)
- json_array_append_new (attributes, id_attr);
GNUNET_free (entry_widget);
GNUNET_free (cal_widget);
}
- json_object_set_new (arguments, "identity", attributes);
+ json_object_set_new (arguments, "identity_attributes", id_attr);
- if (check_state (redux_state, "ReduxCountrySelectedState"))
+ if (check_state (redux_state, UserAttributesCollectionState))
ANASTASIS_redux_action (redux_state,
- "entering_user_attributes",
- arguments,
- &action_cb,
- NULL);
- else
- ANASTASIS_redux_action (redux_state,
- "editing_user_attributes",
+ "enter_user_attributes",
arguments,
&action_cb,
NULL);
- gtk_widget_hide (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_hide (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_user_attributes_image")));
+ 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, "ReduxUserAttributesAddedState"))
+ if (check_state (redux_state, AuthenticationsEditingState))
{
- GList *children;
+ json_t *auth_methods = json_object_get (redux_state,
"authentication_methods");
- children = gtk_container_get_children (GTK_CONTAINER
(GCG_get_main_window_object (
-
"anastasis_gtk_b_authentication_vbox")));
- if (g_list_length (children) > 0)
- init_b_policy (redux_state);
- g_list_free (children);
+ if (json_array_size (auth_methods) > 0)
+ ANASTASIS_redux_action (redux_state,
+ "next",
+ NULL,
+ &action_cb,
+ NULL);
}
}
}
diff --git a/src/anastasis/anastasis-gtk_backup.c
b/src/anastasis/anastasis-gtk_backup.c
index de9e71b..aebdfd4 100644
--- a/src/anastasis/anastasis-gtk_backup.c
+++ b/src/anastasis/anastasis-gtk_backup.c
@@ -26,10 +26,8 @@
*/
#include <gnunet/platform.h>
#include <gnunet/gnunet_util_lib.h>
-#include <gnunet-gtk/gnunet_gtk.h>
#include <taler/taler_json_lib.h>
-#include <gtk/gtk.h>
-#include <anastasis-gtk/anastasis-gtk_helper.h>
+#include "anastasis-gtk_helper.h"
#include <jansson.h>
@@ -141,7 +139,7 @@ anastasis_gtk_backup_button_clicked (GObject *object,
redux_state = ANASTASIS_backup_start (cfg);
GNUNET_assert (0 == persist_state (redux_state));
- if (check_state (redux_state, "ReduxInitialBackupState"))
+ if (check_state (redux_state, ContinentSelectionState))
{
init_continent_list (redux_state);
@@ -163,7 +161,7 @@ anastasis_gtk_backup_button_clicked (GObject *object,
* @param user_data unused
*/
void
-anastasis_gtk_btn_add_auth_edit_provider_clicked_cb
+anastasis_gtk_btn_add_auth_edit_provider_clicked_cb ()
{
gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
"anastasis_gtk_b_edit_provider_dialog")));
@@ -202,10 +200,11 @@ void
anastasis_gtk_b_question_dialog_btn_ok_clicked_cb (GObject *object,
gpointer user_data)
{
- GtkBox *vbox = GTK_BOX (GCG_get_main_window_object
("anastasis_gtk_b_authentication_vbox"));
GtkHBox *hbox;
-
+ GtkBox *vbox = GTK_BOX (GCG_get_main_window_object
("anastasis_gtk_b_authentication_vbox"));
+
bool is_box = GTK_IS_BOX (user_data);
+
if (is_box)
{
hbox = (GtkHBox *) user_data;
@@ -216,6 +215,7 @@ anastasis_gtk_b_question_dialog_btn_ok_clicked_cb (GObject
*object,
}
else
hbox = (GtkHBox *) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
// set labels
GtkLabel *label_prefix = (GtkLabel *) gtk_label_new ("Q: ");
const gchar *question = gtk_entry_get_text (
@@ -224,15 +224,33 @@ anastasis_gtk_b_question_dialog_btn_ok_clicked_cb
(GObject *object,
const gchar *answer = gtk_entry_get_text (
GTK_ENTRY (GCG_get_main_window_object
("anastasis_gtk_b_question_dialog_answer_entry")));
GtkLabel *label_answer = (GtkLabel *) gtk_label_new (answer);
+ {
+ //build json arguments for reducer
+ json_t *arguments = json_object ();
+ json_t *auth_method = json_object ();
+ json_t *method_data = json_object ();
+
+ json_object_set_new (auth_method, "method", json_string
("question"));
+ json_object_set_new (method_data, "question", json_string
(question));
+ json_object_set_new (method_data, "answer", json_string (answer));
+ json_object_set_new (auth_method, "data", method_data);
+ json_object_set_new (arguments, "authentication_method",
method_data);
+
+ ANASTASIS_redux_action (redux_state,
+ "add_authentication",
+ arguments,
+ &action_cb,
+ NULL);
+ }
// set buttons
GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_box_new(1, 0);
- GtkButton *edit_btn = (GtkButton *) gtk_button_new_with_label ("edit");
+ GtkButton *edit_btn = (GtkButton *) gtk_button_new_from_icon_name
("gtk-edit", GTK_ICON_SIZE_BUTTON);
g_signal_connect (edit_btn,
"clicked",
G_CALLBACK
(anastasis_gtk_b_auth_method_btn_edit_clicked_cb),
hbox);
- GtkButton *delete_btn = (GtkButton *) gtk_button_new_with_label
("delete");
+ GtkButton *delete_btn = (GtkButton *) gtk_button_new_from_icon_name
("gtk-delete", GTK_ICON_SIZE_BUTTON);
g_signal_connect (delete_btn,
"clicked",
G_CALLBACK
(anastasis_gtk_b_auth_method_btn_delete_clicked_cb),
@@ -352,15 +370,36 @@ anastasis_gtk_b_post_dialog_btn_ok_clicked_cb (GObject
*object,
const gchar *country = gtk_entry_get_text (
GTK_ENTRY (GCG_get_main_window_object
("anastasis_gtk_b_post_dialog_country_entry")));
GtkLabel *label_country = (GtkLabel *) gtk_label_new (country);
+ {
+ //build json arguments for reducer
+ json_t *arguments = json_object ();
+ json_t *auth_method = json_object ();
+ json_t *method_data = json_object ();
+
+ json_object_set_new (auth_method, "method", json_string ("post"));
+ json_object_set_new (method_data, "full_name", json_string
(full_name));
+ json_object_set_new (method_data, "street", json_string (street));
+ json_object_set_new (method_data, "city", json_string (city));
+ json_object_set_new (method_data, "postcode", json_string
(postcode));
+ json_object_set_new (method_data, "country", json_string (country));
+ json_object_set_new (auth_method, "data", method_data);
+ json_object_set_new (arguments, "authentication_method",
method_data);
+
+ ANASTASIS_redux_action (redux_state,
+ "add_authentication",
+ arguments,
+ &action_cb,
+ NULL);
+ }
// set buttons
GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_box_new(1, 0);
- GtkButton *edit_btn = (GtkButton *) gtk_button_new_with_label ("edit");
+ GtkButton *edit_btn = (GtkButton *) gtk_button_new_from_icon_name
("gtk-edit", GTK_ICON_SIZE_BUTTON);
g_signal_connect (edit_btn,
"clicked",
G_CALLBACK
(anastasis_gtk_b_auth_method_btn_edit_clicked_cb),
hbox);
- GtkButton *delete_btn = (GtkButton *) gtk_button_new_with_label
("delete");
+ GtkButton *delete_btn = (GtkButton *) gtk_button_new_from_icon_name
("gtk-delete", GTK_ICON_SIZE_BUTTON);
g_signal_connect (delete_btn,
"clicked",
G_CALLBACK
(anastasis_gtk_b_auth_method_btn_delete_clicked_cb),
@@ -486,15 +525,32 @@ anastasis_gtk_b_video_dialog_btn_ok_clicked_cb (GObject
*object,
const gchar *photo_path = gtk_entry_get_text (
GTK_ENTRY (GCG_get_main_window_object
("anastasis_gtk_b_video_dialog_photo_path_entry")));
GtkLabel *label_photo_path = (GtkLabel *) gtk_label_new (photo_path);
+ {
+ //build json arguments for reducer
+ json_t *arguments = json_object ();
+ json_t *auth_method = json_object ();
+ json_t *method_data = json_object ();
+
+ json_object_set_new (auth_method, "method", json_string ("video"));
+ json_object_set_new (method_data, "picture", json_string
(photo_path)); // FIXME: load photo, not only path
+ json_object_set_new (auth_method, "data", method_data);
+ json_object_set_new (arguments, "authentication_method",
method_data);
+
+ ANASTASIS_redux_action (redux_state,
+ "add_authentication",
+ arguments,
+ &action_cb,
+ NULL);
+ }
// set buttons
GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_box_new(1, 0);
- GtkButton *edit_btn = (GtkButton *) gtk_button_new_with_label ("edit");
+ GtkButton *edit_btn = (GtkButton *) gtk_button_new_from_icon_name
("gtk-edit", GTK_ICON_SIZE_BUTTON);
g_signal_connect (edit_btn,
"clicked",
G_CALLBACK
(anastasis_gtk_b_auth_method_btn_edit_clicked_cb),
hbox);
- GtkButton *delete_btn = (GtkButton *) gtk_button_new_with_label
("delete");
+ GtkButton *delete_btn = (GtkButton *) gtk_button_new_from_icon_name
("gtk-delete", GTK_ICON_SIZE_BUTTON);
g_signal_connect (delete_btn,
"clicked",
G_CALLBACK
(anastasis_gtk_b_auth_method_btn_delete_clicked_cb),
@@ -596,15 +652,32 @@ anastasis_gtk_b_sms_dialog_btn_ok_clicked_cb (GObject
*object,
const gchar *phonenumber = gtk_entry_get_text (
GTK_ENTRY (GCG_get_main_window_object
("anastasis_gtk_b_sms_dialog_phonenumber_entry")));
GtkLabel *label_phonenumber = (GtkLabel *) gtk_label_new (phonenumber);
+ {
+ //build json arguments for reducer
+ json_t *arguments = json_object ();
+ json_t *auth_method = json_object ();
+ json_t *method_data = json_object ();
+
+ json_object_set_new (auth_method, "method", json_string ("sms"));
+ json_object_set_new (method_data, "phonenumber", json_string
(phonenumber));
+ json_object_set_new (auth_method, "data", method_data);
+ json_object_set_new (arguments, "authentication_method",
method_data);
+
+ ANASTASIS_redux_action (redux_state,
+ "add_authentication",
+ arguments,
+ &action_cb,
+ NULL);
+ }
// set buttons
GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_box_new(1, 0);
- GtkButton *edit_btn = (GtkButton *) gtk_button_new_with_label ("edit");
+ GtkButton *edit_btn = (GtkButton *) gtk_button_new_from_icon_name
("gtk-edit", GTK_ICON_SIZE_BUTTON);
g_signal_connect (edit_btn,
"clicked",
G_CALLBACK
(anastasis_gtk_b_auth_method_btn_edit_clicked_cb),
hbox);
- GtkButton *delete_btn = (GtkButton *) gtk_button_new_with_label
("delete");
+ GtkButton *delete_btn = (GtkButton *) gtk_button_new_from_icon_name
("gtk-delete", GTK_ICON_SIZE_BUTTON);
g_signal_connect (delete_btn,
"clicked",
G_CALLBACK
(anastasis_gtk_b_auth_method_btn_delete_clicked_cb),
@@ -706,15 +779,32 @@ anastasis_gtk_b_email_dialog_btn_ok_clicked_cb (GObject
*object,
const gchar *mailaddress = gtk_entry_get_text (
GTK_ENTRY (GCG_get_main_window_object
("anastasis_gtk_b_email_dialog_mailaddress_entry")));
GtkLabel *label_mailaddress = (GtkLabel *) gtk_label_new (mailaddress);
+ {
+ //build json arguments for reducer
+ json_t *arguments = json_object ();
+ json_t *auth_method = json_object ();
+ json_t *method_data = json_object ();
+
+ json_object_set_new (auth_method, "method", json_string ("email"));
+ json_object_set_new (method_data, "mailaddress", json_string
(mailaddress));
+ json_object_set_new (auth_method, "data", method_data);
+ json_object_set_new (arguments, "authentication_method",
method_data);
+
+ ANASTASIS_redux_action (redux_state,
+ "add_authentication",
+ arguments,
+ &action_cb,
+ NULL);
+ }
// set buttons
GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_box_new(1, 0);
- GtkButton *edit_btn = (GtkButton *) gtk_button_new_with_label ("edit");
+ GtkButton *edit_btn = (GtkButton *) gtk_button_new_from_icon_name
("gtk-edit", GTK_ICON_SIZE_BUTTON);
g_signal_connect (edit_btn,
"clicked",
G_CALLBACK
(anastasis_gtk_b_auth_method_btn_edit_clicked_cb),
hbox);
- GtkButton *delete_btn = (GtkButton *) gtk_button_new_with_label
("delete");
+ GtkButton *delete_btn = (GtkButton *) gtk_button_new_from_icon_name
("gtk-delete", GTK_ICON_SIZE_BUTTON);
g_signal_connect (delete_btn,
"clicked",
G_CALLBACK
(anastasis_gtk_b_auth_method_btn_delete_clicked_cb),
@@ -1115,8 +1205,6 @@ void
init_b_policy (json_t *state)
{
GList *children, *iter;
- json_t *arguments = json_object ();
- json_t *argument_arr = json_array ();
unsigned int row = 0;
GtkGrid *grid = GTK_GRID (GCG_get_main_window_object
("anastasis_gtk_b_policy_grid"));
@@ -1157,9 +1245,8 @@ init_b_policy (json_t *state)
grandchildren = gtk_container_get_children (GTK_CONTAINER
(iter->data));
GtkFrame *method_frame = (GtkFrame *) gtk_frame_new (NULL);
GtkHBox *method_hbox = (GtkHBox *) gtk_box_new
(GTK_ORIENTATION_HORIZONTAL, 2);
- json_t *argument = json_object ();
- json_t *provider_arr = json_array ();
unsigned int index = 0;
+
if (GTK_IS_BOX (iter->data))
for (inner_iter = grandchildren; inner_iter != NULL; inner_iter
= g_list_next (inner_iter))
{
@@ -1171,17 +1258,6 @@ init_b_policy (json_t *state)
// check method type
if (index == 0)
{
- if (0 == strcmp (text, "Q: "))
- json_object_set_new (argument, "method",
json_string ("question"));
- else if (0 == strcmp (text, "EMAIL: "))
- json_object_set_new (argument, "method",
json_string ("email"));
- else if (0 == strcmp (text, "SMS: "))
- json_object_set_new (argument, "method",
json_string ("sms"));
- else if (0 == strcmp (text, "POST: "))
- json_object_set_new (argument, "method",
json_string ("post"));
- else if (0 == strcmp (text, "VIDEO: "))
- json_object_set_new (argument, "method",
json_string ("video"));
-
row++;
gtk_grid_insert_row (grid, row);
GtkLabel *lbl_method_type = (GtkLabel *)
gtk_label_new (text);
@@ -1192,18 +1268,6 @@ init_b_policy (json_t *state)
// check method attributes
if (index == 1)
{
- const char *method_type = json_string_value
(json_object_get (argument, "method"));
- if (0 == strcmp (method_type, "question"))
- json_object_set_new (argument, "question",
json_string (text));
- else if (0 == strcmp (method_type, "email"))
- json_object_set_new (argument,
"email_address", json_string (text));
- else if (0 == strcmp (method_type, "sms"))
- json_object_set_new (argument,
"phone_number", json_string (text));
- else if (0 == strcmp (method_type, "post"))
- json_object_set_new (argument, "full_name",
json_string (text));
- else if (0 == strcmp (method_type, "video"))
- json_object_set_new (argument,
"path_picture", json_string (text));
-
GtkLabel *lbl_method_info = (GtkLabel *)
gtk_label_new (text);
gtk_box_pack_start (GTK_BOX (method_hbox),
GTK_WIDGET (lbl_method_info), 0, 0, 0);
GtkButton *btn_edit_method = (GtkButton *)
gtk_button_new_from_icon_name ("gtk-edit", GTK_ICON_SIZE_BUTTON);
@@ -1215,64 +1279,10 @@ init_b_policy (json_t *state)
gtk_widget_show (GTK_WIDGET (lbl_method_info));
gtk_widget_show (GTK_WIDGET (btn_edit_method));
}
-
- if (index == 2)
- {
- const char *method_type = json_string_value
(json_object_get (argument, "method"));
- if (0 == strcmp (method_type, "question"))
- json_object_set_new (argument, "answer",
json_string (text));
- else if (0 == strcmp (method_type, "post"))
- json_object_set_new (argument, "street",
json_string (text));
- }
-
- if (index == 3)
- {
- const char *method_type = json_string_value
(json_object_get (argument, "method"));
- if (0 == strcmp (method_type, "post"))
- json_object_set_new (argument, "city",
json_string (text));
- }
-
- if (index == 4)
- {
- const char *method_type = json_string_value
(json_object_get (argument, "method"));
- if (0 == strcmp (method_type, "post"))
- json_object_set_new (argument, "postcode",
json_string (text));
- }
-
- if (index == 5)
- {
- const char *method_type = json_string_value
(json_object_get (argument, "method"));
- if (0 == strcmp (method_type, "post"))
- json_object_set_new (argument, "country",
json_string (text));
- }
}
index++;
}
- const char *method_type = json_string_value (json_object_get
(argument, "method"));
- for (unsigned int i = 0; i < servers_length; i++)
- {
- size_t index2;
- json_t *method;
- json_t *method_arr = json_object_get
(servers[i].backend_methods, "methods");
- json_array_foreach (method_arr, index2, method)
- {
- if (0 == strcmp (method_type,
- json_string_value (json_object_get
(method, "method"))))
- {
- const char *method_cost = json_string_value
(json_object_get (method, "cost"));
- json_t *provider = json_pack ("{s:s, s:s, s:s, s:s,
s:s, s:o}",
- "provider-id",
servers[i].backend_id,
- "provider-url",
servers[i].backend_url,
- "provider-name",
servers[i].backend_name,
- "currency",
servers[i].backend_currency,
- "method_cost",
method_cost,
- "annual_cost",
- TALER_JSON_from_amount
(&servers[i].backend_cost));
- json_array_append_new (provider_arr, provider);
- break;
- }
- }
- }
+
gtk_frame_set_shadow_type (GTK_FRAME (method_frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (method_frame),
GTK_WIDGET (method_hbox));
@@ -1297,17 +1307,9 @@ init_b_policy (json_t *state)
gtk_widget_show (GTK_WIDGET (chk_btn));
gtk_widget_show (GTK_WIDGET (frame));
}
- json_object_set_new (argument, "providers", provider_arr);
- json_array_append_new (argument_arr, argument);
g_list_free (grandchildren);
}
g_list_free (children);
- json_object_set_new (arguments, "authentication_methods", argument_arr);
- ANASTASIS_redux_action (state,
- "adding_authentication",
- arguments,
- &action_cb,
- NULL);
}
diff --git a/src/anastasis/anastasis-gtk_helper.c
b/src/anastasis/anastasis-gtk_helper.c
index 65610d5..7621f51 100644
--- a/src/anastasis/anastasis-gtk_helper.c
+++ b/src/anastasis/anastasis-gtk_helper.c
@@ -26,9 +26,7 @@
*/
#include <gnunet/platform.h>
#include <gnunet/gnunet_util_lib.h>
-#include <gnunet-gtk/gnunet_gtk.h>
-#include <gtk/gtk.h>
-#include <anastasis-gtk/anastasis-gtk_helper.h>
+#include "anastasis-gtk_helper.h"
#include <jansson.h>
@@ -170,9 +168,9 @@ persist_state (json_t *state)
char *path;
char *mode;
- if (NULL != json_object_get (state, "backup-state"))
+ if (NULL != json_object_get (state, "backup_state"))
mode = "backup";
- else if (NULL != json_object_get (state, "recovery-state"))
+ else if (NULL != json_object_get (state, "recovery_state"))
mode = "recovery";
else
{
@@ -196,6 +194,34 @@ persist_state (json_t *state)
}
+/**
+ * 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
* or #ANASTASIS_recovery_action.
@@ -212,24 +238,43 @@ action_cb (void *cls,
if (NULL != result_state)
{
redux_state = json_deep_copy (result_state);
- if (check_state (redux_state, "ReduxContinentSelectedState"))
+ if (check_state (redux_state, ContinentSelectionState))
{
+ 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, CountrySelectionState))
+ {
+ anastasis_gtk_hide_all_frames ();
init_country_list (redux_state, json_string_value (json_object_get
(redux_state, "selected_continent")));
- gtk_widget_hide (GTK_WIDGET (GCG_get_main_window_object (
+ 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, "ReduxCountrySelectedState"))
+ if (check_state (redux_state, UserAttributesCollectionState))
{
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, "ReduxUserAttributesAddedState"))
+ if (check_state (redux_state, AuthenticationsEditingState))
{
- if (json_object_get (redux_state, "backup-state"))
+ 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")));
init_b_auth_methods (redux_state);
@@ -237,16 +282,14 @@ action_cb (void *cls,
"anastasis_gtk_b_authentication_methods_image")));
}
}
- if (check_state (redux_state, "ReduxAuthenticationAddedState")
+ if (check_state (redux_state, PoliciesReviewingState)
&& gtk_widget_is_visible (GTK_WIDGET
(GCG_get_main_window_object (
"anastasis_gtk_b_authentication_frame"))))
{
- if (json_object_get (redux_state, "backup-state"))
+ if (json_object_get (redux_state, "backup_state"))
{
- gtk_widget_hide (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_b_authentication_frame")));
- gtk_widget_hide (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_b_authentication_methods_image")));
+ 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 (
@@ -270,14 +313,16 @@ action_cb (void *cls,
* Checks the actual state. True, if state is correct, else false.
*
* @param state the state to check
- * @param state_name the expected state
+ * @param expected_state the expected state enum
* @return bool
*/
bool
-check_state (json_t *state, char *expected_state)
+check_state (json_t *state, REDUX_STATE expected_state)
{
- const char *state_name = json_string_value (json_object_get (state,
"backup-state"));
- if (0 == strcmp (state_name, 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, STATE_STRING[expected_state]))
return true;
else
return false;
@@ -339,6 +384,7 @@ init_country_list (json_t *state,
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);
}
}
diff --git a/src/include/anastasis-gtk_helper.h
b/src/include/anastasis-gtk_helper.h
index b5694bd..2ff471b 100644
--- a/src/include/anastasis-gtk_helper.h
+++ b/src/include/anastasis-gtk_helper.h
@@ -102,11 +102,11 @@ check_attributes_fullfilled ();
* Checks the actual state. True, if state is correct, else false.
*
* @param state the state to check
- * @param state_name the expected state
+ * @param expected_state the expected state enum
* @return bool
*/
bool
-check_state (json_t *state, char *expected_state);
+check_state (json_t *state, REDUX_STATE expected_state);
/**
@@ -198,4 +198,11 @@ anastasis_gtk_main_window_back_clicked (GObject *object,
*/
void
anastasis_gtk_main_window_forward_clicked (GObject *object,
- gpointer user_data);
\ No newline at end of file
+ gpointer user_data);
+
+
+/**
+ * Hides all frames;
+ */
+void
+anastasis_gtk_hide_all_frames ();
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-anastasis-gtk] branch master updated (c215876 -> 2527cca),
gnunet <=
- [taler-anastasis-gtk] 01/07: fix, gnunet, 2020/10/09
- [taler-anastasis-gtk] 04/07: fix change continent, gnunet, 2020/10/09
- [taler-anastasis-gtk] 03/07: fix, gnunet, 2020/10/09
- [taler-anastasis-gtk] 02/07: fix, gnunet, 2020/10/09
- [taler-anastasis-gtk] 06/07: fix country/continent unselect, gnunet, 2020/10/09
- [taler-anastasis-gtk] 05/07: fix, gnunet, 2020/10/09
- [taler-anastasis-gtk] 07/07: rework add_authentication, gnunet, 2020/10/09