gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] 03/05: worked on policy frame


From: gnunet
Subject: [taler-anastasis-gtk] 03/05: worked on policy frame
Date: Tue, 06 Oct 2020 09:57:39 +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 a1f293d4a228ca0726ada0537cf73db489b6fde9
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Mon Oct 5 13:56:18 2020 +0200

    worked on policy frame
---
 contrib/anastasis_gtk_main_window.glade |  25 ++--
 src/anastasis/anastasis-gtk_backup.c    | 195 +++++++++++++++++++++-----------
 src/anastasis/anastasis-gtk_helper.c    |  44 +++++++
 src/include/anastasis-gtk_helper.h      |  21 ++++
 4 files changed, 201 insertions(+), 84 deletions(-)

diff --git a/contrib/anastasis_gtk_main_window.glade 
b/contrib/anastasis_gtk_main_window.glade
index 2af5e9a..fd0489f 100644
--- a/contrib/anastasis_gtk_main_window.glade
+++ b/contrib/anastasis_gtk_main_window.glade
@@ -69,7 +69,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkComboBoxText">
+                  <object class="GtkComboBoxText" 
id="anastasis_gtk_b_email_dialog_provider">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="has_entry">True</property>
@@ -78,6 +78,7 @@
                     </items>
                     <child internal-child="entry">
                       <object class="GtkEntry">
+                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
                       </object>
                     </child>
@@ -225,7 +226,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkComboBoxText">
+                  <object class="GtkComboBoxText" 
id="anastasis_gtk_b_post_dialog_provider">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="has_entry">True</property>
@@ -234,6 +235,7 @@
                     </items>
                     <child internal-child="entry">
                       <object class="GtkEntry">
+                        <property name="visible">True</property>
                         <property name="can_focus">False</property>
                       </object>
                     </child>
@@ -367,17 +369,6 @@
                 <property name="position">4</property>
               </packing>
             </child>
-            <child>
-              <object class="GtkSeparator">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">5</property>
-              </packing>
-            </child>
             <child>
               <object class="GtkBox">
                 <property name="visible">True</property>
@@ -527,7 +518,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkComboBoxText">
+              <object class="GtkComboBoxText" 
id="anastasis_gtk_b_question_dialog_provider">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="has_entry">True</property>
@@ -536,6 +527,7 @@
                 </items>
                 <child internal-child="entry">
                   <object class="GtkEntry">
+                    <property name="visible">True</property>
                     <property name="can_focus">True</property>
                   </object>
                 </child>
@@ -729,7 +721,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkComboBoxText">
+              <object class="GtkComboBoxText" 
id="anastasis_gtk_b_sms_dialog_provider">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="has_entry">True</property>
@@ -738,6 +730,7 @@
                 </items>
                 <child internal-child="entry">
                   <object class="GtkEntry">
+                    <property name="visible">True</property>
                     <property name="can_focus">True</property>
                   </object>
                 </child>
@@ -909,7 +902,7 @@
                       <item translatable="yes">ABCDEFGH</item>
                     </items>
                     <child internal-child="entry">
-                      <object class="GtkEntry">
+                      <object class="GtkEntry" 
id="anastasis_gtk_b_video_dialog_provider">
                         <property name="can_focus">True</property>
                       </object>
                     </child>
