[gnome-control-center] network: Simplify helper functions



commit 08b26a93a75c90e2f040adb6cd07fa1a853c2281
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Nov 8 16:17:58 2019 +1300

    network: Simplify helper functions

 .../network/wireless-security/wireless-security.c  | 37 ++++------------------
 .../network/wireless-security/wireless-security.h  |  5 ++-
 panels/network/wireless-security/ws-dynamic-wep.c  |  4 +--
 panels/network/wireless-security/ws-wpa-eap.c      |  4 +--
 4 files changed, 13 insertions(+), 37 deletions(-)
---
diff --git a/panels/network/wireless-security/wireless-security.c 
b/panels/network/wireless-security/wireless-security.c
index 1c7106b95..d1c92797b 100644
--- a/panels/network/wireless-security/wireless-security.c
+++ b/panels/network/wireless-security/wireless-security.c
@@ -360,12 +360,12 @@ wireless_security_clear_ciphers (NMConnection *connection)
        nm_setting_wireless_security_clear_groups (s_wireless_sec);
 }
 
-static EAPMethod *
-get_active_method (GtkComboBox *combo)
+EAPMethod *
+ws_802_1x_auth_combo_get_eap (GtkComboBox *combo)
 {
        GtkTreeModel *model;
        GtkTreeIter iter;
-       EAPMethod *eap;
+       g_autoptr(EAPMethod) eap = NULL;
 
        model = gtk_combo_box_get_model (combo);
        if (!gtk_combo_box_get_active_iter (combo, &iter))
@@ -375,36 +375,13 @@ get_active_method (GtkComboBox *combo)
        return eap;
 }
 
-void
-ws_802_1x_add_to_size_group (GtkSizeGroup *size_group,
-                             GtkComboBox *combo)
-{
-       g_autoptr(EAPMethod) eap = NULL;
-
-       eap = get_active_method (combo);
-       g_assert (eap);
-       eap_method_add_to_size_group (eap, size_group);
-}
-
-gboolean
-ws_802_1x_validate (GtkComboBox *combo, GError **error)
-{
-       g_autoptr(EAPMethod) eap = NULL;
-       gboolean valid = FALSE;
-
-       eap = get_active_method (combo);
-       g_assert (eap);
-       valid = eap_method_validate (eap, error);
-       return valid;
-}
-
 void
 ws_802_1x_auth_combo_changed (GtkComboBox *combo,
                               WirelessSecurity *self,
                               GtkBox *vbox,
                               GtkSizeGroup *size_group)
 {
-       g_autoptr(EAPMethod) eap = NULL;
+       EAPMethod *eap;
        GList *elt, *children;
        GtkWidget *eap_widget;
        GtkWidget *eap_default_widget = NULL;
@@ -414,7 +391,7 @@ ws_802_1x_auth_combo_changed (GtkComboBox *combo,
        for (elt = children; elt; elt = g_list_next (elt))
                gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (elt->data));
 
-       eap = get_active_method (GTK_COMBO_BOX (combo));
+       eap = ws_802_1x_auth_combo_get_eap (GTK_COMBO_BOX (combo));
        g_assert (eap);
 
        eap_widget = eap_method_get_widget (eap);
@@ -570,10 +547,10 @@ ws_802_1x_fill_connection (GtkComboBox *combo,
        NMSettingWirelessSecurity *s_wireless_sec;
        NMSetting8021x *s_8021x;
        NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
-       g_autoptr(EAPMethod) eap = NULL;
+       EAPMethod *eap;
 
        /* Get the EAPMethod object */
-       eap = get_active_method (combo);
+       eap = ws_802_1x_auth_combo_get_eap (combo);
        g_assert (eap);
 
        /* Get previous pasword flags, if any. Otherwise default to agent-owned secrets */
diff --git a/panels/network/wireless-security/wireless-security.h 
b/panels/network/wireless-security/wireless-security.h
index 97570906d..272eb7671 100644
--- a/panels/network/wireless-security/wireless-security.h
+++ b/panels/network/wireless-security/wireless-security.h
@@ -120,10 +120,9 @@ void ws_802_1x_auth_combo_changed (GtkComboBox *combo,
                                    GtkBox *vbox,
                                    GtkSizeGroup *size_group);
 
-gboolean ws_802_1x_validate (GtkComboBox *combo, GError **error);
+#include "eap-method.h"
 
-void ws_802_1x_add_to_size_group (GtkSizeGroup *size_group,
-                                  GtkComboBox *combo);
+EAPMethod *ws_802_1x_auth_combo_get_eap (GtkComboBox *combo);
 
 void ws_802_1x_fill_connection (GtkComboBox *combo,
                                 NMConnection *connection);
diff --git a/panels/network/wireless-security/ws-dynamic-wep.c 
b/panels/network/wireless-security/ws-dynamic-wep.c
index c04ff5e01..d48357ba8 100644
--- a/panels/network/wireless-security/ws-dynamic-wep.c
+++ b/panels/network/wireless-security/ws-dynamic-wep.c
@@ -59,7 +59,7 @@ static gboolean
 validate (WirelessSecurity *parent, GError **error)
 {
        WirelessSecurityDynamicWEP *self = (WirelessSecurityDynamicWEP *) parent;
-       return ws_802_1x_validate (self->auth_combo, error);
+       return eap_method_validate (ws_802_1x_auth_combo_get_eap (self->auth_combo), error);
 }
 
 static void
@@ -71,7 +71,7 @@ add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group)
        self->size_group = g_object_ref (group);
 
        gtk_size_group_add_widget (self->size_group, GTK_WIDGET (self->auth_label));
-       ws_802_1x_add_to_size_group (self->size_group, self->auth_combo);
+       eap_method_add_to_size_group (ws_802_1x_auth_combo_get_eap (self->auth_combo), self->size_group);
 }
 
 static void
diff --git a/panels/network/wireless-security/ws-wpa-eap.c b/panels/network/wireless-security/ws-wpa-eap.c
index 86b566582..9d1d35b58 100644
--- a/panels/network/wireless-security/ws-wpa-eap.c
+++ b/panels/network/wireless-security/ws-wpa-eap.c
@@ -60,7 +60,7 @@ static gboolean
 validate (WirelessSecurity *parent, GError **error)
 {
        WirelessSecurityWPAEAP *self = (WirelessSecurityWPAEAP *) parent;
-       return ws_802_1x_validate (self->auth_combo, error);
+       return eap_method_validate (ws_802_1x_auth_combo_get_eap (self->auth_combo), error);
 }
 
 static void
@@ -72,7 +72,7 @@ add_to_size_group (WirelessSecurity *parent, GtkSizeGroup *group)
        self->size_group = g_object_ref (group);
 
        gtk_size_group_add_widget (self->size_group, GTK_WIDGET (self->auth_label));
-       ws_802_1x_add_to_size_group (self->size_group, self->auth_combo);
+       eap_method_add_to_size_group (ws_802_1x_auth_combo_get_eap (self->auth_combo), self->size_group);
 }
 
 static void


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