[network-manager-openvpn/th/ui-init-cleanup: 6/11] properties: refactor initialization of spinbutton for "keysize"



commit 802139c2c5bb433de4685293877974b5066f0f86
Author: Thomas Haller <thaller redhat com>
Date:   Mon Aug 15 14:12:23 2016 +0200

    properties: refactor initialization of spinbutton for "keysize"

 properties/auth-helpers.c |   24 ++----------------------
 1 files changed, 2 insertions(+), 22 deletions(-)
---
diff --git a/properties/auth-helpers.c b/properties/auth-helpers.c
index c4f8cfb..4f32fa3 100644
--- a/properties/auth-helpers.c
+++ b/properties/auth-helpers.c
@@ -1657,31 +1657,11 @@ advanced_dialog_new (GHashTable *hash, const char *contype)
        value = g_hash_table_lookup (hash, NM_OPENVPN_KEY_CIPHER);
        populate_cipher_combo (GTK_COMBO_BOX (widget), value);
 
-       widget = GTK_WIDGET (gtk_builder_get_object (builder, "keysize_checkbutton"));
-       g_assert (widget);
-       spin = GTK_WIDGET (gtk_builder_get_object (builder, "keysize_spinbutton"));
-       g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (checkbox_toggled_update_widget_cb), spin);
 
        value = g_hash_table_lookup (hash, NM_OPENVPN_KEY_KEYSIZE);
-       if (value && strlen (value)) {
-               long int tmp;
-
-               errno = 0;
-               tmp = strtol (value, NULL, 10);
-               if (errno == 0 && tmp > 0 && tmp < 65536) {
-                       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+       _builder_init_optional_spinbutton (builder, "keysize_checkbutton", "keysize_spinbutton", !!value,
+                                          _nm_utils_ascii_str_to_int64 (value, 10, 1, 65535, 128));
 
-                       widget = GTK_WIDGET (gtk_builder_get_object (builder, "keysize_spinbutton"));
-                       gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), (gdouble) tmp);
-                       gtk_widget_set_sensitive (widget, TRUE);
-               }
-       } else {
-               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
-
-               widget = GTK_WIDGET (gtk_builder_get_object (builder, "keysize_spinbutton"));
-               gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), 128.0);
-               gtk_widget_set_sensitive (widget, FALSE);
-       }
 
        widget = GTK_WIDGET (gtk_builder_get_object (builder, "hmacauth_combo"));
        value = g_hash_table_lookup (hash, NM_OPENVPN_KEY_AUTH);


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