gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] 06/07: fix country/continent unselect


From: gnunet
Subject: [taler-anastasis-gtk] 06/07: fix country/continent unselect
Date: Fri, 09 Oct 2020 12:03:42 +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 ff163783a9131229e2cbae770655e5bde193fb60
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Fri Oct 9 09:00:11 2020 +0200

    fix country/continent unselect
---
 src/anastasis/anastasis-gtk.c        | 29 ++++++++++++++---------------
 src/anastasis/anastasis-gtk_backup.c |  6 ++----
 src/anastasis/anastasis-gtk_helper.c | 20 +++++++++-----------
 src/include/anastasis-gtk_helper.h   |  4 ++--
 4 files changed, 27 insertions(+), 32 deletions(-)

diff --git a/src/anastasis/anastasis-gtk.c b/src/anastasis/anastasis-gtk.c
index 22d21b8..3c08f0e 100644
--- a/src/anastasis/anastasis-gtk.c
+++ b/src/anastasis/anastasis-gtk.c
@@ -26,9 +26,7 @@
  */
 #include <gnunet/platform.h>
 #include <gnunet/gnunet_util_lib.h>
-#include <gnunet-gtk/gnunet_gtk.h>
-#include <gtk/gtk.h>
-#include <anastasis-gtk/anastasis-gtk_helper.h>
+#include "anastasis-gtk_helper.h"
 #include <jansson.h>
 
 /**
@@ -288,14 +286,14 @@ anastasis_gtk_country_activated (GtkTreeView *tree_view,
             json_object_set (arguments, "country_code", json_string 
(country_code));
             json_object_set (arguments, "currency", json_string 
(country_currency));
 
-            if (check_state (redux_state, "CountrySelectionState"))
+            if (check_state (redux_state, CountrySelectionState))
                 ANASTASIS_redux_action (redux_state,
                                         "select_country",
                                         arguments,
                                         &action_cb,
                                         NULL);
 
-            if (check_state (redux_state, "UserAttributesCollectionState"))
+            if (check_state (redux_state, UserAttributesCollectionState))
                 ANASTASIS_redux_action (redux_state,
                                         "select_country",
                                         arguments,
@@ -319,8 +317,8 @@ anastasis_gtk_continent_unselected (GtkTreeSelection 
*selection,
                                     gpointer user_data)
 {
     GtkTreeModel *model;
-
-    if (! gtk_tree_selection_get_selected (selection, &model, NULL))
+    if (! gtk_tree_selection_get_selected (selection, &model, NULL)
+            && ! check_state (redux_state, ContinentSelectionState))
         ANASTASIS_redux_action (redux_state,
                                 "unselect_continent",
                                 NULL,
@@ -340,8 +338,9 @@ anastasis_gtk_country_unselected (GtkTreeSelection 
*selection,
                                   gpointer user_data)
 {
     GtkTreeModel *model;
-
-    if (! gtk_tree_selection_get_selected (selection, &model, NULL))
+    
+    if (! gtk_tree_selection_get_selected (selection, &model, NULL)
+            && check_state (redux_state, UserAttributesCollectionState))
         ANASTASIS_redux_action (redux_state,
                                 "unselect_country",
                                 NULL,
@@ -366,7 +365,7 @@ anastasis_gtk_main_window_back_clicked (GObject *object,
     GNUNET_assert (NULL != state);
 
     //show continent frame, hide identity frame
-    if (check_state (redux_state, "UserAttributesCollectionState") &&
+    if (check_state (redux_state, UserAttributesCollectionState) &&
             gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
                                         "anastasis_gtk_identity_frame"))))
     {
@@ -378,7 +377,7 @@ anastasis_gtk_main_window_back_clicked (GObject *object,
     }
 
     //show identity frame, hide authentication frame
-    if (check_state (redux_state, "AuthenticationsEditingState") &&
+    if (check_state (redux_state, AuthenticationsEditingState) &&
             gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
                                         
"anastasis_gtk_b_authentication_frame"))))
     {
@@ -390,7 +389,7 @@ anastasis_gtk_main_window_back_clicked (GObject *object,
     }
 
     //show identity frame, hide authentication frame
-    if (check_state (redux_state, "AuthenticationsEditingState") &&
+    if (check_state (redux_state, AuthenticationsEditingState) &&
             gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
                                         
"anastasis_gtk_b_authentication_frame"))))
     {
@@ -414,7 +413,7 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
                                            gpointer user_data)
 {
     //show identity frame, hide continent frame
-    if (check_state (redux_state, "UserAttributesCollectionState") &&
+    if (check_state (redux_state, UserAttributesCollectionState) &&
             gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
                                         "anastasis_gtk_continent_frame"))))
     {
@@ -487,7 +486,7 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
         }
         json_object_set_new (arguments, "identity_attributes", id_attr);
 
-        if (check_state (redux_state, "UserAttributesCollectionState"))
+        if (check_state (redux_state, UserAttributesCollectionState))
             ANASTASIS_redux_action (redux_state,
                                     "enter_user_attributes",
                                     arguments,
@@ -506,7 +505,7 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
     if (gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
                                         
"anastasis_gtk_b_authentication_frame"))))
     {
-        if (check_state (redux_state, "AuthenticationsEditingState"))
+        if (check_state (redux_state, AuthenticationsEditingState))
         {
             GList *children;
 
diff --git a/src/anastasis/anastasis-gtk_backup.c 
b/src/anastasis/anastasis-gtk_backup.c
index 62dd616..7143583 100644
--- a/src/anastasis/anastasis-gtk_backup.c
+++ b/src/anastasis/anastasis-gtk_backup.c
@@ -26,10 +26,8 @@
  */
 #include <gnunet/platform.h>
 #include <gnunet/gnunet_util_lib.h>
