[gnome-control-center] network: display IPv6 gateway
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: display IPv6 gateway
- Date: Wed, 19 May 2021 02:43:41 +0000 (UTC)
commit 5a9fa905bc28b45c2f4d0c65da60c7a7fb96d7bd
Author: treysis <treysis gmx net>
Date: Wed May 19 02:43:39 2021 +0000
network: display IPv6 gateway
panels/network/connection-editor/ce-page-details.c | 44 ++++++++++++++--------
panels/network/net-device-ethernet.c | 10 ++++-
panels/network/net-device-mobile.c | 30 +++++++++++----
3 files changed, 61 insertions(+), 23 deletions(-)
---
diff --git a/panels/network/connection-editor/ce-page-details.c
b/panels/network/connection-editor/ce-page-details.c
index 82085580c..390851569 100644
--- a/panels/network/connection-editor/ce-page-details.c
+++ b/panels/network/connection-editor/ce-page-details.c
@@ -248,7 +248,7 @@ connect_details_page (CEPageDetails *self)
NMIPConfig *ipv4_config = NULL, *ipv6_config = NULL;
gboolean have_ipv4_address = FALSE, have_ipv6_address = FALSE;
gboolean have_dns4 = FALSE, have_dns6 = FALSE;
-
+ const gchar *route4_text = NULL, *route6_text = NULL;
sc = nm_connection_get_setting_connection (self->connection);
type = nm_setting_connection_get_connection_type (sc);
@@ -342,13 +342,15 @@ connect_details_page (CEPageDetails *self)
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);
- if (device_is_active && self->device != NULL)
+ if (device_is_active && self->device != NULL) {
ipv4_config = nm_device_get_ip4_config (self->device);
+ ipv6_config = nm_device_get_ip6_config (self->device);
+ }
+
if (ipv4_config != NULL) {
GPtrArray *addresses;
const gchar *ipv4_text = NULL;
g_autofree gchar *ip4_dns = NULL;
- const gchar *route_text;
addresses = nm_ip_config_get_addresses (ipv4_config);
if (addresses->len > 0)
@@ -366,21 +368,14 @@ connect_details_page (CEPageDetails *self)
gtk_widget_set_visible (GTK_WIDGET (self->dns4_label), ip4_dns != NULL);
have_dns4 = ip4_dns != NULL;
- route_text = nm_ip_config_get_gateway (ipv4_config);
- gtk_label_set_label (self->route_label, route_text);
- gtk_widget_set_visible (GTK_WIDGET (self->route_heading_label), route_text != NULL);
- gtk_widget_set_visible (GTK_WIDGET (self->route_label), route_text != NULL);
+ route4_text = nm_ip_config_get_gateway (ipv4_config);
} else {
gtk_widget_hide (GTK_WIDGET (self->ipv4_heading_label));
gtk_widget_hide (GTK_WIDGET (self->ipv4_label));
gtk_widget_hide (GTK_WIDGET (self->dns4_heading_label));
gtk_widget_hide (GTK_WIDGET (self->dns4_label));
- gtk_widget_hide (GTK_WIDGET (self->route_heading_label));
- gtk_widget_hide (GTK_WIDGET (self->route_label));
}
- 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;
g_autofree gchar *ip6_dns = NULL;
@@ -399,6 +394,8 @@ connect_details_page (CEPageDetails *self)
gtk_widget_set_visible (GTK_WIDGET (self->dns6_heading_label), ip6_dns != NULL);
gtk_widget_set_visible (GTK_WIDGET (self->dns6_label), ip6_dns != NULL);
have_dns6 = ip6_dns != NULL;
+
+ route6_text = nm_ip_config_get_gateway (ipv6_config);
} else {
gtk_widget_hide (GTK_WIDGET (self->ipv6_heading_label));
gtk_widget_hide (GTK_WIDGET (self->ipv6_label));
@@ -409,8 +406,7 @@ connect_details_page (CEPageDetails *self)
if (have_ipv4_address && have_ipv6_address) {
gtk_label_set_label (self->ipv4_heading_label, _("IPv4 Address"));
gtk_label_set_label (self->ipv6_heading_label, _("IPv6 Address"));
- }
- else {
+ } else {
gtk_label_set_label (self->ipv4_heading_label, _("IP Address"));
gtk_label_set_label (self->ipv6_heading_label, _("IP Address"));
}
@@ -418,12 +414,30 @@ connect_details_page (CEPageDetails *self)
if (have_dns4 && have_dns6) {
gtk_label_set_label (self->dns4_heading_label, _("DNS4"));
gtk_label_set_label (self->dns6_heading_label, _("DNS6"));
- }
- else {
+ } else {
gtk_label_set_label (self->dns4_heading_label, _("DNS"));
gtk_label_set_label (self->dns6_heading_label, _("DNS"));
}
+ if (route4_text != NULL || route6_text != NULL) {
+ g_autofree const gchar *routes_text = NULL;
+
+ if (route4_text == NULL) {
+ routes_text = g_strdup (route6_text);
+ } else if (route6_text == NULL) {
+ routes_text = g_strdup (route4_text);
+ } else {
+ routes_text = g_strjoin ("\n", route4_text, route6_text, NULL);
+ }
+ gtk_label_set_label (self->route_label, routes_text);
+ gtk_widget_set_visible (GTK_WIDGET (self->route_heading_label), routes_text != NULL);
+ gtk_widget_set_valign (GTK_WIDGET (self->route_heading_label), GTK_ALIGN_START);
+ gtk_widget_set_visible (GTK_WIDGET (self->route_label), routes_text != NULL);
+ } else {
+ gtk_widget_hide (GTK_WIDGET (self->route_heading_label));
+ gtk_widget_hide (GTK_WIDGET (self->route_label));
+ }
+
if (!device_is_active && self->connection)
update_last_used (self, self->connection);
else {
diff --git a/panels/network/net-device-ethernet.c b/panels/network/net-device-ethernet.c
index bdf810412..a4c3a7275 100644
--- a/panels/network/net-device-ethernet.c
+++ b/panels/network/net-device-ethernet.c
@@ -117,6 +117,7 @@ add_details (GtkWidget *details, NMDevice *device, NMConnection *connection)
const gchar *ip4_route = NULL;
g_autofree gchar *ip4_dns = NULL;
g_autofree gchar *ip6_addresses = NULL;
+ const gchar *ip6_route = NULL;
g_autofree gchar *ip6_dns = NULL;
gint i = 0;
@@ -136,6 +137,7 @@ add_details (GtkWidget *details, NMDevice *device, NMConnection *connection)
ip6_config = nm_device_get_ip6_config (device);
if (ip6_config) {
ip6_addresses = net_device_get_ip6_addresses (ip6_config);
+ ip6_route = nm_ip_config_get_gateway (ip6_config);
ip6_dns = g_strjoinv (" ", (char **) nm_ip_config_get_nameservers (ip6_config));
if (!*ip6_dns)
ip6_dns = NULL;
@@ -154,8 +156,14 @@ add_details (GtkWidget *details, NMDevice *device, NMConnection *connection)
add_details_row (details, i++, _("Hardware Address"), nm_device_get_hw_address (device));
- if (ip4_route)
+ if (ip4_route && ip6_route) {
+ g_autofree gchar *ip_routes = g_strjoin ("\n", ip4_route, ip6_route, NULL);
+ add_details_row (details, i++, _("Default Route"), ip_routes);
+ } else if (ip4_route) {
add_details_row (details, i++, _("Default Route"), ip4_route);
+ } else if (ip6_route) {
+ add_details_row (details, i++, _("Default Route"), ip6_route);
+ }
if (ip4_dns && ip6_dns) {
add_details_row (details, i++, _("DNS4"), ip4_dns);
diff --git a/panels/network/net-device-mobile.c b/panels/network/net-device-mobile.c
index 9039f2b7b..886180ebc 100644
--- a/panels/network/net-device-mobile.c
+++ b/panels/network/net-device-mobile.c
@@ -352,6 +352,7 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *self)
NMIPConfig *ipv4_config = NULL, *ipv6_config = NULL;
gboolean have_ipv4_address = FALSE, have_ipv6_address = FALSE;
gboolean have_dns4 = FALSE, have_dns6 = FALSE;
+ const gchar *route4_text = NULL, *route6_text = NULL;
/* set up the device on/off switch */
gtk_widget_show (GTK_WIDGET (self->device_off_switch));
@@ -384,7 +385,6 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *self)
GPtrArray *addresses;
const gchar *ipv4_text = NULL;
g_autofree gchar *ip4_dns = NULL;
- const gchar *route_text;
addresses = nm_ip_config_get_addresses (ipv4_config);
if (addresses->len > 0)
@@ -402,17 +402,12 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *self)
gtk_widget_set_visible (GTK_WIDGET (self->dns4_label), ip4_dns != NULL);
have_dns4 = ip4_dns != NULL;
- route_text = nm_ip_config_get_gateway (ipv4_config);
- gtk_label_set_label (self->route_label, route_text);
- gtk_widget_set_visible (GTK_WIDGET (self->route_heading_label), route_text != NULL);
- gtk_widget_set_visible (GTK_WIDGET (self->route_label), route_text != NULL);
+ route4_text = nm_ip_config_get_gateway (ipv4_config);
} else {
gtk_widget_hide (GTK_WIDGET (self->ipv4_heading_label));
gtk_widget_hide (GTK_WIDGET (self->ipv4_label));
gtk_widget_hide (GTK_WIDGET (self->dns4_heading_label));
gtk_widget_hide (GTK_WIDGET (self->dns4_label));
- gtk_widget_hide (GTK_WIDGET (self->route_heading_label));
- gtk_widget_hide (GTK_WIDGET (self->route_label));
}
ipv6_config = nm_device_get_ip6_config (self->device);
@@ -434,6 +429,8 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *self)
gtk_widget_set_visible (GTK_WIDGET (self->dns6_heading_label), ip6_dns != NULL);
gtk_widget_set_visible (GTK_WIDGET (self->dns6_label), ip6_dns != NULL);
have_dns6 = ip6_dns != NULL;
+
+ route6_text = nm_ip_config_get_gateway (ipv6_config);
} else {
gtk_widget_hide (GTK_WIDGET (self->ipv6_heading_label));
gtk_widget_hide (GTK_WIDGET (self->ipv6_label));
@@ -457,6 +454,25 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *self)
gtk_label_set_label (self->dns4_heading_label, _("DNS"));
gtk_label_set_label (self->dns6_heading_label, _("DNS"));
}
+
+ if (route4_text != NULL || route6_text != NULL) {
+ g_autofree const gchar *routes_text = NULL;
+
+ if (route4_text == NULL) {
+ routes_text = g_strdup (route6_text);
+ } else if (route6_text == NULL) {
+ routes_text = g_strdup (route4_text);
+ } else {
+ routes_text = g_strjoin ("\n", route4_text, route6_text, NULL);
+ }
+ gtk_label_set_label (self->route_label, routes_text);
+ gtk_widget_set_visible (GTK_WIDGET (self->route_heading_label), routes_text != NULL);
+ gtk_widget_set_valign (GTK_WIDGET (self->route_heading_label), GTK_ALIGN_START);
+ gtk_widget_set_visible (GTK_WIDGET (self->route_label), routes_text != NULL);
+ } else {
+ gtk_widget_hide (GTK_WIDGET (self->route_heading_label));
+ gtk_widget_hide (GTK_WIDGET (self->route_label));
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]