gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] branch master updated (284dee9 -> b289c6b)


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated (284dee9 -> b289c6b)
Date: Thu, 17 Sep 2020 15:29:43 +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 284dee9  fix loop
     new 0b28867  worked on identity attributes
     new 46077b8  fix loop - show forward button in identity frame
     new 467377d  worked on identity attributes
     new 1b1e36f  worked on identity attributes
     new b289c6b  worked on back-/forward-buttons

The 5 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 |  63 +++++++-
 src/anastasis/anastasis-gtk_helper.c    | 268 ++++++++++++++++++++++++++++++--
 2 files changed, 313 insertions(+), 18 deletions(-)

diff --git a/contrib/anastasis_gtk_main_window.glade 
b/contrib/anastasis_gtk_main_window.glade
index 045c017..1106192 100644
--- a/contrib/anastasis_gtk_main_window.glade
+++ b/contrib/anastasis_gtk_main_window.glade
@@ -293,7 +293,6 @@
                                     <property 
name="orientation">vertical</property>
                                     <child>
                                       <object class="GtkBox" 
id="anastasis_gtk_ia_full_name">
-                                        <property 
name="name">anastasis_gtk_id_attr_full_name</property>
                                         <property 
name="can_focus">False</property>
                                         <child>
                                           <object class="GtkLabel" 
id="anastasis_gtk_ia_full_name_label">
@@ -317,6 +316,7 @@
                                             <property 
name="can_focus">True</property>
                                             <property 
name="hexpand">True</property>
                                             <property name="placeholder_text" 
translatable="yes">Max Mustermann</property>
+                                            <signal name="changed" 
handler="anastasis_gtk_ia_full_name_entry_changed_cb" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property 
name="expand">False</property>
@@ -356,6 +356,7 @@
                                             <property 
name="can_focus">True</property>
                                             <property 
name="hexpand">True</property>
                                             <property name="placeholder_text" 
translatable="yes">123456789</property>
+                                            <signal name="changed" 
handler="anastasis_gtk_ia_ahv_entry_changed_cb" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property 
name="expand">False</property>
@@ -395,6 +396,7 @@
                                             <property 
name="can_focus">True</property>
                                             <property 
name="hexpand">True</property>
                                             <property name="placeholder_text" 
translatable="yes">123456789</property>
+                                            <signal name="changed" 
handler="anastasis_gtk_ia_ssn_entry_changed_cb" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property 
name="expand">False</property>
@@ -432,7 +434,8 @@
                                             <property 
name="hexpand">True</property>
                                             <property 
name="year">2020</property>
                                             <property name="month">8</property>
-                                            <property name="day">16</property>
+                                            <property 
name="show_day_names">False</property>
+                                            <signal name="day-selected" 
handler="anastasis_gtk_ia_birthdate_cal_day_selected_cb" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property 
name="expand">False</property>
@@ -466,7 +469,61 @@
                           </packing>
                         </child>
                         <child>
-                          <placeholder/>
+                          <object class="GtkFrame" 
id="anastasis_gtk_provider_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>
+                                <property name="left_padding">12</property>
+                                <child>
+                                  <object class="GtkBox" 
id="anastasis_gtk_provider_vbox">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property 
name="orientation">vertical</property>
+                                    <child>
+                                      <object class="GtkComboBoxText" 
id="anastasis_gtk_provider_combo">
+                                        <property 
name="visible">True</property>
+                                        <property 
name="can_focus">False</property>
+                                        <property 
name="hexpand">True</property>
+                                        <property name="active">0</property>
+                                        <items>
+                                          <item translatable="yes">a</item>
+                                          <item translatable="yes">b</item>
+                                          <item translatable="yes">c</item>
+                                        </items>
+                                      </object>
+                                      <packing>
+                                        <property 
name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
+                                    <child>
+                                      <placeholder/>
+                                    </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">Please select Anastasis provider:</property>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">3</property>
+                          </packing>
                         </child>
                         <child>
                           <placeholder/>
diff --git a/src/anastasis/anastasis-gtk_helper.c 
b/src/anastasis/anastasis-gtk_helper.c
index 942f4b9..cdae465 100644
--- a/src/anastasis/anastasis-gtk_helper.c
+++ b/src/anastasis/anastasis-gtk_helper.c
@@ -32,6 +32,68 @@
 #include <jansson.h>
 
 
