[gnome-control-center/network-widget-references: 10/13] network: Connect signals in swapped form



commit 991d8dfdc2b9726bdb18129a09ef2d03149523cc
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue Oct 15 11:15:30 2019 +1300

    network: Connect signals in swapped form

 panels/network/wireless-security/eap-method-fast.c | 31 ++++++------
 panels/network/wireless-security/eap-method-leap.c | 23 ++++-----
 panels/network/wireless-security/eap-method-peap.c | 28 +++++------
 .../network/wireless-security/eap-method-simple.c  | 33 +++++-------
 panels/network/wireless-security/eap-method-tls.c  | 21 ++++----
 panels/network/wireless-security/eap-method-ttls.c | 29 +++++------
 panels/network/wireless-security/ws-leap.c         | 13 +++--
 panels/network/wireless-security/ws-wep-key.c      | 58 ++++++++++------------
 panels/network/wireless-security/ws-wpa-psk.c      | 13 +++--
 9 files changed, 109 insertions(+), 140 deletions(-)
---
diff --git a/panels/network/wireless-security/eap-method-fast.c 
b/panels/network/wireless-security/eap-method-fast.c
index 784986d0e..49238c54e 100644
--- a/panels/network/wireless-security/eap-method-fast.c
+++ b/panels/network/wireless-security/eap-method-fast.c
@@ -187,17 +187,17 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
 }
 
 static void
-inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
+inner_auth_combo_changed_cb (EAPMethodFAST *self)
 {
-       EAPMethod *parent = (EAPMethod *) user_data;
-       EAPMethodFAST *method = (EAPMethodFAST *) parent;
-       GtkWidget *vbox;
+       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, "eap_fast_inner_auth_combo"));
        vbox = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_inner_auth_vbox"));
        g_assert (vbox);
 
@@ -216,11 +216,11 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
        g_assert (eap_widget);
        gtk_widget_unparent (eap_widget);
 
-       if (method->size_group)
-               eap_method_add_to_size_group (eap, method->size_group);
+       if (self->size_group)
+               eap_method_add_to_size_group (eap, self->size_group);
        gtk_container_add (GTK_CONTAINER (vbox), eap_widget);
 
-       wireless_security_notify_changed (method->sec_parent);
+       wireless_security_notify_changed (self->sec_parent);
 }
 
 static GtkWidget *
@@ -288,9 +288,7 @@ inner_auth_combo_init (EAPMethodFAST *method,
        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 (G_OBJECT (combo), "changed",
-                         (GCallback) inner_auth_combo_changed_cb,
-                         method);
+       g_signal_connect_swapped (combo, "changed", G_CALLBACK (inner_auth_combo_changed_cb), method);
        return combo;
 }
 
@@ -304,21 +302,22 @@ update_secrets (EAPMethod *parent, NMConnection *connection)
 }
 
 static void
-pac_toggled_cb (GtkWidget *widget, gpointer user_data)
+pac_toggled_cb (EAPMethodFAST *self)
 {
-       EAPMethod *parent = (EAPMethod *) user_data;
-       EAPMethodFAST *method = (EAPMethodFAST *) parent;
+       GtkWidget *widget;
+       EAPMethod *parent = (EAPMethod *) self;
        gboolean enabled = FALSE;
        GtkWidget *provision_combo;
 
        provision_combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_fast_pac_provision_combo"));
        g_return_if_fail (provision_combo);
 
+       widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_checkbutton"));
        enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
 
        gtk_widget_set_sensitive (provision_combo, enabled);
 
-       wireless_security_notify_changed (method->sec_parent);
+       wireless_security_notify_changed (self->sec_parent);
 }
 
 static void
@@ -386,7 +385,7 @@ eap_method_fast_new (WirelessSecurity *ws_parent,
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_checkbutton"));
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), provisioning_enabled);
-       g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (pac_toggled_cb), parent);
+       g_signal_connect_swapped (widget, "toggled", G_CALLBACK (pac_toggled_cb), method);
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_anon_identity_entry"));
        if (s_8021x && nm_setting_802_1x_get_anonymous_identity (s_8021x))
