gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] 02/05: fix loop - show forward button in identity


From: gnunet
Subject: [taler-anastasis-gtk] 02/05: fix loop - show forward button in identity frame
Date: Thu, 17 Sep 2020 15:29:45 +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 46077b8dd6f3f12e5edba029d379ea321c73ce59
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Thu Sep 17 10:43:08 2020 +0200

    fix loop - show forward button in identity frame
---
 contrib/anastasis_gtk_main_window.glade |   8 +-
 src/anastasis/anastasis-gtk_helper.c    | 181 +++++++++++++++++++++++---------
 2 files changed, 135 insertions(+), 54 deletions(-)

diff --git a/contrib/anastasis_gtk_main_window.glade 
b/contrib/anastasis_gtk_main_window.glade
index eeccf94..e5720ff 100644
--- a/contrib/anastasis_gtk_main_window.glade
+++ b/contrib/anastasis_gtk_main_window.glade
@@ -317,7 +317,7 @@
                                             <property 
name="can_focus">True</property>
                                             <property 
name="hexpand">True</property>
                                             <property name="placeholder_text" 
translatable="yes">Max Mustermann</property>
-                                            <signal name="insert-text" 
handler="anastasis_gtk_ia_full_name_entry_insert_text_cb" swapped="no"/>
+                                            <signal name="changed" 
handler="anastasis_gtk_ia_full_name_entry_changed_cb" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property 
name="expand">False</property>
@@ -357,7 +357,7 @@
                                             <property 
name="can_focus">True</property>
                                             <property 
name="hexpand">True</property>
                                             <property name="placeholder_text" 
translatable="yes">123456789</property>
-                                            <signal name="insert-text" 
handler="anastasis_gtk_ia_ahv_entry_insert_text_cb" swapped="no"/>
+                                            <signal name="changed" 
handler="anastasis_gtk_ia_ahv_entry_changed_cb" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property 
name="expand">False</property>
@@ -397,7 +397,7 @@
                                             <property 
name="can_focus">True</property>
                                             <property 
name="hexpand">True</property>
                                             <property name="placeholder_text" 
translatable="yes">123456789</property>
-                                            <signal name="insert-text" 
handler="anastasis_gtk_ia_ssn_entry_insert_text_cb" swapped="no"/>
+                                            <signal name="changed" 
handler="anastasis_gtk_ia_ssn_entry_changed_cb" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property 
name="expand">False</property>
@@ -435,7 +435,7 @@
                                             <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>
diff --git a/src/anastasis/anastasis-gtk_helper.c 
b/src/anastasis/anastasis-gtk_helper.c
index c9935eb..fe5779a 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.
  *
@@ -259,63 +321,82 @@ init_id_attr (json_t *state,
 
 
 /**
- * Callback invoked if a text is inserted in "full_name" GtkEntry.
+ * Callback invoked if a text is inserted in "cal" GtkEntry.
  *
- * @param editable the object which received the signal
- * @param start_pos the starting position
- * @param cend_pos the end position
+ * @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_insert_text_cb (GtkEditable *editable,
-                                                 char *new_text,
-                                                 int new_text_length,
-                                                 gpointer position,
-                                                 gpointer user_data)
+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
-    {
-        bool fullfilled = true;
-        size_t index;
-        json_t *id_attr;
-        json_t *id_attributes = json_object_get (redux_state, 
"required_attributes");
+    if (check_attributes_fullfilled ())
+        gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
+                                        
"anastasis_gtk_main_window_forward_button")), true);
+}
 
-        json_array_foreach (id_attributes, index, id_attr)
-        {
-            if (json_boolean (json_object_get (id_attr, "required")))
-            {
-                const char *type = json_string_value (json_object_get 
(id_attr, "type"));
-                if (0 == strcmp (type, "string"))
-                {
-                    const char *widget_name = json_string_value 
(json_object_get (id_attr, "widget"));
-                    char *label_widget;
-                    GNUNET_asprintf (&label_widget,
-                                     "%s_entry",
-                                     widget_name);
-                    GObject *entry = GCG_get_main_window_object (label_widget);
-                    GNUNET_free (label_widget);
-                    if (0 == gtk_entry_get_text_length (GTK_ENTRY (entry)))
-                        fullfilled = false;
-                }
-                if (0 == strcmp (type, "date"))
-                {
-                    guint day;
-                    const char *widget_name = json_string_value 
(json_object_get (id_attr, "widget"));
-                    char *label_widget;
-                    GNUNET_asprintf (&label_widget,
-                                     "%s_cal",
-                                     widget_name);
-                    GObject *cal = GCG_get_main_window_object (label_widget);
-                    GNUNET_free (label_widget);
-                    if (!gtk_calendar_get_day_is_marked (GTK_CALENDAR (cal), 
day))
-                        fullfilled = false;
-                }
-            }
-        }
-        if (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);
 }
 
 

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