diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-05 14:26:26 +1100 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-05 14:26:26 +1100 |
| commit | f23192156866093a1d4a7f0a5e75dc0b27d0fc5d (patch) | |
| tree | 5f5873e21db1cc9a9fc2e1e651853a1e229c89f3 /src/modules/launcher/actions.tsx | |
| parent | wallpapers: filter by size (diff) | |
| download | caelestia-shell-f23192156866093a1d4a7f0a5e75dc0b27d0fc5d.tar.gz caelestia-shell-f23192156866093a1d4a7f0a5e75dc0b27d0fc5d.tar.bz2 caelestia-shell-f23192156866093a1d4a7f0a5e75dc0b27d0fc5d.zip | |
launcher: optimise wallpaper selector
Optimise thumbnail size
Also limit number shown
Add show all when no search option
Diffstat (limited to 'src/modules/launcher/actions.tsx')
| -rw-r--r-- | src/modules/launcher/actions.tsx | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/src/modules/launcher/actions.tsx b/src/modules/launcher/actions.tsx index 64f475a..04c5458 100644 --- a/src/modules/launcher/actions.tsx +++ b/src/modules/launcher/actions.tsx @@ -287,7 +287,7 @@ const Scheme = ({ scheme, name, colours }: { scheme?: string; name: string; colo ); }; -const Wallpaper = ({ path, thumbnail }: IWallpaper) => ( +const Wallpaper = ({ path, thumbnails }: IWallpaper) => ( <Gtk.FlowBoxChild visible canFocus={false}> <button className="result wallpaper-container" @@ -302,13 +302,26 @@ const Wallpaper = ({ path, thumbnail }: IWallpaper) => ( vertical={config.wallpaper.style.get() !== "compact"} className={`wallpaper ${config.wallpaper.style.get()}`} > - <box className="thumbnail" css={"background-image: url('" + (thumbnail ?? path) + "');"} /> + <box + className="thumbnail" + css={bind(config.wallpaper.style).as( + s => "background-image: url('" + thumbnails[s as keyof typeof thumbnails] + "');" + )} + /> <label truncate label={basename(path)} /> </box> </button> </Gtk.FlowBoxChild> ); +const CategoryThumbnail = ({ style, wallpapers }: { style: string; wallpapers: IWallpaper[] }) => ( + <box className="thumbnail"> + {wallpapers.slice(0, 3).map(w => ( + <box hexpand css={"background-image: url('" + w.thumbnails[style as keyof typeof w.thumbnails] + "');"} /> + ))} + </box> +); + const Category = ({ path, wallpapers }: ICategory) => ( <Gtk.FlowBoxChild visible canFocus={false}> <button @@ -328,14 +341,10 @@ const Category = ({ path, wallpapers }: ICategory) => ( s === "compact" ? ( <box className="thumbnail" - css={"background-image: url('" + (wallpapers[0].thumbnail ?? wallpapers[0].path) + "');"} + css={"background-image: url('" + wallpapers[0].thumbnails.compact + "');"} /> ) : ( - <box className="thumbnail"> - {wallpapers.slice(0, 3).map(w => ( - <box hexpand css={"background-image: url('" + (w.thumbnail ?? w.path) + "');"} /> - ))} - </box> + <CategoryThumbnail style={s} wallpapers={wallpapers} /> ) )} <label truncate label={basename(path)} /> @@ -397,12 +406,19 @@ export default class Actions extends Widget.Box implements LauncherContent { } } } else if (action === "wallpaper") { - const random = args[1]?.toLowerCase() === "random"; - const term = (random ? args[2] : args[1]) ?? ""; - const list = random ? Wallpapers.get_default().categories : Wallpapers.get_default().list; + if (args[1]?.toLowerCase() === "random") { + const list = Wallpapers.get_default().categories; + for (const { obj } of fuzzysort.go(args[2] ?? "", list, { all: true, key: "path" })) + this.#content.add(<Category {...obj} />); + } else { + const list = Wallpapers.get_default().list; + let limit = undefined; + if ((args[1] || !config.wallpaper.showAllEmpty.get()) && config.wallpaper.maxResults.get() > 0) + limit = config.wallpaper.maxResults.get(); - for (const { obj } of fuzzysort.go(term, list, { all: true, key: "path" })) - this.#content.add(random ? <Category {...(obj as ICategory)} /> : <Wallpaper {...obj} />); + for (const { obj } of fuzzysort.go(args[1] ?? "", list, { all: true, key: "path", limit })) + this.#content.add(<Wallpaper {...obj} />); + } } else if (action === "transparency") { const list = Object.keys(transparencyActions); |