-#include <gnunet-gtk/gnunet_gtk.h>
 #include <taler/taler_json_lib.h>
-#include <gtk/gtk.h>
-#include <anastasis-gtk/anastasis-gtk_helper.h>
+#include "anastasis-gtk_helper.h"
 #include <jansson.h>
 
 
@@ -141,7 +139,7 @@ anastasis_gtk_backup_button_clicked (GObject *object,
      redux_state = ANASTASIS_backup_start (cfg);
      GNUNET_assert (0 == persist_state (redux_state));
 
-     if (check_state (redux_state, "ContinentSelectionState"))
+     if (check_state (redux_state, ContinentSelectionState))
      {
           init_continent_list (redux_state);
      
diff --git a/src/anastasis/anastasis-gtk_helper.c 
b/src/anastasis/anastasis-gtk_helper.c
index 58d90d7..c762337 100644
--- a/src/anastasis/anastasis-gtk_helper.c
+++ b/src/anastasis/anastasis-gtk_helper.c
@@ -26,9 +26,7 @@
  */
 #include <gnunet/platform.h>
 #include <gnunet/gnunet_util_lib.h>
-#include <gnunet-gtk/gnunet_gtk.h>
-#include <gtk/gtk.h>
-#include <anastasis-gtk/anastasis-gtk_helper.h>
+#include "anastasis-gtk_helper.h"
 #include <jansson.h>
 
 
@@ -212,7 +210,7 @@ action_cb (void *cls,
     if (NULL != result_state)
     {
         redux_state = json_deep_copy (result_state);
-        if (check_state (redux_state, "ContinentSelectionState"))
+        if (check_state (redux_state, ContinentSelectionState))
         {
             GtkListStore *country_liststore = GTK_LIST_STORE 
(GCG_get_main_window_object ("country_liststore"));
 
@@ -224,7 +222,7 @@ action_cb (void *cls,
             gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
                                         
"anastasis_gtk_continent_selection_image")));
         }
-        if (check_state (redux_state, "CountrySelectionState"))
+        if (check_state (redux_state, CountrySelectionState))
         {
             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 (
@@ -244,13 +242,13 @@ action_cb (void *cls,
             gtk_widget_hide (GTK_WIDGET (GCG_get_main_window_object (
                                         
"anastasis_gtk_user_attributes_image")));
         }
-        if (check_state (redux_state, "UserAttributesCollectionState"))
+        if (check_state (redux_state, UserAttributesCollectionState))
         {
             gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
                                         
"anastasis_gtk_main_window_forward_button")), true);
             init_id_attr (redux_state, json_string_value (json_object_get 
(redux_state, "selected_country")));
         }
-        if (check_state (redux_state, "AuthenticationsEditingState"))
+        if (check_state (redux_state, AuthenticationsEditingState))
         {
             if (json_object_get (redux_state, "backup_state"))
             {
@@ -261,7 +259,7 @@ action_cb (void *cls,
                                                 
"anastasis_gtk_b_authentication_methods_image")));
             }
         }
-        if (check_state (redux_state, "PoliciesReviewingState")
+        if (check_state (redux_state, PoliciesReviewingState)
                 && gtk_widget_is_visible (GTK_WIDGET 
(GCG_get_main_window_object (
                                         
"anastasis_gtk_b_authentication_frame"))))
         {
@@ -294,16 +292,16 @@ action_cb (void *cls,
  * Checks the actual state. True, if state is correct, else false.
  * 
  * @param state the state to check
- * @param state_name the expected state
+ * @param expected_state the expected state enum
  * @return bool
  */
 bool
-check_state (json_t *state, char *expected_state)
+check_state (json_t *state, REDUX_STATE expected_state)
 {
     const char *state_name = json_string_value (json_object_get (state, 
"backup_state"));
     if (NULL == state_name)
         state_name = json_string_value (json_object_get (state, 
"recovery_state"));
-    if (0 == strcmp (state_name, expected_state))
+    if (0 == strcmp (state_name, STATE_STRING[expected_state]))
         return true;
     else
         return false;
diff --git a/src/include/anastasis-gtk_helper.h 
b/src/include/anastasis-gtk_helper.h
index b5694bd..16fa045 100644
--- a/src/include/anastasis-gtk_helper.h
+++ b/src/include/anastasis-gtk_helper.h
@@ -102,11 +102,11 @@ check_attributes_fullfilled ();
  * Checks the actual state. True, if state is correct, else false.
  * 
  * @param state the state to check
- * @param state_name the expected state
+ * @param expected_state the expected state enum
  * @return bool
  */
 bool
-check_state (json_t *state, char *expected_state);
+check_state (json_t *state, REDUX_STATE expected_state);
 
 
 /**

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