+/**
+ * Function to ckeck if minimal required attributes are set.
+ * 
+ * @return bool
+ */
+static bool
+check_attributes_fullfilled ()
+{
+    size_t index;
+    json_t *id_attr;
+    json_t *id_attributes = json_object_get (redux_state, 
"required_attributes");
+    bool fullfilled = true;
+
+    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"))
+            {
+                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);
+            }
+            if (0 == strcmp (type, "date"))
+            {
+                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;
+            }
+        }
+    }
+    return fullfilled;
+}
+
 /**
  * Get an object from the main window.
  *
@@ -223,10 +285,10 @@ init_id_attr (json_t *state,
 
     json_array_foreach (id_attributes, index, id_attr)
     {
-        char *widget_name = json_string_value (json_object_get (id_attr, 
"widget"));
-        char *attr_type = json_string_value (json_object_get (id_attr, 
"type"));
-        char *attr_name = json_string_value (json_object_get (id_attr, 
"name"));
-        char *attr_label = json_string_value (json_object_get (id_attr, 
"label"));
+        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)
         {
@@ -258,6 +320,86 @@ init_id_attr (json_t *state,
 }
 
 
+/**
+ * Callback invoked if a text is inserted in "cal" GtkEntry.
+ *
+ * @param cell_editable the object on which the signal was emitted
+ * @param user_data user data set when the signal handler was connected 
(unused)
+ */
+void
+anastasis_gtk_ia_birthdate_cal_day_selected_cb (GtkCellEditable *cell_editable,
+                                       gpointer user_data)
+{
+    gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
+                                        
"anastasis_gtk_main_window_forward_button")), false);
+
+    // check, if required attributes are set to activate forward button
+    if (check_attributes_fullfilled ())
+        gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
+                                        
"anastasis_gtk_main_window_forward_button")), true);
+}
+
+
+/**
+ * Callback invoked if a text is inserted in "ssn" GtkEntry.
+ *
+ * @param cell_editable the object on which the signal was emitted
+ * @param user_data user data set when the signal handler was connected 
(unused)
+ */
+void
+anastasis_gtk_ia_ssn_entry_changed_cb (GtkCellEditable *cell_editable,
+                                       gpointer user_data)
+{
+    gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
+                                        
"anastasis_gtk_main_window_forward_button")), false);
+
+    // check, if required attributes are set to activate forward button
+    if (check_attributes_fullfilled ())
+        gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
+                                        
"anastasis_gtk_main_window_forward_button")), true);
+}
+
+
+/**
+ * Callback invoked if a text is inserted in "ahv" GtkEntry.
+ *
+ * @param cell_editable the object on which the signal was emitted
+ * @param user_data user data set when the signal handler was connected 
(unused)
+ */
+void
+anastasis_gtk_ia_ahv_entry_changed_cb (GtkCellEditable *cell_editable,
+                                       gpointer user_data)
+{
+    gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
+                                        
"anastasis_gtk_main_window_forward_button")), false);
+
+    // check, if required attributes are set to activate forward button
+    if (check_attributes_fullfilled ())
+        gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
+                                        
"anastasis_gtk_main_window_forward_button")), true);
+}
+
+
+/**
+ * Callback invoked if a text is inserted in "full_name" GtkEntry.
+ *
+ * @param cell_editable the object on which the signal was emitted
+ * @param user_data user data set when the signal handler was connected 
(unused)
+ */
+void
+anastasis_gtk_ia_full_name_entry_changed_cb (GtkCellEditable *cell_editable,
+                                             gpointer user_data)
+{
+    gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
+                                        
"anastasis_gtk_main_window_forward_button")), false);
+
+    // check, if required attributes are set to activate forward button
+    if (check_attributes_fullfilled ())
+        gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
+                                        
"anastasis_gtk_main_window_forward_button")), true);
+}
+
+
 /**
  * Callback invoked if a continent is selected (row-activated signal).
  *
@@ -333,15 +475,24 @@ anastasis_gtk_country_activated (GtkTreeView *tree_view,
             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);
+            if (check_state (redux_state, "ReduxContinentSelectedState"))
+                ANASTASIS_backup_action (redux_state,
+                                        "selection_country",
+                                        arguments,
+                                        &action_cb,
+                                        NULL);
+
+            else
+                if (! (0 == strcmp (country_name, json_string_value (
+                    json_object_get (redux_state, "selected_country")))))
+                {
+                    ANASTASIS_backup_action (redux_state,
+                                             "changing_country",
+                                             arguments,
+                                             &action_cb,
+                                             NULL);
+                }
+                
             g_free(country_name);
             g_free(country_code);
         }
@@ -384,6 +535,17 @@ anastasis_gtk_main_window_back_clicked (GObject *object,
         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_gtk_provider_frame"))))
+    {
+        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_provider_frame")));
+        if (check_attributes_fullfilled ())
+            gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
+                                        
"anastasis_gtk_main_window_forward_button")), true);
+    }
 }
 
 
@@ -397,12 +559,88 @@ void
 anastasis_gtk_main_window_forward_clicked (GObject *object,
                                            gpointer user_data)
 {
-    if (check_state (redux_state, "ReduxCountrySelectedState"))
+    if (check_state (redux_state, "ReduxCountrySelectedState") &&
+            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")));
         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);
+    }
+
+    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 *attributes = json_array ();
+
+        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))
+        {
+            const char *entry_widget;
+            const char *cal_widget;
+            const char *widget = gtk_buildable_get_name (iter->data);
+            json_t *id_attr = json_object ();
+
+            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)));
+                json_object_set_new (id_attr, "type", json_string ("string"));
+                json_object_set_new (id_attr, "value", json_string (value));
+                json_object_set_new (id_attr, "widget", json_string 
(entry_widget));
+            }
+            if (GCG_get_main_window_object (cal_widget))
+            {
+                guint day;
+                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_array_append_new (attributes, id_attr);
+            GNUNET_free (entry_widget);
+            GNUNET_free (cal_widget);
+        }
+        json_object_set_new (arguments, "identity", attributes);
+
+        if (check_state (redux_state, "ReduxCountrySelectedState"))
+            ANASTASIS_backup_action (redux_state,
+                                    "entering_user_attributes",
+                                    arguments,
+                                    &action_cb,
+                                    NULL);
+        else
+            ANASTASIS_backup_action (redux_state,
+                                     "editing_user_attributes",
+                                     arguments,
+                                     &action_cb,
+                                     NULL);
+
         gtk_widget_hide (GTK_WIDGET (GCG_get_main_window_object (
-                                        "anastasis_gtk_continent_frame")));
+                                        "anastasis_gtk_identity_frame")));
+        gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+                                        "anastasis_gtk_provider_frame")));
         gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
                                         
"anastasis_gtk_main_window_forward_button")), false);
     }

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