[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis-gtk] 01/03: removed optional attributes logic
From: |
gnunet |
Subject: |
[taler-anastasis-gtk] 01/03: removed optional attributes logic |
Date: |
Fri, 18 Sep 2020 13:38:17 +0200 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis-gtk.
commit 58e8a655544d6c46321217b8e19aa8b32f4f136e
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Fri Sep 18 12:26:01 2020 +0200
removed optional attributes logic
---
src/anastasis/anastasis-gtk_helper.c | 91 +++++++++++++++++++++---------------
1 file changed, 53 insertions(+), 38 deletions(-)
diff --git a/src/anastasis/anastasis-gtk_helper.c
b/src/anastasis/anastasis-gtk_helper.c
index cdae465..6f3ace5 100644
--- a/src/anastasis/anastasis-gtk_helper.c
+++ b/src/anastasis/anastasis-gtk_helper.c
@@ -47,48 +47,51 @@ check_attributes_fullfilled ()
json_array_foreach (id_attributes, index, id_attr)
{
- if (json_is_true (json_object_get (id_attr, "required")))
+ const char *type = json_string_value (json_object_get (id_attr,
"type"));
+ const char *widget_name = json_string_value (json_object_get (id_attr,
"widget"));
+ if (0 == strcmp (type, "string"))
{
- const char *type = json_string_value (json_object_get (id_attr,
"type"));
- const char *widget_name = json_string_value (json_object_get
(id_attr, "widget"));
- if (0 == strcmp (type, "string"))
+ char *entry_widget;
+ if (widget_name)
{
- char *entry_widget;
- if (widget_name)
- {
- GNUNET_asprintf (&entry_widget,
- "%s_entry",
- widget_name);
- }
- else
- {
- /** FIXME: create a new GtkEntry here */
- }
-
- GObject *entry = GCG_get_main_window_object (entry_widget);
- if (0 == gtk_entry_get_text_length (GTK_ENTRY (entry)))
- fullfilled = false;
- GNUNET_free (entry_widget);
+ GNUNET_asprintf (&entry_widget,
+ "%s_entry",
+ widget_name);
}
- if (0 == strcmp (type, "date"))
+ else
{
- guint day;
- char *cal_widget;
- if (widget_name)
- {
- GNUNET_asprintf (&cal_widget,
- "%s_cal",
- widget_name);
- }
- else
- {
- /** FIXME: create a new GtkCalendar here */
- }
- GObject *cal = GCG_get_main_window_object (cal_widget);
- GNUNET_free (cal_widget);
- if (!gtk_calendar_get_day_is_marked (GTK_CALENDAR (cal), day))
- fullfilled = false;
+ /** FIXME: create a new GtkEntry here */
+ }
+
+ GObject *entry = GCG_get_main_window_object (entry_widget);
+ if (0 == gtk_entry_get_text_length (GTK_ENTRY (entry)))
+ fullfilled = false;
+ GNUNET_free (entry_widget);
+ }
+ if (0 == strcmp (type, "date"))
+ {
+ guint day;
+ guint month;
+ guint year;
+ char *cal_widget;
+ if (widget_name)
+ {
+ GNUNET_asprintf (&cal_widget,
+ "%s_cal",
+ widget_name);
}
+ else
+ {
+ /** FIXME: create a new GtkCalendar here */
+ }
+ GObject *cal = GCG_get_main_window_object (cal_widget);
+ gtk_calendar_get_date (GTK_CALENDAR (cal),
+ &year,
+ &month,
+ &day);
+ if (! (day && month && day))
+ fullfilled = false;
+ GNUNET_free (cal_widget);
}
}
return fullfilled;
@@ -559,6 +562,7 @@ void
anastasis_gtk_main_window_forward_clicked (GObject *object,
gpointer user_data)
{
+ //show identity frame, hide continent frame
if (check_state (redux_state, "ReduxCountrySelectedState") &&
gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
"anastasis_gtk_continent_frame"))))
@@ -571,6 +575,7 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
"anastasis_gtk_main_window_forward_button")), false);
}
+ //show provider frame, hide identity frame
if (gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
"anastasis_gtk_identity_frame"))) &&
check_attributes_fullfilled ())
@@ -583,6 +588,7 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
"anastasis_gtk_identity_vbox")));
for (iter = children; iter != NULL; iter = g_list_next (iter))
{
+ bool isset = false;
const char *entry_widget;
const char *cal_widget;
const char *widget = gtk_buildable_get_name (iter->data);
@@ -598,7 +604,15 @@ 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 (strstr (widget, "ia_ahv"))
+ json_object_set_new (id_attr, "name", json_string
("ahv_number"));
+ if (strstr (widget, "ia_ssn"))
+ json_object_set_new (id_attr, "name", json_string
("social_security_number"));
+ 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));
}
@@ -618,7 +632,8 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
json_object_set_new (id_attr, "day", json_integer (day));
json_object_set_new (id_attr, "widget", json_string
(cal_widget));
}
- json_array_append_new (attributes, id_attr);
+ if (isset)
+ json_array_append_new (attributes, id_attr);
GNUNET_free (entry_widget);
GNUNET_free (cal_widget);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.