fix metadata, thumbnails and gallery view for locally mounted drives
This commit is contained in:
parent
f3b4e0bc6a
commit
26e223c4f0
3 changed files with 33 additions and 2 deletions
|
|
@ -1543,7 +1543,11 @@ impl App {
|
||||||
b = b.text(item.name()).data(MounterData(key, item.clone()));
|
b = b.text(item.name()).data(MounterData(key, item.clone()));
|
||||||
let uri = item.uri();
|
let uri = item.uri();
|
||||||
if let Some(path) = item.path() {
|
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() {
|
} else if !uri.is_empty() {
|
||||||
b = b.data(Location::Network(uri, item.name(), None));
|
b = b.data(Location::Network(uri, item.name(), None));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,15 +33,28 @@ fn items(monitor: &gio::VolumeMonitor, sizes: IconSizes) -> MounterItems {
|
||||||
let mut items: MounterItems = (monitor.mounts().into_iter())
|
let mut items: MounterItems = (monitor.mounts().into_iter())
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, mount)| {
|
.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 {
|
MounterItem::Gvfs(Item {
|
||||||
uri: mount.root().uri().into(),
|
uri: mount.root().uri().into(),
|
||||||
kind: ItemKind::Mount,
|
kind: ItemKind::Mount,
|
||||||
index: i,
|
index: i,
|
||||||
name: mount.name().into(),
|
name: mount.name().into(),
|
||||||
is_mounted: true,
|
is_mounted: true,
|
||||||
|
is_remote,
|
||||||
icon_opt: gio_icon_to_path(&MountExt::icon(&mount), sizes.grid()),
|
icon_opt: gio_icon_to_path(&MountExt::icon(&mount), sizes.grid()),
|
||||||
icon_symbolic_opt: gio_icon_to_path(&MountExt::symbolic_icon(&mount), 16),
|
icon_symbolic_opt: gio_icon_to_path(&MountExt::symbolic_icon(&mount), 16),
|
||||||
path_opt: MountExt::root(&mount).path(),
|
path_opt: root.path(),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
@ -61,6 +74,7 @@ fn items(monitor: &gio::VolumeMonitor, sizes: IconSizes) -> MounterItems {
|
||||||
index: i,
|
index: i,
|
||||||
name: volume.name().into(),
|
name: volume.name().into(),
|
||||||
is_mounted: false,
|
is_mounted: false,
|
||||||
|
is_remote: false,
|
||||||
icon_opt: gio_icon_to_path(&VolumeExt::icon(&volume), sizes.grid()),
|
icon_opt: gio_icon_to_path(&VolumeExt::icon(&volume), sizes.grid()),
|
||||||
icon_symbolic_opt: gio_icon_to_path(&VolumeExt::symbolic_icon(&volume), 16),
|
icon_symbolic_opt: gio_icon_to_path(&VolumeExt::symbolic_icon(&volume), 16),
|
||||||
path_opt: None,
|
path_opt: None,
|
||||||
|
|
@ -266,6 +280,7 @@ pub struct Item {
|
||||||
index: usize,
|
index: usize,
|
||||||
name: String,
|
name: String,
|
||||||
is_mounted: bool,
|
is_mounted: bool,
|
||||||
|
is_remote: bool,
|
||||||
icon_opt: Option<PathBuf>,
|
icon_opt: Option<PathBuf>,
|
||||||
icon_symbolic_opt: Option<PathBuf>,
|
icon_symbolic_opt: Option<PathBuf>,
|
||||||
path_opt: Option<PathBuf>,
|
path_opt: Option<PathBuf>,
|
||||||
|
|
@ -280,6 +295,10 @@ impl Item {
|
||||||
self.is_mounted
|
self.is_mounted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const fn is_remote(&self) -> bool {
|
||||||
|
self.is_remote
|
||||||
|
}
|
||||||
|
|
||||||
pub fn uri(&self) -> String {
|
pub fn uri(&self) -> String {
|
||||||
self.uri.clone()
|
self.uri.clone()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,14 @@ impl MounterItem {
|
||||||
Self::None => unreachable!(),
|
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<MounterItem>;
|
pub type MounterItems = Vec<MounterItem>;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue