@gtkx/react 0.15.0 → 0.17.1
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/README.md +1 -0
- package/dist/animation/css-builder.d.ts +3 -0
- package/dist/animation/css-builder.js +53 -0
- package/dist/animation/types.d.ts +120 -0
- package/dist/errors.js +3 -0
- package/dist/factory.d.ts +3 -2
- package/dist/factory.js +1 -1
- package/dist/fiber-root.js +1 -1
- package/dist/generated/internal.d.ts +28 -1
- package/dist/generated/internal.js +93 -18
- package/dist/generated/jsx.d.ts +1672 -1483
- package/dist/generated/jsx.js +475 -0
- package/dist/host-config.d.ts +3 -1
- package/dist/host-config.js +26 -11
- package/dist/jsx.d.ts +136 -166
- package/dist/jsx.js +58 -69
- package/dist/node.d.ts +4 -1
- package/dist/node.js +14 -3
- package/dist/nodes/abstract/positional-child.d.ts +9 -0
- package/dist/nodes/abstract/positional-child.js +29 -0
- package/dist/nodes/abstract/virtual-container.d.ts +21 -0
- package/dist/nodes/abstract/virtual-container.js +68 -0
- package/dist/nodes/abstract/virtual-single-child.d.ts +18 -0
- package/dist/nodes/abstract/virtual-single-child.js +55 -0
- package/dist/nodes/action-row-child.d.ts +0 -13
- package/dist/nodes/action-row-child.js +22 -12
- package/dist/nodes/adjustable.d.ts +23 -0
- package/dist/nodes/adjustable.js +62 -0
- package/dist/nodes/alert-dialog-response.js +86 -0
- package/dist/nodes/animation.js +252 -0
- package/dist/nodes/application.js +17 -7
- package/dist/nodes/autowrapped.js +37 -43
- package/dist/nodes/calendar.js +17 -43
- package/dist/nodes/color-dialog-button.d.ts +1 -0
- package/dist/nodes/color-dialog-button.js +70 -0
- package/dist/nodes/column-view-column.d.ts +3 -3
- package/dist/nodes/column-view-column.js +1 -1
- package/dist/nodes/column-view.js +36 -39
- package/dist/nodes/dialog.d.ts +11 -0
- package/dist/nodes/dialog.js +20 -0
- package/dist/nodes/drawing-area.js +24 -7
- package/dist/nodes/event-controller.d.ts +22 -0
- package/dist/nodes/event-controller.js +96 -0
- package/dist/nodes/expander-row-child.d.ts +0 -14
- package/dist/nodes/expander-row-child.js +22 -12
- package/dist/nodes/fixed-child.js +52 -36
- package/dist/nodes/font-dialog-button.d.ts +1 -0
- package/dist/nodes/font-dialog-button.js +90 -0
- package/dist/nodes/grid-child.js +43 -45
- package/dist/nodes/grid.d.ts +1 -0
- package/dist/nodes/grid.js +41 -0
- package/dist/nodes/index.d.ts +18 -12
- package/dist/nodes/index.js +18 -12
- package/dist/nodes/internal/base-item-renderer.d.ts +29 -0
- package/dist/nodes/internal/base-item-renderer.js +88 -0
- package/dist/nodes/internal/child-attachment.d.ts +26 -0
- package/dist/nodes/internal/child-attachment.js +48 -0
- package/dist/nodes/internal/deferred-action.d.ts +9 -0
- package/dist/nodes/internal/deferred-action.js +22 -0
- package/dist/nodes/internal/list-item-renderer.d.ts +14 -15
- package/dist/nodes/internal/list-item-renderer.js +51 -77
- package/dist/nodes/internal/list-store.d.ts +5 -6
- package/dist/nodes/internal/list-store.js +29 -38
- package/dist/nodes/internal/predicates.d.ts +25 -2
- package/dist/nodes/internal/predicates.js +53 -41
- package/dist/nodes/internal/selection-model.d.ts +30 -0
- package/dist/nodes/internal/selection-model.js +87 -0
- package/dist/nodes/internal/signal-store.d.ts +9 -5
- package/dist/nodes/internal/signal-store.js +31 -31
- package/dist/nodes/internal/simple-list-store.js +6 -9
- package/dist/nodes/internal/text-buffer-controller.d.ts +43 -0
- package/dist/nodes/internal/text-buffer-controller.js +287 -0
- package/dist/nodes/internal/text-tag-styles.d.ts +43 -0
- package/dist/nodes/internal/text-tag-styles.js +52 -0
- package/dist/nodes/internal/tree-list-item-renderer.d.ts +15 -14
- package/dist/nodes/internal/tree-list-item-renderer.js +85 -96
- package/dist/nodes/internal/tree-store.d.ts +8 -11
- package/dist/nodes/internal/tree-store.js +70 -72
- package/dist/nodes/internal/utils.d.ts +7 -4
- package/dist/nodes/internal/utils.js +50 -5
- package/dist/nodes/level-bar.js +19 -54
- package/dist/nodes/list-item.d.ts +6 -3
- package/dist/nodes/list-item.js +7 -4
- package/dist/nodes/list-view.js +17 -12
- package/dist/nodes/menu.d.ts +3 -3
- package/dist/nodes/menu.js +3 -3
- package/dist/nodes/models/list.d.ts +11 -13
- package/dist/nodes/models/list.js +16 -73
- package/dist/nodes/models/menu.d.ts +8 -7
- package/dist/nodes/models/menu.js +43 -50
- package/dist/nodes/models/tree-list.d.ts +6 -12
- package/dist/nodes/models/tree-list.js +30 -93
- package/dist/nodes/navigation-page.d.ts +1 -0
- package/dist/nodes/navigation-page.js +27 -32
- package/dist/nodes/navigation-view.js +17 -28
- package/dist/nodes/notebook-page-tab.d.ts +3 -3
- package/dist/nodes/notebook-page-tab.js +11 -14
- package/dist/nodes/notebook-page.d.ts +7 -5
- package/dist/nodes/notebook-page.js +45 -25
- package/dist/nodes/notebook.js +2 -2
- package/dist/nodes/overlay-child.js +90 -30
- package/dist/nodes/pack-child.d.ts +0 -13
- package/dist/nodes/pack-child.js +22 -12
- package/dist/nodes/popover-menu.js +2 -2
- package/dist/nodes/scale.js +15 -45
- package/dist/nodes/scrolled-window.js +7 -6
- package/dist/nodes/search-bar.d.ts +1 -0
- package/dist/nodes/search-bar.js +40 -0
- package/dist/nodes/shortcut-controller.d.ts +1 -37
- package/dist/nodes/shortcut-controller.js +8 -47
- package/dist/nodes/shortcut.d.ts +5 -4
- package/dist/nodes/shortcut.js +11 -5
- package/dist/nodes/simple-list-view.js +2 -3
- package/dist/nodes/slot.d.ts +6 -9
- package/dist/nodes/slot.js +27 -42
- package/dist/nodes/source-view.js +80 -29
- package/dist/nodes/stack-page.js +20 -22
- package/dist/nodes/stack.js +19 -5
- package/dist/nodes/text-anchor.d.ts +41 -0
- package/dist/nodes/text-anchor.js +59 -0
- package/dist/nodes/text-content.d.ts +10 -0
- package/dist/nodes/text-content.js +1 -0
- package/dist/nodes/text-paintable.d.ts +17 -0
- package/dist/nodes/text-paintable.js +34 -0
- package/dist/nodes/text-segment.d.ts +15 -0
- package/dist/nodes/text-segment.js +29 -0
- package/dist/nodes/text-tag.d.ts +136 -0
- package/dist/nodes/text-tag.js +202 -0
- package/dist/nodes/text-view.d.ts +30 -0
- package/dist/nodes/text-view.js +49 -21
- package/dist/nodes/toggle-group.js +24 -32
- package/dist/nodes/toggle.d.ts +1 -15
- package/dist/nodes/toggle.js +40 -32
- package/dist/nodes/toolbar-child.js +22 -31
- package/dist/nodes/tree-list-item.d.ts +7 -5
- package/dist/nodes/tree-list-item.js +24 -36
- package/dist/nodes/tree-list-view.js +9 -7
- package/dist/nodes/virtual.d.ts +1 -1
- package/dist/nodes/web-view.d.ts +1 -0
- package/dist/nodes/web-view.js +29 -0
- package/dist/nodes/widget.d.ts +2 -16
- package/dist/nodes/widget.js +105 -294
- package/dist/nodes/window.d.ts +9 -3
- package/dist/nodes/window.js +29 -15
- package/dist/registry.d.ts +1 -1
- package/dist/render.js +9 -7
- package/dist/scheduler.d.ts +11 -1
- package/dist/scheduler.js +16 -4
- package/dist/types.d.ts +2 -136
- package/package.json +4 -4
- package/dist/nodes/action-row.js +0 -46
- package/dist/nodes/adjustment.d.ts +0 -48
- package/dist/nodes/adjustment.js +0 -70
- package/dist/nodes/calendar-mark.d.ts +0 -15
- package/dist/nodes/calendar-mark.js +0 -29
- package/dist/nodes/expander-row.js +0 -55
- package/dist/nodes/internal/constants.d.ts +0 -1
- package/dist/nodes/internal/constants.js +0 -24
- package/dist/nodes/level-bar-offset.d.ts +0 -13
- package/dist/nodes/level-bar-offset.js +0 -35
- package/dist/nodes/pack.js +0 -46
- package/dist/nodes/scale-mark.d.ts +0 -17
- package/dist/nodes/scale-mark.js +0 -38
- package/dist/nodes/source-buffer.d.ts +0 -73
- package/dist/nodes/source-buffer.js +0 -149
- package/dist/nodes/text-buffer.d.ts +0 -43
- package/dist/nodes/text-buffer.js +0 -81
- package/dist/nodes/virtual-child.d.ts +0 -18
- package/dist/nodes/virtual-child.js +0 -62
- /package/dist/{nodes/action-row.d.ts → animation/types.js} +0 -0
- /package/dist/nodes/{expander-row.d.ts → alert-dialog-response.d.ts} +0 -0
- /package/dist/nodes/{pack.d.ts → animation.d.ts} +0 -0
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getSignalStore } from "./nodes/internal/signal-store.js";
|
|
2
2
|
export class Node {
|
|
3
3
|
static priority = 0;
|
|
4
4
|
static matches(_type, _containerOrClass) {
|
|
@@ -9,16 +9,27 @@ export class Node {
|
|
|
9
9
|
}
|
|
10
10
|
container;
|
|
11
11
|
typeName;
|
|
12
|
-
|
|
12
|
+
signalStore;
|
|
13
|
+
constructor(typeName, _props = {}, container, rootContainer) {
|
|
13
14
|
this.typeName = typeName;
|
|
14
15
|
this.container = container;
|
|
16
|
+
this.signalStore = getSignalStore(rootContainer);
|
|
15
17
|
}
|
|
16
18
|
appendChild(_child) { }
|
|
17
19
|
removeChild(_child) { }
|
|
18
20
|
insertBefore(_child, _before) { }
|
|
19
21
|
updateProps(_oldProps, _newProps) { }
|
|
20
22
|
mount() { }
|
|
23
|
+
commitProps(oldProps, newProps) {
|
|
24
|
+
this.signalStore.blockAll();
|
|
25
|
+
try {
|
|
26
|
+
this.updateProps(oldProps, newProps);
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
this.signalStore.unblockAll();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
21
32
|
unmount() {
|
|
22
|
-
signalStore.clear(this);
|
|
33
|
+
this.signalStore.clear(this);
|
|
23
34
|
}
|
|
24
35
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { Props } from "../../types.js";
|
|
3
|
+
import { VirtualSingleChildNode } from "./virtual-single-child.js";
|
|
4
|
+
export declare abstract class PositionalChildNode<P extends Props = Props> extends VirtualSingleChildNode<P> {
|
|
5
|
+
protected abstract attachToParent(parent: Gtk.Widget, child: Gtk.Widget): void;
|
|
6
|
+
protected abstract detachFromParent(parent: Gtk.Widget, child: Gtk.Widget): void;
|
|
7
|
+
unmount(): void;
|
|
8
|
+
protected onChildChange(oldChild: Gtk.Widget | null): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isObjectEqual } from "@gtkx/ffi";
|
|
2
|
+
import { VirtualSingleChildNode } from "./virtual-single-child.js";
|
|
3
|
+
export class PositionalChildNode extends VirtualSingleChildNode {
|
|
4
|
+
unmount() {
|
|
5
|
+
if (this.parent && this.child) {
|
|
6
|
+
const parent = this.parent;
|
|
7
|
+
const oldChild = this.child;
|
|
8
|
+
this.child = null;
|
|
9
|
+
const parentOfOld = oldChild.getParent();
|
|
10
|
+
if (parentOfOld && isObjectEqual(parentOfOld, parent)) {
|
|
11
|
+
this.detachFromParent(parent, oldChild);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
this.parent = null;
|
|
15
|
+
super.unmount();
|
|
16
|
+
}
|
|
17
|
+
onChildChange(oldChild) {
|
|
18
|
+
const parent = this.getParent();
|
|
19
|
+
if (oldChild) {
|
|
20
|
+
const parentOfOld = oldChild.getParent();
|
|
21
|
+
if (parentOfOld && isObjectEqual(parentOfOld, parent)) {
|
|
22
|
+
this.detachFromParent(parent, oldChild);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (this.child) {
|
|
26
|
+
this.attachToParent(parent, this.child);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { Node } from "../../node.js";
|
|
3
|
+
import type { Attachable } from "../internal/predicates.js";
|
|
4
|
+
import { VirtualNode } from "../virtual.js";
|
|
5
|
+
type ChildParentWidget = Gtk.Widget & {
|
|
6
|
+
remove(child: Gtk.Widget): void;
|
|
7
|
+
};
|
|
8
|
+
export declare abstract class VirtualContainerNode<P extends ChildParentWidget = ChildParentWidget> extends VirtualNode implements Attachable {
|
|
9
|
+
protected parent: P | null;
|
|
10
|
+
setParent(newParent: P | null): void;
|
|
11
|
+
protected getParent(): P;
|
|
12
|
+
protected abstract attachChild(parent: P, widget: Gtk.Widget): void;
|
|
13
|
+
canBeChildOf(parent: Node): boolean;
|
|
14
|
+
attachTo(parent: Node): void;
|
|
15
|
+
detachFrom(_parent: Node): void;
|
|
16
|
+
unmount(): void;
|
|
17
|
+
appendChild(child: Node): void;
|
|
18
|
+
insertBefore(child: Node, _before: Node): void;
|
|
19
|
+
removeChild(child: Node): void;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { isObjectEqual } from "@gtkx/ffi";
|
|
2
|
+
import { CommitPriority, scheduleAfterCommit } from "../../scheduler.js";
|
|
3
|
+
import { VirtualNode } from "../virtual.js";
|
|
4
|
+
import { WidgetNode } from "../widget.js";
|
|
5
|
+
export class VirtualContainerNode extends VirtualNode {
|
|
6
|
+
parent = null;
|
|
7
|
+
setParent(newParent) {
|
|
8
|
+
this.parent = newParent;
|
|
9
|
+
}
|
|
10
|
+
getParent() {
|
|
11
|
+
if (!this.parent) {
|
|
12
|
+
throw new Error(`Expected parent widget to be set on ${this.typeName}`);
|
|
13
|
+
}
|
|
14
|
+
return this.parent;
|
|
15
|
+
}
|
|
16
|
+
canBeChildOf(parent) {
|
|
17
|
+
return parent instanceof WidgetNode;
|
|
18
|
+
}
|
|
19
|
+
attachTo(parent) {
|
|
20
|
+
if (parent instanceof WidgetNode) {
|
|
21
|
+
this.setParent(parent.container);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
detachFrom(_parent) { }
|
|
25
|
+
unmount() {
|
|
26
|
+
this.parent = null;
|
|
27
|
+
super.unmount();
|
|
28
|
+
}
|
|
29
|
+
appendChild(child) {
|
|
30
|
+
if (!(child instanceof WidgetNode)) {
|
|
31
|
+
throw new Error(`Cannot append '${child.typeName}' to '${this.typeName}': expected Widget`);
|
|
32
|
+
}
|
|
33
|
+
const widget = child.container;
|
|
34
|
+
scheduleAfterCommit(() => {
|
|
35
|
+
const parent = this.parent;
|
|
36
|
+
if (parent) {
|
|
37
|
+
this.attachChild(parent, widget);
|
|
38
|
+
}
|
|
39
|
+
}, CommitPriority.NORMAL);
|
|
40
|
+
}
|
|
41
|
+
insertBefore(child, _before) {
|
|
42
|
+
if (!(child instanceof WidgetNode)) {
|
|
43
|
+
throw new Error(`Cannot insert '${child.typeName}' into '${this.typeName}': expected Widget`);
|
|
44
|
+
}
|
|
45
|
+
const widget = child.container;
|
|
46
|
+
scheduleAfterCommit(() => {
|
|
47
|
+
const parent = this.parent;
|
|
48
|
+
if (parent) {
|
|
49
|
+
this.attachChild(parent, widget);
|
|
50
|
+
}
|
|
51
|
+
}, CommitPriority.NORMAL);
|
|
52
|
+
}
|
|
53
|
+
removeChild(child) {
|
|
54
|
+
if (!(child instanceof WidgetNode)) {
|
|
55
|
+
throw new Error(`Cannot remove '${child.typeName}' from '${this.typeName}': expected Widget`);
|
|
56
|
+
}
|
|
57
|
+
const widget = child.container;
|
|
58
|
+
const parent = this.parent;
|
|
59
|
+
scheduleAfterCommit(() => {
|
|
60
|
+
if (parent) {
|
|
61
|
+
const currentParent = widget.getParent();
|
|
62
|
+
if (currentParent && isObjectEqual(currentParent, parent)) {
|
|
63
|
+
parent.remove(widget);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}, CommitPriority.HIGH);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { Node } from "../../node.js";
|
|
3
|
+
import type { Props } from "../../types.js";
|
|
4
|
+
import type { Attachable } from "../internal/predicates.js";
|
|
5
|
+
import { VirtualNode } from "../virtual.js";
|
|
6
|
+
export declare abstract class VirtualSingleChildNode<P extends Props = Props> extends VirtualNode<P> implements Attachable {
|
|
7
|
+
protected parent: Gtk.Widget | null;
|
|
8
|
+
child: Gtk.Widget | null;
|
|
9
|
+
setParent(parent: Gtk.Widget | null): void;
|
|
10
|
+
protected getParent(): Gtk.Widget;
|
|
11
|
+
protected getTypedParent<T extends Gtk.Widget>(): T;
|
|
12
|
+
protected abstract onChildChange(oldChild: Gtk.Widget | null): void;
|
|
13
|
+
appendChild(child: Node): void;
|
|
14
|
+
removeChild(child: Node): void;
|
|
15
|
+
canBeChildOf(parent: Node): boolean;
|
|
16
|
+
attachTo(parent: Node): void;
|
|
17
|
+
detachFrom(_parent: Node): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { isObjectEqual } from "@gtkx/ffi";
|
|
2
|
+
import { CommitPriority, scheduleAfterCommit } from "../../scheduler.js";
|
|
3
|
+
import { VirtualNode } from "../virtual.js";
|
|
4
|
+
import { WidgetNode } from "../widget.js";
|
|
5
|
+
export class VirtualSingleChildNode extends VirtualNode {
|
|
6
|
+
parent = null;
|
|
7
|
+
child = null;
|
|
8
|
+
setParent(parent) {
|
|
9
|
+
this.parent = parent;
|
|
10
|
+
}
|
|
11
|
+
getParent() {
|
|
12
|
+
if (!this.parent) {
|
|
13
|
+
throw new Error(`Expected parent widget to be set on ${this.typeName}`);
|
|
14
|
+
}
|
|
15
|
+
return this.parent;
|
|
16
|
+
}
|
|
17
|
+
getTypedParent() {
|
|
18
|
+
return this.getParent();
|
|
19
|
+
}
|
|
20
|
+
appendChild(child) {
|
|
21
|
+
if (!(child instanceof WidgetNode)) {
|
|
22
|
+
throw new Error(`Cannot append '${child.typeName}' to '${this.typeName}': expected Widget`);
|
|
23
|
+
}
|
|
24
|
+
const oldChild = this.child;
|
|
25
|
+
this.child = child.container;
|
|
26
|
+
scheduleAfterCommit(() => {
|
|
27
|
+
if (this.parent) {
|
|
28
|
+
this.onChildChange(oldChild);
|
|
29
|
+
}
|
|
30
|
+
}, CommitPriority.NORMAL);
|
|
31
|
+
}
|
|
32
|
+
removeChild(child) {
|
|
33
|
+
if (!(child instanceof WidgetNode)) {
|
|
34
|
+
throw new Error(`Cannot remove '${child.typeName}' from '${this.typeName}': expected Widget`);
|
|
35
|
+
}
|
|
36
|
+
const oldChild = this.child;
|
|
37
|
+
scheduleAfterCommit(() => {
|
|
38
|
+
if (isObjectEqual(oldChild, this.child)) {
|
|
39
|
+
this.child = null;
|
|
40
|
+
}
|
|
41
|
+
if (this.parent && oldChild) {
|
|
42
|
+
this.onChildChange(oldChild);
|
|
43
|
+
}
|
|
44
|
+
}, CommitPriority.HIGH);
|
|
45
|
+
}
|
|
46
|
+
canBeChildOf(parent) {
|
|
47
|
+
return parent instanceof WidgetNode;
|
|
48
|
+
}
|
|
49
|
+
attachTo(parent) {
|
|
50
|
+
if (parent instanceof WidgetNode) {
|
|
51
|
+
this.setParent(parent.container);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
detachFrom(_parent) { }
|
|
55
|
+
}
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import { VirtualChildNode } from "./virtual-child.js";
|
|
3
|
-
type PrefixSuffixWidget = Gtk.Widget & {
|
|
4
|
-
addPrefix(child: Gtk.Widget): void;
|
|
5
|
-
addSuffix(child: Gtk.Widget): void;
|
|
6
|
-
remove(child: Gtk.Widget): void;
|
|
7
|
-
};
|
|
8
|
-
export declare class ActionRowChild extends VirtualChildNode<PrefixSuffixWidget> {
|
|
9
|
-
static priority: number;
|
|
10
|
-
static matches(type: string): boolean;
|
|
11
|
-
protected getPositionLabel(): string;
|
|
12
|
-
protected attachChild(parent: PrefixSuffixWidget, widget: Gtk.Widget): void;
|
|
13
|
-
}
|
|
14
1
|
export {};
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
+
import { PREFIX_SUFFIX_INTERFACE_METHODS } from "../generated/internal.js";
|
|
1
2
|
import { registerNodeClass } from "../registry.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
3
|
+
import { VirtualContainerNode } from "./abstract/virtual-container.js";
|
|
4
|
+
import { matchesInterface } from "./internal/utils.js";
|
|
5
|
+
class ActionRowPrefixNode extends VirtualContainerNode {
|
|
4
6
|
static priority = 1;
|
|
5
7
|
static matches(type) {
|
|
6
|
-
return type === "ActionRowPrefix"
|
|
8
|
+
return type === "ActionRowPrefix";
|
|
7
9
|
}
|
|
8
|
-
|
|
9
|
-
return
|
|
10
|
+
canBeChildOf(parent) {
|
|
11
|
+
return matchesInterface(PREFIX_SUFFIX_INTERFACE_METHODS, parent.container);
|
|
10
12
|
}
|
|
11
13
|
attachChild(parent, widget) {
|
|
12
|
-
|
|
13
|
-
parent.addPrefix(widget);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
parent.addSuffix(widget);
|
|
17
|
-
}
|
|
14
|
+
parent.addPrefix(widget);
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
|
-
|
|
17
|
+
class ActionRowSuffixNode extends VirtualContainerNode {
|
|
18
|
+
static priority = 1;
|
|
19
|
+
static matches(type) {
|
|
20
|
+
return type === "ActionRowSuffix";
|
|
21
|
+
}
|
|
22
|
+
canBeChildOf(parent) {
|
|
23
|
+
return matchesInterface(PREFIX_SUFFIX_INTERFACE_METHODS, parent.container);
|
|
24
|
+
}
|
|
25
|
+
attachChild(parent, widget) {
|
|
26
|
+
parent.addSuffix(widget);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
registerNodeClass(ActionRowPrefixNode);
|
|
30
|
+
registerNodeClass(ActionRowSuffixNode);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { Container, ContainerClass, Props } from "../types.js";
|
|
3
|
+
import type { AdjustableWidget } from "./internal/predicates.js";
|
|
4
|
+
import { WidgetNode } from "./widget.js";
|
|
5
|
+
type AdjustableProps = Props & {
|
|
6
|
+
value?: number;
|
|
7
|
+
lower?: number;
|
|
8
|
+
upper?: number;
|
|
9
|
+
stepIncrement?: number;
|
|
10
|
+
pageIncrement?: number;
|
|
11
|
+
pageSize?: number;
|
|
12
|
+
onValueChanged?: ((value: number, self: AdjustableWidget) => void) | null;
|
|
13
|
+
};
|
|
14
|
+
export declare class AdjustableNode<T extends AdjustableWidget = AdjustableWidget> extends WidgetNode<T, AdjustableProps> {
|
|
15
|
+
static priority: number;
|
|
16
|
+
private adjustment;
|
|
17
|
+
static matches(_type: string, containerOrClass?: Container | ContainerClass | null): boolean;
|
|
18
|
+
updateProps(oldProps: AdjustableProps | null, newProps: AdjustableProps): void;
|
|
19
|
+
protected ensureAdjustment(props: AdjustableProps): Gtk.Adjustment;
|
|
20
|
+
protected applyOwnProps(oldProps: AdjustableProps | null, newProps: AdjustableProps): void;
|
|
21
|
+
private updateValueChangedHandler;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { ADJUSTABLE_INTERFACE_METHODS } from "../generated/internal.js";
|
|
3
|
+
import { registerNodeClass } from "../registry.js";
|
|
4
|
+
import { filterProps, hasChanged, matchesInterface } from "./internal/utils.js";
|
|
5
|
+
import { WidgetNode } from "./widget.js";
|
|
6
|
+
const OWN_PROPS = ["value", "lower", "upper", "stepIncrement", "pageIncrement", "pageSize", "onValueChanged"];
|
|
7
|
+
export class AdjustableNode extends WidgetNode {
|
|
8
|
+
static priority = 2;
|
|
9
|
+
adjustment = null;
|
|
10
|
+
static matches(_type, containerOrClass) {
|
|
11
|
+
return matchesInterface(ADJUSTABLE_INTERFACE_METHODS, containerOrClass);
|
|
12
|
+
}
|
|
13
|
+
updateProps(oldProps, newProps) {
|
|
14
|
+
super.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
15
|
+
this.applyOwnProps(oldProps, newProps);
|
|
16
|
+
}
|
|
17
|
+
ensureAdjustment(props) {
|
|
18
|
+
if (!this.adjustment) {
|
|
19
|
+
this.adjustment = new Gtk.Adjustment(props.value ?? 0, props.lower ?? 0, props.upper ?? 100, props.stepIncrement ?? 1, props.pageIncrement ?? 10, props.pageSize ?? 0);
|
|
20
|
+
this.container.setAdjustment(this.adjustment);
|
|
21
|
+
}
|
|
22
|
+
return this.adjustment;
|
|
23
|
+
}
|
|
24
|
+
applyOwnProps(oldProps, newProps) {
|
|
25
|
+
const adjustment = this.ensureAdjustment(newProps);
|
|
26
|
+
if (hasChanged(oldProps, newProps, "onValueChanged")) {
|
|
27
|
+
this.updateValueChangedHandler(newProps);
|
|
28
|
+
}
|
|
29
|
+
if (!oldProps)
|
|
30
|
+
return;
|
|
31
|
+
if (hasChanged(oldProps, newProps, "lower")) {
|
|
32
|
+
adjustment.setLower(newProps.lower ?? 0);
|
|
33
|
+
}
|
|
34
|
+
if (hasChanged(oldProps, newProps, "upper")) {
|
|
35
|
+
adjustment.setUpper(newProps.upper ?? 100);
|
|
36
|
+
}
|
|
37
|
+
if (hasChanged(oldProps, newProps, "stepIncrement")) {
|
|
38
|
+
adjustment.setStepIncrement(newProps.stepIncrement ?? 1);
|
|
39
|
+
}
|
|
40
|
+
if (hasChanged(oldProps, newProps, "pageIncrement")) {
|
|
41
|
+
adjustment.setPageIncrement(newProps.pageIncrement ?? 10);
|
|
42
|
+
}
|
|
43
|
+
if (hasChanged(oldProps, newProps, "pageSize")) {
|
|
44
|
+
adjustment.setPageSize(newProps.pageSize ?? 0);
|
|
45
|
+
}
|
|
46
|
+
if (hasChanged(oldProps, newProps, "value") && newProps.value !== undefined) {
|
|
47
|
+
adjustment.setValue(newProps.value);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
updateValueChangedHandler(props) {
|
|
51
|
+
if (!this.adjustment)
|
|
52
|
+
return;
|
|
53
|
+
const { onValueChanged } = props;
|
|
54
|
+
if (onValueChanged) {
|
|
55
|
+
this.signalStore.set(this, this.container, "value-changed", (self) => onValueChanged(self.getValue(), self));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.signalStore.set(this, this.container, "value-changed", null);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
registerNodeClass(AdjustableNode);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as Adw from "@gtkx/ffi/adw";
|
|
2
|
+
import { registerNodeClass } from "../registry.js";
|
|
3
|
+
import { CommitPriority, scheduleAfterCommit } from "../scheduler.js";
|
|
4
|
+
import { hasChanged } from "./internal/utils.js";
|
|
5
|
+
import { VirtualNode } from "./virtual.js";
|
|
6
|
+
import { WidgetNode } from "./widget.js";
|
|
7
|
+
class AlertDialogResponseNode extends VirtualNode {
|
|
8
|
+
static priority = 1;
|
|
9
|
+
dialog = null;
|
|
10
|
+
responseId = null;
|
|
11
|
+
static matches(type) {
|
|
12
|
+
return type === "AlertDialogResponse";
|
|
13
|
+
}
|
|
14
|
+
canBeChildOf(parent) {
|
|
15
|
+
return parent instanceof WidgetNode && parent.container instanceof Adw.AlertDialog;
|
|
16
|
+
}
|
|
17
|
+
attachTo(parent) {
|
|
18
|
+
if (!(parent instanceof WidgetNode) || !(parent.container instanceof Adw.AlertDialog)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (this.dialog)
|
|
22
|
+
return;
|
|
23
|
+
this.dialog = parent.container;
|
|
24
|
+
this.responseId = this.props.id;
|
|
25
|
+
const dialog = this.dialog;
|
|
26
|
+
const id = this.responseId;
|
|
27
|
+
const label = this.props.label;
|
|
28
|
+
scheduleAfterCommit(() => {
|
|
29
|
+
if (this.dialog) {
|
|
30
|
+
dialog.addResponse(id, label);
|
|
31
|
+
this.applyOptionalProps(null, this.props);
|
|
32
|
+
}
|
|
33
|
+
}, CommitPriority.NORMAL);
|
|
34
|
+
}
|
|
35
|
+
detachFrom(_parent) {
|
|
36
|
+
this.removeFromDialog();
|
|
37
|
+
}
|
|
38
|
+
removeFromDialog() {
|
|
39
|
+
if (!this.dialog || !this.responseId)
|
|
40
|
+
return;
|
|
41
|
+
const dialog = this.dialog;
|
|
42
|
+
const id = this.responseId;
|
|
43
|
+
this.dialog = null;
|
|
44
|
+
this.responseId = null;
|
|
45
|
+
scheduleAfterCommit(() => {
|
|
46
|
+
dialog.removeResponse(id);
|
|
47
|
+
}, CommitPriority.HIGH);
|
|
48
|
+
}
|
|
49
|
+
updateProps(oldProps, newProps) {
|
|
50
|
+
super.updateProps(oldProps, newProps);
|
|
51
|
+
if (!this.dialog || !this.responseId)
|
|
52
|
+
return;
|
|
53
|
+
if (hasChanged(oldProps, newProps, "id")) {
|
|
54
|
+
const oldId = this.responseId;
|
|
55
|
+
const newId = newProps.id;
|
|
56
|
+
const dialog = this.dialog;
|
|
57
|
+
const label = newProps.label;
|
|
58
|
+
this.responseId = newId;
|
|
59
|
+
scheduleAfterCommit(() => {
|
|
60
|
+
dialog.removeResponse(oldId);
|
|
61
|
+
dialog.addResponse(newId, label);
|
|
62
|
+
this.applyOptionalProps(null, newProps);
|
|
63
|
+
}, CommitPriority.NORMAL);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (hasChanged(oldProps, newProps, "label")) {
|
|
67
|
+
this.dialog.setResponseLabel(this.responseId, newProps.label);
|
|
68
|
+
}
|
|
69
|
+
this.applyOptionalProps(oldProps, newProps);
|
|
70
|
+
}
|
|
71
|
+
applyOptionalProps(oldProps, newProps) {
|
|
72
|
+
if (!this.dialog || !this.responseId)
|
|
73
|
+
return;
|
|
74
|
+
if (hasChanged(oldProps, newProps, "appearance") && newProps.appearance !== undefined) {
|
|
75
|
+
this.dialog.setResponseAppearance(this.responseId, newProps.appearance);
|
|
76
|
+
}
|
|
77
|
+
if (hasChanged(oldProps, newProps, "enabled") && newProps.enabled !== undefined) {
|
|
78
|
+
this.dialog.setResponseEnabled(this.responseId, newProps.enabled);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
unmount() {
|
|
82
|
+
this.removeFromDialog();
|
|
83
|
+
super.unmount();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
registerNodeClass(AlertDialogResponseNode);
|