[gnome-control-center] network: Convert WirelessSecurity into an interface



commit d4ec8a570b06546f03cdd73d7bff276731abf2e9
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue Dec 3 09:27:03 2019 +1300

    network: Convert WirelessSecurity into an interface

 .../network/wireless-security/wireless-security.c  | 29 ++++++++--------------
 .../network/wireless-security/wireless-security.h  |  6 ++---
 panels/network/wireless-security/ws-dynamic-wep.c  | 23 +++++++++++------
 panels/network/wireless-security/ws-dynamic-wep.h  |  4 +--
 panels/network/wireless-security/ws-leap.c         | 23 +++++++++++------
 panels/network/wireless-security/ws-leap.h         |  4 +--
 panels/network/wireless-security/ws-wep-key.c      | 21 ++++++++++------
 panels/network/wireless-security/ws-wep-key.h      |  4 +--
 panels/network/wireless-security/ws-wpa-eap.c      | 23 +++++++++++------
 panels/network/wireless-security/ws-wpa-eap.h      |  4 +--
 panels/network/wireless-security/ws-wpa-psk.c      | 23 +++++++++++------
 panels/network/wireless-security/ws-wpa-psk.h      |  4 +--
 12 files changed, 92 insertions(+), 76 deletions(-)
---
diff --git a/panels/network/wireless-security/wireless-security.c 
b/panels/network/wireless-security/wireless-security.c
index 5de1b049c..aeed83eec 100644
--- a/panels/network/wireless-security/wireless-security.c
+++ b/panels/network/wireless-security/wireless-security.c
@@ -26,10 +26,7 @@
 #include "wireless-security.h"
 #include "wireless-security-resources.h"
 