diff --git a/src/anastasis/anastasis-gtk_backup.c 
b/src/anastasis/anastasis-gtk_backup.c
index a6aa354..707f7ad 100644
--- a/src/anastasis/anastasis-gtk_backup.c
+++ b/src/anastasis/anastasis-gtk_backup.c
@@ -778,7 +778,7 @@ anastasis_gtk_b_email_dialog_btn_cancel_clicked_cb (GObject 
*object,
  * Callback invoked if the the "authentication methods edit"-button is clicked.
  *
  * @param object
- * @param user_data unused
+ * @param user_data 
  */
 void
 anastasis_gtk_b_auth_method_btn_edit_clicked_cb (GObject *object,
@@ -786,8 +786,12 @@ anastasis_gtk_b_auth_method_btn_edit_clicked_cb (GObject 
*object,
 {
      GList *children, *iter;
      children = gtk_container_get_children (GTK_CONTAINER (user_data));
+     bool policy_frame_active = false;
      char *type = "";
      unsigned int index = 0;
+     if (gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
+                                        "anastasis_gtk_b_policy_frame"))))
+          policy_frame_active = true;
      for (iter = children; iter != NULL; iter = g_list_next (iter))
      {
           const gchar *text = "";
@@ -806,127 +810,183 @@ anastasis_gtk_b_auth_method_btn_edit_clicked_cb 
(GObject *object,
                if (0 == strcmp (text, "VIDEO: "))
                     type = "video";
           }
+          if (index == 0 && policy_frame_active)
+               gtk_widget_show (GTK_WIDGET (iter->data));
+          else if (index == 0)
+               gtk_widget_hide (GTK_WIDGET (iter->data));
           if (index > 0)
           {
+               GtkEntry *entry;
+
                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);
+                    {
+                         entry = (GtkEntry *) GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_question_dialog_question_entry");
+                         gtk_entry_set_text (entry, text);
+                    }
                     if (index == 2)
                     {
                          gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
                                         
"anastasis_gtk_b_question_dialog_answer_entry")), text);
                          GtkButton *ok_btn = GTK_BUTTON 
(GCG_get_main_window_object (
                                         
"anastasis_gtk_b_question_dialog_btn_ok"));
-                         if (g_signal_question > 0)
-                              g_signal_handler_disconnect (ok_btn, 
g_signal_question);
-                         g_signal_question = g_signal_connect(ok_btn, 
-                                                              "clicked", 
-                                                              G_CALLBACK 
(anastasis_gtk_b_question_dialog_btn_ok_clicked_cb),
-                                                              user_data);
-                         
+                         if (! policy_frame_active)
+                         {
+                              if (g_signal_question > 0)
+                                   g_signal_handler_disconnect (ok_btn, 
g_signal_question);
+                              g_signal_question = 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")));
-                         break;
-                    }
-                    
+                    } 
                }
                if (0 == strcmp (type, "sms"))
                {
                     if (index == 1)
                     {
-                         gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
-                                        
"anastasis_gtk_b_sms_dialog_phonenumber_entry")), text);
+                         entry = (GtkEntry *) GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_sms_dialog_phonenumber_entry");
+                         gtk_entry_set_text (entry, text);
                          GtkButton *ok_btn = GTK_BUTTON 
(GCG_get_main_window_object (
                                         "anastasis_gtk_b_sms_dialog_btn_ok"));
-                         if (g_signal_sms > 0)
-                              g_signal_handler_disconnect (ok_btn, 
g_signal_sms);
-                         g_signal_sms = g_signal_connect (ok_btn, 
-                                                          "clicked", 
-                                                          G_CALLBACK 
(anastasis_gtk_b_sms_dialog_btn_ok_clicked_cb),
-                                                          user_data);
+                         if (! policy_frame_active)
+                         {
+                              if (g_signal_sms > 0)
+                                   g_signal_handler_disconnect (ok_btn, 
g_signal_sms);
+                              g_signal_sms = g_signal_connect (ok_btn, 
+                                                            "clicked", 
+                                                            G_CALLBACK 
(anastasis_gtk_b_sms_dialog_btn_ok_clicked_cb),
+                                                            user_data);
+                         }
                          
                          gtk_widget_show (GTK_WIDGET 
(GCG_get_main_window_object (
                                                             
"anastasis_gtk_b_sms_dialog")));
-                         break;
                     }
                }
                if (0 == strcmp (type, "email"))
                {
                     if (index == 1)
                     {
-                         gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
-                                        
"anastasis_gtk_b_email_dialog_mailaddress_entry")), text);
+                         entry = (GtkEntry *) GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_email_dialog_mailaddress_entry");
+                         gtk_entry_set_text (entry, text);
                          GtkButton *ok_btn = GTK_BUTTON 
