From 3beaa9d1586c99ee4064474b34c212297f7790c6 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Thu, 5 Nov 2020 12:20:15 +1300 Subject: [PATCH] network: Move signals handlers into .ui files --- panels/network/cc-wifi-connection-row.c | 8 ++++---- panels/network/cc-wifi-connection-row.ui | 3 ++- panels/network/net-proxy.c | 16 +++------------- panels/network/net-vpn.c | 13 ++++--------- panels/network/network-proxy.ui | 6 +++++- panels/network/network-vpn.ui | 2 ++ 6 files changed, 20 insertions(+), 28 deletions(-) diff --git a/panels/network/cc-wifi-connection-row.c b/panels/network/cc-wifi-connection-row.c index 4886d70b6..83486b238 100644 --- a/panels/network/cc-wifi-connection-row.c +++ b/panels/network/cc-wifi-connection-row.c @@ -35,7 +35,6 @@ struct _CcWifiConnectionRow GtkImage *active_icon; GtkStack *button_stack; GtkCheckButton *checkbutton; - GtkButton *configure_button; GtkSpinner *connecting_spinner; GtkImage *encrypted_icon; GtkLabel *name_label; @@ -68,6 +67,8 @@ G_DEFINE_TYPE (CcWifiConnectionRow, cc_wifi_connection_row, GTK_TYPE_LIST_BOX_RO static GParamSpec *props[PROP_LAST]; +static void configure_clicked_cb (CcWifiConnectionRow *self); + static NMAccessPointSecurity get_access_point_security (NMAccessPoint *ap) { @@ -460,12 +461,13 @@ cc_wifi_connection_row_class_init (CcWifiConnectionRowClass *klass) gtk_widget_class_bind_template_child (widget_class, CcWifiConnectionRow, active_icon); gtk_widget_class_bind_template_child (widget_class, CcWifiConnectionRow, button_stack); gtk_widget_class_bind_template_child (widget_class, CcWifiConnectionRow, checkbutton); - gtk_widget_class_bind_template_child (widget_class, CcWifiConnectionRow, configure_button); gtk_widget_class_bind_template_child (widget_class, CcWifiConnectionRow, connecting_spinner); gtk_widget_class_bind_template_child (widget_class, CcWifiConnectionRow, encrypted_icon); gtk_widget_class_bind_template_child (widget_class, CcWifiConnectionRow, name_label); gtk_widget_class_bind_template_child (widget_class, CcWifiConnectionRow, strength_icon); + gtk_widget_class_bind_template_callback (widget_class, configure_clicked_cb); + props[PROP_CHECKABLE] = g_param_spec_boolean ("checkable", "checkable", "Whether to show a checkbox to select the row", FALSE, @@ -514,8 +516,6 @@ cc_wifi_connection_row_init (CcWifiConnectionRow *self) { gtk_widget_init_template (GTK_WIDGET (self)); - g_signal_connect_object (self->configure_button, "clicked", G_CALLBACK (configure_clicked_cb), self, G_CONNECT_SWAPPED); - self->aps = g_ptr_array_new_with_free_func (g_object_unref); g_object_bind_property (self, "checked", diff --git a/panels/network/cc-wifi-connection-row.ui b/panels/network/cc-wifi-connection-row.ui index 18de7b948..121508361 100644 --- a/panels/network/cc-wifi-connection-row.ui +++ b/panels/network/cc-wifi-connection-row.ui @@ -82,13 +82,14 @@ end False - + options_button True True True center center + True diff --git a/panels/network/net-proxy.c b/panels/network/net-proxy.c index 9e3c3de15..8182adc4b 100644 --- a/panels/network/net-proxy.c +++ b/panels/network/net-proxy.c @@ -40,7 +40,6 @@ struct _NetProxy GtkRadioButton *automatic_radio; GtkDialog *dialog; - GtkButton *dialog_button; GtkRadioButton *manual_radio; GtkRadioButton *none_radio; GtkEntry *proxy_ftp_entry; @@ -212,7 +211,6 @@ net_proxy_class_init (NetProxyClass *klass) gtk_widget_class_bind_template_child (widget_class, NetProxy, automatic_radio); gtk_widget_class_bind_template_child (widget_class, NetProxy, dialog); - gtk_widget_class_bind_template_child (widget_class, NetProxy, dialog_button); gtk_widget_class_bind_template_child (widget_class, NetProxy, manual_radio); gtk_widget_class_bind_template_child (widget_class, NetProxy, none_radio); gtk_widget_class_bind_template_child (widget_class, NetProxy, proxy_ftp_entry); @@ -228,6 +226,9 @@ net_proxy_class_init (NetProxyClass *klass) gtk_widget_class_bind_template_child (widget_class, NetProxy, proxy_warning_label); gtk_widget_class_bind_template_child (widget_class, NetProxy, stack); gtk_widget_class_bind_template_child (widget_class, NetProxy, status_label); + + gtk_widget_class_bind_template_callback (widget_class, panel_proxy_mode_radio_changed_cb); + gtk_widget_class_bind_template_callback (widget_class, show_dialog_cb); } static gboolean @@ -363,17 +364,6 @@ net_proxy_init (NetProxy *self) panel_proxy_mode_setup_widgets (self, value); panel_update_status_label (self, value); - g_signal_connect_object (self->none_radio, "toggled", G_CALLBACK (panel_proxy_mode_radio_changed_cb), self, G_CONNECT_SWAPPED); - g_signal_connect_object (self->manual_radio, "toggled", G_CALLBACK (panel_proxy_mode_radio_changed_cb), self, G_CONNECT_SWAPPED); - g_signal_connect_object (self->automatic_radio, "toggled", G_CALLBACK (panel_proxy_mode_radio_changed_cb), self, G_CONNECT_SWAPPED); - - /* show dialog button */ - g_signal_connect_object (self->dialog_button, - "clicked", - G_CALLBACK (show_dialog_cb), - self, - G_CONNECT_SWAPPED); - /* prevent the dialog from being destroyed */ g_signal_connect_object (self->dialog, "delete-event", diff --git a/panels/network/net-vpn.c b/panels/network/net-vpn.c index b0cebdedb..89c5777be 100644 --- a/panels/network/net-vpn.c +++ b/panels/network/net-vpn.c @@ -38,7 +38,6 @@ struct _NetVpn GtkBox *box; GtkLabel *device_label; GtkSwitch *device_off_switch; - GtkButton *options_button; GtkSeparator *separator; NMClient *client; @@ -155,7 +154,7 @@ edit_connection (NetVpn *self) NetConnectionEditor *editor; g_autofree gchar *title = NULL; - window = gtk_widget_get_toplevel (GTK_WIDGET (self->options_button)); + window = gtk_widget_get_toplevel (GTK_WIDGET (self)); editor = net_connection_editor_new (GTK_WINDOW (window), self->connection, @@ -196,20 +195,16 @@ net_vpn_class_init (NetVpnClass *klass) gtk_widget_class_bind_template_child (widget_class, NetVpn, device_label); gtk_widget_class_bind_template_child (widget_class, NetVpn, device_off_switch); - gtk_widget_class_bind_template_child (widget_class, NetVpn, options_button); gtk_widget_class_bind_template_child (widget_class, NetVpn, separator); + + gtk_widget_class_bind_template_callback (widget_class, device_off_toggled); + gtk_widget_class_bind_template_callback (widget_class, edit_connection); } static void net_vpn_init (NetVpn *self) { gtk_widget_init_template (GTK_WIDGET (self)); - - g_signal_connect_object (self->device_off_switch, "notify::active", - G_CALLBACK (device_off_toggled), self, G_CONNECT_SWAPPED); - - g_signal_connect_object (self->options_button, "clicked", - G_CALLBACK (edit_connection), self, G_CONNECT_SWAPPED); } NetVpn * diff --git a/panels/network/network-proxy.ui b/panels/network/network-proxy.ui index 4771716e1..dcc88d5f5 100644 --- a/panels/network/network-proxy.ui +++ b/panels/network/network-proxy.ui @@ -64,9 +64,10 @@ - + True True + True @@ -107,6 +108,7 @@ False True none_radio + @@ -117,6 +119,7 @@ False True none_radio + @@ -126,6 +129,7 @@ Disabled False True + diff --git a/panels/network/network-vpn.ui b/panels/network/network-vpn.ui index 8a7521ef0..f60add2b8 100644 --- a/panels/network/network-vpn.ui +++ b/panels/network/network-vpn.ui @@ -50,6 +50,7 @@ True end center + Turn VPN connection off @@ -63,6 +64,7 @@ True True True + True