@@ -416,7 +415,7 @@ eap_method_fast_new (WirelessSecurity *ws_parent,
        }
 
        widget = inner_auth_combo_init (method, connection, s_8021x, secrets_only);
-       inner_auth_combo_changed_cb (widget, (gpointer) method);
+       inner_auth_combo_changed_cb (method);
 
        if (secrets_only) {
                widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_fast_anon_identity_label"));
diff --git a/panels/network/wireless-security/eap-method-leap.c 
b/panels/network/wireless-security/eap-method-leap.c
index fdd891b21..7f379c73b 100644
--- a/panels/network/wireless-security/eap-method-leap.c
+++ b/panels/network/wireless-security/eap-method-leap.c
@@ -44,11 +44,14 @@ struct _EAPMethodLEAP {
 };
 
 static void
-show_toggled_cb (GtkToggleButton *button, EAPMethodLEAP *method)
+show_toggled_cb (EAPMethodLEAP *method)
 {
+       EAPMethod *parent = (EAPMethod *) method;
+       GtkWidget *widget;
        gboolean visible;
 
-       visible = gtk_toggle_button_get_active (button);
+       widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_eapleap"));
+       visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
        gtk_entry_set_visibility (method->password_entry, visible);
 }
 
@@ -152,13 +155,13 @@ set_userpass_ui (EAPMethodLEAP *method)
 }
 
 static void
-widgets_realized (GtkWidget *widget, EAPMethodLEAP *method)
+widgets_realized (EAPMethodLEAP *method)
 {
        set_userpass_ui (method);
 }
 
 static void