(GCG_get_main_window_object (
                                         
"anastasis_gtk_b_email_dialog_btn_ok"));
-                         if (g_signal_email > 0)
-                              g_signal_handler_disconnect (ok_btn, 
g_signal_email);
-                         g_signal_email = g_signal_connect (ok_btn, 
-                                                            "clicked", 
-                                                            G_CALLBACK 
(anastasis_gtk_b_email_dialog_btn_ok_clicked_cb),
-                                                            user_data);
+                         if (! policy_frame_active)
+                         {
+                              if (g_signal_email > 0)
+                                   g_signal_handler_disconnect (ok_btn, 
g_signal_email);
+                              g_signal_email = g_signal_connect (ok_btn, 
+                                                                 "clicked", 
+                                                                 G_CALLBACK 
(anastasis_gtk_b_email_dialog_btn_ok_clicked_cb),
+                                                                 user_data);
+                         }
                          
                          gtk_widget_show (GTK_WIDGET 
(GCG_get_main_window_object (
                                                             
"anastasis_gtk_b_email_dialog")));
-                         break;
                     }
                }
                if (0 == strcmp (type, "post"))
-               {
+               {         
                     if (index == 1)
-                         gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
-                                        
"anastasis_gtk_b_post_dialog_full_name_entry")), text);
+                    {
+                         entry = (GtkEntry *) GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_post_dialog_full_name_entry");
+                         gtk_entry_set_text (entry, text);
+                    }
                     if (index == 2)
-                         gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
-                                        
"anastasis_gtk_b_post_dialog_street_entry")), text);
+                    {
+                         entry = (GtkEntry *) GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_post_dialog_street_entry");
+                         gtk_entry_set_text (entry, text);
+                    }
                     if (index == 3)
-                         gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
-                                        
"anastasis_gtk_b_post_dialog_city_entry")), text);
+                    {
+                         entry = (GtkEntry *) GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_post_dialog_city_entry");
+                         gtk_entry_set_text (entry, text);
+                    }
                     if (index == 4)
-                         gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
-                                        
"anastasis_gtk_b_post_dialog_postcode_entry")), text);
+                    {
+                         entry = (GtkEntry *) GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_post_dialog_postcode_entry");
+                         gtk_entry_set_text (entry, text);
+                    }
                     if (index == 5)
                     {
-                         gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
-                                        
"anastasis_gtk_b_post_dialog_country_entry")), text);
+                         entry = (GtkEntry *) GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_post_dialog_country_entry");
+                         gtk_entry_set_text (entry, text);
                          GtkButton *ok_btn = GTK_BUTTON 
(GCG_get_main_window_object (
                                         "anastasis_gtk_b_post_dialog_btn_ok"));
