gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] 04/05: worked on adding authentication methods


From: gnunet
Subject: [taler-anastasis-gtk] 04/05: worked on adding authentication methods
Date: Wed, 23 Sep 2020 19:02:54 +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 45e4f316d6eba626593febb1fbd033f16afd4cfe
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Wed Sep 23 11:23:11 2020 +0200

    worked on adding authentication methods
---
 contrib/anastasis_gtk_main_window.glade |  24 ++---
 src/anastasis/anastasis-gtk_backup.c    | 159 +++++++++++++++++++++++++++++++-
 2 files changed, 171 insertions(+), 12 deletions(-)

diff --git a/contrib/anastasis_gtk_main_window.glade 
b/contrib/anastasis_gtk_main_window.glade
index e9290c2..6c30bcf 100644
--- a/contrib/anastasis_gtk_main_window.glade
+++ b/contrib/anastasis_gtk_main_window.glade
@@ -481,6 +481,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <signal name="clicked" 
handler="anastasis_gtk_b_question_dialog_btn_cancel_clicked_cb" swapped="no"/>
               </object>
               <packing>
                 <property name="expand">True</property>
@@ -494,6 +495,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <signal name="clicked" 
handler="anastasis_gtk_b_question_dialog_btn_ok_clicked_cb" swapped="no"/>
               </object>
               <packing>
                 <property name="expand">True</property>
@@ -583,7 +585,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkEntry">
+                  <object class="GtkEntry" 
id="anastasis_gtk_b_question_dialog_question_entry">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="hexpand">True</property>
@@ -636,7 +638,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkEntry">
+              <object class="GtkEntry" 
id="anastasis_gtk_b_question_dialog_answer_entry">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="hexpand">True</property>
@@ -1518,25 +1520,25 @@
                                     <property name="can_focus">False</property>
                                     <property name="left_padding">12</property>
                                     <child>
-                                      <object class="GtkBox" 
id="anastasis_gtk_provider_vbox">
+                                      <object class="GtkBox">
                                         <property 
name="visible">True</property>
                                         <property 
name="can_focus">False</property>
                                         <property 
name="orientation">vertical</property>
                                         <child>
-                                          <object class="GtkBox">
+                                          <object class="GtkBox" 
id="anastasis_gtk_b_authentication_hbox">
                                             <property 
name="visible">True</property>
                                             <property 
name="can_focus">False</property>
                                             <child>
-                                              <object class="GtkTextView">
-                                                <property 
name="name">anastasis_gtk_b_authentication_methods_text</property>
+                                              <object class="GtkBox" 
id="anastasis_gtk_b_authentication_vbox">
                                                 <property 
name="visible">True</property>
-                                                <property 
name="can_focus">True</property>
-                                                <property 
name="hexpand">True</property>
-                                                <property 
name="vexpand">True</property>
-                                                <property 
name="editable">False</property>
+                                                <property 
name="can_focus">False</property>
+                                                <property 
name="orientation">vertical</property>
+                                                <child>
+                                                  <placeholder/>
+                                                </child>
                                               </object>
                                               <packing>
-                                                <property 
name="expand">False</property>
+                                                <property 
name="expand">True</property>
                                                 <property 
name="fill">True</property>
                                                 <property 
name="position">0</property>
                                               </packing>
diff --git a/src/anastasis/anastasis-gtk_backup.c 
b/src/anastasis/anastasis-gtk_backup.c
index 8236af8..49eb1e2 100644
--- a/src/anastasis/anastasis-gtk_backup.c
+++ b/src/anastasis/anastasis-gtk_backup.c
@@ -124,6 +124,80 @@ anastasis_gtk_backup_button_clicked (GObject *object,
 }
 
 
+/**
+ * Callback invoked if the the "authentication methods edit"-button is clicked.
+ *
+ * @param object
+ * @param user_data unused
+ */
+void
+anastasis_gtk_b_auth_method_btn_edit_clicked_cb (GObject *object,
+                                                 gpointer user_data)
+{
+     GList *children, *iter;
+     children = gtk_container_get_children (GTK_CONTAINER (user_data));
+     char *type;
+     unsigned int index = 0;
+     for (iter = children; iter != NULL; iter = g_list_next (iter))
+     {
+          gchar *text;
+          gchar *widget_name = gtk_widget_get_name (GTK_WIDGET (iter->dara));
+          if (0 == strcmp (widget_name, "GtkLabel"))
+          {
+               text = gtk_label_get_text (GTK_LABEL (iter->dara));
+               if (0 == strcmp (text, "Q: "))
+                    type = "question";
+               if (0 == strcmp (text, "SMS: "))
+                    type = "sms";
+               if (0 == strcmp (text, "EMAIL: "))
+                    type = "email";
+               if (0 == strcmp (text, "POST: "))
+                    type = "post";
+               if (0 == strcmp (text, "VIDEO: "))
+                    type = "video";
+          }
+          if (index > 0)
+          {
+               if (0 == strcmp (type, "question"))
+               {
+                    if (index == 1)
+                         gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_question_dialog_question_entry")), text);
+                    if (index == 2)
+                         gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_question_dialog_answer_entry")), text);
+               }
+          }
+          index++;
+     }
+     g_list_free (children);
+
+     GtkButton *ok_btn = GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_question_dialog_btn_ok");
+     g_signal_connect (ok_btn, 
+                       "clicked", 
+                       G_CALLBACK 
(anastasis_gtk_b_question_dialog_btn_ok_clicked_cb),
+                       user_data);
+     
+     gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+                                        "anastasis_gtk_b_question_dialog")));
+}
+
+
+/**
+ * Callback invoked if the the "authentication methods delete"-button is 
clicked.
+ *
+ * @param object
+ * @param user_data unused
+ */
+void
+anastasis_gtk_b_auth_method_btn_delete_clicked_cb (GObject *object,
+                                                   gpointer user_data)
+{
+     gtk_widget_destroy (GTK_WIDGET (user_data));
+}
+
+
 /**
  * Callback invoked if the the "secure question"-button is clicked.
  *
@@ -132,13 +206,96 @@ anastasis_gtk_backup_button_clicked (GObject *object,
  */
 void
 anastasis_gtk_btn_add_auth_question_clicked_cb (GObject *object,
-                                                 gpointer user_data)
+                                                gpointer user_data)
 {
      gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
                                         "anastasis_gtk_b_question_dialog")));
 }
 
 
