Stub out file search plugin

This commit is contained in:
Javier Feliz 2025-09-04 00:35:06 -04:00
parent 13fa1e932f
commit 53e45fa232
4 changed files with 56 additions and 0 deletions

View File

@ -11,6 +11,7 @@ fn main() {
app.connect_activate(|app| {
let launcher = WaycastLauncher::new()
.add_plugin(plugins::drun::DrunPlugin {})
.add_plugin(plugins::file_search::FileSearchPlugin {})
.initialize(app);
launcher.borrow().show();

View File

@ -0,0 +1,53 @@
use crate::{LaunchError, LauncherListItem, LauncherPlugin};
struct FileEntry {
title: String,
}
impl LauncherListItem for ExampleEntry {
fn title(&self) -> String {
return self.title.to_string();
}
fn description(&self) -> Option<String> {
return None;
}
fn execute(&self) -> Result<(), LaunchError> {
println!("Sample item clicked: {}", self.title);
Ok(())
}
fn icon(&self) -> String {
return String::from("vscode");
}
}
pub struct FileSearchPlugin {}
impl LauncherPlugin for FileSearchPlugin {
fn name(&self) -> String {
return String::from("File search");
}
fn priority(&self) -> i32 {
return 900;
}
fn description(&self) -> Option<String> {
None
}
fn prefix(&self) -> Option<String> {
Some(String::from("f"))
}
fn by_prefix_only(&self) -> bool {
false
}
fn default_list(&self) -> Vec<Box<dyn LauncherListItem>> {
Vec::new()
}
fn filter(&self, query: &str) -> Vec<Box<dyn LauncherListItem>> {
self.default_list()
}
}

View File

@ -1 +1,2 @@
pub mod drun;
pub mod file_search;

View File

@ -128,6 +128,7 @@ impl WaycastLauncher {
for p in init_plugins {
plugins.push(Arc::from(p));
}
plugins.sort_by(|a, b| b.priority().cmp(&a.priority()));
// Organize plugins for faster querying
let mut plugins_show_always: Vec<Arc<dyn LauncherPlugin>> = Vec::new();
for p in &plugins {