-                         if (g_signal_post > 0)
-                              g_signal_handler_disconnect (ok_btn, 
g_signal_post);
-                         g_signal_post = g_signal_connect (ok_btn, 
-                                                           "clicked", 
-                                                           G_CALLBACK 
(anastasis_gtk_b_post_dialog_btn_ok_clicked_cb),
-                                                           user_data);
+                         if (! policy_frame_active)
+                         {
+                              if (g_signal_post > 0)
+                                   g_signal_handler_disconnect (ok_btn, 
g_signal_post);
+                              g_signal_post = g_signal_connect (ok_btn, 
+                                                            "clicked", 
+                                                            G_CALLBACK 
(anastasis_gtk_b_post_dialog_btn_ok_clicked_cb),
+                                                            user_data);
+                         }
                          
                          gtk_widget_show (GTK_WIDGET 
(GCG_get_main_window_object (
                                                             
"anastasis_gtk_b_post_dialog")));
-                         break;
                     }
                }
                if (0 == strcmp (type, "video"))
                {
                     if (index == 1)
                     {
-                         gtk_entry_set_text (GTK_ENTRY 
(GCG_get_main_window_object (
-                                        
"anastasis_gtk_b_video_dialog_photo_path_entry")), text);
+                         GtkEntry *entry = (GtkEntry *) 
GCG_get_main_window_object (
+                                        
"anastasis_gtk_b_video_dialog_photo_path_entry");
+                         gtk_entry_set_text (entry, text);
+
                          GtkButton *ok_btn = GTK_BUTTON 
(GCG_get_main_window_object (
                                         
"anastasis_gtk_b_video_dialog_btn_ok"));
-                         if (g_signal_video > 0)
+                         if (! policy_frame_active)
+                         {
+                              if (g_signal_video > 0)
                               g_signal_handler_disconnect (ok_btn, 
g_signal_video);
-                         g_signal_video = g_signal_connect (ok_btn, 
-                                                            "clicked", 
-                                                            G_CALLBACK 
(anastasis_gtk_b_video_dialog_btn_ok_clicked_cb),
-                                                            user_data);
+                              g_signal_video = g_signal_connect (ok_btn, 
+                                                                 "clicked", 
+                                                                 G_CALLBACK 
(anastasis_gtk_b_video_dialog_btn_ok_clicked_cb),
+                                                                 user_data);
+                         }
                          
                          gtk_widget_show (GTK_WIDGET 
(GCG_get_main_window_object (
                                                             
"anastasis_gtk_b_video_dialog")));
-                         break;
                     }
                }
+               if (entry && policy_frame_active)
+                    gtk_editable_set_editable (GTK_EDITABLE (entry), false);
+               else if (entry)
+                    gtk_editable_set_editable (GTK_EDITABLE (entry), true);
           }
           index++;
      }
+     if (policy_frame_active)
+     {
+          //show provider combo box
+          gtk_widget_show (gtk_widget_get_parent (GTK_WIDGET 
+                         (GCG_get_main_window_object 
("anastasis_gtk_b_sms_dialog_provider"))));
+          gtk_widget_show (gtk_widget_get_parent (GTK_WIDGET 
+                         (GCG_get_main_window_object 
("anastasis_gtk_b_email_dialog_provider"))));
+          gtk_widget_show (gtk_widget_get_parent (GTK_WIDGET 
+                         (GCG_get_main_window_object 
("anastasis_gtk_b_question_dialog_provider"))));
+          gtk_widget_show (gtk_widget_get_parent (GTK_WIDGET 
+                         (GCG_get_main_window_object 
("anastasis_gtk_b_post_dialog_provider"))));
+          gtk_widget_show (gtk_widget_get_parent (GTK_WIDGET 
+                         (GCG_get_main_window_object 
("anastasis_gtk_b_video_dialog_provider"))));
+
+          //hide secret answer entry
+          gtk_widget_hide (gtk_widget_get_parent (GTK_WIDGET 
+                         (GCG_get_main_window_object 
("anastasis_gtk_b_question_dialog_answer_entry"))));
+     }
      g_list_free (children);
 }
 
@@ -989,7 +1049,7 @@ config_cb (void *cls,
 
 
 /**
- * Initialize the auhentication methods in backup mode.
+ * Prepare authentication methods for policy generation.
  * 
  * @param state the state to operate on
  */
@@ -1015,13 +1075,7 @@ init_b_policy (json_t *state)
      gtk_widget_set_valign (GTK_WIDGET (frm_policy_title), GTK_ALIGN_CENTER);
 
      //get number of policies/policy columns
-     GValue val_policies_col = G_VALUE_INIT;
-     g_value_init (&val_policies_col, G_TYPE_INT);
-     gtk_container_child_get_property (GTK_CONTAINER (grid), 
-                                       GTK_WIDGET (frm_policy_title), 
-                                       "width", 
-                                       &val_policies_col);
-     int policies_col = g_value_get_int (&val_policies_col);
+     int policies_col = get_widget_width (grid, GTK_WIDGET (frm_policy_title));
 
      //format title label for backup cost
      GtkFrame *frm_b_cost_title = 
@@ -1094,7 +1148,14 @@ init_b_policy (json_t *state)
 
                               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);