+/**
+ * Callback invoked if the the "secure question OK"-button is clicked.
+ *
+ * @param object
+ * @param user_data unused
+ */
+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 = (GtkHBox *) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+     GtkSeparator *separator = (GtkSeparator *) gtk_separator_new 
(GTK_ORIENTATION_HORIZONTAL);
+
+     // set labels
+     GtkLabel *label_prefix = (GtkLabel *) gtk_label_new ("Q: ");
+     gchar *question = gtk_entry_get_text (
+          GTK_ENTRY (GCG_get_main_window_object 
("anastasis_gtk_b_question_dialog_question_entry")));
+     GtkLabel *label_question = (GtkLabel *) gtk_label_new (question);
+     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);
+
+     // set buttons
+     GtkHButtonBox *buttons = (GtkHButtonBox *) gtk_hbox_new(1, 0);
+     GtkButton  *edit_btn = (GtkButton *) gtk_button_new_with_label ("edit");
+     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");
+     g_signal_connect (delete_btn, 
+                       "clicked", 
+                       G_CALLBACK 
(anastasis_gtk_b_auth_method_btn_delete_clicked_cb),
+                       hbox);
+     gtk_box_pack_start (buttons, edit_btn, 0, 0, 0);
+     gtk_box_pack_start (buttons, delete_btn, 0, 0, 0);
+     
+     gtk_box_pack_start (hbox, label_prefix, 0, 0, 0);
+     gtk_box_pack_start (hbox, label_question, 0, 0, 0);
+     gtk_box_pack_start (hbox, label_answer, 0, 0, 0);
+     gtk_box_pack_end (hbox, buttons, 0, 0, 0);
+
+     gtk_box_pack_start (vbox, hbox, 0, 0, 0);
+     gtk_box_pack_start (vbox, separator, 0, 0, 0);
+
+     gtk_widget_show (GTK_WIDGET (hbox));
+     gtk_widget_show (GTK_WIDGET (label_prefix));
+     gtk_widget_show (GTK_WIDGET (label_question));
+     gtk_widget_hide (GTK_WIDGET (label_answer));
+     gtk_widget_show (GTK_WIDGET (buttons));
+     gtk_widget_show (GTK_WIDGET (edit_btn));
+     gtk_widget_show (GTK_WIDGET (delete_btn));
+     gtk_widget_show (GTK_WIDGET (separator));
+
+     gtk_entry_set_text ( GTK_ENTRY (
+          GCG_get_main_window_object 
("anastasis_gtk_b_question_dialog_question_entry")), "");
+     gtk_entry_set_text ( GTK_ENTRY (
+          GCG_get_main_window_object 
("anastasis_gtk_b_question_dialog_answer_entry")), "");
+     gtk_widget_hide (GTK_WIDGET (GCG_get_main_window_object (
+                                        "anastasis_gtk_b_question_dialog")));
+}
+
+
+/**
+ * Callback invoked if the the "secure question Cancel"-button is clicked.
+ *
+ * @param object
+ * @param user_data unused
+ */
+void
+anastasis_gtk_b_question_dialog_btn_cancel_clicked_cb (GObject *object,
+                                                       gpointer user_data)
+{
+     gtk_entry_set_text ( GTK_ENTRY (
+          GCG_get_main_window_object 
("anastasis_gtk_b_question_dialog_question_entry")), "");
+     gtk_entry_set_text ( GTK_ENTRY (
+          GCG_get_main_window_object 
("anastasis_gtk_b_question_dialog_answer_entry")), "");
+     gtk_widget_hide (GTK_WIDGET (GCG_get_main_window_object (
+                                        "anastasis_gtk_b_question_dialog")));
+}
+
+
 /**
  * Callback invoked if the the "post"-button is clicked.
  *

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