@gtkx/react 0.17.2 → 0.18.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/README.md +7 -7
- package/dist/factory.d.ts +0 -1
- package/dist/factory.js +21 -8
- package/dist/generated/internal.d.ts +4 -51
- package/dist/generated/internal.js +626 -412
- package/dist/generated/jsx.d.ts +453 -958
- package/dist/host-config.d.ts +1 -1
- package/dist/host-config.js +18 -23
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/jsx.d.ts +579 -302
- package/dist/jsx.js +37 -179
- package/dist/metadata.d.ts +3 -0
- package/dist/metadata.js +26 -0
- package/dist/node.d.ts +20 -12
- package/dist/node.js +72 -17
- package/dist/nodes/adjustable.d.ts +3 -16
- package/dist/nodes/adjustable.js +5 -22
- package/dist/nodes/alert-dialog-response.d.ts +14 -1
- package/dist/nodes/alert-dialog-response.js +36 -62
- package/dist/nodes/animation.d.ts +37 -1
- package/dist/nodes/animation.js +162 -105
- package/dist/nodes/application.d.ts +11 -1
- package/dist/nodes/application.js +17 -38
- package/dist/nodes/calendar.d.ts +13 -0
- package/dist/nodes/calendar.js +10 -16
- package/dist/nodes/color-dialog-button.d.ts +13 -0
- package/dist/nodes/color-dialog-button.js +10 -38
- package/dist/nodes/column-view-column.d.ts +13 -11
- package/dist/nodes/column-view-column.js +27 -23
- package/dist/nodes/column-view.d.ts +31 -0
- package/dist/nodes/column-view.js +44 -44
- package/dist/nodes/container-slot.d.ts +15 -0
- package/dist/nodes/container-slot.js +68 -0
- package/dist/nodes/dialog.d.ts +6 -8
- package/dist/nodes/dialog.js +12 -13
- package/dist/nodes/drawing-area.d.ts +12 -0
- package/dist/nodes/drawing-area.js +24 -24
- package/dist/nodes/drop-down.d.ts +22 -0
- package/dist/nodes/drop-down.js +72 -0
- package/dist/nodes/event-controller.d.ts +8 -17
- package/dist/nodes/event-controller.js +20 -42
- package/dist/nodes/fixed-child.d.ts +18 -1
- package/dist/nodes/fixed-child.js +52 -36
- package/dist/nodes/font-dialog-button.d.ts +13 -0
- package/dist/nodes/font-dialog-button.js +12 -35
- package/dist/nodes/grid-child.d.ts +17 -1
- package/dist/nodes/grid-child.js +57 -37
- package/dist/nodes/grid-view.d.ts +24 -0
- package/dist/nodes/grid-view.js +73 -0
- package/dist/nodes/internal/base-item-renderer.d.ts +7 -9
- package/dist/nodes/internal/base-item-renderer.js +15 -18
- package/dist/nodes/internal/grid-item-renderer.d.ts +17 -0
- package/dist/nodes/internal/grid-item-renderer.js +59 -0
- package/dist/nodes/internal/list-item-renderer.d.ts +14 -9
- package/dist/nodes/internal/list-item-renderer.js +96 -35
- package/dist/nodes/internal/list-store.d.ts +5 -0
- package/dist/nodes/internal/list-store.js +39 -9
- package/dist/nodes/internal/predicates.d.ts +4 -19
- package/dist/nodes/internal/predicates.js +1 -20
- package/dist/nodes/internal/props.d.ts +5 -0
- package/dist/nodes/internal/props.js +42 -0
- package/dist/nodes/internal/{selection-model.d.ts → selection-model-controller.d.ts} +4 -9
- package/dist/nodes/internal/{selection-model.js → selection-model-controller.js} +6 -15
- package/dist/nodes/internal/signal-store.js +12 -5
- package/dist/nodes/internal/simple-list-store.d.ts +5 -0
- package/dist/nodes/internal/simple-list-store.js +42 -13
- package/dist/nodes/internal/text-buffer-controller.d.ts +4 -12
- package/dist/nodes/internal/text-buffer-controller.js +32 -33
- package/dist/nodes/internal/tree-store.d.ts +7 -0
- package/dist/nodes/internal/tree-store.js +75 -18
- package/dist/nodes/internal/widget.d.ts +7 -0
- package/dist/nodes/internal/widget.js +68 -0
- package/dist/nodes/level-bar.d.ts +10 -0
- package/dist/nodes/level-bar.js +11 -22
- package/dist/nodes/list-item.d.ts +17 -9
- package/dist/nodes/list-item.js +67 -12
- package/dist/nodes/list-view.d.ts +23 -0
- package/dist/nodes/list-view.js +27 -31
- package/dist/nodes/menu.d.ts +2 -4
- package/dist/nodes/menu.js +0 -6
- package/dist/nodes/models/grid.d.ts +27 -0
- package/dist/nodes/models/grid.js +68 -0
- package/dist/nodes/models/list.d.ts +15 -13
- package/dist/nodes/models/list.js +48 -26
- package/dist/nodes/models/menu.d.ts +15 -16
- package/dist/nodes/models/menu.js +63 -93
- package/dist/nodes/navigation-page.d.ts +16 -10
- package/dist/nodes/navigation-page.js +108 -31
- package/dist/nodes/navigation-view.d.ts +15 -0
- package/dist/nodes/navigation-view.js +15 -65
- package/dist/nodes/notebook-page-tab.d.ts +10 -12
- package/dist/nodes/notebook-page-tab.js +24 -27
- package/dist/nodes/notebook-page.d.ts +19 -16
- package/dist/nodes/notebook-page.js +75 -56
- package/dist/nodes/notebook.d.ts +10 -1
- package/dist/nodes/notebook.js +10 -22
- package/dist/nodes/overlay-child.d.ts +17 -1
- package/dist/nodes/overlay-child.js +53 -75
- package/dist/nodes/popover-menu.d.ts +15 -0
- package/dist/nodes/popover-menu.js +13 -26
- package/dist/nodes/scale.d.ts +8 -0
- package/dist/nodes/scale.js +2 -11
- package/dist/nodes/scrolled-window.d.ts +9 -0
- package/dist/nodes/scrolled-window.js +5 -11
- package/dist/nodes/search-bar.d.ts +9 -0
- package/dist/nodes/search-bar.js +8 -33
- package/dist/nodes/shortcut-controller.d.ts +9 -1
- package/dist/nodes/shortcut-controller.js +12 -25
- package/dist/nodes/shortcut.d.ts +11 -33
- package/dist/nodes/shortcut.js +19 -15
- package/dist/nodes/slot.d.ts +16 -15
- package/dist/nodes/slot.js +63 -57
- package/dist/nodes/source-view.d.ts +16 -0
- package/dist/nodes/source-view.js +44 -44
- package/dist/nodes/stack-page.d.ts +21 -1
- package/dist/nodes/stack-page.js +68 -17
- package/dist/nodes/stack.d.ts +11 -0
- package/dist/nodes/stack.js +8 -26
- package/dist/nodes/text-anchor.d.ts +11 -30
- package/dist/nodes/text-anchor.js +20 -22
- package/dist/nodes/text-content.d.ts +1 -0
- package/dist/nodes/text-content.js +1 -1
- package/dist/nodes/text-paintable.d.ts +10 -15
- package/dist/nodes/text-paintable.js +16 -9
- package/dist/nodes/text-segment.d.ts +12 -10
- package/dist/nodes/text-segment.js +19 -11
- package/dist/nodes/text-tag.d.ts +20 -119
- package/dist/nodes/text-tag.js +153 -119
- package/dist/nodes/text-view.d.ts +13 -18
- package/dist/nodes/text-view.js +17 -17
- package/dist/nodes/toggle-group.d.ts +9 -0
- package/dist/nodes/toggle-group.js +8 -33
- package/dist/nodes/toggle.d.ts +15 -1
- package/dist/nodes/toggle.js +34 -52
- package/dist/nodes/virtual.d.ts +3 -10
- package/dist/nodes/virtual.js +1 -14
- package/dist/nodes/web-view.d.ts +9 -0
- package/dist/nodes/web-view.js +10 -24
- package/dist/nodes/widget.d.ts +17 -13
- package/dist/nodes/widget.js +185 -112
- package/dist/nodes/window.d.ts +20 -21
- package/dist/nodes/window.js +54 -35
- package/dist/registry.d.ts +17 -6
- package/dist/registry.js +104 -5
- package/dist/render.d.ts +1 -10
- package/dist/render.js +1 -13
- package/package.json +6 -6
- package/dist/animation/css-builder.d.ts +0 -3
- package/dist/animation/css-builder.js +0 -53
- package/dist/animation/types.d.ts +0 -120
- package/dist/animation/types.js +0 -1
- package/dist/nodes/abstract/positional-child.d.ts +0 -9
- package/dist/nodes/abstract/positional-child.js +0 -29
- package/dist/nodes/abstract/virtual-container.d.ts +0 -21
- package/dist/nodes/abstract/virtual-container.js +0 -68
- package/dist/nodes/abstract/virtual-single-child.d.ts +0 -18
- package/dist/nodes/abstract/virtual-single-child.js +0 -55
- package/dist/nodes/action-row-child.d.ts +0 -1
- package/dist/nodes/action-row-child.js +0 -30
- package/dist/nodes/autowrapped.d.ts +0 -1
- package/dist/nodes/autowrapped.js +0 -115
- package/dist/nodes/expander-row-child.d.ts +0 -1
- package/dist/nodes/expander-row-child.js +0 -30
- package/dist/nodes/grid.d.ts +0 -1
- package/dist/nodes/grid.js +0 -41
- package/dist/nodes/index.d.ts +0 -56
- package/dist/nodes/index.js +0 -56
- package/dist/nodes/internal/child-attachment.d.ts +0 -26
- package/dist/nodes/internal/child-attachment.js +0 -48
- package/dist/nodes/internal/deferred-action.d.ts +0 -9
- package/dist/nodes/internal/deferred-action.js +0 -22
- package/dist/nodes/internal/text-tag-styles.d.ts +0 -43
- package/dist/nodes/internal/text-tag-styles.js +0 -52
- package/dist/nodes/internal/tree-list-item-renderer.d.ts +0 -26
- package/dist/nodes/internal/tree-list-item-renderer.js +0 -134
- package/dist/nodes/internal/utils.d.ts +0 -12
- package/dist/nodes/internal/utils.js +0 -92
- package/dist/nodes/models/tree-list.d.ts +0 -28
- package/dist/nodes/models/tree-list.js +0 -113
- package/dist/nodes/pack-child.d.ts +0 -1
- package/dist/nodes/pack-child.js +0 -30
- package/dist/nodes/simple-list-item.d.ts +0 -9
- package/dist/nodes/simple-list-item.js +0 -9
- package/dist/nodes/simple-list-view.d.ts +0 -1
- package/dist/nodes/simple-list-view.js +0 -74
- package/dist/nodes/toolbar-child.d.ts +0 -1
- package/dist/nodes/toolbar-child.js +0 -30
- package/dist/nodes/tree-list-item.d.ts +0 -22
- package/dist/nodes/tree-list-item.js +0 -90
- package/dist/nodes/tree-list-view.d.ts +0 -1
- package/dist/nodes/tree-list-view.js +0 -77
- package/dist/scheduler.d.ts +0 -26
- package/dist/scheduler.js +0 -42
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import { Node } from "../node.js";
|
|
3
|
-
import type {
|
|
4
|
-
import
|
|
5
|
-
export declare class EventControllerNode<T extends Gtk.EventController = Gtk.EventController> extends Node<T, Props
|
|
6
|
-
static priority: number;
|
|
7
|
-
static matches(type: string): boolean;
|
|
3
|
+
import type { Props } from "../types.js";
|
|
4
|
+
import { WidgetNode } from "./widget.js";
|
|
5
|
+
export declare class EventControllerNode<T extends Gtk.EventController = Gtk.EventController, TChild extends Node = any> extends Node<T, Props, WidgetNode, TChild> {
|
|
8
6
|
static createContainer(props: Props, containerClass: typeof Gtk.EventController): Gtk.EventController;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
removeChild(_child: Node): void;
|
|
15
|
-
insertBefore(_child: Node, _before: Node): void;
|
|
16
|
-
attachTo(parent: Node): void;
|
|
17
|
-
detachFrom(_parent: Node): void;
|
|
18
|
-
updateProps(oldProps: Props | null, newProps: Props): void;
|
|
19
|
-
unmount(): void;
|
|
20
|
-
private applyProps;
|
|
7
|
+
isValidParent(parent: Node): boolean;
|
|
8
|
+
setParent(parent: WidgetNode | null): void;
|
|
9
|
+
commitUpdate(oldProps: Props | null, newProps: Props): void;
|
|
10
|
+
detachDeletedInstance(): void;
|
|
11
|
+
private applyOwnProps;
|
|
21
12
|
private setProperty;
|
|
22
13
|
}
|
|
@@ -1,64 +1,43 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import {
|
|
2
|
+
import { CONSTRUCTOR_PROPS } from "../generated/internal.js";
|
|
3
|
+
import { resolvePropMeta, resolveSignal } from "../metadata.js";
|
|
3
4
|
import { Node } from "../node.js";
|
|
4
|
-
import { registerNodeClass } from "../registry.js";
|
|
5
|
-
import { propNameToSignalName, resolvePropMeta, resolveSignal } from "./internal/utils.js";
|
|
6
5
|
import { WidgetNode } from "./widget.js";
|
|
7
6
|
const G_TYPE_INVALID = 0;
|
|
8
7
|
export class EventControllerNode extends Node {
|
|
9
|
-
static priority = 1;
|
|
10
|
-
static matches(type) {
|
|
11
|
-
return type in CONTROLLER_CLASSES;
|
|
12
|
-
}
|
|
13
8
|
static createContainer(props, containerClass) {
|
|
14
9
|
const typeName = containerClass.glibTypeName;
|
|
15
10
|
if (typeName === "GtkDropTarget") {
|
|
16
11
|
const actions = props.actions ?? 0;
|
|
17
12
|
return new Gtk.DropTarget(G_TYPE_INVALID, actions);
|
|
18
13
|
}
|
|
19
|
-
const args = (
|
|
14
|
+
const args = (CONSTRUCTOR_PROPS[typeName] ?? []).map((name) => props[name]);
|
|
20
15
|
// biome-ignore lint/suspicious/noExplicitAny: Dynamic constructor invocation
|
|
21
16
|
return new containerClass(...args);
|
|
22
17
|
}
|
|
23
|
-
|
|
24
|
-
parentWidget = null;
|
|
25
|
-
constructor(typeName, props, container, rootContainer) {
|
|
26
|
-
super(typeName, props, container, rootContainer);
|
|
27
|
-
this.props = props;
|
|
28
|
-
}
|
|
29
|
-
canBeChildOf(parent) {
|
|
18
|
+
isValidParent(parent) {
|
|
30
19
|
return parent instanceof WidgetNode;
|
|
31
20
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
attachTo(parent) {
|
|
36
|
-
if (parent instanceof WidgetNode) {
|
|
37
|
-
this.parentWidget = parent.container;
|
|
38
|
-
parent.container.addController(this.container);
|
|
21
|
+
setParent(parent) {
|
|
22
|
+
if (!parent && this.parent) {
|
|
23
|
+
this.parent.container.removeController(this.container);
|
|
39
24
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.parentWidget.removeController(this.container);
|
|
25
|
+
super.setParent(parent);
|
|
26
|
+
if (parent) {
|
|
27
|
+
parent.container.addController(this.container);
|
|
44
28
|
}
|
|
45
|
-
this.parentWidget = null;
|
|
46
29
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.
|
|
30
|
+
commitUpdate(oldProps, newProps) {
|
|
31
|
+
super.commitUpdate(oldProps, newProps);
|
|
32
|
+
this.applyOwnProps(oldProps, newProps);
|
|
50
33
|
}
|
|
51
|
-
|
|
52
|
-
if (this.
|
|
53
|
-
this.
|
|
34
|
+
detachDeletedInstance() {
|
|
35
|
+
if (this.parent && this.container.getWidget() === this.parent.container) {
|
|
36
|
+
this.parent.container.removeController(this.container);
|
|
54
37
|
}
|
|
55
|
-
|
|
56
|
-
super.unmount();
|
|
38
|
+
super.detachDeletedInstance();
|
|
57
39
|
}
|
|
58
|
-
|
|
59
|
-
if (!this.container) {
|
|
60
|
-
throw new Error(`EventControllerNode.applyProps: container is undefined for ${this.typeName}`);
|
|
61
|
-
}
|
|
40
|
+
applyOwnProps(oldProps, newProps) {
|
|
62
41
|
const propNames = new Set([...Object.keys(oldProps ?? {}), ...Object.keys(newProps ?? {})]);
|
|
63
42
|
for (const name of propNames) {
|
|
64
43
|
if (name === "children")
|
|
@@ -67,8 +46,8 @@ export class EventControllerNode extends Node {
|
|
|
67
46
|
const newValue = newProps[name];
|
|
68
47
|
if (oldValue === newValue)
|
|
69
48
|
continue;
|
|
70
|
-
const signalName =
|
|
71
|
-
if (
|
|
49
|
+
const signalName = resolveSignal(this.container, name);
|
|
50
|
+
if (signalName) {
|
|
72
51
|
const handler = typeof newValue === "function" ? newValue : undefined;
|
|
73
52
|
this.signalStore.set(this, this.container, signalName, handler, { blockable: false });
|
|
74
53
|
}
|
|
@@ -93,4 +72,3 @@ export class EventControllerNode extends Node {
|
|
|
93
72
|
}
|
|
94
73
|
}
|
|
95
74
|
}
|
|
96
|
-
registerNodeClass(EventControllerNode);
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { FixedChildProps } from "../jsx.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
import { VirtualNode } from "./virtual.js";
|
|
5
|
+
import { WidgetNode } from "./widget.js";
|
|
6
|
+
export declare class FixedChildNode extends VirtualNode<FixedChildProps, WidgetNode<Gtk.Fixed>, WidgetNode> {
|
|
7
|
+
isValidChild(child: Node): boolean;
|
|
8
|
+
isValidParent(parent: Node): boolean;
|
|
9
|
+
setParent(parent: WidgetNode<Gtk.Fixed> | null): void;
|
|
10
|
+
appendChild(child: WidgetNode): void;
|
|
11
|
+
removeChild(child: WidgetNode): void;
|
|
12
|
+
commitUpdate(oldProps: FixedChildProps | null, newProps: FixedChildProps): void;
|
|
13
|
+
detachDeletedInstance(): void;
|
|
14
|
+
private attachToParent;
|
|
15
|
+
private detachFromParent;
|
|
16
|
+
private repositionChild;
|
|
17
|
+
private applyTransform;
|
|
18
|
+
}
|
|
@@ -1,36 +1,40 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
class FixedChildNode extends
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return type === "FixedChild";
|
|
2
|
+
import { hasChanged } from "./internal/props.js";
|
|
3
|
+
import { VirtualNode } from "./virtual.js";
|
|
4
|
+
import { WidgetNode } from "./widget.js";
|
|
5
|
+
export class FixedChildNode extends VirtualNode {
|
|
6
|
+
isValidChild(child) {
|
|
7
|
+
return child instanceof WidgetNode;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
|
-
return parent.container instanceof Gtk.Fixed;
|
|
9
|
+
isValidParent(parent) {
|
|
10
|
+
return parent instanceof WidgetNode && parent.container instanceof Gtk.Fixed;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
setParent(parent) {
|
|
13
|
+
if (!parent && this.parent && this.children[0]) {
|
|
14
|
+
this.detachFromParent(this.parent.container, this.children[0].container);
|
|
15
|
+
}
|
|
16
|
+
super.setParent(parent);
|
|
17
|
+
if (parent && this.children[0]) {
|
|
18
|
+
this.attachToParent(parent.container, this.children[0].container);
|
|
16
19
|
this.applyTransform();
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
detachFromParent(parent, child) {
|
|
26
|
-
parent.remove(child);
|
|
22
|
+
appendChild(child) {
|
|
23
|
+
super.appendChild(child);
|
|
24
|
+
if (this.parent) {
|
|
25
|
+
this.attachToParent(this.parent.container, child.container);
|
|
26
|
+
this.applyTransform();
|
|
27
|
+
}
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
removeChild(child) {
|
|
30
|
+
if (this.parent) {
|
|
31
|
+
this.detachFromParent(this.parent.container, child.container);
|
|
32
|
+
}
|
|
33
|
+
super.removeChild(child);
|
|
31
34
|
}
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
commitUpdate(oldProps, newProps) {
|
|
36
|
+
super.commitUpdate(oldProps, newProps);
|
|
37
|
+
if (!this.parent || !this.children[0]) {
|
|
34
38
|
return;
|
|
35
39
|
}
|
|
36
40
|
const positionChanged = hasChanged(oldProps, newProps, "x") || hasChanged(oldProps, newProps, "y");
|
|
@@ -41,29 +45,41 @@ class FixedChildNode extends PositionalChildNode {
|
|
|
41
45
|
this.applyTransform();
|
|
42
46
|
}
|
|
43
47
|
}
|
|
48
|
+
detachDeletedInstance() {
|
|
49
|
+
if (this.parent && this.children[0]) {
|
|
50
|
+
this.detachFromParent(this.parent.container, this.children[0].container);
|
|
51
|
+
}
|
|
52
|
+
super.detachDeletedInstance();
|
|
53
|
+
}
|
|
54
|
+
attachToParent(parent, child) {
|
|
55
|
+
const x = this.props.x ?? 0;
|
|
56
|
+
const y = this.props.y ?? 0;
|
|
57
|
+
parent.put(child, x, y);
|
|
58
|
+
}
|
|
59
|
+
detachFromParent(parent, child) {
|
|
60
|
+
const childParent = child.getParent();
|
|
61
|
+
if (childParent && childParent === parent) {
|
|
62
|
+
parent.remove(child);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
44
65
|
repositionChild() {
|
|
45
|
-
|
|
46
|
-
const child = this.child;
|
|
47
|
-
if (!child) {
|
|
66
|
+
if (!this.parent || !this.children[0])
|
|
48
67
|
return;
|
|
49
|
-
}
|
|
50
68
|
const x = this.props.x ?? 0;
|
|
51
69
|
const y = this.props.y ?? 0;
|
|
52
|
-
|
|
53
|
-
|
|
70
|
+
this.parent.container.remove(this.children[0].container);
|
|
71
|
+
this.parent.container.put(this.children[0].container, x, y);
|
|
54
72
|
this.applyTransform();
|
|
55
73
|
}
|
|
56
74
|
applyTransform() {
|
|
57
|
-
if (!this.
|
|
75
|
+
if (!this.parent || !this.children[0] || !this.props.transform) {
|
|
58
76
|
return;
|
|
59
77
|
}
|
|
60
|
-
const
|
|
61
|
-
const layoutManager = fixed.getLayoutManager();
|
|
78
|
+
const layoutManager = this.parent.container.getLayoutManager();
|
|
62
79
|
if (!layoutManager) {
|
|
63
80
|
return;
|
|
64
81
|
}
|
|
65
|
-
const layoutChild = layoutManager.getLayoutChild(this.
|
|
82
|
+
const layoutChild = layoutManager.getLayoutChild(this.children[0].container);
|
|
66
83
|
layoutChild.setTransform(this.props.transform);
|
|
67
84
|
}
|
|
68
85
|
}
|
|
69
|
-
registerNodeClass(FixedChildNode);
|
|
@@ -1 +1,14 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { GtkFontDialogButtonProps } from "../jsx.js";
|
|
3
|
+
import type { Container } from "../types.js";
|
|
4
|
+
import { WidgetNode } from "./widget.js";
|
|
5
|
+
declare const OWN_PROPS: readonly ["fontDesc", "onFontDescChanged", "title", "modal", "language", "useFont", "useSize", "level"];
|
|
6
|
+
type FontDialogButtonProps = Pick<GtkFontDialogButtonProps, (typeof OWN_PROPS)[number]>;
|
|
7
|
+
export declare class FontDialogButtonNode extends WidgetNode<Gtk.FontDialogButton, FontDialogButtonProps> {
|
|
8
|
+
private dialog;
|
|
9
|
+
static createContainer(_props: FontDialogButtonProps, containerClass: typeof Gtk.Widget): Container | null;
|
|
10
|
+
constructor(typeName: string, props: FontDialogButtonProps, container: Gtk.FontDialogButton, rootContainer: Container);
|
|
11
|
+
commitUpdate(oldProps: FontDialogButtonProps | null, newProps: FontDialogButtonProps): void;
|
|
12
|
+
private applyOwnProps;
|
|
13
|
+
}
|
|
1
14
|
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import {
|
|
3
|
-
import { filterProps, hasChanged, matchesAnyClass } from "./internal/utils.js";
|
|
2
|
+
import { filterProps, hasChanged } from "./internal/props.js";
|
|
4
3
|
import { WidgetNode } from "./widget.js";
|
|
5
4
|
const OWN_PROPS = [
|
|
6
5
|
"fontDesc",
|
|
@@ -12,33 +11,28 @@ const OWN_PROPS = [
|
|
|
12
11
|
"useSize",
|
|
13
12
|
"level",
|
|
14
13
|
];
|
|
15
|
-
class FontDialogButtonNode extends WidgetNode {
|
|
16
|
-
static priority = 1;
|
|
14
|
+
export class FontDialogButtonNode extends WidgetNode {
|
|
17
15
|
dialog;
|
|
18
|
-
notifyHandler = null;
|
|
19
|
-
static matches(_type, containerOrClass) {
|
|
20
|
-
return matchesAnyClass([Gtk.FontDialogButton], containerOrClass);
|
|
21
|
-
}
|
|
22
16
|
static createContainer(_props, containerClass) {
|
|
23
17
|
const dialog = new Gtk.FontDialog();
|
|
24
18
|
const button = new containerClass(dialog);
|
|
25
19
|
return button;
|
|
26
20
|
}
|
|
27
|
-
constructor(
|
|
28
|
-
super(
|
|
21
|
+
constructor(typeName, props, container, rootContainer) {
|
|
22
|
+
super(typeName, props, container, rootContainer);
|
|
29
23
|
const dialog = container.getDialog();
|
|
30
24
|
if (!dialog) {
|
|
31
25
|
throw new Error("FontDialogButton must have a dialog");
|
|
32
26
|
}
|
|
33
27
|
this.dialog = dialog;
|
|
34
28
|
}
|
|
35
|
-
|
|
36
|
-
super.
|
|
29
|
+
commitUpdate(oldProps, newProps) {
|
|
30
|
+
super.commitUpdate(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
37
31
|
this.applyOwnProps(oldProps, newProps);
|
|
38
32
|
}
|
|
39
33
|
applyOwnProps(oldProps, newProps) {
|
|
40
|
-
if (hasChanged(oldProps, newProps, "title")
|
|
41
|
-
this.dialog.setTitle(newProps.title);
|
|
34
|
+
if (hasChanged(oldProps, newProps, "title")) {
|
|
35
|
+
this.dialog.setTitle(newProps.title ?? "");
|
|
42
36
|
}
|
|
43
37
|
if (hasChanged(oldProps, newProps, "modal")) {
|
|
44
38
|
this.dialog.setModal(newProps.modal ?? true);
|
|
@@ -59,32 +53,15 @@ class FontDialogButtonNode extends WidgetNode {
|
|
|
59
53
|
this.container.setFontDesc(newProps.fontDesc);
|
|
60
54
|
}
|
|
61
55
|
if (hasChanged(oldProps, newProps, "onFontDescChanged")) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
setupNotifyHandler(callback) {
|
|
66
|
-
if (this.notifyHandler) {
|
|
67
|
-
this.signalStore.set(this, this.container, "notify", undefined);
|
|
68
|
-
this.notifyHandler = null;
|
|
69
|
-
}
|
|
70
|
-
if (callback) {
|
|
71
|
-
this.notifyHandler = (_button, pspec) => {
|
|
72
|
-
if (pspec.getName() === "font-desc") {
|
|
56
|
+
const callback = newProps.onFontDescChanged;
|
|
57
|
+
this.signalStore.set(this, this.container, "notify::font-desc", callback
|
|
58
|
+
? () => {
|
|
73
59
|
const fontDesc = this.container.getFontDesc();
|
|
74
60
|
if (fontDesc) {
|
|
75
61
|
callback(fontDesc);
|
|
76
62
|
}
|
|
77
63
|
}
|
|
78
|
-
|
|
79
|
-
this.signalStore.set(this, this.container, "notify", this.notifyHandler);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
unmount() {
|
|
83
|
-
if (this.notifyHandler) {
|
|
84
|
-
this.signalStore.set(this, this.container, "notify", undefined);
|
|
85
|
-
this.notifyHandler = null;
|
|
64
|
+
: undefined);
|
|
86
65
|
}
|
|
87
|
-
super.unmount();
|
|
88
66
|
}
|
|
89
67
|
}
|
|
90
|
-
registerNodeClass(FontDialogButtonNode);
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { GridChildProps } from "../jsx.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
import { VirtualNode } from "./virtual.js";
|
|
5
|
+
import { WidgetNode } from "./widget.js";
|
|
6
|
+
export declare class GridChildNode extends VirtualNode<GridChildProps, WidgetNode<Gtk.Grid>, WidgetNode> {
|
|
7
|
+
isValidChild(child: Node): boolean;
|
|
8
|
+
isValidParent(parent: Node): boolean;
|
|
9
|
+
setParent(parent: WidgetNode<Gtk.Grid> | null): void;
|
|
10
|
+
appendChild(child: WidgetNode): void;
|
|
11
|
+
removeChild(child: WidgetNode): void;
|
|
12
|
+
commitUpdate(oldProps: GridChildProps | null, newProps: GridChildProps): void;
|
|
13
|
+
detachDeletedInstance(): void;
|
|
14
|
+
private attachToParent;
|
|
15
|
+
private detachFromParent;
|
|
16
|
+
private reattachChild;
|
|
17
|
+
}
|
package/dist/nodes/grid-child.js
CHANGED
|
@@ -1,60 +1,80 @@
|
|
|
1
|
-
import { isObjectEqual } from "@gtkx/ffi";
|
|
2
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
class GridChildNode extends
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return type === "GridChild";
|
|
2
|
+
import { hasChanged } from "./internal/props.js";
|
|
3
|
+
import { VirtualNode } from "./virtual.js";
|
|
4
|
+
import { WidgetNode } from "./widget.js";
|
|
5
|
+
export class GridChildNode extends VirtualNode {
|
|
6
|
+
isValidChild(child) {
|
|
7
|
+
return child instanceof WidgetNode;
|
|
10
8
|
}
|
|
11
|
-
|
|
12
|
-
return parent.container instanceof Gtk.Grid;
|
|
9
|
+
isValidParent(parent) {
|
|
10
|
+
return parent instanceof WidgetNode && parent.container instanceof Gtk.Grid;
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (existingChild && !isObjectEqual(existingChild, child)) {
|
|
22
|
-
grid.remove(existingChild);
|
|
12
|
+
setParent(parent) {
|
|
13
|
+
if (!parent && this.parent && this.children[0]) {
|
|
14
|
+
this.detachFromParent(this.parent.container, this.children[0].container);
|
|
15
|
+
}
|
|
16
|
+
super.setParent(parent);
|
|
17
|
+
if (parent && this.children[0]) {
|
|
18
|
+
this.attachToParent(parent.container, this.children[0].container);
|
|
23
19
|
}
|
|
24
|
-
grid.attach(child, column, row, columnSpan, rowSpan);
|
|
25
20
|
}
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
appendChild(child) {
|
|
22
|
+
super.appendChild(child);
|
|
23
|
+
if (this.parent) {
|
|
24
|
+
this.attachToParent(this.parent.container, child.container);
|
|
25
|
+
}
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
removeChild(child) {
|
|
28
|
+
if (this.parent) {
|
|
29
|
+
this.detachFromParent(this.parent.container, child.container);
|
|
30
|
+
}
|
|
31
|
+
super.removeChild(child);
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
commitUpdate(oldProps, newProps) {
|
|
34
|
+
super.commitUpdate(oldProps, newProps);
|
|
34
35
|
const positionChanged = hasChanged(oldProps, newProps, "column") ||
|
|
35
36
|
hasChanged(oldProps, newProps, "row") ||
|
|
36
37
|
hasChanged(oldProps, newProps, "columnSpan") ||
|
|
37
38
|
hasChanged(oldProps, newProps, "rowSpan");
|
|
38
|
-
if (positionChanged && this.parent && this.
|
|
39
|
+
if (positionChanged && this.parent && this.children[0]) {
|
|
39
40
|
this.reattachChild();
|
|
40
41
|
}
|
|
41
42
|
}
|
|
43
|
+
detachDeletedInstance() {
|
|
44
|
+
if (this.parent && this.children[0]) {
|
|
45
|
+
this.detachFromParent(this.parent.container, this.children[0].container);
|
|
46
|
+
}
|
|
47
|
+
super.detachDeletedInstance();
|
|
48
|
+
}
|
|
49
|
+
attachToParent(parent, child) {
|
|
50
|
+
const column = this.props.column ?? 0;
|
|
51
|
+
const row = this.props.row ?? 0;
|
|
52
|
+
const columnSpan = this.props.columnSpan ?? 1;
|
|
53
|
+
const rowSpan = this.props.rowSpan ?? 1;
|
|
54
|
+
const existingChild = parent.getChildAt(column, row);
|
|
55
|
+
if (existingChild && existingChild !== child) {
|
|
56
|
+
parent.remove(existingChild);
|
|
57
|
+
}
|
|
58
|
+
parent.attach(child, column, row, columnSpan, rowSpan);
|
|
59
|
+
}
|
|
60
|
+
detachFromParent(parent, child) {
|
|
61
|
+
const childParent = child.getParent();
|
|
62
|
+
if (childParent && childParent === parent) {
|
|
63
|
+
parent.remove(child);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
42
66
|
reattachChild() {
|
|
43
|
-
|
|
44
|
-
const child = this.child;
|
|
45
|
-
if (!child) {
|
|
67
|
+
if (!this.parent || !this.children[0])
|
|
46
68
|
return;
|
|
47
|
-
}
|
|
48
69
|
const column = this.props.column ?? 0;
|
|
49
70
|
const row = this.props.row ?? 0;
|
|
50
71
|
const columnSpan = this.props.columnSpan ?? 1;
|
|
51
72
|
const rowSpan = this.props.rowSpan ?? 1;
|
|
52
|
-
const existingChild =
|
|
53
|
-
if (existingChild &&
|
|
54
|
-
|
|
73
|
+
const existingChild = this.parent.container.getChildAt(column, row);
|
|
74
|
+
if (existingChild && existingChild !== this.children[0].container) {
|
|
75
|
+
this.parent.container.remove(existingChild);
|
|
55
76
|
}
|
|
56
|
-
|
|
57
|
-
|
|
77
|
+
this.parent.container.remove(this.children[0].container);
|
|
78
|
+
this.parent.container.attach(this.children[0].container, column, row, columnSpan, rowSpan);
|
|
58
79
|
}
|
|
59
80
|
}
|
|
60
|
-
registerNodeClass(GridChildNode);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { GtkGridViewProps } from "../jsx.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
import type { Container } from "../types.js";
|
|
5
|
+
import { ListItemNode } from "./list-item.js";
|
|
6
|
+
import { type GridModelProps } from "./models/grid.js";
|
|
7
|
+
import { WidgetNode } from "./widget.js";
|
|
8
|
+
declare const OWN_PROPS: readonly ["renderItem", "estimatedItemHeight"];
|
|
9
|
+
type GridViewProps = Pick<GtkGridViewProps, (typeof OWN_PROPS)[number]> & GridModelProps;
|
|
10
|
+
export declare class GridViewNode extends WidgetNode<Gtk.GridView, GridViewProps, ListItemNode> {
|
|
11
|
+
private itemRenderer;
|
|
12
|
+
private grid;
|
|
13
|
+
constructor(typeName: string, props: GridViewProps, container: Gtk.GridView, rootContainer: Container);
|
|
14
|
+
isValidChild(child: Node): boolean;
|
|
15
|
+
appendChild(child: ListItemNode): void;
|
|
16
|
+
insertBefore(child: ListItemNode, before: ListItemNode): void;
|
|
17
|
+
removeChild(child: ListItemNode): void;
|
|
18
|
+
finalizeInitialChildren(props: GridViewProps): boolean;
|
|
19
|
+
commitUpdate(oldProps: GridViewProps | null, newProps: GridViewProps): void;
|
|
20
|
+
commitMount(): void;
|
|
21
|
+
detachDeletedInstance(): void;
|
|
22
|
+
private applyOwnProps;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { GridItemRenderer } from "./internal/grid-item-renderer.js";
|
|
2
|
+
import { filterProps, hasChanged } from "./internal/props.js";
|
|
3
|
+
import { ListItemNode } from "./list-item.js";
|
|
4
|
+
import { GridModel } from "./models/grid.js";
|
|
5
|
+
import { WidgetNode } from "./widget.js";
|
|
6
|
+
const OWN_PROPS = ["renderItem", "estimatedItemHeight"];
|
|
7
|
+
export class GridViewNode extends WidgetNode {
|
|
8
|
+
itemRenderer;
|
|
9
|
+
grid;
|
|
10
|
+
constructor(typeName, props, container, rootContainer) {
|
|
11
|
+
super(typeName, props, container, rootContainer);
|
|
12
|
+
this.grid = new GridModel({ owner: this, signalStore: this.signalStore }, {
|
|
13
|
+
selectionMode: props.selectionMode,
|
|
14
|
+
selected: props.selected,
|
|
15
|
+
onSelectionChanged: props.onSelectionChanged,
|
|
16
|
+
});
|
|
17
|
+
this.itemRenderer = new GridItemRenderer(this.signalStore);
|
|
18
|
+
this.itemRenderer.setStore(this.grid.getStore());
|
|
19
|
+
this.grid.getStore().setOnItemUpdated((id) => this.itemRenderer.rebindItem(id));
|
|
20
|
+
this.container.setFactory(this.itemRenderer.getFactory());
|
|
21
|
+
}
|
|
22
|
+
isValidChild(child) {
|
|
23
|
+
if (!(child instanceof ListItemNode))
|
|
24
|
+
return false;
|
|
25
|
+
if (child.getChildNodes().length > 0) {
|
|
26
|
+
throw new Error("GtkGridView does not support nested ListItems. Use GtkListView for tree lists.");
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
appendChild(child) {
|
|
31
|
+
super.appendChild(child);
|
|
32
|
+
this.grid.appendChild(child);
|
|
33
|
+
}
|
|
34
|
+
insertBefore(child, before) {
|
|
35
|
+
super.insertBefore(child, before);
|
|
36
|
+
this.grid.insertBefore(child, before);
|
|
37
|
+
}
|
|
38
|
+
removeChild(child) {
|
|
39
|
+
this.grid.removeChild(child);
|
|
40
|
+
super.removeChild(child);
|
|
41
|
+
}
|
|
42
|
+
finalizeInitialChildren(props) {
|
|
43
|
+
super.finalizeInitialChildren(props);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
commitUpdate(oldProps, newProps) {
|
|
47
|
+
super.commitUpdate(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
48
|
+
this.applyOwnProps(oldProps, newProps);
|
|
49
|
+
}
|
|
50
|
+
commitMount() {
|
|
51
|
+
super.commitMount();
|
|
52
|
+
this.grid.flushBatch();
|
|
53
|
+
this.container.setModel(this.grid.getSelectionModel());
|
|
54
|
+
}
|
|
55
|
+
detachDeletedInstance() {
|
|
56
|
+
this.itemRenderer.dispose();
|
|
57
|
+
super.detachDeletedInstance();
|
|
58
|
+
}
|
|
59
|
+
applyOwnProps(oldProps, newProps) {
|
|
60
|
+
if (hasChanged(oldProps, newProps, "renderItem")) {
|
|
61
|
+
this.itemRenderer.setRenderFn(newProps.renderItem ?? null);
|
|
62
|
+
}
|
|
63
|
+
if (hasChanged(oldProps, newProps, "estimatedItemHeight")) {
|
|
64
|
+
this.itemRenderer.setEstimatedItemHeight(newProps.estimatedItemHeight ?? null);
|
|
65
|
+
}
|
|
66
|
+
const previousModel = this.grid.getSelectionModel();
|
|
67
|
+
this.grid.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
68
|
+
const currentModel = this.grid.getSelectionModel();
|
|
69
|
+
if (previousModel !== currentModel) {
|
|
70
|
+
this.container.setModel(currentModel);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -4,25 +4,23 @@ import type Reconciler from "react-reconciler";
|
|
|
4
4
|
import type { SignalStore } from "./signal-store.js";
|
|
5
5
|
export declare abstract class BaseItemRenderer<TStore = unknown> {
|
|
6
6
|
protected factory: Gtk.SignalListItemFactory;
|
|
7
|
-
protected fiberRoots: Map<
|
|
8
|
-
protected tornDown: Set<
|
|
7
|
+
protected fiberRoots: Map<Gtk.ListItem, any>;
|
|
8
|
+
protected tornDown: Set<Gtk.ListItem>;
|
|
9
9
|
protected estimatedItemHeight: number | null;
|
|
10
10
|
private store;
|
|
11
11
|
protected signalStore: SignalStore;
|
|
12
|
-
protected abstract getStoreTypeName(): string;
|
|
13
12
|
constructor(signalStore: SignalStore);
|
|
14
13
|
getFactory(): Gtk.SignalListItemFactory;
|
|
15
14
|
setEstimatedItemHeight(height: number | null): void;
|
|
16
15
|
setStore(store: TStore | null): void;
|
|
17
16
|
protected getStore(): TStore;
|
|
18
17
|
dispose(): void;
|
|
19
|
-
protected abstract renderItem(
|
|
20
|
-
protected abstract
|
|
21
|
-
protected abstract
|
|
22
|
-
protected abstract onBind(listItem: Gtk.ListItem, ptr: number, fiberRoot: Reconciler.FiberRoot): void;
|
|
18
|
+
protected abstract renderItem(listItem: Gtk.ListItem): ReactNode;
|
|
19
|
+
protected abstract onSetup(listItem: Gtk.ListItem): Gtk.Widget;
|
|
20
|
+
protected abstract onBind(listItem: Gtk.ListItem, fiberRoot: Reconciler.FiberRoot): void;
|
|
23
21
|
protected abstract onUnbind(listItem: Gtk.ListItem): void;
|
|
24
|
-
protected
|
|
25
|
-
protected
|
|
22
|
+
protected onSetupComplete(_listItem: Gtk.ListItem): void;
|
|
23
|
+
protected onTeardown(_listItem: Gtk.ListItem): void;
|
|
26
24
|
protected createBox(): Gtk.Box;
|
|
27
25
|
protected clearBoxSizeRequest(box: Gtk.Widget): void;
|
|
28
26
|
private initializeFactory;
|