package chandra:desktop@0.1.0; /// The widget (plasmoid) contract. interface plasmoid { use types.{size, draw-op, input-event}; record plasmoid-info { /// Stable machine id, e.g. "org.chandra.clock.digital". id: string, name: string, preferred: size, min-width: u32, /// Whether the panel may grow this widget beyond `preferred`. stretch: bool, } record popup-surface { size: size, ops: list, } enum surface { widget, popup } info: func() -> plasmoid-info; /// Draw the widget into a `size` box (local coordinates). render: func(size: size) -> list; /// Present when the widget wants a popup surface (e.g. a launcher menu). popup: func() -> option; /// Returns true when the widget's visuals changed and a redraw is needed. on-event: func(target: surface, event: input-event) -> bool; } /// Optional: a module's own settings. A module that exports this gets a "Module settings" entry in /// its right-click menu, listing the items below; the shell draws the menu (the same for every /// module), remembers each choice per module in state.edn (`:module-config`), and hands the saved /// values back through `set-config` right after the module is loaded. A module without it simply /// has no settings: the export is looked up by name, so older modules keep loading. interface module-config { record config-item { /// Stable key, saved in state.edn, e.g. "format". key: string, /// What the menu shows, e.g. "Time format". label: string, /// The values to choose from, shown as one row each (the current one ticked). Empty: an on/off /// switch, whose value is "on" or "off". choices: list, /// The current value. value: string, } config-items: func() -> list; /// Set `key` to `value` (unknown keys and values are ignored). True when the widget should redraw. set-config: func(key: string, value: string) -> bool; }