@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,70 @@
|
|
|
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 = ["rgba", "onRgbaChanged", "title", "modal", "withAlpha"];
|
|
6
|
+
class ColorDialogButtonNode extends WidgetNode {
|
|
7
|
+
static priority = 1;
|
|
8
|
+
dialog;
|
|
9
|
+
notifyHandler = null;
|
|
10
|
+
static matches(_type, containerOrClass) {
|
|
11
|
+
return matchesAnyClass([Gtk.ColorDialogButton], containerOrClass);
|
|
12
|
+
}
|
|
13
|
+
static createContainer(_props, containerClass) {
|
|
14
|
+
const dialog = new Gtk.ColorDialog();
|
|
15
|
+
const button = new containerClass(dialog);
|
|
16
|
+
return button;
|
|
17
|
+
}
|
|
18
|
+
constructor(type, props, container, rootContainer) {
|
|
19
|
+
super(type, props, container, rootContainer);
|
|
20
|
+
const dialog = container.getDialog();
|
|
21
|
+
if (!dialog) {
|
|
22
|
+
throw new Error("ColorDialogButton must have a dialog");
|
|
23
|
+
}
|
|
24
|
+
this.dialog = dialog;
|
|
25
|
+
}
|
|
26
|
+
updateProps(oldProps, newProps) {
|
|
27
|
+
super.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
28
|
+
this.applyOwnProps(oldProps, newProps);
|
|
29
|
+
}
|
|
30
|
+
applyOwnProps(oldProps, newProps) {
|
|
31
|
+
if (hasChanged(oldProps, newProps, "title") && newProps.title !== undefined) {
|
|
32
|
+
this.dialog.setTitle(newProps.title);
|
|
33
|
+
}
|
|
34
|
+
if (hasChanged(oldProps, newProps, "modal")) {
|
|
35
|
+
this.dialog.setModal(newProps.modal ?? true);
|
|
36
|
+
}
|
|
37
|
+
if (hasChanged(oldProps, newProps, "withAlpha")) {
|
|
38
|
+
this.dialog.setWithAlpha(newProps.withAlpha ?? true);
|
|
39
|
+
}
|
|
40
|
+
if (hasChanged(oldProps, newProps, "rgba") && newProps.rgba) {
|
|
41
|
+
this.container.setRgba(newProps.rgba);
|
|
42
|
+
}
|
|
43
|
+
if (hasChanged(oldProps, newProps, "onRgbaChanged")) {
|
|
44
|
+
this.setupNotifyHandler(newProps.onRgbaChanged);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
setupNotifyHandler(callback) {
|
|
48
|
+
if (this.notifyHandler) {
|
|
49
|
+
this.signalStore.set(this, this.container, "notify", undefined);
|
|
50
|
+
this.notifyHandler = null;
|
|
51
|
+
}
|
|
52
|
+
if (callback) {
|
|
53
|
+
this.notifyHandler = (_button, pspec) => {
|
|
54
|
+
if (pspec.getName() === "rgba") {
|
|
55
|
+
const rgba = this.container.getRgba();
|
|
56
|
+
callback(rgba);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
this.signalStore.set(this, this.container, "notify", this.notifyHandler);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
unmount() {
|
|
63
|
+
if (this.notifyHandler) {
|
|
64
|
+
this.signalStore.set(this, this.container, "notify", undefined);
|
|
65
|
+
this.notifyHandler = null;
|
|
66
|
+
}
|
|
67
|
+
super.unmount();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
registerNodeClass(ColorDialogButtonNode);
|
|
@@ -9,9 +9,10 @@ export declare class ColumnViewColumnNode extends VirtualNode<Props> {
|
|
|
9
9
|
static matches(type: string): boolean;
|
|
10
10
|
column: Gtk.ColumnViewColumn;
|
|
11
11
|
private itemRenderer;
|
|
12
|
-
constructor(typeName: string, props: Props, container: undefined, rootContainer
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
constructor(typeName: string, props: Props, container: undefined, rootContainer: Container);
|
|
13
|
+
unmount(): void;
|
|
14
|
+
setStore(model: ListStore | null): void;
|
|
15
|
+
setEstimatedRowHeight(height: number | null): void;
|
|
15
16
|
updateProps(oldProps: Props | null, newProps: Props): void;
|
|
16
17
|
}
|
|
17
18
|
export {};
|
|
@@ -11,10 +11,14 @@ export class ColumnViewColumnNode extends VirtualNode {
|
|
|
11
11
|
itemRenderer;
|
|
12
12
|
constructor(typeName, props, container, rootContainer) {
|
|
13
13
|
super(typeName, props, container, rootContainer);
|
|
14
|
-
this.itemRenderer = new ListItemRenderer();
|
|
14
|
+
this.itemRenderer = new ListItemRenderer(this.signalStore);
|
|
15
15
|
this.column = new Gtk.ColumnViewColumn();
|
|
16
16
|
this.column.setFactory(this.itemRenderer.getFactory());
|
|
17
17
|
}
|
|
18
|
+
unmount() {
|
|
19
|
+
this.itemRenderer.dispose();
|
|
20
|
+
super.unmount();
|
|
21
|
+
}
|
|
18
22
|
setStore(model) {
|
|
19
23
|
this.itemRenderer.setStore(model);
|
|
20
24
|
}
|
|
@@ -2,24 +2,23 @@ import * as Gtk from "@gtkx/ffi/gtk";
|
|
|
2
2
|
import { COLUMN_VIEW_CLASSES } from "../generated/internal.js";
|
|
3
3
|
import { registerNodeClass } from "../registry.js";
|
|
4
4
|
import { ColumnViewColumnNode } from "./column-view-column.js";
|
|
5
|
-
import { signalStore } from "./internal/signal-store.js";
|
|
6
5
|
import { filterProps, matchesAnyClass } from "./internal/utils.js";
|
|
7
6
|
import { ListItemNode } from "./list-item.js";
|
|
8
|
-
import {
|
|
7
|
+
import { ListModel } from "./models/list.js";
|
|
9
8
|
import { WidgetNode } from "./widget.js";
|
|
10
|
-
const PROP_NAMES = ["sortColumn", "sortOrder", "
|
|
9
|
+
const PROP_NAMES = ["sortColumn", "sortOrder", "onSortChanged", "estimatedRowHeight"];
|
|
11
10
|
class ColumnViewNode extends WidgetNode {
|
|
12
11
|
static priority = 1;
|
|
13
|
-
handleSortChange;
|
|
12
|
+
handleSortChange = null;
|
|
14
13
|
list;
|
|
15
14
|
columnNodes = new Set();
|
|
16
|
-
estimatedRowHeight;
|
|
15
|
+
estimatedRowHeight = null;
|
|
17
16
|
static matches(_type, containerOrClass) {
|
|
18
17
|
return matchesAnyClass(COLUMN_VIEW_CLASSES, containerOrClass);
|
|
19
18
|
}
|
|
20
19
|
constructor(typeName, props, container, rootContainer) {
|
|
21
20
|
super(typeName, props, container, rootContainer);
|
|
22
|
-
this.list = new
|
|
21
|
+
this.list = new ListModel({ owner: this, signalStore: this.signalStore }, {
|
|
23
22
|
selectionMode: props.selectionMode,
|
|
24
23
|
selected: props.selected,
|
|
25
24
|
onSelectionChanged: props.onSelectionChanged,
|
|
@@ -41,9 +40,9 @@ class ColumnViewNode extends WidgetNode {
|
|
|
41
40
|
if (existingColumn) {
|
|
42
41
|
this.container.removeColumn(existingColumn);
|
|
43
42
|
}
|
|
44
|
-
this.container.appendColumn(child.column);
|
|
45
43
|
child.setStore(this.list.getStore());
|
|
46
44
|
child.setEstimatedRowHeight(this.estimatedRowHeight);
|
|
45
|
+
this.container.appendColumn(child.column);
|
|
47
46
|
this.columnNodes.add(child);
|
|
48
47
|
}
|
|
49
48
|
insertBefore(child, before) {
|
|
@@ -58,6 +57,8 @@ class ColumnViewNode extends WidgetNode {
|
|
|
58
57
|
if (existingColumn) {
|
|
59
58
|
this.container.removeColumn(existingColumn);
|
|
60
59
|
}
|
|
60
|
+
child.setStore(this.list.getStore());
|
|
61
|
+
child.setEstimatedRowHeight(this.estimatedRowHeight);
|
|
61
62
|
if (before instanceof ColumnViewColumnNode) {
|
|
62
63
|
const beforeIndex = this.getColumnIndex(before.column);
|
|
63
64
|
this.container.insertColumn(beforeIndex, child.column);
|
|
@@ -65,8 +66,6 @@ class ColumnViewNode extends WidgetNode {
|
|
|
65
66
|
else {
|
|
66
67
|
this.container.appendColumn(child.column);
|
|
67
68
|
}
|
|
68
|
-
child.setStore(this.list.getStore());
|
|
69
|
-
child.setEstimatedRowHeight(this.estimatedRowHeight);
|
|
70
69
|
this.columnNodes.add(child);
|
|
71
70
|
}
|
|
72
71
|
removeChild(child) {
|
|
@@ -81,18 +80,23 @@ class ColumnViewNode extends WidgetNode {
|
|
|
81
80
|
if (existingColumn) {
|
|
82
81
|
this.container.removeColumn(existingColumn);
|
|
83
82
|
}
|
|
84
|
-
child.setStore(
|
|
83
|
+
child.setStore(null);
|
|
85
84
|
this.columnNodes.delete(child);
|
|
86
85
|
}
|
|
87
86
|
updateProps(oldProps, newProps) {
|
|
88
|
-
|
|
87
|
+
super.updateProps(oldProps ? filterProps(oldProps, PROP_NAMES) : null, filterProps(newProps, PROP_NAMES));
|
|
88
|
+
this.applyOwnProps(oldProps, newProps);
|
|
89
|
+
this.list.updateProps(oldProps, newProps);
|
|
90
|
+
}
|
|
91
|
+
applyOwnProps(oldProps, newProps) {
|
|
92
|
+
if (!oldProps || oldProps.onSortChanged !== newProps.onSortChanged) {
|
|
89
93
|
const sorter = this.container.getSorter();
|
|
90
|
-
const
|
|
94
|
+
const onSortChanged = newProps.onSortChanged;
|
|
91
95
|
if (sorter) {
|
|
92
96
|
this.handleSortChange = () => {
|
|
93
|
-
|
|
97
|
+
onSortChanged?.(sorter.getPrimarySortColumn()?.getId() ?? null, sorter.getPrimarySortOrder());
|
|
94
98
|
};
|
|
95
|
-
signalStore.set(this, sorter, "changed", this.handleSortChange);
|
|
99
|
+
this.signalStore.set(this, sorter, "changed", this.handleSortChange);
|
|
96
100
|
}
|
|
97
101
|
}
|
|
98
102
|
if (!oldProps || oldProps.sortColumn !== newProps.sortColumn || oldProps.sortOrder !== newProps.sortOrder) {
|
|
@@ -106,51 +110,44 @@ class ColumnViewNode extends WidgetNode {
|
|
|
106
110
|
}
|
|
107
111
|
}
|
|
108
112
|
if (!oldProps || oldProps.estimatedRowHeight !== newProps.estimatedRowHeight) {
|
|
109
|
-
this.estimatedRowHeight = newProps.estimatedRowHeight;
|
|
113
|
+
this.estimatedRowHeight = newProps.estimatedRowHeight ?? null;
|
|
110
114
|
for (const column of this.columnNodes) {
|
|
111
115
|
column.setEstimatedRowHeight(this.estimatedRowHeight);
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
|
-
this.list.updateProps(oldProps ? filterProps(oldProps, PROP_NAMES) : null, filterProps(newProps, PROP_NAMES));
|
|
115
|
-
super.updateProps(oldProps ? filterProps(oldProps, PROP_NAMES) : null, filterProps(newProps, PROP_NAMES));
|
|
116
118
|
}
|
|
117
|
-
|
|
119
|
+
findColumn(predicate) {
|
|
118
120
|
const columns = this.container.getColumns();
|
|
119
121
|
for (let i = 0; i < columns.getNItems(); i++) {
|
|
120
122
|
const column = columns.getObject(i);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
const result = predicate(column, i);
|
|
124
|
+
if (result !== null)
|
|
125
|
+
return result;
|
|
124
126
|
}
|
|
125
|
-
|
|
127
|
+
return null;
|
|
126
128
|
}
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
130
|
-
throw new Error(`Unable to find column '${
|
|
129
|
+
getColumn(columnId) {
|
|
130
|
+
const column = this.findColumn((col) => (col.getId() === columnId ? col : null));
|
|
131
|
+
if (!column) {
|
|
132
|
+
throw new Error(`Unable to find column '${columnId}' in ColumnView`);
|
|
131
133
|
}
|
|
132
|
-
return
|
|
134
|
+
return column;
|
|
133
135
|
}
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return i;
|
|
140
|
-
}
|
|
136
|
+
getColumnIndex(column) {
|
|
137
|
+
const targetId = column.getId();
|
|
138
|
+
const index = this.findColumn((col, i) => (col.getId() === targetId ? i : null));
|
|
139
|
+
if (index === null) {
|
|
140
|
+
throw new Error(`Unable to find column '${targetId}' in ColumnView`);
|
|
141
141
|
}
|
|
142
|
-
return
|
|
142
|
+
return index;
|
|
143
143
|
}
|
|
144
144
|
findColumnInView(column) {
|
|
145
|
-
const columns = this.container.getColumns();
|
|
146
145
|
const targetId = column.getId();
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
return null;
|
|
146
|
+
return this.findColumn((col) => (col.getId() === targetId ? col : null));
|
|
147
|
+
}
|
|
148
|
+
unmount() {
|
|
149
|
+
this.columnNodes.clear();
|
|
150
|
+
super.unmount();
|
|
154
151
|
}
|
|
155
152
|
}
|
|
156
153
|
registerNodeClass(ColumnViewNode);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Adw from "@gtkx/ffi/adw";
|
|
2
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
+
import type { Container, ContainerClass } from "../types.js";
|
|
4
|
+
import { WidgetNode } from "./widget.js";
|
|
5
|
+
export declare class DialogNode extends WidgetNode<Adw.Dialog> {
|
|
6
|
+
static priority: number;
|
|
7
|
+
parent: Gtk.Window | null;
|
|
8
|
+
static matches(_type: string, containerOrClass?: Container | ContainerClass | null): boolean;
|
|
9
|
+
mount(): void;
|
|
10
|
+
unmount(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as Adw from "@gtkx/ffi/adw";
|
|
2
|
+
import { registerNodeClass } from "../registry.js";
|
|
3
|
+
import { matchesAnyClass } from "./internal/utils.js";
|
|
4
|
+
import { WidgetNode } from "./widget.js";
|
|
5
|
+
export class DialogNode extends WidgetNode {
|
|
6
|
+
static priority = 1;
|
|
7
|
+
parent = null;
|
|
8
|
+
static matches(_type, containerOrClass) {
|
|
9
|
+
return matchesAnyClass([Adw.Dialog], containerOrClass);
|
|
10
|
+
}
|
|
11
|
+
mount() {
|
|
12
|
+
this.container.present(this.parent ?? undefined);
|
|
13
|
+
super.mount();
|
|
14
|
+
}
|
|
15
|
+
unmount() {
|
|
16
|
+
this.container.forceClose();
|
|
17
|
+
super.unmount();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
registerNodeClass(DialogNode);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
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 = ["onDraw"];
|
|
6
|
+
class DrawingAreaNode extends WidgetNode {
|
|
7
|
+
static priority = 1;
|
|
8
|
+
pendingDrawFunc = null;
|
|
9
|
+
static matches(_type, containerOrClass) {
|
|
10
|
+
return matchesAnyClass([Gtk.DrawingArea], containerOrClass);
|
|
11
|
+
}
|
|
12
|
+
updateProps(oldProps, newProps) {
|
|
13
|
+
super.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
14
|
+
this.applyOwnProps(oldProps, newProps);
|
|
15
|
+
}
|
|
16
|
+
applyOwnProps(oldProps, newProps) {
|
|
17
|
+
if (hasChanged(oldProps, newProps, "onDraw") && newProps.onDraw) {
|
|
18
|
+
if (this.container.getRealized()) {
|
|
19
|
+
this.container.setDrawFunc(newProps.onDraw);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.pendingDrawFunc = newProps.onDraw;
|
|
23
|
+
this.signalStore.set(this, this.container, "realize", this.onRealize.bind(this));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
onRealize() {
|
|
28
|
+
if (this.pendingDrawFunc) {
|
|
29
|
+
const drawFunc = this.pendingDrawFunc;
|
|
30
|
+
this.pendingDrawFunc = null;
|
|
31
|
+
queueMicrotask(() => this.container.setDrawFunc(drawFunc));
|
|
32
|
+
}
|
|
33
|
+
this.signalStore.set(this, this.container, "realize", null);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
registerNodeClass(DrawingAreaNode);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { CONTROLLER_CLASSES, CONTROLLER_CONSTRUCTOR_PROPS } from "../generated/internal.js";
|
|
3
|
+
import { Node } from "../node.js";
|
|
4
|
+
import { registerNodeClass } from "../registry.js";
|
|
5
|
+
import { propNameToSignalName, resolvePropMeta, resolveSignal } from "./internal/utils.js";
|
|
6
|
+
import { WidgetNode } from "./widget.js";
|
|
7
|
+
const G_TYPE_INVALID = 0;
|
|
8
|
+
class EventControllerNode extends Node {
|
|
9
|
+
static priority = 1;
|
|
10
|
+
static matches(type) {
|
|
11
|
+
return type in CONTROLLER_CLASSES;
|
|
12
|
+
}
|
|
13
|
+
static createContainer(props, containerClass) {
|
|
14
|
+
const typeName = containerClass.glibTypeName;
|
|
15
|
+
if (typeName === "GtkDropTarget") {
|
|
16
|
+
const actions = props.actions ?? 0;
|
|
17
|
+
return new Gtk.DropTarget(G_TYPE_INVALID, actions);
|
|
18
|
+
}
|
|
19
|
+
const args = (CONTROLLER_CONSTRUCTOR_PROPS[typeName] ?? []).map((name) => props[name]);
|
|
20
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic constructor invocation
|
|
21
|
+
return new containerClass(...args);
|
|
22
|
+
}
|
|
23
|
+
props;
|
|
24
|
+
parentWidget = null;
|
|
25
|
+
constructor(typeName, props, container, rootContainer) {
|
|
26
|
+
super(typeName, props, container, rootContainer);
|
|
27
|
+
this.props = props;
|
|
28
|
+
}
|
|
29
|
+
canBeChildOf(parent) {
|
|
30
|
+
return parent instanceof WidgetNode;
|
|
31
|
+
}
|
|
32
|
+
appendChild(_child) { }
|
|
33
|
+
removeChild(_child) { }
|
|
34
|
+
insertBefore(_child, _before) { }
|
|
35
|
+
attachTo(parent) {
|
|
36
|
+
if (parent instanceof WidgetNode) {
|
|
37
|
+
this.parentWidget = parent.container;
|
|
38
|
+
parent.container.addController(this.container);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
detachFrom(_parent) {
|
|
42
|
+
if (this.parentWidget) {
|
|
43
|
+
this.parentWidget.removeController(this.container);
|
|
44
|
+
}
|
|
45
|
+
this.parentWidget = null;
|
|
46
|
+
}
|
|
47
|
+
updateProps(oldProps, newProps) {
|
|
48
|
+
this.props = newProps;
|
|
49
|
+
this.applyProps(oldProps, newProps);
|
|
50
|
+
}
|
|
51
|
+
unmount() {
|
|
52
|
+
if (this.parentWidget) {
|
|
53
|
+
this.parentWidget.removeController(this.container);
|
|
54
|
+
}
|
|
55
|
+
this.parentWidget = null;
|
|
56
|
+
super.unmount();
|
|
57
|
+
}
|
|
58
|
+
applyProps(oldProps, newProps) {
|
|
59
|
+
if (!this.container) {
|
|
60
|
+
throw new Error(`EventControllerNode.applyProps: container is undefined for ${this.typeName}`);
|
|
61
|
+
}
|
|
62
|
+
const propNames = new Set([...Object.keys(oldProps ?? {}), ...Object.keys(newProps ?? {})]);
|
|
63
|
+
for (const name of propNames) {
|
|
64
|
+
if (name === "children")
|
|
65
|
+
continue;
|
|
66
|
+
const oldValue = oldProps?.[name];
|
|
67
|
+
const newValue = newProps[name];
|
|
68
|
+
if (oldValue === newValue)
|
|
69
|
+
continue;
|
|
70
|
+
const signalName = propNameToSignalName(name);
|
|
71
|
+
if (resolveSignal(this.container, signalName)) {
|
|
72
|
+
const handler = typeof newValue === "function" ? newValue : undefined;
|
|
73
|
+
this.signalStore.set(this, this.container, signalName, handler);
|
|
74
|
+
}
|
|
75
|
+
else if (newValue !== undefined) {
|
|
76
|
+
this.setProperty(name, newValue);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
setProperty(name, value) {
|
|
81
|
+
if (name === "types" && this.container instanceof Gtk.DropTarget) {
|
|
82
|
+
const types = value;
|
|
83
|
+
this.container.setGtypes(types.length, types);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const propMeta = resolvePropMeta(this.container, name);
|
|
87
|
+
if (propMeta) {
|
|
88
|
+
const [, setterName] = propMeta;
|
|
89
|
+
const setterFn = this.container[setterName];
|
|
90
|
+
if (typeof setterFn === "function") {
|
|
91
|
+
setterFn.call(this.container, value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
registerNodeClass(EventControllerNode);
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
import type * as Adw from "@gtkx/ffi/adw";
|
|
2
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
-
import { VirtualChildNode } from "./virtual-child.js";
|
|
4
|
-
type ExpanderRowWidget = Adw.ExpanderRow & {
|
|
5
|
-
addRow(child: Gtk.Widget): void;
|
|
6
|
-
addAction(widget: Gtk.Widget): void;
|
|
7
|
-
remove(child: Gtk.Widget): void;
|
|
8
|
-
};
|
|
9
|
-
export declare class ExpanderRowChild extends VirtualChildNode<ExpanderRowWidget> {
|
|
10
|
-
static priority: number;
|
|
11
|
-
static matches(type: string): boolean;
|
|
12
|
-
protected getPositionLabel(): string;
|
|
13
|
-
protected attachChild(parent: ExpanderRowWidget, widget: Gtk.Widget): void;
|
|
14
|
-
}
|
|
15
1
|
export {};
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { registerNodeClass } from "../registry.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { VirtualContainerNode } from "./abstract/virtual-container.js";
|
|
3
|
+
class ExpanderRowRowNode extends VirtualContainerNode {
|
|
4
4
|
static priority = 1;
|
|
5
5
|
static matches(type) {
|
|
6
|
-
return type === "ExpanderRowRow"
|
|
6
|
+
return type === "ExpanderRowRow";
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
attachChild(parent, widget) {
|
|
9
|
+
parent.addRow(widget);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
class ExpanderRowActionNode extends VirtualContainerNode {
|
|
13
|
+
static priority = 1;
|
|
14
|
+
static matches(type) {
|
|
15
|
+
return type === "ExpanderRowAction";
|
|
10
16
|
}
|
|
11
17
|
attachChild(parent, widget) {
|
|
12
|
-
|
|
13
|
-
parent.addRow(widget);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
parent.addAction(widget);
|
|
17
|
-
}
|
|
18
|
+
parent.addAction(widget);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
registerNodeClass(
|
|
21
|
+
registerNodeClass(ExpanderRowRowNode);
|
|
22
|
+
registerNodeClass(ExpanderRowActionNode);
|
|
@@ -1,54 +1,18 @@
|
|
|
1
1
|
import * as Adw from "@gtkx/ffi/adw";
|
|
2
2
|
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { SlotNode } from "./slot.js";
|
|
7
|
-
import { WidgetNode } from "./widget.js";
|
|
8
|
-
class ExpanderRowNode extends WidgetNode {
|
|
3
|
+
import { PositionalParentNode } from "./abstract/positional-parent.js";
|
|
4
|
+
import { matchesAnyClass } from "./internal/utils.js";
|
|
5
|
+
class ExpanderRowNode extends PositionalParentNode {
|
|
9
6
|
static priority = -1;
|
|
7
|
+
acceptedPositionalChildTypes = new Set([
|
|
8
|
+
"ExpanderRowRow",
|
|
9
|
+
"ExpanderRowAction",
|
|
10
|
+
"ActionRowPrefix",
|
|
11
|
+
"ActionRowSuffix",
|
|
12
|
+
]);
|
|
13
|
+
containerTypeName = "ExpanderRow";
|
|
10
14
|
static matches(_type, containerOrClass) {
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
appendChild(child) {
|
|
14
|
-
if (child instanceof ExpanderRowChild) {
|
|
15
|
-
child.setParent(this.container);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (child instanceof ActionRowChild) {
|
|
19
|
-
child.setParent(this.container);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (child instanceof SlotNode || child instanceof WidgetNode) {
|
|
23
|
-
super.appendChild(child);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
throw new Error(`Cannot append '${child.typeName}' to 'ExpanderRow': expected x.ExpanderRowRow, x.ExpanderRowAction, x.ActionRowPrefix, x.ActionRowSuffix, or Widget`);
|
|
27
|
-
}
|
|
28
|
-
insertBefore(child, before) {
|
|
29
|
-
if (child instanceof ExpanderRowChild) {
|
|
30
|
-
child.setParent(this.container);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (child instanceof ActionRowChild) {
|
|
34
|
-
child.setParent(this.container);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (child instanceof SlotNode || child instanceof WidgetNode) {
|
|
38
|
-
super.insertBefore(child, before);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
throw new Error(`Cannot insert '${child.typeName}' into 'ExpanderRow': expected x.ExpanderRowRow, x.ExpanderRowAction, x.ActionRowPrefix, x.ActionRowSuffix, or Widget`);
|
|
42
|
-
}
|
|
43
|
-
removeChild(child) {
|
|
44
|
-
if (child instanceof ExpanderRowChild || child instanceof ActionRowChild) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
if (child instanceof SlotNode || child instanceof WidgetNode) {
|
|
48
|
-
super.removeChild(child);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
throw new Error(`Cannot remove '${child.typeName}' from 'ExpanderRow': expected x.ExpanderRowRow, x.ExpanderRowAction, x.ActionRowPrefix, x.ActionRowSuffix, or Widget`);
|
|
15
|
+
return matchesAnyClass([Adw.ExpanderRow], containerOrClass);
|
|
52
16
|
}
|
|
53
17
|
}
|
|
54
18
|
registerNodeClass(ExpanderRowNode);
|
|
@@ -1,53 +1,65 @@
|
|
|
1
|
-
import { batch, isObjectEqual } from "@gtkx/ffi";
|
|
2
1
|
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { PositionalChildNode } from "./abstract/positional-child.js";
|
|
3
|
+
import { hasChanged } from "./internal/utils.js";
|
|
4
|
+
class FixedChildNode extends PositionalChildNode {
|
|
5
5
|
static priority = 1;
|
|
6
6
|
static matches(type) {
|
|
7
7
|
return type === "FixedChild";
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
onChildChange(oldChild) {
|
|
10
|
+
super.onChildChange(oldChild);
|
|
11
|
+
if (this.child) {
|
|
12
|
+
this.applyTransform();
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
}
|
|
15
|
+
attachToParent(parent, child) {
|
|
16
|
+
const fixed = parent;
|
|
17
|
+
const x = this.props.x ?? 0;
|
|
18
|
+
const y = this.props.y ?? 0;
|
|
19
|
+
fixed.put(child, x, y);
|
|
20
|
+
}
|
|
21
|
+
detachFromParent(parent, child) {
|
|
22
|
+
parent.remove(child);
|
|
14
23
|
}
|
|
15
24
|
updateProps(oldProps, newProps) {
|
|
16
25
|
super.updateProps(oldProps, newProps);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
this.applyOwnProps(oldProps, newProps);
|
|
27
|
+
}
|
|
28
|
+
applyOwnProps(oldProps, newProps) {
|
|
29
|
+
if (!this.parent || !this.child) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const positionChanged = hasChanged(oldProps, newProps, "x") || hasChanged(oldProps, newProps, "y");
|
|
33
|
+
if (positionChanged) {
|
|
34
|
+
this.repositionChild();
|
|
35
|
+
}
|
|
36
|
+
else if (hasChanged(oldProps, newProps, "transform")) {
|
|
37
|
+
this.applyTransform();
|
|
21
38
|
}
|
|
22
39
|
}
|
|
23
|
-
|
|
24
|
-
const fixed = this.
|
|
40
|
+
repositionChild() {
|
|
41
|
+
const fixed = this.getTypedParent();
|
|
42
|
+
const child = this.child;
|
|
43
|
+
if (!child) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
25
46
|
const x = this.props.x ?? 0;
|
|
26
47
|
const y = this.props.y ?? 0;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const currentParent = child.getParent();
|
|
31
|
-
if (currentParent && isObjectEqual(currentParent, fixed)) {
|
|
32
|
-
fixed.remove(child);
|
|
33
|
-
}
|
|
34
|
-
fixed.put(child, x, y);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
48
|
+
fixed.remove(child);
|
|
49
|
+
fixed.put(child, x, y);
|
|
50
|
+
this.applyTransform();
|
|
37
51
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
});
|
|
52
|
+
applyTransform() {
|
|
53
|
+
if (!this.child || !this.props.transform) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const fixed = this.getTypedParent();
|
|
57
|
+
const layoutManager = fixed.getLayoutManager();
|
|
58
|
+
if (!layoutManager) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const layoutChild = layoutManager.getLayoutChild(this.child);
|
|
62
|
+
layoutChild.setTransform(this.props.transform);
|
|
51
63
|
}
|
|
52
64
|
}
|
|
53
65
|
registerNodeClass(FixedChildNode);
|