gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r33579 - gnunet-gtk/src/namestore


From: gnunet
Subject: [GNUnet-SVN] r33579 - gnunet-gtk/src/namestore
Date: Sat, 7 Jun 2014 15:04:46 +0200

Author: grothoff
Date: 2014-06-07 15:04:46 +0200 (Sat, 07 Jun 2014)
New Revision: 33579

Modified:
   gnunet-gtk/src/namestore/plugin_gtk_namestore_tlsa.c
Log:
evaluate toggle button logic

Modified: gnunet-gtk/src/namestore/plugin_gtk_namestore_tlsa.c
===================================================================
--- gnunet-gtk/src/namestore/plugin_gtk_namestore_tlsa.c        2014-06-07 
11:36:06 UTC (rev 33578)
+++ gnunet-gtk/src/namestore/plugin_gtk_namestore_tlsa.c        2014-06-07 
13:04:46 UTC (rev 33579)
@@ -73,6 +73,67 @@
 
 
 /**
+ * Return the selected button from a list of radio buttons.
+ *
+ * @param builder builder to resolve button names
+ * @param button_names NULL-terminated array of buttons
+ * @return index of the selected button, -1 for none
+ */
+static int
+get_selected_radio_value (GtkBuilder *builder,
+                          const char *const*button_names)
+{
+  GtkToggleButton *b;
+  int i;
+
+  for (i=0; NULL != button_names[i]; i++)
+  {
+    b = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
+                                                   button_names[i]));
+    if (gtk_toggle_button_get_active (b))
+      return i;
+  }
+  return -1;
+}
+
+
+/**
+ * NULL-terminated array with the names of the "usage" buttons,
+ * in order to match the respective value in TLSA.
+ */
+static const char *const usage_buttons[] = {
+  "edit_dialog_tlsa_usage_ca_radiobutton",
+  "edit_dialog_tlsa_usage_service_cert_radiobutton",
+  "edit_dialog_tlsa_usage_trust_anchor_radiobutton",
+  "edit_dialog_tlsa_usage_domain_issued_cert_radiobutton",
+  NULL
+};
+
+
+/**
+ * NULL-terminated array with the names of the "selector" buttons,
+ * in order to match the respective value in TLSA.
+ */
+static const char *const selector_buttons[] = {
+  "edit_dialog_tlsa_selector_full_cert_radiobutton",
+  "edit_dialog_tlsa_selector_subject_public_key_radiobutton",
+  NULL
+};
+
+
+/**
+ * NULL-terminated array with the names of the "matching type" buttons,
+ * in order to match the respective value in TLSA.
+ */
+static const char *const matching_type_buttons[] = {
+  "edit_dialog_tlsa_matching_type_full_contents_radiobutton",
+  "edit_dialog_tlsa_matching_type_sha256_radiobutton",
+  "edit_dialog_tlsa_matching_type_sha512_radiobutton",
+  NULL
+};
+
+
+/**
  * Function that will be called to initialize the builder's
  * widgets from the existing record (if there is one).
  * The `n_value` is the existing value of the record as a string.
@@ -274,9 +335,19 @@
                       &iter,
                       1, &service,
                       -1);
-  usage = 42; // FIXME: get from GUI!
-  selector = 42; // FIXME: get from GUI!
-  matching_type = 42; // FIXME: get from GUI!
+  usage = get_selected_radio_value (builder,
+                                    usage_buttons);
+  selector = get_selected_radio_value (builder,
+                                       selector_buttons);
+  matching_type = get_selected_radio_value (builder,
+                                            matching_type_buttons);
+  if ( (-1 == usage) ||
+       (-1 == selector) ||
+       (-1 == matching_type) )
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
 
   tb = gtk_text_view_get_buffer (GTK_TEXT_VIEW
                                  (gtk_builder_get_object (builder,
@@ -363,7 +434,8 @@
       /* not hex */
       return GNUNET_SYSERR;
     }
-    matching_type = 42; // FIXME: get from GUI!
+    matching_type = get_selected_radio_value (builder,
+                                              matching_type_buttons);
 
     switch (matching_type)
     {




reply via email to

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