Improve dialog handling

This commit is contained in:
Jeremy Soller 2024-02-13 12:29:50 -07:00
parent dea974469a
commit db485798da
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
7 changed files with 273 additions and 93 deletions

View file

@ -6,11 +6,7 @@ use cosmic::{
cosmic_config::{self, CosmicConfigEntry},
iced::Limits,
};
use std::{
path::PathBuf,
process,
sync::{Arc, Mutex},
};
use std::{path::PathBuf, process};
use app::{App, Flags};
mod app;
@ -35,24 +31,6 @@ pub fn home_dir() -> PathBuf {
}
}
/// Runs application with these settings
pub fn dialog() -> Result<Option<Vec<PathBuf>>, Box<dyn std::error::Error>> {
localize::localize();
let mut settings = Settings::default();
let mut result_lock = Arc::new(Mutex::new(None));
let flags = dialog::Flags {
result_lock: result_lock.clone(),
};
cosmic::app::run::<dialog::App>(settings, flags)?;
let mut result_guard = result_lock.lock().unwrap();
let result = result_guard.take();
Ok(result)
}
/// Runs application with these settings
#[rustfmt::skip]
pub fn main() -> Result<(), Box<dyn std::error::Error>> {