@gjsify/example-gtk-adwaita-storybook 0.53.0 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-main.js +8093 -3042
- package/dist/gjs.js +15 -10
- package/dist/gjs.node.mjs +10 -5
- package/package.json +5 -5
- package/src/browser/buttons/color-dialog-button.web.ts +42 -0
- package/src/browser/buttons/font-dialog-button.web.ts +42 -0
- package/src/browser/buttons/link-button.web.ts +37 -0
- package/src/browser/buttons/scale-button.web.ts +36 -0
- package/src/browser/buttons/toggle-button.web.ts +35 -0
- package/src/browser/controls/check-button.web.ts +38 -0
- package/src/browser/controls/gtk-spinner.web.ts +39 -0
- package/src/browser/controls/level-bar.web.ts +43 -0
- package/src/browser/controls/password-entry.web.ts +36 -0
- package/src/browser/controls/progress-bar.web.ts +39 -0
- package/src/browser/controls/scale.web.ts +44 -0
- package/src/browser/controls/search-entry.web.ts +49 -0
- package/src/browser/controls/spin-button.web.ts +40 -0
- package/src/browser/controls/switch.web.ts +38 -0
- package/src/browser/drawing/drag-icon.web.ts +112 -0
- package/src/browser/drawing/drawing-area.web.ts +66 -0
- package/src/browser/drawing/gl-area.web.ts +162 -0
- package/src/browser/drawing/graphics-offload.web.ts +74 -0
- package/src/browser/feedback/dialog.web.ts +76 -0
- package/src/browser/feedback/emoji-chooser.web.ts +93 -0
- package/src/browser/feedback/gtk-about-dialog.web.ts +105 -0
- package/src/browser/feedback/page-setup-unix-dialog.web.ts +93 -0
- package/src/browser/feedback/print-unix-dialog.web.ts +111 -0
- package/src/browser/feedback/shortcuts-dialog.web.ts +90 -0
- package/src/browser/layout/application-window.web.ts +94 -0
- package/src/browser/layout/aspect-frame.web.ts +49 -0
- package/src/browser/layout/bin.web.ts +41 -0
- package/src/browser/layout/breakpoint-bin.web.ts +61 -0
- package/src/browser/layout/center-box.web.ts +45 -0
- package/src/browser/layout/clamp-scrollable.web.ts +47 -0
- package/src/browser/layout/expander.web.ts +52 -0
- package/src/browser/layout/fixed.web.ts +51 -0
- package/src/browser/layout/frame.web.ts +40 -0
- package/src/browser/layout/grid.web.ts +46 -0
- package/src/browser/layout/layout-slot.web.ts +60 -0
- package/src/browser/layout/multi-layout-view.web.ts +94 -0
- package/src/browser/layout/overlay.web.ts +57 -0
- package/src/browser/layout/paned.web.ts +69 -0
- package/src/browser/layout/popover-bin.web.ts +54 -0
- package/src/browser/layout/popover-menu.web.ts +48 -0
- package/src/browser/layout/popover.web.ts +61 -0
- package/src/browser/layout/revealer.web.ts +53 -0
- package/src/browser/layout/scrollbar.web.ts +54 -0
- package/src/browser/layout/scrolled-window.web.ts +52 -0
- package/src/browser/layout/separator.web.ts +47 -0
- package/src/browser/layout/viewport.web.ts +51 -0
- package/src/browser/layout/window.web.ts +60 -0
- package/src/browser/media/image.web.ts +39 -0
- package/src/browser/media/inscription.web.ts +52 -0
- package/src/browser/media/media-controls.web.ts +65 -0
- package/src/browser/media/picture.web.ts +56 -0
- package/src/browser/media/video.web.ts +56 -0
- package/src/browser/navigation/popover-menu-bar.web.ts +40 -0
- package/src/browser/presentation/calendar.web.ts +49 -0
- package/src/browser/presentation/column-view.web.ts +45 -0
- package/src/browser/presentation/flow-box.web.ts +52 -0
- package/src/browser/presentation/grid-view.web.ts +37 -0
- package/src/browser/presentation/list-box.web.ts +48 -0
- package/src/browser/presentation/list-view.web.ts +36 -0
- package/src/browser/presentation/tree-expander.web.ts +68 -0
- package/src/browser/presentation/window-handle.web.ts +42 -0
- package/src/browser/rows/preferences-row.web.ts +43 -0
- package/src/browser/stories.ts +158 -0
- package/src/browser/text/editable-label.web.ts +45 -0
- package/src/browser/text/search-bar.web.ts +45 -0
- package/src/browser/text/text-view.web.ts +54 -0
- package/src/browser/text/text.web.ts +48 -0
- package/src/browser/view-switching/notebook.web.ts +67 -0
- package/src/browser/view-switching/stack-sidebar.web.ts +68 -0
- package/src/browser/view-switching/stack-switcher.web.ts +70 -0
- package/src/browser/view-switching/stack.web.ts +72 -0
- package/src/browser/view-switching/tab-bar.web.ts +105 -0
- package/src/browser/view-switching/tab-button.web.ts +52 -0
- package/src/browser/view-switching/tab-overview.web.ts +87 -0
- package/src/browser/view-switching/view-switcher-sidebar.web.ts +77 -0
- package/src/browser/windows/action-bar.web.ts +66 -0
- package/src/browser/windows/gtk-application-window.web.ts +67 -0
- package/src/browser/windows/gtk-header-bar.web.ts +61 -0
- package/src/browser/windows/gtk-window.web.ts +58 -0
- package/src/browser/windows/window-controls.web.ts +54 -0
- package/src/buttons/color-dialog-button.meta.ts +16 -0
- package/src/buttons/color-dialog-button.story.ts +49 -0
- package/src/buttons/font-dialog-button.meta.ts +29 -0
- package/src/buttons/font-dialog-button.story.ts +52 -0
- package/src/buttons/link-button.meta.ts +18 -0
- package/src/buttons/link-button.story.ts +48 -0
- package/src/buttons/scale-button.meta.ts +34 -0
- package/src/buttons/scale-button.story.ts +50 -0
- package/src/buttons/toggle-button.meta.ts +17 -0
- package/src/buttons/toggle-button.story.ts +46 -0
- package/src/controls/check-button.meta.ts +19 -0
- package/src/controls/check-button.story.ts +56 -0
- package/src/controls/gtk-spinner.meta.ts +24 -0
- package/src/controls/gtk-spinner.story.ts +53 -0
- package/src/controls/level-bar.meta.ts +39 -0
- package/src/controls/level-bar.story.ts +58 -0
- package/src/controls/password-entry.meta.ts +18 -0
- package/src/controls/password-entry.story.ts +54 -0
- package/src/controls/progress-bar.meta.ts +20 -0
- package/src/controls/progress-bar.story.ts +53 -0
- package/src/controls/scale.meta.ts +47 -0
- package/src/controls/scale.story.ts +66 -0
- package/src/controls/search-entry.meta.ts +18 -0
- package/src/controls/search-entry.story.ts +57 -0
- package/src/controls/spin-button.meta.ts +40 -0
- package/src/controls/spin-button.story.ts +55 -0
- package/src/controls/switch.meta.ts +18 -0
- package/src/controls/switch.story.ts +50 -0
- package/src/drawing/drag-icon.meta.ts +39 -0
- package/src/drawing/drag-icon.story.ts +117 -0
- package/src/drawing/drawing-area.meta.ts +45 -0
- package/src/drawing/drawing-area.story.ts +78 -0
- package/src/drawing/gl-area.meta.ts +30 -0
- package/src/drawing/gl-area.story.ts +113 -0
- package/src/drawing/graphics-offload.meta.ts +39 -0
- package/src/drawing/graphics-offload.story.ts +73 -0
- package/src/feedback/dialog.meta.ts +25 -0
- package/src/feedback/dialog.story.ts +78 -0
- package/src/feedback/emoji-chooser.meta.ts +10 -0
- package/src/feedback/emoji-chooser.story.ts +98 -0
- package/src/feedback/gtk-about-dialog.meta.ts +29 -0
- package/src/feedback/gtk-about-dialog.story.ts +90 -0
- package/src/feedback/page-setup-unix-dialog.meta.ts +37 -0
- package/src/feedback/page-setup-unix-dialog.story.ts +70 -0
- package/src/feedback/print-unix-dialog.meta.ts +30 -0
- package/src/feedback/print-unix-dialog.story.ts +93 -0
- package/src/feedback/shortcuts-dialog.meta.ts +12 -0
- package/src/feedback/shortcuts-dialog.story.ts +79 -0
- package/src/layout/application-window.meta.ts +16 -0
- package/src/layout/application-window.story.ts +97 -0
- package/src/layout/aspect-frame.meta.ts +19 -0
- package/src/layout/aspect-frame.story.ts +62 -0
- package/src/layout/bin.meta.ts +15 -0
- package/src/layout/bin.story.ts +56 -0
- package/src/layout/breakpoint-bin.meta.ts +38 -0
- package/src/layout/breakpoint-bin.story.ts +62 -0
- package/src/layout/center-box.meta.ts +26 -0
- package/src/layout/center-box.story.ts +54 -0
- package/src/layout/clamp-scrollable.meta.ts +30 -0
- package/src/layout/clamp-scrollable.story.ts +51 -0
- package/src/layout/expander.meta.ts +30 -0
- package/src/layout/expander.story.ts +62 -0
- package/src/layout/fixed.meta.ts +16 -0
- package/src/layout/fixed.story.ts +54 -0
- package/src/layout/frame.meta.ts +24 -0
- package/src/layout/frame.story.ts +51 -0
- package/src/layout/grid.meta.ts +45 -0
- package/src/layout/grid.story.ts +80 -0
- package/src/layout/layout-slot.meta.ts +22 -0
- package/src/layout/layout-slot.story.ts +68 -0
- package/src/layout/multi-layout-view.meta.ts +31 -0
- package/src/layout/multi-layout-view.story.ts +101 -0
- package/src/layout/overlay.meta.ts +42 -0
- package/src/layout/overlay.story.ts +72 -0
- package/src/layout/paned.meta.ts +45 -0
- package/src/layout/paned.story.ts +70 -0
- package/src/layout/popover-bin.meta.ts +29 -0
- package/src/layout/popover-bin.story.ts +66 -0
- package/src/layout/popover-menu.meta.ts +54 -0
- package/src/layout/popover-menu.story.ts +119 -0
- package/src/layout/popover.meta.ts +38 -0
- package/src/layout/popover.story.ts +66 -0
- package/src/layout/revealer.meta.ts +44 -0
- package/src/layout/revealer.story.ts +79 -0
- package/src/layout/scrollbar.meta.ts +33 -0
- package/src/layout/scrollbar.story.ts +61 -0
- package/src/layout/scrolled-window.meta.ts +57 -0
- package/src/layout/scrolled-window.story.ts +74 -0
- package/src/layout/separator.meta.ts +25 -0
- package/src/layout/separator.story.ts +53 -0
- package/src/layout/viewport.meta.ts +19 -0
- package/src/layout/viewport.story.ts +53 -0
- package/src/layout/window.meta.ts +13 -0
- package/src/layout/window.story.ts +66 -0
- package/src/media/image.meta.ts +24 -0
- package/src/media/image.story.ts +48 -0
- package/src/media/inscription.meta.ts +45 -0
- package/src/media/inscription.story.ts +64 -0
- package/src/media/media-controls.meta.ts +30 -0
- package/src/media/media-controls.story.ts +58 -0
- package/src/media/picture.meta.ts +42 -0
- package/src/media/picture.story.ts +81 -0
- package/src/media/video.meta.ts +32 -0
- package/src/media/video.story.ts +57 -0
- package/src/metas.ts +79 -0
- package/src/navigation/popover-menu-bar.meta.ts +51 -0
- package/src/navigation/popover-menu-bar.story.ts +72 -0
- package/src/presentation/calendar.meta.ts +28 -0
- package/src/presentation/calendar.story.ts +64 -0
- package/src/presentation/column-view.meta.ts +30 -0
- package/src/presentation/column-view.story.ts +73 -0
- package/src/presentation/flow-box.meta.ts +51 -0
- package/src/presentation/flow-box.story.ts +72 -0
- package/src/presentation/grid-view.meta.ts +28 -0
- package/src/presentation/grid-view.story.ts +64 -0
- package/src/presentation/list-box.meta.ts +55 -0
- package/src/presentation/list-box.story.ts +68 -0
- package/src/presentation/list-view.meta.ts +38 -0
- package/src/presentation/list-view.story.ts +73 -0
- package/src/presentation/tree-expander.meta.ts +24 -0
- package/src/presentation/tree-expander.story.ts +105 -0
- package/src/presentation/window-handle.meta.ts +27 -0
- package/src/presentation/window-handle.story.ts +53 -0
- package/src/rows/preferences-row.meta.ts +15 -0
- package/src/rows/preferences-row.story.ts +50 -0
- package/src/text/editable-label.meta.ts +17 -0
- package/src/text/editable-label.story.ts +47 -0
- package/src/text/search-bar.meta.ts +17 -0
- package/src/text/search-bar.story.ts +48 -0
- package/src/text/text-view.meta.ts +49 -0
- package/src/text/text-view.story.ts +69 -0
- package/src/text/text.meta.ts +21 -0
- package/src/text/text.story.ts +50 -0
- package/src/view-switching/notebook.meta.ts +44 -0
- package/src/view-switching/notebook.story.ts +77 -0
- package/src/view-switching/stack-sidebar.meta.ts +50 -0
- package/src/view-switching/stack-sidebar.story.ts +85 -0
- package/src/view-switching/stack-switcher.meta.ts +53 -0
- package/src/view-switching/stack-switcher.story.ts +95 -0
- package/src/view-switching/stack.meta.ts +53 -0
- package/src/view-switching/stack.story.ts +95 -0
- package/src/view-switching/tab-bar.meta.ts +22 -0
- package/src/view-switching/tab-bar.story.ts +85 -0
- package/src/view-switching/tab-button.meta.ts +14 -0
- package/src/view-switching/tab-button.story.ts +52 -0
- package/src/view-switching/tab-overview.meta.ts +21 -0
- package/src/view-switching/tab-overview.story.ts +86 -0
- package/src/view-switching/view-switcher-sidebar.meta.ts +42 -0
- package/src/view-switching/view-switcher-sidebar.story.ts +73 -0
- package/src/windows/action-bar.meta.ts +27 -0
- package/src/windows/action-bar.story.ts +65 -0
- package/src/windows/gtk-application-window.meta.ts +27 -0
- package/src/windows/gtk-application-window.story.ts +89 -0
- package/src/windows/gtk-header-bar.meta.ts +39 -0
- package/src/windows/gtk-header-bar.story.ts +76 -0
- package/src/windows/gtk-window.meta.ts +30 -0
- package/src/windows/gtk-window.story.ts +64 -0
- package/src/windows/window-controls.meta.ts +42 -0
- package/src/windows/window-controls.story.ts +61 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Browser port of the Window Controls story. Shares metadata with window-controls.story.ts.
|
|
2
|
+
|
|
3
|
+
import { StoryElement, type StoryArgs, type StoryMeta, type WebStoryModule } from '@gjsify/adwaita-storybook';
|
|
4
|
+
import { windowControlsMeta } from '../../windows/window-controls.meta.js';
|
|
5
|
+
|
|
6
|
+
export class WindowControlsWebStory extends StoryElement {
|
|
7
|
+
private _window: HTMLElement | null = null;
|
|
8
|
+
private _controls: HTMLElement | null = null;
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super(WindowControlsWebStory.getMetadata(), 'Default');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static getMetadata(): StoryMeta {
|
|
15
|
+
return windowControlsMeta;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
initialize(): void {
|
|
19
|
+
this._window = document.createElement('gtk-window');
|
|
20
|
+
this._window.setAttribute('title', 'Documents');
|
|
21
|
+
this._window.setAttribute('default-width', '420');
|
|
22
|
+
this._window.setAttribute('default-height', '220');
|
|
23
|
+
|
|
24
|
+
const note = document.createElement('span');
|
|
25
|
+
note.textContent = 'A Gtk.WindowControls outside a window draws nothing — that is GTK, not this port.';
|
|
26
|
+
this._window.appendChild(note);
|
|
27
|
+
|
|
28
|
+
// A window with NO titlebar of its own, so these really are the titlebar, which is the
|
|
29
|
+
// shape `update_window_buttons` reads its four window properties for. The frame draws
|
|
30
|
+
// its own controls pair around them when there is nothing here — hence the slot.
|
|
31
|
+
this._controls = document.createElement('gtk-window-controls');
|
|
32
|
+
this._controls.setAttribute('slot', 'titlebar');
|
|
33
|
+
this._window.appendChild(this._controls);
|
|
34
|
+
|
|
35
|
+
this.addContent(this._window);
|
|
36
|
+
this._apply();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
updateArgs(_args: StoryArgs): void {
|
|
40
|
+
this._apply();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private _apply(): void {
|
|
44
|
+
if (!this._window || !this._controls) return;
|
|
45
|
+
this._controls.setAttribute('side', (this.args.side as string) === 'end' ? 'end' : 'start');
|
|
46
|
+
this._controls.setAttribute('decoration-layout', this.args.decorationLayout as string);
|
|
47
|
+
// `update_window_buttons` (:270-274) reads exactly these four off the frame.
|
|
48
|
+
this._window.setAttribute('resizable', String(this.args.resizable as boolean));
|
|
49
|
+
this._window.setAttribute('maximized', String(this.args.maximized as boolean));
|
|
50
|
+
this._window.setAttribute('modal', String(this.args.modal as boolean));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const WindowControlsWebStories: WebStoryModule = { stories: [WindowControlsWebStory] };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Color Dialog Button story. Imported by the
|
|
2
|
+
// GTK renderer (color-dialog-button.story.ts) and the browser renderer
|
|
3
|
+
// (browser/buttons/color-dialog-button.web.ts), so both expose identical controls.
|
|
4
|
+
|
|
5
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
6
|
+
|
|
7
|
+
export const colorDialogButtonMeta: StoryMeta = {
|
|
8
|
+
title: 'Buttons/Color Dialog Button',
|
|
9
|
+
description:
|
|
10
|
+
'Gtk.ColorDialogButton — a button that shows a colour and opens a chooser for it. It is ' +
|
|
11
|
+
'insensitive until a dialog is set, and the swatch announces the channel percentages.',
|
|
12
|
+
controls: [
|
|
13
|
+
{ name: 'rgba', label: 'Colour', type: ControlType.TEXT, defaultValue: '#3584e4' },
|
|
14
|
+
{ name: 'title', label: 'Dialog title', type: ControlType.TEXT, defaultValue: 'Choose a colour' },
|
|
15
|
+
],
|
|
16
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Gtk.ColorDialogButton — a button that shows a colour and opens a chooser for it.
|
|
2
|
+
// original implementation.
|
|
3
|
+
|
|
4
|
+
import Gtk from 'gi://Gtk?version=4.0';
|
|
5
|
+
import Gdk from 'gi://Gdk?version=4.0';
|
|
6
|
+
import GObject from 'gi://GObject?version=2.0';
|
|
7
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
8
|
+
import { colorDialogButtonMeta } from './color-dialog-button.meta.js';
|
|
9
|
+
|
|
10
|
+
/** Story: a Gtk.ColorDialogButton with a dialog, its colour and the dialog's title bound. */
|
|
11
|
+
export class ColorDialogButtonStory extends StoryWidget {
|
|
12
|
+
private _button: Gtk.ColorDialogButton | null = null;
|
|
13
|
+
|
|
14
|
+
static {
|
|
15
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookColorDialogButton' }, ColorDialogButtonStory);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
super(StoryWidget.fromMeta(ColorDialogButtonStory.getMetadata(), 'Default'));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static getMetadata(): StoryMeta {
|
|
23
|
+
return { ...colorDialogButtonMeta, component: Gtk.ColorDialogButton.$gtype };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
initialize(): void {
|
|
27
|
+
// The dialog is what makes the button sensitive at all, so it is set BEFORE the
|
|
28
|
+
// colour: `update_button_sensitivity` is `dialog != NULL && cancellable == NULL`.
|
|
29
|
+
this._button = new Gtk.ColorDialogButton({ halign: Gtk.Align.CENTER });
|
|
30
|
+
this._button.dialog = new Gtk.ColorDialog();
|
|
31
|
+
this._apply();
|
|
32
|
+
this.addContent(this._button);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
updateArgs(_args: StoryArgs): void {
|
|
36
|
+
this._apply();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private _apply(): void {
|
|
40
|
+
if (!this._button) return;
|
|
41
|
+
const rgba = new Gdk.RGBA();
|
|
42
|
+
if (rgba.parse(this.args.rgba as string)) this._button.rgba = rgba;
|
|
43
|
+
this._button.dialog!.title = (this.args.title as string) || '';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
GObject.type_ensure(ColorDialogButtonStory.$gtype);
|
|
48
|
+
|
|
49
|
+
export const ColorDialogButtonStories: StoryModule = { stories: [ColorDialogButtonStory] };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Font Dialog Button story. Imported by the GTK
|
|
2
|
+
// renderer (font-dialog-button.story.ts) and the browser renderer
|
|
3
|
+
// (browser/buttons/font-dialog-button.web.ts), so both expose identical controls.
|
|
4
|
+
|
|
5
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
6
|
+
|
|
7
|
+
export const fontDialogButtonMeta: StoryMeta = {
|
|
8
|
+
title: 'Buttons/Font Dialog Button',
|
|
9
|
+
description:
|
|
10
|
+
'Gtk.FontDialogButton — a button that shows a font and opens a chooser for it. At level family ' +
|
|
11
|
+
'the label is the family alone; from font up it is family plus size, and the size box appears.',
|
|
12
|
+
controls: [
|
|
13
|
+
{ name: 'fontDesc', label: 'Font', type: ControlType.TEXT, defaultValue: 'Sans Bold 12' },
|
|
14
|
+
{
|
|
15
|
+
name: 'level',
|
|
16
|
+
label: 'Level',
|
|
17
|
+
type: ControlType.SELECT,
|
|
18
|
+
options: [
|
|
19
|
+
{ label: 'Family', value: 'family' },
|
|
20
|
+
{ label: 'Face', value: 'face' },
|
|
21
|
+
{ label: 'Font', value: 'font' },
|
|
22
|
+
{ label: 'Features', value: 'features' },
|
|
23
|
+
],
|
|
24
|
+
defaultValue: 'font',
|
|
25
|
+
},
|
|
26
|
+
{ name: 'useFont', label: 'Draw in the font', type: ControlType.BOOLEAN, defaultValue: true },
|
|
27
|
+
{ name: 'useSize', label: 'Draw in the size', type: ControlType.BOOLEAN, defaultValue: true },
|
|
28
|
+
],
|
|
29
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Gtk.FontDialogButton — a button that shows a font and opens a chooser for it.
|
|
2
|
+
// original implementation.
|
|
3
|
+
|
|
4
|
+
import Gtk from 'gi://Gtk?version=4.0';
|
|
5
|
+
import Pango from 'gi://Pango?version=1.0';
|
|
6
|
+
import GObject from 'gi://GObject?version=2.0';
|
|
7
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
8
|
+
import { fontDialogButtonMeta } from './font-dialog-button.meta.js';
|
|
9
|
+
|
|
10
|
+
/** Story: a Gtk.FontDialogButton with the level, the description and the two draw flags bound. */
|
|
11
|
+
export class FontDialogButtonStory extends StoryWidget {
|
|
12
|
+
private _button: Gtk.FontDialogButton | null = null;
|
|
13
|
+
|
|
14
|
+
static {
|
|
15
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookFontDialogButton' }, FontDialogButtonStory);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
super(StoryWidget.fromMeta(FontDialogButtonStory.getMetadata(), 'Default'));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static getMetadata(): StoryMeta {
|
|
23
|
+
return { ...fontDialogButtonMeta, component: Gtk.FontDialogButton.$gtype };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
initialize(): void {
|
|
27
|
+
this._button = new Gtk.FontDialogButton({ halign: Gtk.Align.CENTER });
|
|
28
|
+
this._button.dialog = new Gtk.FontDialog();
|
|
29
|
+
this._apply();
|
|
30
|
+
this.addContent(this._button);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
updateArgs(_args: StoryArgs): void {
|
|
34
|
+
this._apply();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private _apply(): void {
|
|
38
|
+
if (!this._button) return;
|
|
39
|
+
// `level` first: it decides whether the size box is visible at all, so writing the
|
|
40
|
+
// description afterwards paints the label the new level asks for.
|
|
41
|
+
this._button.level = this.args.level as unknown as Gtk.FontLevel;
|
|
42
|
+
const desc = Pango.FontDescription.from_string(this.args.fontDesc as string);
|
|
43
|
+
if (desc !== null) this._button.fontDesc = desc;
|
|
44
|
+
// `use_size` is only consulted when `use_font` is set, so it goes second.
|
|
45
|
+
this._button.useFont = this.args.useFont as boolean;
|
|
46
|
+
this._button.useSize = this.args.useSize as boolean;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
GObject.type_ensure(FontDialogButtonStory.$gtype);
|
|
51
|
+
|
|
52
|
+
export const FontDialogButtonStories: StoryModule = { stories: [FontDialogButtonStory] };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Link Button story. Imported by the GTK
|
|
2
|
+
// renderer (link-button.story.ts) and the browser renderer
|
|
3
|
+
// (browser/buttons/link-button.web.ts), so both expose identical controls.
|
|
4
|
+
|
|
5
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
6
|
+
|
|
7
|
+
export const linkButtonMeta: StoryMeta = {
|
|
8
|
+
title: 'Buttons/Link Button',
|
|
9
|
+
description:
|
|
10
|
+
'Gtk.LinkButton — a button that follows a URI. It is a Gtk.Button with a uri and a visited ' +
|
|
11
|
+
'state: clicking launches the URI and marks the link visited, and pointing it somewhere new ' +
|
|
12
|
+
'un-visits it.',
|
|
13
|
+
controls: [
|
|
14
|
+
{ name: 'label', label: 'Label', type: ControlType.TEXT, defaultValue: 'GNOME' },
|
|
15
|
+
{ name: 'uri', label: 'URI', type: ControlType.TEXT, defaultValue: 'https://gnome.org' },
|
|
16
|
+
{ name: 'visited', label: 'Visited', type: ControlType.BOOLEAN, defaultValue: false },
|
|
17
|
+
],
|
|
18
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Gtk.LinkButton — a button that follows a URI.
|
|
2
|
+
// original implementation.
|
|
3
|
+
|
|
4
|
+
import Gtk from 'gi://Gtk?version=4.0';
|
|
5
|
+
import GObject from 'gi://GObject?version=2.0';
|
|
6
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
7
|
+
import { linkButtonMeta } from './link-button.meta.js';
|
|
8
|
+
|
|
9
|
+
/** Story: a Gtk.LinkButton with its label, URI and visited state bound to args. */
|
|
10
|
+
export class LinkButtonStory extends StoryWidget {
|
|
11
|
+
private _button: Gtk.LinkButton | null = null;
|
|
12
|
+
|
|
13
|
+
static {
|
|
14
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookLinkButton' }, LinkButtonStory);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super(StoryWidget.fromMeta(LinkButtonStory.getMetadata(), 'Default'));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static getMetadata(): StoryMeta {
|
|
22
|
+
return { ...linkButtonMeta, component: Gtk.LinkButton.$gtype };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
initialize(): void {
|
|
26
|
+
this._button = new Gtk.LinkButton({ halign: Gtk.Align.CENTER });
|
|
27
|
+
this._apply();
|
|
28
|
+
this.addContent(this._button);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
updateArgs(_args: StoryArgs): void {
|
|
32
|
+
this._apply();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private _apply(): void {
|
|
36
|
+
if (!this._button) return;
|
|
37
|
+
const label = this.args.label as string;
|
|
38
|
+
this._button.label = label;
|
|
39
|
+
// `uri` last, because `gtk_link_button_set_uri()` unsets `visited` as a side effect
|
|
40
|
+
// — writing the two the other way round would never show a visited link.
|
|
41
|
+
this._button.uri = this.args.uri as string;
|
|
42
|
+
this._button.visited = this.args.visited as boolean;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
GObject.type_ensure(LinkButtonStory.$gtype);
|
|
47
|
+
|
|
48
|
+
export const LinkButtonStories: StoryModule = { stories: [LinkButtonStory] };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Scale Button story. Imported by the GTK
|
|
2
|
+
// renderer (scale-button.story.ts) and the browser renderer
|
|
3
|
+
// (browser/buttons/scale-button.web.ts), so both expose identical controls.
|
|
4
|
+
|
|
5
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
6
|
+
|
|
7
|
+
/** The icon list every renderer binds: three names, so the value picks between them. */
|
|
8
|
+
export const SCALE_BUTTON_ICONS = [
|
|
9
|
+
'audio-volume-muted-symbolic',
|
|
10
|
+
'audio-volume-low-symbolic',
|
|
11
|
+
'audio-volume-high-symbolic',
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
export const scaleButtonMeta: StoryMeta = {
|
|
15
|
+
title: 'Buttons/Scale Button',
|
|
16
|
+
description:
|
|
17
|
+
'Gtk.ScaleButton — a button whose press opens a scale. The icon follows the value: no list ' +
|
|
18
|
+
'draws image-missing, one name is used throughout, two split the range, three put the first at ' +
|
|
19
|
+
'the bottom and the second at the top and share the interior, five spread it.',
|
|
20
|
+
controls: [
|
|
21
|
+
{ name: 'value', label: 'Value', type: ControlType.NUMBER, defaultValue: 70 },
|
|
22
|
+
{
|
|
23
|
+
name: 'orientation',
|
|
24
|
+
label: 'Orientation',
|
|
25
|
+
type: ControlType.SELECT,
|
|
26
|
+
options: [
|
|
27
|
+
{ label: 'Vertical', value: 'vertical' },
|
|
28
|
+
{ label: 'Horizontal', value: 'horizontal' },
|
|
29
|
+
],
|
|
30
|
+
defaultValue: 'vertical',
|
|
31
|
+
},
|
|
32
|
+
{ name: 'hasFrame', label: 'Has frame', type: ControlType.BOOLEAN, defaultValue: false },
|
|
33
|
+
],
|
|
34
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Gtk.ScaleButton — a button whose press opens a scale.
|
|
2
|
+
// original implementation.
|
|
3
|
+
|
|
4
|
+
import Gtk from 'gi://Gtk?version=4.0';
|
|
5
|
+
import GObject from 'gi://GObject?version=2.0';
|
|
6
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
7
|
+
import { scaleButtonMeta } from './scale-button.meta.js';
|
|
8
|
+
import { SCALE_BUTTON_ICONS } from './scale-button.meta.js';
|
|
9
|
+
|
|
10
|
+
/** Story: a Gtk.ScaleButton whose icon follows its value, with the axis and the frame bound. */
|
|
11
|
+
export class ScaleButtonStory extends StoryWidget {
|
|
12
|
+
private _button: Gtk.ScaleButton | null = null;
|
|
13
|
+
|
|
14
|
+
static {
|
|
15
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookScaleButton' }, ScaleButtonStory);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
super(StoryWidget.fromMeta(ScaleButtonStory.getMetadata(), 'Default'));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static getMetadata(): StoryMeta {
|
|
23
|
+
return { ...scaleButtonMeta, component: Gtk.ScaleButton.$gtype };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
initialize(): void {
|
|
27
|
+
this._button = new Gtk.ScaleButton({ halign: Gtk.Align.CENTER });
|
|
28
|
+
this._button.icons = SCALE_BUTTON_ICONS;
|
|
29
|
+
this._apply();
|
|
30
|
+
this.addContent(this._button);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
updateArgs(_args: StoryArgs): void {
|
|
34
|
+
this._apply();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private _apply(): void {
|
|
38
|
+
if (!this._button) return;
|
|
39
|
+
// Orientation before the value: moving the axis does not move the value, and
|
|
40
|
+
// `gtk_scale_button_set_value()` clamps into the adjustment either way.
|
|
41
|
+
this._button.orientation =
|
|
42
|
+
(this.args.orientation as string) === 'horizontal' ? Gtk.Orientation.HORIZONTAL : Gtk.Orientation.VERTICAL;
|
|
43
|
+
this._button.hasFrame = this.args.hasFrame as boolean;
|
|
44
|
+
this._button.value = this.args.value as number;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
GObject.type_ensure(ScaleButtonStory.$gtype);
|
|
49
|
+
|
|
50
|
+
export const ScaleButtonStories: StoryModule = { stories: [ScaleButtonStory] };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Toggle Button story. Imported by the GTK
|
|
2
|
+
// renderer (toggle-button.story.ts) and the browser renderer
|
|
3
|
+
// (browser/buttons/toggle-button.web.ts), so both expose identical controls.
|
|
4
|
+
|
|
5
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
6
|
+
|
|
7
|
+
export const toggleButtonMeta: StoryMeta = {
|
|
8
|
+
title: 'Buttons/Toggle Button',
|
|
9
|
+
description:
|
|
10
|
+
'Gtk.ToggleButton — a button that stays pressed. It is a Gtk.Button with one more property, active, ' +
|
|
11
|
+
'so every button style class applies; Adw.ToggleGroup is the linked, single-choice form of it.',
|
|
12
|
+
controls: [
|
|
13
|
+
{ name: 'label', label: 'Label', type: ControlType.TEXT, defaultValue: 'Mute' },
|
|
14
|
+
{ name: 'active', label: 'Active', type: ControlType.BOOLEAN, defaultValue: false },
|
|
15
|
+
{ name: 'flat', label: 'Flat', type: ControlType.BOOLEAN, defaultValue: false },
|
|
16
|
+
],
|
|
17
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Gtk.ToggleButton — a button that stays pressed.
|
|
2
|
+
// original implementation.
|
|
3
|
+
|
|
4
|
+
import Gtk from 'gi://Gtk?version=4.0';
|
|
5
|
+
import GObject from 'gi://GObject?version=2.0';
|
|
6
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
7
|
+
import { toggleButtonMeta } from './toggle-button.meta.js';
|
|
8
|
+
|
|
9
|
+
/** Story: a Gtk.ToggleButton with its label, state and the flat style class bound to args. */
|
|
10
|
+
export class ToggleButtonStory extends StoryWidget {
|
|
11
|
+
private _button: Gtk.ToggleButton | null = null;
|
|
12
|
+
|
|
13
|
+
static {
|
|
14
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookToggleButton' }, ToggleButtonStory);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super(StoryWidget.fromMeta(ToggleButtonStory.getMetadata(), 'Default'));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static getMetadata(): StoryMeta {
|
|
22
|
+
return { ...toggleButtonMeta, component: Gtk.ToggleButton.$gtype };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
initialize(): void {
|
|
26
|
+
this._button = new Gtk.ToggleButton({ halign: Gtk.Align.CENTER });
|
|
27
|
+
this._apply();
|
|
28
|
+
this.addContent(this._button);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
updateArgs(_args: StoryArgs): void {
|
|
32
|
+
this._apply();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private _apply(): void {
|
|
36
|
+
if (!this._button) return;
|
|
37
|
+
this._button.label = this.args.label as string;
|
|
38
|
+
this._button.active = this.args.active as boolean;
|
|
39
|
+
if (this.args.flat as boolean) this._button.add_css_class('flat');
|
|
40
|
+
else this._button.remove_css_class('flat');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
GObject.type_ensure(ToggleButtonStory.$gtype);
|
|
45
|
+
|
|
46
|
+
export const ToggleButtonStories: StoryModule = { stories: [ToggleButtonStory] };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Check Button story. Imported by the GTK
|
|
2
|
+
// renderer (check-button.story.ts) and the browser renderer
|
|
3
|
+
// (browser/controls/check-button.web.ts), so both expose identical controls.
|
|
4
|
+
|
|
5
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
6
|
+
|
|
7
|
+
export const checkButtonMeta: StoryMeta = {
|
|
8
|
+
title: 'Controls/Check Button',
|
|
9
|
+
description:
|
|
10
|
+
'Gtk.CheckButton — a label beside an indicator, with a third "in between" state for a selection ' +
|
|
11
|
+
'that is only partly made. The browser element spells the two states checked and indeterminate, ' +
|
|
12
|
+
'the words the Adwaita stylesheet selects on; the grouped, single-choice form is Adw.Radio.',
|
|
13
|
+
controls: [
|
|
14
|
+
{ name: 'label', label: 'Label', type: ControlType.TEXT, defaultValue: 'Enable networking' },
|
|
15
|
+
{ name: 'checked', label: 'Checked', type: ControlType.BOOLEAN, defaultValue: true },
|
|
16
|
+
{ name: 'indeterminate', label: 'Indeterminate', type: ControlType.BOOLEAN, defaultValue: false },
|
|
17
|
+
{ name: 'disabled', label: 'Disabled', type: ControlType.BOOLEAN, defaultValue: false },
|
|
18
|
+
],
|
|
19
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Gtk.CheckButton — a label beside an indicator, and the third "in between" state.
|
|
2
|
+
// original implementation.
|
|
3
|
+
|
|
4
|
+
import Gtk from 'gi://Gtk?version=4.0';
|
|
5
|
+
import GObject from 'gi://GObject?version=2.0';
|
|
6
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
7
|
+
import { checkButtonMeta } from './check-button.meta.js';
|
|
8
|
+
|
|
9
|
+
/** Story: a Gtk.CheckButton with its label, both booleans and `sensitive` bound to args. */
|
|
10
|
+
export class CheckButtonStory extends StoryWidget {
|
|
11
|
+
private _box: Gtk.Box | null = null;
|
|
12
|
+
private _button: Gtk.CheckButton | null = null;
|
|
13
|
+
|
|
14
|
+
static {
|
|
15
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookCheckButton' }, CheckButtonStory);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
super(StoryWidget.fromMeta(CheckButtonStory.getMetadata(), 'Default'));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static getMetadata(): StoryMeta {
|
|
23
|
+
return { ...checkButtonMeta, component: Gtk.CheckButton.$gtype };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
initialize(): void {
|
|
27
|
+
this._button = new Gtk.CheckButton();
|
|
28
|
+
this._box = new Gtk.Box({
|
|
29
|
+
orientation: Gtk.Orientation.VERTICAL,
|
|
30
|
+
spacing: 12,
|
|
31
|
+
halign: Gtk.Align.CENTER,
|
|
32
|
+
});
|
|
33
|
+
this._box.append(this._button);
|
|
34
|
+
this._apply();
|
|
35
|
+
this.addContent(this._box);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
updateArgs(_args: StoryArgs): void {
|
|
39
|
+
this._apply();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private _apply(): void {
|
|
43
|
+
if (!this._button) return;
|
|
44
|
+
this._button.label = this.args.label as string;
|
|
45
|
+
this._button.active = this.args.checked as boolean;
|
|
46
|
+
// GTK does NOT clear the inconsistent state when the user checks the button; the
|
|
47
|
+
// property's own documentation says turning it off again is the application's job
|
|
48
|
+
// (gtkcheckbutton.c:855-856). The browser element diverges here, and says so.
|
|
49
|
+
this._button.inconsistent = this.args.indeterminate as boolean;
|
|
50
|
+
this._button.sensitive = !(this.args.disabled as boolean);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
GObject.type_ensure(CheckButtonStory.$gtype);
|
|
55
|
+
|
|
56
|
+
export const CheckButtonStories: StoryModule = { stories: [CheckButtonStory] };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the GTK Spinner story. Imported by the GTK
|
|
2
|
+
// renderer (gtk-spinner.story.ts) and the browser renderer
|
|
3
|
+
// (browser/controls/gtk-spinner.web.ts), so both expose identical controls.
|
|
4
|
+
//
|
|
5
|
+
// The NAME is `gtk-spinner` and not `spinner` because `Presentation/Spinner` already
|
|
6
|
+
// holds that bare name for `Adw.Spinner`, and the storybook keys every meta on its file
|
|
7
|
+
// name: a second `spinner.meta.ts` would silently displace one of the two. The block in
|
|
8
|
+
// /gjsify/gtk/indicators/ is titled `Gtk.Spinner`, which `TITLED_AFTER` in
|
|
9
|
+
// `scripts/check-website-adwaita-gallery.mjs` maps onto this meta.
|
|
10
|
+
|
|
11
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
12
|
+
|
|
13
|
+
export const gtkSpinnerMeta: StoryMeta = {
|
|
14
|
+
title: 'Controls/Spinner (GTK)',
|
|
15
|
+
description:
|
|
16
|
+
"Gtk.Spinner — GTK's own busy indicator: a faint ring with a quarter arc turning around it, " +
|
|
17
|
+
'sized by its allocation. Adw.Spinner is the libadwaita replacement and looks different; under ' +
|
|
18
|
+
'reduced motion GTK swaps this one for a static hourglass, which Adw.Spinner deliberately does not do.',
|
|
19
|
+
controls: [
|
|
20
|
+
{ name: 'size', label: 'Size (px)', type: ControlType.RANGE, min: 16, max: 64, step: 4, defaultValue: 32 },
|
|
21
|
+
{ name: 'spinning', label: 'Spinning', type: ControlType.BOOLEAN, defaultValue: true },
|
|
22
|
+
{ name: 'disabled', label: 'Disabled', type: ControlType.BOOLEAN, defaultValue: false },
|
|
23
|
+
],
|
|
24
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Gtk.Spinner — the GTK busy indicator, sized by its allocation.
|
|
2
|
+
// original implementation.
|
|
3
|
+
|
|
4
|
+
import Gtk from 'gi://Gtk?version=4.0';
|
|
5
|
+
import GObject from 'gi://GObject?version=2.0';
|
|
6
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
7
|
+
import { gtkSpinnerMeta } from './gtk-spinner.meta.js';
|
|
8
|
+
|
|
9
|
+
/** Story: a Gtk.Spinner at a chosen size, spinning or stopped. */
|
|
10
|
+
export class GtkSpinnerStory extends StoryWidget {
|
|
11
|
+
private _spinner: Gtk.Spinner | null = null;
|
|
12
|
+
|
|
13
|
+
static {
|
|
14
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookGtkSpinner' }, GtkSpinnerStory);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super(StoryWidget.fromMeta(GtkSpinnerStory.getMetadata(), 'Default'));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static getMetadata(): StoryMeta {
|
|
22
|
+
return { ...gtkSpinnerMeta, component: Gtk.Spinner.$gtype };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
initialize(): void {
|
|
26
|
+
this._spinner = new Gtk.Spinner({ halign: Gtk.Align.CENTER, valign: Gtk.Align.CENTER });
|
|
27
|
+
this._apply();
|
|
28
|
+
this.addContent(this._spinner);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
updateArgs(_args: StoryArgs): void {
|
|
32
|
+
this._apply();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private _apply(): void {
|
|
36
|
+
if (!this._spinner) return;
|
|
37
|
+
// `GtkSpinner` has ONE property and no size property of its own: the icon is
|
|
38
|
+
// measured from the `icon-size` CSS property and the widget from its allocation
|
|
39
|
+
// (gtkspinner.c:110-123), so a request is how a story sizes it.
|
|
40
|
+
const size = this.args.size as number;
|
|
41
|
+
this._spinner.widthRequest = size;
|
|
42
|
+
this._spinner.heightRequest = size;
|
|
43
|
+
// `start()` / `stop()`, not the property: both also raise and clear
|
|
44
|
+
// GTK_ACCESSIBLE_STATE_BUSY (gtkspinner.c:373-400).
|
|
45
|
+
if (this.args.spinning as boolean) this._spinner.start();
|
|
46
|
+
else this._spinner.stop();
|
|
47
|
+
this._spinner.sensitive = !(this.args.disabled as boolean);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
GObject.type_ensure(GtkSpinnerStory.$gtype);
|
|
52
|
+
|
|
53
|
+
export const GtkSpinnerStories: StoryModule = { stories: [GtkSpinnerStory] };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Level Bar story. Imported by the GTK
|
|
2
|
+
// renderer (level-bar.story.ts) and the browser renderer
|
|
3
|
+
// (browser/controls/level-bar.web.ts), so both expose identical controls.
|
|
4
|
+
|
|
5
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
6
|
+
|
|
7
|
+
export const levelBarMeta: StoryMeta = {
|
|
8
|
+
title: 'Controls/Level Bar',
|
|
9
|
+
description:
|
|
10
|
+
'Gtk.LevelBar — how full something is, over an interval that need not be 0…1: a password ' +
|
|
11
|
+
'strength meter, a battery. `mode` decides one filled level or one block per unit, and the ' +
|
|
12
|
+
'block takes a class from the nearest OFFSET (low, high, full by default), which is how libadwaita ' +
|
|
13
|
+
'colours it and how an application adds a colour of its own.',
|
|
14
|
+
controls: [
|
|
15
|
+
{ name: 'value', label: 'Value', type: ControlType.RANGE, min: 0, max: 1, step: 0.05, defaultValue: 0.8 },
|
|
16
|
+
{ name: 'maxValue', label: 'Max value', type: ControlType.RANGE, min: 1, max: 5, step: 1, defaultValue: 5 },
|
|
17
|
+
{
|
|
18
|
+
name: 'mode',
|
|
19
|
+
label: 'Mode',
|
|
20
|
+
type: ControlType.SELECT,
|
|
21
|
+
options: [
|
|
22
|
+
{ label: 'Continuous', value: 'continuous' },
|
|
23
|
+
{ label: 'Discrete', value: 'discrete' },
|
|
24
|
+
],
|
|
25
|
+
defaultValue: 'continuous',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'orientation',
|
|
29
|
+
label: 'Orientation',
|
|
30
|
+
type: ControlType.SELECT,
|
|
31
|
+
options: [
|
|
32
|
+
{ label: 'Horizontal', value: 'horizontal' },
|
|
33
|
+
{ label: 'Vertical', value: 'vertical' },
|
|
34
|
+
],
|
|
35
|
+
defaultValue: 'horizontal',
|
|
36
|
+
},
|
|
37
|
+
{ name: 'inverted', label: 'Inverted', type: ControlType.BOOLEAN, defaultValue: false },
|
|
38
|
+
],
|
|
39
|
+
};
|