[gnome-control-center] Split device removed into separate functions
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] Split device removed into separate functions
- Date: Tue, 30 Jun 2020 04:04:35 +0000 (UTC)
commit 0e26087a01dcfb82b32aceea0c5a74d3da5689ea
Author: Jamison Lofthouse <jamison lofthouse gmail com>
Date: Wed Jun 24 11:35:16 2020 -0400
Split device removed into separate functions
panels/network/cc-wifi-panel.c | 69 ++++++++++++++++++++++--------------------
1 file changed, 37 insertions(+), 32 deletions(-)
---
diff --git a/panels/network/cc-wifi-panel.c b/panels/network/cc-wifi-panel.c
index 2080475b7..126adda06 100644
--- a/panels/network/cc-wifi-panel.c
+++ b/panels/network/cc-wifi-panel.c
@@ -174,6 +174,42 @@ add_wifi_device (CcWifiPanel *self,
nm_device_get_description (device));
}
+static void
+remove_wifi_device (CcWifiPanel *self,
+ NMDevice *device)
+{
+ GtkWidget *child;
+ const gchar *id;
+ guint i;
+
+ if (!NM_IS_DEVICE_WIFI (device) || !nm_device_get_managed (device))
+ return;
+
+ id = nm_device_get_udi (device);
+
+ /* Destroy all stack pages related to this device */
+ child = gtk_stack_get_child_by_name (self->stack, id);
+ gtk_widget_destroy (child);
+
+ child = gtk_stack_get_child_by_name (self->header_stack, id);
+ gtk_widget_destroy (child);
+
+ /* Remove from the devices list */
+ for (i = 0; i < self->devices->len; i++)
+ {
+ NetDeviceWifi *net_device = g_ptr_array_index (self->devices, i);
+
+ if (net_device_wifi_get_device (net_device) == device)
+ {
+ g_ptr_array_remove (self->devices, net_device);
+ break;
+ }
+ }
+
+ /* Update the title widget */
+ update_devices_names (self);
+}
+
static void
check_main_stack_page (CcWifiPanel *self)
{
@@ -426,38 +462,7 @@ device_added_cb (CcWifiPanel *self, NMDevice *device)
static void
device_removed_cb (CcWifiPanel *self, NMDevice *device)
{
- GtkWidget *child;
- const gchar *id;
- guint i;
-
- if (!NM_IS_DEVICE_WIFI (device) || !nm_device_get_managed (device))
- return;
-
- id = nm_device_get_udi (device);
-
- /* Destroy all stack pages related to this device */
- child = gtk_stack_get_child_by_name (self->stack, id);
- gtk_widget_destroy (child);
-
- child = gtk_stack_get_child_by_name (self->header_stack, id);
- gtk_widget_destroy (child);
-
- /* Remove from the devices list */
- for (i = 0; i < self->devices->len; i++)
- {
- NetDeviceWifi *net_device = g_ptr_array_index (self->devices, i);
-
- if (net_device_wifi_get_device (net_device) == device)
- {
- g_ptr_array_remove (self->devices, net_device);
- break;
- }
- }
-
- /* Update the title widget */
- update_devices_names (self);
-
- /* And check which page should be visible */
+ remove_wifi_device (self, device);
check_main_stack_page (self);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]