Skip to content

Commit

Permalink
Spawn explorer.exe instead of relying on GTK on Windows to open files…
Browse files Browse the repository at this point in the history
… and directories
  • Loading branch information
salihgerdan committed Aug 2, 2023
1 parent 01f71e6 commit 9186480
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@ pub fn initiate_ui() {
let action_show = gtk::gio::SimpleAction::new("show", Some(glib::VariantTy::STRING));
action_show.connect_activate(glib::clone!(@weak application => move |_, param| {
param.map(|x| {
gtk::show_uri(None::<&gtk::Window>, x.to_string().trim_matches('\''), 0);
//dbg!(gtk::gio::AppInfo::launch_default_for_uri(x.to_string().as_str(), None::<&gtk::gdk::AppLaunchContext>))
if cfg!(windows) {
use std::process::Command;
Command::new("explorer.exe")
.args(&[x.to_string().trim_matches('\'')])
.spawn()
.expect("failed to execute process");
} else {
gtk::show_uri(None::<&gtk::Window>, x.to_string().trim_matches('\''), 0);
}
//dbg!(gtk::gio::AppInfo::launch_default_for_uri(x.to_string().as_str(), None::<&gtk::gdk::AppLaunchContext>))
});
}));
let action_disabled = gtk::gio::SimpleAction::new("disabled", None);
Expand Down

0 comments on commit 9186480

Please sign in to comment.