[gnome-control-center] network: Remove helper function with minimal value



commit 9b1226aea53a7c01e6dfa292b89e4004de502aa6
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Oct 18 14:28:46 2019 +1300

    network: Remove helper function with minimal value
    
    This can be more easily optimised away in the modules that use it.

 panels/network/connection-editor/ce-page-details.c | 26 ++++++++++++++------
 panels/network/net-device-mobile.c                 | 28 ++++++++++++----------
 panels/network/net-device-wifi.c                   | 14 ++++++++---
 panels/network/panel-common.c                      |  2 +-
 panels/network/panel-common.h                      |  3 ---
 5 files changed, 46 insertions(+), 27 deletions(-)
---
diff --git a/panels/network/connection-editor/ce-page-details.c 
b/panels/network/connection-editor/ce-page-details.c
index 5a989ae90..820df6c0b 100644
--- a/panels/network/connection-editor/ce-page-details.c
+++ b/panels/network/connection-editor/ce-page-details.c
@@ -109,7 +109,9 @@ update_last_used (CEPageDetails *self, NMConnection *connection)
         else
                 last_used = g_strdup_printf (ngettext ("%i day ago", "%i days ago", days), days);
 out:
-        panel_set_device_widget_details (self->last_used_heading_label, self->last_used_label, last_used);
+        gtk_label_set_label (self->last_used_label, last_used);
+        gtk_widget_set_visible (GTK_WIDGET (self->last_used_heading_label), last_used != NULL);
+        gtk_widget_set_visible (GTK_WIDGET (self->last_used_label), last_used != NULL);
 }
 
 static void
@@ -218,18 +220,24 @@ connect_details_page (CEPageDetails *self)
         }
         if (speed > 0)
                 speed_label = g_strdup_printf (_("%d Mb/s"), speed);
-        panel_set_device_widget_details (self->speed_heading_label, self->speed_label, speed_label);
+        gtk_label_set_label (self->speed_label, speed_label);
+        gtk_widget_set_visible (GTK_WIDGET (self->speed_heading_label), speed_label != NULL);
+        gtk_widget_set_visible (GTK_WIDGET (self->speed_label), speed_label != NULL);
 
         if (NM_IS_DEVICE_WIFI (self->device))
                 hw_address = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (self->device));
         else if (NM_IS_DEVICE_ETHERNET (self->device))
                 hw_address = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (self->device));
 
-        panel_set_device_widget_details (self->mac_heading_label, self->mac_label, hw_address);
+        gtk_label_set_label (self->mac_label, hw_address);
+        gtk_widget_set_visible (GTK_WIDGET (self->mac_heading_label), hw_address != NULL);
+        gtk_widget_set_visible (GTK_WIDGET (self->mac_label), hw_address != NULL);
 
         if (device_is_active && active_ap)
                 security_string = get_ap_security_string (active_ap);
-        panel_set_device_widget_details (self->security_heading_label, self->security_label, 
security_string);
+        gtk_label_set_label (self->security_label, security_string);
+        gtk_widget_set_visible (GTK_WIDGET (self->security_heading_label), security_string != NULL);
+        gtk_widget_set_visible (GTK_WIDGET (self->security_label), security_string != NULL);
 
         strength = 0;
         if (self->ap != NULL)
@@ -247,7 +255,9 @@ connect_details_page (CEPageDetails *self)
                 strength_label = C_("Signal strength", "Good");
         else
                 strength_label = C_("Signal strength", "Excellent");
-        panel_set_device_widget_details (self->strength_heading_label, self->strength_label, strength_label);
+        gtk_label_set_label (self->strength_label, strength_label);
+        gtk_widget_set_visible (GTK_WIDGET (self->strength_heading_label), strength_label != NULL);
+        gtk_widget_set_visible (GTK_WIDGET (self->strength_label), strength_label != NULL);
 
         /* set IP entries */
         panel_set_device_widgets (self->ipv4_heading_label, self->ipv4_label,
@@ -258,8 +268,10 @@ connect_details_page (CEPageDetails *self)
 
         if (!device_is_active && CE_PAGE (self)->connection)
                 update_last_used (self, CE_PAGE (self)->connection);
-        else
-                panel_set_device_widget_details (self->last_used_heading_label, self->last_used_label, NULL);
+        else {
+                gtk_widget_set_visible (GTK_WIDGET (self->last_used_heading_label), FALSE);
+                gtk_widget_set_visible (GTK_WIDGET (self->last_used_label), FALSE);
+        }
 
         /* Auto connect check */
         if (g_str_equal (type, NM_SETTING_VPN_SETTING_NAME)) {
diff --git a/panels/network/net-device-mobile.c b/panels/network/net-device-mobile.c
index 044ddc934..365fe9c05 100644
--- a/panels/network/net-device-mobile.c
+++ b/panels/network/net-device-mobile.c
@@ -269,7 +269,9 @@ device_mobile_refresh_equipment_id (NetDeviceMobile *self)
                                                   "ControlCenter::EquipmentIdentifier");
         }
 
-        panel_set_device_widget_details (self->imei_heading_label, self->imei_label, equipment_id);
+        gtk_label_set_label (self->imei_label, equipment_id);
+        gtk_widget_set_visible (GTK_WIDGET (self->imei_heading_label), equipment_id != NULL);
+        gtk_widget_set_visible (GTK_WIDGET (self->imei_label), equipment_id != NULL);
 }
 
 static gchar *
