@gtkx/react 1.0.0-rc.1 → 1.0.0-rc.2
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/adw/config.d.ts +2 -0
- package/dist/adw/config.d.ts.map +1 -0
- package/dist/adw/config.js +2 -0
- package/dist/adw/config.js.map +1 -0
- package/dist/{libraries/adw → adw}/dialog.d.ts +2 -2
- package/dist/adw/dialog.d.ts.map +1 -0
- package/dist/adw/dialog.js +25 -0
- package/dist/adw/dialog.js.map +1 -0
- package/dist/adw/element-behaviors.d.ts +2 -0
- package/dist/adw/element-behaviors.d.ts.map +1 -0
- package/dist/adw/element-behaviors.js +299 -0
- package/dist/adw/element-behaviors.js.map +1 -0
- package/dist/adw/element-config.d.ts +9 -0
- package/dist/adw/element-config.d.ts.map +1 -0
- package/dist/adw/element-config.js +137 -0
- package/dist/adw/element-config.js.map +1 -0
- package/dist/adw/index.d.ts +4 -0
- package/dist/adw/index.d.ts.map +1 -0
- package/dist/adw/index.js +3 -0
- package/dist/adw/index.js.map +1 -0
- package/dist/adw/prop-types.d.ts +29 -0
- package/dist/adw/prop-types.d.ts.map +1 -0
- package/dist/adw/prop-types.js +2 -0
- package/dist/adw/prop-types.js.map +1 -0
- package/dist/bootstrap.d.ts +2 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +5 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/components/application.d.ts +2 -2
- package/dist/components/application.d.ts.map +1 -1
- package/dist/components/application.js +31 -18
- package/dist/components/application.js.map +1 -1
- package/dist/components/element.d.ts +6 -0
- package/dist/components/element.d.ts.map +1 -0
- package/dist/components/element.js +29 -0
- package/dist/components/element.js.map +1 -0
- package/dist/components/window.d.ts +2 -2
- package/dist/components/window.d.ts.map +1 -1
- package/dist/components/window.js +10 -11
- package/dist/components/window.js.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -0
- package/dist/element-behaviors.d.ts +2 -0
- package/dist/element-behaviors.d.ts.map +1 -0
- package/dist/element-behaviors.js +348 -0
- package/dist/element-behaviors.js.map +1 -0
- package/dist/element-config.d.ts +10 -0
- package/dist/element-config.d.ts.map +1 -0
- package/dist/element-config.js +146 -0
- package/dist/element-config.js.map +1 -0
- package/dist/hooks/use-application.d.ts +4 -3
- package/dist/hooks/use-application.d.ts.map +1 -1
- package/dist/hooks/use-application.js +5 -4
- package/dist/hooks/use-application.js.map +1 -1
- package/dist/hooks/use-bind-setting.d.ts +21 -4
- package/dist/hooks/use-bind-setting.d.ts.map +1 -1
- package/dist/hooks/use-bind-setting.js +27 -16
- package/dist/hooks/use-bind-setting.js.map +1 -1
- package/dist/hooks/use-merged-refs.d.ts +8 -0
- package/dist/hooks/use-merged-refs.d.ts.map +1 -0
- package/dist/hooks/use-merged-refs.js +48 -0
- package/dist/hooks/use-merged-refs.js.map +1 -0
- package/dist/hooks/use-object-value.d.ts +3 -2
- package/dist/hooks/use-object-value.d.ts.map +1 -1
- package/dist/hooks/use-object-value.js +18 -21
- package/dist/hooks/use-object-value.js.map +1 -1
- package/dist/hooks/use-parent-window.d.ts +3 -2
- package/dist/hooks/use-parent-window.d.ts.map +1 -1
- package/dist/hooks/use-parent-window.js +3 -2
- package/dist/hooks/use-parent-window.js.map +1 -1
- package/dist/hooks/use-property.d.ts +5 -5
- package/dist/hooks/use-property.d.ts.map +1 -1
- package/dist/hooks/use-property.js +4 -3
- package/dist/hooks/use-property.js.map +1 -1
- package/dist/hooks/use-setting.d.ts +5 -16
- package/dist/hooks/use-setting.d.ts.map +1 -1
- package/dist/hooks/use-setting.js +16 -11
- package/dist/hooks/use-setting.js.map +1 -1
- package/dist/hooks/use-signal.d.ts +10 -7
- package/dist/hooks/use-signal.d.ts.map +1 -1
- package/dist/hooks/use-signal.js +29 -18
- package/dist/hooks/use-signal.js.map +1 -1
- package/dist/index.d.ts +7 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +6 -7
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +5 -7
- package/dist/internal.js.map +1 -1
- package/dist/prop-types.d.ts +110 -0
- package/dist/prop-types.d.ts.map +1 -0
- package/dist/prop-types.js +2 -0
- package/dist/prop-types.js.map +1 -0
- package/dist/reconciler/apply-props.d.ts +10 -7
- package/dist/reconciler/apply-props.d.ts.map +1 -1
- package/dist/reconciler/apply-props.js +182 -84
- package/dist/reconciler/apply-props.js.map +1 -1
- package/dist/reconciler/behaviors.d.ts +59 -0
- package/dist/reconciler/behaviors.d.ts.map +1 -0
- package/dist/reconciler/behaviors.js +172 -0
- package/dist/reconciler/behaviors.js.map +1 -0
- package/dist/reconciler/child-routing.d.ts +5 -0
- package/dist/reconciler/child-routing.d.ts.map +1 -0
- package/dist/reconciler/child-routing.js +156 -0
- package/dist/reconciler/child-routing.js.map +1 -0
- package/dist/reconciler/host-config.d.ts +8 -12
- package/dist/reconciler/host-config.d.ts.map +1 -1
- package/dist/reconciler/host-config.js +175 -270
- package/dist/reconciler/host-config.js.map +1 -1
- package/dist/reconciler/instance.d.ts +4 -5
- package/dist/reconciler/instance.d.ts.map +1 -1
- package/dist/reconciler/instance.js +44 -22
- package/dist/reconciler/instance.js.map +1 -1
- package/dist/reconciler/metadata.d.ts +17 -0
- package/dist/reconciler/metadata.d.ts.map +1 -0
- package/dist/reconciler/metadata.js +82 -0
- package/dist/reconciler/metadata.js.map +1 -0
- package/dist/reconciler/node.d.ts +76 -0
- package/dist/reconciler/node.d.ts.map +1 -0
- package/dist/reconciler/node.js +53 -0
- package/dist/reconciler/node.js.map +1 -0
- package/dist/reconciler/placement.d.ts +5 -0
- package/dist/reconciler/placement.d.ts.map +1 -0
- package/dist/reconciler/placement.js +175 -0
- package/dist/reconciler/placement.js.map +1 -0
- package/dist/reconciler/registry.d.ts +92 -0
- package/dist/reconciler/registry.d.ts.map +1 -0
- package/dist/reconciler/registry.js +64 -0
- package/dist/reconciler/registry.js.map +1 -0
- package/dist/reconciler/root-element.d.ts +9 -12
- package/dist/reconciler/root-element.d.ts.map +1 -1
- package/dist/reconciler/root-element.js +6 -6
- package/dist/reconciler/root-element.js.map +1 -1
- package/dist/reconciler/root.d.ts +56 -0
- package/dist/reconciler/root.d.ts.map +1 -0
- package/dist/reconciler/root.js +109 -0
- package/dist/reconciler/root.js.map +1 -0
- package/dist/reconciler/signals.d.ts +10 -0
- package/dist/reconciler/signals.d.ts.map +1 -0
- package/dist/reconciler/signals.js +70 -0
- package/dist/reconciler/signals.js.map +1 -0
- package/dist/reconciler/text.d.ts +19 -0
- package/dist/reconciler/text.d.ts.map +1 -0
- package/dist/reconciler/text.js +276 -0
- package/dist/reconciler/text.js.map +1 -0
- package/dist/utils/accessible-metadata.d.ts +11 -4
- package/dist/utils/accessible-metadata.d.ts.map +1 -1
- package/dist/utils/accessible-metadata.js +20 -17
- package/dist/utils/accessible-metadata.js.map +1 -1
- package/dist/{reconciler/accessible.d.ts → utils/accessible-props.d.ts} +7 -6
- package/dist/utils/accessible-props.d.ts.map +1 -0
- package/dist/utils/accessible-props.js +181 -0
- package/dist/utils/accessible-props.js.map +1 -0
- package/dist/utils/ref-prop.d.ts +15 -0
- package/dist/utils/ref-prop.d.ts.map +1 -0
- package/dist/utils/ref-prop.js +18 -0
- package/dist/utils/ref-prop.js.map +1 -0
- package/dist/utils/settings.d.ts +17 -0
- package/dist/utils/settings.d.ts.map +1 -0
- package/dist/utils/settings.js +37 -0
- package/dist/utils/settings.js.map +1 -0
- package/dist/utils/variant.d.ts +57 -0
- package/dist/utils/variant.d.ts.map +1 -0
- package/dist/utils/variant.js +197 -0
- package/dist/utils/variant.js.map +1 -0
- package/env.d.ts +9 -0
- package/package.json +36 -11
- package/src/adw/config.ts +1 -0
- package/src/adw/dialog.tsx +35 -0
- package/src/adw/element-behaviors.ts +379 -0
- package/src/adw/element-config.ts +140 -0
- package/src/adw/index.ts +4 -0
- package/src/adw/prop-types.ts +42 -0
- package/src/bootstrap.ts +5 -0
- package/src/components/application.tsx +42 -23
- package/src/components/element.tsx +47 -0
- package/src/components/window.tsx +12 -13
- package/src/config.ts +3 -0
- package/src/element-behaviors.ts +424 -0
- package/src/element-config.ts +148 -0
- package/src/env.d.ts +1 -0
- package/src/hooks/use-application.ts +6 -4
- package/src/hooks/use-bind-setting.ts +47 -31
- package/src/hooks/use-merged-refs.ts +64 -0
- package/src/hooks/use-object-value.ts +27 -23
- package/src/hooks/use-parent-window.ts +4 -2
- package/src/hooks/use-property.ts +11 -10
- package/src/hooks/use-setting.ts +20 -33
- package/src/hooks/use-signal.ts +37 -48
- package/src/index.ts +7 -8
- package/src/internal.ts +7 -18
- package/src/prop-types.ts +142 -0
- package/src/reconciler/apply-props.ts +233 -85
- package/src/reconciler/behaviors.ts +324 -0
- package/src/reconciler/child-routing.ts +202 -0
- package/src/reconciler/host-config.ts +239 -366
- package/src/reconciler/instance.ts +76 -24
- package/src/reconciler/metadata.ts +119 -0
- package/src/reconciler/node.ts +161 -0
- package/src/reconciler/placement.ts +255 -0
- package/src/reconciler/registry.ts +161 -0
- package/src/reconciler/root-element.ts +9 -11
- package/src/reconciler/root.ts +175 -0
- package/src/reconciler/signals.ts +113 -0
- package/src/reconciler/text.ts +407 -0
- package/src/utils/accessible-metadata.ts +23 -18
- package/src/utils/accessible-props.ts +279 -0
- package/src/utils/ref-prop.ts +30 -0
- package/src/utils/settings.ts +69 -0
- package/src/utils/variant.ts +368 -0
- package/dist/hooks/use-merge-refs.d.ts +0 -3
- package/dist/hooks/use-merge-refs.d.ts.map +0 -1
- package/dist/hooks/use-merge-refs.js +0 -48
- package/dist/hooks/use-merge-refs.js.map +0 -1
- package/dist/hooks/use-object-attachment.d.ts +0 -10
- package/dist/hooks/use-object-attachment.d.ts.map +0 -1
- package/dist/hooks/use-object-attachment.js +0 -24
- package/dist/hooks/use-object-attachment.js.map +0 -1
- package/dist/libraries/adw/dialog.d.ts.map +0 -1
- package/dist/libraries/adw/dialog.js +0 -25
- package/dist/libraries/adw/dialog.js.map +0 -1
- package/dist/libraries/adw/index.d.ts +0 -2
- package/dist/libraries/adw/index.d.ts.map +0 -1
- package/dist/libraries/adw/index.js +0 -2
- package/dist/libraries/adw/index.js.map +0 -1
- package/dist/reconciler/accessible.d.ts.map +0 -1
- package/dist/reconciler/accessible.js +0 -143
- package/dist/reconciler/accessible.js.map +0 -1
- package/dist/reconciler/commit-flush.d.ts +0 -3
- package/dist/reconciler/commit-flush.d.ts.map +0 -1
- package/dist/reconciler/commit-flush.js +0 -13
- package/dist/reconciler/commit-flush.js.map +0 -1
- package/dist/reconciler/container-attach.d.ts +0 -10
- package/dist/reconciler/container-attach.d.ts.map +0 -1
- package/dist/reconciler/container-attach.js +0 -216
- package/dist/reconciler/container-attach.js.map +0 -1
- package/dist/reconciler/content-rebuild.d.ts +0 -3
- package/dist/reconciler/content-rebuild.d.ts.map +0 -1
- package/dist/reconciler/content-rebuild.js +0 -15
- package/dist/reconciler/content-rebuild.js.map +0 -1
- package/dist/reconciler/dispatch.d.ts +0 -6
- package/dist/reconciler/dispatch.d.ts.map +0 -1
- package/dist/reconciler/dispatch.js +0 -61
- package/dist/reconciler/dispatch.js.map +0 -1
- package/dist/reconciler/element-prop-appliers.d.ts +0 -5
- package/dist/reconciler/element-prop-appliers.d.ts.map +0 -1
- package/dist/reconciler/element-prop-appliers.js +0 -104
- package/dist/reconciler/element-prop-appliers.js.map +0 -1
- package/dist/reconciler/element-props.d.ts +0 -25
- package/dist/reconciler/element-props.d.ts.map +0 -1
- package/dist/reconciler/element-props.js +0 -157
- package/dist/reconciler/element-props.js.map +0 -1
- package/dist/reconciler/label-text-rebuild.d.ts +0 -3
- package/dist/reconciler/label-text-rebuild.d.ts.map +0 -1
- package/dist/reconciler/label-text-rebuild.js +0 -22
- package/dist/reconciler/label-text-rebuild.js.map +0 -1
- package/dist/reconciler/portal.d.ts +0 -11
- package/dist/reconciler/portal.d.ts.map +0 -1
- package/dist/reconciler/portal.js +0 -20
- package/dist/reconciler/portal.js.map +0 -1
- package/dist/reconciler/reconciler-error-handler.d.ts +0 -7
- package/dist/reconciler/reconciler-error-handler.d.ts.map +0 -1
- package/dist/reconciler/reconciler-error-handler.js +0 -24
- package/dist/reconciler/reconciler-error-handler.js.map +0 -1
- package/dist/reconciler/reconciler-root.d.ts +0 -19
- package/dist/reconciler/reconciler-root.d.ts.map +0 -1
- package/dist/reconciler/reconciler-root.js +0 -24
- package/dist/reconciler/reconciler-root.js.map +0 -1
- package/dist/reconciler/reconciler.d.ts +0 -3
- package/dist/reconciler/reconciler.d.ts.map +0 -1
- package/dist/reconciler/reconciler.js +0 -12
- package/dist/reconciler/reconciler.js.map +0 -1
- package/dist/reconciler/render.d.ts +0 -23
- package/dist/reconciler/render.d.ts.map +0 -1
- package/dist/reconciler/render.js +0 -46
- package/dist/reconciler/render.js.map +0 -1
- package/dist/reconciler/signal-store.d.ts +0 -22
- package/dist/reconciler/signal-store.d.ts.map +0 -1
- package/dist/reconciler/signal-store.js +0 -84
- package/dist/reconciler/signal-store.js.map +0 -1
- package/dist/reconciler/state.d.ts +0 -36
- package/dist/reconciler/state.d.ts.map +0 -1
- package/dist/reconciler/state.js +0 -38
- package/dist/reconciler/state.js.map +0 -1
- package/dist/reconciler/text-buffer-controller.d.ts +0 -17
- package/dist/reconciler/text-buffer-controller.d.ts.map +0 -1
- package/dist/reconciler/text-buffer-controller.js +0 -102
- package/dist/reconciler/text-buffer-controller.js.map +0 -1
- package/dist/reconciler/text-buffer-rebuild.d.ts +0 -3
- package/dist/reconciler/text-buffer-rebuild.d.ts.map +0 -1
- package/dist/reconciler/text-buffer-rebuild.js +0 -7
- package/dist/reconciler/text-buffer-rebuild.js.map +0 -1
- package/dist/reconciler/text-node.d.ts +0 -7
- package/dist/reconciler/text-node.d.ts.map +0 -1
- package/dist/reconciler/text-node.js +0 -8
- package/dist/reconciler/text-node.js.map +0 -1
- package/dist/reconciler/types.d.ts +0 -5
- package/dist/reconciler/types.d.ts.map +0 -1
- package/dist/reconciler/types.js +0 -2
- package/dist/reconciler/types.js.map +0 -1
- package/dist/reconciler/visibility.d.ts +0 -6
- package/dist/reconciler/visibility.d.ts.map +0 -1
- package/dist/reconciler/visibility.js +0 -57
- package/dist/reconciler/visibility.js.map +0 -1
- package/dist/reconciler/wrapper-apply.d.ts +0 -6
- package/dist/reconciler/wrapper-apply.d.ts.map +0 -1
- package/dist/reconciler/wrapper-apply.js +0 -287
- package/dist/reconciler/wrapper-apply.js.map +0 -1
- package/dist/reconciler/wrapper-content.d.ts +0 -8
- package/dist/reconciler/wrapper-content.d.ts.map +0 -1
- package/dist/reconciler/wrapper-content.js +0 -19
- package/dist/reconciler/wrapper-content.js.map +0 -1
- package/dist/reconciler/wrapper-node.d.ts +0 -8
- package/dist/reconciler/wrapper-node.d.ts.map +0 -1
- package/dist/reconciler/wrapper-node.js +0 -4
- package/dist/reconciler/wrapper-node.js.map +0 -1
- package/dist/reconciler/wrapper-protocol.d.ts +0 -13
- package/dist/reconciler/wrapper-protocol.d.ts.map +0 -1
- package/dist/reconciler/wrapper-protocol.js +0 -20
- package/dist/reconciler/wrapper-protocol.js.map +0 -1
- package/dist/utils/create-element-component.d.ts +0 -4
- package/dist/utils/create-element-component.d.ts.map +0 -1
- package/dist/utils/create-element-component.js +0 -54
- package/dist/utils/create-element-component.js.map +0 -1
- package/dist/utils/gtype.d.ts +0 -16
- package/dist/utils/gtype.d.ts.map +0 -1
- package/dist/utils/gtype.js +0 -127
- package/dist/utils/gtype.js.map +0 -1
- package/dist/utils/notify-name.d.ts +0 -5
- package/dist/utils/notify-name.d.ts.map +0 -1
- package/dist/utils/notify-name.js +0 -6
- package/dist/utils/notify-name.js.map +0 -1
- package/dist/utils/object-prop.d.ts +0 -8
- package/dist/utils/object-prop.d.ts.map +0 -1
- package/dist/utils/object-prop.js +0 -9
- package/dist/utils/object-prop.js.map +0 -1
- package/dist/utils/settings-accessor.d.ts +0 -8
- package/dist/utils/settings-accessor.d.ts.map +0 -1
- package/dist/utils/settings-accessor.js +0 -69
- package/dist/utils/settings-accessor.js.map +0 -1
- package/dist/utils/wrapper-node-jsx.d.ts +0 -32
- package/dist/utils/wrapper-node-jsx.d.ts.map +0 -1
- package/dist/utils/wrapper-node-jsx.js +0 -2
- package/dist/utils/wrapper-node-jsx.js.map +0 -1
- package/src/hooks/use-merge-refs.ts +0 -53
- package/src/hooks/use-object-attachment.ts +0 -35
- package/src/libraries/adw/dialog.tsx +0 -34
- package/src/libraries/adw/index.ts +0 -1
- package/src/reconciler/accessible.ts +0 -232
- package/src/reconciler/commit-flush.ts +0 -13
- package/src/reconciler/container-attach.ts +0 -219
- package/src/reconciler/content-rebuild.ts +0 -19
- package/src/reconciler/dispatch.ts +0 -58
- package/src/reconciler/element-prop-appliers.ts +0 -110
- package/src/reconciler/element-props.ts +0 -192
- package/src/reconciler/label-text-rebuild.ts +0 -26
- package/src/reconciler/portal.ts +0 -28
- package/src/reconciler/reconciler-error-handler.ts +0 -29
- package/src/reconciler/reconciler-root.ts +0 -57
- package/src/reconciler/reconciler.ts +0 -13
- package/src/reconciler/render.ts +0 -61
- package/src/reconciler/signal-store.ts +0 -103
- package/src/reconciler/state.ts +0 -72
- package/src/reconciler/text-buffer-controller.ts +0 -107
- package/src/reconciler/text-buffer-rebuild.ts +0 -12
- package/src/reconciler/text-node.ts +0 -13
- package/src/reconciler/types.ts +0 -6
- package/src/reconciler/visibility.ts +0 -52
- package/src/reconciler/wrapper-apply.ts +0 -308
- package/src/reconciler/wrapper-content.ts +0 -24
- package/src/reconciler/wrapper-node.ts +0 -8
- package/src/reconciler/wrapper-protocol.ts +0 -32
- package/src/utils/create-element-component.ts +0 -77
- package/src/utils/gtype.ts +0 -166
- package/src/utils/notify-name.ts +0 -10
- package/src/utils/object-prop.ts +0 -13
- package/src/utils/settings-accessor.ts +0 -89
- package/src/utils/wrapper-node-jsx.ts +0 -34
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import * as GObject from "@gtkx/gi/gobject";
|
|
2
|
-
import * as Gtk from "@gtkx/gi/gtk";
|
|
3
|
-
import { deleteAccessibleMetadata, setAccessibleMetadata } from "../utils/accessible-metadata.js";
|
|
4
|
-
import type { Props } from "./types.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Accessibility props available on every widget. Each member maps to a GTK4 accessible attribute
|
|
8
|
-
* (a `Gtk.AccessibleProperty`, `Gtk.AccessibleState`, or `Gtk.AccessibleRelation`) and is applied
|
|
9
|
-
* to the widget's accessible interface; setting a member to `undefined` resets that attribute to its default.
|
|
10
|
-
*/
|
|
11
|
-
export interface AccessibleProps {
|
|
12
|
-
accessibleAutocomplete?: Gtk.AccessibleAutocomplete | null | undefined;
|
|
13
|
-
accessibleDescription?: string | null | undefined;
|
|
14
|
-
accessibleHasPopup?: boolean | null | undefined;
|
|
15
|
-
accessibleKeyShortcuts?: string | null | undefined;
|
|
16
|
-
accessibleLabel?: string | null | undefined;
|
|
17
|
-
accessibleLevel?: number | null | undefined;
|
|
18
|
-
accessibleModal?: boolean | null | undefined;
|
|
19
|
-
accessibleMultiLine?: boolean | null | undefined;
|
|
20
|
-
accessibleMultiSelectable?: boolean | null | undefined;
|
|
21
|
-
accessibleOrientation?: Gtk.Orientation | null | undefined;
|
|
22
|
-
accessiblePlaceholder?: string | null | undefined;
|
|
23
|
-
accessibleReadOnly?: boolean | null | undefined;
|
|
24
|
-
accessibleRequired?: boolean | null | undefined;
|
|
25
|
-
accessibleRoleDescription?: string | null | undefined;
|
|
26
|
-
accessibleSort?: Gtk.AccessibleSort | null | undefined;
|
|
27
|
-
accessibleValueMax?: number | null | undefined;
|
|
28
|
-
accessibleValueMin?: number | null | undefined;
|
|
29
|
-
accessibleValueNow?: number | null | undefined;
|
|
30
|
-
accessibleValueText?: string | null | undefined;
|
|
31
|
-
accessibleHelpText?: string | null | undefined;
|
|
32
|
-
accessibleBusy?: boolean | null | undefined;
|
|
33
|
-
accessibleChecked?: Gtk.AccessibleTristate | null | undefined;
|
|
34
|
-
accessibleDisabled?: boolean | null | undefined;
|
|
35
|
-
accessibleExpanded?: boolean | null | undefined;
|
|
36
|
-
accessibleHidden?: boolean | null | undefined;
|
|
37
|
-
accessibleInvalid?: Gtk.AccessibleInvalidState | null | undefined;
|
|
38
|
-
accessiblePressed?: Gtk.AccessibleTristate | null | undefined;
|
|
39
|
-
accessibleSelected?: boolean | null | undefined;
|
|
40
|
-
accessibleVisited?: boolean | null | undefined;
|
|
41
|
-
accessibleActiveDescendant?: Gtk.Widget | null | undefined;
|
|
42
|
-
accessibleColCount?: number | null | undefined;
|
|
43
|
-
accessibleColIndex?: number | null | undefined;
|
|
44
|
-
accessibleColIndexText?: string | null | undefined;
|
|
45
|
-
accessibleColSpan?: number | null | undefined;
|
|
46
|
-
accessibleControls?: Gtk.Widget[] | null | undefined;
|
|
47
|
-
accessibleDescribedBy?: Gtk.Widget[] | null | undefined;
|
|
48
|
-
accessibleDetails?: Gtk.Widget[] | null | undefined;
|
|
49
|
-
accessibleErrorMessage?: Gtk.Widget[] | null | undefined;
|
|
50
|
-
accessibleFlowTo?: Gtk.Widget[] | null | undefined;
|
|
51
|
-
accessibleLabelledBy?: Gtk.Widget[] | null | undefined;
|
|
52
|
-
accessibleOwns?: Gtk.Widget[] | null | undefined;
|
|
53
|
-
accessiblePosInSet?: number | null | undefined;
|
|
54
|
-
accessibleRowCount?: number | null | undefined;
|
|
55
|
-
accessibleRowIndex?: number | null | undefined;
|
|
56
|
-
accessibleRowIndexText?: string | null | undefined;
|
|
57
|
-
accessibleRowSpan?: number | null | undefined;
|
|
58
|
-
accessibleSetSize?: number | null | undefined;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
type CreateValue = (jsValue: unknown) => GObject.Value;
|
|
62
|
-
|
|
63
|
-
type AccessiblePropertyDescriptor = {
|
|
64
|
-
kind: "property";
|
|
65
|
-
enumValue: Gtk.AccessibleProperty;
|
|
66
|
-
createValue: CreateValue;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
type AccessibleStateDescriptor = {
|
|
70
|
-
kind: "state";
|
|
71
|
-
enumValue: Gtk.AccessibleState;
|
|
72
|
-
createValue: CreateValue;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
type AccessibleRelationDescriptor = {
|
|
76
|
-
kind: "relation";
|
|
77
|
-
enumValue: Gtk.AccessibleRelation;
|
|
78
|
-
createValue: CreateValue;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
type AccessibleDescriptor = AccessiblePropertyDescriptor | AccessibleStateDescriptor | AccessibleRelationDescriptor;
|
|
82
|
-
|
|
83
|
-
const fromString: CreateValue = (val) => GObject.buildValue(GObject.TYPE_STRING, (v) => v.setString(val as string));
|
|
84
|
-
const fromBoolean: CreateValue = (val) => GObject.buildValue(GObject.TYPE_BOOLEAN, (v) => v.setBoolean(val as boolean));
|
|
85
|
-
const fromInt: CreateValue = (val) => GObject.buildValue(GObject.TYPE_INT, (v) => v.setInt(val as number));
|
|
86
|
-
const fromDouble: CreateValue = (val) => GObject.buildValue(GObject.TYPE_DOUBLE, (v) => v.setDouble(val as number));
|
|
87
|
-
const fromObject: CreateValue = (val) =>
|
|
88
|
-
GObject.buildValue(GObject.TYPE_OBJECT, (v) => v.setObject(val as GObject.Object));
|
|
89
|
-
|
|
90
|
-
const fromRefList: CreateValue = (val) => {
|
|
91
|
-
const widgets = val as Gtk.Accessible[];
|
|
92
|
-
const list = Gtk.AccessibleList.newFromList(widgets);
|
|
93
|
-
return GObject.buildValue(Gtk.AccessibleList.prototype.__type__, (v) => v.setBoxed(list));
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const property = (enumValue: Gtk.AccessibleProperty, createValue: CreateValue): AccessiblePropertyDescriptor => ({
|
|
97
|
-
kind: "property",
|
|
98
|
-
enumValue,
|
|
99
|
-
createValue,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
const state = (enumValue: Gtk.AccessibleState, createValue: CreateValue): AccessibleStateDescriptor => ({
|
|
103
|
-
kind: "state",
|
|
104
|
-
enumValue,
|
|
105
|
-
createValue,
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const relation = (enumValue: Gtk.AccessibleRelation, createValue: CreateValue): AccessibleRelationDescriptor => ({
|
|
109
|
-
kind: "relation",
|
|
110
|
-
enumValue,
|
|
111
|
-
createValue,
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const ACCESSIBLE_PROP_MAP: Record<keyof AccessibleProps, AccessibleDescriptor> = {
|
|
115
|
-
accessibleAutocomplete: property(Gtk.AccessibleProperty.AUTOCOMPLETE, fromInt),
|
|
116
|
-
accessibleDescription: property(Gtk.AccessibleProperty.DESCRIPTION, fromString),
|
|
117
|
-
accessibleHasPopup: property(Gtk.AccessibleProperty.HAS_POPUP, fromBoolean),
|
|
118
|
-
accessibleKeyShortcuts: property(Gtk.AccessibleProperty.KEY_SHORTCUTS, fromString),
|
|
119
|
-
accessibleLabel: property(Gtk.AccessibleProperty.LABEL, fromString),
|
|
120
|
-
accessibleLevel: property(Gtk.AccessibleProperty.LEVEL, fromInt),
|
|
121
|
-
accessibleModal: property(Gtk.AccessibleProperty.MODAL, fromBoolean),
|
|
122
|
-
accessibleMultiLine: property(Gtk.AccessibleProperty.MULTI_LINE, fromBoolean),
|
|
123
|
-
accessibleMultiSelectable: property(Gtk.AccessibleProperty.MULTI_SELECTABLE, fromBoolean),
|
|
124
|
-
accessibleOrientation: property(Gtk.AccessibleProperty.ORIENTATION, fromInt),
|
|
125
|
-
accessiblePlaceholder: property(Gtk.AccessibleProperty.PLACEHOLDER, fromString),
|
|
126
|
-
accessibleReadOnly: property(Gtk.AccessibleProperty.READ_ONLY, fromBoolean),
|
|
127
|
-
accessibleRequired: property(Gtk.AccessibleProperty.REQUIRED, fromBoolean),
|
|
128
|
-
accessibleRoleDescription: property(Gtk.AccessibleProperty.ROLE_DESCRIPTION, fromString),
|
|
129
|
-
accessibleSort: property(Gtk.AccessibleProperty.SORT, fromInt),
|
|
130
|
-
accessibleValueMax: property(Gtk.AccessibleProperty.VALUE_MAX, fromDouble),
|
|
131
|
-
accessibleValueMin: property(Gtk.AccessibleProperty.VALUE_MIN, fromDouble),
|
|
132
|
-
accessibleValueNow: property(Gtk.AccessibleProperty.VALUE_NOW, fromDouble),
|
|
133
|
-
accessibleValueText: property(Gtk.AccessibleProperty.VALUE_TEXT, fromString),
|
|
134
|
-
accessibleHelpText: property(Gtk.AccessibleProperty.HELP_TEXT, fromString),
|
|
135
|
-
accessibleBusy: state(Gtk.AccessibleState.BUSY, fromBoolean),
|
|
136
|
-
accessibleChecked: state(Gtk.AccessibleState.CHECKED, fromInt),
|
|
137
|
-
accessibleDisabled: state(Gtk.AccessibleState.DISABLED, fromBoolean),
|
|
138
|
-
accessibleExpanded: state(Gtk.AccessibleState.EXPANDED, fromInt),
|
|
139
|
-
accessibleHidden: state(Gtk.AccessibleState.HIDDEN, fromBoolean),
|
|
140
|
-
accessibleInvalid: state(Gtk.AccessibleState.INVALID, fromInt),
|
|
141
|
-
accessiblePressed: state(Gtk.AccessibleState.PRESSED, fromInt),
|
|
142
|
-
accessibleSelected: state(Gtk.AccessibleState.SELECTED, fromInt),
|
|
143
|
-
accessibleVisited: state(Gtk.AccessibleState.VISITED, fromInt),
|
|
144
|
-
accessibleActiveDescendant: relation(Gtk.AccessibleRelation.ACTIVE_DESCENDANT, fromObject),
|
|
145
|
-
accessibleColCount: relation(Gtk.AccessibleRelation.COL_COUNT, fromInt),
|
|
146
|
-
accessibleColIndex: relation(Gtk.AccessibleRelation.COL_INDEX, fromInt),
|
|
147
|
-
accessibleColIndexText: relation(Gtk.AccessibleRelation.COL_INDEX_TEXT, fromString),
|
|
148
|
-
accessibleColSpan: relation(Gtk.AccessibleRelation.COL_SPAN, fromInt),
|
|
149
|
-
accessibleControls: relation(Gtk.AccessibleRelation.CONTROLS, fromRefList),
|
|
150
|
-
accessibleDescribedBy: relation(Gtk.AccessibleRelation.DESCRIBED_BY, fromRefList),
|
|
151
|
-
accessibleDetails: relation(Gtk.AccessibleRelation.DETAILS, fromRefList),
|
|
152
|
-
accessibleErrorMessage: relation(Gtk.AccessibleRelation.ERROR_MESSAGE, fromRefList),
|
|
153
|
-
accessibleFlowTo: relation(Gtk.AccessibleRelation.FLOW_TO, fromRefList),
|
|
154
|
-
accessibleLabelledBy: relation(Gtk.AccessibleRelation.LABELLED_BY, fromRefList),
|
|
155
|
-
accessibleOwns: relation(Gtk.AccessibleRelation.OWNS, fromRefList),
|
|
156
|
-
accessiblePosInSet: relation(Gtk.AccessibleRelation.POS_IN_SET, fromInt),
|
|
157
|
-
accessibleRowCount: relation(Gtk.AccessibleRelation.ROW_COUNT, fromInt),
|
|
158
|
-
accessibleRowIndex: relation(Gtk.AccessibleRelation.ROW_INDEX, fromInt),
|
|
159
|
-
accessibleRowIndexText: relation(Gtk.AccessibleRelation.ROW_INDEX_TEXT, fromString),
|
|
160
|
-
accessibleRowSpan: relation(Gtk.AccessibleRelation.ROW_SPAN, fromInt),
|
|
161
|
-
accessibleSetSize: relation(Gtk.AccessibleRelation.SET_SIZE, fromInt),
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const lookupDescriptor = (name: string): AccessibleDescriptor | undefined =>
|
|
165
|
-
Object.hasOwn(ACCESSIBLE_PROP_MAP, name) ? ACCESSIBLE_PROP_MAP[name as keyof AccessibleProps] : undefined;
|
|
166
|
-
|
|
167
|
-
export const isAccessibleProp = (name: string): boolean => Object.hasOwn(ACCESSIBLE_PROP_MAP, name);
|
|
168
|
-
|
|
169
|
-
function applyDescriptor(widget: Gtk.Accessible, descriptor: AccessibleDescriptor, newValue: unknown): void {
|
|
170
|
-
const gvalue = descriptor.createValue(newValue);
|
|
171
|
-
|
|
172
|
-
switch (descriptor.kind) {
|
|
173
|
-
case "property":
|
|
174
|
-
widget.updateProperty([descriptor.enumValue], [gvalue]);
|
|
175
|
-
break;
|
|
176
|
-
case "state":
|
|
177
|
-
widget.updateState([descriptor.enumValue], [gvalue]);
|
|
178
|
-
break;
|
|
179
|
-
case "relation":
|
|
180
|
-
widget.updateRelation([descriptor.enumValue], [gvalue]);
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function resetDescriptor(widget: Gtk.Accessible, descriptor: AccessibleDescriptor): void {
|
|
186
|
-
switch (descriptor.kind) {
|
|
187
|
-
case "property":
|
|
188
|
-
widget.resetProperty(descriptor.enumValue);
|
|
189
|
-
break;
|
|
190
|
-
case "state":
|
|
191
|
-
widget.resetState(descriptor.enumValue);
|
|
192
|
-
break;
|
|
193
|
-
case "relation":
|
|
194
|
-
widget.resetRelation(descriptor.enumValue);
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const applyChangedAccessibleProps = (widget: Gtk.Accessible, oldProps: Props | null, newProps: Props): void => {
|
|
200
|
-
for (const name in newProps) {
|
|
201
|
-
const descriptor = lookupDescriptor(name);
|
|
202
|
-
if (!descriptor) continue;
|
|
203
|
-
|
|
204
|
-
const newValue = newProps[name];
|
|
205
|
-
if (oldProps?.[name] === newValue) continue;
|
|
206
|
-
|
|
207
|
-
if (newValue === undefined) {
|
|
208
|
-
resetDescriptor(widget, descriptor);
|
|
209
|
-
deleteAccessibleMetadata(widget, name);
|
|
210
|
-
} else {
|
|
211
|
-
applyDescriptor(widget, descriptor, newValue);
|
|
212
|
-
setAccessibleMetadata(widget, name, newValue);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
const resetRemovedAccessibleProps = (widget: Gtk.Accessible, oldProps: Props, newProps: Props): void => {
|
|
218
|
-
for (const name in oldProps) {
|
|
219
|
-
if (Object.hasOwn(newProps, name)) continue;
|
|
220
|
-
const descriptor = lookupDescriptor(name);
|
|
221
|
-
if (!descriptor) continue;
|
|
222
|
-
if (oldProps[name] !== undefined) {
|
|
223
|
-
resetDescriptor(widget, descriptor);
|
|
224
|
-
deleteAccessibleMetadata(widget, name);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
export const applyAccessibleProps = (widget: Gtk.Accessible, oldProps: Props | null, newProps: Props): void => {
|
|
230
|
-
applyChangedAccessibleProps(widget, oldProps, newProps);
|
|
231
|
-
if (oldProps) resetRemovedAccessibleProps(widget, oldProps, newProps);
|
|
232
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const pending = new Set<() => void>();
|
|
2
|
-
|
|
3
|
-
export const scheduleFlush = (fn: () => void): void => {
|
|
4
|
-
pending.add(fn);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const runCommitFlush = (): void => {
|
|
8
|
-
while (pending.size > 0) {
|
|
9
|
-
const batch = [...pending];
|
|
10
|
-
pending.clear();
|
|
11
|
-
for (const fn of batch) fn();
|
|
12
|
-
}
|
|
13
|
-
};
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import type { ContainerProp } from "@gtkx/config";
|
|
2
|
-
import * as GObject from "@gtkx/gi/gobject";
|
|
3
|
-
import * as Gtk from "@gtkx/gi/gtk";
|
|
4
|
-
import { typeChainIncludes } from "../utils/gtype.js";
|
|
5
|
-
import { callUsesRef, nullSetterCurrentHolder, resolveContainerProp, runCall } from "./element-props.js";
|
|
6
|
-
import { type ElementMapping, registeredStateOf, stateOf } from "./state.js";
|
|
7
|
-
import { childWidget } from "./wrapper-content.js";
|
|
8
|
-
|
|
9
|
-
const containerPropFor = (container: GObject.Object, child: Gtk.Widget): ContainerProp | null =>
|
|
10
|
-
resolveContainerProp(container.__type__, child.__type__, undefined);
|
|
11
|
-
|
|
12
|
-
const scopeFor = (child: Gtk.Widget) => ({ child, props: registeredStateOf(child)?.props ?? {} });
|
|
13
|
-
|
|
14
|
-
export function attachChild(child: Gtk.Widget, container: GObject.Object): void {
|
|
15
|
-
const cp = containerPropFor(container, child);
|
|
16
|
-
if (cp?.append !== undefined) {
|
|
17
|
-
runCall(container, cp.append, [child], scopeFor(child));
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (container instanceof Gtk.Widget) child.setParent(container);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function detachChild(child: Gtk.Widget, container: GObject.Object): void {
|
|
24
|
-
const cp = containerPropFor(container, child);
|
|
25
|
-
if (cp?.remove !== undefined) {
|
|
26
|
-
const holder = nullSetterCurrentHolder(container, cp.remove);
|
|
27
|
-
if (holder !== undefined) {
|
|
28
|
-
if (holder === child) runCall(container, cp.remove, [child], scopeFor(child));
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
if (container instanceof Gtk.Widget && !isDescendantOf(child, container)) return;
|
|
32
|
-
runCall(container, cp.remove, [child], scopeFor(child));
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if (container instanceof Gtk.Widget && isDescendantOf(child, container)) child.unparent();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function unparentWidget(widget: Gtk.Widget): void {
|
|
39
|
-
const currentParent = widget.getParent();
|
|
40
|
-
if (currentParent === null) return;
|
|
41
|
-
detachChild(widget, currentParent);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function getFocusWidget(widget: Gtk.Widget): Gtk.Widget | null {
|
|
45
|
-
const root = widget.getRoot();
|
|
46
|
-
return root?.getFocus() ?? null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function isDescendantOf(widget: Gtk.Widget, ancestor: Gtk.Widget): boolean {
|
|
50
|
-
let current: Gtk.Widget | null = widget;
|
|
51
|
-
while (current) {
|
|
52
|
-
if (current === ancestor) return true;
|
|
53
|
-
current = current.getParent();
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const isAutowrapChild = (cp: ContainerProp | null, widget: Gtk.Widget): boolean =>
|
|
59
|
-
cp?.autowrap !== undefined && !typeChainIncludes(widget.__type__, cp.autowrap);
|
|
60
|
-
|
|
61
|
-
const detachAutowrapped = (widget: Gtk.Widget): void => {
|
|
62
|
-
const wrapper = widget.getParent();
|
|
63
|
-
if (wrapper === null) return;
|
|
64
|
-
detachChild(widget, wrapper);
|
|
65
|
-
const wrapperParent = wrapper.getParent();
|
|
66
|
-
if (wrapperParent !== null) detachChild(wrapper, wrapperParent);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
function* childWidgetsOf(container: Gtk.Widget): IterableIterator<Gtk.Widget> {
|
|
70
|
-
let child = container.getFirstChild();
|
|
71
|
-
while (child) {
|
|
72
|
-
yield child;
|
|
73
|
-
child = child.getNextSibling();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const unwrapChildWidget = (child: Gtk.Widget): Gtk.Widget | null => {
|
|
78
|
-
if ("getChild" in child && typeof child.getChild === "function") {
|
|
79
|
-
const inner: unknown = child.getChild();
|
|
80
|
-
return inner instanceof Gtk.Widget ? inner : null;
|
|
81
|
-
}
|
|
82
|
-
return child;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const findWrappedPosition = (container: Gtk.Widget, anchor: Gtk.Widget, wrapper: string): number | null => {
|
|
86
|
-
const anchorIsWrapper = typeChainIncludes(anchor.__type__, wrapper);
|
|
87
|
-
let position = 0;
|
|
88
|
-
for (const current of childWidgetsOf(container)) {
|
|
89
|
-
const compare = anchorIsWrapper ? current : unwrapChildWidget(current);
|
|
90
|
-
if (compare && compare === anchor) return position;
|
|
91
|
-
position++;
|
|
92
|
-
}
|
|
93
|
-
return null;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const findInsertPosition = (container: Gtk.Widget, anchor: Gtk.Widget): number => {
|
|
97
|
-
let position = 0;
|
|
98
|
-
for (const current of childWidgetsOf(container)) {
|
|
99
|
-
if (current === anchor) return position;
|
|
100
|
-
position++;
|
|
101
|
-
}
|
|
102
|
-
return position;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const reorderPosition = (container: Gtk.Widget, anchor: Gtk.Widget, moving: Gtk.Widget): number => {
|
|
106
|
-
let position = 0;
|
|
107
|
-
for (const current of childWidgetsOf(container)) {
|
|
108
|
-
if (current === moving) continue;
|
|
109
|
-
if (current === anchor) return position;
|
|
110
|
-
position++;
|
|
111
|
-
}
|
|
112
|
-
return position;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const findPrevSibling = (container: Gtk.Widget, anchor: Gtk.Widget): Gtk.Widget | undefined => {
|
|
116
|
-
for (const child of childWidgetsOf(container)) {
|
|
117
|
-
if (child === anchor) return child.getPrevSibling() ?? undefined;
|
|
118
|
-
}
|
|
119
|
-
return undefined;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const insertAtIndex = (
|
|
123
|
-
container: Gtk.Widget,
|
|
124
|
-
widget: Gtk.Widget,
|
|
125
|
-
anchor: Gtk.Widget,
|
|
126
|
-
cp: ContainerProp & { insert: NonNullable<ContainerProp["insert"]> },
|
|
127
|
-
): void => {
|
|
128
|
-
if (cp.autowrap !== undefined) {
|
|
129
|
-
if (widget.getParent() !== null) {
|
|
130
|
-
if (isAutowrapChild(cp, widget)) detachAutowrapped(widget);
|
|
131
|
-
else unparentWidget(widget);
|
|
132
|
-
}
|
|
133
|
-
const position = findWrappedPosition(container, anchor, cp.autowrap);
|
|
134
|
-
if (position === null) attachChild(widget, container);
|
|
135
|
-
else runCall(container, cp.insert, [widget, position], { child: widget, index: position });
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
if (widget.getParent() === container && cp.reorder !== undefined) {
|
|
139
|
-
const position = reorderPosition(container, anchor, widget);
|
|
140
|
-
runCall(container, cp.reorder, [widget, position], { child: widget, index: position });
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
unparentWidget(widget);
|
|
144
|
-
const position = findInsertPosition(container, anchor);
|
|
145
|
-
runCall(container, cp.insert, [widget, position], { child: widget, index: position });
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const insertBySibling = (container: Gtk.Widget, widget: Gtk.Widget, anchor: Gtk.Widget, cp: ContainerProp): void => {
|
|
149
|
-
const previous = findPrevSibling(container, anchor);
|
|
150
|
-
const scope = { child: widget, sibling: previous ?? null };
|
|
151
|
-
if (widget.getParent() === container && cp.reorder !== undefined) {
|
|
152
|
-
runCall(container, cp.reorder, [widget, previous], scope);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
unparentWidget(widget);
|
|
156
|
-
if (cp.insert !== undefined) runCall(container, cp.insert, [widget, previous], scope);
|
|
157
|
-
else attachChild(widget, container);
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const reinsertAll = (container: GObject.Object): void => {
|
|
161
|
-
const widgets: Gtk.Widget[] = [];
|
|
162
|
-
for (const child of stateOf(container).children) {
|
|
163
|
-
const widget = childWidget(child);
|
|
164
|
-
if (widget) widgets.push(widget);
|
|
165
|
-
}
|
|
166
|
-
for (const widget of widgets) detachChild(widget, container);
|
|
167
|
-
for (const widget of widgets) attachChild(widget, container);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const insertWidgetBefore = (container: GObject.Object, widget: Gtk.Widget, anchor: Gtk.Widget): void => {
|
|
171
|
-
const cp = containerPropFor(container, widget);
|
|
172
|
-
if (cp?.insert !== undefined && callUsesRef(cp.insert, "index") && container instanceof Gtk.Widget) {
|
|
173
|
-
insertAtIndex(container, widget, anchor, { ...cp, insert: cp.insert });
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
if (
|
|
177
|
-
container instanceof Gtk.Widget &&
|
|
178
|
-
(cp?.reorder !== undefined || (cp?.insert !== undefined && callUsesRef(cp.insert, "sibling")))
|
|
179
|
-
) {
|
|
180
|
-
insertBySibling(container, widget, anchor, cp);
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
reinsertAll(container);
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
const appendWidget = (container: GObject.Object, widget: Gtk.Widget, fresh: boolean): void => {
|
|
187
|
-
if (!fresh && widget.getParent() !== null) {
|
|
188
|
-
const cp = containerPropFor(container, widget);
|
|
189
|
-
if (isAutowrapChild(cp, widget)) detachAutowrapped(widget);
|
|
190
|
-
else unparentWidget(widget);
|
|
191
|
-
}
|
|
192
|
-
attachChild(widget, container);
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
const removeWidget = (container: GObject.Object, widget: Gtk.Widget): void => {
|
|
196
|
-
const cp = containerPropFor(container, widget);
|
|
197
|
-
if (!isAutowrapChild(cp, widget)) {
|
|
198
|
-
detachChild(widget, container);
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
const wrapper = widget.getParent();
|
|
202
|
-
if (wrapper !== null && wrapper !== container) {
|
|
203
|
-
detachChild(widget, wrapper);
|
|
204
|
-
detachChild(wrapper, container);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export const containerMapping: ElementMapping = (child, parent) => {
|
|
209
|
-
const widget = childWidget(child);
|
|
210
|
-
if (widget === null || !(parent instanceof GObject.Object)) return null;
|
|
211
|
-
if (!(parent instanceof Gtk.Widget) && containerPropFor(parent, widget) === null) return null;
|
|
212
|
-
return {
|
|
213
|
-
attach: (anchor, fresh) => {
|
|
214
|
-
if (anchor instanceof Gtk.Widget) insertWidgetBefore(parent, widget, anchor);
|
|
215
|
-
else appendWidget(parent, widget, fresh === true);
|
|
216
|
-
},
|
|
217
|
-
detach: () => removeWidget(parent, widget),
|
|
218
|
-
};
|
|
219
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { scheduleFlush } from "./commit-flush.js";
|
|
2
|
-
import { closestInstance, type Node } from "./state.js";
|
|
3
|
-
|
|
4
|
-
const rebuildsByContentOwner = new WeakMap<Node, () => void>();
|
|
5
|
-
|
|
6
|
-
export const scheduleContentRebuild = <T extends Node>(
|
|
7
|
-
node: Node,
|
|
8
|
-
isContentOwner: (candidate: Node) => candidate is T,
|
|
9
|
-
createRebuild: (owner: T) => () => void,
|
|
10
|
-
): void => {
|
|
11
|
-
const owner = closestInstance(node, isContentOwner);
|
|
12
|
-
if (!owner) return;
|
|
13
|
-
let rebuild = rebuildsByContentOwner.get(owner);
|
|
14
|
-
if (!rebuild) {
|
|
15
|
-
rebuild = createRebuild(owner);
|
|
16
|
-
rebuildsByContentOwner.set(owner, rebuild);
|
|
17
|
-
}
|
|
18
|
-
scheduleFlush(rebuild);
|
|
19
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import * as GObject from "@gtkx/gi/gobject";
|
|
2
|
-
import { containerMapping } from "./container-attach.js";
|
|
3
|
-
import { type ElementHandler, type ElementMapping, type Node, stateOf } from "./state.js";
|
|
4
|
-
import { containerChildMapping, containerPropMapping, lazyElementMapping, objectPropMapping } from "./wrapper-apply.js";
|
|
5
|
-
import { isWrapperNode } from "./wrapper-node.js";
|
|
6
|
-
|
|
7
|
-
const ELEMENT_MAP: ElementMapping[] = [
|
|
8
|
-
objectPropMapping,
|
|
9
|
-
containerPropMapping,
|
|
10
|
-
lazyElementMapping,
|
|
11
|
-
containerChildMapping,
|
|
12
|
-
containerMapping,
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
const resolveHandler = (child: Node, parent: Node): ElementHandler | null => {
|
|
16
|
-
for (const mapping of ELEMENT_MAP) {
|
|
17
|
-
const handler = mapping(child, parent);
|
|
18
|
-
if (handler !== null) return handler;
|
|
19
|
-
}
|
|
20
|
-
return null;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const attachToParent = (child: Node, parent: Node, anchor?: GObject.Object | null, fresh?: boolean): void => {
|
|
24
|
-
resolveHandler(child, parent)?.attach(anchor, fresh);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const detachFromParent = (child: Node, parent: Node): void => {
|
|
28
|
-
resolveHandler(child, parent)?.detach();
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const resyncWrapperNode = (node: Node): void => {
|
|
32
|
-
const parent = stateOf(node).parent;
|
|
33
|
-
if (isWrapperNode(node) && parent) attachToParent(node, parent);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const anchorWrapper = (before: Node): GObject.Object | null => {
|
|
37
|
-
if (before instanceof GObject.Object) return before;
|
|
38
|
-
for (const grandchild of stateOf(before).children) {
|
|
39
|
-
if (grandchild instanceof GObject.Object) return grandchild;
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const attachNode = (parent: Node, child: Node, before: Node | null, fresh: boolean): void => {
|
|
45
|
-
if (before === null) {
|
|
46
|
-
if (isWrapperNode(child) || !isWrapperNode(parent)) attachToParent(child, parent, null, fresh);
|
|
47
|
-
} else if (isWrapperNode(child)) {
|
|
48
|
-
attachToParent(child, parent);
|
|
49
|
-
} else if (!isWrapperNode(parent)) {
|
|
50
|
-
attachToParent(child, parent, anchorWrapper(before));
|
|
51
|
-
}
|
|
52
|
-
if (isWrapperNode(parent)) resyncWrapperNode(parent);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const detachNode = (parent: Node, child: Node): void => {
|
|
56
|
-
if (isWrapperNode(child) || !isWrapperNode(parent)) detachFromParent(child, parent);
|
|
57
|
-
if (isWrapperNode(parent)) resyncWrapperNode(parent);
|
|
58
|
-
};
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import type { AppliedProp, Call, ControlledTextProp, LazyProp, ListProp, ValueProp } from "@gtkx/config";
|
|
2
|
-
import type { TypedClass } from "@gtkx/runtime";
|
|
3
|
-
import { callMethod, isShallowEqual } from "@gtkx/utils";
|
|
4
|
-
import { appliedPropsFor, runCall } from "./element-props.js";
|
|
5
|
-
import type { Props } from "./types.js";
|
|
6
|
-
|
|
7
|
-
const asArray = (value: unknown): unknown[] => (Array.isArray(value) ? value : []);
|
|
8
|
-
|
|
9
|
-
const isRecord = (value: unknown): value is Record<string, unknown> => typeof value === "object" && value !== null;
|
|
10
|
-
|
|
11
|
-
const itemsEqual = (a: unknown, b: unknown): boolean => {
|
|
12
|
-
if (a === b) return true;
|
|
13
|
-
return isRecord(a) && isRecord(b) && isShallowEqual(a, b);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const listValuesEqual = (oldValue: unknown, newValue: unknown): boolean => {
|
|
17
|
-
if (oldValue === newValue) return true;
|
|
18
|
-
const a = asArray(oldValue);
|
|
19
|
-
const b = asArray(newValue);
|
|
20
|
-
return a.length === b.length && a.every((item, index) => itemsEqual(item, b[index]));
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const runAdd = (instance: object, add: Call | Call[], item: unknown): void => {
|
|
24
|
-
if (Array.isArray(add)) {
|
|
25
|
-
for (const call of add) runCall(instance, call, [item], { item });
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
runCall(instance, add, [item], { item });
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const snapshotItems = (items: unknown[]): unknown[] => items.map((item) => (isRecord(item) ? { ...item } : item));
|
|
32
|
-
|
|
33
|
-
const appliedLists = new WeakMap<object, Map<string, unknown[]>>();
|
|
34
|
-
|
|
35
|
-
const rememberAppliedList = (instance: object, prop: string, items: unknown[]): void => {
|
|
36
|
-
const byProp = appliedLists.get(instance) ?? new Map<string, unknown[]>();
|
|
37
|
-
byProp.set(prop, snapshotItems(items));
|
|
38
|
-
appliedLists.set(instance, byProp);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const applyList = (instance: object, prop: ListProp, newValue: unknown): void => {
|
|
42
|
-
const applied = appliedLists.get(instance)?.get(prop.prop);
|
|
43
|
-
const newItems = asArray(newValue);
|
|
44
|
-
if (applied !== undefined && listValuesEqual(applied, newItems)) return;
|
|
45
|
-
if (prop.clear !== undefined) {
|
|
46
|
-
runCall(instance, prop.clear, [], {});
|
|
47
|
-
} else if (prop.remove !== undefined) {
|
|
48
|
-
for (const item of asArray(applied)) runCall(instance, prop.remove, [item], { item });
|
|
49
|
-
} else if (asArray(applied).length !== 0) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
for (const item of newItems) runAdd(instance, prop.add, item);
|
|
53
|
-
rememberAppliedList(instance, prop.prop, newItems);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const applyValue = (instance: object, prop: ValueProp, oldValue: unknown, newValue: unknown): void => {
|
|
57
|
-
if (oldValue === newValue) return;
|
|
58
|
-
runCall(instance, prop.call, [newValue], { item: newValue });
|
|
59
|
-
if (prop.after !== undefined) callMethod(instance, prop.after, []);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const applyControlledText = (
|
|
63
|
-
instance: object,
|
|
64
|
-
prop: ControlledTextProp,
|
|
65
|
-
oldValue: unknown,
|
|
66
|
-
newValue: unknown,
|
|
67
|
-
): void => {
|
|
68
|
-
if (oldValue === newValue || typeof newValue !== "string") return;
|
|
69
|
-
if (oldValue !== undefined && Reflect.get(instance, prop.prop) !== oldValue) return;
|
|
70
|
-
Reflect.set(instance, prop.prop, newValue);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const applyLazy = (instance: object, prop: LazyProp, props: Props): void => {
|
|
74
|
-
const value = props[prop.prop];
|
|
75
|
-
if (value == null || value === "") return;
|
|
76
|
-
if (Reflect.get(instance, prop.prop) === value) return;
|
|
77
|
-
if (prop.lookup !== undefined && !callMethod(instance, prop.lookup, [value])) return;
|
|
78
|
-
Reflect.set(instance, prop.prop, value);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const applyProp = (instance: object, prop: AppliedProp, oldProps: Props | null, newProps: Props): void => {
|
|
82
|
-
const oldValue = oldProps?.[prop.prop];
|
|
83
|
-
const newValue = newProps[prop.prop];
|
|
84
|
-
switch (prop.kind) {
|
|
85
|
-
case "value":
|
|
86
|
-
applyValue(instance, prop, oldValue, newValue);
|
|
87
|
-
return;
|
|
88
|
-
case "controlled-text":
|
|
89
|
-
applyControlledText(instance, prop, oldValue, newValue);
|
|
90
|
-
return;
|
|
91
|
-
case "lazy":
|
|
92
|
-
applyLazy(instance, prop, newProps);
|
|
93
|
-
return;
|
|
94
|
-
case "list":
|
|
95
|
-
applyList(instance, prop, newValue);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export const applyElementProps = (instance: TypedClass & object, oldProps: Props | null, newProps: Props): void => {
|
|
101
|
-
for (const prop of appliedPropsFor(instance.__type__).values()) {
|
|
102
|
-
applyProp(instance, prop, oldProps, newProps);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export const reapplyLazyProps = (instance: TypedClass & object, props: Props): void => {
|
|
107
|
-
for (const prop of appliedPropsFor(instance.__type__).values()) {
|
|
108
|
-
if (prop.kind === "lazy") applyLazy(instance, prop, props);
|
|
109
|
-
}
|
|
110
|
-
};
|