-widgets_unrealized (GtkWidget *widget, EAPMethodLEAP *method)
+widgets_unrealized (EAPMethodLEAP *method)
 {
        wireless_security_set_userpass (method->ws_parent,
                                        gtk_entry_get_text (method->username_entry),
@@ -218,12 +221,8 @@ eap_method_leap_new (WirelessSecurity *ws_parent,
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_notebook"));
        g_assert (widget);
-       g_signal_connect (G_OBJECT (widget), "realize",
-                         (GCallback) widgets_realized,
-                         method);
-       g_signal_connect (G_OBJECT (widget), "unrealize",
-                         (GCallback) widgets_unrealized,
-                         method);
+       g_signal_connect_swapped (widget, "realize", G_CALLBACK (widgets_realized), method);
+       g_signal_connect_swapped (widget, "unrealize", G_CALLBACK (widgets_unrealized), method);
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_username_entry"));
        g_assert (widget);
@@ -247,9 +246,7 @@ eap_method_leap_new (WirelessSecurity *ws_parent,
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_eapleap"));
        g_assert (widget);
        method->show_password = GTK_TOGGLE_BUTTON (widget);
-       g_signal_connect (G_OBJECT (widget), "toggled",
-                         (GCallback) show_toggled_cb,
-                         parent);
+       g_signal_connect_swapped (widget, "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 5158ba4d9..c47ed7310 100644
--- a/panels/network/wireless-security/eap-method-peap.c
+++ b/panels/network/wireless-security/eap-method-peap.c
@@ -82,9 +82,9 @@ validate (EAPMethod *parent, GError **error)
 }
 
 static void
-ca_cert_not_required_toggled (GtkWidget *ignored, gpointer user_data)
+ca_cert_not_required_toggled (EAPMethodPEAP *self)
 {
-       EAPMethod *parent = user_data;
+       EAPMethod *parent = (EAPMethod *) self;
 
        eap_method_ca_cert_not_required_toggled (GTK_TOGGLE_BUTTON (gtk_builder_get_object (parent->builder, 
"eap_peap_ca_cert_not_required_checkbox")),
                                                 GTK_FILE_CHOOSER (gtk_builder_get_object (parent->builder, 
"eap_peap_ca_cert_button")));
@@ -191,11 +191,10 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
        eap_method_fill_connection (eap, connection, flags);
 }
 static void
-inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
+inner_auth_combo_changed_cb (EAPMethodPEAP *self)
 {
-       EAPMethod *parent = (EAPMethod *) user_data;
-       EAPMethodPEAP *method = (EAPMethodPEAP *) parent;
-       GtkWidget *vbox;
+       EAPMethod *parent = (EAPMethod *) self;
+       GtkWidget *combo, *vbox;
        g_autoptr(EAPMethod) eap = NULL;
        GList *elt, *children;
        GtkTreeModel *model;
@@ -210,6 +209,7 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
        for (elt = children; elt; elt = g_list_next (elt))
                gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (elt->data));
 
+       combo = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_inner_auth_combo"));
        model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
        gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
        gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
@@ -219,11 +219,11 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
        g_assert (eap_widget);
        gtk_widget_unparent (eap_widget);
 
-       if (method->size_group)
-               eap_method_add_to_size_group (eap, method->size_group);
+       if (self->size_group)
+               eap_method_add_to_size_group (eap, self->size_group);
        gtk_container_add (GTK_CONTAINER (vbox), eap_widget);
 
-       wireless_security_notify_changed (method->sec_parent);
+       wireless_security_notify_changed (self->sec_parent);
 }
 
 static GtkWidget *
@@ -306,9 +306,7 @@ inner_auth_combo_init (EAPMethodPEAP *method,
        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 (G_OBJECT (combo), "changed",
-                         (GCallback) inner_auth_combo_changed_cb,
-                         method);
+       g_signal_connect_swapped (combo, "changed", G_CALLBACK (inner_auth_combo_changed_cb), method);
        return combo;
 }
 
@@ -363,9 +361,7 @@ eap_method_peap_new (WirelessSecurity *ws_parent,
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_peap_ca_cert_not_required_checkbox"));
        g_assert (widget);
-       g_signal_connect (G_OBJECT (widget), "toggled",
-                         (GCallback) ca_cert_not_required_toggled,
-                         parent);
+       g_signal_connect_swapped (widget, "toggled", G_CALLBACK (ca_cert_not_required_toggled), method);
        g_signal_connect_swapped (widget, "toggled", G_CALLBACK (changed_cb), method);
        widget_ca_not_required_checkbox = widget;
 
@@ -389,7 +385,7 @@ eap_method_peap_new (WirelessSecurity *ws_parent,
        }
 
        widget = inner_auth_combo_init (method, connection, s_8021x, secrets_only);
-       inner_auth_combo_changed_cb (widget, (gpointer) method);
+       inner_auth_combo_changed_cb (method);
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_version_combo"));
        g_assert (widget);
diff --git a/panels/network/wireless-security/eap-method-simple.c 
b/panels/network/wireless-security/eap-method-simple.c
index 4bc175955..51e21fb57 100644
--- a/panels/network/wireless-security/eap-method-simple.c
+++ b/panels/network/wireless-security/eap-method-simple.c
@@ -46,12 +46,15 @@ struct _EAPMethodSimple {
 };
 
 static void
-show_toggled_cb (GtkToggleButton *button, EAPMethodSimple *method)
+show_toggled_cb (EAPMethodSimple *self)
 {
+       EAPMethod *parent = (EAPMethod *) self;
+       GtkWidget *widget;
        gboolean visible;
 
-       visible = gtk_toggle_button_get_active (button);
-       gtk_entry_set_visibility (method->password_entry, visible);
+       widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_eapsimple"));
+       visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+       gtk_entry_set_visibility (self->password_entry, visible);
 }
 
 static gboolean
@@ -203,9 +206,7 @@ stuff_changed (EAPMethodSimple *method)
 }
 
 static void
-password_storage_changed (GObject *entry,
-                          GParamSpec *pspec,
-                          EAPMethodSimple *method)
+password_storage_changed (EAPMethodSimple *method)
 {
        gboolean always_ask;
        gboolean secrets_only = method->flags & EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY;
@@ -244,13 +245,13 @@ set_userpass_ui (EAPMethodSimple *method)
 }
 
 static void
-widgets_realized (GtkWidget *widget, EAPMethodSimple *method)
+widgets_realized (EAPMethodSimple *method)
 {
        set_userpass_ui (method);
 }
 
 static void
-widgets_unrealized (GtkWidget *widget, EAPMethodSimple *method)
+widgets_unrealized (EAPMethodSimple *method)
 {
        wireless_security_set_userpass (method->ws_parent,
                                        gtk_entry_get_text (method->username_entry),
@@ -316,12 +317,8 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_notebook"));
        g_assert (widget);
-       g_signal_connect (G_OBJECT (widget), "realize",
-                         (GCallback) widgets_realized,
-                         method);
-       g_signal_connect (G_OBJECT (widget), "unrealize",
-                         (GCallback) widgets_unrealized,
-                         method);
+       g_signal_connect_swapped (widget, "realize", G_CALLBACK (widgets_realized), method);
+       g_signal_connect_swapped (widget, "unrealize", G_CALLBACK (widgets_unrealized), method);
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_username_entry"));
        g_assert (widget);
@@ -342,16 +339,12 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
        nma_utils_setup_password_storage (widget, 0, (NMSetting *) s_8021x, parent->password_flags_name,
                                          FALSE, flags & EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY);
 
-       g_signal_connect (method->password_entry, "notify::secondary-icon-name",
-                         G_CALLBACK (password_storage_changed),
-                         method);
+       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_checkbutton_eapsimple"));
        g_assert (widget);
        method->show_password = GTK_TOGGLE_BUTTON (widget);
-       g_signal_connect (G_OBJECT (widget), "toggled",
-                         (GCallback) show_toggled_cb,
-                         method);
+       g_signal_connect_swapped (widget, "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 427ba8b25..fc1d76441 100644
--- a/panels/network/wireless-security/eap-method-tls.c
+++ b/panels/network/wireless-security/eap-method-tls.c
@@ -40,15 +40,16 @@ struct _EAPMethodTLS {
 
 
 static void
-show_toggled_cb (GtkCheckButton *button, EAPMethod *method)
+show_toggled_cb (EAPMethodTLS *self)
 {
+       EAPMethod *method = (EAPMethod *) self;
        GtkWidget *widget;
        gboolean visible;
 
-       widget = GTK_WIDGET (gtk_builder_get_object (method->builder, "eap_tls_private_key_password_entry"));
-       g_assert (widget);
+       widget = GTK_WIDGET (gtk_builder_get_object (method->builder, "show_checkbutton_eaptls"));
+       visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
 
-       visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+       widget = GTK_WIDGET (gtk_builder_get_object (method->builder, "eap_tls_private_key_password_entry"));
        gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
 }
 
@@ -121,9 +122,9 @@ validate (EAPMethod *parent, GError **error)
 }
 
 static void
-ca_cert_not_required_toggled (GtkWidget *ignored, gpointer user_data)
+ca_cert_not_required_toggled (EAPMethodTLS *self)
 {
-       EAPMethod *parent = user_data;
+       EAPMethod *parent = (EAPMethod *) self;
 
        eap_method_ca_cert_not_required_toggled (GTK_TOGGLE_BUTTON (gtk_builder_get_object (parent->builder, 
"eap_tls_ca_cert_not_required_checkbox")),
                                                 GTK_FILE_CHOOSER (gtk_builder_get_object (parent->builder, 
"eap_tls_ca_cert_button")));
@@ -463,9 +464,7 @@ eap_method_tls_new (WirelessSecurity *ws_parent,
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_tls_ca_cert_not_required_checkbox"));
        g_assert (widget);
-       g_signal_connect (G_OBJECT (widget), "toggled",
-                         (GCallback) ca_cert_not_required_toggled,
-                         parent);
+       g_signal_connect_swapped (widget, "toggled", G_CALLBACK (ca_cert_not_required_toggled), method);
        g_signal_connect_swapped (widget, "toggled", G_CALLBACK (changed_cb), method);
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_identity_entry"));
@@ -514,9 +513,7 @@ eap_method_tls_new (WirelessSecurity *ws_parent,
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_eaptls"));
        g_assert (widget);
-       g_signal_connect (G_OBJECT (widget), "toggled",
-                         (GCallback) show_toggled_cb,
-                         parent);
+       g_signal_connect_swapped (widget, "toggled", G_CALLBACK (show_toggled_cb), method);
 
        if (secrets_only) {
                widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_identity_entry"));
diff --git a/panels/network/wireless-security/eap-method-ttls.c 
b/panels/network/wireless-security/eap-method-ttls.c
index 2b2ea6bad..992e01807 100644
--- a/panels/network/wireless-security/eap-method-ttls.c
+++ b/panels/network/wireless-security/eap-method-ttls.c
@@ -82,10 +82,9 @@ validate (EAPMethod *parent, GError **error)
 }
 
 static void
-ca_cert_not_required_toggled (GtkWidget *ignored, gpointer user_data)
+ca_cert_not_required_toggled (EAPMethodTTLS *self)
 {
-       EAPMethod *parent = user_data;
-
+       EAPMethod *parent = (EAPMethod *) self;
        eap_method_ca_cert_not_required_toggled (GTK_TOGGLE_BUTTON (gtk_builder_get_object (parent->builder, 
"eap_ttls_ca_cert_not_required_checkbox")),
                                                 GTK_FILE_CHOOSER (gtk_builder_get_object (parent->builder, 
"eap_ttls_ca_cert_button")));
 }
@@ -183,17 +182,17 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
 }
 
 static void
-inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
+inner_auth_combo_changed_cb (EAPMethodTTLS *self)
 {
-       EAPMethod *parent = (EAPMethod *) user_data;
-       EAPMethodTTLS *method = (EAPMethodTTLS *) parent;
-       GtkWidget *vbox;
+       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, "eap_ttls_inner_auth_combo"));
        vbox = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_inner_auth_vbox"));
        g_assert (vbox);
 
@@ -212,11 +211,11 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
        g_assert (eap_widget);
        gtk_widget_unparent (eap_widget);
 
-       if (method->size_group)
-               eap_method_add_to_size_group (eap, method->size_group);
+       if (self->size_group)
+               eap_method_add_to_size_group (eap, self->size_group);
        gtk_container_add (GTK_CONTAINER (vbox), eap_widget);
 
-       wireless_security_notify_changed (method->sec_parent);
+       wireless_security_notify_changed (self->sec_parent);
 }
 
 static GtkWidget *
@@ -361,9 +360,7 @@ inner_auth_combo_init (EAPMethodTTLS *method,
        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 (G_OBJECT (combo), "changed",
-                         (GCallback) inner_auth_combo_changed_cb,
-                         method);
+       g_signal_connect_swapped (combo, "changed", G_CALLBACK (inner_auth_combo_changed_cb), method);
        return combo;
 }
 
@@ -418,9 +415,7 @@ eap_method_ttls_new (WirelessSecurity *ws_parent,
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_ttls_ca_cert_not_required_checkbox"));
        g_assert (widget);
-       g_signal_connect (G_OBJECT (widget), "toggled",
-                         (GCallback) ca_cert_not_required_toggled,
-                         parent);
+       g_signal_connect_swapped (widget, "toggled", G_CALLBACK (ca_cert_not_required_toggled), method);
        g_signal_connect_swapped (widget, "toggled", G_CALLBACK (changed_cb), method);
        widget_ca_not_required_checkbox = widget;
 
@@ -453,7 +448,7 @@ eap_method_ttls_new (WirelessSecurity *ws_parent,
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), method);
 
        widget = inner_auth_combo_init (method, connection, s_8021x, secrets_only);
-       inner_auth_combo_changed_cb (widget, (gpointer) method);
+       inner_auth_combo_changed_cb (method);
 
        if (secrets_only) {
                widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, 
"eap_ttls_anon_identity_label"));
diff --git a/panels/network/wireless-security/ws-leap.c b/panels/network/wireless-security/ws-leap.c
index e65529257..eafef7d85 100644
--- a/panels/network/wireless-security/ws-leap.c
+++ b/panels/network/wireless-security/ws-leap.c
@@ -37,15 +37,16 @@ struct _WirelessSecurityLEAP {
 };
 
 static void
-show_toggled_cb (GtkCheckButton *button, WirelessSecurity *sec)
+show_toggled_cb (WirelessSecurityLEAP *self)
 {
+       WirelessSecurity *sec = (WirelessSecurity *) self;
        GtkWidget *widget;
        gboolean visible;
 
-       widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "leap_password_entry"));
-       g_assert (widget);
+       widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "show_checkbutton_leap"));
+       visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
 
-       visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+       widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "leap_password_entry"));
        gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
 }
 
