@gtkx/react 0.14.0 → 0.16.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 +28 -27
- package/dist/errors.js +3 -0
- package/dist/factory.d.ts +3 -2
- package/dist/factory.js +1 -1
- package/dist/generated/internal.d.ts +28 -1
- package/dist/generated/internal.js +93 -18
- package/dist/generated/jsx.d.ts +1712 -1516
- package/dist/generated/jsx.js +475 -0
- package/dist/host-config.d.ts +3 -1
- package/dist/host-config.js +31 -11
- package/dist/jsx.d.ts +147 -97
- package/dist/jsx.js +89 -21
- package/dist/node.d.ts +3 -1
- package/dist/node.js +5 -3
- package/dist/nodes/abstract/positional-child.d.ts +9 -0
- package/dist/nodes/abstract/positional-child.js +29 -0
- package/dist/nodes/abstract/positional-parent.d.ts +18 -0
- package/dist/nodes/abstract/positional-parent.js +48 -0
- package/dist/nodes/abstract/virtual-container.d.ts +17 -0
- package/dist/nodes/abstract/virtual-container.js +59 -0
- package/dist/nodes/abstract/virtual-single-child.d.ts +18 -0
- package/dist/nodes/abstract/virtual-single-child.js +54 -0
- package/dist/nodes/action-row-child.d.ts +0 -13
- package/dist/nodes/action-row-child.js +14 -12
- package/dist/nodes/action-row.d.ts +6 -1
- package/dist/nodes/action-row.js +4 -37
- package/dist/nodes/adjustable.d.ts +23 -0
- package/dist/nodes/adjustable.js +62 -0
- package/dist/nodes/alert-dialog-response.d.ts +1 -0
- package/dist/nodes/alert-dialog-response.js +86 -0
- package/dist/nodes/animation/animation-controller.d.ts +17 -0
- package/dist/nodes/animation/animation-controller.js +107 -0
- package/dist/nodes/animation/animation-factory.d.ts +15 -0
- package/dist/nodes/animation/animation-factory.js +25 -0
- package/dist/nodes/animation/animation-node.d.ts +9 -0
- package/dist/nodes/animation/animation-node.js +126 -0
- package/dist/nodes/animation/animation-style-sheet.d.ts +16 -0
- package/dist/nodes/animation/animation-style-sheet.js +74 -0
- package/dist/nodes/animation/index.d.ts +4 -0
- package/dist/nodes/animation/index.js +1 -0
- package/dist/nodes/animation/property-mapper.d.ts +11 -0
- package/dist/nodes/animation/property-mapper.js +36 -0
- package/dist/nodes/animation/transform-state.d.ts +11 -0
- package/dist/nodes/animation/transform-state.js +57 -0
- package/dist/nodes/animation/widget-registry.d.ts +5 -0
- package/dist/nodes/animation/widget-registry.js +42 -0
- package/dist/nodes/application.js +17 -7
- package/dist/nodes/autowrapped.js +37 -43
- package/dist/nodes/calendar.js +16 -55
- 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 +4 -3
- package/dist/nodes/column-view-column.js +5 -1
- package/dist/nodes/column-view.js +40 -43
- package/dist/nodes/dialog.d.ts +11 -0
- package/dist/nodes/dialog.js +20 -0
- package/dist/nodes/drawing-area.d.ts +1 -0
- package/dist/nodes/drawing-area.js +36 -0
- package/dist/nodes/event-controller.d.ts +1 -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 +14 -12
- package/dist/nodes/expander-row.d.ts +6 -1
- package/dist/nodes/expander-row.js +11 -47
- package/dist/nodes/fixed-child.js +48 -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 +39 -45
- package/dist/nodes/grid.d.ts +1 -0
- package/dist/nodes/grid.js +41 -0
- package/dist/nodes/index.d.ts +22 -6
- package/dist/nodes/index.js +22 -6
- 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/base-store.d.ts +9 -0
- package/dist/nodes/internal/base-store.js +20 -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 +8 -0
- package/dist/nodes/internal/deferred-action.js +19 -0
- package/dist/nodes/internal/list-item-renderer.d.ts +14 -14
- package/dist/nodes/internal/list-item-renderer.js +49 -70
- package/dist/nodes/internal/list-store.d.ts +7 -6
- package/dist/nodes/internal/list-store.js +20 -24
- package/dist/nodes/internal/predicates.d.ts +28 -1
- package/dist/nodes/internal/predicates.js +53 -38
- package/dist/nodes/internal/selection-model.d.ts +30 -0
- package/dist/nodes/internal/selection-model.js +91 -0
- package/dist/nodes/internal/signal-store.d.ts +5 -3
- package/dist/nodes/internal/signal-store.js +30 -21
- 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 +16 -14
- package/dist/nodes/internal/tree-list-item-renderer.js +88 -91
- package/dist/nodes/internal/tree-store.d.ts +10 -9
- package/dist/nodes/internal/tree-store.js +31 -35
- package/dist/nodes/internal/utils.d.ts +7 -4
- package/dist/nodes/internal/utils.js +50 -5
- package/dist/nodes/level-bar.js +18 -66
- package/dist/nodes/list-item.d.ts +6 -3
- package/dist/nodes/list-item.js +7 -4
- package/dist/nodes/list-view.js +19 -11
- 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 +7 -3
- package/dist/nodes/navigation-view.js +17 -28
- package/dist/nodes/notebook-page-tab.d.ts +4 -3
- package/dist/nodes/notebook-page-tab.js +5 -2
- package/dist/nodes/notebook-page.d.ts +7 -5
- package/dist/nodes/notebook-page.js +39 -16
- 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 +14 -12
- package/dist/nodes/pack.d.ts +6 -1
- package/dist/nodes/pack.js +4 -37
- package/dist/nodes/popover-menu.js +2 -2
- package/dist/nodes/scale.js +15 -58
- package/dist/nodes/scrolled-window.js +7 -5
- 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 -0
- package/dist/nodes/shortcut-controller.js +90 -0
- package/dist/nodes/shortcut.d.ts +39 -0
- package/dist/nodes/shortcut.js +52 -0
- 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.d.ts +1 -0
- package/dist/nodes/source-view.js +93 -0
- package/dist/nodes/stack-page.js +17 -13
- 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 +31 -0
- package/dist/nodes/text-view.js +73 -0
- 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 +14 -16
- 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 -4
- package/dist/nodes/virtual.d.ts +1 -1
- package/dist/nodes/widget.d.ts +3 -13
- package/dist/nodes/widget.js +117 -231
- package/dist/nodes/window.d.ts +9 -3
- package/dist/nodes/window.js +35 -19
- package/dist/registry.d.ts +1 -1
- package/dist/render.js +8 -6
- package/dist/scheduler.d.ts +11 -1
- package/dist/scheduler.js +16 -4
- package/dist/types.d.ts +2 -110
- package/package.json +3 -3
- package/dist/nodes/calendar-mark.d.ts +0 -15
- package/dist/nodes/calendar-mark.js +0 -29
- package/dist/nodes/internal/constants.d.ts +0 -1
- package/dist/nodes/internal/constants.js +0 -21
- package/dist/nodes/level-bar-offset.d.ts +0 -13
- package/dist/nodes/level-bar-offset.js +0 -35
- package/dist/nodes/scale-mark.d.ts +0 -17
- package/dist/nodes/scale-mark.js +0 -38
- package/dist/nodes/virtual-child.d.ts +0 -18
- package/dist/nodes/virtual-child.js +0 -62
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { registerNodeClass } from "../registry.js";
|
|
3
|
+
import { filterProps, hasChanged, matchesAnyClass } from "./internal/utils.js";
|
|
4
|
+
import { WidgetNode } from "./widget.js";
|
|
5
|
+
const OWN_PROPS = [
|
|
6
|
+
"fontDesc",
|
|
7
|
+
"onFontDescChanged",
|
|
8
|
+
"title",
|
|
9
|
+
"modal",
|
|
10
|
+
"language",
|
|
11
|
+
"useFont",
|
|
12
|
+
"useSize",
|
|
13
|
+
"level",
|
|
14
|
+
];
|
|
15
|
+
class FontDialogButtonNode extends WidgetNode {
|
|
16
|
+
static priority = 1;
|
|
17
|
+
dialog;
|
|
18
|
+
notifyHandler = null;
|
|
19
|
+
static matches(_type, containerOrClass) {
|
|
20
|
+
return matchesAnyClass([Gtk.FontDialogButton], containerOrClass);
|
|
21
|
+
}
|
|
22
|
+
static createContainer(_props, containerClass) {
|
|
23
|
+
const dialog = new Gtk.FontDialog();
|
|
24
|
+
const button = new containerClass(dialog);
|
|
25
|
+
return button;
|
|
26
|
+
}
|
|
27
|
+
constructor(type, props, container, rootContainer) {
|
|
28
|
+
super(type, props, container, rootContainer);
|
|
29
|
+
const dialog = container.getDialog();
|
|
30
|
+
if (!dialog) {
|
|
31
|
+
throw new Error("FontDialogButton must have a dialog");
|
|
32
|
+
}
|
|
33
|
+
this.dialog = dialog;
|
|
34
|
+
}
|
|
35
|
+
updateProps(oldProps, newProps) {
|
|
36
|
+
super.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
37
|
+
this.applyOwnProps(oldProps, newProps);
|
|
38
|
+
}
|
|
39
|
+
applyOwnProps(oldProps, newProps) {
|
|
40
|
+
if (hasChanged(oldProps, newProps, "title") && newProps.title !== undefined) {
|
|
41
|
+
this.dialog.setTitle(newProps.title);
|
|
42
|
+
}
|
|
43
|
+
if (hasChanged(oldProps, newProps, "modal")) {
|
|
44
|
+
this.dialog.setModal(newProps.modal ?? true);
|
|
45
|
+
}
|
|
46
|
+
if (hasChanged(oldProps, newProps, "language") && newProps.language) {
|
|
47
|
+
this.dialog.setLanguage(newProps.language);
|
|
48
|
+
}
|
|
49
|
+
if (hasChanged(oldProps, newProps, "useFont")) {
|
|
50
|
+
this.container.setUseFont(newProps.useFont ?? false);
|
|
51
|
+
}
|
|
52
|
+
if (hasChanged(oldProps, newProps, "useSize")) {
|
|
53
|
+
this.container.setUseSize(newProps.useSize ?? false);
|
|
54
|
+
}
|
|
55
|
+
if (hasChanged(oldProps, newProps, "level")) {
|
|
56
|
+
this.container.setLevel(newProps.level ?? Gtk.FontLevel.FONT);
|
|
57
|
+
}
|
|
58
|
+
if (hasChanged(oldProps, newProps, "fontDesc") && newProps.fontDesc) {
|
|
59
|
+
this.container.setFontDesc(newProps.fontDesc);
|
|
60
|
+
}
|
|
61
|
+
if (hasChanged(oldProps, newProps, "onFontDescChanged")) {
|
|
62
|
+
this.setupNotifyHandler(newProps.onFontDescChanged);
|
|
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") {
|
|
73
|
+
const fontDesc = this.container.getFontDesc();
|
|
74
|
+
if (fontDesc) {
|
|
75
|
+
callback(fontDesc);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
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;
|
|
86
|
+
}
|
|
87
|
+
super.unmount();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
registerNodeClass(FontDialogButtonNode);
|
package/dist/nodes/grid-child.js
CHANGED
|
@@ -1,62 +1,56 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isObjectEqual } from "@gtkx/ffi";
|
|
2
2
|
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { PositionalChildNode } from "./abstract/positional-child.js";
|
|
4
|
+
import { hasChanged } from "./internal/utils.js";
|
|
5
|
+
class GridChildNode extends PositionalChildNode {
|
|
5
6
|
static priority = 1;
|
|
6
7
|
static matches(type) {
|
|
7
8
|
return type === "GridChild";
|
|
8
9
|
}
|
|
10
|
+
attachToParent(parent, child) {
|
|
11
|
+
const grid = parent;
|
|
12
|
+
const column = this.props.column ?? 0;
|
|
13
|
+
const row = this.props.row ?? 0;
|
|
14
|
+
const columnSpan = this.props.columnSpan ?? 1;
|
|
15
|
+
const rowSpan = this.props.rowSpan ?? 1;
|
|
16
|
+
const existingChild = grid.getChildAt(column, row);
|
|
17
|
+
if (existingChild && !isObjectEqual(existingChild, child)) {
|
|
18
|
+
grid.remove(existingChild);
|
|
19
|
+
}
|
|
20
|
+
grid.attach(child, column, row, columnSpan, rowSpan);
|
|
21
|
+
}
|
|
22
|
+
detachFromParent(parent, child) {
|
|
23
|
+
parent.remove(child);
|
|
24
|
+
}
|
|
9
25
|
updateProps(oldProps, newProps) {
|
|
10
26
|
super.updateProps(oldProps, newProps);
|
|
11
|
-
|
|
12
|
-
oldProps.column !== newProps.column ||
|
|
13
|
-
oldProps.row !== newProps.row ||
|
|
14
|
-
oldProps.columnSpan !== newProps.columnSpan ||
|
|
15
|
-
oldProps.rowSpan !== newProps.rowSpan) {
|
|
16
|
-
if (this.parent && this.child) {
|
|
17
|
-
this.attachChild();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
27
|
+
this.applyOwnProps(oldProps, newProps);
|
|
20
28
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
applyOwnProps(oldProps, newProps) {
|
|
30
|
+
const positionChanged = hasChanged(oldProps, newProps, "column") ||
|
|
31
|
+
hasChanged(oldProps, newProps, "row") ||
|
|
32
|
+
hasChanged(oldProps, newProps, "columnSpan") ||
|
|
33
|
+
hasChanged(oldProps, newProps, "rowSpan");
|
|
34
|
+
if (positionChanged && this.parent && this.child) {
|
|
35
|
+
this.reattachChild();
|
|
24
36
|
}
|
|
25
|
-
return this.parent;
|
|
26
37
|
}
|
|
27
|
-
|
|
28
|
-
const grid = this.
|
|
38
|
+
reattachChild() {
|
|
39
|
+
const grid = this.getTypedParent();
|
|
40
|
+
const child = this.child;
|
|
41
|
+
if (!child) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
29
44
|
const column = this.props.column ?? 0;
|
|
30
45
|
const row = this.props.row ?? 0;
|
|
31
46
|
const columnSpan = this.props.columnSpan ?? 1;
|
|
32
47
|
const rowSpan = this.props.rowSpan ?? 1;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const currentParent = this.child.getParent();
|
|
40
|
-
if (currentParent && isObjectEqual(currentParent, grid)) {
|
|
41
|
-
grid.remove(this.child);
|
|
42
|
-
}
|
|
43
|
-
grid.attach(this.child, column, row, columnSpan, rowSpan);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
onChildChange(oldChild) {
|
|
48
|
-
const grid = this.getGrid();
|
|
49
|
-
batch(() => {
|
|
50
|
-
if (oldChild) {
|
|
51
|
-
const parent = oldChild.getParent();
|
|
52
|
-
if (parent && isObjectEqual(parent, grid)) {
|
|
53
|
-
grid.remove(oldChild);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (this.child) {
|
|
57
|
-
this.attachChild();
|
|
58
|
-
}
|
|
59
|
-
});
|
|
48
|
+
const existingChild = grid.getChildAt(column, row);
|
|
49
|
+
if (existingChild && !isObjectEqual(existingChild, child)) {
|
|
50
|
+
grid.remove(existingChild);
|
|
51
|
+
}
|
|
52
|
+
grid.remove(child);
|
|
53
|
+
grid.attach(child, column, row, columnSpan, rowSpan);
|
|
60
54
|
}
|
|
61
55
|
}
|
|
62
56
|
registerNodeClass(GridChildNode);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { registerNodeClass } from "../registry.js";
|
|
3
|
+
import { isAttachable } from "./internal/predicates.js";
|
|
4
|
+
import { matchesAnyClass } from "./internal/utils.js";
|
|
5
|
+
import { SlotNode } from "./slot.js";
|
|
6
|
+
import { WidgetNode } from "./widget.js";
|
|
7
|
+
class GridNode extends WidgetNode {
|
|
8
|
+
static priority = 0;
|
|
9
|
+
static matches(_type, containerOrClass) {
|
|
10
|
+
return matchesAnyClass([Gtk.Grid], containerOrClass);
|
|
11
|
+
}
|
|
12
|
+
isGridChild(child) {
|
|
13
|
+
return child.typeName === "GridChild";
|
|
14
|
+
}
|
|
15
|
+
appendChild(child) {
|
|
16
|
+
if (child instanceof SlotNode) {
|
|
17
|
+
super.appendChild(child);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (isAttachable(child) && this.isGridChild(child)) {
|
|
21
|
+
child.attachTo(this);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
throw new Error(`Cannot append '${child.typeName}' to 'Grid': expected x.GridChild`);
|
|
25
|
+
}
|
|
26
|
+
insertBefore(child, _before) {
|
|
27
|
+
this.appendChild(child);
|
|
28
|
+
}
|
|
29
|
+
removeChild(child) {
|
|
30
|
+
if (child instanceof SlotNode) {
|
|
31
|
+
super.removeChild(child);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (isAttachable(child) && this.isGridChild(child)) {
|
|
35
|
+
child.detachFrom(this);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
throw new Error(`Cannot remove '${child.typeName}' from 'Grid': expected x.GridChild`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
registerNodeClass(GridNode);
|
package/dist/nodes/index.d.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import "./action-row-child.js";
|
|
2
1
|
import "./action-row.js";
|
|
2
|
+
import "./adjustable.js";
|
|
3
|
+
import "./animation/index.js";
|
|
4
|
+
import "./alert-dialog-response.js";
|
|
3
5
|
import "./application.js";
|
|
4
6
|
import "./autowrapped.js";
|
|
5
|
-
import "./calendar-mark.js";
|
|
6
7
|
import "./calendar.js";
|
|
8
|
+
import "./color-dialog-button.js";
|
|
7
9
|
import "./column-view-column.js";
|
|
8
10
|
import "./column-view.js";
|
|
9
|
-
import "./
|
|
11
|
+
import "./dialog.js";
|
|
12
|
+
import "./drawing-area.js";
|
|
10
13
|
import "./expander-row.js";
|
|
11
14
|
import "./fixed-child.js";
|
|
15
|
+
import "./font-dialog-button.js";
|
|
16
|
+
import "./grid.js";
|
|
12
17
|
import "./grid-child.js";
|
|
13
|
-
import "./level-bar-offset.js";
|
|
14
18
|
import "./level-bar.js";
|
|
15
19
|
import "./list-item.js";
|
|
16
20
|
import "./list-view.js";
|
|
@@ -21,22 +25,34 @@ import "./notebook-page-tab.js";
|
|
|
21
25
|
import "./notebook-page.js";
|
|
22
26
|
import "./notebook.js";
|
|
23
27
|
import "./overlay-child.js";
|
|
24
|
-
import "./pack-child.js";
|
|
25
28
|
import "./pack.js";
|
|
26
29
|
import "./popover-menu.js";
|
|
27
|
-
import "./scale-mark.js";
|
|
28
30
|
import "./scale.js";
|
|
29
31
|
import "./scrolled-window.js";
|
|
32
|
+
import "./search-bar.js";
|
|
33
|
+
import "./shortcut-controller.js";
|
|
34
|
+
import "./shortcut.js";
|
|
35
|
+
import "./event-controller.js";
|
|
30
36
|
import "./simple-list-item.js";
|
|
31
37
|
import "./simple-list-view.js";
|
|
32
38
|
import "./slot.js";
|
|
39
|
+
import "./source-view.js";
|
|
33
40
|
import "./stack-page.js";
|
|
34
41
|
import "./stack.js";
|
|
42
|
+
import "./text-anchor.js";
|
|
43
|
+
import "./text-content.js";
|
|
44
|
+
import "./text-paintable.js";
|
|
45
|
+
import "./text-segment.js";
|
|
46
|
+
import "./text-tag.js";
|
|
47
|
+
import "./text-view.js";
|
|
35
48
|
import "./toggle.js";
|
|
36
49
|
import "./toggle-group.js";
|
|
37
50
|
import "./toolbar-child.js";
|
|
38
51
|
import "./tree-list-item.js";
|
|
39
52
|
import "./tree-list-view.js";
|
|
40
53
|
import "./virtual.js";
|
|
54
|
+
import "./action-row-child.js";
|
|
55
|
+
import "./expander-row-child.js";
|
|
56
|
+
import "./pack-child.js";
|
|
41
57
|
import "./widget.js";
|
|
42
58
|
import "./window.js";
|
package/dist/nodes/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import "./action-row-child.js";
|
|
2
1
|
import "./action-row.js";
|
|
2
|
+
import "./adjustable.js";
|
|
3
|
+
import "./animation/index.js";
|
|
4
|
+
import "./alert-dialog-response.js";
|
|
3
5
|
import "./application.js";
|
|
4
6
|
import "./autowrapped.js";
|
|
5
|
-
import "./calendar-mark.js";
|
|
6
7
|
import "./calendar.js";
|
|
8
|
+
import "./color-dialog-button.js";
|
|
7
9
|
import "./column-view-column.js";
|
|
8
10
|
import "./column-view.js";
|
|
9
|
-
import "./
|
|
11
|
+
import "./dialog.js";
|
|
12
|
+
import "./drawing-area.js";
|
|
10
13
|
import "./expander-row.js";
|
|
11
14
|
import "./fixed-child.js";
|
|
15
|
+
import "./font-dialog-button.js";
|
|
16
|
+
import "./grid.js";
|
|
12
17
|
import "./grid-child.js";
|
|
13
|
-
import "./level-bar-offset.js";
|
|
14
18
|
import "./level-bar.js";
|
|
15
19
|
import "./list-item.js";
|
|
16
20
|
import "./list-view.js";
|
|
@@ -21,22 +25,34 @@ import "./notebook-page-tab.js";
|
|
|
21
25
|
import "./notebook-page.js";
|
|
22
26
|
import "./notebook.js";
|
|
23
27
|
import "./overlay-child.js";
|
|
24
|
-
import "./pack-child.js";
|
|
25
28
|
import "./pack.js";
|
|
26
29
|
import "./popover-menu.js";
|
|
27
|
-
import "./scale-mark.js";
|
|
28
30
|
import "./scale.js";
|
|
29
31
|
import "./scrolled-window.js";
|
|
32
|
+
import "./search-bar.js";
|
|
33
|
+
import "./shortcut-controller.js";
|
|
34
|
+
import "./shortcut.js";
|
|
35
|
+
import "./event-controller.js";
|
|
30
36
|
import "./simple-list-item.js";
|
|
31
37
|
import "./simple-list-view.js";
|
|
32
38
|
import "./slot.js";
|
|
39
|
+
import "./source-view.js";
|
|
33
40
|
import "./stack-page.js";
|
|
34
41
|
import "./stack.js";
|
|
42
|
+
import "./text-anchor.js";
|
|
43
|
+
import "./text-content.js";
|
|
44
|
+
import "./text-paintable.js";
|
|
45
|
+
import "./text-segment.js";
|
|
46
|
+
import "./text-tag.js";
|
|
47
|
+
import "./text-view.js";
|
|
35
48
|
import "./toggle.js";
|
|
36
49
|
import "./toggle-group.js";
|
|
37
50
|
import "./toolbar-child.js";
|
|
38
51
|
import "./tree-list-item.js";
|
|
39
52
|
import "./tree-list-view.js";
|
|
40
53
|
import "./virtual.js";
|
|
54
|
+
import "./action-row-child.js";
|
|
55
|
+
import "./expander-row-child.js";
|
|
56
|
+
import "./pack-child.js";
|
|
41
57
|
import "./widget.js";
|
|
42
58
|
import "./window.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type Reconciler from "react-reconciler";
|
|
4
|
+
import type { SignalStore } from "./signal-store.js";
|
|
5
|
+
export declare abstract class BaseItemRenderer<TStore = unknown> {
|
|
6
|
+
protected factory: Gtk.SignalListItemFactory;
|
|
7
|
+
protected fiberRoots: Map<number, any>;
|
|
8
|
+
protected tornDown: Set<number>;
|
|
9
|
+
protected estimatedItemHeight: number | null;
|
|
10
|
+
private store;
|
|
11
|
+
protected signalStore: SignalStore;
|
|
12
|
+
protected abstract getStoreTypeName(): string;
|
|
13
|
+
constructor(signalStore: SignalStore);
|
|
14
|
+
getFactory(): Gtk.SignalListItemFactory;
|
|
15
|
+
setEstimatedItemHeight(height: number | null): void;
|
|
16
|
+
setStore(store: TStore | null): void;
|
|
17
|
+
protected getStore(): TStore;
|
|
18
|
+
dispose(): void;
|
|
19
|
+
protected abstract renderItem(ptr: number): ReactNode;
|
|
20
|
+
protected abstract getItemFromListItem(listItem: Gtk.ListItem): unknown;
|
|
21
|
+
protected abstract onSetup(listItem: Gtk.ListItem, ptr: number): Gtk.Widget;
|
|
22
|
+
protected abstract onBind(listItem: Gtk.ListItem, ptr: number, fiberRoot: Reconciler.FiberRoot): void;
|
|
23
|
+
protected abstract onUnbind(listItem: Gtk.ListItem): void;
|
|
24
|
+
protected abstract onTeardown(listItem: Gtk.ListItem, ptr: number): void;
|
|
25
|
+
protected onSetupComplete(_ptr: number): void;
|
|
26
|
+
protected createBox(): Gtk.Box;
|
|
27
|
+
protected clearBoxSizeRequest(box: Gtk.Widget): void;
|
|
28
|
+
private initializeFactory;
|
|
29
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { getNativeId } from "@gtkx/ffi";
|
|
2
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
+
import { createFiberRoot } from "../../fiber-root.js";
|
|
4
|
+
import { reconciler } from "../../reconciler.js";
|
|
5
|
+
export class BaseItemRenderer {
|
|
6
|
+
factory;
|
|
7
|
+
fiberRoots = new Map();
|
|
8
|
+
tornDown = new Set();
|
|
9
|
+
estimatedItemHeight = null;
|
|
10
|
+
store = null;
|
|
11
|
+
signalStore;
|
|
12
|
+
constructor(signalStore) {
|
|
13
|
+
this.signalStore = signalStore;
|
|
14
|
+
this.factory = new Gtk.SignalListItemFactory();
|
|
15
|
+
this.initializeFactory();
|
|
16
|
+
}
|
|
17
|
+
getFactory() {
|
|
18
|
+
return this.factory;
|
|
19
|
+
}
|
|
20
|
+
setEstimatedItemHeight(height) {
|
|
21
|
+
this.estimatedItemHeight = height;
|
|
22
|
+
}
|
|
23
|
+
setStore(store) {
|
|
24
|
+
this.store = store;
|
|
25
|
+
}
|
|
26
|
+
getStore() {
|
|
27
|
+
if (!this.store) {
|
|
28
|
+
throw new Error(`Expected ${this.getStoreTypeName()} to be set on ${this.constructor.name}`);
|
|
29
|
+
}
|
|
30
|
+
return this.store;
|
|
31
|
+
}
|
|
32
|
+
dispose() {
|
|
33
|
+
this.signalStore.clear(this);
|
|
34
|
+
this.fiberRoots.clear();
|
|
35
|
+
this.tornDown.clear();
|
|
36
|
+
}
|
|
37
|
+
onSetupComplete(_ptr) { }
|
|
38
|
+
createBox() {
|
|
39
|
+
const box = new Gtk.Box(Gtk.Orientation.HORIZONTAL);
|
|
40
|
+
box.setValign(Gtk.Align.CENTER);
|
|
41
|
+
if (this.estimatedItemHeight !== null) {
|
|
42
|
+
box.setSizeRequest(-1, this.estimatedItemHeight);
|
|
43
|
+
}
|
|
44
|
+
return box;
|
|
45
|
+
}
|
|
46
|
+
clearBoxSizeRequest(box) {
|
|
47
|
+
if (box instanceof Gtk.Box) {
|
|
48
|
+
box.setSizeRequest(-1, -1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
initializeFactory() {
|
|
52
|
+
this.signalStore.set(this, this.factory, "setup", (listItem) => {
|
|
53
|
+
const ptr = getNativeId(listItem.handle);
|
|
54
|
+
const container = this.onSetup(listItem, ptr);
|
|
55
|
+
const fiberRoot = createFiberRoot(container);
|
|
56
|
+
this.fiberRoots.set(ptr, fiberRoot);
|
|
57
|
+
const element = this.renderItem(ptr);
|
|
58
|
+
reconciler.getInstance().updateContainer(element, fiberRoot, null, () => {
|
|
59
|
+
if (this.tornDown.has(ptr))
|
|
60
|
+
return;
|
|
61
|
+
this.onSetupComplete(ptr);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
this.signalStore.set(this, this.factory, "bind", (listItem) => {
|
|
65
|
+
const ptr = getNativeId(listItem.handle);
|
|
66
|
+
const fiberRoot = this.fiberRoots.get(ptr);
|
|
67
|
+
if (!fiberRoot)
|
|
68
|
+
return;
|
|
69
|
+
this.onBind(listItem, ptr, fiberRoot);
|
|
70
|
+
});
|
|
71
|
+
this.signalStore.set(this, this.factory, "unbind", (listItem) => {
|
|
72
|
+
this.onUnbind(listItem);
|
|
73
|
+
});
|
|
74
|
+
this.signalStore.set(this, this.factory, "teardown", (listItem) => {
|
|
75
|
+
const ptr = getNativeId(listItem.handle);
|
|
76
|
+
const fiberRoot = this.fiberRoots.get(ptr);
|
|
77
|
+
if (fiberRoot) {
|
|
78
|
+
this.tornDown.add(ptr);
|
|
79
|
+
this.onTeardown(listItem, ptr);
|
|
80
|
+
reconciler.getInstance().updateContainer(null, fiberRoot, null, () => { });
|
|
81
|
+
queueMicrotask(() => {
|
|
82
|
+
this.fiberRoots.delete(ptr);
|
|
83
|
+
this.tornDown.delete(ptr);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare abstract class BaseStore<TItem = unknown> {
|
|
2
|
+
protected items: Map<string, TItem>;
|
|
3
|
+
private syncAction;
|
|
4
|
+
constructor();
|
|
5
|
+
getItem(id: string): TItem | undefined;
|
|
6
|
+
updateItem(id: string, item: TItem): void;
|
|
7
|
+
protected scheduleSync(): void;
|
|
8
|
+
protected abstract sync(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CommitPriority } from "../../scheduler.js";
|
|
2
|
+
import { DeferredAction } from "./deferred-action.js";
|
|
3
|
+
export class BaseStore {
|
|
4
|
+
items = new Map();
|
|
5
|
+
syncAction;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.syncAction = new DeferredAction(() => this.sync(), CommitPriority.LOW);
|
|
8
|
+
}
|
|
9
|
+
getItem(id) {
|
|
10
|
+
return this.items.get(id);
|
|
11
|
+
}
|
|
12
|
+
updateItem(id, item) {
|
|
13
|
+
if (this.items.has(id)) {
|
|
14
|
+
this.items.set(id, item);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
scheduleSync() {
|
|
18
|
+
this.syncAction.schedule();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
type AttachmentStrategy = {
|
|
3
|
+
type: "appendable";
|
|
4
|
+
container: Gtk.Widget & {
|
|
5
|
+
append(child: Gtk.Widget): void;
|
|
6
|
+
};
|
|
7
|
+
} | {
|
|
8
|
+
type: "addable";
|
|
9
|
+
container: Gtk.Widget & {
|
|
10
|
+
add(child: Gtk.Widget): void;
|
|
11
|
+
};
|
|
12
|
+
} | {
|
|
13
|
+
type: "content";
|
|
14
|
+
container: Gtk.Widget & {
|
|
15
|
+
setContent(content: Gtk.Widget | null): void;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
type: "singleChild";
|
|
19
|
+
container: Gtk.Widget & {
|
|
20
|
+
setChild(child: Gtk.Widget | null): void;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare const getAttachmentStrategy: (container: Gtk.Widget) => AttachmentStrategy | null;
|
|
24
|
+
export declare const attachChild: (child: Gtk.Widget, strategy: AttachmentStrategy) => void;
|
|
25
|
+
export declare const detachChild: (child: Gtk.Widget, strategy: AttachmentStrategy) => void;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { isAddable, isAppendable, isContentWidget, isRemovable, isSingleChild } from "./predicates.js";
|
|
2
|
+
export const getAttachmentStrategy = (container) => {
|
|
3
|
+
if (isAppendable(container)) {
|
|
4
|
+
return { type: "appendable", container };
|
|
5
|
+
}
|
|
6
|
+
if (isAddable(container)) {
|
|
7
|
+
return { type: "addable", container };
|
|
8
|
+
}
|
|
9
|
+
if (isContentWidget(container)) {
|
|
10
|
+
return { type: "content", container };
|
|
11
|
+
}
|
|
12
|
+
if (isSingleChild(container)) {
|
|
13
|
+
return { type: "singleChild", container };
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
export const attachChild = (child, strategy) => {
|
|
18
|
+
switch (strategy.type) {
|
|
19
|
+
case "appendable":
|
|
20
|
+
strategy.container.append(child);
|
|
21
|
+
break;
|
|
22
|
+
case "addable":
|
|
23
|
+
strategy.container.add(child);
|
|
24
|
+
break;
|
|
25
|
+
case "content":
|
|
26
|
+
strategy.container.setContent(child);
|
|
27
|
+
break;
|
|
28
|
+
case "singleChild":
|
|
29
|
+
strategy.container.setChild(child);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export const detachChild = (child, strategy) => {
|
|
34
|
+
switch (strategy.type) {
|
|
35
|
+
case "appendable":
|
|
36
|
+
case "addable":
|
|
37
|
+
if (isRemovable(strategy.container)) {
|
|
38
|
+
strategy.container.remove(child);
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
case "content":
|
|
42
|
+
strategy.container.setContent(null);
|
|
43
|
+
break;
|
|
44
|
+
case "singleChild":
|
|
45
|
+
strategy.container.setChild(null);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { scheduleAfterCommit } from "../../scheduler.js";
|
|
2
|
+
export class DeferredAction {
|
|
3
|
+
action;
|
|
4
|
+
priority;
|
|
5
|
+
scheduled = false;
|
|
6
|
+
constructor(action, priority) {
|
|
7
|
+
this.action = action;
|
|
8
|
+
this.priority = priority;
|
|
9
|
+
}
|
|
10
|
+
schedule() {
|
|
11
|
+
if (this.scheduled)
|
|
12
|
+
return;
|
|
13
|
+
this.scheduled = true;
|
|
14
|
+
scheduleAfterCommit(() => {
|
|
15
|
+
this.scheduled = false;
|
|
16
|
+
this.action();
|
|
17
|
+
}, this.priority);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
+
import type Reconciler from "react-reconciler";
|
|
4
|
+
import { BaseItemRenderer } from "./base-item-renderer.js";
|
|
3
5
|
import type { ListStore } from "./list-store.js";
|
|
4
6
|
export type RenderItemFn<T> = (item: T | null) => ReactNode;
|
|
5
|
-
export declare class ListItemRenderer {
|
|
6
|
-
private
|
|
7
|
-
private
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
private getStore;
|
|
18
|
-
private initialize;
|
|
7
|
+
export declare class ListItemRenderer extends BaseItemRenderer<ListStore> {
|
|
8
|
+
private renderFn;
|
|
9
|
+
private boundItems;
|
|
10
|
+
setRenderFn(renderFn: RenderItemFn<unknown> | null): void;
|
|
11
|
+
rebindItem(id: string): void;
|
|
12
|
+
protected getStoreTypeName(): string;
|
|
13
|
+
protected renderItem(_ptr: number): ReactNode;
|
|
14
|
+
protected getItemFromListItem(listItem: Gtk.ListItem): string | null;
|
|
15
|
+
protected onSetup(listItem: Gtk.ListItem, _ptr: number): Gtk.Widget;
|
|
16
|
+
protected onBind(listItem: Gtk.ListItem, ptr: number, fiberRoot: Reconciler.FiberRoot): void;
|
|
17
|
+
protected onUnbind(listItem: Gtk.ListItem): void;
|
|
18
|
+
protected onTeardown(_listItem: Gtk.ListItem, _ptr: number): void;
|
|
19
19
|
}
|