From 0fc65966818131ea7fc3b4fe1a027c86aaff0ace Mon Sep 17 00:00:00 2001 From: Frederic Laing Date: Mon, 17 Nov 2025 09:06:02 +0100 Subject: [PATCH] directly navigate to the mounted drive after mounting them with a click on the sidebar --- src/app.rs | 10 ++++++++++ src/mounter/gvfs.rs | 25 ++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index 8074c34..32ba25a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -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:?}"); diff --git a/src/mounter/gvfs.rs b/src/mounter/gvfs.rs index 25f299f..9c720c0 100644 --- a/src/mounter/gvfs.rs +++ b/src/mounter/gvfs.rs @@ -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)