[gnome-control-center/network-widget-references: 13/13] network: Store widgets inside objects
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/network-widget-references: 13/13] network: Store widgets inside objects
- Date: Tue, 15 Oct 2019 03:41:14 +0000 (UTC)
commit ef602094fd2d8904d9fd8181812317cd7f13e7ca
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Oct 15 12:25:48 2019 +1300
network: Store widgets inside objects
This is a step towards replacing GtkBuilder with GtkTemplate
panels/network/wireless-security/eap-method-fast.c | 199 ++++++++-----------
panels/network/wireless-security/eap-method-leap.c | 85 ++++----
panels/network/wireless-security/eap-method-peap.c | 191 ++++++++----------
.../network/wireless-security/eap-method-simple.c | 84 ++++----
panels/network/wireless-security/eap-method-tls.c | 219 +++++++++------------
panels/network/wireless-security/eap-method-ttls.c | 185 +++++++----------
panels/network/wireless-security/ws-dynamic-wep.c | 33 +++-
panels/network/wireless-security/ws-leap.c | 90 ++++-----
panels/network/wireless-security/ws-wep-key.c | 146 ++++++--------
panels/network/wireless-security/ws-wpa-eap.c | 33 +++-
panels/network/wireless-security/ws-wpa-psk.c | 86 ++++----
11 files changed, 576 insertions(+), 775 deletions(-)
---
diff --git a/panels/network/wireless-security/eap-method-fast.c
b/panels/network/wireless-security/eap-method-fast.c
index 52715ffa6..aedfa3732 100644
--- a/panels/network/wireless-security/eap-method-fast.c
+++ b/panels/network/wireless-security/eap-method-fast.c
@@ -36,6 +36,16 @@
struct _EAPMethodFAST {
EAPMethod parent;
+ GtkEntry *anon_identity_entry;
+ GtkLabel *anon_identity_label;
+ GtkComboBox *inner_auth_combo;
+ GtkLabel *inner_auth_label;
+ GtkBox *inner_auth_box;
+ GtkFileChooserButton *pac_file_button;
+ GtkLabel *pac_file_label;
+ GtkCheckButton *pac_provision_check;
+ GtkComboBox *pac_provision_combo;
+
GtkSizeGroup *size_group;
WirelessSecurity *sec_parent;
gboolean is_editor;
@@ -53,7 +63,7 @@ destroy (EAPMethod *parent)
static gboolean
validate (EAPMethod *parent, GError **error)
{
- GtkWidget *widget;
+ EAPMethodFAST *self = (EAPMethodFAST *) parent;
GtkTreeModel *model;
GtkTreeIter iter;
g_autoptr(EAPMethod) eap = NULL;
@@ -61,23 +71,17 @@ validate (EAPMethod *parent, GError **error)
gboolean provisioning;
gboolean valid = TRUE;
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_provision_check"));
- g_assert (widget);
- provisioning = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_file_button"));
- g_assert (widget);
- file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
+ provisioning = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->pac_provision_check));
+ file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (self->pac_file_button));
if (!provisioning && !file) {
- widget_set_error (widget);
+ widget_set_error (GTK_WIDGET (self->pac_file_button));
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing EAP-FAST PAC file"));
valid = FALSE;
} else
- widget_unset_error (widget);
+ widget_unset_error (GTK_WIDGET (self->pac_file_button));
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- g_assert (widget);
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
+ model = gtk_combo_box_get_model (self->inner_auth_combo);
+ gtk_combo_box_get_active_iter (self->inner_auth_combo, &iter);
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap);
valid = eap_method_validate (eap, valid ? error : NULL) && valid;
@@ -88,7 +92,6 @@ static void
add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
{
EAPMethodFAST *method = (EAPMethodFAST *) parent;
- GtkWidget *widget;
GtkTreeModel *model;
GtkTreeIter iter;
g_autoptr(EAPMethod) eap = NULL;
@@ -97,27 +100,13 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
g_object_unref (method->size_group);
method->size_group = g_object_ref (group);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_file_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_provision_check"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
+ gtk_size_group_add_widget (group, GTK_WIDGET (method->anon_identity_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (method->pac_file_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (method->pac_provision_check));
+ gtk_size_group_add_widget (group, GTK_WIDGET (method->inner_auth_label));
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- g_assert (widget);
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
+ model = gtk_combo_box_get_model (method->inner_auth_combo);
+ gtk_combo_box_get_active_iter (method->inner_auth_combo, &iter);
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap);
eap_method_add_to_size_group (eap, group);
@@ -126,8 +115,8 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
static void
fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFlags flags)
{
+ EAPMethodFAST *self = (EAPMethodFAST *) parent;
NMSetting8021x *s_8021x;
- GtkWidget *widget;
const char *text;
char *filename;
g_autoptr(EAPMethod) eap = NULL;
@@ -141,25 +130,19 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
nm_setting_802_1x_add_eap_method (s_8021x, "fast");
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_entry"));
- g_assert (widget);
- text = gtk_entry_get_text (GTK_ENTRY (widget));
+ text = gtk_entry_get_text (self->anon_identity_entry);
if (text && strlen (text))
g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, text, NULL);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_file_button"));
- g_assert (widget);
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (self->pac_file_button));
g_object_set (s_8021x, NM_SETTING_802_1X_PAC_FILE, filename, NULL);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_provision_check"));
- enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+ enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->pac_provision_check));
if (!enabled)
g_object_set (G_OBJECT (s_8021x), NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, "0", NULL);
else {
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_provision_combo"));
- pac_provisioning = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
+ pac_provisioning = gtk_combo_box_get_active (self->pac_provision_combo);
switch (pac_provisioning) {
case 0: /* Anonymous */
@@ -177,9 +160,8 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
}
}
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
+ model = gtk_combo_box_get_model (self->inner_auth_combo);
+ gtk_combo_box_get_active_iter (self->inner_auth_combo, &iter);
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap);
@@ -189,26 +171,20 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
static void
inner_auth_combo_changed_cb (EAPMethodFAST *self)
{
- EAPMethod *parent = (EAPMethod *) self;
- GtkWidget *combo, *vbox;
g_autoptr(EAPMethod) eap = NULL;
GList *elt, *children;
GtkTreeModel *model;
GtkTreeIter iter;
GtkWidget *eap_widget;
- combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- vbox = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_box"));
- g_assert (vbox);
-
/* Remove any previous wireless security widgets */
- children = gtk_container_get_children (GTK_CONTAINER (vbox));
+ children = gtk_container_get_children (GTK_CONTAINER (self->inner_auth_box));
for (elt = children; elt; elt = g_list_next (elt))
- gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (elt->data));
+ gtk_container_remove (GTK_CONTAINER (self->inner_auth_box), GTK_WIDGET (elt->data));
g_list_free (children);
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
+ model = gtk_combo_box_get_model (self->inner_auth_combo);
+ gtk_combo_box_get_active_iter (self->inner_auth_combo, &iter);
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap);
@@ -218,19 +194,17 @@ inner_auth_combo_changed_cb (EAPMethodFAST *self)
if (self->size_group)
eap_method_add_to_size_group (eap, self->size_group);
- gtk_container_add (GTK_CONTAINER (vbox), eap_widget);
+ gtk_container_add (GTK_CONTAINER (self->inner_auth_box), eap_widget);
wireless_security_notify_changed (self->sec_parent);
}
-static GtkWidget *
+static void
inner_auth_combo_init (EAPMethodFAST *method,
NMConnection *connection,
NMSetting8021x *s_8021x,
gboolean secrets_only)
{
- EAPMethod *parent = (EAPMethod *) method;
- GtkWidget *combo;
g_autoptr(GtkListStore) auth_model = NULL;
GtkTreeIter iter;
g_autoptr(EAPMethodSimple) em_gtc = NULL;
@@ -282,40 +256,29 @@ inner_auth_combo_init (EAPMethodFAST *method,
if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2"))
active = 1;
- combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- g_assert (combo);
-
- gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model));
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active);
+ gtk_combo_box_set_model (method->inner_auth_combo, GTK_TREE_MODEL (auth_model));
+ gtk_combo_box_set_active (method->inner_auth_combo, active);
- g_signal_connect_swapped (combo, "changed", G_CALLBACK (inner_auth_combo_changed_cb), method);
- return combo;
+ g_signal_connect_swapped (method->inner_auth_combo, "changed", G_CALLBACK
(inner_auth_combo_changed_cb), method);
}
static void
update_secrets (EAPMethod *parent, NMConnection *connection)
{
+ EAPMethodFAST *self = (EAPMethodFAST *) parent;
eap_method_phase2_update_secrets_helper (parent,
connection,
- GTK_COMBO_BOX (gtk_builder_get_object (parent->builder,
"inner_auth_combo")),
+ self->inner_auth_combo,
I_METHOD_COLUMN);
}
static void
pac_toggled_cb (EAPMethodFAST *self)
{
- GtkWidget *widget;
- EAPMethod *parent = (EAPMethod *) self;
gboolean enabled = FALSE;
- GtkWidget *provision_combo;
-
- provision_combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_provision_combo"));
- g_return_if_fail (provision_combo);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_provision_check"));
- enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-
- gtk_widget_set_sensitive (provision_combo, enabled);
+ enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->pac_provision_check));
+ gtk_widget_set_sensitive (GTK_WIDGET (self->pac_provision_combo), enabled);
wireless_security_notify_changed (self->sec_parent);
}
@@ -334,7 +297,6 @@ eap_method_fast_new (WirelessSecurity *ws_parent,
{
EAPMethod *parent;
EAPMethodFAST *method;
- GtkWidget *widget;
GtkFileFilter *filter;
NMSetting8021x *s_8021x = NULL;
const char *filename;
@@ -358,13 +320,20 @@ eap_method_fast_new (WirelessSecurity *ws_parent,
method->sec_parent = ws_parent;
method->is_editor = is_editor;
+ method->anon_identity_entry = GTK_ENTRY (gtk_builder_get_object (parent->builder,
"anon_identity_entry"));
+ method->anon_identity_label = GTK_LABEL (gtk_builder_get_object (parent->builder,
"anon_identity_label"));
+ method->inner_auth_combo = GTK_COMBO_BOX (gtk_builder_get_object (parent->builder,
"inner_auth_combo"));
+ method->inner_auth_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "inner_auth_label"));
+ method->inner_auth_box = GTK_BOX (gtk_builder_get_object (parent->builder, "inner_auth_box"));
+ method->pac_file_button = GTK_FILE_CHOOSER_BUTTON (gtk_builder_get_object (parent->builder,
"pac_file_button"));
+ method->pac_file_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "pac_file_label"));
+ method->pac_provision_check = GTK_CHECK_BUTTON (gtk_builder_get_object (parent->builder,
"pac_provision_check"));
+ method->pac_provision_combo = GTK_COMBO_BOX (gtk_builder_get_object (parent->builder,
"pac_provision_combo"));
+
if (connection)
s_8021x = nm_connection_get_setting_802_1x (connection);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_provision_combo"));
- g_assert (widget);
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+ gtk_combo_box_set_active (method->pac_provision_combo, 0);
if (s_8021x) {
const char *fast_prov;
@@ -373,67 +342,55 @@ eap_method_fast_new (WirelessSecurity *ws_parent,
if (!strcmp (fast_prov, "0"))
provisioning_enabled = FALSE;
else if (!strcmp (fast_prov, "1"))
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+ gtk_combo_box_set_active (method->pac_provision_combo, 0);
else if (!strcmp (fast_prov, "2"))
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1);
+ gtk_combo_box_set_active (method->pac_provision_combo, 1);
else if (!strcmp (fast_prov, "3"))
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2);
+ gtk_combo_box_set_active (method->pac_provision_combo, 2);
}
}
- gtk_widget_set_sensitive (widget, provisioning_enabled);
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), method);
+ gtk_widget_set_sensitive (GTK_WIDGET (method->pac_provision_combo), provisioning_enabled);
+ g_signal_connect_swapped (method->pac_provision_combo, "changed", G_CALLBACK (changed_cb), method);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_provision_check"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), provisioning_enabled);
- g_signal_connect_swapped (widget, "toggled", G_CALLBACK (pac_toggled_cb), method);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (method->pac_provision_check), provisioning_enabled);
+ g_signal_connect_swapped (method->pac_provision_check, "toggled", G_CALLBACK (pac_toggled_cb),
method);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_entry"));
if (s_8021x && nm_setting_802_1x_get_anonymous_identity (s_8021x))
- gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_anonymous_identity (s_8021x));
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), method);
+ gtk_entry_set_text (method->anon_identity_entry, nm_setting_802_1x_get_anonymous_identity
(s_8021x));
+ g_signal_connect_swapped (method->anon_identity_entry, "changed", G_CALLBACK (changed_cb), method);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_file_button"));
- g_assert (widget);
- gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (widget), TRUE);
- gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON (widget),
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (method->pac_file_button), TRUE);
+ gtk_file_chooser_button_set_title (method->pac_file_button,
_("Choose a PAC file"));
- g_signal_connect_swapped (widget, "selection-changed", G_CALLBACK (changed_cb), method);
+ g_signal_connect_swapped (method->pac_file_button, "selection-changed", G_CALLBACK (changed_cb),
method);
filter = gtk_file_filter_new ();
gtk_file_filter_add_pattern (filter, "*.pac");
gtk_file_filter_set_name (filter, _("PAC files (*.pac)"));
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (widget), filter);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (method->pac_file_button), filter);
filter = gtk_file_filter_new ();
gtk_file_filter_add_pattern (filter, "*");
gtk_file_filter_set_name (filter, _("All files"));
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (widget), filter);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (method->pac_file_button), filter);
if (connection && s_8021x) {
filename = nm_setting_802_1x_get_pac_file (s_8021x);
if (filename)
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), filename);
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (method->pac_file_button), filename);
}
- widget = inner_auth_combo_init (method, connection, s_8021x, secrets_only);
+ inner_auth_combo_init (method, connection, s_8021x, secrets_only);
inner_auth_combo_changed_cb (method);
if (secrets_only) {
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_entry"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_provision_check"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_provision_combo"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_file_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "pac_file_button"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- gtk_widget_hide (widget);
+ gtk_widget_hide (GTK_WIDGET (method->anon_identity_label));
+ gtk_widget_hide (GTK_WIDGET (method->anon_identity_entry));
+ gtk_widget_hide (GTK_WIDGET (method->pac_provision_check));
+ gtk_widget_hide (GTK_WIDGET (method->pac_provision_combo));
+ gtk_widget_hide (GTK_WIDGET (method->pac_file_label));
+ gtk_widget_hide (GTK_WIDGET (method->pac_file_button));
+ gtk_widget_hide (GTK_WIDGET (method->inner_auth_label));
+ gtk_widget_hide (GTK_WIDGET (method->inner_auth_combo));
}
return method;
diff --git a/panels/network/wireless-security/eap-method-leap.c
b/panels/network/wireless-security/eap-method-leap.c
index e449ae7de..b02244ec5 100644
--- a/panels/network/wireless-security/eap-method-leap.c
+++ b/panels/network/wireless-security/eap-method-leap.c
@@ -34,24 +34,23 @@
struct _EAPMethodLEAP {
EAPMethod parent;
+ GtkNotebook *notebook;
+ GtkEntry *password_entry;
+ GtkLabel *password_label;
+ GtkCheckButton *show_password_check;
+ GtkEntry *username_entry;
+ GtkLabel *username_label;
+
WirelessSecurity *ws_parent;
gboolean editing_connection;
-
- GtkEntry *username_entry;
- GtkEntry *password_entry;
- GtkToggleButton *show_password;
};
static void
show_toggled_cb (EAPMethodLEAP *method)
{
- EAPMethod *parent = (EAPMethod *) method;
- GtkWidget *widget;
gboolean visible;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_password_check"));
- visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+ visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (method->show_password_check));
gtk_entry_set_visibility (method->password_entry, visible);
}
@@ -86,15 +85,9 @@ validate (EAPMethod *parent, GError **error)
static void
add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
{
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "username_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "password_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
+ EAPMethodLEAP *self = (EAPMethodLEAP *) parent;
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->username_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->password_label));
}
static void
@@ -103,7 +96,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
EAPMethodLEAP *method = (EAPMethodLEAP *) parent;
NMSetting8021x *s_8021x;
NMSettingSecretFlags secret_flags;
- GtkWidget *passwd_entry;
s_8021x = nm_connection_get_setting_802_1x (connection);
g_assert (s_8021x);
@@ -113,25 +105,23 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, gtk_entry_get_text (method->username_entry), NULL);
g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD, gtk_entry_get_text (method->password_entry), NULL);
- passwd_entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "password_entry"));
- g_assert (passwd_entry);
-
/* Save 802.1X password flags to the connection */
- secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
+ secret_flags = nma_utils_menu_to_secret_flags (GTK_WIDGET (method->password_entry));
nm_setting_set_secret_flags (NM_SETTING (s_8021x), parent->password_flags_name,
secret_flags, NULL);
/* Update secret flags and popup when editing the connection */
if (method->editing_connection)
- nma_utils_update_password_storage (passwd_entry, secret_flags,
+ nma_utils_update_password_storage (GTK_WIDGET (method->password_entry), secret_flags,
NM_SETTING (s_8021x), parent->password_flags_name);
}
static void
update_secrets (EAPMethod *parent, NMConnection *connection)
{
+ EAPMethodLEAP *self = (EAPMethodLEAP *) parent;
helper_fill_secret_entry (connection,
- GTK_ENTRY (gtk_builder_get_object (parent->builder, "password_entry")),
+ self->password_entry,
NM_TYPE_SETTING_802_1X,
(HelperSecretFunc) nm_setting_802_1x_get_password);
}
@@ -151,7 +141,7 @@ set_userpass_ui (EAPMethodLEAP *method)
else
gtk_entry_set_text (method->password_entry, "");
- gtk_toggle_button_set_active (method->show_password, wireless_security_get_show_password
(method->ws_parent));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (method->show_password_check),
wireless_security_get_show_password (method->ws_parent));
}
static void
@@ -167,22 +157,18 @@ widgets_unrealized (EAPMethodLEAP *method)
gtk_entry_get_text (method->username_entry),
gtk_entry_get_text (method->password_entry),
(gboolean) -1,
- gtk_toggle_button_get_active (method->show_password));
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(method->show_password_check)));
}
static void
destroy (EAPMethod *parent)
{
EAPMethodLEAP *method = (EAPMethodLEAP *) parent;
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "notebook"));
- g_assert (widget);
- g_signal_handlers_disconnect_by_data (widget, method);
+ g_signal_handlers_disconnect_by_data (method->notebook, method);
g_signal_handlers_disconnect_by_data (method->username_entry, method->ws_parent);
g_signal_handlers_disconnect_by_data (method->password_entry, method->ws_parent);
- g_signal_handlers_disconnect_by_data (method->show_password, method);
+ g_signal_handlers_disconnect_by_data (method->show_password_check, method);
}
static void
@@ -198,7 +184,6 @@ eap_method_leap_new (WirelessSecurity *ws_parent,
{
EAPMethodLEAP *method;
EAPMethod *parent;
- GtkWidget *widget;
NMSetting8021x *s_8021x = NULL;
parent = eap_method_init (sizeof (EAPMethodLEAP),
@@ -219,34 +204,30 @@ eap_method_leap_new (WirelessSecurity *ws_parent,
method->editing_connection = secrets_only ? FALSE : TRUE;
method->ws_parent = ws_parent;
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "notebook"));
- g_assert (widget);
- g_signal_connect_swapped (widget, "realize", G_CALLBACK (widgets_realized), method);
- g_signal_connect_swapped (widget, "unrealize", G_CALLBACK (widgets_unrealized), method);
+ method->notebook = GTK_NOTEBOOK (gtk_builder_get_object (parent->builder, "notebook"));
+ method->password_entry = GTK_ENTRY (gtk_builder_get_object (parent->builder, "password_entry"));
+ method->password_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "password_label"));
+ method->show_password_check = GTK_CHECK_BUTTON (gtk_builder_get_object (parent->builder,
"show_password_check"));
+ method->username_entry = GTK_ENTRY (gtk_builder_get_object (parent->builder, "username_entry"));
+ method->username_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "username_label"));
+
+ g_signal_connect_swapped (method->notebook, "realize", G_CALLBACK (widgets_realized), method);
+ g_signal_connect_swapped (method->notebook, "unrealize", G_CALLBACK (widgets_unrealized), method);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "username_entry"));
- g_assert (widget);
- method->username_entry = GTK_ENTRY (widget);
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), method);
+ g_signal_connect_swapped (method->username_entry, "changed", G_CALLBACK (changed_cb), method);
if (secrets_only)
- gtk_widget_set_sensitive (widget, FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (method->username_entry), FALSE);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "password_entry"));
- g_assert (widget);
- method->password_entry = GTK_ENTRY (widget);
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), method);
+ g_signal_connect_swapped (method->password_entry, "changed", G_CALLBACK (changed_cb), method);
/* Create password-storage popup menu for password entry under entry's secondary icon */
if (connection)
s_8021x = nm_connection_get_setting_802_1x (connection);
- nma_utils_setup_password_storage (widget, 0, (NMSetting *) s_8021x, parent->password_flags_name,
+ nma_utils_setup_password_storage (GTK_WIDGET (method->password_entry), 0, (NMSetting *) s_8021x,
parent->password_flags_name,
FALSE, secrets_only);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_password_check"));
- g_assert (widget);
- method->show_password = GTK_TOGGLE_BUTTON (widget);
- g_signal_connect_swapped (widget, "toggled", G_CALLBACK (show_toggled_cb), method);
+ g_signal_connect_swapped (method->show_password_check, "toggled", G_CALLBACK (show_toggled_cb),
method);
/* Initialize the UI fields with the security settings from method->ws_parent.
* This will be done again when the widget gets realized. It must be done here as well,
diff --git a/panels/network/wireless-security/eap-method-peap.c
b/panels/network/wireless-security/eap-method-peap.c
index ae6409566..2c7f9de31 100644
--- a/panels/network/wireless-security/eap-method-peap.c
+++ b/panels/network/wireless-security/eap-method-peap.c
@@ -35,6 +35,17 @@
struct _EAPMethodPEAP {
EAPMethod parent;
+ GtkEntry *anon_identity_entry;
+ GtkLabel *anon_identity_label;
+ GtkFileChooserButton *ca_cert_button;
+ GtkLabel *ca_cert_label;
+ GtkCheckButton *ca_cert_not_required_check;
+ GtkBox *inner_auth_box;
+ GtkComboBox *inner_auth_combo;
+ GtkLabel *inner_auth_label;
+ GtkComboBox *version_combo;
+ GtkLabel *version_label;
+
GtkSizeGroup *size_group;
WirelessSecurity *sec_parent;
gboolean is_editor;
@@ -52,29 +63,26 @@ destroy (EAPMethod *parent)
static gboolean
validate (EAPMethod *parent, GError **error)
{
- GtkWidget *widget;
+ EAPMethodPEAP *self = (EAPMethodPEAP *) parent;
GtkTreeModel *model;
GtkTreeIter iter;
g_autoptr(EAPMethod) eap = NULL;
gboolean valid = FALSE;
g_autoptr(GError) local_error = NULL;
- if (!eap_method_validate_filepicker (GTK_FILE_CHOOSER (gtk_builder_get_object (parent->builder,
"ca_cert_button")),
+ if (!eap_method_validate_filepicker (GTK_FILE_CHOOSER (self->ca_cert_button),
TYPE_CA_CERT, NULL, NULL, &local_error)) {
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-PEAP CA certificate: %s"),
local_error->message);
return FALSE;
}
- if (eap_method_ca_cert_required (GTK_TOGGLE_BUTTON (gtk_builder_get_object (parent->builder,
"ca_cert_not_required_check")),
- GTK_FILE_CHOOSER (gtk_builder_get_object (parent->builder,
"ca_cert_button")))) {
+ if (eap_method_ca_cert_required (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check),
+ GTK_FILE_CHOOSER (self->ca_cert_button))) {
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-PEAP CA certificate:
no certificate specified"));
return FALSE;
}
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- g_assert (widget);
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
+ model = gtk_combo_box_get_model (self->inner_auth_combo);
+ gtk_combo_box_get_active_iter (self->inner_auth_combo, &iter);
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap);
valid = eap_method_validate (eap, error);
@@ -84,10 +92,8 @@ validate (EAPMethod *parent, GError **error)
static void
ca_cert_not_required_toggled (EAPMethodPEAP *self)
{
- EAPMethod *parent = (EAPMethod *) self;
-
- eap_method_ca_cert_not_required_toggled (GTK_TOGGLE_BUTTON (gtk_builder_get_object (parent->builder,
"ca_cert_not_required_check")),
- GTK_FILE_CHOOSER (gtk_builder_get_object (parent->builder,
"ca_cert_button")));
+ eap_method_ca_cert_not_required_toggled (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check),
+ GTK_FILE_CHOOSER (self->ca_cert_button));
wireless_security_notify_changed (self->sec_parent);
}
@@ -95,7 +101,6 @@ static void
add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
{
EAPMethodPEAP *method = (EAPMethodPEAP *) parent;
- GtkWidget *widget;
GtkTreeModel *model;
GtkTreeIter iter;
g_autoptr(EAPMethod) eap = NULL;
@@ -104,31 +109,14 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
g_object_unref (method->size_group);
method->size_group = g_object_ref (group);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_not_required_check"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "version_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
+ gtk_size_group_add_widget (group, GTK_WIDGET (method->ca_cert_not_required_check));
+ gtk_size_group_add_widget (group, GTK_WIDGET (method->anon_identity_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (method->ca_cert_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (method->version_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (method->inner_auth_label));
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- g_assert (widget);
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
+ model = gtk_combo_box_get_model (method->inner_auth_combo);
+ gtk_combo_box_get_active_iter (method->inner_auth_combo, &iter);
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap);
eap_method_add_to_size_group (eap, group);
@@ -137,9 +125,9 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
static void
fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFlags flags)
{
+ EAPMethodPEAP *self = (EAPMethodPEAP *) parent;
NMSetting8021x *s_8021x;
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
- GtkWidget *widget;
const char *text;
g_autofree gchar *filename = NULL;
g_autoptr(EAPMethod) eap = NULL;
@@ -154,23 +142,18 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
nm_setting_802_1x_add_eap_method (s_8021x, "peap");
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_entry"));
- g_assert (widget);
- text = gtk_entry_get_text (GTK_ENTRY (widget));
+ text = gtk_entry_get_text (self->anon_identity_entry);
if (text && strlen (text))
g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, text, NULL);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_button"));
- g_assert (widget);
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (self->ca_cert_button));
if (!nm_setting_802_1x_set_ca_cert (s_8021x, filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format,
&error)) {
g_warning ("Couldn't read CA certificate '%s': %s", filename, error ? error->message :
"(unknown)");
ca_cert_error = TRUE;
}
eap_method_ca_cert_ignore_set (parent, connection, filename, ca_cert_error);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "version_combo"));
- peapver_active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
+ peapver_active = gtk_combo_box_get_active (self->version_combo);
switch (peapver_active) {
case 1: /* PEAP v0 */
g_object_set (G_OBJECT (s_8021x), NM_SETTING_802_1X_PHASE1_PEAPVER, "0", NULL);
@@ -183,36 +166,30 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
break;
}
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
+ model = gtk_combo_box_get_model (self->inner_auth_combo);
+ gtk_combo_box_get_active_iter (self->inner_auth_combo, &iter);
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap);
eap_method_fill_connection (eap, connection, flags);
}
+
static void
inner_auth_combo_changed_cb (EAPMethodPEAP *self)
{
- EAPMethod *parent = (EAPMethod *) self;
- GtkWidget *combo, *box;
g_autoptr(EAPMethod) eap = NULL;
GList *elt, *children;
GtkTreeModel *model;
GtkTreeIter iter;
GtkWidget *eap_widget;
- box = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_box"));
- g_assert (box);
-
/* Remove any previous wireless security widgets */
- children = gtk_container_get_children (GTK_CONTAINER (box));
+ children = gtk_container_get_children (GTK_CONTAINER (self->inner_auth_box));
for (elt = children; elt; elt = g_list_next (elt))
- gtk_container_remove (GTK_CONTAINER (box), GTK_WIDGET (elt->data));
+ gtk_container_remove (GTK_CONTAINER (self->inner_auth_box), GTK_WIDGET (elt->data));
- combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
+ model = gtk_combo_box_get_model (self->inner_auth_combo);
+ gtk_combo_box_get_active_iter (self->inner_auth_combo, &iter);
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap);
@@ -222,19 +199,17 @@ inner_auth_combo_changed_cb (EAPMethodPEAP *self)
if (self->size_group)
eap_method_add_to_size_group (eap, self->size_group);
- gtk_container_add (GTK_CONTAINER (box), eap_widget);
+ gtk_container_add (GTK_CONTAINER (self->inner_auth_box), eap_widget);
wireless_security_notify_changed (self->sec_parent);
}
-static GtkWidget *
+static void
inner_auth_combo_init (EAPMethodPEAP *method,
NMConnection *connection,
NMSetting8021x *s_8021x,
gboolean secrets_only)
{
- EAPMethod *parent = (EAPMethod *) method;
- GtkWidget *combo;
g_autoptr(GtkListStore) auth_model = NULL;
GtkTreeIter iter;
g_autoptr(EAPMethodSimple) em_mschap_v2 = NULL;
@@ -301,22 +276,19 @@ inner_auth_combo_init (EAPMethodPEAP *method,
if (phase2_auth && !strcasecmp (phase2_auth, "gtc"))
active = 2;
- combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- g_assert (combo);
-
- gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model));
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active);
+ gtk_combo_box_set_model (method->inner_auth_combo, GTK_TREE_MODEL (auth_model));
+ gtk_combo_box_set_active (method->inner_auth_combo, active);
- g_signal_connect_swapped (combo, "changed", G_CALLBACK (inner_auth_combo_changed_cb), method);
- return combo;
+ g_signal_connect_swapped (method->inner_auth_combo, "changed", G_CALLBACK
(inner_auth_combo_changed_cb), method);
}
static void
update_secrets (EAPMethod *parent, NMConnection *connection)
{
+ EAPMethodPEAP *self = (EAPMethodPEAP *) parent;
eap_method_phase2_update_secrets_helper (parent,
connection,
- GTK_COMBO_BOX (gtk_builder_get_object (parent->builder,
"inner_auth_combo")),
+ self->inner_auth_combo,
I_METHOD_COLUMN);
}
@@ -334,7 +306,6 @@ eap_method_peap_new (WirelessSecurity *ws_parent,
{
EAPMethod *parent;
EAPMethodPEAP *method;
- GtkWidget *widget, *widget_ca_not_required_checkbox;
GtkFileFilter *filter;
NMSetting8021x *s_8021x = NULL;
const char *filename;
@@ -357,39 +328,43 @@ eap_method_peap_new (WirelessSecurity *ws_parent,
method->sec_parent = ws_parent;
method->is_editor = is_editor;
+ method->anon_identity_entry = GTK_ENTRY (gtk_builder_get_object (parent->builder,
"anon_identity_entry"));
+ method->anon_identity_label = GTK_LABEL (gtk_builder_get_object (parent->builder,
"anon_identity_label"));
+ method->ca_cert_button = GTK_FILE_CHOOSER_BUTTON (gtk_builder_get_object (parent->builder,
"ca_cert_button"));
+ method->ca_cert_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "ca_cert_label"));
+ method->ca_cert_not_required_check = GTK_CHECK_BUTTON (gtk_builder_get_object (parent->builder,
"ca_cert_not_required_check"));
+ method->inner_auth_combo = GTK_COMBO_BOX (gtk_builder_get_object (parent->builder,
"inner_auth_combo"));
+ method->inner_auth_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "inner_auth_label"));
+ method->inner_auth_box = GTK_BOX (gtk_builder_get_object (parent->builder, "inner_auth_box"));
+ method->version_combo = GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "version_combo"));
+ method->version_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "version_label"));
+
if (connection)
s_8021x = nm_connection_get_setting_802_1x (connection);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_not_required_check"));
- g_assert (widget);
- g_signal_connect_swapped (widget, "toggled", G_CALLBACK (ca_cert_not_required_toggled), method);
- widget_ca_not_required_checkbox = widget;
+ g_signal_connect_swapped (method->ca_cert_not_required_check, "toggled", G_CALLBACK
(ca_cert_not_required_toggled), method);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_button"));
- g_assert (widget);
- gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (widget), TRUE);
- gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON (widget),
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (method->ca_cert_button), TRUE);
+ gtk_file_chooser_button_set_title (method->ca_cert_button,
_("Choose a Certificate Authority certificate"));
- g_signal_connect_swapped (widget, "selection-changed", G_CALLBACK (changed_cb), method);
+ g_signal_connect_swapped (method->ca_cert_button, "selection-changed", G_CALLBACK (changed_cb),
method);
filter = eap_method_default_file_chooser_filter_new (FALSE);
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (widget), filter);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (method->ca_cert_button), filter);
if (connection && s_8021x) {
filename = NULL;
if (nm_setting_802_1x_get_ca_cert_scheme (s_8021x) == NM_SETTING_802_1X_CK_SCHEME_PATH) {
filename = nm_setting_802_1x_get_ca_cert_path (s_8021x);
if (filename)
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), filename);
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (method->ca_cert_button),
filename);
}
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget_ca_not_required_checkbox),
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (method->ca_cert_not_required_check),
!filename && eap_method_ca_cert_ignore_get (parent,
connection));
}
- widget = inner_auth_combo_init (method, connection, s_8021x, secrets_only);
+ inner_auth_combo_init (method, connection, s_8021x, secrets_only);
inner_auth_combo_changed_cb (method);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "version_combo"));
- g_assert (widget);
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+ gtk_combo_box_set_active (method->version_combo, 0);
if (s_8021x) {
const char *peapver;
@@ -397,37 +372,27 @@ eap_method_peap_new (WirelessSecurity *ws_parent,
if (peapver) {
/* Index 0 is "Automatic" */
if (!strcmp (peapver, "0"))
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1);
+ gtk_combo_box_set_active (method->version_combo, 1);
else if (!strcmp (peapver, "1"))
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2);
+ gtk_combo_box_set_active (method->version_combo, 2);
}
}
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), method);
+ g_signal_connect_swapped (method->version_combo, "changed", G_CALLBACK (changed_cb), method);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_entry"));
if (s_8021x && nm_setting_802_1x_get_anonymous_identity (s_8021x))
- gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_anonymous_identity (s_8021x));
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), method);
+ gtk_entry_set_text (method->anon_identity_entry, nm_setting_802_1x_get_anonymous_identity
(s_8021x));
+ g_signal_connect_swapped (method->anon_identity_entry, "changed", G_CALLBACK (changed_cb), method);
if (secrets_only) {
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_entry"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_button"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_not_required_check"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "version_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "version_combo"));
- gtk_widget_hide (widget);
+ gtk_widget_hide (GTK_WIDGET (method->anon_identity_label));
+ gtk_widget_hide (GTK_WIDGET (method->anon_identity_entry));
+ gtk_widget_hide (GTK_WIDGET (method->ca_cert_label));
+ gtk_widget_hide (GTK_WIDGET (method->ca_cert_button));
+ gtk_widget_hide (GTK_WIDGET (method->ca_cert_not_required_check));
+ gtk_widget_hide (GTK_WIDGET (method->inner_auth_label));
+ gtk_widget_hide (GTK_WIDGET (method->inner_auth_combo));
+ gtk_widget_hide (GTK_WIDGET (method->version_label));
+ gtk_widget_hide (GTK_WIDGET (method->version_combo));
}
return method;
diff --git a/panels/network/wireless-security/eap-method-simple.c
b/panels/network/wireless-security/eap-method-simple.c
index d7aeb7346..e3ae37fee 100644
--- a/panels/network/wireless-security/eap-method-simple.c
+++ b/panels/network/wireless-security/eap-method-simple.c
@@ -34,26 +34,27 @@
struct _EAPMethodSimple {
EAPMethod parent;
+ GtkNotebook *notebook;
+ GtkEntry *password_entry;
+ GtkLabel *password_label;
+ GtkToggleButton *show_password_check;
+ GtkEntry *username_entry;
+ GtkLabel *username_label;
+
WirelessSecurity *ws_parent;
EAPMethodSimpleType type;
EAPMethodSimpleFlags flags;
- GtkEntry *username_entry;
- GtkEntry *password_entry;
- GtkToggleButton *show_password;
guint idle_func_id;
};
static void
show_toggled_cb (EAPMethodSimple *self)
{
- EAPMethod *parent = (EAPMethod *) self;
- GtkWidget *widget;
gboolean visible;
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_password_check"));
- visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+ visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->show_password_check));
gtk_entry_set_visibility (self->password_entry, visible);
}
@@ -100,15 +101,9 @@ validate (EAPMethod *parent, GError **error)
static void
add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
{
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "username_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "password_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
+ EAPMethodSimple *self = (EAPMethodSimple *) parent;
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->username_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->password_label));
}
typedef struct {
@@ -180,10 +175,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
/* Update secret flags and popup when editing the connection */
if (!(method->flags & EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY)) {
- GtkWidget *passwd_entry = GTK_WIDGET (gtk_builder_get_object (parent->builder,
"password_entry"));
- g_assert (passwd_entry);
-
- nma_utils_update_password_storage (passwd_entry, flags,
+ nma_utils_update_password_storage (GTK_WIDGET (method->password_entry), flags,
NM_SETTING (s_8021x), parent->password_flags_name);
}
}
@@ -191,8 +183,9 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
static void
update_secrets (EAPMethod *parent, NMConnection *connection)
{
+ EAPMethodSimple *self = (EAPMethodSimple *) parent;
helper_fill_secret_entry (connection,
- GTK_ENTRY (gtk_builder_get_object (parent->builder, "password_entry")),
+ self->password_entry,
NM_TYPE_SETTING_802_1X,
(HelperSecretFunc) nm_setting_802_1x_get_password);
}
@@ -216,10 +209,10 @@ password_storage_changed (EAPMethodSimple *method)
if (always_ask && !secrets_only) {
/* we always clear this button and do not restore it
* (because we want to hide the password). */
- gtk_toggle_button_set_active (method->show_password, FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (method->show_password_check), FALSE);
}
- gtk_widget_set_sensitive (GTK_WIDGET (method->show_password),
+ gtk_widget_set_sensitive (GTK_WIDGET (method->show_password_check),
!always_ask || secrets_only);
if (!method->idle_func_id)
@@ -241,7 +234,7 @@ set_userpass_ui (EAPMethodSimple *method)
else
gtk_entry_set_text (method->password_entry, "");
- gtk_toggle_button_set_active (method->show_password, wireless_security_get_show_password
(method->ws_parent));
+ gtk_toggle_button_set_active (method->show_password_check, wireless_security_get_show_password
(method->ws_parent));
}
static void
@@ -257,23 +250,19 @@ widgets_unrealized (EAPMethodSimple *method)
gtk_entry_get_text (method->username_entry),
gtk_entry_get_text (method->password_entry),
always_ask_selected (method->password_entry),
- gtk_toggle_button_get_active (method->show_password));
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(method->show_password_check)));
}
static void
destroy (EAPMethod *parent)
{
EAPMethodSimple *method = (EAPMethodSimple *) parent;
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "notebook"));
- g_assert (widget);
- g_signal_handlers_disconnect_by_data (widget, method);
+ g_signal_handlers_disconnect_by_data (method->notebook, method);
g_signal_handlers_disconnect_by_data (method->username_entry, method->ws_parent);
g_signal_handlers_disconnect_by_data (method->password_entry, method->ws_parent);
g_signal_handlers_disconnect_by_data (method->password_entry, method);
- g_signal_handlers_disconnect_by_data (method->show_password, method);
+ g_signal_handlers_disconnect_by_data (method->show_password_check, method);
nm_clear_g_source (&method->idle_func_id);
}
@@ -292,7 +281,6 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
{
EAPMethod *parent;
EAPMethodSimple *method;
- GtkWidget *widget;
NMSetting8021x *s_8021x = NULL;
parent = eap_method_init (sizeof (EAPMethodSimple),
@@ -315,36 +303,32 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
method->type = type;
g_assert (type < EAP_METHOD_SIMPLE_TYPE_LAST);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "notebook"));
- g_assert (widget);
- g_signal_connect_swapped (widget, "realize", G_CALLBACK (widgets_realized), method);
- g_signal_connect_swapped (widget, "unrealize", G_CALLBACK (widgets_unrealized), method);
+ method->notebook = GTK_NOTEBOOK (gtk_builder_get_object (parent->builder, "notebook"));
+ method->password_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "password_label"));
+ method->username_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "username_label"));
+ method->password_entry = GTK_ENTRY (gtk_builder_get_object (parent->builder, "password_entry"));
+ method->show_password_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (parent->builder,
"show_password_check"));
+ method->username_entry = GTK_ENTRY (gtk_builder_get_object (parent->builder, "username_entry"));
+
+ g_signal_connect_swapped (method->notebook, "realize", G_CALLBACK (widgets_realized), method);
+ g_signal_connect_swapped (method->notebook, "unrealize", G_CALLBACK (widgets_unrealized), method);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "username_entry"));
- g_assert (widget);
- method->username_entry = GTK_ENTRY (widget);
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), method);
+ g_signal_connect_swapped (method->username_entry, "changed", G_CALLBACK (changed_cb), method);
if (method->flags & EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY)
- gtk_widget_set_sensitive (widget, FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (method->username_entry), FALSE);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "password_entry"));
- g_assert (widget);
- method->password_entry = GTK_ENTRY (widget);
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), method);
+ g_signal_connect_swapped (method->password_entry, "changed", G_CALLBACK (changed_cb), method);
/* Create password-storage popup menu for password entry under entry's secondary icon */
if (connection)
s_8021x = nm_connection_get_setting_802_1x (connection);
- nma_utils_setup_password_storage (widget, 0, (NMSetting *) s_8021x, parent->password_flags_name,
+ nma_utils_setup_password_storage (GTK_WIDGET (method->password_entry), 0, (NMSetting *) s_8021x,
parent->password_flags_name,
FALSE, flags & EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY);
g_signal_connect_swapped (method->password_entry, "notify::secondary-icon-name", G_CALLBACK
(password_storage_changed), method);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_password_check"));
- g_assert (widget);
- method->show_password = GTK_TOGGLE_BUTTON (widget);
- g_signal_connect_swapped (widget, "toggled", G_CALLBACK (show_toggled_cb), method);
+ g_signal_connect_swapped (method->show_password_check, "toggled", G_CALLBACK (show_toggled_cb),
method);
/* Initialize the UI fields with the security settings from method->ws_parent.
* This will be done again when the widget gets realized. It must be done here as well,
diff --git a/panels/network/wireless-security/eap-method-tls.c
b/panels/network/wireless-security/eap-method-tls.c
index 152a59cd5..cb8d550dc 100644
--- a/panels/network/wireless-security/eap-method-tls.c
+++ b/panels/network/wireless-security/eap-method-tls.c
@@ -34,6 +34,19 @@
struct _EAPMethodTLS {
EAPMethod parent;
+ GtkFileChooserButton *ca_cert_button;
+ GtkLabel *ca_cert_label;
+ GtkCheckButton *ca_cert_not_required_check;
+ GtkEntry *identity_entry;
+ GtkLabel *identity_label;
+ GtkFileChooserButton *private_key_button;
+ GtkLabel *private_key_label;
+ GtkEntry *private_key_password_entry;
+ GtkLabel *private_key_password_label;
+ GtkCheckButton *show_password_check;
+ GtkFileChooserButton *user_cert_button;
+ GtkLabel *user_cert_label;
+
WirelessSecurity *sec_parent;
gboolean editing_connection;
};
@@ -42,60 +55,51 @@ struct _EAPMethodTLS {
static void
show_toggled_cb (EAPMethodTLS *self)
{
- EAPMethod *method = (EAPMethod *) self;
- GtkWidget *widget;
gboolean visible;
- widget = GTK_WIDGET (gtk_builder_get_object (method->builder, "show_password_check"));
- visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-
- widget = GTK_WIDGET (gtk_builder_get_object (method->builder, "private_key_password_entry"));
- gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
+ visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->show_password_check));
+ gtk_entry_set_visibility (self->private_key_password_entry, visible);
}
static gboolean
validate (EAPMethod *parent, GError **error)
{
+ EAPMethodTLS *self = (EAPMethodTLS *) parent;
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
- GtkWidget *widget;
const char *password, *identity;
g_autoptr(GError) ca_cert_error = NULL;
g_autoptr(GError) private_key_error = NULL;
g_autoptr(GError) user_cert_error = NULL;
gboolean ret = TRUE;
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "identity_entry"));
- g_assert (widget);
- identity = gtk_entry_get_text (GTK_ENTRY (widget));
+ identity = gtk_entry_get_text (self->identity_entry);
if (!identity || !strlen (identity)) {
- widget_set_error (widget);
+ widget_set_error (GTK_WIDGET (self->identity_entry));
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing EAP-TLS identity"));
ret = FALSE;
} else {
- widget_unset_error (widget);
+ widget_unset_error (GTK_WIDGET (self->identity_entry));
}
- if (!eap_method_validate_filepicker (GTK_FILE_CHOOSER (gtk_builder_get_object (parent->builder,
"ca_cert_button")),
+ if (!eap_method_validate_filepicker (GTK_FILE_CHOOSER (self->ca_cert_button),
TYPE_CA_CERT, NULL, NULL, &ca_cert_error)) {
- widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_button")));
+ widget_set_error (GTK_WIDGET (self->ca_cert_button));
if (ret) {
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS CA certificate:
%s"), ca_cert_error->message);
ret = FALSE;
}
- } else if (eap_method_ca_cert_required (GTK_TOGGLE_BUTTON (gtk_builder_get_object (parent->builder,
"ca_cert_not_required_check")),
- GTK_FILE_CHOOSER (gtk_builder_get_object (parent->builder,
"ca_cert_button")))) {
- widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_button")));
+ } else if (eap_method_ca_cert_required (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check),
+ GTK_FILE_CHOOSER (self->ca_cert_button))) {
+ widget_set_error (GTK_WIDGET (self->ca_cert_button));
if (ret) {
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS CA
certificate: no certificate specified"));
ret = FALSE;
}
}
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "private_key_password_entry"));
- g_assert (widget);
- password = gtk_entry_get_text (GTK_ENTRY (widget));
+ password = gtk_entry_get_text (self->private_key_password_entry);
- if (!eap_method_validate_filepicker (GTK_FILE_CHOOSER (gtk_builder_get_object (parent->builder,
"private_key_button")),
+ if (!eap_method_validate_filepicker (GTK_FILE_CHOOSER (self->private_key_button),
TYPE_PRIVATE_KEY,
password,
&format,
@@ -104,17 +108,17 @@ validate (EAPMethod *parent, GError **error)
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS private-key:
%s"), private_key_error->message);
ret = FALSE;
}
- widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder,
"private_key_button")));
+ widget_set_error (GTK_WIDGET (self->private_key_button));
}
if (format != NM_SETTING_802_1X_CK_FORMAT_PKCS12) {
- if (!eap_method_validate_filepicker (GTK_FILE_CHOOSER (gtk_builder_get_object
(parent->builder, "user_cert_button")),
+ if (!eap_method_validate_filepicker (GTK_FILE_CHOOSER (self->user_cert_button),
TYPE_CLIENT_CERT, NULL, NULL, &user_cert_error)) {
if (ret) {
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS
user-certificate: %s"), user_cert_error->message);
ret = FALSE;
}
- widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder,
"user_cert_button")));
+ widget_set_error (GTK_WIDGET (self->user_cert_button));
}
}
@@ -124,41 +128,22 @@ validate (EAPMethod *parent, GError **error)
static void
ca_cert_not_required_toggled (EAPMethodTLS *self)
{
- EAPMethod *parent = (EAPMethod *) self;
-
- eap_method_ca_cert_not_required_toggled (GTK_TOGGLE_BUTTON (gtk_builder_get_object (parent->builder,
"ca_cert_not_required_check")),
- GTK_FILE_CHOOSER (gtk_builder_get_object (parent->builder,
"ca_cert_button")));
+ eap_method_ca_cert_not_required_toggled (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check),
+ GTK_FILE_CHOOSER (self->ca_cert_button));
wireless_security_notify_changed (self->sec_parent);
}
static void
add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
{
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_not_required_check"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "identity_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "user_cert_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "private_key_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "private_key_password_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
+ EAPMethodTLS *self = (EAPMethodTLS *) parent;
+
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->ca_cert_not_required_check));
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->identity_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->user_cert_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->ca_cert_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->private_key_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->private_key_password_label));
}
static void
@@ -168,7 +153,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
NMSetting8021x *s_8021x;
NMSettingSecretFlags secret_flags;
- GtkWidget *widget, *passwd_entry;
g_autofree gchar *ca_filename = NULL;
g_autofree gchar *pk_filename = NULL;
const char *password = NULL;
@@ -182,20 +166,12 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
else
nm_setting_802_1x_add_eap_method (s_8021x, "tls");
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "identity_entry"));
- g_assert (widget);
- g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, gtk_entry_get_text (GTK_ENTRY (widget)), NULL);
+ g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, gtk_entry_get_text (method->identity_entry), NULL);
/* TLS private key */
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "private_key_password_entry"));
- g_assert (widget);
- password = gtk_entry_get_text (GTK_ENTRY (widget));
- g_assert (password);
- passwd_entry = widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "private_key_button"));
- g_assert (widget);
- pk_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
+ password = gtk_entry_get_text (method->private_key_password_entry);
+
+ pk_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (method->private_key_button));
g_assert (pk_filename);
if (parent->phase2) {
@@ -209,13 +185,13 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
}
/* Save 802.1X password flags to the connection */
- secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
+ secret_flags = nma_utils_menu_to_secret_flags (GTK_WIDGET (method->private_key_password_entry));
nm_setting_set_secret_flags (NM_SETTING (s_8021x), parent->password_flags_name,
secret_flags, NULL);
/* Update secret flags and popup when editing the connection */
if (method->editing_connection) {
- nma_utils_update_password_storage (passwd_entry, secret_flags,
+ nma_utils_update_password_storage (GTK_WIDGET (method->private_key_password_entry),
secret_flags,
NM_SETTING (s_8021x), parent->password_flags_name);
}
@@ -226,9 +202,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
/* If the key is pkcs#12 nm_setting_802_1x_set_private_key() already
* set the client certificate for us.
*/
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "user_cert_button"));
- g_assert (widget);
- cc_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
+ cc_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (method->user_cert_button));
g_assert (cc_filename);
format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
@@ -244,9 +218,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
}
/* TLS CA certificate */
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_button"));
- g_assert (widget);
- ca_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
+ ca_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (method->ca_cert_button));
format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
if (parent->phase2) {
@@ -268,25 +240,22 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
static void
private_key_picker_helper (EAPMethod *parent, const char *filename, gboolean changed)
{
+ EAPMethodTLS *self = (EAPMethodTLS *) parent;
g_autoptr(NMSetting8021x) setting = NULL;
NMSetting8021xCKFormat cert_format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
const char *password;
- GtkWidget *widget;
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "private_key_password_entry"));
- g_assert (widget);
- password = gtk_entry_get_text (GTK_ENTRY (widget));
+ password = gtk_entry_get_text (self->private_key_password_entry);
setting = (NMSetting8021x *) nm_setting_802_1x_new ();
nm_setting_802_1x_set_private_key (setting, filename, password, NM_SETTING_802_1X_CK_SCHEME_PATH,
&cert_format, NULL);
/* With PKCS#12, the client cert must be the same as the private key */
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "user_cert_button"));
if (cert_format == NM_SETTING_802_1X_CK_FORMAT_PKCS12) {
- gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (widget));
- gtk_widget_set_sensitive (widget, FALSE);
+ gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (self->user_cert_button));
+ gtk_widget_set_sensitive (GTK_WIDGET (self->user_cert_button), FALSE);
} else if (changed)
- gtk_widget_set_sensitive (widget, TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (self->user_cert_button), TRUE);
/* Warn the user if the private key is unencrypted */
if (!eap_method_is_encrypted_private_key (filename)) {
@@ -394,12 +363,12 @@ setup_filepicker (GtkFileChooserButton *button,
static void
update_secrets (EAPMethod *parent, NMConnection *connection)
{
+ EAPMethodTLS *self = (EAPMethodTLS *) parent;
NMSetting8021x *s_8021x;
HelperSecretFunc password_func;
SchemeFunc scheme_func;
PathFunc path_func;
const char *filename;
- GtkWidget *widget;
if (parent->phase2) {
password_func = (HelperSecretFunc) nm_setting_802_1x_get_phase2_private_key_password;
@@ -412,7 +381,7 @@ update_secrets (EAPMethod *parent, NMConnection *connection)
}
helper_fill_secret_entry (connection,
- GTK_ENTRY (gtk_builder_get_object (parent->builder,
"private_key_password_entry")),
+ self->private_key_password_entry,
NM_TYPE_SETTING_802_1X,
password_func);
@@ -420,11 +389,8 @@ update_secrets (EAPMethod *parent, NMConnection *connection)
s_8021x = nm_connection_get_setting_802_1x (connection);
if (s_8021x && (scheme_func (s_8021x) == NM_SETTING_802_1X_CK_SCHEME_PATH)) {
filename = path_func (s_8021x);
- if (filename) {
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "private_key_button"));
- g_assert (widget);
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), filename);
- }
+ if (filename)
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (self->private_key_button), filename);
}
}
@@ -436,7 +402,6 @@ eap_method_tls_new (WirelessSecurity *ws_parent,
{
EAPMethodTLS *method;
EAPMethod *parent;
- GtkWidget *widget;
NMSetting8021x *s_8021x = NULL;
gboolean ca_not_required = FALSE;
@@ -460,78 +425,72 @@ eap_method_tls_new (WirelessSecurity *ws_parent,
method->sec_parent = ws_parent;
method->editing_connection = secrets_only ? FALSE : TRUE;
+ method->ca_cert_button = GTK_FILE_CHOOSER_BUTTON (gtk_builder_get_object (parent->builder,
"ca_cert_button"));
+ method->ca_cert_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "ca_cert_label"));
+ method->ca_cert_not_required_check = GTK_CHECK_BUTTON (gtk_builder_get_object (parent->builder,
"ca_cert_not_required_check"));
+ method->identity_entry = GTK_ENTRY (gtk_builder_get_object (parent->builder, "identity_entry"));
+ method->identity_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "identity_label"));
+ method->private_key_button = GTK_FILE_CHOOSER_BUTTON (gtk_builder_get_object (parent->builder,
"private_key_button"));
+ method->private_key_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "private_key_label"));
+ method->private_key_password_entry = GTK_ENTRY (gtk_builder_get_object (parent->builder,
"private_key_password_entry"));
+ method->private_key_password_label = GTK_LABEL (gtk_builder_get_object (parent->builder,
"private_key_password_label"));
+ method->show_password_check = GTK_CHECK_BUTTON (gtk_builder_get_object (parent->builder,
"show_password_check"));
+ method->user_cert_button = GTK_FILE_CHOOSER_BUTTON (gtk_builder_get_object (parent->builder,
"user_cert_button"));
+ method->user_cert_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "user_cert_label"));
+
if (connection)
s_8021x = nm_connection_get_setting_802_1x (connection);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_not_required_check"));
- g_assert (widget);
- g_signal_connect_swapped (widget, "toggled", G_CALLBACK (ca_cert_not_required_toggled), method);
+ g_signal_connect_swapped (method->ca_cert_not_required_check, "toggled", G_CALLBACK
(ca_cert_not_required_toggled), method);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "identity_entry"));
- g_assert (widget);
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), method);
+ g_signal_connect_swapped (method->identity_entry, "changed", G_CALLBACK (changed_cb), method);
if (s_8021x && nm_setting_802_1x_get_identity (s_8021x))
- gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_identity (s_8021x));
+ gtk_entry_set_text (method->identity_entry, nm_setting_802_1x_get_identity (s_8021x));
- setup_filepicker (GTK_FILE_CHOOSER_BUTTON (gtk_builder_get_object (parent->builder,
"user_cert_button")),
+ setup_filepicker (method->user_cert_button,
_("Choose your personal certificate"),
ws_parent, parent, s_8021x,
phase2 ? nm_setting_802_1x_get_phase2_client_cert_scheme :
nm_setting_802_1x_get_client_cert_scheme,
phase2 ? nm_setting_802_1x_get_phase2_client_cert_path :
nm_setting_802_1x_get_client_cert_path,
FALSE, TRUE);
- setup_filepicker (GTK_FILE_CHOOSER_BUTTON (gtk_builder_get_object (parent->builder,
"ca_cert_button")),
+ setup_filepicker (method->ca_cert_button,
_("Choose a Certificate Authority certificate"),
ws_parent, parent, s_8021x,
phase2 ? nm_setting_802_1x_get_phase2_ca_cert_scheme :
nm_setting_802_1x_get_ca_cert_scheme,
phase2 ? nm_setting_802_1x_get_phase2_ca_cert_path :
nm_setting_802_1x_get_ca_cert_path,
FALSE, FALSE);
- setup_filepicker (GTK_FILE_CHOOSER_BUTTON (gtk_builder_get_object (parent->builder,
"private_key_button")),
+ setup_filepicker (method->private_key_button,
_("Choose your private key"),
ws_parent, parent, s_8021x,
phase2 ? nm_setting_802_1x_get_phase2_private_key_scheme :
nm_setting_802_1x_get_private_key_scheme,
phase2 ? nm_setting_802_1x_get_phase2_private_key_path :
nm_setting_802_1x_get_private_key_path,
TRUE, FALSE);
- if (connection && eap_method_ca_cert_ignore_get (parent, connection)) {
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_button"));
- ca_not_required = !gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
- }
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_not_required_check"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), ca_not_required);
+ if (connection && eap_method_ca_cert_ignore_get (parent, connection))
+ ca_not_required = !gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (method->ca_cert_button));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (method->ca_cert_not_required_check),
ca_not_required);
/* Fill secrets, if any */
if (connection)
update_secrets (parent, connection);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "private_key_password_entry"));
- g_assert (widget);
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), method);
+ g_signal_connect_swapped (method->private_key_password_entry, "changed", G_CALLBACK (changed_cb),
method);
/* Create password-storage popup menu for password entry under entry's secondary icon */
- nma_utils_setup_password_storage (widget, 0, (NMSetting *) s_8021x, parent->password_flags_name,
+ nma_utils_setup_password_storage (GTK_WIDGET (method->private_key_password_entry), 0, (NMSetting *)
s_8021x, parent->password_flags_name,
FALSE, secrets_only);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_password_check"));
- g_assert (widget);
- g_signal_connect_swapped (widget, "toggled", G_CALLBACK (show_toggled_cb), method);
+ g_signal_connect_swapped (method->show_password_check, "toggled", G_CALLBACK (show_toggled_cb),
method);
if (secrets_only) {
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "identity_entry"));
- gtk_widget_set_sensitive (widget, FALSE);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "user_cert_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "user_cert_button"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "private_key_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "private_key_button"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_button"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_not_required_check"));
- gtk_widget_hide (widget);
+ gtk_widget_set_sensitive (GTK_WIDGET (method->identity_entry), FALSE);
+ gtk_widget_hide (GTK_WIDGET (method->user_cert_label));
+ gtk_widget_hide (GTK_WIDGET (method->user_cert_button));
+ gtk_widget_hide (GTK_WIDGET (method->private_key_label));
+ gtk_widget_hide (GTK_WIDGET (method->private_key_button));
+ gtk_widget_hide (GTK_WIDGET (method->ca_cert_label));
+ gtk_widget_hide (GTK_WIDGET (method->ca_cert_button));
+ gtk_widget_hide (GTK_WIDGET (method->ca_cert_not_required_check));
}
return method;
diff --git a/panels/network/wireless-security/eap-method-ttls.c
b/panels/network/wireless-security/eap-method-ttls.c
index 871a237cb..5db1a2c6e 100644
--- a/panels/network/wireless-security/eap-method-ttls.c
+++ b/panels/network/wireless-security/eap-method-ttls.c
@@ -35,6 +35,17 @@
struct _EAPMethodTTLS {
EAPMethod parent;
+ GtkEntry *anon_identity_entry;
+ GtkLabel *anon_identity_label;
+ GtkFileChooserButton *ca_cert_button;
+ GtkLabel *ca_cert_label;
+ GtkCheckButton *ca_cert_not_required_check;
+ GtkEntry *domain_match_entry;
+ GtkLabel *domain_match_label;
+ GtkComboBox *inner_auth_combo;
+ GtkLabel *inner_auth_label;
+ GtkBox *inner_auth_box;
+
GtkSizeGroup *size_group;
WirelessSecurity *sec_parent;
gboolean is_editor;
@@ -52,29 +63,26 @@ destroy (EAPMethod *parent)
static gboolean
validate (EAPMethod *parent, GError **error)
{
- GtkWidget *widget;
+ EAPMethodTTLS *self = (EAPMethodTTLS *) parent;
GtkTreeModel *model;
GtkTreeIter iter;
g_autoptr(EAPMethod) eap = NULL;
gboolean valid = FALSE;
g_autoptr(GError) local_error = NULL;
- if (!eap_method_validate_filepicker (GTK_FILE_CHOOSER (gtk_builder_get_object (parent->builder,
"ca_cert_button")),
+ if (!eap_method_validate_filepicker (GTK_FILE_CHOOSER (self->ca_cert_button),
TYPE_CA_CERT, NULL, NULL, &local_error)) {
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TTLS CA certificate: %s"),
local_error->message);
return FALSE;
}
- if (eap_method_ca_cert_required (GTK_TOGGLE_BUTTON (gtk_builder_get_object (parent->builder,
"ca_cert_not_required_check")),
- GTK_FILE_CHOOSER (gtk_builder_get_object (parent->builder,
"ca_cert_button")))) {
+ if (eap_method_ca_cert_required (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check),
+ GTK_FILE_CHOOSER (self->ca_cert_button))) {
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TTLS CA certificate:
no certificate specified"));
return FALSE;
}
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- g_assert (widget);
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
+ model = gtk_combo_box_get_model (self->inner_auth_combo);
+ gtk_combo_box_get_active_iter (self->inner_auth_combo, &iter);
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap);
valid = eap_method_validate (eap, error);
@@ -84,9 +92,8 @@ validate (EAPMethod *parent, GError **error)
static void
ca_cert_not_required_toggled (EAPMethodTTLS *self)
{
- EAPMethod *parent = (EAPMethod *) self;
- eap_method_ca_cert_not_required_toggled (GTK_TOGGLE_BUTTON (gtk_builder_get_object (parent->builder,
"ca_cert_not_required_check")),
- GTK_FILE_CHOOSER (gtk_builder_get_object (parent->builder,
"ca_cert_button")));
+ eap_method_ca_cert_not_required_toggled (GTK_TOGGLE_BUTTON (self->ca_cert_not_required_check),
+ GTK_FILE_CHOOSER (self->ca_cert_button));
wireless_security_notify_changed (self->sec_parent);
}
@@ -94,7 +101,6 @@ static void
add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
{
EAPMethodTTLS *method = (EAPMethodTTLS *) parent;
- GtkWidget *widget;
GtkTreeModel *model;
GtkTreeIter iter;
g_autoptr(EAPMethod) eap = NULL;
@@ -103,31 +109,14 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
g_object_unref (method->size_group);
method->size_group = g_object_ref (group);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_not_required_check"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "domain_match_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_label"));
- g_assert (widget);
- gtk_size_group_add_widget (group, widget);
+ gtk_size_group_add_widget (group, GTK_WIDGET (method->ca_cert_not_required_check));
+ gtk_size_group_add_widget (group, GTK_WIDGET (method->anon_identity_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (method->domain_match_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (method->ca_cert_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (method->inner_auth_label));
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- g_assert (widget);
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
+ model = gtk_combo_box_get_model (method->inner_auth_combo);
+ gtk_combo_box_get_active_iter (method->inner_auth_combo, &iter);
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap);
eap_method_add_to_size_group (eap, group);
@@ -136,9 +125,9 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
static void
fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFlags flags)
{
+ EAPMethodTTLS *self = (EAPMethodTTLS *) parent;
NMSetting8021x *s_8021x;
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
- GtkWidget *widget;
const char *text;
g_autofree gchar *filename = NULL;
g_autoptr(EAPMethod) eap = NULL;
@@ -152,30 +141,23 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
nm_setting_802_1x_add_eap_method (s_8021x, "ttls");
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_entry"));
- g_assert (widget);
- text = gtk_entry_get_text (GTK_ENTRY (widget));
+ text = gtk_entry_get_text (self->anon_identity_entry);
if (text && strlen (text))
g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, text, NULL);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "domain_match_entry"));
- g_assert (widget);
- text = gtk_entry_get_text (GTK_ENTRY (widget));
+ text = gtk_entry_get_text (self->domain_match_entry);
if (text && strlen (text))
g_object_set (s_8021x, NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH, text, NULL);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_button"));
- g_assert (widget);
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (self->ca_cert_button));
if (!nm_setting_802_1x_set_ca_cert (s_8021x, filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format,
&error)) {
g_warning ("Couldn't read CA certificate '%s': %s", filename, error ? error->message :
"(unknown)");
ca_cert_error = TRUE;
}
eap_method_ca_cert_ignore_set (parent, connection, filename, ca_cert_error);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
+ model = gtk_combo_box_get_model (self->inner_auth_combo);
+ gtk_combo_box_get_active_iter (self->inner_auth_combo, &iter);
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap);
@@ -185,26 +167,20 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
static void
inner_auth_combo_changed_cb (EAPMethodTTLS *self)
{
- EAPMethod *parent = (EAPMethod *) self;
- GtkWidget *combo, *box;
g_autoptr(EAPMethod) eap = NULL;
GList *elt, *children;
GtkTreeModel *model;
GtkTreeIter iter;
GtkWidget *eap_widget;
- combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- box = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_box"));
- g_assert (box);
-
/* Remove any previous wireless security widgets */
- children = gtk_container_get_children (GTK_CONTAINER (box));
+ children = gtk_container_get_children (GTK_CONTAINER (self->inner_auth_box));
for (elt = children; elt; elt = g_list_next (elt))
- gtk_container_remove (GTK_CONTAINER (box), GTK_WIDGET (elt->data));
+ gtk_container_remove (GTK_CONTAINER (self->inner_auth_box), GTK_WIDGET (elt->data));
g_list_free (children);
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
+ model = gtk_combo_box_get_model (self->inner_auth_combo);
+ gtk_combo_box_get_active_iter (self->inner_auth_combo, &iter);
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap);
@@ -214,19 +190,17 @@ inner_auth_combo_changed_cb (EAPMethodTTLS *self)
if (self->size_group)
eap_method_add_to_size_group (eap, self->size_group);
- gtk_container_add (GTK_CONTAINER (box), eap_widget);
+ gtk_container_add (GTK_CONTAINER (self->inner_auth_box), eap_widget);
wireless_security_notify_changed (self->sec_parent);
}
-static GtkWidget *
+static void
inner_auth_combo_init (EAPMethodTTLS *method,
NMConnection *connection,
NMSetting8021x *s_8021x,
gboolean secrets_only)
{
- EAPMethod *parent = (EAPMethod *) method;
- GtkWidget *combo;
g_autoptr(GtkListStore) auth_model = NULL;
GtkTreeIter iter;
g_autoptr(EAPMethodSimple) em_pap = NULL;
@@ -355,22 +329,19 @@ inner_auth_combo_init (EAPMethodTTLS *method,
if (phase2_auth && !strcasecmp (phase2_auth, "gtc"))
active = 6;
- combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- g_assert (combo);
+ gtk_combo_box_set_model (method->inner_auth_combo, GTK_TREE_MODEL (auth_model));
+ gtk_combo_box_set_active (method->inner_auth_combo, active);
- gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model));
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active);
-
- g_signal_connect_swapped (combo, "changed", G_CALLBACK (inner_auth_combo_changed_cb), method);
- return combo;
+ g_signal_connect_swapped (method->inner_auth_combo, "changed", G_CALLBACK
(inner_auth_combo_changed_cb), method);
}
static void
update_secrets (EAPMethod *parent, NMConnection *connection)
{
+ EAPMethodTTLS *self = (EAPMethodTTLS *) parent;
eap_method_phase2_update_secrets_helper (parent,
connection,
- GTK_COMBO_BOX (gtk_builder_get_object (parent->builder,
"inner_auth_combo")),
+ self->inner_auth_combo,
I_METHOD_COLUMN);
}
@@ -388,7 +359,6 @@ eap_method_ttls_new (WirelessSecurity *ws_parent,
{
EAPMethod *parent;
EAPMethodTTLS *method;
- GtkWidget *widget, *widget_ca_not_required_checkbox;
GtkFileFilter *filter;
NMSetting8021x *s_8021x = NULL;
const char *filename;
@@ -411,64 +381,59 @@ eap_method_ttls_new (WirelessSecurity *ws_parent,
method->sec_parent = ws_parent;
method->is_editor = is_editor;
+ method->anon_identity_entry = GTK_ENTRY (gtk_builder_get_object (parent->builder,
"anon_identity_entry"));
+ method->anon_identity_label = GTK_LABEL (gtk_builder_get_object (parent->builder,
"anon_identity_label"));
+ method->ca_cert_button = GTK_FILE_CHOOSER_BUTTON (gtk_builder_get_object (parent->builder,
"ca_cert_button"));
+ method->ca_cert_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "ca_cert_label"));
+ method->ca_cert_not_required_check = GTK_CHECK_BUTTON (gtk_builder_get_object (parent->builder,
"ca_cert_not_required_check"));
+ method->domain_match_entry = GTK_ENTRY (gtk_builder_get_object (parent->builder,
"domain_match_entry"));
+ method->domain_match_label = GTK_LABEL (gtk_builder_get_object (parent->builder,
"domain_match_label"));
+ method->inner_auth_combo = GTK_COMBO_BOX (gtk_builder_get_object (parent->builder,
"inner_auth_combo"));
+ method->inner_auth_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "inner_auth_label"));
+ method->inner_auth_box = GTK_BOX (gtk_builder_get_object (parent->builder, "inner_auth_box"));
+
if (connection)
s_8021x = nm_connection_get_setting_802_1x (connection);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_not_required_check"));
- g_assert (widget);
- g_signal_connect_swapped (widget, "toggled", G_CALLBACK (ca_cert_not_required_toggled), method);
- widget_ca_not_required_checkbox = widget;
+ g_signal_connect_swapped (method->ca_cert_not_required_check, "toggled", G_CALLBACK
(ca_cert_not_required_toggled), method);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_button"));
- g_assert (widget);
- gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (widget), TRUE);
- gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON (widget),
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (method->ca_cert_button), TRUE);
+ gtk_file_chooser_button_set_title (method->ca_cert_button,
_("Choose a Certificate Authority certificate"));
- g_signal_connect_swapped (widget, "selection-changed", G_CALLBACK (changed_cb), method);
+ g_signal_connect_swapped (method->ca_cert_button, "selection-changed", G_CALLBACK (changed_cb),
method);
filter = eap_method_default_file_chooser_filter_new (FALSE);
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (widget), filter);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (method->ca_cert_button), filter);
if (connection && s_8021x) {
filename = NULL;
if (nm_setting_802_1x_get_ca_cert_scheme (s_8021x) == NM_SETTING_802_1X_CK_SCHEME_PATH) {
filename = nm_setting_802_1x_get_ca_cert_path (s_8021x);
if (filename)
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), filename);
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (method->ca_cert_button),
filename);
}
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget_ca_not_required_checkbox),
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (method->ca_cert_not_required_check),
!filename && eap_method_ca_cert_ignore_get (parent,
connection));
}
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_entry"));
if (s_8021x && nm_setting_802_1x_get_anonymous_identity (s_8021x))
- gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_anonymous_identity (s_8021x));
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), method);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "domain_match_entry"));
+ gtk_entry_set_text (method->anon_identity_entry, nm_setting_802_1x_get_anonymous_identity
(s_8021x));
+ g_signal_connect_swapped (method->anon_identity_entry, "changed", G_CALLBACK (changed_cb), method);
if (s_8021x && nm_setting_802_1x_get_domain_suffix_match (s_8021x))
- gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_domain_suffix_match (s_8021x));
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), method);
+ gtk_entry_set_text (method->domain_match_entry, nm_setting_802_1x_get_domain_suffix_match
(s_8021x));
+ g_signal_connect_swapped (method->domain_match_entry, "changed", G_CALLBACK (changed_cb), method);
- widget = inner_auth_combo_init (method, connection, s_8021x, secrets_only);
+ inner_auth_combo_init (method, connection, s_8021x, secrets_only);
inner_auth_combo_changed_cb (method);
if (secrets_only) {
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "anon_identity_entry"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "domain_match_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "domain_match_entry"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_button"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ca_cert_not_required_check"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_label"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "inner_auth_combo"));
- gtk_widget_hide (widget);
+ gtk_widget_hide (GTK_WIDGET (method->anon_identity_label));
+ gtk_widget_hide (GTK_WIDGET (method->anon_identity_entry));
+ gtk_widget_hide (GTK_WIDGET (method->domain_match_label));
+ gtk_widget_hide (GTK_WIDGET (method->domain_match_entry));
+ gtk_widget_hide (GTK_WIDGET (method->ca_cert_label));
+ gtk_widget_hide (GTK_WIDGET (method->ca_cert_button));
+ gtk_widget_hide (GTK_WIDGET (method->ca_cert_not_required_check));
+ gtk_widget_hide (GTK_WIDGET (method->inner_auth_label));
+ gtk_widget_hide (GTK_WIDGET (method->inner_auth_combo));
}
return method;
diff --git a/panels/network/wireless-security/ws-dynamic-wep.c
b/panels/network/wireless-security/ws-dynamic-wep.c
index 6d281af34..2efa0dee1 100644
--- a/panels/network/wireless-security/ws-dynamic-wep.c
+++ b/panels/network/wireless-security/ws-dynamic-wep.c
@@ -32,6 +32,11 @@
struct _WirelessSecurityDynamicWEP {
WirelessSecurity parent;
+ GtkComboBox *auth_combo;
+ GtkLabel *auth_label;
+ GtkBox *method_box;
+ GtkNotebook *notebook;
+
GtkSizeGroup *size_group;
};
@@ -47,13 +52,15 @@ destroy (WirelessSecurity *parent)
static GtkWidget *
get_widget (WirelessSecurity *parent)
{
- return GTK_WIDGET (gtk_builder_get_object (parent->builder, "notebook"));
+ WirelessSecurityDynamicWEP *self = (WirelessSecurityDynamicWEP *) parent;
+ return GTK_WIDGET (self->notebook);
}
static gboolean
validate (WirelessSecurity *parent, GError **error)
{
- return ws_802_1x_validate (GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "auth_combo")),
error);
+ WirelessSecurityDynamicWEP *self = (WirelessSecurityDynamicWEP *) parent;
+ return ws_802_1x_validate (self->auth_combo, error);
}
static void
@@ -65,17 +72,16 @@ add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group)
g_object_unref (sec->size_group);
sec->size_group = g_object_ref (group);
- ws_802_1x_add_to_size_group (sec->size_group,
- GTK_LABEL (gtk_builder_get_object (parent->builder, "auth_label")),
- GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "auth_combo")));
+ ws_802_1x_add_to_size_group (sec->size_group, sec->auth_label, sec->auth_combo);
}
static void
fill_connection (WirelessSecurity *parent, NMConnection *connection)
{
+ WirelessSecurityDynamicWEP *self = (WirelessSecurityDynamicWEP *) parent;
NMSettingWirelessSecurity *s_wireless_sec;
- ws_802_1x_fill_connection (GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "auth_combo")),
connection);
+ ws_802_1x_fill_connection (self->auth_combo, connection);
s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
g_assert (s_wireless_sec);
@@ -91,7 +97,7 @@ auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
ws_802_1x_auth_combo_changed (combo,
parent,
- GTK_BOX (gtk_builder_get_object (parent->builder, "method_box")),
+ sec->method_box,
sec->size_group);
}
@@ -101,6 +107,7 @@ ws_dynamic_wep_new (NMConnection *connection,
gboolean secrets_only)
{
WirelessSecurity *parent;
+ WirelessSecurityDynamicWEP *self;
parent = wireless_security_init (sizeof (WirelessSecurityDynamicWEP),
get_widget,
@@ -111,18 +118,24 @@ ws_dynamic_wep_new (NMConnection *connection,
"/org/gnome/ControlCenter/network/ws-dynamic-wep.ui");
if (!parent)
return NULL;
+ self = (WirelessSecurityDynamicWEP *) parent;
+
+ self->auth_combo = GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "auth_combo"));
+ self->auth_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "auth_label"));
+ self->method_box = GTK_BOX (gtk_builder_get_object (parent->builder, "method_box"));
+ self->notebook = GTK_NOTEBOOK (gtk_builder_get_object (parent->builder, "notebook"));
wireless_security_set_adhoc_compatible (parent, FALSE);
wireless_security_set_hotspot_compatible (parent, FALSE);
ws_802_1x_auth_combo_init (parent,
- GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "auth_combo")),
- GTK_LABEL (gtk_builder_get_object (parent->builder, "auth_label")),
+ self->auth_combo,
+ self->auth_label,
(GCallback) auth_combo_changed_cb,
connection,
is_editor,
secrets_only);
- auth_combo_changed_cb (GTK_WIDGET (gtk_builder_get_object (parent->builder, "auth_combo")),
(gpointer) parent);
+ auth_combo_changed_cb (GTK_WIDGET (self->auth_combo), (gpointer) parent);
return (WirelessSecurityDynamicWEP *) parent;
}
diff --git a/panels/network/wireless-security/ws-leap.c b/panels/network/wireless-security/ws-leap.c
index 827c7d0bb..82823a65f 100644
--- a/panels/network/wireless-security/ws-leap.c
+++ b/panels/network/wireless-security/ws-leap.c
@@ -32,6 +32,14 @@
struct _WirelessSecurityLEAP {
WirelessSecurity parent;
+
+ GtkNotebook *notebook;
+ GtkEntry *password_entry;
+ GtkLabel *password_label;
+ GtkCheckButton *show_password_check;
+ GtkEntry *username_entry;
+ GtkLabel *username_label;
+
gboolean editing_connection;
const char *password_flags_name;
};
@@ -39,51 +47,43 @@ struct _WirelessSecurityLEAP {
static void
show_toggled_cb (WirelessSecurityLEAP *self)
{
- WirelessSecurity *sec = (WirelessSecurity *) self;
- GtkWidget *widget;
gboolean visible;
- widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "show_password_check"));
- visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-
- widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "password_entry"));
- gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
+ visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->show_password_check));
+ gtk_entry_set_visibility (self->password_entry, visible);
}
static GtkWidget *
get_widget (WirelessSecurity *parent)
{
- return GTK_WIDGET (gtk_builder_get_object (parent->builder, "notebook"));
+ WirelessSecurityLEAP *self = (WirelessSecurityLEAP *) parent;
+ return GTK_WIDGET (self->notebook);
}
static gboolean
validate (WirelessSecurity *parent, GError **error)
{
- GtkWidget *entry;
+ WirelessSecurityLEAP *self = (WirelessSecurityLEAP *) parent;
const char *text;
gboolean ret = TRUE;
- entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "username_entry"));
- g_assert (entry);
- text = gtk_entry_get_text (GTK_ENTRY (entry));
+ text = gtk_entry_get_text (self->username_entry);
if (!text || !strlen (text)) {
- widget_set_error (entry);
+ widget_set_error (GTK_WIDGET (self->username_entry));
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing leap-username"));
ret = FALSE;
} else
- widget_unset_error (entry);
+ widget_unset_error (GTK_WIDGET (self->username_entry));
- entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "password_entry"));
- g_assert (entry);
- text = gtk_entry_get_text (GTK_ENTRY (entry));
+ text = gtk_entry_get_text (self->password_entry);
if (!text || !strlen (text)) {
- widget_set_error (entry);
+ widget_set_error (GTK_WIDGET (self->password_entry));
if (ret) {
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing leap-password"));
ret = FALSE;
}
} else
- widget_unset_error (entry);
+ widget_unset_error (GTK_WIDGET (self->password_entry));
return ret;
}
@@ -91,13 +91,9 @@ validate (WirelessSecurity *parent, GError **error)
static void
add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group)
{
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "username_label"));
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "password_label"));
- gtk_size_group_add_widget (group, widget);
+ WirelessSecurityLEAP *sec = (WirelessSecurityLEAP *) parent;
+ gtk_size_group_add_widget (group, GTK_WIDGET (sec->username_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (sec->password_label));
}
static void
@@ -106,19 +102,14 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
WirelessSecurityLEAP *sec = (WirelessSecurityLEAP *) parent;
NMSettingWirelessSecurity *s_wireless_sec;
NMSettingSecretFlags secret_flags;
- GtkWidget *widget, *passwd_entry;
const char *leap_password = NULL, *leap_username = NULL;
/* Blow away the old security setting by adding a clear one */
s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "username_entry"));
- leap_username = gtk_entry_get_text (GTK_ENTRY (widget));
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "password_entry"));
- passwd_entry = widget;
- leap_password = gtk_entry_get_text (GTK_ENTRY (widget));
+ leap_username = gtk_entry_get_text (sec->username_entry);
+ leap_password = gtk_entry_get_text (sec->password_entry);
g_object_set (s_wireless_sec,
NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x",
@@ -128,21 +119,22 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
NULL);
/* Save LEAP_PASSWORD_FLAGS to the connection */
- secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
+ secret_flags = nma_utils_menu_to_secret_flags (GTK_WIDGET (sec->password_entry));
nm_setting_set_secret_flags (NM_SETTING (s_wireless_sec), sec->password_flags_name,
secret_flags, NULL);
/* Update secret flags and popup when editing the connection */
if (sec->editing_connection)
- nma_utils_update_password_storage (passwd_entry, secret_flags,
+ nma_utils_update_password_storage (GTK_WIDGET (sec->password_entry), secret_flags,
NM_SETTING (s_wireless_sec), sec->password_flags_name);
}
static void
update_secrets (WirelessSecurity *parent, NMConnection *connection)
{
+ WirelessSecurityLEAP *self = (WirelessSecurityLEAP *) parent;
helper_fill_secret_entry (connection,
- GTK_ENTRY (gtk_builder_get_object (parent->builder, "password_entry")),
+ self->password_entry,
NM_TYPE_SETTING_WIRELESS_SECURITY,
(HelperSecretFunc) nm_setting_wireless_security_get_leap_password);
}
@@ -158,7 +150,6 @@ ws_leap_new (NMConnection *connection, gboolean secrets_only)
{
WirelessSecurity *parent;
WirelessSecurityLEAP *sec;
- GtkWidget *widget;
NMSettingWirelessSecurity *wsec = NULL;
parent = wireless_security_init (sizeof (WirelessSecurityLEAP),
@@ -189,29 +180,30 @@ ws_leap_new (NMConnection *connection, gboolean secrets_only)
sec->editing_connection = secrets_only ? FALSE : TRUE;
sec->password_flags_name = NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD;
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "password_entry"));
- g_assert (widget);
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), sec);
+ sec->notebook = GTK_NOTEBOOK (gtk_builder_get_object (parent->builder, "notebook"));
+ sec->password_entry = GTK_ENTRY (gtk_builder_get_object (parent->builder, "password_entry"));
+ sec->password_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "password_label"));
+ sec->show_password_check = GTK_CHECK_BUTTON (gtk_builder_get_object (parent->builder,
"show_password_check"));
+ sec->username_entry = GTK_ENTRY (gtk_builder_get_object (parent->builder, "username_entry"));
+ sec->username_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "username_label"));
+
+ g_signal_connect_swapped (sec->password_entry, "changed", G_CALLBACK (changed_cb), sec);
/* Create password-storage popup menu for password entry under entry's secondary icon */
- nma_utils_setup_password_storage (widget, 0, (NMSetting *) wsec, sec->password_flags_name,
+ nma_utils_setup_password_storage (GTK_WIDGET (sec->password_entry), 0, (NMSetting *) wsec,
sec->password_flags_name,
FALSE, secrets_only);
if (wsec)
update_secrets (WIRELESS_SECURITY (sec), connection);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "username_entry"));
- g_assert (widget);
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), sec);
+ g_signal_connect_swapped (sec->username_entry, "changed", G_CALLBACK (changed_cb), sec);
if (wsec)
- gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_wireless_security_get_leap_username
(wsec));
+ gtk_entry_set_text (sec->username_entry, nm_setting_wireless_security_get_leap_username
(wsec));
if (secrets_only)
- gtk_widget_hide (widget);
+ gtk_widget_hide (GTK_WIDGET (sec->username_entry));
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_password_check"));
- g_assert (widget);
- g_signal_connect_swapped (widget, "toggled", G_CALLBACK (show_toggled_cb), sec);
+ g_signal_connect_swapped (sec->show_password_check, "toggled", G_CALLBACK (show_toggled_cb), sec);
return sec;
}
diff --git a/panels/network/wireless-security/ws-wep-key.c b/panels/network/wireless-security/ws-wep-key.c
index 867cd9c58..a44dffc63 100644
--- a/panels/network/wireless-security/ws-wep-key.c
+++ b/panels/network/wireless-security/ws-wep-key.c
@@ -33,6 +33,15 @@
struct _WirelessSecurityWEPKey {
WirelessSecurity parent;
+ GtkComboBox *auth_method_combo;
+ GtkLabel *auth_method_label;
+ GtkNotebook *notebook;
+ GtkEntry *key_entry;
+ GtkComboBox *key_index_combo;
+ GtkLabel *key_index_label;
+ GtkLabel *key_label;
+ GtkCheckButton *show_key_check;
+
gboolean editing_connection;
const char *password_flags_name;
@@ -44,44 +53,34 @@ struct _WirelessSecurityWEPKey {
static void
show_toggled_cb (WirelessSecurityWEPKey *self)
{
- WirelessSecurity *parent = (WirelessSecurity *) self;
- GtkWidget *widget, *button;
gboolean visible;
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_entry"));
- g_assert (widget);
-
- button = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_key_check"));
- visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
- gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
+ visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->show_key_check));
+ gtk_entry_set_visibility (self->key_entry, visible);
}
static void
key_index_combo_changed_cb (WirelessSecurityWEPKey *self)
{
- WirelessSecurity *parent = (WirelessSecurity *) self;
- GtkWidget *combo, *entry;
const char *key;
int key_index;
/* Save WEP key for old key index */
- entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_entry"));
- key = gtk_entry_get_text (GTK_ENTRY (entry));
+ key = gtk_entry_get_text (self->key_entry);
if (key)
g_strlcpy (self->keys[self->cur_index], key, sizeof (self->keys[self->cur_index]));
else
memset (self->keys[self->cur_index], 0, sizeof (self->keys[self->cur_index]));
- combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_index_combo"));
- key_index = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
+ key_index = gtk_combo_box_get_active (self->key_index_combo);
g_return_if_fail (key_index <= 3);
g_return_if_fail (key_index >= 0);
/* Populate entry with key from new index */
- gtk_entry_set_text (GTK_ENTRY (entry), self->keys[key_index]);
+ gtk_entry_set_text (self->key_entry, self->keys[key_index]);
self->cur_index = key_index;
- wireless_security_notify_changed (parent);
+ wireless_security_notify_changed ((WirelessSecurity *) self);
}
static void
@@ -97,23 +96,20 @@ destroy (WirelessSecurity *parent)
static GtkWidget *
get_widget (WirelessSecurity *parent)
{
- return GTK_WIDGET (gtk_builder_get_object (parent->builder, "notebook"));
+ WirelessSecurityWEPKey *self = (WirelessSecurityWEPKey *) parent;
+ return GTK_WIDGET (self->notebook);
}
static gboolean
validate (WirelessSecurity *parent, GError **error)
{
WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) parent;
- GtkWidget *entry;
const char *key;
int i;
- entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_entry"));
- g_assert (entry);
-
- key = gtk_entry_get_text (GTK_ENTRY (entry));
+ key = gtk_entry_get_text (sec->key_entry);
if (!key) {
- widget_set_error (entry);
+ widget_set_error (GTK_WIDGET (sec->key_entry));
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("missing wep-key"));
return FALSE;
}
@@ -122,7 +118,7 @@ validate (WirelessSecurity *parent, GError **error)
if ((strlen (key) == 10) || (strlen (key) == 26)) {
for (i = 0; i < strlen (key); i++) {
if (!g_ascii_isxdigit (key[i])) {
- widget_set_error (entry);
+ widget_set_error (GTK_WIDGET (sec->key_entry));
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wep-key:
key with a length of %zu must contain only hex-digits"), strlen (key));
return FALSE;
}
@@ -130,19 +126,19 @@ validate (WirelessSecurity *parent, GError **error)
} else if ((strlen (key) == 5) || (strlen (key) == 13)) {
for (i = 0; i < strlen (key); i++) {
if (!g_ascii_isprint (key[i])) {
- widget_set_error (entry);
+ widget_set_error (GTK_WIDGET (sec->key_entry));
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wep-key:
key with a length of %zu must contain only ascii characters"), strlen (key));
return FALSE;
}
}
} else {
- widget_set_error (entry);
+ widget_set_error (GTK_WIDGET (sec->key_entry));
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wep-key: wrong key
length %zu. A key must be either of length 5/13 (ascii) or 10/26 (hex)"), strlen (key));
return FALSE;
}
} else if (sec->type == NM_WEP_KEY_TYPE_PASSPHRASE) {
if (!*key || (strlen (key) > 64)) {
- widget_set_error (entry);
+ widget_set_error (GTK_WIDGET (sec->key_entry));
if (!*key)
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wep-key:
passphrase must be non-empty"));
else
@@ -150,7 +146,7 @@ validate (WirelessSecurity *parent, GError **error)
return FALSE;
}
}
- widget_unset_error (entry);
+ widget_unset_error (GTK_WIDGET (sec->key_entry));
return TRUE;
}
@@ -158,16 +154,10 @@ validate (WirelessSecurity *parent, GError **error)
static void
add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group)
{
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "auth_method_label"));
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_label"));
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_index_label"));
- gtk_size_group_add_widget (group, widget);
+ WirelessSecurityWEPKey *self = (WirelessSecurityWEPKey *) parent;
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->auth_method_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->key_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->key_index_label));
}
static void
@@ -176,17 +166,13 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) parent;
NMSettingWirelessSecurity *s_wsec;
NMSettingSecretFlags secret_flags;
- GtkWidget *widget, *passwd_entry;
gint auth_alg;
const char *key;
int i;
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "auth_method_combo"));
- auth_alg = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
+ auth_alg = gtk_combo_box_get_active (sec->auth_method_combo);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_entry"));
- passwd_entry = widget;
- key = gtk_entry_get_text (GTK_ENTRY (widget));
+ key = gtk_entry_get_text (sec->key_entry);
g_strlcpy (sec->keys[sec->cur_index], key, sizeof (sec->keys[sec->cur_index]));
/* Blow away the old security setting by adding a clear one */
@@ -206,12 +192,12 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
}
/* Save WEP_KEY_FLAGS to the connection */
- secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
+ secret_flags = nma_utils_menu_to_secret_flags (GTK_WIDGET (sec->key_entry));
g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, secret_flags, NULL);
/* Update secret flags and popup when editing the connection */
if (sec->editing_connection)
- nma_utils_update_password_storage (passwd_entry, secret_flags,
+ nma_utils_update_password_storage (GTK_WIDGET (sec->key_entry), secret_flags,
NM_SETTING (s_wsec), sec->password_flags_name);
}
@@ -221,10 +207,6 @@ wep_entry_filter_cb (WirelessSecurityWEPKey *self,
gint length,
gint *position)
{
- WirelessSecurity *parent = (WirelessSecurity *) self;
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_entry"));
if (self->type == NM_WEP_KEY_TYPE_KEY) {
int i, count = 0;
g_autofree gchar *result = g_new (gchar, length+1);
@@ -236,11 +218,11 @@ wep_entry_filter_cb (WirelessSecurityWEPKey *self,
result[count] = 0;
if (count > 0) {
- g_signal_handlers_block_by_func (widget, G_CALLBACK (wep_entry_filter_cb), self);
- gtk_editable_insert_text (GTK_EDITABLE (widget), result, count, position);
- g_signal_handlers_unblock_by_func (widget, G_CALLBACK (wep_entry_filter_cb), self);
+ g_signal_handlers_block_by_func (self->key_entry, G_CALLBACK (wep_entry_filter_cb),
self);
+ gtk_editable_insert_text (GTK_EDITABLE (self->key_entry), result, count, position);
+ g_signal_handlers_unblock_by_func (self->key_entry, G_CALLBACK (wep_entry_filter_cb),
self);
}
- g_signal_stop_emission_by_name (widget, "insert-text");
+ g_signal_stop_emission_by_name (self->key_entry, "insert-text");
}
}
@@ -249,7 +231,6 @@ update_secrets (WirelessSecurity *parent, NMConnection *connection)
{
WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) parent;
NMSettingWirelessSecurity *s_wsec;
- GtkWidget *widget;
const char *tmp;
int i;
@@ -260,9 +241,8 @@ update_secrets (WirelessSecurity *parent, NMConnection *connection)
g_strlcpy (sec->keys[i], tmp, sizeof (sec->keys[i]));
}
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_entry"));
if (strlen (sec->keys[sec->cur_index]))
- gtk_entry_set_text (GTK_ENTRY (widget), sec->keys[sec->cur_index]);
+ gtk_entry_set_text (sec->key_entry, sec->keys[sec->cur_index]);
}
static void
@@ -279,7 +259,6 @@ ws_wep_key_new (NMConnection *connection,
{
WirelessSecurity *parent;
WirelessSecurityWEPKey *sec;
- GtkWidget *widget;
NMSettingWirelessSecurity *s_wsec = NULL;
NMSetting *setting = NULL;
guint8 default_key_idx = 0;
@@ -295,20 +274,27 @@ ws_wep_key_new (NMConnection *connection,
"/org/gnome/ControlCenter/network/ws-wep-key.ui");
if (!parent)
return NULL;
-
sec = (WirelessSecurityWEPKey *) parent;
+
+ sec->auth_method_combo = GTK_COMBO_BOX (gtk_builder_get_object (parent->builder,
"auth_method_combo"));
+ sec->auth_method_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "auth_method_label"));
+ sec->key_entry = GTK_ENTRY (gtk_builder_get_object (parent->builder, "key_entry"));
+ sec->key_index_combo = GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "key_index_combo"));
+ sec->key_index_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "key_index_label"));
+ sec->key_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "key_label"));
+ sec->notebook = GTK_NOTEBOOK (gtk_builder_get_object (parent->builder, "notebook"));
+ sec->show_key_check = GTK_CHECK_BUTTON (gtk_builder_get_object (parent->builder, "show_key_check"));
+
sec->editing_connection = secrets_only ? FALSE : TRUE;
sec->password_flags_name = NM_SETTING_WIRELESS_SECURITY_WEP_KEY0;
sec->type = type;
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_entry"));
- g_assert (widget);
- gtk_entry_set_width_chars (GTK_ENTRY (widget), 28);
+ gtk_entry_set_width_chars (sec->key_entry, 28);
/* Create password-storage popup menu for password entry under entry's secondary icon */
if (connection)
setting = (NMSetting *) nm_connection_get_setting_wireless_security (connection);
- nma_utils_setup_password_storage (widget, 0, setting, sec->password_flags_name,
+ nma_utils_setup_password_storage (GTK_WIDGET (sec->key_entry), 0, setting, sec->password_flags_name,
FALSE, secrets_only);
if (connection) {
@@ -328,40 +314,35 @@ ws_wep_key_new (NMConnection *connection,
}
}
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), sec);
- g_signal_connect_swapped (widget, "insert-text", G_CALLBACK (wep_entry_filter_cb), sec);
+ g_signal_connect_swapped (sec->key_entry, "changed", G_CALLBACK (changed_cb), sec);
+ g_signal_connect_swapped (sec->key_entry, "insert-text", G_CALLBACK (wep_entry_filter_cb), sec);
if (sec->type == NM_WEP_KEY_TYPE_KEY)
- gtk_entry_set_max_length (GTK_ENTRY (widget), 26);
+ gtk_entry_set_max_length (sec->key_entry, 26);
else if (sec->type == NM_WEP_KEY_TYPE_PASSPHRASE)
- gtk_entry_set_max_length (GTK_ENTRY (widget), 64);
+ gtk_entry_set_max_length (sec->key_entry, 64);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_index_combo"));
if (connection && s_wsec)
default_key_idx = nm_setting_wireless_security_get_wep_tx_keyidx (s_wsec);
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), default_key_idx);
+ gtk_combo_box_set_active (sec->key_index_combo, default_key_idx);
sec->cur_index = default_key_idx;
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (key_index_combo_changed_cb), sec);
+ g_signal_connect_swapped (sec->key_index_combo, "changed", G_CALLBACK (key_index_combo_changed_cb),
sec);
/* Key index is useless with adhoc networks */
if (is_adhoc || secrets_only) {
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "key_index_label"));
- gtk_widget_hide (widget);
+ gtk_widget_hide (GTK_WIDGET (sec->key_index_combo));
+ gtk_widget_hide (GTK_WIDGET (sec->key_index_label));
}
/* Fill the key entry with the key for that index */
if (connection)
update_secrets (WIRELESS_SECURITY (sec), connection);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_key_check"));
- g_assert (widget);
- g_signal_connect_swapped (widget, "toggled", G_CALLBACK (show_toggled_cb), sec);
+ g_signal_connect_swapped (sec->show_key_check, "toggled", G_CALLBACK (show_toggled_cb), sec);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "auth_method_combo"));
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), is_shared_key ? 1 : 0);
+ gtk_combo_box_set_active (sec->auth_method_combo, is_shared_key ? 1 : 0);
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), sec);
+ g_signal_connect_swapped (sec->auth_method_combo, "changed", G_CALLBACK (changed_cb), sec);
/* Don't show auth method for adhoc (which always uses open-system) or
* when in "simple" mode.
@@ -369,10 +350,9 @@ ws_wep_key_new (NMConnection *connection,
if (is_adhoc || secrets_only) {
/* Ad-Hoc connections can't use Shared Key auth */
if (is_adhoc)
- gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "auth_method_label"));
- gtk_widget_hide (widget);
+ gtk_combo_box_set_active (sec->auth_method_combo, 0);
+ gtk_widget_hide (GTK_WIDGET (sec->auth_method_combo));
+ gtk_widget_hide (GTK_WIDGET (sec->auth_method_label));
}
return sec;
diff --git a/panels/network/wireless-security/ws-wpa-eap.c b/panels/network/wireless-security/ws-wpa-eap.c
index 3cf524030..f8b5883e6 100644
--- a/panels/network/wireless-security/ws-wpa-eap.c
+++ b/panels/network/wireless-security/ws-wpa-eap.c
@@ -32,6 +32,11 @@
struct _WirelessSecurityWPAEAP {
WirelessSecurity parent;
+ GtkComboBox *auth_combo;
+ GtkLabel *auth_label;
+ GtkBox *method_box;
+ GtkNotebook *notebook;
+
GtkSizeGroup *size_group;
};
@@ -48,13 +53,15 @@ destroy (WirelessSecurity *parent)
static GtkWidget *
get_widget (WirelessSecurity *parent)
{
- return GTK_WIDGET (gtk_builder_get_object (parent->builder, "notebook"));
+ WirelessSecurityWPAEAP *self = (WirelessSecurityWPAEAP *) parent;
+ return GTK_WIDGET (self->notebook);
}
static gboolean
validate (WirelessSecurity *parent, GError **error)
{
- return ws_802_1x_validate (GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "auth_combo")),
error);
+ WirelessSecurityWPAEAP *self = (WirelessSecurityWPAEAP *) parent;
+ return ws_802_1x_validate (self->auth_combo, error);
}
static void
@@ -66,17 +73,16 @@ add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group)
g_object_unref (sec->size_group);
sec->size_group = g_object_ref (group);
- ws_802_1x_add_to_size_group (sec->size_group,
- GTK_LABEL (gtk_builder_get_object (parent->builder, "auth_label")),
- GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "auth_combo")));
+ ws_802_1x_add_to_size_group (sec->size_group, sec->auth_label, sec->auth_combo);
}
static void
fill_connection (WirelessSecurity *parent, NMConnection *connection)
{
+ WirelessSecurityWPAEAP *self = (WirelessSecurityWPAEAP *) parent;
NMSettingWirelessSecurity *s_wireless_sec;
- ws_802_1x_fill_connection (GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "auth_combo")),
connection);
+ ws_802_1x_fill_connection (self->auth_combo, connection);
s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
g_assert (s_wireless_sec);
@@ -92,7 +98,7 @@ auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
ws_802_1x_auth_combo_changed (combo,
parent,
- GTK_BOX (gtk_builder_get_object (parent->builder, "method_box")),
+ sec->method_box,
sec->size_group);
}
@@ -102,6 +108,7 @@ ws_wpa_eap_new (NMConnection *connection,
gboolean secrets_only)
{
WirelessSecurity *parent;
+ WirelessSecurityWPAEAP *self;
parent = wireless_security_init (sizeof (WirelessSecurityWPAEAP),
get_widget,
@@ -112,18 +119,24 @@ ws_wpa_eap_new (NMConnection *connection,
"/org/gnome/ControlCenter/network/ws-wpa-eap.ui");
if (!parent)
return NULL;
+ self = (WirelessSecurityWPAEAP *) parent;
+
+ self->auth_combo = GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "auth_combo"));
+ self->auth_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "auth_label"));
+ self->method_box = GTK_BOX (gtk_builder_get_object (parent->builder, "method_box"));
+ self->notebook = GTK_NOTEBOOK (gtk_builder_get_object (parent->builder, "notebook"));
wireless_security_set_adhoc_compatible (parent, FALSE);
wireless_security_set_hotspot_compatible (parent, FALSE);
ws_802_1x_auth_combo_init (parent,
- GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "auth_combo")),
- GTK_LABEL (gtk_builder_get_object (parent->builder, "auth_label")),
+ self->auth_combo,
+ self->auth_label,
(GCallback) auth_combo_changed_cb,
connection,
is_editor,
secrets_only);
- auth_combo_changed_cb (GTK_WIDGET (gtk_builder_get_object (parent->builder, "auth_combo")), parent);
+ auth_combo_changed_cb (GTK_WIDGET (self->auth_combo), parent);
return (WirelessSecurityWPAEAP *) parent;
}
diff --git a/panels/network/wireless-security/ws-wpa-psk.c b/panels/network/wireless-security/ws-wpa-psk.c
index 8cdc68785..a1e36ba8c 100644
--- a/panels/network/wireless-security/ws-wpa-psk.c
+++ b/panels/network/wireless-security/ws-wpa-psk.c
@@ -36,6 +36,13 @@
struct _WirelessSecurityWPAPSK {
WirelessSecurity parent;
+ GtkNotebook *notebook;
+ GtkEntry *password_entry;
+ GtkLabel *password_label;
+ GtkCheckButton *show_password_check;
+ GtkComboBox *type_combo;
+ GtkLabel *type_label;
+
gboolean editing_connection;
const char *password_flags_name;
};
@@ -43,38 +50,31 @@ struct _WirelessSecurityWPAPSK {
static GtkWidget *
get_widget (WirelessSecurity *parent)
{
- return GTK_WIDGET (gtk_builder_get_object (parent->builder, "notebook"));
+ WirelessSecurityWPAPSK *self = (WirelessSecurityWPAPSK *) parent;
+ return GTK_WIDGET (self->notebook);
}
static void
show_toggled_cb (WirelessSecurityWPAPSK *self)
{
- WirelessSecurity *sec = (WirelessSecurity *) self;
- GtkWidget *widget;
gboolean visible;
- widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "show_password_check"));
- visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-
- widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "password_entry"));
- gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
+ visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->show_password_check));
+ gtk_entry_set_visibility (self->password_entry, visible);
}
static gboolean
validate (WirelessSecurity *parent, GError **error)
{
- GtkWidget *entry;
+ WirelessSecurityWPAPSK *self = (WirelessSecurityWPAPSK *) parent;
const char *key;
gsize len;
int i;
- entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "password_entry"));
- g_assert (entry);
-
- key = gtk_entry_get_text (GTK_ENTRY (entry));
+ key = gtk_entry_get_text (self->password_entry);
len = key ? strlen (key) : 0;
if ((len < 8) || (len > 64)) {
- widget_set_error (entry);
+ widget_set_error (GTK_WIDGET (self->password_entry));
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wpa-psk: invalid key-length %zu.
Must be [8,63] bytes or 64 hex digits"), len);
return FALSE;
}
@@ -83,13 +83,13 @@ validate (WirelessSecurity *parent, GError **error)
/* Hex PSK */
for (i = 0; i < len; i++) {
if (!isxdigit (key[i])) {
- widget_set_error (entry);
+ widget_set_error (GTK_WIDGET (self->password_entry));
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid wpa-psk:
cannot interpret key with 64 bytes as hex"));
return FALSE;
}
}
}
- widget_unset_error (entry);
+ widget_unset_error (GTK_WIDGET (self->password_entry));
/* passphrase can be between 8 and 63 characters inclusive */
@@ -99,20 +99,15 @@ validate (WirelessSecurity *parent, GError **error)
static void
add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group)
{
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "type_label"));
- gtk_size_group_add_widget (group, widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "password_label"));
- gtk_size_group_add_widget (group, widget);
+ WirelessSecurityWPAPSK *self = (WirelessSecurityWPAPSK *) parent;
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->type_label));
+ gtk_size_group_add_widget (group, GTK_WIDGET (self->password_label));
}
static void
fill_connection (WirelessSecurity *parent, NMConnection *connection)
{
WirelessSecurityWPAPSK *wpa_psk = (WirelessSecurityWPAPSK *) parent;
- GtkWidget *widget, *passwd_entry;
const char *key;
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
@@ -131,19 +126,17 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "password_entry"));
- passwd_entry = widget;
- key = gtk_entry_get_text (GTK_ENTRY (widget));
+ key = gtk_entry_get_text (wpa_psk->password_entry);
g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_PSK, key, NULL);
/* Save PSK_FLAGS to the connection */
- secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);
+ secret_flags = nma_utils_menu_to_secret_flags (GTK_WIDGET (wpa_psk->password_entry));
nm_setting_set_secret_flags (NM_SETTING (s_wireless_sec), NM_SETTING_WIRELESS_SECURITY_PSK,
secret_flags, NULL);
/* Update secret flags and popup when editing the connection */
if (wpa_psk->editing_connection)
- nma_utils_update_password_storage (passwd_entry, secret_flags,
+ nma_utils_update_password_storage (GTK_WIDGET (wpa_psk->password_entry), secret_flags,
NM_SETTING (s_wireless_sec), wpa_psk->password_flags_name);
wireless_security_clear_ciphers (connection);
@@ -169,8 +162,9 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
static void
update_secrets (WirelessSecurity *parent, NMConnection *connection)
{
+ WirelessSecurityWPAPSK *self = (WirelessSecurityWPAPSK *) parent;
helper_fill_secret_entry (connection,
- GTK_ENTRY (gtk_builder_get_object (parent->builder, "password_entry")),
+ self->password_entry,
NM_TYPE_SETTING_WIRELESS_SECURITY,
(HelperSecretFunc) nm_setting_wireless_security_get_psk);
}
@@ -187,7 +181,6 @@ ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only)
WirelessSecurity *parent;
WirelessSecurityWPAPSK *sec;
NMSetting *setting = NULL;
- GtkWidget *widget;
parent = wireless_security_init (sizeof (WirelessSecurityWPAPSK),
get_widget,
@@ -198,42 +191,41 @@ ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only)
"/org/gnome/ControlCenter/network/ws-wpa-psk.ui");
if (!parent)
return NULL;
+ sec = (WirelessSecurityWPAPSK *) parent;
+
+ sec->notebook = GTK_NOTEBOOK (gtk_builder_get_object (parent->builder, "notebook"));
+ sec->password_entry = GTK_ENTRY (gtk_builder_get_object (parent->builder, "password_entry"));
+ sec->password_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "password_label"));
+ sec->show_password_check = GTK_CHECK_BUTTON (gtk_builder_get_object (parent->builder,
"show_password_check"));
+ sec->type_combo = GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "type_combo"));
+ sec->type_label = GTK_LABEL (gtk_builder_get_object (parent->builder, "type_label"));
wireless_security_set_adhoc_compatible (parent, FALSE);
- sec = (WirelessSecurityWPAPSK *) parent;
+
sec->editing_connection = secrets_only ? FALSE : TRUE;
sec->password_flags_name = NM_SETTING_WIRELESS_SECURITY_PSK;
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "password_entry"));
- g_assert (widget);
- g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), sec);
- gtk_entry_set_width_chars (GTK_ENTRY (widget), 28);
+ g_signal_connect_swapped (sec->password_entry, "changed", G_CALLBACK (changed_cb), sec);
+ gtk_entry_set_width_chars (sec->password_entry, 28);
/* Create password-storage popup menu for password entry under entry's secondary icon */
if (connection)
setting = (NMSetting *) nm_connection_get_setting_wireless_security (connection);
- nma_utils_setup_password_storage (widget, 0, setting, sec->password_flags_name,
+ nma_utils_setup_password_storage (GTK_WIDGET (sec->password_entry), 0, setting,
sec->password_flags_name,
FALSE, secrets_only);
/* Fill secrets, if any */
if (connection)
update_secrets (WIRELESS_SECURITY (sec), connection);
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_password_check"));
- g_assert (widget);
- g_signal_connect_swapped (widget, "toggled", G_CALLBACK (show_toggled_cb), sec);
+ g_signal_connect_swapped (sec->show_password_check, "toggled", G_CALLBACK (show_toggled_cb), sec);
/* Hide WPA/RSN for now since this can be autodetected by NM and the
* supplicant when connecting to the AP.
*/
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "type_combo"));
- g_assert (widget);
- gtk_widget_hide (widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "type_label"));
- g_assert (widget);
- gtk_widget_hide (widget);
+ gtk_widget_hide (GTK_WIDGET (sec->type_combo));
+ gtk_widget_hide (GTK_WIDGET (sec->type_label));
return sec;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]