Network: Show all IPv6 addresses for an interface
Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1300
This commit is contained in:
parent
25a5a8e6f2
commit
5a18b369c6
5 changed files with 38 additions and 21 deletions
|
@ -28,6 +28,8 @@
|
||||||
#include "ce-page.h"
|
#include "ce-page.h"
|
||||||
#include "ce-page-details.h"
|
#include "ce-page-details.h"
|
||||||
|
|
||||||
|
#include "../panel-common.h"
|
||||||
|
|
||||||
struct _CEPageDetails
|
struct _CEPageDetails
|
||||||
{
|
{
|
||||||
GtkGrid parent;
|
GtkGrid parent;
|
||||||
|
@ -380,15 +382,13 @@ connect_details_page (CEPageDetails *self)
|
||||||
if (device_is_active && self->device != NULL)
|
if (device_is_active && self->device != NULL)
|
||||||
ipv6_config = nm_device_get_ip6_config (self->device);
|
ipv6_config = nm_device_get_ip6_config (self->device);
|
||||||
if (ipv6_config != NULL) {
|
if (ipv6_config != NULL) {
|
||||||
GPtrArray *addresses;
|
g_autofree gchar *ipv6_text = NULL;
|
||||||
const gchar *ipv6_text = NULL;
|
|
||||||
g_autofree gchar *ip6_dns = NULL;
|
g_autofree gchar *ip6_dns = NULL;
|
||||||
|
|
||||||
addresses = nm_ip_config_get_addresses (ipv6_config);
|
ipv6_text = net_device_get_ip6_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_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_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);
|
gtk_widget_set_visible (GTK_WIDGET (self->ipv6_label), ipv6_text != NULL);
|
||||||
have_ipv6_address = ipv6_text != NULL;
|
have_ipv6_address = ipv6_text != NULL;
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ add_details_row (GtkWidget *details, gint top, const gchar *heading, const gchar
|
||||||
heading_label = gtk_label_new (heading);
|
heading_label = gtk_label_new (heading);
|
||||||
gtk_style_context_add_class (gtk_widget_get_style_context (heading_label), "dim-label");
|
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_halign (heading_label, GTK_ALIGN_END);
|
||||||
|
gtk_widget_set_valign (heading_label, GTK_ALIGN_START);
|
||||||
gtk_widget_set_hexpand (heading_label, TRUE);
|
gtk_widget_set_hexpand (heading_label, TRUE);
|
||||||
|
|
||||||
gtk_grid_attach (GTK_GRID (details), heading_label, 0, top, 1, 1);
|
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_address = NULL;
|
||||||
const gchar *ip4_route = NULL;
|
const gchar *ip4_route = NULL;
|
||||||
g_autofree gchar *ip4_dns = NULL;
|
g_autofree gchar *ip4_dns = NULL;
|
||||||
const gchar *ip6_address = NULL;
|
g_autofree gchar *ip6_addresses = NULL;
|
||||||
g_autofree gchar *ip6_dns = NULL;
|
g_autofree gchar *ip6_dns = NULL;
|
||||||
gint i = 0;
|
gint i = 0;
|
||||||
|
|
||||||
|
@ -134,24 +135,21 @@ add_details (GtkWidget *details, NMDevice *device, NMConnection *connection)
|
||||||
}
|
}
|
||||||
ip6_config = nm_device_get_ip6_config (device);
|
ip6_config = nm_device_get_ip6_config (device);
|
||||||
if (ip6_config) {
|
if (ip6_config) {
|
||||||
GPtrArray *addresses;
|
ip6_addresses = net_device_get_ip6_addresses (ip6_config);
|
||||||
|
|
||||||
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_dns = g_strjoinv (" ", (char **) nm_ip_config_get_nameservers (ip6_config));
|
ip6_dns = g_strjoinv (" ", (char **) nm_ip_config_get_nameservers (ip6_config));
|
||||||
if (!*ip6_dns)
|
if (!*ip6_dns)
|
||||||
ip6_dns = NULL;
|
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++, _("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) {
|
} else if (ip4_address) {
|
||||||
add_details_row (details, i++, _("IP Address"), ip4_address);
|
add_details_row (details, i++, _("IP Address"), ip4_address);
|
||||||
} else if (ip6_address) {
|
} else if (ip6_addresses) {
|
||||||
add_details_row (details, i++, _("IP Address"), ip6_address);
|
add_details_row (details, i++, _("IP Address"), ip6_addresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_details_row (details, i++, _("Hardware Address"), nm_device_get_hw_address (device));
|
add_details_row (details, i++, _("Hardware Address"), nm_device_get_hw_address (device));
|
||||||
|
|
|
@ -417,15 +417,13 @@ nm_device_mobile_refresh_ui (NetDeviceMobile *self)
|
||||||
|
|
||||||
ipv6_config = nm_device_get_ip6_config (self->device);
|
ipv6_config = nm_device_get_ip6_config (self->device);
|
||||||
if (ipv6_config != NULL) {
|
if (ipv6_config != NULL) {
|
||||||
GPtrArray *addresses;
|
g_autofree gchar *ipv6_text = NULL;
|
||||||
const gchar *ipv6_text = NULL;
|
|
||||||
g_autofree gchar *ip6_dns = NULL;
|
g_autofree gchar *ip6_dns = NULL;
|
||||||
|
|
||||||
addresses = nm_ip_config_get_addresses (ipv6_config);
|
ipv6_text = net_device_get_ip6_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_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_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);
|
gtk_widget_set_visible (GTK_WIDGET (self->ipv6_label), ipv6_text != NULL);
|
||||||
have_ipv6_address = ipv6_text != NULL;
|
have_ipv6_address = ipv6_text != NULL;
|
||||||
|
|
||||||
|
|
|
@ -428,3 +428,22 @@ net_device_get_valid_connections (NMClient *client, NMDevice *device)
|
||||||
|
|
||||||
return g_slist_reverse (valid);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -34,4 +34,6 @@ NMConnection *net_device_get_find_connection (NMClient *client,
|
||||||
GSList *net_device_get_valid_connections (NMClient *client,
|
GSList *net_device_get_valid_connections (NMClient *client,
|
||||||
NMDevice *device);
|
NMDevice *device);
|
||||||
|
|
||||||
|
gchar *net_device_get_ip6_addresses (NMIPConfig *ipv6_config);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue