Make Background a native feature
- Background replaces the Background Slideshow plugin and the background image of Appearance. It shows a folder as a slideshow, or one image. - It is on by default. Its module loads at launch only when a folder or an image is chosen. - Rust keeps the one folder in background-folder.json. The interface never sends a path. Eight background_* commands replace the six deprecated backgrounds_* commands. - The first start moves the slideshow folder and settings, and keeps the saved image as the image source. - One blur worker with a cache, fewer folder reads, and a decode before each fade. The hub writes only the changed properties. - Remove the deprecated folder methods of api.backgrounds. set, get, and subscribe stay for the Project Management plugin. - Show the view buttons in the workbench test without text, after UI-056. - Update the tests, the measurement tool, the docs, and UI-057.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// A feature in the workbench of one window. Its views and commands come from the static catalog, so the
|
||||
// navigation buttons and the command palette show them without the feature code. The first mount,
|
||||
// restore, or command loads the feature module and starts one instance for this window.
|
||||
// restore, or action command loads the feature module and starts one instance for this window.
|
||||
// A launch rule (`launch.ts`) can also start the instance at once.
|
||||
import { tr } from "../i18n/index.ts";
|
||||
import type { Dispose, PluginCommand, PluginDocumentType, PluginView } from "../plugins/sdk.ts";
|
||||
import type { FeatureEntry } from "./catalog.ts";
|
||||
@@ -32,7 +33,9 @@ export class FeatureSession {
|
||||
});
|
||||
}
|
||||
for (const info of entry.commands) {
|
||||
this.commands.set(info.id, { id: info.id, get title() { return info.title(); }, icon: info.icon, run: () => context.openView(info.view) });
|
||||
const view = info.view;
|
||||
this.commands.set(info.id, { id: info.id, get title() { return info.title(); }, icon: info.icon,
|
||||
run: view ? () => context.openView(view) : async () => { await (await this.running()).run?.(info.id); } });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +65,12 @@ export class FeatureSession {
|
||||
|
||||
async launch(id: string) { this.context.openView(id); }
|
||||
|
||||
/** Load the module and start the instance now, without a view. Later calls use the same instance. */
|
||||
async start(): Promise<void> { await this.running(); }
|
||||
|
||||
/** True after the instance started. */
|
||||
get started(): boolean { return this.instance !== undefined; }
|
||||
|
||||
async run(id: string) {
|
||||
const command = this.commands.get(id);
|
||||
if (!command) throw new Error(tr("This command is unavailable."));
|
||||
|
||||
Reference in New Issue
Block a user