[gnome-shell-extensions/gnome-40] drive-menu: Don't assume mounts without volume are local
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions/gnome-40] drive-menu: Don't assume mounts without volume are local
- Date: Mon, 12 Jul 2021 18:59:40 +0000 (UTC)
commit 561b8aeb03493b5c0813f52b285898ebae648462
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Feb 5 22:16:09 2018 +0100
drive-menu: Don't assume mounts without volume are local
The intention of the code is to only expose actually plugged in
devices rather than network mounts, but the existing heuristics are
based on GVolume and simply assume a local mount where there's no
associated volume. Fill that gap by querying the ::remote filesystem
attribute in that case.
https://gitlab.gnome.org/GNOME/gnome-shell-extensions/issues/53
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/27>
(cherry picked from commit 7d6670ce3c1716bdaf2cba7e7fa942cceff4cc31)
extensions/drive-menu/extension.js | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/extensions/drive-menu/extension.js b/extensions/drive-menu/extension.js
index 5bd9152..59603c8 100644
--- a/extensions/drive-menu/extension.js
+++ b/extensions/drive-menu/extension.js
@@ -62,13 +62,21 @@ class MountMenuItem extends PopupMenu.PopupBaseMenuItem {
let volume = this.mount.get_volume();
- if (!volume) {
- // probably a GDaemonMount, could be network or
- // local, but we can't tell; assume it's local for now
- return true;
+ if (volume)
+ return volume.get_identifier('class') !== 'network';
+
+ const root = this.mount.get_root();
+
+ try {
+ const attr = Gio.FILE_ATTRIBUTE_FILESYSTEM_REMOTE;
+ const info = root.query_filesystem_info(attr, null);
+ return !info.get_attribute_boolean(attr);
+ } catch (e) {
+ log(`Failed to query filesystem: ${e.message}`);
}
- return volume.get_identifier('class') !== 'network';
+ // Hack, fall back to looking at GType
+ return Gio._LocalFilePrototype.isPrototypeOf(root);
}
_syncVisibility() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]