Improve dialog handling
This commit is contained in:
parent
dea974469a
commit
db485798da
7 changed files with 273 additions and 93 deletions
24
src/lib.rs
24
src/lib.rs
|
|
@ -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>> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue