diff --git a/src/app.rs b/src/app.rs index d6f673b..8074c34 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1543,7 +1543,11 @@ impl App { b = b.text(item.name()).data(MounterData(key, item.clone())); let uri = item.uri(); if let Some(path) = item.path() { - b = b.data(Location::Network(uri, item.name(), Some(path))); + if item.is_remote() { + b = b.data(Location::Network(uri, item.name(), Some(path))); + } else { + b = b.data(Location::Path(path)); + } } else if !uri.is_empty() { b = b.data(Location::Network(uri, item.name(), None)); } diff --git a/src/mounter/gvfs.rs b/src/mounter/gvfs.rs index 4d2a44d..25f299f 100644 --- a/src/mounter/gvfs.rs +++ b/src/mounter/gvfs.rs @@ -33,15 +33,28 @@ fn items(monitor: &gio::VolumeMonitor, sizes: IconSizes) -> MounterItems { let mut items: MounterItems = (monitor.mounts().into_iter()) .enumerate() .map(|(i, mount)| { + let root = MountExt::root(&mount); + let is_remote = root + .query_filesystem_info( + gio::FILE_ATTRIBUTE_FILESYSTEM_REMOTE, + gio::Cancellable::NONE, + ) + .ok() + .and_then(|info| { + Some(info.boolean(gio::FILE_ATTRIBUTE_FILESYSTEM_REMOTE)) + }) + .unwrap_or(true); // Default to remote if query fails + MounterItem::Gvfs(Item { uri: mount.root().uri().into(), kind: ItemKind::Mount, index: i, name: mount.name().into(), is_mounted: true, + is_remote, icon_opt: gio_icon_to_path(&MountExt::icon(&mount), sizes.grid()), icon_symbolic_opt: gio_icon_to_path(&MountExt::symbolic_icon(&mount), 16), - path_opt: MountExt::root(&mount).path(), + path_opt: root.path(), }) }) .collect(); @@ -61,6 +74,7 @@ fn items(monitor: &gio::VolumeMonitor, sizes: IconSizes) -> MounterItems { index: i, name: volume.name().into(), is_mounted: false, + is_remote: false, icon_opt: gio_icon_to_path(&VolumeExt::icon(&volume), sizes.grid()), icon_symbolic_opt: gio_icon_to_path(&VolumeExt::symbolic_icon(&volume), 16), path_opt: None, @@ -266,6 +280,7 @@ pub struct Item { index: usize, name: String, is_mounted: bool, + is_remote: bool, icon_opt: Option, icon_symbolic_opt: Option, path_opt: Option, @@ -280,6 +295,10 @@ impl Item { self.is_mounted } + pub const fn is_remote(&self) -> bool { + self.is_remote + } + pub fn uri(&self) -> String { self.uri.clone() } diff --git a/src/mounter/mod.rs b/src/mounter/mod.rs index caaba72..098b2b3 100644 --- a/src/mounter/mod.rs +++ b/src/mounter/mod.rs @@ -90,6 +90,14 @@ impl MounterItem { Self::None => unreachable!(), } } + + pub fn is_remote(&self) -> bool { + match self { + #[cfg(feature = "gvfs")] + Self::Gvfs(item) => item.is_remote(), + Self::None => unreachable!(), + } + } } pub type MounterItems = Vec;