@@ -210,9 +211,7 @@ ws_leap_new (NMConnection *connection, gboolean secrets_only)
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_leap"));
        g_assert (widget);
-       g_signal_connect (G_OBJECT (widget), "toggled",
-                         (GCallback) show_toggled_cb,
-                         sec);
+       g_signal_connect_swapped (widget, "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 c4e257add..74d1f1c6d 100644
--- a/panels/network/wireless-security/ws-wep-key.c
+++ b/panels/network/wireless-security/ws-wep-key.c
@@ -42,23 +42,25 @@ struct _WirelessSecurityWEPKey {
 };
 
 static void
-show_toggled_cb (GtkCheckButton *button, WirelessSecurity *sec)
+show_toggled_cb (WirelessSecurityWEPKey *self)
 {
-       GtkWidget *widget;
+       WirelessSecurity *parent = (WirelessSecurity *) self;
+       GtkWidget *widget, *button;
        gboolean visible;
 
-       widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "wep_key_entry"));
+       widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wep_key_entry"));
        g_assert (widget);
 
+       button = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_wep"));
        visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
        gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
 }
 
 static void
-key_index_combo_changed_cb (GtkWidget *combo, WirelessSecurity *parent)
+key_index_combo_changed_cb (WirelessSecurityWEPKey *self)
 {
-       WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) parent;
-       GtkWidget *entry;
+       WirelessSecurity *parent = (WirelessSecurity *) self;
+       GtkWidget *combo, *entry;
        const char *key;
        int key_index;
 