@@ -314,8 +316,9 @@ device_mobile_find_provider (NetDeviceMobile *self,
 static void
 device_mobile_refresh_operator_name (NetDeviceMobile *self)
 {
+        g_autofree gchar *operator_name = NULL;
+
         if (self->mm_object != NULL) {
-                g_autofree gchar *operator_name = NULL;
                 MMModem3gpp *modem_3gpp;
                 MMModemCdma *modem_cdma;
 
@@ -350,7 +353,6 @@ device_mobile_refresh_operator_name (NetDeviceMobile *self)
                                  operator_name);
                 }
 
-                panel_set_device_widget_details (self->provider_heading_label, self->provider_label, 
operator_name);
         } else {
                 const gchar *gsm;
                 const gchar *cdma;
@@ -361,17 +363,17 @@ device_mobile_refresh_operator_name (NetDeviceMobile *self)
                 cdma = g_object_get_data (G_OBJECT (self),
                                           "ControlCenter::OperatorNameCdma");
 
-                if (gsm != NULL && cdma != NULL) {
-                        g_autofree gchar *both = g_strdup_printf ("%s, %s", gsm, cdma);
-                        panel_set_device_widget_details (self->provider_heading_label, self->provider_label, 
both);
-                } else if (gsm != NULL) {
-                        panel_set_device_widget_details (self->provider_heading_label, self->provider_label, 
gsm);
-                } else if (cdma != NULL) {
-                        panel_set_device_widget_details (self->provider_heading_label, self->provider_label, 
cdma);
-                } else {
-                        panel_set_device_widget_details (self->provider_heading_label, self->provider_label, 
NULL);
-                }
+                if (gsm != NULL && cdma != NULL)
+                        operator_name = g_strdup_printf ("%s, %s", gsm, cdma);
+                else if (gsm != NULL)
+                        operator_name = g_strdup (gsm);
+                else if (cdma != NULL)
+                        operator_name = g_strdup (cdma);
         }
+
+        gtk_label_set_label (self->provider_label, operator_name);
+        gtk_widget_set_visible (GTK_WIDGET (self->provider_heading_label), operator_name != NULL);
+        gtk_widget_set_visible (GTK_WIDGET (self->provider_label), operator_name != NULL);
 }
 
 static void
diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c
index ce96ccc3e..5d7a91d10 100644
--- a/panels/network/net-device-wifi.c
+++ b/panels/network/net-device-wifi.c
@@ -329,9 +329,17 @@ nm_device_wifi_refresh_hotspot (NetDeviceWifi *self)
         g_debug ("Refreshing hotspot labels to name: '%s', security key: '%s', security: '%s'",
                  hotspot_ssid, hotspot_secret, hotspot_security);
 
-        panel_set_device_widget_details (self->hotspot_network_name_heading_label, 
self->hotspot_network_name_label, hotspot_ssid);
-        panel_set_device_widget_details (self->hotspot_security_key_heading_label, 
self->hotspot_security_key_label, hotspot_secret);
-        panel_set_device_widget_details (self->hotspot_security_heading_label, self->hotspot_security_label, 
hotspot_security);
+        gtk_label_set_label (self->hotspot_network_name_label, hotspot_ssid);
+        gtk_widget_set_visible (GTK_WIDGET (self->hotspot_network_name_heading_label), hotspot_ssid != NULL);
+        gtk_widget_set_visible (GTK_WIDGET (self->hotspot_network_name_label), hotspot_ssid != NULL);
+
+        gtk_label_set_label (self->hotspot_security_key_label, hotspot_secret);
+        gtk_widget_set_visible (GTK_WIDGET (self->hotspot_security_key_heading_label), hotspot_secret != 
NULL);
+        gtk_widget_set_visible (GTK_WIDGET (self->hotspot_security_key_label), hotspot_secret != NULL);
+
+        gtk_label_set_label (self->hotspot_security_label, hotspot_security);
+        gtk_widget_set_visible (GTK_WIDGET (self->hotspot_security_heading_label), hotspot_security != NULL);
+        gtk_widget_set_visible (GTK_WIDGET (self->hotspot_security_label), hotspot_security != NULL);
 }
 
 static void
diff --git a/panels/network/panel-common.c b/panels/network/panel-common.c
index bb1b59029..24e61f475 100644
--- a/panels/network/panel-common.c
+++ b/panels/network/panel-common.c
@@ -314,7 +314,7 @@ panel_device_status_to_localized_string (NMDevice *nm_device,
         return g_string_free (string, FALSE);
 }
 
-gboolean
+static gboolean
 panel_set_device_widget_details (GtkLabel *heading,
                                  GtkLabel *widget,
                                  const gchar *value)
diff --git a/panels/network/panel-common.h b/panels/network/panel-common.h
index 9d3581e8f..b1cf16e75 100644
--- a/panels/network/panel-common.h
+++ b/panels/network/panel-common.h
@@ -28,9 +28,6 @@ G_BEGIN_DECLS
 
 gchar           *panel_device_status_to_localized_string       (NMDevice *nm_device,
                                                                 const gchar *speed);
-gboolean         panel_set_device_widget_details               (GtkLabel *heading,
-                                                                GtkLabel *widget,
-                                                                const gchar *value);
 void             panel_set_device_widgets                      (GtkLabel *ipv4_heading_label, GtkLabel 
*ipv4_label,
                                                                 GtkLabel *ipv6_heading_label, GtkLabel 
*ipv6_label,
                                                                 GtkLabel *heading_dns, GtkLabel *dns_label,


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