summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Pabon <luis.pabon@auronconsulting.co.uk>2020-12-16 12:16:52 +0000
committerThomas Haller <thaller@redhat.com>2021-02-02 20:25:16 +0100
commit219fd8da0c74656af33da4881bc3680ba726a9a2 (patch)
treed6eac64f44d3a473d887524bd917d2cb88e9d183
parent4b6d62703bb0d660a5aa73dcfcf4bbd3659696a2 (diff)
downloadnetwork-manager-applet-219fd8da0c74656af33da4881bc3680ba726a9a2.tar.gz
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
-rw-r--r--src/applet-device-broadband.c6
-rw-r--r--src/applet-device-bt.c4
-rw-r--r--src/applet-device-ethernet.c8
-rw-r--r--src/applet-device-wifi.c3
-rw-r--r--src/applet.c6
-rw-r--r--src/applet.h2
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,