[network-manager-applet] applet: hide unmanaged interfaces
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet] applet: hide unmanaged interfaces
- Date: Tue, 2 Feb 2021 19:27:00 +0000 (UTC)
commit 219fd8da0c74656af33da4881bc3680ba726a9a2
Author: Luis Pabon <luis pabon auronconsulting co uk>
Date: Wed Dec 16 12:16:52 2020 +0000
applet: hide unmanaged interfaces
This patch removes any unmanaged ethernet interfaces from
the drop down list. Specifically, virtualbox and docker virtual
networks will no longer be shown.
Author: Campbell Vertesi <campbell vertesi com>
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1458322
[thaller redhat com: squashed commits]
https://gitlab.gnome.org/GNOME/network-manager-applet/-/merge_requests/93
src/applet-device-broadband.c | 6 ++++--
src/applet-device-bt.c | 4 +++-
src/applet-device-ethernet.c | 8 +++++++-
src/applet-device-wifi.c | 3 ++-
src/applet.c | 6 +++---
src/applet.h | 2 +-
6 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/src/applet-device-broadband.c b/src/applet-device-broadband.c
index 30ccd494..9c47318a 100644
--- a/src/applet-device-broadband.c
+++ b/src/applet-device-broadband.c
@@ -698,7 +698,7 @@ add_connection_item (NMDevice *device,
gtk_widget_show (item);
}
-static void
+static gboolean
add_menu_item (NMDevice *device,
gboolean multiple_devices,
const GPtrArray *connections,
@@ -715,7 +715,7 @@ add_menu_item (NMDevice *device,
if (!info) {
g_warning ("ModemManager is not available for modem at %s",
nm_device_get_udi (device));
- return;
+ return FALSE;
}
if (multiple_devices) {
@@ -794,6 +794,8 @@ add_menu_item (NMDevice *device,
add_connection_item (device, NULL, item, menu, applet);
}
}
+
+ return TRUE;
}
/********************************************************************/
diff --git a/src/applet-device-bt.c b/src/applet-device-bt.c
index 75231e70..a78f1068 100644
--- a/src/applet-device-bt.c
+++ b/src/applet-device-bt.c
@@ -24,7 +24,7 @@ bt_new_auto_connection (NMDevice *device,
return FALSE;
}
-static void
+static gboolean
bt_add_menu_item (NMDevice *device,
gboolean multiple__devices,
const GPtrArray *connections,
@@ -62,6 +62,8 @@ bt_add_menu_item (NMDevice *device,
applet_add_connection_items (device, connections, TRUE, active, NMA_ADD_INACTIVE,
menu, applet);
}
}
+
+ return TRUE;
}
static void
diff --git a/src/applet-device-ethernet.c b/src/applet-device-ethernet.c
index 9b709422..52f70a1d 100644
--- a/src/applet-device-ethernet.c
+++ b/src/applet-device-ethernet.c
@@ -47,7 +47,7 @@ ethernet_new_auto_connection (NMDevice *device,
return TRUE;
}
-static void
+static gboolean
ethernet_add_menu_item (NMDevice *device,
gboolean multiple_devices,
const GPtrArray *connections,
@@ -59,6 +59,10 @@ ethernet_add_menu_item (NMDevice *device,
GtkWidget *item;
gboolean carrier = TRUE;
+ if (nm_device_get_state (device) == NM_DEVICE_STATE_UNMANAGED) {
+ return FALSE;
+ }
+
if (multiple_devices) {
const char *desc;
@@ -107,6 +111,8 @@ ethernet_add_menu_item (NMDevice *device,
else
applet_add_default_connection_item (device, DEFAULT_ETHERNET_NAME, carrier, menu,
applet);
}
+
+ return TRUE;
}
static void
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 0f1043c0..b39d2f0f 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -791,7 +791,7 @@ sort_toplevel (gconstpointer tmpa, gconstpointer tmpb)
return sort_by_name (a, b);
}
-static void
+static gboolean
wifi_add_menu_item (NMDevice *device,
gboolean multiple_devices,
const GPtrArray *connections,
@@ -934,6 +934,7 @@ wifi_add_menu_item (NMDevice *device,
out:
g_slist_free (menu_items);
+ return TRUE;
}
static void
diff --git a/src/applet.c b/src/applet.c
index c94adb5f..8ebac755 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -1385,6 +1385,7 @@ add_device_items (NMDeviceType type, const GPtrArray *all_devices,
NMADeviceClass *dclass;
NMConnection *active;
GPtrArray *connections;
+ gboolean added;
dclass = get_device_class (device, applet);
if (!dclass)
@@ -1393,11 +1394,11 @@ add_device_items (NMDeviceType type, const GPtrArray *all_devices,
connections = nm_device_filter_connections (device, all_connections);
active = applet_find_active_connection_for_device (device, applet, NULL);
- dclass->add_menu_item (device, n_devices > 1, connections, active, menu, applet);
+ added = dclass->add_menu_item (device, n_devices > 1, connections, active, menu, applet);
g_ptr_array_unref (connections);
- if (INDICATOR_ENABLED (applet))
+ if (INDICATOR_ENABLED (applet) && added)
gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());
}
@@ -3450,4 +3451,3 @@ static void nma_class_init (NMAppletClass *klass)
oclass->finalize = finalize;
}
-
diff --git a/src/applet.h b/src/applet.h
index 81327f69..2bc2246f 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -186,7 +186,7 @@ struct NMADeviceClass {
AppletNewAutoConnectionCallback callback,
gpointer callback_data);
- void (*add_menu_item) (NMDevice *device,
+ gboolean (*add_menu_item) (NMDevice *device,
gboolean multiple_devices,
const GPtrArray *connections,
NMConnection *active,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]