Small cleanup
This commit is contained in:
parent
25710a319f
commit
575b8b8ad5
@ -10,7 +10,7 @@ fn main() {
|
||||
.build();
|
||||
|
||||
app.connect_activate(|app| {
|
||||
let mut file_search_plugin = plugins::file_search::FileSearchPlugin::new();
|
||||
let mut file_search_plugin = plugins::file_search::new();
|
||||
|
||||
match file_search_plugin.add_search_path("/home/javi/working-files/DJ Music/") {
|
||||
Err(e) => eprintln!("{}", e),
|
||||
@ -19,7 +19,7 @@ fn main() {
|
||||
|
||||
// Create the core launcher
|
||||
let launcher = WaycastLauncher::new()
|
||||
.add_plugin(Box::new(plugins::drun::DrunPlugin {}))
|
||||
.add_plugin(Box::new(plugins::drun::new()))
|
||||
.add_plugin(Box::new(file_search_plugin))
|
||||
.init();
|
||||
|
||||
|
@ -86,6 +86,10 @@ pub fn get_desktop_entries() -> Vec<DesktopEntry> {
|
||||
entries
|
||||
}
|
||||
|
||||
pub fn new() -> DrunPlugin {
|
||||
DrunPlugin {}
|
||||
}
|
||||
|
||||
pub struct DrunPlugin {}
|
||||
|
||||
impl LauncherPlugin for DrunPlugin {
|
||||
|
@ -39,9 +39,7 @@ impl LauncherListItem for FileEntry {
|
||||
println!("Executing: {}", self.path.display());
|
||||
|
||||
// Use xdg-open directly since it works properly with music files
|
||||
match Command::new("xdg-open")
|
||||
.arg(&self.path)
|
||||
.spawn() {
|
||||
match Command::new("xdg-open").arg(&self.path).spawn() {
|
||||
Ok(_) => {
|
||||
println!("Successfully launched with xdg-open");
|
||||
Ok(())
|
||||
@ -58,9 +56,10 @@ impl LauncherListItem for FileEntry {
|
||||
}
|
||||
Err(e2) => {
|
||||
println!("GIO fallback also failed: {}", e2);
|
||||
Err(LaunchError::CouldNotLaunch(
|
||||
format!("Both xdg-open and GIO failed: {} / {}", e, e2)
|
||||
))
|
||||
Err(LaunchError::CouldNotLaunch(format!(
|
||||
"Both xdg-open and GIO failed: {} / {}",
|
||||
e, e2
|
||||
)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -112,15 +111,8 @@ pub fn default_search_list() -> Vec<PathBuf> {
|
||||
|
||||
Vec::new()
|
||||
}
|
||||
pub struct FileSearchPlugin {
|
||||
search_paths: Vec<PathBuf>,
|
||||
skip_dirs: Vec<String>,
|
||||
// Running list of files in memory
|
||||
files: Arc<Mutex<Vec<FileEntry>>>,
|
||||
}
|
||||
|
||||
impl FileSearchPlugin {
|
||||
pub fn new() -> Self {
|
||||
pub fn new() -> FileSearchPlugin {
|
||||
return FileSearchPlugin {
|
||||
search_paths: default_search_list(),
|
||||
skip_dirs: vec![
|
||||
@ -131,8 +123,15 @@ impl FileSearchPlugin {
|
||||
],
|
||||
files: Arc::new(Mutex::new(Vec::new())),
|
||||
};
|
||||
}
|
||||
}
|
||||
pub struct FileSearchPlugin {
|
||||
search_paths: Vec<PathBuf>,
|
||||
skip_dirs: Vec<String>,
|
||||
// Running list of files in memory
|
||||
files: Arc<Mutex<Vec<FileEntry>>>,
|
||||
}
|
||||
|
||||
impl FileSearchPlugin {
|
||||
pub fn add_search_path<P: AsRef<Path>>(&mut self, path: P) -> Result<(), String> {
|
||||
let p = path.as_ref();
|
||||
|
||||
@ -148,6 +147,11 @@ impl FileSearchPlugin {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn add_skip_dir(&mut self, directory_name: String) -> Result<(), String> {
|
||||
self.skip_dirs.push(directory_name);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn init_with_timeout(&self, timeout: Duration) {
|
||||
let files_clone = Arc::clone(&self.files);
|
||||
let skip_dirs_clone = self.skip_dirs.clone();
|
||||
|
Loading…
x
Reference in New Issue
Block a user