Stub out file search plugin
This commit is contained in:
parent
13fa1e932f
commit
53e45fa232
@ -11,6 +11,7 @@ fn main() {
|
|||||||
app.connect_activate(|app| {
|
app.connect_activate(|app| {
|
||||||
let launcher = WaycastLauncher::new()
|
let launcher = WaycastLauncher::new()
|
||||||
.add_plugin(plugins::drun::DrunPlugin {})
|
.add_plugin(plugins::drun::DrunPlugin {})
|
||||||
|
.add_plugin(plugins::file_search::FileSearchPlugin {})
|
||||||
.initialize(app);
|
.initialize(app);
|
||||||
|
|
||||||
launcher.borrow().show();
|
launcher.borrow().show();
|
||||||
|
53
src/plugins/file_search.rs
Normal file
53
src/plugins/file_search.rs
Normal 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()
|
||||||
|
}
|
||||||
|
}
|
@ -1 +1,2 @@
|
|||||||
pub mod drun;
|
pub mod drun;
|
||||||
|
pub mod file_search;
|
||||||
|
@ -128,6 +128,7 @@ impl WaycastLauncher {
|
|||||||
for p in init_plugins {
|
for p in init_plugins {
|
||||||
plugins.push(Arc::from(p));
|
plugins.push(Arc::from(p));
|
||||||
}
|
}
|
||||||
|
plugins.sort_by(|a, b| b.priority().cmp(&a.priority()));
|
||||||
// Organize plugins for faster querying
|
// Organize plugins for faster querying
|
||||||
let mut plugins_show_always: Vec<Arc<dyn LauncherPlugin>> = Vec::new();
|
let mut plugins_show_always: Vec<Arc<dyn LauncherPlugin>> = Vec::new();
|
||||||
for p in &plugins {
|
for p in &plugins {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user