-typedef struct {
-} WirelessSecurityPrivate;
-
-G_DEFINE_TYPE_WITH_PRIVATE (WirelessSecurity, wireless_security, G_TYPE_OBJECT)
+G_DEFINE_INTERFACE (WirelessSecurity, wireless_security, G_TYPE_OBJECT)
 
 enum {
         CHANGED,
@@ -38,20 +35,14 @@ enum {
 
 static guint signals[LAST_SIGNAL] = { 0 };
 
-void
-wireless_security_init (WirelessSecurity *self)
+static void
+wireless_security_default_init (WirelessSecurityInterface *iface)
 {
        g_resources_register (wireless_security_get_resource ());
-}
-
-void
-wireless_security_class_init (WirelessSecurityClass *klass)
-{
-        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
         signals[CHANGED] =
                 g_signal_new ("changed",
-                              G_TYPE_FROM_CLASS (object_class),
+                              G_TYPE_FROM_INTERFACE (iface),
                               G_SIGNAL_RUN_FIRST,
                               0,
                               NULL, NULL,
@@ -64,7 +55,7 @@ wireless_security_get_widget (WirelessSecurity *self)
 {
        g_return_val_if_fail (WIRELESS_IS_SECURITY (self), NULL);
 
-       return WIRELESS_SECURITY_GET_CLASS (self)->get_widget (self);
+       return WIRELESS_SECURITY_GET_IFACE (self)->get_widget (self);
 }
 
 void
@@ -83,7 +74,7 @@ wireless_security_validate (WirelessSecurity *self, GError **error)
        g_return_val_if_fail (WIRELESS_IS_SECURITY (self), FALSE);
        g_return_val_if_fail (!error || !*error, FALSE);
 
-       result = WIRELESS_SECURITY_GET_CLASS (self)->validate (self, error);
+       result = WIRELESS_SECURITY_GET_IFACE (self)->validate (self, error);
        if (!result && error && !*error)
                g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Unknown error validating 802.1X 
security"));
        return result;
@@ -95,7 +86,7 @@ wireless_security_add_to_size_group (WirelessSecurity *self, GtkSizeGroup *group
        g_return_if_fail (WIRELESS_IS_SECURITY (self));
        g_return_if_fail (GTK_IS_SIZE_GROUP (group));
 
-       return WIRELESS_SECURITY_GET_CLASS (self)->add_to_size_group (self, group);
+       return WIRELESS_SECURITY_GET_IFACE (self)->add_to_size_group (self, group);
 }
 
 void
@@ -105,14 +96,14 @@ wireless_security_fill_connection (WirelessSecurity *self,
        g_return_if_fail (WIRELESS_IS_SECURITY (self));
        g_return_if_fail (connection != NULL);
 
-       return WIRELESS_SECURITY_GET_CLASS (self)->fill_connection (self, connection);
+       return WIRELESS_SECURITY_GET_IFACE (self)->fill_connection (self, connection);
 }
 
 gboolean
 wireless_security_adhoc_compatible (WirelessSecurity *self)
 {
-       if (WIRELESS_SECURITY_GET_CLASS (self)->adhoc_compatible)
-               return WIRELESS_SECURITY_GET_CLASS (self)->adhoc_compatible (self);
+       if (WIRELESS_SECURITY_GET_IFACE (self)->adhoc_compatible)
+               return WIRELESS_SECURITY_GET_IFACE (self)->adhoc_compatible (self);
        else
                return TRUE;
 }
diff --git a/panels/network/wireless-security/wireless-security.h 
b/panels/network/wireless-security/wireless-security.h
index a0c6b0184..96c401d8c 100644
--- a/panels/network/wireless-security/wireless-security.h
+++ b/panels/network/wireless-security/wireless-security.h
@@ -27,10 +27,10 @@
 
 G_BEGIN_DECLS
 
-G_DECLARE_DERIVABLE_TYPE (WirelessSecurity, wireless_security, WIRELESS, SECURITY, GObject)
+G_DECLARE_INTERFACE (WirelessSecurity, wireless_security, WIRELESS, SECURITY, GObject)
 
-struct _WirelessSecurityClass {
-       GObjectClass parent_class;
+struct _WirelessSecurityInterface {
+       GTypeInterface g_iface;
 
        void       (*add_to_size_group) (WirelessSecurity *sec, GtkSizeGroup *group);
        void       (*fill_connection)   (WirelessSecurity *sec, NMConnection *connection);
diff --git a/panels/network/wireless-security/ws-dynamic-wep.c 
b/panels/network/wireless-security/ws-dynamic-wep.c
index 9b98542d1..e84f90673 100644
--- a/panels/network/wireless-security/ws-dynamic-wep.c
+++ b/panels/network/wireless-security/ws-dynamic-wep.c
@@ -33,7 +33,7 @@
 #include "ws-dynamic-wep.h"
 
 struct _WirelessSecurityDynamicWEP {
-       WirelessSecurity parent;
+       GObject parent;
 
        GtkBuilder   *builder;
        GtkComboBox  *auth_combo;
@@ -50,7 +50,10 @@ struct _WirelessSecurityDynamicWEP {
        EAPMethodPEAP   *em_peap;
 };
 
-G_DEFINE_TYPE (WirelessSecurityDynamicWEP, ws_dynamic_wep, wireless_security_get_type ())
+static void wireless_security_iface_init (WirelessSecurityInterface *);
+
+G_DEFINE_TYPE_WITH_CODE (WirelessSecurityDynamicWEP, ws_dynamic_wep, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (wireless_security_get_type (), 
wireless_security_iface_init));
 
 #define AUTH_NAME_COLUMN    0
 #define AUTH_ID_COLUMN      1
@@ -193,14 +196,18 @@ void
 ws_dynamic_wep_class_init (WirelessSecurityDynamicWEPClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       WirelessSecurityClass *ws_class = WIRELESS_SECURITY_CLASS (klass);
 
        object_class->dispose = ws_dynamic_wep_dispose;
-       ws_class->get_widget = get_widget;
-       ws_class->validate = validate;
-       ws_class->add_to_size_group = add_to_size_group;
-       ws_class->fill_connection = fill_connection;
-       ws_class->adhoc_compatible = adhoc_compatible;
+}
+
+static void
+wireless_security_iface_init (WirelessSecurityInterface *iface)
+{
+       iface->get_widget = get_widget;
+       iface->validate = validate;
+       iface->add_to_size_group = add_to_size_group;
+       iface->fill_connection = fill_connection;
+       iface->adhoc_compatible = adhoc_compatible;
 }
 
 WirelessSecurityDynamicWEP *
diff --git a/panels/network/wireless-security/ws-dynamic-wep.h 
b/panels/network/wireless-security/ws-dynamic-wep.h
index 95fdf0de8..76da106cc 100644
--- a/panels/network/wireless-security/ws-dynamic-wep.h
+++ b/panels/network/wireless-security/ws-dynamic-wep.h
@@ -24,11 +24,9 @@
 
 #include <NetworkManager.h>
 
-#include "wireless-security.h"
-
 G_BEGIN_DECLS
 
-G_DECLARE_FINAL_TYPE (WirelessSecurityDynamicWEP, ws_dynamic_wep, WS, DYNAMIC_WEP, WirelessSecurity)
+G_DECLARE_FINAL_TYPE (WirelessSecurityDynamicWEP, ws_dynamic_wep, WS, DYNAMIC_WEP, GObject)
 
 WirelessSecurityDynamicWEP *ws_dynamic_wep_new (NMConnection *connection,
                                                 gboolean is_editor,
diff --git a/panels/network/wireless-security/ws-leap.c b/panels/network/wireless-security/ws-leap.c
index 48a22b57c..ebcb3f71d 100644
--- a/panels/network/wireless-security/ws-leap.c
+++ b/panels/network/wireless-security/ws-leap.c
@@ -29,7 +29,7 @@
 #include "ws-leap.h"
 
 struct _WirelessSecurityLEAP {
-       WirelessSecurity parent;
+       GObject parent;
 
        GtkBuilder     *builder;
        GtkGrid        *grid;
@@ -43,7 +43,10 @@ struct _WirelessSecurityLEAP {
        const char *password_flags_name;
 };
 
-G_DEFINE_TYPE (WirelessSecurityLEAP, ws_leap, wireless_security_get_type ())
+static void wireless_security_iface_init (WirelessSecurityInterface *);
+
+G_DEFINE_TYPE_WITH_CODE (WirelessSecurityLEAP, ws_leap, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (wireless_security_get_type (), 
wireless_security_iface_init));
 
 static void
 ws_leap_dispose (GObject *object)
@@ -161,14 +164,18 @@ void
 ws_leap_class_init (WirelessSecurityLEAPClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       WirelessSecurityClass *ws_class = WIRELESS_SECURITY_CLASS (klass);
 
        object_class->dispose = ws_leap_dispose;
-       ws_class->get_widget = get_widget;
-       ws_class->validate = validate;
-       ws_class->add_to_size_group = add_to_size_group;
-       ws_class->fill_connection = fill_connection;
-       ws_class->adhoc_compatible = adhoc_compatible;
+}
+
+static void
+wireless_security_iface_init (WirelessSecurityInterface *iface)
+{
+       iface->get_widget = get_widget;
+       iface->validate = validate;
+       iface->add_to_size_group = add_to_size_group;
+       iface->fill_connection = fill_connection;
+       iface->adhoc_compatible = adhoc_compatible;
 }
 
 WirelessSecurityLEAP *
diff --git a/panels/network/wireless-security/ws-leap.h b/panels/network/wireless-security/ws-leap.h
index 33abc6062..023a1b92c 100644
--- a/panels/network/wireless-security/ws-leap.h
+++ b/panels/network/wireless-security/ws-leap.h
@@ -24,11 +24,9 @@
 
 #include <NetworkManager.h>
 
-#include "wireless-security.h"
-
 G_BEGIN_DECLS
 
-G_DECLARE_FINAL_TYPE (WirelessSecurityLEAP, ws_leap, WS, LEAP, WirelessSecurity)
+G_DECLARE_FINAL_TYPE (WirelessSecurityLEAP, ws_leap, WS, LEAP, GObject)
 
 WirelessSecurityLEAP * ws_leap_new (NMConnection *connection, gboolean secrets_only);
 
diff --git a/panels/network/wireless-security/ws-wep-key.c b/panels/network/wireless-security/ws-wep-key.c
index bf09163f2..3b7adc84c 100644
--- a/panels/network/wireless-security/ws-wep-key.c
+++ b/panels/network/wireless-security/ws-wep-key.c
@@ -29,7 +29,7 @@
 #include "wireless-security.h"
 
 struct _WirelessSecurityWEPKey {
-       WirelessSecurity parent;
+       GObject parent;
 
        GtkBuilder     *builder;
        GtkComboBox    *auth_method_combo;
@@ -49,7 +49,10 @@ struct _WirelessSecurityWEPKey {
        guint8 cur_index;
 };
 
-G_DEFINE_TYPE (WirelessSecurityWEPKey, ws_wep_key, wireless_security_get_type ())
+static void wireless_security_iface_init (WirelessSecurityInterface *);
+
+G_DEFINE_TYPE_WITH_CODE (WirelessSecurityWEPKey, ws_wep_key, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (wireless_security_get_type (), 
wireless_security_iface_init));
 
 static void
 show_toggled_cb (WirelessSecurityWEPKey *self)
@@ -263,13 +266,17 @@ void
 ws_wep_key_class_init (WirelessSecurityWEPKeyClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       WirelessSecurityClass *ws_class = WIRELESS_SECURITY_CLASS (klass);
 
        object_class->dispose = ws_wep_key_dispose;
-       ws_class->get_widget = get_widget;
-       ws_class->validate = validate;
-       ws_class->add_to_size_group = add_to_size_group;
-       ws_class->fill_connection = fill_connection;
+}
+
+static void
+wireless_security_iface_init (WirelessSecurityInterface *iface)
+{
+       iface->get_widget = get_widget;
+       iface->validate = validate;
+       iface->add_to_size_group = add_to_size_group;
+       iface->fill_connection = fill_connection;
 }
 
 WirelessSecurityWEPKey *
diff --git a/panels/network/wireless-security/ws-wep-key.h b/panels/network/wireless-security/ws-wep-key.h
index 85003e2e6..f20fbff9c 100644
--- a/panels/network/wireless-security/ws-wep-key.h
+++ b/panels/network/wireless-security/ws-wep-key.h
@@ -24,11 +24,9 @@
 
 #include <NetworkManager.h>
 
-#include "wireless-security.h"
-
 G_BEGIN_DECLS
 
-G_DECLARE_FINAL_TYPE (WirelessSecurityWEPKey, ws_wep_key, WS, WEP_KEY, WirelessSecurity)
+G_DECLARE_FINAL_TYPE (WirelessSecurityWEPKey, ws_wep_key, WS, WEP_KEY, GObject)
 
 WirelessSecurityWEPKey *ws_wep_key_new (NMConnection *connection,
                                         NMWepKeyType type,
diff --git a/panels/network/wireless-security/ws-wpa-eap.c b/panels/network/wireless-security/ws-wpa-eap.c
index e2da862ab..583ecb35f 100644
--- a/panels/network/wireless-security/ws-wpa-eap.c
+++ b/panels/network/wireless-security/ws-wpa-eap.c
@@ -33,7 +33,7 @@
 #include "eap-method-ttls.h"
 
 struct _WirelessSecurityWPAEAP {
-       WirelessSecurity parent;
+       GObject parent;
 
        GtkBuilder   *builder;
        GtkComboBox  *auth_combo;
@@ -51,7 +51,10 @@ struct _WirelessSecurityWPAEAP {
        EAPMethodPEAP   *em_peap;
 };
 
-G_DEFINE_TYPE (WirelessSecurityWPAEAP, ws_wpa_eap, wireless_security_get_type ())
+static void wireless_security_iface_init (WirelessSecurityInterface *);
+
+G_DEFINE_TYPE_WITH_CODE (WirelessSecurityWPAEAP, ws_wpa_eap, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (wireless_security_get_type (), 
wireless_security_iface_init));
 
 #define AUTH_NAME_COLUMN    0
 #define AUTH_ID_COLUMN      1
@@ -208,14 +211,18 @@ void
 ws_wpa_eap_class_init (WirelessSecurityWPAEAPClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       WirelessSecurityClass *ws_class = WIRELESS_SECURITY_CLASS (klass);
 
        object_class->dispose = ws_wpa_eap_dispose;
-       ws_class->get_widget = get_widget;
-       ws_class->validate = validate;
-       ws_class->add_to_size_group = add_to_size_group;
-       ws_class->fill_connection = fill_connection;
-       ws_class->adhoc_compatible = adhoc_compatible;
+}
+
+static void
+wireless_security_iface_init (WirelessSecurityInterface *iface)
+{
+       iface->get_widget = get_widget;
+       iface->validate = validate;
+       iface->add_to_size_group = add_to_size_group;
+       iface->fill_connection = fill_connection;
+       iface->adhoc_compatible = adhoc_compatible;
 }
 
 WirelessSecurityWPAEAP *
diff --git a/panels/network/wireless-security/ws-wpa-eap.h b/panels/network/wireless-security/ws-wpa-eap.h
index 682e982b0..5ad4a2163 100644
--- a/panels/network/wireless-security/ws-wpa-eap.h
+++ b/panels/network/wireless-security/ws-wpa-eap.h
@@ -24,11 +24,9 @@
 
 #include <NetworkManager.h>
 
-#include "wireless-security.h"
-
 G_BEGIN_DECLS
 
-G_DECLARE_FINAL_TYPE (WirelessSecurityWPAEAP, ws_wpa_eap, WS, WPA_EAP, WirelessSecurity)
+G_DECLARE_FINAL_TYPE (WirelessSecurityWPAEAP, ws_wpa_eap, WS, WPA_EAP, GObject)
 
 WirelessSecurityWPAEAP *ws_wpa_eap_new             (NMConnection *connection,
                                                     gboolean is_editor,
diff --git a/panels/network/wireless-security/ws-wpa-psk.c b/panels/network/wireless-security/ws-wpa-psk.c
index e6d4c25f9..a3b5a8735 100644
--- a/panels/network/wireless-security/ws-wpa-psk.c
+++ b/panels/network/wireless-security/ws-wpa-psk.c
@@ -32,7 +32,7 @@
 #define WPA_PMK_LEN 32
 
 struct _WirelessSecurityWPAPSK {
-       WirelessSecurity parent;
+       GObject parent;
 
        GtkBuilder     *builder;
        GtkGrid        *grid;
@@ -46,7 +46,10 @@ struct _WirelessSecurityWPAPSK {
        const char *password_flags_name;
 };
 
-G_DEFINE_TYPE (WirelessSecurityWPAPSK, ws_wpa_psk, wireless_security_get_type ())
+static void wireless_security_iface_init (WirelessSecurityInterface *);
+
+G_DEFINE_TYPE_WITH_CODE (WirelessSecurityWPAPSK, ws_wpa_psk, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (wireless_security_get_type (), 
wireless_security_iface_init));
 
 static void
 ws_wpa_psk_dispose (GObject *object)
@@ -191,14 +194,18 @@ void
 ws_wpa_psk_class_init (WirelessSecurityWPAPSKClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       WirelessSecurityClass *ws_class = WIRELESS_SECURITY_CLASS (klass);
 
        object_class->dispose = ws_wpa_psk_dispose;
-       ws_class->get_widget = get_widget;
-       ws_class->validate = validate;
-       ws_class->add_to_size_group = add_to_size_group;
-       ws_class->fill_connection = fill_connection;
-       ws_class->adhoc_compatible = adhoc_compatible;
+}
+
+static void
+wireless_security_iface_init (WirelessSecurityInterface *iface)
+{
+       iface->get_widget = get_widget;
+       iface->validate = validate;
+       iface->add_to_size_group = add_to_size_group;
+       iface->fill_connection = fill_connection;
+       iface->adhoc_compatible = adhoc_compatible;
 }
 
 WirelessSecurityWPAPSK *
diff --git a/panels/network/wireless-security/ws-wpa-psk.h b/panels/network/wireless-security/ws-wpa-psk.h
index d2c4a5bd2..16f4fb443 100644
--- a/panels/network/wireless-security/ws-wpa-psk.h
+++ b/panels/network/wireless-security/ws-wpa-psk.h
@@ -24,11 +24,9 @@
 
 #include <NetworkManager.h>
 
-#include "wireless-security.h"
-
 G_BEGIN_DECLS
 
-G_DECLARE_FINAL_TYPE (WirelessSecurityWPAPSK, ws_wpa_psk, WS, WPA_PSK, WirelessSecurity)
+G_DECLARE_FINAL_TYPE (WirelessSecurityWPAPSK, ws_wpa_psk, WS, WPA_PSK, GObject)
 
 WirelessSecurityWPAPSK * ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only);
 


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