directly navigate to the mounted drive after mounting them with a click on the sidebar

This commit is contained in:
Frederic Laing 2025-11-17 09:06:02 +01:00
parent 26e223c4f0
commit 0fc6596681
No known key found for this signature in database
GPG key ID: C126157F0CDCD306
2 changed files with 34 additions and 1 deletions

View file

@ -3092,6 +3092,16 @@ impl Application for App {
Message::MountResult(mounter_key, item, res) => match res {
Ok(true) => {
log::info!("connected to {item:?}");
// Automatically navigate to the mounted location
if let Some(path) = item.path() {
let location = if item.is_remote() {
Location::Network(item.uri(), item.name(), Some(path))
} else {
Location::Path(path)
};
let message = Message::TabMessage(None, tab::Message::Location(location));
return self.update(message);
}
}
Ok(false) => {
log::info!("cancelled connection to {item:?}");

View file

@ -408,6 +408,7 @@ impl Gvfs {
let mount_op = mount_op(name.to_string(), event_tx.clone());
let event_tx = event_tx.clone();
let mounter_item = mounter_item.clone();
let volume_for_callback = volume.clone();
VolumeExt::mount(
&volume,
gio::MountMountFlags::NONE,
@ -415,7 +416,29 @@ impl Gvfs {
gio::Cancellable::NONE,
move |res| {
log::info!("mount {name}: result {res:?}");
event_tx.send(Event::MountResult(mounter_item, match res {
// Update the mounter_item with mount information after successful mount
let mut updated_item = mounter_item.clone();
if res.is_ok() {
if let MounterItem::Gvfs(ref mut item) = updated_item {
if let Some(mount) = volume_for_callback.get_mount() {
let root = MountExt::root(&mount);
item.path_opt = root.path();
item.is_mounted = true;
// Query if remote
item.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);
}
}
}
event_tx.send(Event::MountResult(updated_item, match res {
Ok(()) => {
_ = complete_tx.send(Ok(()));
Ok(true)