[gnome-control-center] network: Move signals into GtkBuilder files
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Move signals into GtkBuilder files
- Date: Tue, 5 Nov 2019 23:08:20 +0000 (UTC)
commit 39113f6a034195db12f2e797c58ad11853811fca
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Oct 24 20:29:35 2019 +1300
network: Move signals into GtkBuilder files
panels/network/net-device-bluetooth.c | 14 ++---
panels/network/net-device-ethernet.c | 21 +++----
panels/network/net-device-mobile.c | 18 +++---
panels/network/net-device-wifi.c | 104 +++++++++++++++-------------------
panels/network/network-bluetooth.ui | 2 +
panels/network/network-ethernet.ui | 5 +-
panels/network/network-mobile.ui | 3 +
panels/network/network-wifi.ui | 9 ++-
8 files changed, 81 insertions(+), 95 deletions(-)
---
diff --git a/panels/network/net-device-bluetooth.c b/panels/network/net-device-bluetooth.c
index 111ed00a2..6a0fa11d9 100644
--- a/panels/network/net-device-bluetooth.c
+++ b/panels/network/net-device-bluetooth.c
@@ -93,7 +93,7 @@ nm_device_bluetooth_refresh_ui (NetDeviceBluetooth *self)
}
static void
-device_off_toggled (NetDeviceBluetooth *self)
+device_off_switch_changed_cb (NetDeviceBluetooth *self)
{
const GPtrArray *acs;
gboolean active;
@@ -130,7 +130,7 @@ device_off_toggled (NetDeviceBluetooth *self)
}
static void
-edit_connection (NetDeviceBluetooth *self)
+options_button_clicked_cb (NetDeviceBluetooth *self)
{
const gchar *uuid;
g_autofree gchar *cmdline = NULL;
@@ -170,18 +170,16 @@ net_device_bluetooth_class_init (NetDeviceBluetoothClass *klass)
gtk_widget_class_bind_template_child (widget_class, NetDeviceBluetooth, device_off_switch);
gtk_widget_class_bind_template_child (widget_class, NetDeviceBluetooth, options_button);
gtk_widget_class_bind_template_child (widget_class, NetDeviceBluetooth, separator);
+
+ gtk_widget_class_bind_template_callback (widget_class, device_off_switch_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, options_button_clicked_cb);
+
}
static void
net_device_bluetooth_init (NetDeviceBluetooth *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
-
- g_signal_connect_swapped (self->device_off_switch, "notify::active",
- G_CALLBACK (device_off_toggled), self);
-
- g_signal_connect_swapped (self->options_button, "clicked",
- G_CALLBACK (edit_connection), self);
gtk_widget_set_visible (GTK_WIDGET (self->options_button), g_find_program_in_path
("nm-connection-editor") != NULL);
}
diff --git a/panels/network/net-device-ethernet.c b/panels/network/net-device-ethernet.c
index c1d26f029..8a7bb4796 100644
--- a/panels/network/net-device-ethernet.c
+++ b/panels/network/net-device-ethernet.c
@@ -39,7 +39,6 @@ struct _NetDeviceEthernet
{
GtkBox parent;
- GtkButton *add_profile_button;
GtkButton *details_button;
GtkFrame *details_frame;
HdyActionRow *details_row;
@@ -242,7 +241,7 @@ show_details_for_row (NetDeviceEthernet *self, GtkButton *button)
}
static void
-show_details_for_wired (NetDeviceEthernet *self)
+details_button_clicked_cb (NetDeviceEthernet *self)
{
/* Translators: This is used as the title of the connection
* details window for ethernet, if there is only a single
@@ -387,7 +386,7 @@ client_connection_added_cb (NetDeviceEthernet *self)
}
static void
-add_profile (NetDeviceEthernet *self)
+add_profile_button_clicked_cb (NetDeviceEthernet *self)
{
NMConnection *connection;
NMSettingConnection *sc;
@@ -423,7 +422,7 @@ add_profile (NetDeviceEthernet *self)
}
static void
-device_off_toggled (NetDeviceEthernet *self)
+device_off_switch_changed_cb (NetDeviceEthernet *self)
{
NMConnection *connection;
@@ -482,13 +481,16 @@ net_device_ethernet_class_init (NetDeviceEthernetClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/control-center/network/network-ethernet.ui");
- gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, add_profile_button);
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, details_button);
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, details_frame);
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, details_row);
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, device_label);
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, device_off_switch);
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, scrolled_window);
+
+ gtk_widget_class_bind_template_callback (widget_class, device_off_switch_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, details_button_clicked_cb);
+ gtk_widget_class_bind_template_callback (widget_class, add_profile_button_clicked_cb);
}
static void
@@ -505,15 +507,6 @@ net_device_ethernet_init (NetDeviceEthernet *self)
g_signal_connect_swapped (self->list, "row-activated",
G_CALLBACK (connection_activated), self);
gtk_widget_show (GTK_WIDGET (self->list));
-
- g_signal_connect_swapped (self->device_off_switch, "notify::active",
- G_CALLBACK (device_off_toggled), self);
-
- g_signal_connect_swapped (self->details_button, "clicked",
- G_CALLBACK (show_details_for_wired), self);
-
- g_signal_connect_swapped (self->add_profile_button, "clicked",
- G_CALLBACK (add_profile), self);
}
NetDeviceEthernet *
diff --git a/panels/network/net-device-mobile.c b/panels/network/net-device-mobile.c
index 791cec9a3..536a37468 100644
--- a/panels/network/net-device-mobile.c
+++ b/panels/network/net-device-mobile.c
@@ -99,7 +99,7 @@ connection_activate_cb (GObject *source_object,
}
static void
-mobile_connection_changed_cb (NetDeviceMobile *self)
+network_combo_changed_cb (NetDeviceMobile *self)
{
gboolean ret;
g_autofree gchar *object_path = NULL;
@@ -438,7 +438,7 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *self)
}
static void
-device_off_toggled (NetDeviceMobile *self)
+device_off_switch_changed_cb (NetDeviceMobile *self)
{
const GPtrArray *acs;
gboolean active;
@@ -475,7 +475,7 @@ device_off_toggled (NetDeviceMobile *self)
}
static void
-edit_connection (NetDeviceMobile *self)
+options_button_clicked_cb (NetDeviceMobile *self)
{
const gchar *uuid;
g_autofree gchar *cmdline = NULL;
@@ -761,6 +761,10 @@ net_device_mobile_class_init (NetDeviceMobileClass *klass)
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, route_heading_label);
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, route_label);
gtk_widget_class_bind_template_child (widget_class, NetDeviceMobile, status_label);
+
+ gtk_widget_class_bind_template_callback (widget_class, device_off_switch_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, network_combo_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, options_button_clicked_cb);
}
static void
@@ -773,9 +777,6 @@ net_device_mobile_init (NetDeviceMobile *self)
self->cancellable = g_cancellable_new ();
/* setup mobile combobox model */
- g_signal_connect_swapped (self->network_combo, "changed",
- G_CALLBACK (mobile_connection_changed_cb),
- self);
renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self->network_combo),
renderer,
@@ -784,11 +785,6 @@ net_device_mobile_init (NetDeviceMobile *self)
"text", COLUMN_TITLE,
NULL);
- g_signal_connect_swapped (self->device_off_switch, "notify::active",
- G_CALLBACK (device_off_toggled), self);
-
- g_signal_connect_swapped (self->options_button, "clicked",
- G_CALLBACK (edit_connection), self);
gtk_widget_set_visible (GTK_WIDGET (self->options_button), g_find_program_in_path
("nm-connection-editor") != NULL);
}
diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c
index bf58c5290..8bcc83c95 100644
--- a/panels/network/net-device-wifi.c
+++ b/panels/network/net-device-wifi.c
@@ -59,10 +59,8 @@ struct _NetDeviceWifi
GtkStack parent;
GtkBox *center_box;
- GtkButton *connect_hidden_button;
GtkSwitch *device_off_switch;
GtkBox *header_box;
- GtkButton *history_button;
GtkBox *hotspot_box;
GtkLabel *hotspot_network_name_heading_label;
GtkLabel *hotspot_network_name_label;
@@ -380,7 +378,7 @@ nm_device_wifi_refresh_ui (NetDeviceWifi *self)
}
static void
-device_off_toggled (NetDeviceWifi *self)
+device_off_switch_changed_cb (NetDeviceWifi *self)
{
gboolean active;
@@ -394,7 +392,7 @@ device_off_toggled (NetDeviceWifi *self)
}
static void
-connect_to_hidden_network (NetDeviceWifi *self)
+connect_hidden_button_clicked_cb (NetDeviceWifi *self)
{
GtkWidget *toplevel;
@@ -692,7 +690,7 @@ overwrite_ssid_cb (GObject *source_object,
}
static void
-start_hotspot (NetDeviceWifi *self)
+start_hotspot_button_clicked_cb (NetDeviceWifi *self)
{
g_autofree gchar *active_ssid = NULL;
GtkWidget *window;
@@ -784,7 +782,7 @@ stop_hotspot_response_cb (NetDeviceWifi *self, gint response, GtkWidget *dialog)
}
static void
-switch_hotspot_changed_cb (NetDeviceWifi *self)
+hotspot_off_switch_changed_cb (NetDeviceWifi *self)
{
GtkWidget *dialog;
GtkWidget *window;
@@ -849,44 +847,6 @@ net_device_wifi_get_property (GObject *object,
}
}
-static void
-net_device_wifi_class_init (NetDeviceWifiClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->finalize = net_device_wifi_finalize;
- object_class->get_property = net_device_wifi_get_property;
-
- g_object_class_install_property (object_class,
- PROP_SCANNING,
- g_param_spec_boolean ("scanning",
- "Scanning",
- "Whether the device is scanning for access
points",
- FALSE,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/control-center/network/network-wifi.ui");
-
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, center_box);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, connect_hidden_button);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, device_off_switch);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, header_box);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, history_button);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, hotspot_box);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi,
hotspot_network_name_heading_label);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, hotspot_network_name_label);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, hotspot_off_switch);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, hotspot_security_heading_label);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi,
hotspot_security_key_heading_label);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, hotspot_security_key_label);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, hotspot_security_label);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, listbox_box);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, start_hotspot_button);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, status_label);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, title_label);
-}
-
static void
really_forgotten (GObject *source_object,
GAsyncResult *res,
@@ -1087,7 +1047,7 @@ on_connection_list_row_activated_cb (NetDeviceWifi *self,
}
static void
-open_history (NetDeviceWifi *self)
+history_button_clicked_cb (NetDeviceWifi *self)
{
GtkWidget *dialog;
GtkWidget *window;
@@ -1220,27 +1180,53 @@ ap_activated (NetDeviceWifi *self, GtkListBoxRow *row)
}
static void
-net_device_wifi_init (NetDeviceWifi *self)
+net_device_wifi_class_init (NetDeviceWifiClass *klass)
{
- gtk_widget_init_template (GTK_WIDGET (self));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- self->cancellable = g_cancellable_new ();
+ object_class->finalize = net_device_wifi_finalize;
+ object_class->get_property = net_device_wifi_get_property;
- /* setup wifi views */
- g_signal_connect_swapped (self->device_off_switch, "notify::active",
- G_CALLBACK (device_off_toggled), self);
+ g_object_class_install_property (object_class,
+ PROP_SCANNING,
+ g_param_spec_boolean ("scanning",
+ "Scanning",
+ "Whether the device is scanning for access
points",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_signal_connect_swapped (self->start_hotspot_button, "clicked",
- G_CALLBACK (start_hotspot), self);
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/control-center/network/network-wifi.ui");
- g_signal_connect_swapped (self->connect_hidden_button, "clicked",
- G_CALLBACK (connect_to_hidden_network), self);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, center_box);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, device_off_switch);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, header_box);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, hotspot_box);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi,
hotspot_network_name_heading_label);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, hotspot_network_name_label);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, hotspot_off_switch);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, hotspot_security_heading_label);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi,
hotspot_security_key_heading_label);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, hotspot_security_key_label);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, hotspot_security_label);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, listbox_box);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, start_hotspot_button);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, status_label);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, title_label);
- g_signal_connect_swapped (self->history_button, "clicked",
- G_CALLBACK (open_history), self);
+ gtk_widget_class_bind_template_callback (widget_class, connect_hidden_button_clicked_cb);
+ gtk_widget_class_bind_template_callback (widget_class, device_off_switch_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, history_button_clicked_cb);
+ gtk_widget_class_bind_template_callback (widget_class, hotspot_off_switch_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, start_hotspot_button_clicked_cb);
+}
- g_signal_connect_swapped (self->hotspot_off_switch, "notify::active",
- G_CALLBACK (switch_hotspot_changed_cb), self);
+static void
+net_device_wifi_init (NetDeviceWifi *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+
+ self->cancellable = g_cancellable_new ();
}
NetDeviceWifi *
diff --git a/panels/network/network-bluetooth.ui b/panels/network/network-bluetooth.ui
index 2e9da8a7d..e068af397 100644
--- a/panels/network/network-bluetooth.ui
+++ b/panels/network/network-bluetooth.ui
@@ -44,6 +44,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">center</property>
+ <signal name="notify::active" handler="device_off_switch_changed_cb"
object="NetDeviceBluetooth" swapped="yes"/>
<child internal-child="accessible">
<object class="AtkObject">
<property name="accessible-name" translatable="yes">Turn device off</property>
@@ -58,6 +59,7 @@
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="use_underline">True</property>
+ <signal name="clicked" handler="options_button_clicked_cb" object="NetDeviceBluetooth"
swapped="yes"/>
<style>
<class name="image-button"/>
</style>
diff --git a/panels/network/network-ethernet.ui b/panels/network/network-ethernet.ui
index 4b97e72b0..f5063158d 100644
--- a/panels/network/network-ethernet.ui
+++ b/panels/network/network-ethernet.ui
@@ -23,11 +23,12 @@
</object>
</child>
<child>
- <object class="GtkButton" id="add_profile_button">
+ <object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
+ <signal name="clicked" handler="add_profile_button_clicked_cb" object="NetDeviceEthernet"
swapped="yes"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
@@ -81,6 +82,7 @@
<property name="receives_default">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
+ <signal name="clicked" handler="details_button_clicked_cb"
object="NetDeviceEthernet" swapped="yes"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
@@ -101,6 +103,7 @@
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
+ <signal name="notify::active" handler="device_off_switch_changed_cb"
object="NetDeviceEthernet" swapped="yes"/>
</object>
</child>
</object>
diff --git a/panels/network/network-mobile.ui b/panels/network/network-mobile.ui
index 75f1a56b2..bc13dc44b 100644
--- a/panels/network/network-mobile.ui
+++ b/panels/network/network-mobile.ui
@@ -267,6 +267,7 @@
<property name="can_focus">False</property>
<property name="model">mobile_connections_list_store</property>
<property name="entry_text_column">1</property>
+ <signal name="changed" handler="network_combo_changed_cb" object="NetDeviceMobile"
swapped="yes"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -349,6 +350,7 @@
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
+ <signal name="notify::active" handler="device_off_switch_changed_cb"
object="NetDeviceMobile" swapped="yes"/>
</object>
<packing>
<property name="expand">False</property>
@@ -389,6 +391,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
+ <signal name="clicked" handler="options_button_clicked_cb" object="NetDeviceMobile"
swapped="yes"/>
<style>
<class name="image-button"/>
</style>
diff --git a/panels/network/network-wifi.ui b/panels/network/network-wifi.ui
index 0a78121b1..3e549b932 100644
--- a/panels/network/network-wifi.ui
+++ b/panels/network/network-wifi.ui
@@ -73,6 +73,7 @@
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
+ <signal name="notify::active" handler="hotspot_off_switch_changed_cb" object="NetDeviceWifi"
swapped="yes"/>
</object>
<packing>
<property name="expand">False</property>
@@ -257,6 +258,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">center</property>
+ <signal name="notify::active" handler="device_off_switch_changed_cb" object="NetDeviceWifi"
swapped="yes"/>
<child internal-child="accessible">
<object class="AtkObject">
<property name="accessible-name" translatable="yes">Turn Wi-Fi off</property>
@@ -290,13 +292,14 @@
<property name="spacing">6</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkModelButton" id="connect_hidden_button">
+ <object class="GtkModelButton">
<property name="label" translatable="yes">_Connect to Hidden Network…</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
<property name="xalign">0.0</property>
+ <signal name="clicked" handler="connect_hidden_button_clicked_cb" object="NetDeviceWifi"
swapped="yes"/>
</object>
</child>
<child>
@@ -307,16 +310,18 @@
<property name="receives_default">True</property>
<property name="use_underline">True</property>
<property name="xalign">0.0</property>
+ <signal name="clicked" handler="start_hotspot_button_clicked_cb" object="NetDeviceWifi"
swapped="yes"/>
</object>
</child>
<child>
- <object class="GtkModelButton" id="history_button">
+ <object class="GtkModelButton">
<property name="label" translatable="yes">_Known Wi-Fi Networks</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
<property name="xalign">0.0</property>
+ <signal name="clicked" handler="history_button_clicked_cb" object="NetDeviceWifi" swapped="yes"/>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]