gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] 07/07: rework add_authentication


From: gnunet
Subject: [taler-anastasis-gtk] 07/07: rework add_authentication
Date: Fri, 09 Oct 2020 12:03:43 +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 2527cca6edeeeb4a0ce0a2c2e6b68ec3ffe55d7c
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Fri Oct 9 12:03:27 2020 +0200

    rework add_authentication
---
 src/anastasis/anastasis-gtk.c        |  71 ++++--------
 src/anastasis/anastasis-gtk_backup.c | 208 ++++++++++++++++++-----------------
 src/anastasis/anastasis-gtk_helper.c |  45 ++++++--
 src/include/anastasis-gtk_helper.h   |   9 +-
 4 files changed, 167 insertions(+), 166 deletions(-)

diff --git a/src/anastasis/anastasis-gtk.c b/src/anastasis/anastasis-gtk.c
index 3c08f0e..8acb749 100644
--- a/src/anastasis/anastasis-gtk.c
+++ b/src/anastasis/anastasis-gtk.c
@@ -359,45 +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 (NULL != state);
-
-    //show continent frame, hide identity frame
-    if (check_state (redux_state, UserAttributesCollectionState) &&
-            gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
-                                        "anastasis_gtk_identity_frame"))))
-    {
-        ANASTASIS_redux_action (redux_state,
-                                "back",
-                                NULL,
-                                &action_cb,
-                                NULL);
-    }
-
+    ANASTASIS_redux_action (redux_state,
+                            "back",
+                            NULL,
+                            &action_cb,
+                            NULL);
     //show identity frame, hide authentication frame
-    if (check_state (redux_state, AuthenticationsEditingState) &&
-            gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
-                                        
"anastasis_gtk_b_authentication_frame"))))
-    {
-        ANASTASIS_redux_action (redux_state,
-                                "back",
-                                NULL,
-                                &action_cb,
-                                NULL);
-    }
-
-    //show identity frame, hide authentication frame
-    if (check_state (redux_state, AuthenticationsEditingState) &&
+    if (check_state (redux_state, UserAttributesCollectionState) &&
             gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
                                         
"anastasis_gtk_b_authentication_frame"))))
     {
-        ANASTASIS_redux_action (redux_state,
-                                "back",
-                                NULL,
-                                &action_cb,
-                                NULL);
+        anastasis_gtk_hide_all_frames ();
+        gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+                                        "anastasis_gtk_identity_frame")));
+        gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+                                        
"anastasis_gtk_user_attributes_image")));
     }
 }
 
@@ -417,16 +393,11 @@ anastasis_gtk_main_window_forward_clicked (GObject 
*object,
             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")));
     }
@@ -493,12 +464,9 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
                                     &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
@@ -507,13 +475,14 @@ anastasis_gtk_main_window_forward_clicked (GObject 
*object,
     {
         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 7143583..aebdfd4 100644
--- a/src/anastasis/anastasis-gtk_backup.c
+++ b/src/anastasis/anastasis-gtk_backup.c
@@ -200,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;
@@ -214,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 (
@@ -222,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),
@@ -350,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),
@@ -484,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),
@@ -594,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),
@@ -704,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),
@@ -1113,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"));
 
@@ -1155,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))
                {
@@ -1169,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);
@@ -1190,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);
@@ -1213,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));
@@ -1295,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 c762337..7621f51 100644
--- a/src/anastasis/anastasis-gtk_helper.c
+++ b/src/anastasis/anastasis-gtk_helper.c
@@ -194,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.
@@ -214,33 +242,27 @@ action_cb (void *cls,
         {
             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_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_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 (
-                                        
"anastasis_gtk_continent_selection_image")));
             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_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_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")));
-            gtk_widget_hide (GTK_WIDGET (GCG_get_main_window_object (
-                                        
"anastasis_gtk_user_attributes_image")));
         }
         if (check_state (redux_state, UserAttributesCollectionState))
         {
@@ -252,6 +274,7 @@ action_cb (void *cls,
         {
             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);
@@ -265,10 +288,8 @@ action_cb (void *cls,
         {
             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 (
diff --git a/src/include/anastasis-gtk_helper.h 
b/src/include/anastasis-gtk_helper.h
index 16fa045..2ff471b 100644
--- a/src/include/anastasis-gtk_helper.h
+++ b/src/include/anastasis-gtk_helper.h
@@ -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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]