✨ chore(runner): try a new approach to show results, make plugins return properties instead of the actual widget
returning the results as objects seems to be a better approach, also, the new way of showing results doesn't work for some reason(i didn't discover it yet lol)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { Gtk } from "ags/gtk4";
|
||||
import { Clipboard } from "../../scripts/clipboard";
|
||||
import { Runner } from "../Runner";
|
||||
import { jsx } from "ags/gtk4/jsx-runtime";
|
||||
|
||||
|
||||
export const PluginClipboard = {
|
||||
prefix: '>',
|
||||
prioritize: true,
|
||||
handle: (search) => {
|
||||
if(Clipboard.getDefault().history.length < 1)
|
||||
return {
|
||||
icon: "edit-paste-symbolic",
|
||||
title: "Clipboard is empty",
|
||||
description: "Copy something and it will be shown right here!"
|
||||
};
|
||||
|
||||
return Clipboard.getDefault().history.filter(item =>
|
||||
// not the best way to search, but it works
|
||||
Runner.regExMatch(search, item.id) || Runner.regExMatch(search, item.preview)).map((item) => ({
|
||||
icon: jsx(Gtk.Label, {
|
||||
label: `${item.id}`,
|
||||
css: "font-size: 16px; margin-right: 8px; font-weight: 600;"
|
||||
}),
|
||||
title: item.preview,
|
||||
actionClick: () => Clipboard.getDefault().selectItem(item).catch((err: Error) => {
|
||||
console.error(`Runner(Plugin/Clipboard): An error occurred while selecting clipboard item. Stderr:\n${
|
||||
err.message ? `${err.message}\n` : ""}Stack: ${err.stack}`
|
||||
);
|
||||
})
|
||||
}));
|
||||
}
|
||||
} as Runner.Plugin;
|
||||
Reference in New Issue
Block a user