@gtkx/react 0.15.0 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/animation/css-builder.d.ts +3 -0
- package/dist/animation/css-builder.js +53 -0
- package/dist/animation/types.d.ts +120 -0
- package/dist/errors.js +3 -0
- package/dist/factory.d.ts +3 -2
- package/dist/factory.js +1 -1
- package/dist/fiber-root.js +1 -1
- package/dist/generated/internal.d.ts +28 -1
- package/dist/generated/internal.js +93 -18
- package/dist/generated/jsx.d.ts +1672 -1483
- package/dist/generated/jsx.js +475 -0
- package/dist/host-config.d.ts +3 -1
- package/dist/host-config.js +26 -11
- package/dist/jsx.d.ts +136 -166
- package/dist/jsx.js +58 -69
- package/dist/node.d.ts +4 -1
- package/dist/node.js +14 -3
- package/dist/nodes/abstract/positional-child.d.ts +9 -0
- package/dist/nodes/abstract/positional-child.js +29 -0
- package/dist/nodes/abstract/virtual-container.d.ts +21 -0
- package/dist/nodes/abstract/virtual-container.js +68 -0
- package/dist/nodes/abstract/virtual-single-child.d.ts +18 -0
- package/dist/nodes/abstract/virtual-single-child.js +55 -0
- package/dist/nodes/action-row-child.d.ts +0 -13
- package/dist/nodes/action-row-child.js +22 -12
- package/dist/nodes/adjustable.d.ts +23 -0
- package/dist/nodes/adjustable.js +62 -0
- package/dist/nodes/alert-dialog-response.js +86 -0
- package/dist/nodes/animation.js +252 -0
- package/dist/nodes/application.js +17 -7
- package/dist/nodes/autowrapped.js +37 -43
- package/dist/nodes/calendar.js +17 -43
- package/dist/nodes/color-dialog-button.d.ts +1 -0
- package/dist/nodes/color-dialog-button.js +70 -0
- package/dist/nodes/column-view-column.d.ts +3 -3
- package/dist/nodes/column-view-column.js +1 -1
- package/dist/nodes/column-view.js +36 -39
- package/dist/nodes/dialog.d.ts +11 -0
- package/dist/nodes/dialog.js +20 -0
- package/dist/nodes/drawing-area.js +24 -7
- package/dist/nodes/event-controller.d.ts +22 -0
- package/dist/nodes/event-controller.js +96 -0
- package/dist/nodes/expander-row-child.d.ts +0 -14
- package/dist/nodes/expander-row-child.js +22 -12
- package/dist/nodes/fixed-child.js +52 -36
- package/dist/nodes/font-dialog-button.d.ts +1 -0
- package/dist/nodes/font-dialog-button.js +90 -0
- package/dist/nodes/grid-child.js +43 -45
- package/dist/nodes/grid.d.ts +1 -0
- package/dist/nodes/grid.js +41 -0
- package/dist/nodes/index.d.ts +18 -12
- package/dist/nodes/index.js +18 -12
- package/dist/nodes/internal/base-item-renderer.d.ts +29 -0
- package/dist/nodes/internal/base-item-renderer.js +88 -0
- package/dist/nodes/internal/child-attachment.d.ts +26 -0
- package/dist/nodes/internal/child-attachment.js +48 -0
- package/dist/nodes/internal/deferred-action.d.ts +9 -0
- package/dist/nodes/internal/deferred-action.js +22 -0
- package/dist/nodes/internal/list-item-renderer.d.ts +14 -15
- package/dist/nodes/internal/list-item-renderer.js +51 -77
- package/dist/nodes/internal/list-store.d.ts +5 -6
- package/dist/nodes/internal/list-store.js +29 -38
- package/dist/nodes/internal/predicates.d.ts +25 -2
- package/dist/nodes/internal/predicates.js +53 -41
- package/dist/nodes/internal/selection-model.d.ts +30 -0
- package/dist/nodes/internal/selection-model.js +87 -0
- package/dist/nodes/internal/signal-store.d.ts +9 -5
- package/dist/nodes/internal/signal-store.js +31 -31
- package/dist/nodes/internal/simple-list-store.js +6 -9
- package/dist/nodes/internal/text-buffer-controller.d.ts +43 -0
- package/dist/nodes/internal/text-buffer-controller.js +287 -0
- package/dist/nodes/internal/text-tag-styles.d.ts +43 -0
- package/dist/nodes/internal/text-tag-styles.js +52 -0
- package/dist/nodes/internal/tree-list-item-renderer.d.ts +15 -14
- package/dist/nodes/internal/tree-list-item-renderer.js +85 -96
- package/dist/nodes/internal/tree-store.d.ts +8 -11
- package/dist/nodes/internal/tree-store.js +70 -72
- package/dist/nodes/internal/utils.d.ts +7 -4
- package/dist/nodes/internal/utils.js +50 -5
- package/dist/nodes/level-bar.js +19 -54
- package/dist/nodes/list-item.d.ts +6 -3
- package/dist/nodes/list-item.js +7 -4
- package/dist/nodes/list-view.js +17 -12
- package/dist/nodes/menu.d.ts +3 -3
- package/dist/nodes/menu.js +3 -3
- package/dist/nodes/models/list.d.ts +11 -13
- package/dist/nodes/models/list.js +16 -73
- package/dist/nodes/models/menu.d.ts +8 -7
- package/dist/nodes/models/menu.js +43 -50
- package/dist/nodes/models/tree-list.d.ts +6 -12
- package/dist/nodes/models/tree-list.js +30 -93
- package/dist/nodes/navigation-page.d.ts +1 -0
- package/dist/nodes/navigation-page.js +27 -32
- package/dist/nodes/navigation-view.js +17 -28
- package/dist/nodes/notebook-page-tab.d.ts +3 -3
- package/dist/nodes/notebook-page-tab.js +11 -14
- package/dist/nodes/notebook-page.d.ts +7 -5
- package/dist/nodes/notebook-page.js +45 -25
- package/dist/nodes/notebook.js +2 -2
- package/dist/nodes/overlay-child.js +90 -30
- package/dist/nodes/pack-child.d.ts +0 -13
- package/dist/nodes/pack-child.js +22 -12
- package/dist/nodes/popover-menu.js +2 -2
- package/dist/nodes/scale.js +15 -45
- package/dist/nodes/scrolled-window.js +7 -6
- package/dist/nodes/search-bar.d.ts +1 -0
- package/dist/nodes/search-bar.js +40 -0
- package/dist/nodes/shortcut-controller.d.ts +1 -37
- package/dist/nodes/shortcut-controller.js +8 -47
- package/dist/nodes/shortcut.d.ts +5 -4
- package/dist/nodes/shortcut.js +11 -5
- package/dist/nodes/simple-list-view.js +2 -3
- package/dist/nodes/slot.d.ts +6 -9
- package/dist/nodes/slot.js +27 -42
- package/dist/nodes/source-view.js +80 -29
- package/dist/nodes/stack-page.js +20 -22
- package/dist/nodes/stack.js +19 -5
- package/dist/nodes/text-anchor.d.ts +41 -0
- package/dist/nodes/text-anchor.js +59 -0
- package/dist/nodes/text-content.d.ts +10 -0
- package/dist/nodes/text-content.js +1 -0
- package/dist/nodes/text-paintable.d.ts +17 -0
- package/dist/nodes/text-paintable.js +34 -0
- package/dist/nodes/text-segment.d.ts +15 -0
- package/dist/nodes/text-segment.js +29 -0
- package/dist/nodes/text-tag.d.ts +136 -0
- package/dist/nodes/text-tag.js +202 -0
- package/dist/nodes/text-view.d.ts +30 -0
- package/dist/nodes/text-view.js +49 -21
- package/dist/nodes/toggle-group.js +24 -32
- package/dist/nodes/toggle.d.ts +1 -15
- package/dist/nodes/toggle.js +40 -32
- package/dist/nodes/toolbar-child.js +22 -31
- package/dist/nodes/tree-list-item.d.ts +7 -5
- package/dist/nodes/tree-list-item.js +24 -36
- package/dist/nodes/tree-list-view.js +9 -7
- package/dist/nodes/virtual.d.ts +1 -1
- package/dist/nodes/web-view.d.ts +1 -0
- package/dist/nodes/web-view.js +29 -0
- package/dist/nodes/widget.d.ts +2 -16
- package/dist/nodes/widget.js +105 -294
- package/dist/nodes/window.d.ts +9 -3
- package/dist/nodes/window.js +29 -15
- package/dist/registry.d.ts +1 -1
- package/dist/render.js +9 -7
- package/dist/scheduler.d.ts +11 -1
- package/dist/scheduler.js +16 -4
- package/dist/types.d.ts +2 -136
- package/package.json +4 -4
- package/dist/nodes/action-row.js +0 -46
- package/dist/nodes/adjustment.d.ts +0 -48
- package/dist/nodes/adjustment.js +0 -70
- package/dist/nodes/calendar-mark.d.ts +0 -15
- package/dist/nodes/calendar-mark.js +0 -29
- package/dist/nodes/expander-row.js +0 -55
- package/dist/nodes/internal/constants.d.ts +0 -1
- package/dist/nodes/internal/constants.js +0 -24
- package/dist/nodes/level-bar-offset.d.ts +0 -13
- package/dist/nodes/level-bar-offset.js +0 -35
- package/dist/nodes/pack.js +0 -46
- package/dist/nodes/scale-mark.d.ts +0 -17
- package/dist/nodes/scale-mark.js +0 -38
- package/dist/nodes/source-buffer.d.ts +0 -73
- package/dist/nodes/source-buffer.js +0 -149
- package/dist/nodes/text-buffer.d.ts +0 -43
- package/dist/nodes/text-buffer.js +0 -81
- package/dist/nodes/virtual-child.d.ts +0 -18
- package/dist/nodes/virtual-child.js +0 -62
- /package/dist/{nodes/action-row.d.ts → animation/types.js} +0 -0
- /package/dist/nodes/{expander-row.d.ts → alert-dialog-response.d.ts} +0 -0
- /package/dist/nodes/{pack.d.ts → animation.d.ts} +0 -0
|
@@ -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
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,10 +80,15 @@ 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) {
|
|
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) {
|
|
88
92
|
if (!oldProps || oldProps.onSortChanged !== newProps.onSortChanged) {
|
|
89
93
|
const sorter = this.container.getSorter();
|
|
90
94
|
const onSortChanged = newProps.onSortChanged;
|
|
@@ -92,7 +96,7 @@ class ColumnViewNode extends WidgetNode {
|
|
|
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(filterProps(oldProps ?? {}, PROP_NAMES), filterProps(newProps, PROP_NAMES));
|
|
115
|
-
super.updateProps(filterProps(oldProps ?? {}, PROP_NAMES), 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);
|
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import { filterProps,
|
|
3
|
+
import { filterProps, hasChanged, matchesAnyClass } from "./internal/utils.js";
|
|
4
4
|
import { WidgetNode } from "./widget.js";
|
|
5
|
-
const
|
|
5
|
+
const OWN_PROPS = ["onDraw"];
|
|
6
6
|
class DrawingAreaNode extends WidgetNode {
|
|
7
7
|
static priority = 1;
|
|
8
|
+
pendingDrawFunc = null;
|
|
8
9
|
static matches(_type, containerOrClass) {
|
|
9
|
-
return
|
|
10
|
+
return matchesAnyClass([Gtk.DrawingArea], containerOrClass);
|
|
10
11
|
}
|
|
11
12
|
updateProps(oldProps, newProps) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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));
|
|
15
32
|
}
|
|
16
|
-
|
|
33
|
+
this.signalStore.set(this, this.container, "realize", null);
|
|
17
34
|
}
|
|
18
35
|
}
|
|
19
36
|
registerNodeClass(DrawingAreaNode);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { Node } from "../node.js";
|
|
3
|
+
import type { Container, Props } from "../types.js";
|
|
4
|
+
import type { Attachable } from "./internal/predicates.js";
|
|
5
|
+
export declare class EventControllerNode<T extends Gtk.EventController = Gtk.EventController> extends Node<T, Props> implements Attachable {
|
|
6
|
+
static priority: number;
|
|
7
|
+
static matches(type: string): boolean;
|
|
8
|
+
static createContainer(props: Props, containerClass: typeof Gtk.EventController): Gtk.EventController;
|
|
9
|
+
props: Props;
|
|
10
|
+
protected parentWidget: Gtk.Widget | null;
|
|
11
|
+
constructor(typeName: string, props: Props, container: T, rootContainer: Container);
|
|
12
|
+
canBeChildOf(parent: Node): boolean;
|
|
13
|
+
appendChild(_child: Node): void;
|
|
14
|
+
removeChild(_child: Node): void;
|
|
15
|
+
insertBefore(_child: Node, _before: Node): void;
|
|
16
|
+
attachTo(parent: Node): void;
|
|
17
|
+
detachFrom(_parent: Node): void;
|
|
18
|
+
updateProps(oldProps: Props | null, newProps: Props): void;
|
|
19
|
+
unmount(): void;
|
|
20
|
+
private applyProps;
|
|
21
|
+
private setProperty;
|
|
22
|
+
}
|
|
@@ -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
|
+
export 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, { blockable: false });
|
|
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,30 @@
|
|
|
1
1
|
import { registerNodeClass } from "../registry.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { VirtualContainerNode } from "./abstract/virtual-container.js";
|
|
3
|
+
import { matchesInterface } from "./internal/utils.js";
|
|
4
|
+
const EXPANDER_ROW_INTERFACE_METHODS = ["addRow", "addAction", "remove"];
|
|
5
|
+
class ExpanderRowRowNode extends VirtualContainerNode {
|
|
4
6
|
static priority = 1;
|
|
5
7
|
static matches(type) {
|
|
6
|
-
return type === "ExpanderRowRow"
|
|
8
|
+
return type === "ExpanderRowRow";
|
|
7
9
|
}
|
|
8
|
-
|
|
9
|
-
return
|
|
10
|
+
canBeChildOf(parent) {
|
|
11
|
+
return matchesInterface(EXPANDER_ROW_INTERFACE_METHODS, parent.container);
|
|
10
12
|
}
|
|
11
13
|
attachChild(parent, widget) {
|
|
12
|
-
|
|
13
|
-
parent.addRow(widget);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
parent.addAction(widget);
|
|
17
|
-
}
|
|
14
|
+
parent.addRow(widget);
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
|
-
|
|
17
|
+
class ExpanderRowActionNode extends VirtualContainerNode {
|
|
18
|
+
static priority = 1;
|
|
19
|
+
static matches(type) {
|
|
20
|
+
return type === "ExpanderRowAction";
|
|
21
|
+
}
|
|
22
|
+
canBeChildOf(parent) {
|
|
23
|
+
return matchesInterface(EXPANDER_ROW_INTERFACE_METHODS, parent.container);
|
|
24
|
+
}
|
|
25
|
+
attachChild(parent, widget) {
|
|
26
|
+
parent.addAction(widget);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
registerNodeClass(ExpanderRowRowNode);
|
|
30
|
+
registerNodeClass(ExpanderRowActionNode);
|
|
@@ -1,53 +1,69 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
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 FixedChildNode extends PositionalChildNode {
|
|
5
6
|
static priority = 1;
|
|
6
7
|
static matches(type) {
|
|
7
8
|
return type === "FixedChild";
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
canBeChildOf(parent) {
|
|
11
|
+
return parent.container instanceof Gtk.Fixed;
|
|
12
|
+
}
|
|
13
|
+
onChildChange(oldChild) {
|
|
14
|
+
super.onChildChange(oldChild);
|
|
15
|
+
if (this.child) {
|
|
16
|
+
this.applyTransform();
|
|
12
17
|
}
|
|
13
|
-
|
|
18
|
+
}
|
|
19
|
+
attachToParent(parent, child) {
|
|
20
|
+
const fixed = parent;
|
|
21
|
+
const x = this.props.x ?? 0;
|
|
22
|
+
const y = this.props.y ?? 0;
|
|
23
|
+
fixed.put(child, x, y);
|
|
24
|
+
}
|
|
25
|
+
detachFromParent(parent, child) {
|
|
26
|
+
parent.remove(child);
|
|
14
27
|
}
|
|
15
28
|
updateProps(oldProps, newProps) {
|
|
16
29
|
super.updateProps(oldProps, newProps);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
30
|
+
this.applyOwnProps(oldProps, newProps);
|
|
31
|
+
}
|
|
32
|
+
applyOwnProps(oldProps, newProps) {
|
|
33
|
+
if (!this.parent || !this.child) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const positionChanged = hasChanged(oldProps, newProps, "x") || hasChanged(oldProps, newProps, "y");
|
|
37
|
+
if (positionChanged) {
|
|
38
|
+
this.repositionChild();
|
|
39
|
+
}
|
|
40
|
+
else if (hasChanged(oldProps, newProps, "transform")) {
|
|
41
|
+
this.applyTransform();
|
|
21
42
|
}
|
|
22
43
|
}
|
|
23
|
-
|
|
24
|
-
const fixed = this.
|
|
44
|
+
repositionChild() {
|
|
45
|
+
const fixed = this.getTypedParent();
|
|
46
|
+
const child = this.child;
|
|
47
|
+
if (!child) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
25
50
|
const x = this.props.x ?? 0;
|
|
26
51
|
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
|
-
}
|
|
52
|
+
fixed.remove(child);
|
|
53
|
+
fixed.put(child, x, y);
|
|
54
|
+
this.applyTransform();
|
|
37
55
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
});
|
|
56
|
+
applyTransform() {
|
|
57
|
+
if (!this.child || !this.props.transform) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const fixed = this.getTypedParent();
|
|
61
|
+
const layoutManager = fixed.getLayoutManager();
|
|
62
|
+
if (!layoutManager) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const layoutChild = layoutManager.getLayoutChild(this.child);
|
|
66
|
+
layoutChild.setTransform(this.props.transform);
|
|
51
67
|
}
|
|
52
68
|
}
|
|
53
69
|
registerNodeClass(FixedChildNode);
|
|
@@ -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);
|