+                              g_signal_connect (btn_edit_method, 
+                                                "clicked", 
+                                                G_CALLBACK 
(anastasis_gtk_b_auth_method_btn_edit_clicked_cb),
+                                                method_hbox);
+                              gtk_box_pack_end (GTK_BOX (method_hbox), 
GTK_WIDGET (btn_edit_method), 0, 0, 0);
                               gtk_widget_show (GTK_WIDGET (lbl_method_info));
+                              gtk_widget_show (GTK_WIDGET (btn_edit_method));
                          }
 
                          if (index == 2)
@@ -1188,9 +1249,7 @@ init_b_policy (json_t *state)
                              "adding_authentication",
                              arguments,
                              &action_cb,
-                             NULL);
-
-     
+                             NULL);  
 }
 
 
diff --git a/src/anastasis/anastasis-gtk_helper.c 
b/src/anastasis/anastasis-gtk_helper.c
index 6e24aa2..65610d5 100644
--- a/src/anastasis/anastasis-gtk_helper.c
+++ b/src/anastasis/anastasis-gtk_helper.c
@@ -32,6 +32,49 @@
 #include <jansson.h>
 
 
+/**
+ * Get num of cols a widget takes in a grid.
+ * 
+ * @param grid Grid the widget belongs to
+ * @param widget Widget to look up
+ * @return int
+ */
+int
+get_widget_width (GtkGrid *grid,
+                      GtkWidget *widget)
+{
+     //get number of policies/policy columns
+     GValue val_policies_col = G_VALUE_INIT;
+     g_value_init (&val_policies_col, G_TYPE_INT);
+     gtk_container_child_get_property (GTK_CONTAINER (grid), 
+                                       GTK_WIDGET (widget), 
+                                       "width", 
+                                       &val_policies_col);
+     return g_value_get_int (&val_policies_col);
+}
+
+
+/**
+ * Set policy check buttons according to policies in state.
+ * 
+ * @param state the state to operate on
+ */
+void
+set_policy_check_buttons (json_t *state)
+{
+     GtkGrid *grid = GTK_GRID (GCG_get_main_window_object 
("anastasis_gtk_b_policy_grid"));
+
+     //get number of policies/policy columns
+     GtkFrame *frm_policy_title = GTK_FRAME (gtk_grid_get_child_at (grid, 1, 
0));
+     int cols = get_widget_width (grid, GTK_WIDGET (frm_policy_title));
+
+     for (unsigned int i = 0; i < cols; i++)
+     {
+          /** FIXME: set check buttons here */
+     }
+}
+
+
 /**
  * Function to ckeck if required attributes are set.
  * 
@@ -208,6 +251,7 @@ action_cb (void *cls,
                                         "anastasis_gtk_b_policy_frame")));
                 gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
                                                 
"anastasis_gtk_b_policies_image")));
+                set_policy_check_buttons (redux_state);
             }
         }
         /** FIXME: Don't use this like this; now used to check if json state 
is build correctly */
diff --git a/src/include/anastasis-gtk_helper.h 
b/src/include/anastasis-gtk_helper.h
index 7bcd44e..b5694bd 100644
--- a/src/include/anastasis-gtk_helper.h
+++ b/src/include/anastasis-gtk_helper.h
@@ -149,6 +149,27 @@ void
 init_b_auth_methods (json_t *state);
 
 
+/**
+ * Get num of cols a widget takes in a grid.
+ * 
+ * @param grid Grid the widget belongs to
+ * @param widget Widget to look up
+ * @return int
+ */
+int 
+get_widget_width (GtkGrid *grid,
+                  GtkWidget *widget);
+
+
+/**
+ * Set policy check buttons according to policies in state.
+ * 
+ * @param state the state to operate on
+ */
+void
+set_policy_check_buttons (json_t *state);
+
+
 /**
  * Initialize the policies in backup mode.
  * 

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