diff options
Diffstat (limited to 'panels')
19 files changed, 84 insertions, 218 deletions
diff --git a/panels/network/connection-editor/ce-page-8021x-security.c b/panels/network/connection-editor/ce-page-8021x-security.c index 794e29cd5..0318fca9c 100644 --- a/panels/network/connection-editor/ce-page-8021x-security.c +++ b/panels/network/connection-editor/ce-page-8021x-security.c @@ -40,7 +40,6 @@ struct _CEPage8021xSecurity { GtkLabel *security_label; NMConnection *connection; - GtkWidget *security_widget; WirelessSecurityWPAEAP *security; GtkSizeGroup *group; gboolean initial_have_8021x; @@ -54,7 +53,7 @@ G_DEFINE_TYPE_WITH_CODE (CEPage8021xSecurity, ce_page_8021x_security, GTK_TYPE_G static void enable_toggled (CEPage8021xSecurity *self) { - gtk_widget_set_sensitive (self->security_widget, gtk_switch_get_active (self->enable_8021x_switch)); + gtk_widget_set_sensitive (GTK_WIDGET (self->security), gtk_switch_get_active (self->enable_8021x_switch)); ce_page_changed (CE_PAGE (self)); } @@ -81,19 +80,18 @@ finish_setup (CEPage8021xSecurity *self, gpointer unused, GError *error, gpointe } g_signal_connect_object (WIRELESS_SECURITY (self->security), "changed", G_CALLBACK (security_item_changed_cb), self, G_CONNECT_SWAPPED); - self->security_widget = wireless_security_get_widget (WIRELESS_SECURITY (self->security)); - parent = gtk_widget_get_parent (self->security_widget); + parent = gtk_widget_get_parent (GTK_WIDGET (self->security)); if (parent) - gtk_container_remove (GTK_CONTAINER (parent), self->security_widget); + gtk_container_remove (GTK_CONTAINER (parent), GTK_WIDGET (self->security)); gtk_switch_set_active (self->enable_8021x_switch, self->initial_have_8021x); g_signal_connect_swapped (self->enable_8021x_switch, "notify::active", G_CALLBACK (enable_toggled), self); - gtk_widget_set_sensitive (self->security_widget, self->initial_have_8021x); + gtk_widget_set_sensitive (GTK_WIDGET (self->security), self->initial_have_8021x); gtk_size_group_add_widget (self->group, GTK_WIDGET (self->security_label)); wireless_security_add_to_size_group (WIRELESS_SECURITY (self->security), self->group); - gtk_container_add (GTK_CONTAINER (self->box), self->security_widget); + gtk_container_add (GTK_CONTAINER (self->box), GTK_WIDGET (self->security)); } diff --git a/panels/network/connection-editor/ce-page-security.c b/panels/network/connection-editor/ce-page-security.c index 55d0e0e27..df4767026 100644 --- a/panels/network/connection-editor/ce-page-security.c +++ b/panels/network/connection-editor/ce-page-security.c @@ -160,19 +160,16 @@ security_combo_changed (CEPageSecurity *self) sec = security_combo_get_active (self); if (sec) { - GtkWidget *sec_widget; GtkWidget *parent; - sec_widget = wireless_security_get_widget (sec); - g_assert (sec_widget); - parent = gtk_widget_get_parent (sec_widget); + parent = gtk_widget_get_parent (GTK_WIDGET (sec)); if (parent) - gtk_container_remove (GTK_CONTAINER (parent), sec_widget); + gtk_container_remove (GTK_CONTAINER (parent), GTK_WIDGET (sec)); gtk_size_group_add_widget (self->group, GTK_WIDGET (self->security_label)); wireless_security_add_to_size_group (sec, self->group); - gtk_container_add (GTK_CONTAINER (self->box), sec_widget); + gtk_container_add (GTK_CONTAINER (self->box), g_object_ref (GTK_WIDGET (sec))); } ce_page_changed (CE_PAGE (self)); diff --git a/panels/network/wireless-security/wireless-security.c b/panels/network/wireless-security/wireless-security.c index aeed83eec..9f083f6f4 100644 --- a/panels/network/wireless-security/wireless-security.c +++ b/panels/network/wireless-security/wireless-security.c @@ -50,14 +50,6 @@ wireless_security_default_init (WirelessSecurityInterface *iface) G_TYPE_NONE, 0); } -GtkWidget * -wireless_security_get_widget (WirelessSecurity *self) -{ - g_return_val_if_fail (WIRELESS_IS_SECURITY (self), NULL); - - return WIRELESS_SECURITY_GET_IFACE (self)->get_widget (self); -} - void wireless_security_notify_changed (WirelessSecurity *self) { diff --git a/panels/network/wireless-security/wireless-security.h b/panels/network/wireless-security/wireless-security.h index 96c401d8c..7f1cbed61 100644 --- a/panels/network/wireless-security/wireless-security.h +++ b/panels/network/wireless-security/wireless-security.h @@ -36,11 +36,8 @@ struct _WirelessSecurityInterface { void (*fill_connection) (WirelessSecurity *sec, NMConnection *connection); gboolean (*validate) (WirelessSecurity *sec, GError **error); gboolean (*adhoc_compatible) (WirelessSecurity *sec); - GtkWidget* (*get_widget) (WirelessSecurity *sec); }; -GtkWidget *wireless_security_get_widget (WirelessSecurity *sec); - gboolean wireless_security_validate (WirelessSecurity *sec, GError **error); void wireless_security_add_to_size_group (WirelessSecurity *sec, diff --git a/panels/network/wireless-security/ws-dynamic-wep.c b/panels/network/wireless-security/ws-dynamic-wep.c index e84f90673..9a0407d74 100644 --- a/panels/network/wireless-security/ws-dynamic-wep.c +++ b/panels/network/wireless-security/ws-dynamic-wep.c @@ -33,13 +33,11 @@ #include "ws-dynamic-wep.h" struct _WirelessSecurityDynamicWEP { - GObject parent; + GtkGrid parent; - GtkBuilder *builder; GtkComboBox *auth_combo; GtkLabel *auth_label; GtkListStore *auth_model; - GtkGrid *grid; GtkBox *method_box; EAPMethodTLS *em_tls; @@ -52,7 +50,7 @@ struct _WirelessSecurityDynamicWEP { static void wireless_security_iface_init (WirelessSecurityInterface *); -G_DEFINE_TYPE_WITH_CODE (WirelessSecurityDynamicWEP, ws_dynamic_wep, G_TYPE_OBJECT, +G_DEFINE_TYPE_WITH_CODE (WirelessSecurityDynamicWEP, ws_dynamic_wep, GTK_TYPE_GRID, G_IMPLEMENT_INTERFACE (wireless_security_get_type (), wireless_security_iface_init)); #define AUTH_NAME_COLUMN 0 @@ -84,23 +82,6 @@ get_eap (WirelessSecurityDynamicWEP *self) return NULL; } -static void -ws_dynamic_wep_dispose (GObject *object) -{ - WirelessSecurityDynamicWEP *self = WS_DYNAMIC_WEP (object); - - g_clear_object (&self->builder); - - G_OBJECT_CLASS (ws_dynamic_wep_parent_class)->dispose (object); -} - -static GtkWidget * -get_widget (WirelessSecurity *security) -{ - WirelessSecurityDynamicWEP *self = WS_DYNAMIC_WEP (security); - return GTK_WIDGET (self->grid); -} - static gboolean validate (WirelessSecurity *security, GError **error) { @@ -190,20 +171,25 @@ auth_combo_changed_cb (WirelessSecurityDynamicWEP *self) void ws_dynamic_wep_init (WirelessSecurityDynamicWEP *self) { + gtk_widget_init_template (GTK_WIDGET (self)); } void ws_dynamic_wep_class_init (WirelessSecurityDynamicWEPClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - object_class->dispose = ws_dynamic_wep_dispose; + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/ControlCenter/network/ws-dynamic-wep.ui"); + + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityDynamicWEP, auth_combo); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityDynamicWEP, auth_label); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityDynamicWEP, auth_model); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityDynamicWEP, method_box); } 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; @@ -219,22 +205,9 @@ ws_dynamic_wep_new (NMConnection *connection, const gchar *default_method = NULL; EAPMethodSimpleFlags simple_flags = EAP_METHOD_SIMPLE_FLAG_NONE; GtkTreeIter iter; - g_autoptr(GError) error = NULL; self = g_object_new (ws_dynamic_wep_get_type (), NULL); - self->builder = gtk_builder_new (); - if (!gtk_builder_add_from_resource (self->builder, "/org/gnome/ControlCenter/network/ws-dynamic-wep.ui", &error)) { - g_warning ("Couldn't load UI builder resource: %s", error->message); - return NULL; - } - - self->auth_combo = GTK_COMBO_BOX (gtk_builder_get_object (self->builder, "auth_combo")); - self->auth_label = GTK_LABEL (gtk_builder_get_object (self->builder, "auth_label")); - self->auth_model = GTK_LIST_STORE (gtk_builder_get_object (self->builder, "auth_model")); - self->grid = GTK_GRID (gtk_builder_get_object (self->builder, "grid")); - self->method_box = GTK_BOX (gtk_builder_get_object (self->builder, "method_box")); - /* Grab the default EAP method out of the security object */ if (connection) { NMSetting8021x *s_8021x; diff --git a/panels/network/wireless-security/ws-dynamic-wep.h b/panels/network/wireless-security/ws-dynamic-wep.h index 76da106cc..6e9a1fa25 100644 --- a/panels/network/wireless-security/ws-dynamic-wep.h +++ b/panels/network/wireless-security/ws-dynamic-wep.h @@ -22,11 +22,12 @@ #pragma once +#include <gtk/gtk.h> #include <NetworkManager.h> G_BEGIN_DECLS -G_DECLARE_FINAL_TYPE (WirelessSecurityDynamicWEP, ws_dynamic_wep, WS, DYNAMIC_WEP, GObject) +G_DECLARE_FINAL_TYPE (WirelessSecurityDynamicWEP, ws_dynamic_wep, WS, DYNAMIC_WEP, GtkGrid) WirelessSecurityDynamicWEP *ws_dynamic_wep_new (NMConnection *connection, gboolean is_editor, diff --git a/panels/network/wireless-security/ws-dynamic-wep.ui b/panels/network/wireless-security/ws-dynamic-wep.ui index c3293e4b1..a7fadffcb 100644 --- a/panels/network/wireless-security/ws-dynamic-wep.ui +++ b/panels/network/wireless-security/ws-dynamic-wep.ui @@ -43,7 +43,7 @@ </row> </data> </object> - <object class="GtkGrid" id="grid"> + <template class="WirelessSecurityDynamicWEP" parent="GtkGrid"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="column_spacing">6</property> @@ -96,5 +96,5 @@ <property name="top_attach">1</property> </packing> </child> - </object> + </template> </interface> diff --git a/panels/network/wireless-security/ws-leap.c b/panels/network/wireless-security/ws-leap.c index ebcb3f71d..9fb2a93ac 100644 --- a/panels/network/wireless-security/ws-leap.c +++ b/panels/network/wireless-security/ws-leap.c @@ -29,10 +29,8 @@ #include "ws-leap.h" struct _WirelessSecurityLEAP { - GObject parent; + GtkGrid parent; - GtkBuilder *builder; - GtkGrid *grid; GtkEntry *password_entry; GtkLabel *password_label; GtkCheckButton *show_password_check; @@ -45,20 +43,10 @@ struct _WirelessSecurityLEAP { static void wireless_security_iface_init (WirelessSecurityInterface *); -G_DEFINE_TYPE_WITH_CODE (WirelessSecurityLEAP, ws_leap, G_TYPE_OBJECT, +G_DEFINE_TYPE_WITH_CODE (WirelessSecurityLEAP, ws_leap, GTK_TYPE_GRID, G_IMPLEMENT_INTERFACE (wireless_security_get_type (), wireless_security_iface_init)); static void -ws_leap_dispose (GObject *object) -{ - WirelessSecurityLEAP *self = WS_LEAP (object); - - g_clear_object (&self->builder); - - G_OBJECT_CLASS (ws_leap_parent_class)->dispose (object); -} - -static void show_toggled_cb (WirelessSecurityLEAP *self) { gboolean visible; @@ -67,13 +55,6 @@ show_toggled_cb (WirelessSecurityLEAP *self) gtk_entry_set_visibility (self->password_entry, visible); } -static GtkWidget * -get_widget (WirelessSecurity *security) -{ - WirelessSecurityLEAP *self = WS_LEAP (security); - return GTK_WIDGET (self->grid); -} - static gboolean validate (WirelessSecurity *security, GError **error) { @@ -158,20 +139,26 @@ changed_cb (WirelessSecurityLEAP *self) void ws_leap_init (WirelessSecurityLEAP *self) { + gtk_widget_init_template (GTK_WIDGET (self)); } void ws_leap_class_init (WirelessSecurityLEAPClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/ControlCenter/network/ws-leap.ui"); - object_class->dispose = ws_leap_dispose; + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityLEAP, password_entry); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityLEAP, password_label); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityLEAP, show_password_check); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityLEAP, username_entry); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityLEAP, username_label); } 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; @@ -183,7 +170,6 @@ ws_leap_new (NMConnection *connection, gboolean secrets_only) { WirelessSecurityLEAP *self; NMSettingWirelessSecurity *wsec = NULL; - g_autoptr(GError) error = NULL; self = g_object_new (ws_leap_get_type (), NULL); @@ -202,19 +188,6 @@ ws_leap_new (NMConnection *connection, gboolean secrets_only) self->editing_connection = secrets_only ? FALSE : TRUE; self->password_flags_name = NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD; - self->builder = gtk_builder_new (); - if (!gtk_builder_add_from_resource (self->builder, "/org/gnome/ControlCenter/network/ws-leap.ui", &error)) { - g_warning ("Couldn't load UI builder resource: %s", error->message); - return NULL; - } - - self->grid = GTK_GRID (gtk_builder_get_object (self->builder, "grid")); - self->password_entry = GTK_ENTRY (gtk_builder_get_object (self->builder, "password_entry")); - self->password_label = GTK_LABEL (gtk_builder_get_object (self->builder, "password_label")); - self->show_password_check = GTK_CHECK_BUTTON (gtk_builder_get_object (self->builder, "show_password_check")); - self->username_entry = GTK_ENTRY (gtk_builder_get_object (self->builder, "username_entry")); - self->username_label = GTK_LABEL (gtk_builder_get_object (self->builder, "username_label")); - g_signal_connect_swapped (self->password_entry, "changed", G_CALLBACK (changed_cb), self); /* Create password-storage popup menu for password entry under entry's secondary icon */ diff --git a/panels/network/wireless-security/ws-leap.h b/panels/network/wireless-security/ws-leap.h index 023a1b92c..20b8c0e15 100644 --- a/panels/network/wireless-security/ws-leap.h +++ b/panels/network/wireless-security/ws-leap.h @@ -22,11 +22,12 @@ #pragma once +#include <gtk/gtk.h> #include <NetworkManager.h> G_BEGIN_DECLS -G_DECLARE_FINAL_TYPE (WirelessSecurityLEAP, ws_leap, WS, LEAP, GObject) +G_DECLARE_FINAL_TYPE (WirelessSecurityLEAP, ws_leap, WS, LEAP, GtkGrid) WirelessSecurityLEAP * ws_leap_new (NMConnection *connection, gboolean secrets_only); diff --git a/panels/network/wireless-security/ws-leap.ui b/panels/network/wireless-security/ws-leap.ui index cba9c6c8b..3815d88dd 100644 --- a/panels/network/wireless-security/ws-leap.ui +++ b/panels/network/wireless-security/ws-leap.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> <requires lib="gtk+" version="3.4"/> - <object class="GtkGrid" id="grid"> + <template class="WirelessSecurityLEAP" parent="GtkGrid"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="valign">start</property> @@ -78,5 +78,5 @@ <property name="top_attach">0</property> </packing> </child> - </object> + </template> </interface> diff --git a/panels/network/wireless-security/ws-wep-key.c b/panels/network/wireless-security/ws-wep-key.c index 3b7adc84c..4ceb1ea29 100644 --- a/panels/network/wireless-security/ws-wep-key.c +++ b/panels/network/wireless-security/ws-wep-key.c @@ -29,12 +29,10 @@ #include "wireless-security.h" struct _WirelessSecurityWEPKey { - GObject parent; + GtkGrid parent; - GtkBuilder *builder; GtkComboBox *auth_method_combo; GtkLabel *auth_method_label; - GtkGrid *grid; GtkEntry *key_entry; GtkComboBox *key_index_combo; GtkLabel *key_index_label; @@ -51,7 +49,7 @@ struct _WirelessSecurityWEPKey { static void wireless_security_iface_init (WirelessSecurityInterface *); -G_DEFINE_TYPE_WITH_CODE (WirelessSecurityWEPKey, ws_wep_key, G_TYPE_OBJECT, +G_DEFINE_TYPE_WITH_CODE (WirelessSecurityWEPKey, ws_wep_key, GTK_TYPE_GRID, G_IMPLEMENT_INTERFACE (wireless_security_get_type (), wireless_security_iface_init)); static void @@ -93,20 +91,12 @@ ws_wep_key_dispose (GObject *object) WirelessSecurityWEPKey *self = WS_WEP_KEY (object); int i; - g_clear_object (&self->builder); for (i = 0; i < 4; i++) memset (self->keys[i], 0, sizeof (self->keys[i])); G_OBJECT_CLASS (ws_wep_key_parent_class)->dispose (object); } -static GtkWidget * -get_widget (WirelessSecurity *security) -{ - WirelessSecurityWEPKey *self = WS_WEP_KEY (security); - return GTK_WIDGET (self->grid); -} - static gboolean validate (WirelessSecurity *security, GError **error) { @@ -260,20 +250,31 @@ changed_cb (WirelessSecurityWEPKey *self) void ws_wep_key_init (WirelessSecurityWEPKey *self) { + gtk_widget_init_template (GTK_WIDGET (self)); } void ws_wep_key_class_init (WirelessSecurityWEPKeyClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); object_class->dispose = ws_wep_key_dispose; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/ControlCenter/network/ws-wep-key.ui"); + + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWEPKey, auth_method_combo); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWEPKey, auth_method_label); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWEPKey, key_entry); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWEPKey, key_index_combo); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWEPKey, key_index_label); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWEPKey, key_label); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWEPKey, show_key_check); } 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; @@ -291,25 +292,9 @@ ws_wep_key_new (NMConnection *connection, guint8 default_key_idx = 0; gboolean is_adhoc = adhoc_create; gboolean is_shared_key = FALSE; - g_autoptr(GError) error = NULL; self = g_object_new (ws_wep_key_get_type (), NULL); - self->builder = gtk_builder_new (); - if (!gtk_builder_add_from_resource (self->builder, "/org/gnome/ControlCenter/network/ws-wep-key.ui", &error)) { - g_warning ("Couldn't load UI builder resource: %s", error->message); - return NULL; - } - - self->auth_method_combo = GTK_COMBO_BOX (gtk_builder_get_object (self->builder, "auth_method_combo")); - self->auth_method_label = GTK_LABEL (gtk_builder_get_object (self->builder, "auth_method_label")); - self->grid = GTK_GRID (gtk_builder_get_object (self->builder, "grid")); - self->key_entry = GTK_ENTRY (gtk_builder_get_object (self->builder, "key_entry")); - self->key_index_combo = GTK_COMBO_BOX (gtk_builder_get_object (self->builder, "key_index_combo")); - self->key_index_label = GTK_LABEL (gtk_builder_get_object (self->builder, "key_index_label")); - self->key_label = GTK_LABEL (gtk_builder_get_object (self->builder, "key_label")); - self->show_key_check = GTK_CHECK_BUTTON (gtk_builder_get_object (self->builder, "show_key_check")); - self->editing_connection = secrets_only ? FALSE : TRUE; self->password_flags_name = NM_SETTING_WIRELESS_SECURITY_WEP_KEY0; self->type = type; diff --git a/panels/network/wireless-security/ws-wep-key.h b/panels/network/wireless-security/ws-wep-key.h index f20fbff9c..218270255 100644 --- a/panels/network/wireless-security/ws-wep-key.h +++ b/panels/network/wireless-security/ws-wep-key.h @@ -22,11 +22,12 @@ #pragma once +#include <gtk/gtk.h> #include <NetworkManager.h> G_BEGIN_DECLS -G_DECLARE_FINAL_TYPE (WirelessSecurityWEPKey, ws_wep_key, WS, WEP_KEY, GObject) +G_DECLARE_FINAL_TYPE (WirelessSecurityWEPKey, ws_wep_key, WS, WEP_KEY, GtkGrid) WirelessSecurityWEPKey *ws_wep_key_new (NMConnection *connection, NMWepKeyType type, diff --git a/panels/network/wireless-security/ws-wep-key.ui b/panels/network/wireless-security/ws-wep-key.ui index b987d7fca..7214032b6 100644 --- a/panels/network/wireless-security/ws-wep-key.ui +++ b/panels/network/wireless-security/ws-wep-key.ui @@ -35,7 +35,7 @@ </row> </data> </object> - <object class="GtkGrid" id="grid"> + <template class="WirelessSecurityWEPKey" parent="GtkGrid"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="column_spacing">6</property> @@ -158,5 +158,5 @@ <property name="top_attach">2</property> </packing> </child> - </object> + </template> </interface> diff --git a/panels/network/wireless-security/ws-wpa-eap.c b/panels/network/wireless-security/ws-wpa-eap.c index 583ecb35f..b14b334e7 100644 --- a/panels/network/wireless-security/ws-wpa-eap.c +++ b/panels/network/wireless-security/ws-wpa-eap.c @@ -33,13 +33,11 @@ #include "eap-method-ttls.h" struct _WirelessSecurityWPAEAP { - GObject parent; + GtkGrid parent; - GtkBuilder *builder; GtkComboBox *auth_combo; GtkLabel *auth_label; GtkListStore *auth_model; - GtkGrid *grid; GtkBox *method_box; EAPMethodSimple *em_md5; @@ -53,7 +51,7 @@ struct _WirelessSecurityWPAEAP { static void wireless_security_iface_init (WirelessSecurityInterface *); -G_DEFINE_TYPE_WITH_CODE (WirelessSecurityWPAEAP, ws_wpa_eap, G_TYPE_OBJECT, +G_DEFINE_TYPE_WITH_CODE (WirelessSecurityWPAEAP, ws_wpa_eap, GTK_TYPE_GRID, G_IMPLEMENT_INTERFACE (wireless_security_get_type (), wireless_security_iface_init)); #define AUTH_NAME_COLUMN 0 @@ -87,23 +85,6 @@ get_eap (WirelessSecurityWPAEAP *self) return NULL; } -static void -ws_wpa_eap_dispose (GObject *object) -{ - WirelessSecurityWPAEAP *self = WS_WPA_EAP (object); - - g_clear_object (&self->builder); - - G_OBJECT_CLASS (ws_wpa_eap_parent_class)->dispose (object); -} - -static GtkWidget * -get_widget (WirelessSecurity *security) -{ - WirelessSecurityWPAEAP *self = WS_WPA_EAP (security); - return GTK_WIDGET (self->grid); -} - static gboolean validate (WirelessSecurity *security, GError **error) { @@ -205,20 +186,25 @@ auth_combo_changed_cb (WirelessSecurityWPAEAP *self) void ws_wpa_eap_init (WirelessSecurityWPAEAP *self) { + gtk_widget_init_template (GTK_WIDGET (self)); } void ws_wpa_eap_class_init (WirelessSecurityWPAEAPClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - object_class->dispose = ws_wpa_eap_dispose; + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/ControlCenter/network/ws-wpa-eap.ui"); + + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWPAEAP, auth_combo); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWPAEAP, auth_label); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWPAEAP, auth_model); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWPAEAP, method_box); } 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; @@ -235,22 +221,9 @@ ws_wpa_eap_new (NMConnection *connection, gboolean wired = FALSE; EAPMethodSimpleFlags simple_flags = EAP_METHOD_SIMPLE_FLAG_NONE; GtkTreeIter iter; - g_autoptr(GError) error = NULL; self = g_object_new (ws_wpa_eap_get_type (), NULL); - self->builder = gtk_builder_new (); - if (!gtk_builder_add_from_resource (self->builder, "/org/gnome/ControlCenter/network/ws-wpa-eap.ui", &error)) { - g_warning ("Couldn't load UI builder resource: %s", error->message); - return NULL; - } - - self->auth_combo = GTK_COMBO_BOX (gtk_builder_get_object (self->builder, "auth_combo")); - self->auth_label = GTK_LABEL (gtk_builder_get_object (self->builder, "auth_label")); - self->auth_model = GTK_LIST_STORE (gtk_builder_get_object (self->builder, "auth_model")); - self->grid = GTK_GRID (gtk_builder_get_object (self->builder, "grid")); - self->method_box = GTK_BOX (gtk_builder_get_object (self->builder, "method_box")); - /* Grab the default EAP method out of the security object */ if (connection) { NMSettingConnection *s_con; diff --git a/panels/network/wireless-security/ws-wpa-eap.h b/panels/network/wireless-security/ws-wpa-eap.h index 5ad4a2163..d099d2d08 100644 --- a/panels/network/wireless-security/ws-wpa-eap.h +++ b/panels/network/wireless-security/ws-wpa-eap.h @@ -22,11 +22,12 @@ #pragma once +#include <gtk/gtk.h> #include <NetworkManager.h> G_BEGIN_DECLS -G_DECLARE_FINAL_TYPE (WirelessSecurityWPAEAP, ws_wpa_eap, WS, WPA_EAP, GObject) +G_DECLARE_FINAL_TYPE (WirelessSecurityWPAEAP, ws_wpa_eap, WS, WPA_EAP, GtkGrid) WirelessSecurityWPAEAP *ws_wpa_eap_new (NMConnection *connection, gboolean is_editor, diff --git a/panels/network/wireless-security/ws-wpa-eap.ui b/panels/network/wireless-security/ws-wpa-eap.ui index 95b129fa1..0555aaaf9 100644 --- a/panels/network/wireless-security/ws-wpa-eap.ui +++ b/panels/network/wireless-security/ws-wpa-eap.ui @@ -48,7 +48,7 @@ </row> </data> </object> - <object class="GtkGrid" id="grid"> + <template class="WirelessSecurityWPAEAP" parent="GtkGrid"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="column_spacing">6</property> @@ -100,5 +100,5 @@ <property name="top_attach">1</property> </packing> </child> - </object> + </template> </interface> diff --git a/panels/network/wireless-security/ws-wpa-psk.c b/panels/network/wireless-security/ws-wpa-psk.c index a3b5a8735..5e228d41f 100644 --- a/panels/network/wireless-security/ws-wpa-psk.c +++ b/panels/network/wireless-security/ws-wpa-psk.c @@ -32,10 +32,8 @@ #define WPA_PMK_LEN 32 struct _WirelessSecurityWPAPSK { - GObject parent; + GtkGrid parent; - GtkBuilder *builder; - GtkGrid *grid; GtkEntry *password_entry; GtkLabel *password_label; GtkCheckButton *show_password_check; @@ -48,27 +46,10 @@ struct _WirelessSecurityWPAPSK { static void wireless_security_iface_init (WirelessSecurityInterface *); -G_DEFINE_TYPE_WITH_CODE (WirelessSecurityWPAPSK, ws_wpa_psk, G_TYPE_OBJECT, +G_DEFINE_TYPE_WITH_CODE (WirelessSecurityWPAPSK, ws_wpa_psk, GTK_TYPE_GRID, G_IMPLEMENT_INTERFACE (wireless_security_get_type (), wireless_security_iface_init)); static void -ws_wpa_psk_dispose (GObject *object) -{ - WirelessSecurityWPAPSK *self = WS_WPA_PSK (object); - - g_clear_object (&self->builder); - - G_OBJECT_CLASS (ws_wpa_psk_parent_class)->dispose (object); -} - -static GtkWidget * -get_widget (WirelessSecurity *security) -{ - WirelessSecurityWPAPSK *self = WS_WPA_PSK (security); - return GTK_WIDGET (self->grid); -} - -static void show_toggled_cb (WirelessSecurityWPAPSK *self) { gboolean visible; @@ -188,20 +169,26 @@ changed_cb (WirelessSecurityWPAPSK *self) void ws_wpa_psk_init (WirelessSecurityWPAPSK *self) { + gtk_widget_init_template (GTK_WIDGET (self)); } void ws_wpa_psk_class_init (WirelessSecurityWPAPSKClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/ControlCenter/network/ws-wpa-psk.ui"); - object_class->dispose = ws_wpa_psk_dispose; + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWPAPSK, password_entry); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWPAPSK, password_label); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWPAPSK, show_password_check); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWPAPSK, type_combo); + gtk_widget_class_bind_template_child (widget_class, WirelessSecurityWPAPSK, type_label); } 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; @@ -213,23 +200,9 @@ ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only) { WirelessSecurityWPAPSK *self; NMSetting *setting = NULL; - g_autoptr(GError) error = NULL; self = g_object_new (ws_wpa_psk_get_type (), NULL); - self->builder = gtk_builder_new (); - if (!gtk_builder_add_from_resource (self->builder, "/org/gnome/ControlCenter/network/ws-wpa-psk.ui", &error)) { - g_warning ("Couldn't load UI builder resource: %s", error->message); - return NULL; - } - - self->grid = GTK_GRID (gtk_builder_get_object (self->builder, "grid")); - self->password_entry = GTK_ENTRY (gtk_builder_get_object (self->builder, "password_entry")); - self->password_label = GTK_LABEL (gtk_builder_get_object (self->builder, "password_label")); - self->show_password_check = GTK_CHECK_BUTTON (gtk_builder_get_object (self->builder, "show_password_check")); - self->type_combo = GTK_COMBO_BOX (gtk_builder_get_object (self->builder, "type_combo")); - self->type_label = GTK_LABEL (gtk_builder_get_object (self->builder, "type_label")); - self->editing_connection = secrets_only ? FALSE : TRUE; self->password_flags_name = NM_SETTING_WIRELESS_SECURITY_PSK; diff --git a/panels/network/wireless-security/ws-wpa-psk.h b/panels/network/wireless-security/ws-wpa-psk.h index 16f4fb443..3c47506e1 100644 --- a/panels/network/wireless-security/ws-wpa-psk.h +++ b/panels/network/wireless-security/ws-wpa-psk.h @@ -22,11 +22,12 @@ #pragma once +#include <gtk/gtk.h> #include <NetworkManager.h> G_BEGIN_DECLS -G_DECLARE_FINAL_TYPE (WirelessSecurityWPAPSK, ws_wpa_psk, WS, WPA_PSK, GObject) +G_DECLARE_FINAL_TYPE (WirelessSecurityWPAPSK, ws_wpa_psk, WS, WPA_PSK, GtkGrid) WirelessSecurityWPAPSK * ws_wpa_psk_new (NMConnection *connection, gboolean secrets_only); diff --git a/panels/network/wireless-security/ws-wpa-psk.ui b/panels/network/wireless-security/ws-wpa-psk.ui index 4fea601b4..203748e23 100644 --- a/panels/network/wireless-security/ws-wpa-psk.ui +++ b/panels/network/wireless-security/ws-wpa-psk.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> <requires lib="gtk+" version="3.4"/> - <object class="GtkGrid" id="grid"> + <template class="WirelessSecurityWPAPSK" parent="GtkGrid"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="column_spacing">6</property> @@ -85,5 +85,5 @@ <property name="top_attach">2</property> </packing> </child> - </object> + </template> </interface> |