@@ -66,17 +68,18 @@ key_index_combo_changed_cb (GtkWidget *combo, WirelessSecurity *parent)
        entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wep_key_entry"));
        key = gtk_entry_get_text (GTK_ENTRY (entry));
        if (key)
-               g_strlcpy (sec->keys[sec->cur_index], key, sizeof (sec->keys[sec->cur_index]));
+               g_strlcpy (self->keys[self->cur_index], key, sizeof (self->keys[self->cur_index]));
        else
-               memset (sec->keys[sec->cur_index], 0, sizeof (sec->keys[sec->cur_index]));
+               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));
        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), sec->keys[key_index]);
-       sec->cur_index = key_index;
+       gtk_entry_set_text (GTK_ENTRY (entry), self->keys[key_index]);
+       self->cur_index = key_index;
 
        wireless_security_notify_changed (parent);
 }
@@ -213,15 +216,16 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
 }
 
 static void
-wep_entry_filter_cb (GtkEditable *editable,
+wep_entry_filter_cb (WirelessSecurityWEPKey *self,
                      gchar *text,
                      gint length,
-                     gint *position,
-                     gpointer data)
+                     gint *position)
 {
-       WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) data;
+       WirelessSecurity *parent = (WirelessSecurity *) self;
+       GtkWidget *widget;
 
