[gnome-control-center] network: Simplify helper function
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Simplify helper function
- Date: Wed, 27 Nov 2019 22:09:38 +0000 (UTC)
commit f2111a85f54886c304b411fb4eb609979a392aeb
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Nov 8 09:56:00 2019 +1300
network: Simplify helper function
panels/network/wireless-security/wireless-security.c | 11 +----------
panels/network/wireless-security/wireless-security.h | 4 +---
panels/network/wireless-security/ws-dynamic-wep.c | 20 +++++++++++---------
panels/network/wireless-security/ws-wpa-eap.c | 20 +++++++++++---------
4 files changed, 24 insertions(+), 31 deletions(-)
---
diff --git a/panels/network/wireless-security/wireless-security.c
b/panels/network/wireless-security/wireless-security.c
index d5897299b..199cd1f77 100644
--- a/panels/network/wireless-security/wireless-security.c
+++ b/panels/network/wireless-security/wireless-security.c
@@ -402,7 +402,7 @@ ws_802_1x_validate (GtkComboBox *combo, GError **error)
}
void
-ws_802_1x_auth_combo_changed (GtkWidget *combo,
+ws_802_1x_auth_combo_changed (GtkComboBox *combo,
WirelessSecurity *self,
GtkBox *vbox,
GtkSizeGroup *size_group)
@@ -441,8 +441,6 @@ ws_802_1x_auth_combo_changed (GtkWidget *combo,
void
ws_802_1x_auth_combo_init (WirelessSecurity *self,
GtkComboBox *combo,
- GtkLabel *label,
- GCallback auth_combo_changed_cb,
NMConnection *connection,
gboolean is_editor,
gboolean secrets_only)
@@ -566,13 +564,6 @@ ws_802_1x_auth_combo_init (WirelessSecurity *self,
gtk_combo_box_set_model (combo, GTK_TREE_MODEL (auth_model));
gtk_combo_box_set_active (combo, active < 0 ? 0 : (guint32) active);
-
- g_signal_connect (G_OBJECT (combo), "changed", auth_combo_changed_cb, self);
-
- if (secrets_only) {
- gtk_widget_hide (GTK_WIDGET (combo));
- gtk_widget_hide (GTK_WIDGET (label));
- }
}
void
diff --git a/panels/network/wireless-security/wireless-security.h
b/panels/network/wireless-security/wireless-security.h
index 065a8fc8e..6db979a1d 100644
--- a/panels/network/wireless-security/wireless-security.h
+++ b/panels/network/wireless-security/wireless-security.h
@@ -111,13 +111,11 @@ void wireless_security_clear_ciphers (NMConnection *connection);
void ws_802_1x_auth_combo_init (WirelessSecurity *sec,
GtkComboBox *combo,
- GtkLabel *label,
- GCallback auth_combo_changed_cb,
NMConnection *connection,
gboolean is_editor,
gboolean secrets_only);
-void ws_802_1x_auth_combo_changed (GtkWidget *combo,
+void ws_802_1x_auth_combo_changed (GtkComboBox *combo,
WirelessSecurity *sec,
GtkBox *vbox,
GtkSizeGroup *size_group);
diff --git a/panels/network/wireless-security/ws-dynamic-wep.c
b/panels/network/wireless-security/ws-dynamic-wep.c
index 46fa9eda1..85ff5502e 100644
--- a/panels/network/wireless-security/ws-dynamic-wep.c
+++ b/panels/network/wireless-security/ws-dynamic-wep.c
@@ -88,13 +88,10 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
}
static void
-auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
+auth_combo_changed_cb (WirelessSecurityDynamicWEP *self)
{
- WirelessSecurity *parent = WIRELESS_SECURITY (user_data);
- WirelessSecurityDynamicWEP *self = (WirelessSecurityDynamicWEP *) parent;
-
- ws_802_1x_auth_combo_changed (combo,
- parent,
+ ws_802_1x_auth_combo_changed (self->auth_combo,
+ WIRELESS_SECURITY (self),
self->method_box,
self->size_group);
}
@@ -128,12 +125,17 @@ ws_dynamic_wep_new (NMConnection *connection,
ws_802_1x_auth_combo_init (parent,
self->auth_combo,
- self->auth_label,
- (GCallback) auth_combo_changed_cb,
connection,
is_editor,
secrets_only);
- auth_combo_changed_cb (GTK_WIDGET (self->auth_combo), (gpointer) parent);
+
+ if (secrets_only) {
+ gtk_widget_hide (GTK_WIDGET (self->auth_combo));
+ gtk_widget_hide (GTK_WIDGET (self->auth_label));
+ }
+
+ g_signal_connect_object (G_OBJECT (self->auth_combo), "changed", G_CALLBACK (auth_combo_changed_cb),
self, G_CONNECT_SWAPPED);
+ auth_combo_changed_cb (self);
return self;
}
diff --git a/panels/network/wireless-security/ws-wpa-eap.c b/panels/network/wireless-security/ws-wpa-eap.c
index 02c5eb26b..f090c7a13 100644
--- a/panels/network/wireless-security/ws-wpa-eap.c
+++ b/panels/network/wireless-security/ws-wpa-eap.c
@@ -89,13 +89,10 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
}
static void
-auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
+auth_combo_changed_cb (WirelessSecurityWPAEAP *self)
{
- WirelessSecurity *parent = WIRELESS_SECURITY (user_data);
- WirelessSecurityWPAEAP *self = (WirelessSecurityWPAEAP *) parent;
-
- ws_802_1x_auth_combo_changed (combo,
- parent,
+ ws_802_1x_auth_combo_changed (self->auth_combo,
+ WIRELESS_SECURITY (self),
self->method_box,
self->size_group);
}
@@ -129,12 +126,17 @@ ws_wpa_eap_new (NMConnection *connection,
ws_802_1x_auth_combo_init (parent,
self->auth_combo,
- self->auth_label,
- (GCallback) auth_combo_changed_cb,
connection,
is_editor,
secrets_only);
- auth_combo_changed_cb (GTK_WIDGET (self->auth_combo), parent);
+
+ if (secrets_only) {
+ gtk_widget_hide (GTK_WIDGET (self->auth_combo));
+ gtk_widget_hide (GTK_WIDGET (self->auth_label));
+ }
+
+ g_signal_connect_object (G_OBJECT (self->auth_combo), "changed", G_CALLBACK (auth_combo_changed_cb),
self, G_CONNECT_SWAPPED);
+ auth_combo_changed_cb (self);
return self;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]