[gnome-control-center] network: Merge together methods



commit 5244b013265f8e769c239ca60247d0672e132b15
Author: Robert Ancell <robert ancell canonical com>
Date:   Thu Oct 24 11:08:41 2019 +1300

    network: Merge together methods
    
    A method was public, and not being used. Simplify the case it's used in.

 panels/network/cc-network-panel.c | 53 +++++++++++++--------------------------
 panels/network/cc-network-panel.h |  2 --
 2 files changed, 17 insertions(+), 38 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index b443cf09a..e788160a6 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -243,51 +243,34 @@ object_removed_cb (CcNetworkPanel *self, NetObject *object)
                 gtk_widget_destroy (widget);
 }
 
-GPtrArray *
-cc_network_panel_get_devices (CcNetworkPanel *self)
+static void
+panel_refresh_device_titles (CcNetworkPanel *self)
 {
-        GPtrArray *devices;
-        guint i;
-
-        g_return_val_if_fail (CC_IS_NETWORK_PANEL (self), NULL);
-
-        devices = g_ptr_array_new_with_free_func (g_object_unref);
+        g_autoptr(GPtrArray) ndarray = NULL;
+        g_autoptr(GPtrArray) nmdarray = NULL;
+        NetDevice **devices;
+        NMDevice **nm_devices;
+        g_auto(GStrv) titles = NULL;
+        guint i, num_devices;
 
+        ndarray = g_ptr_array_new ();
+        nmdarray = g_ptr_array_new ();
         for (i = 0; i < self->devices->len; i++) {
                 NetObject *object = g_ptr_array_index (self->devices, i);
+                NMDevice *nm_device;
 
                 if (!NET_IS_DEVICE (object))
                         continue;
 
-                g_ptr_array_add (devices, g_object_ref (object));
+                nm_device = net_device_get_nm_device (NET_DEVICE (object));
+                if (nm_device != NULL) {
+                        g_ptr_array_add (ndarray, object);
+                        g_ptr_array_add (nmdarray, nm_device);
+                }
         }
 
-        return devices;
-}
-
-static void
-panel_refresh_device_titles (CcNetworkPanel *self)
-{
-        GPtrArray *ndarray, *nmdarray;
-        NetDevice **devices;
-        NMDevice **nm_devices, *nm_device;
-        g_auto(GStrv) titles = NULL;
-        gint i, num_devices;
-
-        ndarray = cc_network_panel_get_devices (self);
-        if (!ndarray->len) {
-                g_ptr_array_free (ndarray, TRUE);
+        if (ndarray->len == 0)
                 return;
-        }
-
-        nmdarray = g_ptr_array_new ();
-        for (i = 0; i < ndarray->len; i++) {
-                nm_device = net_device_get_nm_device (ndarray->pdata[i]);
-                if (nm_device)
-                        g_ptr_array_add (nmdarray, nm_device);
-                else
-                        g_ptr_array_remove_index (ndarray, i--);
-        }
 
         devices = (NetDevice **)ndarray->pdata;
         nm_devices = (NMDevice **)nmdarray->pdata;
@@ -306,8 +289,6 @@ panel_refresh_device_titles (CcNetworkPanel *self)
                 else
                         net_object_set_title (NET_OBJECT (devices[i]), titles[i]);
         }
-        g_ptr_array_free (ndarray, TRUE);
-        g_ptr_array_free (nmdarray, TRUE);
 }
 
 static gboolean
diff --git a/panels/network/cc-network-panel.h b/panels/network/cc-network-panel.h
index e4db954d3..9141ad078 100644
--- a/panels/network/cc-network-panel.h
+++ b/panels/network/cc-network-panel.h
@@ -27,6 +27,4 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (CcNetworkPanel, cc_network_panel, CC, NETWORK_PANEL, CcPanel)
 
-GPtrArray *cc_network_panel_get_devices (CcNetworkPanel *panel);
-
 G_END_DECLS


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