Don't disambiguate wired networks titles

In RHEL-50729 the customer wants the ethernet device name to appear
consistent regardless of the name of the device.

What GNOME Settings upstream does is to use
nm_device_disambiguate_names() so that it can show a simple "Wired"
device when there's only one (usually embedded) device and still
change the device name when there are multiple devices connected
(corner case) to disambiguate.

These changes make the Ethernet devices always appear as
"Wired $IFACE", where $IFACE is the result of nm_device_get_iface ().

See https://networkmanager.dev/docs/libnm/latest/NMDevice.html#nm-device-disambiguate-names

Related: RHEL-5072
This commit is contained in:
Felipe Borges 2025-01-23 13:32:16 +01:00 committed by Felipe Borges
parent ae377685f9
commit 4ea37fc594
2 changed files with 82 additions and 0 deletions

View File

@ -27,6 +27,9 @@ Source0: https://download.gnome.org/sources/%{name}/46/%{name}-%{tarball_
# https://issues.redhat.com/browse/RHEL-59200 # https://issues.redhat.com/browse/RHEL-59200
Patch0: power-honor-sleep-inactive-ac-type-server-setting.patch Patch0: power-honor-sleep-inactive-ac-type-server-setting.patch
# https://issues.redhat.com/browse/RHEL-5072
Patch1: network-dont-disambiguate-ethernet-device-names.patch
BuildRequires: desktop-file-utils BuildRequires: desktop-file-utils
BuildRequires: docbook-style-xsl libxslt BuildRequires: docbook-style-xsl libxslt
BuildRequires: gcc BuildRequires: gcc

View File

@ -0,0 +1,79 @@
From 3d41c7295ae6915f7a777f761fe22f11ac5b6f08 Mon Sep 17 00:00:00 2001
From: Felipe Borges <felipeborges@gnome.org>
Date: Thu, 23 Jan 2025 13:05:25 +0100
Subject: [PATCH] Don't disambiguate wired networks titles
In RHEL-50729 the customer wants the ethernet device name to appear
consistent regardless of the name of the device.
What GNOME Settings upstream does is to use
nm_device_disambiguate_names() so that it can show a simple "Wired"
device when there's only one (usually embedded) device and still
change the device name when there are multiple devices connected
(corner case) to disambiguate.
These changes make the Ethernet devices always appear as "Wired $IFACE",
where $IFACE is the result of nm_device_get_iface ().
See https://networkmanager.dev/docs/libnm/latest/NMDevice.html#nm-device-disambiguate-names
Related: RHEL-50729
---
panels/network/cc-network-panel.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index 3b19ed516..be9932994 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -21,6 +21,7 @@
#include <config.h>
#include <stdlib.h>
+#include <glib/gi18n.h>
#include "shell/cc-object-storage.h"
@@ -233,6 +234,23 @@ cc_network_panel_get_help_uri (CcPanel *panel)
return "help:gnome-help/net";
}
+static gchar *
+get_ethernet_device_name (NMDevice *device)
+{
+ const gchar *type_name;
+
+ switch (nm_device_get_device_type (device)) {
+ case NM_DEVICE_TYPE_ETHERNET:
+ case NM_DEVICE_TYPE_INFINIBAND:
+ type_name = _("Wired");
+ break;
+ default:
+ return NULL;
+ }
+
+ return g_strdup_printf ("%s (%s)", type_name, nm_device_get_iface (device));
+}
+
static void
panel_refresh_device_titles (CcNetworkPanel *self)
{
@@ -272,8 +290,13 @@ panel_refresh_device_titles (CcNetworkPanel *self)
for (i = 0; i < num_devices; i++) {
if (NM_IS_DEVICE_BT (nm_devices[i]))
adw_preferences_row_set_title (ADW_PREFERENCES_ROW (devices[i]), nm_device_bt_get_name (NM_DEVICE_BT (nm_devices[i])));
- else if (NET_IS_DEVICE_ETHERNET (devices[i]))
- adw_preferences_group_set_title (ADW_PREFERENCES_GROUP (devices[i]), titles[i]);
+ else if (NET_IS_DEVICE_ETHERNET (devices[i])) {
+ g_autofree gchar *device_name = NULL;
+
+ device_name = get_ethernet_device_name (net_device_ethernet_get_device (NET_DEVICE_ETHERNET (devices[i])));
+ adw_preferences_group_set_title (ADW_PREFERENCES_GROUP (devices[i]),
+ device_name ? device_name : titles[i]);
+ }
else if (NET_IS_DEVICE_MOBILE (devices[i]))
net_device_mobile_set_title (NET_DEVICE_MOBILE (devices[i]), titles[i]);
}
--
2.45.2