@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,42 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export class NotebookPageTabNode extends
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
page = null;
|
|
7
|
-
static matches(type) {
|
|
8
|
-
return type === "NotebookPageTab";
|
|
1
|
+
import { VirtualNode } from "./virtual.js";
|
|
2
|
+
import { WidgetNode } from "./widget.js";
|
|
3
|
+
export class NotebookPageTabNode extends VirtualNode {
|
|
4
|
+
isValidChild(child) {
|
|
5
|
+
return child instanceof WidgetNode;
|
|
9
6
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.page = page;
|
|
13
|
-
this.setParent(notebook);
|
|
14
|
-
}
|
|
15
|
-
updateProps(oldProps, newProps) {
|
|
16
|
-
super.updateProps(oldProps, newProps);
|
|
7
|
+
isValidParent(parent) {
|
|
8
|
+
return parent instanceof VirtualNode && parent.typeName === "NotebookPage";
|
|
17
9
|
}
|
|
18
10
|
getNotebook() {
|
|
19
|
-
|
|
20
|
-
throw new Error("Expected Notebook reference to be set on NotebookPageTabNode");
|
|
21
|
-
}
|
|
22
|
-
return this.notebook;
|
|
11
|
+
return this.parent?.parent?.container ?? null;
|
|
23
12
|
}
|
|
24
13
|
getPage() {
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
return this.parent?.findContentChild()?.container ?? null;
|
|
15
|
+
}
|
|
16
|
+
appendChild(child) {
|
|
17
|
+
super.appendChild(child);
|
|
18
|
+
if (this.parent) {
|
|
19
|
+
this.onChildChange();
|
|
27
20
|
}
|
|
28
|
-
return this.page;
|
|
29
21
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
removeChild(child) {
|
|
23
|
+
super.removeChild(child);
|
|
24
|
+
if (this.parent) {
|
|
25
|
+
this.onChildChange();
|
|
33
26
|
}
|
|
27
|
+
}
|
|
28
|
+
onChildChange() {
|
|
34
29
|
const notebook = this.getNotebook();
|
|
35
30
|
const page = this.getPage();
|
|
31
|
+
if (!notebook || !page) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
36
34
|
if (notebook.pageNum(page) === -1) {
|
|
37
35
|
return;
|
|
38
36
|
}
|
|
39
|
-
notebook.setTabLabel(page, this.
|
|
37
|
+
notebook.setTabLabel(page, this.children[0]?.container ?? null);
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
registerNodeClass(NotebookPageTabNode);
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { NotebookPageProps } from "../jsx.js";
|
|
3
3
|
import type { Node } from "../node.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
private
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
import { NotebookPageTabNode } from "./notebook-page-tab.js";
|
|
5
|
+
import { VirtualNode } from "./virtual.js";
|
|
6
|
+
import { WidgetNode } from "./widget.js";
|
|
7
|
+
type NotebookPageChild = WidgetNode | NotebookPageTabNode;
|
|
8
|
+
export declare class NotebookPageNode extends VirtualNode<NotebookPageProps, WidgetNode<Gtk.Notebook>, NotebookPageChild> {
|
|
9
|
+
private position;
|
|
10
|
+
isValidChild(child: Node): boolean;
|
|
11
|
+
isValidParent(parent: Node): boolean;
|
|
12
|
+
findTabNode(): NotebookPageTabNode | undefined;
|
|
13
|
+
findContentChild(): WidgetNode | undefined;
|
|
14
|
+
setParent(parent: WidgetNode<Gtk.Notebook> | null): void;
|
|
15
|
+
appendChild(child: NotebookPageChild): void;
|
|
16
|
+
removeChild(child: NotebookPageChild): void;
|
|
17
|
+
commitUpdate(oldProps: NotebookPageProps | null, newProps: NotebookPageProps): void;
|
|
18
|
+
detachDeletedInstance(): void;
|
|
12
19
|
setPosition(position: number | null): void;
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
removeChild(child: Node): void;
|
|
17
|
-
unmount(): void;
|
|
18
|
-
updateProps(oldProps: Props | null, newProps: Props): void;
|
|
19
|
-
protected applyOwnProps(oldProps: Props | null, newProps: Props): void;
|
|
20
|
+
getChildWidget(): Gtk.Widget;
|
|
21
|
+
private getParentWidget;
|
|
22
|
+
private applyOwnProps;
|
|
20
23
|
private attachPage;
|
|
21
24
|
private applyPageProps;
|
|
22
25
|
private detachPage;
|
|
23
|
-
|
|
26
|
+
private onChildChange;
|
|
24
27
|
}
|
|
25
28
|
export {};
|
|
@@ -1,86 +1,104 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import {
|
|
3
|
-
import { CommitPriority, scheduleAfterCommit } from "../scheduler.js";
|
|
4
|
-
import { hasChanged } from "./internal/utils.js";
|
|
2
|
+
import { hasChanged } from "./internal/props.js";
|
|
5
3
|
import { NotebookPageTabNode } from "./notebook-page-tab.js";
|
|
6
|
-
import {
|
|
4
|
+
import { VirtualNode } from "./virtual.js";
|
|
7
5
|
import { WidgetNode } from "./widget.js";
|
|
8
|
-
export class NotebookPageNode extends
|
|
9
|
-
static priority = 1;
|
|
6
|
+
export class NotebookPageNode extends VirtualNode {
|
|
10
7
|
position = null;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return type === "NotebookPage";
|
|
8
|
+
isValidChild(child) {
|
|
9
|
+
return child instanceof WidgetNode || child instanceof NotebookPageTabNode;
|
|
14
10
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.updateTabNode();
|
|
11
|
+
isValidParent(parent) {
|
|
12
|
+
return parent instanceof WidgetNode && parent.container instanceof Gtk.Notebook;
|
|
18
13
|
}
|
|
19
|
-
|
|
20
|
-
this.
|
|
14
|
+
findTabNode() {
|
|
15
|
+
return this.children.find((c) => c instanceof NotebookPageTabNode);
|
|
21
16
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
throw new Error("Expected Notebook reference to be set on NotebookPageNode");
|
|
25
|
-
}
|
|
26
|
-
return this.parent;
|
|
17
|
+
findContentChild() {
|
|
18
|
+
return this.children.find((c) => c instanceof WidgetNode && !(c instanceof NotebookPageTabNode));
|
|
27
19
|
}
|
|
28
|
-
|
|
29
|
-
if (this.
|
|
30
|
-
this.
|
|
20
|
+
setParent(parent) {
|
|
21
|
+
if (!parent && this.parent) {
|
|
22
|
+
const childWidget = this.findContentChild()?.container ?? null;
|
|
23
|
+
if (childWidget) {
|
|
24
|
+
this.detachPage(childWidget);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
super.setParent(parent);
|
|
28
|
+
if (parent && this.findContentChild()) {
|
|
29
|
+
this.onChildChange(null);
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
appendChild(child) {
|
|
34
33
|
if (child instanceof NotebookPageTabNode) {
|
|
35
|
-
|
|
36
|
-
scheduleAfterCommit(() => {
|
|
37
|
-
this.updateTabNode();
|
|
38
|
-
}, CommitPriority.NORMAL);
|
|
34
|
+
super.appendChild(child);
|
|
39
35
|
return;
|
|
40
36
|
}
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
const oldContent = this.findContentChild()?.container ?? null;
|
|
38
|
+
super.appendChild(child);
|
|
39
|
+
if (this.parent) {
|
|
40
|
+
this.onChildChange(oldContent);
|
|
43
41
|
}
|
|
44
|
-
const oldChild = this.child;
|
|
45
|
-
this.child = child.container;
|
|
46
|
-
scheduleAfterCommit(() => {
|
|
47
|
-
if (this.parent) {
|
|
48
|
-
this.onChildChange(oldChild ?? null);
|
|
49
|
-
}
|
|
50
|
-
this.updateTabNode();
|
|
51
|
-
}, CommitPriority.NORMAL);
|
|
52
42
|
}
|
|
53
43
|
removeChild(child) {
|
|
54
44
|
if (child instanceof NotebookPageTabNode) {
|
|
55
|
-
|
|
45
|
+
super.removeChild(child);
|
|
56
46
|
return;
|
|
57
47
|
}
|
|
48
|
+
const isContent = child === this.findContentChild();
|
|
49
|
+
const oldContent = isContent ? child.container : null;
|
|
58
50
|
super.removeChild(child);
|
|
51
|
+
if (isContent && this.parent && oldContent) {
|
|
52
|
+
this.onChildChange(oldContent);
|
|
53
|
+
}
|
|
59
54
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
super.unmount();
|
|
63
|
-
}
|
|
64
|
-
updateProps(oldProps, newProps) {
|
|
65
|
-
super.updateProps(oldProps, newProps);
|
|
55
|
+
commitUpdate(oldProps, newProps) {
|
|
56
|
+
super.commitUpdate(oldProps, newProps);
|
|
66
57
|
this.applyOwnProps(oldProps, newProps);
|
|
67
58
|
}
|
|
59
|
+
detachDeletedInstance() {
|
|
60
|
+
const childWidget = this.findContentChild()?.container ?? null;
|
|
61
|
+
if (childWidget && this.parent) {
|
|
62
|
+
this.detachPage(childWidget);
|
|
63
|
+
}
|
|
64
|
+
super.detachDeletedInstance();
|
|
65
|
+
}
|
|
66
|
+
setPosition(position) {
|
|
67
|
+
this.position = position;
|
|
68
|
+
}
|
|
69
|
+
getChildWidget() {
|
|
70
|
+
const contentChild = this.findContentChild();
|
|
71
|
+
if (!contentChild) {
|
|
72
|
+
throw new Error("Expected content child widget to be set on NotebookPageNode");
|
|
73
|
+
}
|
|
74
|
+
return contentChild.container;
|
|
75
|
+
}
|
|
76
|
+
getParentWidget() {
|
|
77
|
+
if (!this.parent) {
|
|
78
|
+
throw new Error("Expected parent widget to be set on NotebookPageNode");
|
|
79
|
+
}
|
|
80
|
+
return this.parent.container;
|
|
81
|
+
}
|
|
68
82
|
applyOwnProps(oldProps, newProps) {
|
|
69
|
-
|
|
70
|
-
|
|
83
|
+
const contentChild = this.findContentChild();
|
|
84
|
+
const childWidget = contentChild?.container ?? null;
|
|
85
|
+
const tabNode = this.findTabNode();
|
|
86
|
+
if (hasChanged(oldProps, newProps, "label") && childWidget && this.parent && !tabNode?.children[0]) {
|
|
87
|
+
const tabLabel = this.getParentWidget().getTabLabel(childWidget);
|
|
71
88
|
tabLabel.setLabel(newProps.label ?? "");
|
|
72
89
|
}
|
|
73
90
|
const pagePropsChanged = hasChanged(oldProps, newProps, "tabExpand") || hasChanged(oldProps, newProps, "tabFill");
|
|
74
|
-
if (
|
|
91
|
+
if (childWidget && this.parent && pagePropsChanged) {
|
|
75
92
|
this.applyPageProps();
|
|
76
93
|
}
|
|
77
94
|
}
|
|
78
95
|
attachPage() {
|
|
79
|
-
const child = this.
|
|
80
|
-
const notebook = this.
|
|
96
|
+
const child = this.getChildWidget();
|
|
97
|
+
const notebook = this.getParentWidget();
|
|
98
|
+
const tabNode = this.findTabNode();
|
|
81
99
|
let tabLabel;
|
|
82
|
-
if (
|
|
83
|
-
tabLabel =
|
|
100
|
+
if (tabNode?.children[0]) {
|
|
101
|
+
tabLabel = tabNode.children[0].container;
|
|
84
102
|
}
|
|
85
103
|
else {
|
|
86
104
|
const label = new Gtk.Label();
|
|
@@ -96,10 +114,10 @@ export class NotebookPageNode extends SlotNode {
|
|
|
96
114
|
this.applyPageProps();
|
|
97
115
|
}
|
|
98
116
|
applyPageProps() {
|
|
99
|
-
const child = this.
|
|
117
|
+
const child = this.findContentChild()?.container ?? null;
|
|
100
118
|
if (!child || !this.parent)
|
|
101
119
|
return;
|
|
102
|
-
const notebook = this.
|
|
120
|
+
const notebook = this.getParentWidget();
|
|
103
121
|
const page = notebook.getPage(child);
|
|
104
122
|
if (!page)
|
|
105
123
|
return;
|
|
@@ -111,17 +129,18 @@ export class NotebookPageNode extends SlotNode {
|
|
|
111
129
|
}
|
|
112
130
|
}
|
|
113
131
|
detachPage(childToDetach) {
|
|
114
|
-
const notebook = this.
|
|
132
|
+
const notebook = this.getParentWidget();
|
|
115
133
|
const pageNum = notebook.pageNum(childToDetach);
|
|
116
|
-
|
|
134
|
+
if (pageNum !== -1) {
|
|
135
|
+
notebook.removePage(pageNum);
|
|
136
|
+
}
|
|
117
137
|
}
|
|
118
138
|
onChildChange(oldChild) {
|
|
119
139
|
if (oldChild) {
|
|
120
140
|
this.detachPage(oldChild);
|
|
121
141
|
}
|
|
122
|
-
if (this.
|
|
142
|
+
if (this.findContentChild()) {
|
|
123
143
|
this.attachPage();
|
|
124
144
|
}
|
|
125
145
|
}
|
|
126
146
|
}
|
|
127
|
-
registerNodeClass(NotebookPageNode);
|
package/dist/nodes/notebook.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
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 { NotebookPageNode } from "./notebook-page.js";
|
|
5
|
+
import { WidgetNode } from "./widget.js";
|
|
6
|
+
export declare class NotebookNode extends WidgetNode<Gtk.Notebook, Props, NotebookPageNode> {
|
|
7
|
+
isValidChild(child: Node): boolean;
|
|
8
|
+
insertBefore(child: NotebookPageNode, before: NotebookPageNode): void;
|
|
9
|
+
removeChild(child: NotebookPageNode): void;
|
|
10
|
+
}
|
package/dist/nodes/notebook.js
CHANGED
|
@@ -1,32 +1,20 @@
|
|
|
1
|
-
import { NOTEBOOK_CLASSES } from "../generated/internal.js";
|
|
2
|
-
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import { matchesAnyClass } from "./internal/utils.js";
|
|
4
1
|
import { NotebookPageNode } from "./notebook-page.js";
|
|
5
2
|
import { WidgetNode } from "./widget.js";
|
|
6
|
-
class NotebookNode extends WidgetNode {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return matchesAnyClass(NOTEBOOK_CLASSES, containerOrClass);
|
|
10
|
-
}
|
|
11
|
-
appendChild(child) {
|
|
12
|
-
if (!(child instanceof NotebookPageNode)) {
|
|
13
|
-
throw new Error(`Cannot append '${child.typeName}' to 'Notebook': expected x.NotebookPage`);
|
|
14
|
-
}
|
|
15
|
-
child.setParent(this.container);
|
|
3
|
+
export class NotebookNode extends WidgetNode {
|
|
4
|
+
isValidChild(child) {
|
|
5
|
+
return child instanceof NotebookPageNode;
|
|
16
6
|
}
|
|
17
7
|
insertBefore(child, before) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
const beforePosition = this.container.pageNum(before.getChild());
|
|
8
|
+
const isMove = this.children.includes(child);
|
|
9
|
+
const beforePosition = this.container.pageNum(before.getChildWidget());
|
|
22
10
|
child.setPosition(beforePosition);
|
|
23
|
-
|
|
11
|
+
if (isMove) {
|
|
12
|
+
this.container.reorderChild(child.getChildWidget(), beforePosition);
|
|
13
|
+
}
|
|
14
|
+
super.insertBefore(child, before);
|
|
24
15
|
}
|
|
25
16
|
removeChild(child) {
|
|
26
|
-
if (!(child instanceof NotebookPageNode)) {
|
|
27
|
-
throw new Error(`Cannot remove '${child.typeName}' from 'Notebook': expected x.NotebookPage`);
|
|
28
|
-
}
|
|
29
17
|
child.setPosition(null);
|
|
18
|
+
super.removeChild(child);
|
|
30
19
|
}
|
|
31
20
|
}
|
|
32
|
-
registerNodeClass(NotebookNode);
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { OverlayChildProps } 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 OverlayChildNode extends VirtualNode<OverlayChildProps, WidgetNode<Gtk.Overlay>, WidgetNode> {
|
|
7
|
+
isValidChild(child: Node): boolean;
|
|
8
|
+
isValidParent(parent: Node): boolean;
|
|
9
|
+
setParent(parent: WidgetNode<Gtk.Overlay> | null): void;
|
|
10
|
+
appendChild(child: WidgetNode): void;
|
|
11
|
+
insertBefore(child: WidgetNode, before: WidgetNode): void;
|
|
12
|
+
removeChild(child: WidgetNode): void;
|
|
13
|
+
commitUpdate(oldProps: OverlayChildProps | null, newProps: OverlayChildProps): void;
|
|
14
|
+
detachDeletedInstance(): void;
|
|
15
|
+
private attachToParent;
|
|
16
|
+
private detachAllChildren;
|
|
17
|
+
}
|
|
@@ -1,109 +1,87 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { CommitPriority, scheduleAfterCommit } from "../scheduler.js";
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { hasChanged } from "./internal/props.js";
|
|
4
3
|
import { VirtualNode } from "./virtual.js";
|
|
5
4
|
import { WidgetNode } from "./widget.js";
|
|
6
|
-
class OverlayChildNode extends VirtualNode {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return type === "OverlayChild";
|
|
5
|
+
export class OverlayChildNode extends VirtualNode {
|
|
6
|
+
isValidChild(child) {
|
|
7
|
+
return child instanceof WidgetNode;
|
|
10
8
|
}
|
|
11
|
-
parent
|
|
12
|
-
|
|
13
|
-
canBeChildOf(parent) {
|
|
14
|
-
return parent instanceof WidgetNode;
|
|
9
|
+
isValidParent(parent) {
|
|
10
|
+
return parent instanceof WidgetNode && parent.container instanceof Gtk.Overlay;
|
|
15
11
|
}
|
|
16
|
-
|
|
17
|
-
if (parent
|
|
18
|
-
this.parent
|
|
12
|
+
setParent(parent) {
|
|
13
|
+
if (!parent && this.parent) {
|
|
14
|
+
this.detachAllChildren(this.parent.container);
|
|
19
15
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const parent = this.parent;
|
|
25
|
-
const children = [...this.children.values()];
|
|
26
|
-
this.children.clear();
|
|
27
|
-
for (const child of children) {
|
|
28
|
-
const currentParent = child.getParent();
|
|
29
|
-
if (currentParent && isObjectEqual(currentParent, parent)) {
|
|
30
|
-
parent.removeOverlay(child);
|
|
31
|
-
}
|
|
16
|
+
super.setParent(parent);
|
|
17
|
+
if (parent) {
|
|
18
|
+
for (const child of this.children) {
|
|
19
|
+
this.attachToParent(parent.container, child.container);
|
|
32
20
|
}
|
|
33
21
|
}
|
|
34
|
-
this.parent = null;
|
|
35
|
-
super.unmount();
|
|
36
22
|
}
|
|
37
23
|
appendChild(child) {
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
super.appendChild(child);
|
|
25
|
+
if (this.parent) {
|
|
26
|
+
this.attachToParent(this.parent.container, child.container);
|
|
40
27
|
}
|
|
41
|
-
const widget = child.container;
|
|
42
|
-
this.children.set(getNativeId(widget.handle), widget);
|
|
43
|
-
scheduleAfterCommit(() => {
|
|
44
|
-
if (this.parent) {
|
|
45
|
-
this.attachChild(widget);
|
|
46
|
-
}
|
|
47
|
-
}, CommitPriority.NORMAL);
|
|
48
28
|
}
|
|
49
|
-
insertBefore(child,
|
|
50
|
-
|
|
51
|
-
|
|
29
|
+
insertBefore(child, before) {
|
|
30
|
+
super.insertBefore(child, before);
|
|
31
|
+
if (this.parent) {
|
|
32
|
+
this.attachToParent(this.parent.container, child.container);
|
|
52
33
|
}
|
|
53
|
-
const widget = child.container;
|
|
54
|
-
this.children.set(getNativeId(widget.handle), widget);
|
|
55
|
-
scheduleAfterCommit(() => {
|
|
56
|
-
if (this.parent) {
|
|
57
|
-
this.attachChild(widget);
|
|
58
|
-
}
|
|
59
|
-
}, CommitPriority.NORMAL);
|
|
60
34
|
}
|
|
61
35
|
removeChild(child) {
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this.children.delete(getNativeId(widget.handle));
|
|
68
|
-
scheduleAfterCommit(() => {
|
|
69
|
-
if (parent) {
|
|
70
|
-
const currentParent = widget.getParent();
|
|
71
|
-
if (currentParent && isObjectEqual(currentParent, parent)) {
|
|
72
|
-
parent.removeOverlay(widget);
|
|
73
|
-
}
|
|
36
|
+
if (this.parent) {
|
|
37
|
+
const widget = child.container;
|
|
38
|
+
const currentParent = widget.getParent();
|
|
39
|
+
if (currentParent && currentParent === this.parent.container) {
|
|
40
|
+
this.parent.container.removeOverlay(widget);
|
|
74
41
|
}
|
|
75
|
-
}
|
|
42
|
+
}
|
|
43
|
+
super.removeChild(child);
|
|
76
44
|
}
|
|
77
|
-
|
|
78
|
-
super.
|
|
45
|
+
commitUpdate(oldProps, newProps) {
|
|
46
|
+
super.commitUpdate(oldProps, newProps);
|
|
79
47
|
if (!this.parent) {
|
|
80
48
|
return;
|
|
81
49
|
}
|
|
82
|
-
const measureChanged = oldProps
|
|
83
|
-
const clipOverlayChanged = oldProps
|
|
50
|
+
const measureChanged = hasChanged(oldProps, newProps, "measure");
|
|
51
|
+
const clipOverlayChanged = hasChanged(oldProps, newProps, "clipOverlay");
|
|
84
52
|
if (measureChanged || clipOverlayChanged) {
|
|
85
|
-
const parent = this.parent;
|
|
86
|
-
for (const child of this.children
|
|
53
|
+
const parent = this.parent.container;
|
|
54
|
+
for (const child of this.children) {
|
|
87
55
|
if (measureChanged) {
|
|
88
|
-
parent.setMeasureOverlay(child, newProps.measure ?? false);
|
|
56
|
+
parent.setMeasureOverlay(child.container, newProps.measure ?? false);
|
|
89
57
|
}
|
|
90
58
|
if (clipOverlayChanged) {
|
|
91
|
-
parent.setClipOverlay(child, newProps.clipOverlay ?? false);
|
|
59
|
+
parent.setClipOverlay(child.container, newProps.clipOverlay ?? false);
|
|
92
60
|
}
|
|
93
61
|
}
|
|
94
62
|
}
|
|
95
63
|
}
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
|
|
64
|
+
detachDeletedInstance() {
|
|
65
|
+
if (this.parent) {
|
|
66
|
+
this.detachAllChildren(this.parent.container);
|
|
99
67
|
}
|
|
100
|
-
|
|
68
|
+
super.detachDeletedInstance();
|
|
69
|
+
}
|
|
70
|
+
attachToParent(parent, child) {
|
|
71
|
+
parent.addOverlay(child);
|
|
101
72
|
if (this.props.measure !== undefined) {
|
|
102
|
-
|
|
73
|
+
parent.setMeasureOverlay(child, this.props.measure);
|
|
103
74
|
}
|
|
104
75
|
if (this.props.clipOverlay !== undefined) {
|
|
105
|
-
|
|
76
|
+
parent.setClipOverlay(child, this.props.clipOverlay);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
detachAllChildren(parent) {
|
|
80
|
+
for (const child of this.children) {
|
|
81
|
+
const currentParent = child.container.getParent();
|
|
82
|
+
if (currentParent && currentParent === parent) {
|
|
83
|
+
parent.removeOverlay(child.container);
|
|
84
|
+
}
|
|
106
85
|
}
|
|
107
86
|
}
|
|
108
87
|
}
|
|
109
|
-
registerNodeClass(OverlayChildNode);
|
|
@@ -1 +1,16 @@
|
|
|
1
|
+
import type { Node } from "../node.js";
|
|
2
|
+
import type { PopoverMenuWidget } from "../registry.js";
|
|
3
|
+
import type { Container, Props } from "../types.js";
|
|
4
|
+
import { MenuNode } from "./menu.js";
|
|
5
|
+
import { SlotNode } from "./slot.js";
|
|
6
|
+
import { WidgetNode } from "./widget.js";
|
|
7
|
+
type PopoverMenuChild = MenuNode | SlotNode | WidgetNode;
|
|
8
|
+
export declare class PopoverMenuNode extends WidgetNode<PopoverMenuWidget, Props, PopoverMenuChild> {
|
|
9
|
+
private menu;
|
|
10
|
+
isValidChild(child: Node): boolean;
|
|
11
|
+
constructor(typeName: string, props: Props, container: PopoverMenuWidget, rootContainer: Container);
|
|
12
|
+
appendChild(child: PopoverMenuChild): void;
|
|
13
|
+
insertBefore(child: PopoverMenuChild, before: PopoverMenuChild): void;
|
|
14
|
+
removeChild(child: PopoverMenuChild): void;
|
|
15
|
+
}
|
|
1
16
|
export {};
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import * as Gio from "@gtkx/ffi/gio";
|
|
2
2
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
-
import { POPOVER_MENU_CLASSES } from "../generated/internal.js";
|
|
4
|
-
import { registerNodeClass } from "../registry.js";
|
|
5
|
-
import { matchesAnyClass } from "./internal/utils.js";
|
|
6
3
|
import { MenuNode } from "./menu.js";
|
|
7
4
|
import { MenuModel } from "./models/menu.js";
|
|
8
5
|
import { SlotNode } from "./slot.js";
|
|
9
6
|
import { WidgetNode } from "./widget.js";
|
|
10
|
-
|
|
11
|
-
class PopoverMenuNode extends WidgetNode {
|
|
12
|
-
static priority = 1;
|
|
7
|
+
export class PopoverMenuNode extends WidgetNode {
|
|
13
8
|
menu;
|
|
14
|
-
|
|
15
|
-
return
|
|
9
|
+
isValidChild(child) {
|
|
10
|
+
return child instanceof MenuNode || child instanceof SlotNode || child instanceof WidgetNode;
|
|
16
11
|
}
|
|
17
12
|
constructor(typeName, props, container, rootContainer) {
|
|
18
13
|
super(typeName, props, container, rootContainer);
|
|
19
14
|
const application = rootContainer instanceof Gtk.Application ? rootContainer : undefined;
|
|
20
15
|
const actionGroup = new Gio.SimpleActionGroup();
|
|
21
|
-
const prefix = application ? "app" :
|
|
16
|
+
const prefix = application ? "app" : "menu";
|
|
22
17
|
this.container.insertActionGroup(prefix, actionGroup);
|
|
23
18
|
this.menu = new MenuModel("root", {}, rootContainer, actionGroup, application);
|
|
24
19
|
this.container.setMenuModel(this.menu.getMenu());
|
|
@@ -28,33 +23,25 @@ class PopoverMenuNode extends WidgetNode {
|
|
|
28
23
|
this.menu.appendChild(child);
|
|
29
24
|
return;
|
|
30
25
|
}
|
|
31
|
-
|
|
32
|
-
super.appendChild(child);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
throw new Error(`Cannot append '${child.typeName}' to 'PopoverMenu': expected MenuItem or Widget`);
|
|
26
|
+
super.appendChild(child);
|
|
36
27
|
}
|
|
37
28
|
insertBefore(child, before) {
|
|
38
29
|
if (child instanceof MenuNode) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
if (before instanceof MenuNode) {
|
|
31
|
+
this.menu.insertBefore(child, before);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.menu.appendChild(child);
|
|
35
|
+
}
|
|
44
36
|
return;
|
|
45
37
|
}
|
|
46
|
-
|
|
38
|
+
super.insertBefore(child, before);
|
|
47
39
|
}
|
|
48
40
|
removeChild(child) {
|
|
49
41
|
if (child instanceof MenuNode) {
|
|
50
42
|
this.menu.removeChild(child);
|
|
51
43
|
return;
|
|
52
44
|
}
|
|
53
|
-
|
|
54
|
-
super.removeChild(child);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
throw new Error(`Cannot remove '${child.typeName}' from 'PopoverMenu': expected MenuItem or Widget`);
|
|
45
|
+
super.removeChild(child);
|
|
58
46
|
}
|
|
59
47
|
}
|
|
60
|
-
registerNodeClass(PopoverMenuNode);
|
package/dist/nodes/scale.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { AdjustableProps, GtkScaleProps } from "../jsx.js";
|
|
3
|
+
import { AdjustableNode } from "./adjustable.js";
|
|
4
|
+
type ScaleProps = AdjustableProps & Pick<GtkScaleProps, "marks">;
|
|
5
|
+
export declare class ScaleNode extends AdjustableNode<Gtk.Scale> {
|
|
6
|
+
private appliedMarks;
|
|
7
|
+
protected applyOwnProps(oldProps: ScaleProps | null, newProps: ScaleProps): void;
|
|
8
|
+
}
|
|
1
9
|
export {};
|