-       if (sec->type == NM_WEP_KEY_TYPE_KEY) {
+       widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wep_key_entry"));
+       if (self->type == NM_WEP_KEY_TYPE_KEY) {
                int i, count = 0;
                g_autofree gchar *result = g_new (gchar, length+1);
 
@@ -232,15 +236,11 @@ wep_entry_filter_cb (GtkEditable *editable,
                result[count] = 0;
 
                if (count > 0) {
-                       g_signal_handlers_block_by_func (G_OBJECT (editable),
-                                                        G_CALLBACK (wep_entry_filter_cb),
-                                                        data);
-                       gtk_editable_insert_text (editable, result, count, position);
-                       g_signal_handlers_unblock_by_func (G_OBJECT (editable),
-                                                          G_CALLBACK (wep_entry_filter_cb),
-                                                          data);
+                       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_stop_emission_by_name (G_OBJECT (editable), "insert-text");
+               g_signal_stop_emission_by_name (widget, "insert-text");
        }
 }
 
@@ -329,9 +329,7 @@ ws_wep_key_new (NMConnection *connection,
        }
 
        g_signal_connect_swapped (widget, "changed", G_CALLBACK (changed_cb), sec);
-       g_signal_connect (G_OBJECT (widget), "insert-text",
-                         (GCallback) wep_entry_filter_cb,
-                         sec);
+       g_signal_connect_swapped (widget, "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);
        else if (sec->type == NM_WEP_KEY_TYPE_PASSPHRASE)
@@ -343,9 +341,7 @@ ws_wep_key_new (NMConnection *connection,
 
        gtk_combo_box_set_active (GTK_COMBO_BOX (widget), default_key_idx);
        sec->cur_index = default_key_idx;
-       g_signal_connect (G_OBJECT (widget), "changed",
-                         (GCallback) key_index_combo_changed_cb,
-                         sec);
+       g_signal_connect_swapped (widget, "changed", G_CALLBACK (key_index_combo_changed_cb), sec);
 
        /* Key index is useless with adhoc networks */
        if (is_adhoc || secrets_only) {
@@ -360,9 +356,7 @@ ws_wep_key_new (NMConnection *connection,
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_wep"));
        g_assert (widget);
-       g_signal_connect (G_OBJECT (widget), "toggled",
-                         (GCallback) show_toggled_cb,
-                         sec);
+       g_signal_connect_swapped (widget, "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);
diff --git a/panels/network/wireless-security/ws-wpa-psk.c b/panels/network/wireless-security/ws-wpa-psk.c
index 090b8a26d..ca9c146f9 100644
--- a/panels/network/wireless-security/ws-wpa-psk.c
+++ b/panels/network/wireless-security/ws-wpa-psk.c
@@ -47,15 +47,16 @@ get_widget (WirelessSecurity *parent)
 }
 
 static void
-show_toggled_cb (GtkCheckButton *button, WirelessSecurity *sec)
+show_toggled_cb (WirelessSecurityWPAPSK *self)
 {
+       WirelessSecurity *sec = (WirelessSecurity *) self;
        GtkWidget *widget;
        gboolean visible;
 
-       widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "wpa_psk_entry"));
-       g_assert (widget);
+       widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "show_checkbutton_wpa"));
+       visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
 
-       visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+       widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, "wpa_psk_entry"));
        gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
 }
 
@@ -220,9 +221,7 @@ ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only)
 
        widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "show_checkbutton_wpa"));
        g_assert (widget);
-       g_signal_connect (G_OBJECT (widget), "toggled",
-                         (GCallback) show_toggled_cb,
-                         sec);
+       g_signal_connect_swapped (widget, "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.


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