use FileLauncher

This commit is contained in:
yggverse 2024-10-18 10:16:23 +03:00
parent 5c28a405ee
commit da3618aa0a

View File

@ -8,8 +8,9 @@ use window::Window;
use adw::ApplicationWindow; use adw::ApplicationWindow;
use gtk::{ use gtk::{
gio::{AppInfo, AppLaunchContext, SimpleAction}, gio::{Cancellable, File, SimpleAction},
prelude::{ActionMapExt, GtkWindowExt}, prelude::{ActionMapExt, GtkWindowExt},
FileLauncher,
}; };
use sqlite::Transaction; use sqlite::Transaction;
use std::{path::PathBuf, sync::Arc}; use std::{path::PathBuf, sync::Arc};
@ -90,10 +91,15 @@ impl Browser {
action_tool_profile.connect_activate({ action_tool_profile.connect_activate({
move |_, _| { move |_, _| {
// @TODO [4_10] https://docs.gtk.org/gtk4/class.FileLauncher.html FileLauncher::new(Some(&File::for_path(&profile_path))).launch(
let _ = AppInfo::launch_default_for_uri( None::<&gtk::Window>,
&format!("file://{}", profile_path.to_string_lossy()), None::<&Cancellable>,
Some(&AppLaunchContext::new()), |result| {
if let Err(error) = result {
// @TODO
println!("Could not delegate launch action: {error}")
}
},
); );
} }
}); });