diff --git a/panels/network/connection-editor/ce-page-details.c b/panels/network/connection-editor/ce-page-details.c index 27433efe2..82085580c 100644 --- a/panels/network/connection-editor/ce-page-details.c +++ b/panels/network/connection-editor/ce-page-details.c @@ -28,6 +28,8 @@ #include "ce-page.h" #include "ce-page-details.h" +#include "../panel-common.h" + struct _CEPageDetails { GtkGrid parent; @@ -380,15 +382,13 @@ 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) { - GPtrArray *addresses; - const gchar *ipv6_text = NULL; + g_autofree gchar *ipv6_text = NULL; g_autofree gchar *ip6_dns = NULL; - 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)); + ipv6_text = net_device_get_ip6_addresses (ipv6_config); 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_valign (GTK_WIDGET (self->ipv6_heading_label), GTK_ALIGN_START); gtk_widget_set_visible (GTK_WIDGET (self->ipv6_label), ipv6_text != NULL); have_ipv6_address = ipv6_text != NULL; diff --git a/panels/network/net-device-ethernet.c b/panels/network/net-device-ethernet.c index f7cd6ae6b..bdf810412 100644 --- a/panels/network/net-device-ethernet.c +++ b/panels/network/net-device-ethernet.c @@ -63,6 +63,7 @@ add_details_row (GtkWidget *details, gint top, const gchar *heading, const gchar heading_label = gtk_label_new (heading); gtk_style_context_add_class (gtk_widget_get_style_context (heading_label), "dim-label"); gtk_widget_set_halign (heading_label, GTK_ALIGN_END); + gtk_widget_set_valign (heading_label, GTK_ALIGN_START); gtk_widget_set_hexpand (heading_label, TRUE); gtk_grid_attach (GTK_GRID (details), heading_label, 0, top, 1, 1); @@ -115,7 +116,7 @@ add_details (GtkWidget *details, NMDevice *device, NMConnection *connection) const gchar *ip4_address = NULL; const gchar *ip4_route = NULL; g_autofree gchar *ip4_dns = NULL; - const gchar *ip6_address = NULL; + g_autofree gchar *ip6_addresses = NULL; g_autofree gchar *ip6_dns = NULL; gint i = 0; @@ -134,24 +135,21 @@ add_details (GtkWidget *details, NMDevice *device, NMConnection *connection) } ip6_config = nm_device_get_ip6_config (device); if (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)); - + ip6_addresses = net_device_get_ip6_addresses (ip6_config); ip6_dns = g_strjoinv (" ", (char **) nm_ip_config_get_nameservers (ip6_config)); if (!*ip6_dns) ip6_dns = NULL; } - if (ip4_address && ip6_address) { + if (ip4_address && ip6_addresses) { add_details_row (details, i++, _("IPv4 Address"), ip4_address); - add_details_row (details, i++, _("IPv6 Address"), ip6_address); + gtk_widget_set_valign (details, GTK_ALIGN_START); + add_details_row (details, i++, _("IPv6 Address"), ip6_addresses); + gtk_widget_set_valign (details, GTK_ALIGN_START); } else if (ip4_address) { add_details_row (details, i++, _("IP Address"), ip4_address); - } else if (ip6_address) { - add_details_row (details, i++, _("IP Address"), ip6_address); + } else if (ip6_addresses) { + add_details_row (details, i++, _("IP Address"), ip6_addresses); } add_details_row (details, i++, _("Hardware Address"), nm_device_get_hw_address (device)); diff --git a/panels/network/net-device-mobile.c b/panels/network/net-device-mobile.c index 34eb86241..9039f2b7b 100644 --- a/panels/network/net-device-mobile.c +++ b/panels/network/net-device-mobile.c @@ -417,15 +417,13 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *self) ipv6_config = nm_device_get_ip6_config (self->device); if (ipv6_config != NULL) { - GPtrArray *addresses; - const gchar *ipv6_text = NULL; + g_autofree gchar *ipv6_text = NULL; g_autofree gchar *ip6_dns = NULL; - 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)); + ipv6_text = net_device_get_ip6_addresses (ipv6_config); 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_valign (GTK_WIDGET (self->ipv6_heading_label), GTK_ALIGN_START); gtk_widget_set_visible (GTK_WIDGET (self->ipv6_label), ipv6_text != NULL); have_ipv6_address = ipv6_text != NULL; diff --git a/panels/network/panel-common.c b/panels/network/panel-common.c index dca1b6920..7654a561d 100644 --- a/panels/network/panel-common.c +++ b/panels/network/panel-common.c @@ -428,3 +428,22 @@ net_device_get_valid_connections (NMClient *client, NMDevice *device) return g_slist_reverse (valid); } + +gchar * +net_device_get_ip6_addresses (NMIPConfig *ipv6_config) +{ + g_autoptr(GPtrArray) ipv6 = NULL; + GPtrArray *addresses; + + addresses = nm_ip_config_get_addresses (ipv6_config); + if (addresses->len == 0) { + return NULL; + } + ipv6 = g_ptr_array_sized_new (addresses->len + 1); + + for (int i = 0; i < addresses->len; i++) { + g_ptr_array_add (ipv6, (char *) nm_ip_address_get_address (g_ptr_array_index (addresses, i))); + } + g_ptr_array_add (ipv6, NULL); + return g_strjoinv ("\n", (char **) ipv6->pdata); +} diff --git a/panels/network/panel-common.h b/panels/network/panel-common.h index 07326ad93..32aed09bd 100644 --- a/panels/network/panel-common.h +++ b/panels/network/panel-common.h @@ -34,4 +34,6 @@ NMConnection *net_device_get_find_connection (NMClient *client, GSList *net_device_get_valid_connections (NMClient *client, NMDevice *device); +gchar *net_device_get_ip6_addresses (NMIPConfig *ipv6_config); + G_END_DECLS