[gnome-control-center] network: Remove helper functions
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Remove helper functions
- Date: Tue, 22 Oct 2019 20:18:22 +0000 (UTC)
commit 7f410ee1c650419e9806d1f56caa374ed9d2153c
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Oct 18 15:13:55 2019 +1300
network: Remove helper functions
They're not complex enough or used in enough places to warrant keeping.
They can be better refactored in the classes that use them.
panels/network/connection-editor/ce-page-details.c | 17 +++++++----
panels/network/net-device-ethernet.c | 19 +++++++++----
panels/network/net-device-mobile.c | 16 +++++++----
panels/network/panel-common.c | 33 ----------------------
panels/network/panel-common.h | 3 --
5 files changed, 36 insertions(+), 52 deletions(-)
---
diff --git a/panels/network/connection-editor/ce-page-details.c
b/panels/network/connection-editor/ce-page-details.c
index 68ab27824..c01def0e5 100644
--- a/panels/network/connection-editor/ce-page-details.c
+++ b/panels/network/connection-editor/ce-page-details.c
@@ -26,7 +26,6 @@
#include <NetworkManager.h>
-#include "../panel-common.h"
#include "ce-page-details.h"
G_DEFINE_TYPE (CEPageDetails, ce_page_details, CE_TYPE_PAGE)
@@ -264,17 +263,20 @@ connect_details_page (CEPageDetails *self)
if (device_is_active && self->device != NULL)
ipv4_config = nm_device_get_ip4_config (self->device);
if (ipv4_config != NULL) {
- g_autofree gchar *ipv4_text = NULL;
+ GPtrArray *addresses;
+ const gchar *ipv4_text = NULL;
g_autofree gchar *dns_text = NULL;
const gchar *route_text;
- ipv4_text = panel_get_ip4_address_as_string (ipv4_config);
+ addresses = nm_ip_config_get_addresses (ipv4_config);
+ if (addresses->len > 0)
+ ipv4_text = nm_ip_address_get_address (g_ptr_array_index (addresses, 0));
gtk_label_set_label (self->ipv4_label, ipv4_text);
gtk_widget_set_visible (GTK_WIDGET (self->ipv4_heading_label), ipv4_text != NULL);
gtk_widget_set_visible (GTK_WIDGET (self->ipv4_label), ipv4_text != NULL);
have_ipv4_address = ipv4_text != NULL;
- dns_text = panel_get_ip4_dns_as_string (ipv4_config);
+ dns_text = g_strjoinv (" ", (char **) nm_ip_config_get_nameservers (ipv4_config));
gtk_label_set_label (self->dns_label, dns_text);
gtk_widget_set_visible (GTK_WIDGET (self->dns_heading_label), dns_text != NULL);
gtk_widget_set_visible (GTK_WIDGET (self->dns_label), dns_text != NULL);
@@ -295,9 +297,12 @@ connect_details_page (CEPageDetails *self)
if (device_is_active && self->device != NULL)
ipv6_config = nm_device_get_ip6_config (self->device);
if (ipv6_config != NULL) {
- g_autofree gchar *ipv6_text = NULL;
+ GPtrArray *addresses;
+ const gchar *ipv6_text = NULL;
- ipv6_text = panel_get_ip6_address_as_string (ipv6_config);
+ addresses = nm_ip_config_get_addresses (ipv6_config);
+ if (addresses->len > 0)
+ ipv6_text = nm_ip_address_get_address (g_ptr_array_index (addresses, 0));
gtk_label_set_label (self->ipv6_label, ipv6_text);
gtk_widget_set_visible (GTK_WIDGET (self->ipv6_heading_label), ipv6_text != NULL);
gtk_widget_set_visible (GTK_WIDGET (self->ipv6_label), ipv6_text != NULL);
diff --git a/panels/network/net-device-ethernet.c b/panels/network/net-device-ethernet.c
index c70197d16..5762e533f 100644
--- a/panels/network/net-device-ethernet.c
+++ b/panels/network/net-device-ethernet.c
@@ -142,21 +142,30 @@ add_details (GtkWidget *details, NMDevice *device, NMConnection *connection)
{
NMIPConfig *ip4_config = NULL;
NMIPConfig *ip6_config = NULL;
- g_autofree gchar *ip4_address = NULL;
+ const gchar *ip4_address = NULL;
const gchar *ip4_route = NULL;
g_autofree gchar *ip4_dns = NULL;
- g_autofree gchar *ip6_address = NULL;
+ const gchar *ip6_address = NULL;
gint i = 0;
ip4_config = nm_device_get_ip4_config (device);
if (ip4_config) {
- ip4_address = panel_get_ip4_address_as_string (ip4_config);
+ GPtrArray *addresses;
+
+ addresses = nm_ip_config_get_addresses (ip4_config);
+ if (addresses->len > 0)
+ ip4_address = nm_ip_address_get_address (g_ptr_array_index (addresses, 0));
+
ip4_route = nm_ip_config_get_gateway (ip4_config);
- ip4_dns = panel_get_ip4_dns_as_string (ip4_config);
+ ip4_dns = g_strjoinv (" ", (char **) nm_ip_config_get_nameservers (ip4_config));
}
ip6_config = nm_device_get_ip6_config (device);
if (ip6_config) {
- ip6_address = panel_get_ip6_address_as_string (ip6_config);
+ GPtrArray *addresses;
+
+ addresses = nm_ip_config_get_addresses (ip6_config);
+ if (addresses->len > 0)
+ ip6_address = nm_ip_address_get_address (g_ptr_array_index (addresses, 0));
}
if (ip4_address && ip6_address) {
diff --git a/panels/network/net-device-mobile.c b/panels/network/net-device-mobile.c
index 73152b754..13689475e 100644
--- a/panels/network/net-device-mobile.c
+++ b/panels/network/net-device-mobile.c
@@ -419,17 +419,20 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *self)
ipv4_config = nm_device_get_ip4_config (nm_device);
if (ipv4_config != NULL) {
- g_autofree gchar *ipv4_text = NULL;
+ GPtrArray *addresses;
+ const gchar *ipv4_text = NULL;
g_autofree gchar *dns_text = NULL;
const gchar *route_text;
- ipv4_text = panel_get_ip4_address_as_string (ipv4_config);
+ addresses = nm_ip_config_get_addresses (ipv4_config);
+ if (addresses->len > 0)
+ ipv4_text = nm_ip_address_get_address (g_ptr_array_index (addresses, 0));
gtk_label_set_label (self->ipv4_label, ipv4_text);
gtk_widget_set_visible (GTK_WIDGET (self->ipv4_heading_label), ipv4_text != NULL);
gtk_widget_set_visible (GTK_WIDGET (self->ipv4_label), ipv4_text != NULL);
have_ipv4_address = ipv4_text != NULL;
- dns_text = panel_get_ip4_dns_as_string (ipv4_config);
+ dns_text = g_strjoinv (" ", (char **) nm_ip_config_get_nameservers (ipv4_config));
gtk_label_set_label (self->dns_label, dns_text);
gtk_widget_set_visible (GTK_WIDGET (self->dns_heading_label), dns_text != NULL);
gtk_widget_set_visible (GTK_WIDGET (self->dns_label), dns_text != NULL);
@@ -449,9 +452,12 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *self)
ipv6_config = nm_device_get_ip6_config (nm_device);
if (ipv6_config != NULL) {
- g_autofree gchar *ipv6_text = NULL;
+ GPtrArray *addresses;
+ const gchar *ipv6_text = NULL;
- ipv6_text = panel_get_ip6_address_as_string (ipv6_config);
+ addresses = nm_ip_config_get_addresses (ipv6_config);
+ if (addresses->len > 0)
+ ipv6_text = nm_ip_address_get_address (g_ptr_array_index (addresses, 0));
gtk_label_set_label (self->ipv6_label, ipv6_text);
gtk_widget_set_visible (GTK_WIDGET (self->ipv6_heading_label), ipv6_text != NULL);
gtk_widget_set_visible (GTK_WIDGET (self->ipv6_label), ipv6_text != NULL);
diff --git a/panels/network/panel-common.c b/panels/network/panel-common.c
index 5e099a364..a4eb1184f 100644
--- a/panels/network/panel-common.c
+++ b/panels/network/panel-common.c
@@ -313,36 +313,3 @@ panel_device_status_to_localized_string (NMDevice *nm_device,
return g_string_free (string, FALSE);
}
-
-gchar *
-panel_get_ip4_address_as_string (NMIPConfig *ip4_config)
-{
- GPtrArray *array;
- NMIPAddress *address;
-
- array = nm_ip_config_get_addresses (ip4_config);
- if (array->len < 1)
- return NULL;
- address = array->pdata[0];
- return g_strdup (nm_ip_address_get_address (address));
-}
-
-gchar *
-panel_get_ip4_dns_as_string (NMIPConfig *ip4_config)
-{
- return g_strjoinv (" ",
- (char **) nm_ip_config_get_nameservers (ip4_config));
-}
-
-gchar *
-panel_get_ip6_address_as_string (NMIPConfig *ip6_config)
-{
- GPtrArray *array;
- NMIPAddress *address;
-
- array = nm_ip_config_get_addresses (ip6_config);
- if (array->len < 1)
- return NULL;
- address = array->pdata[0];
- return g_strdup (nm_ip_address_get_address (address));
-}
diff --git a/panels/network/panel-common.h b/panels/network/panel-common.h
index dcb6a54a0..76d561e3e 100644
--- a/panels/network/panel-common.h
+++ b/panels/network/panel-common.h
@@ -28,8 +28,5 @@ G_BEGIN_DECLS
gchar *panel_device_status_to_localized_string (NMDevice *nm_device,
const gchar *speed);
-gchar *panel_get_ip4_address_as_string (NMIPConfig *config);
-gchar *panel_get_ip4_dns_as_string (NMIPConfig *config);
-gchar *panel_get_ip6_address_as_string (NMIPConfig *config);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]