@gtkx/react 0.1.48 → 0.1.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -12
- package/dist/codegen/jsx-generator.d.ts +12 -2
- package/dist/codegen/jsx-generator.js +40 -42
- package/dist/container-interfaces.d.ts +51 -0
- package/dist/container-interfaces.js +5 -0
- package/dist/factory.d.ts +1 -1
- package/dist/factory.js +17 -3
- package/dist/generated/internal.d.ts +7 -0
- package/dist/generated/internal.js +7818 -0
- package/dist/generated/jsx.d.ts +31 -22
- package/dist/generated/jsx.js +0 -7817
- package/dist/node.d.ts +4 -4
- package/dist/node.js +8 -7
- package/dist/nodes/about-dialog.d.ts +9 -0
- package/dist/nodes/about-dialog.js +14 -0
- package/dist/nodes/action-bar.d.ts +9 -0
- package/dist/nodes/action-bar.js +15 -0
- package/dist/nodes/column-view.d.ts +5 -4
- package/dist/nodes/column-view.js +28 -29
- package/dist/nodes/dropdown.d.ts +7 -17
- package/dist/nodes/dropdown.js +17 -10
- package/dist/nodes/flow-box.d.ts +9 -0
- package/dist/nodes/flow-box.js +25 -0
- package/dist/nodes/grid.d.ts +6 -3
- package/dist/nodes/grid.js +28 -26
- package/dist/nodes/list-box.d.ts +9 -0
- package/dist/nodes/list-box.js +21 -0
- package/dist/nodes/list.d.ts +4 -3
- package/dist/nodes/list.js +8 -7
- package/dist/nodes/notebook.d.ts +7 -3
- package/dist/nodes/notebook.js +31 -14
- package/dist/nodes/overlay.d.ts +2 -1
- package/dist/nodes/root.d.ts +2 -3
- package/dist/nodes/root.js +3 -3
- package/dist/nodes/slot.d.ts +1 -2
- package/dist/nodes/slot.js +2 -2
- package/dist/nodes/text-view.d.ts +2 -7
- package/dist/nodes/text-view.js +10 -49
- package/dist/nodes/widget.d.ts +6 -5
- package/dist/nodes/widget.js +9 -149
- package/dist/nodes/window.d.ts +11 -0
- package/dist/nodes/window.js +37 -0
- package/dist/props.d.ts +5 -0
- package/dist/props.js +10 -0
- package/dist/reconciler.d.ts +4 -1
- package/dist/reconciler.js +8 -6
- package/dist/types.d.ts +4 -4
- package/package.json +3 -3
package/dist/node.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { Props, ROOT_NODE_CONTAINER } from "./factory.js";
|
|
3
3
|
export declare abstract class Node<T extends Gtk.Widget | undefined = Gtk.Widget | undefined> {
|
|
4
|
-
static matches(_type: string,
|
|
4
|
+
static matches(_type: string, _existingWidget?: Gtk.Widget | typeof ROOT_NODE_CONTAINER): boolean;
|
|
5
5
|
protected signalHandlers: Map<string, number>;
|
|
6
6
|
protected widget: T;
|
|
7
7
|
protected widgetType: string;
|
|
8
8
|
protected isVirtual(): boolean;
|
|
9
|
-
constructor(type: string, props: Props,
|
|
10
|
-
protected createWidget(type: string, props: Props
|
|
9
|
+
constructor(type: string, props: Props, existingWidget?: Gtk.Widget);
|
|
10
|
+
protected createWidget(type: string, props: Props): T;
|
|
11
11
|
getWidget(): T;
|
|
12
12
|
appendChild(child: Node): void;
|
|
13
13
|
removeChild(child: Node): void;
|
|
@@ -21,5 +21,5 @@ export declare abstract class Node<T extends Gtk.Widget | undefined = Gtk.Widget
|
|
|
21
21
|
protected disconnectSignal(eventName: string): void;
|
|
22
22
|
protected connectSignal(widget: Gtk.Widget, eventName: string, handler: (...args: unknown[]) => unknown): void;
|
|
23
23
|
protected setProperty(widget: Gtk.Widget, key: string, value: unknown): void;
|
|
24
|
-
mount(
|
|
24
|
+
mount(): void;
|
|
25
25
|
}
|
package/dist/node.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { getCurrentApp } from "@gtkx/ffi";
|
|
1
2
|
import * as GObject from "@gtkx/ffi/gobject";
|
|
2
3
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
-
import { CONSTRUCTOR_PARAMS, PROP_SETTERS, SETTER_GETTERS } from "./generated/
|
|
4
|
+
import { CONSTRUCTOR_PARAMS, PROP_SETTERS, SETTER_GETTERS } from "./generated/internal.js";
|
|
4
5
|
import { isAppendable, isRemovable, isSingleChild } from "./predicates.js";
|
|
5
6
|
const extractConstructorArgs = (type, props) => {
|
|
6
7
|
const params = CONSTRUCTOR_PARAMS[type];
|
|
@@ -9,7 +10,7 @@ const extractConstructorArgs = (type, props) => {
|
|
|
9
10
|
return params.map((p) => props[p.name]);
|
|
10
11
|
};
|
|
11
12
|
export class Node {
|
|
12
|
-
static matches(_type,
|
|
13
|
+
static matches(_type, _existingWidget) {
|
|
13
14
|
return false;
|
|
14
15
|
}
|
|
15
16
|
signalHandlers = new Map();
|
|
@@ -18,16 +19,16 @@ export class Node {
|
|
|
18
19
|
isVirtual() {
|
|
19
20
|
return false;
|
|
20
21
|
}
|
|
21
|
-
constructor(type, props,
|
|
22
|
+
constructor(type, props, existingWidget) {
|
|
22
23
|
this.widgetType = type.split(".")[0] || type;
|
|
23
24
|
if (existingWidget) {
|
|
24
25
|
this.widget = existingWidget;
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
|
-
this.widget = (this.isVirtual() ? undefined : this.createWidget(type, props
|
|
28
|
+
this.widget = (this.isVirtual() ? undefined : this.createWidget(type, props));
|
|
28
29
|
this.updateProps({}, props);
|
|
29
30
|
}
|
|
30
|
-
createWidget(type, props
|
|
31
|
+
createWidget(type, props) {
|
|
31
32
|
const normalizedType = type.split(".")[0] || type;
|
|
32
33
|
// biome-ignore lint/performance/noDynamicNamespaceImportAccess: dynamic widget creation
|
|
33
34
|
const WidgetClass = Gtk[normalizedType];
|
|
@@ -35,7 +36,7 @@ export class Node {
|
|
|
35
36
|
throw new Error(`Unknown GTK widget type: ${normalizedType}`);
|
|
36
37
|
}
|
|
37
38
|
if (WidgetClass === Gtk.ApplicationWindow) {
|
|
38
|
-
return new WidgetClass(
|
|
39
|
+
return new WidgetClass(getCurrentApp());
|
|
39
40
|
}
|
|
40
41
|
return new WidgetClass(...extractConstructorArgs(normalizedType, props));
|
|
41
42
|
}
|
|
@@ -164,5 +165,5 @@ export class Node {
|
|
|
164
165
|
}
|
|
165
166
|
setter.call(widget, value);
|
|
166
167
|
}
|
|
167
|
-
mount(
|
|
168
|
+
mount() { }
|
|
168
169
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { Node } from "../node.js";
|
|
3
|
+
export declare class AboutDialogNode extends Node<Gtk.AboutDialog> {
|
|
4
|
+
static matches(type: string): boolean;
|
|
5
|
+
attachToParent(_parent: Node): void;
|
|
6
|
+
attachToParentBefore(_parent: Node, _before: Node): void;
|
|
7
|
+
detachFromParent(_parent: Node): void;
|
|
8
|
+
mount(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Node } from "../node.js";
|
|
2
|
+
export class AboutDialogNode extends Node {
|
|
3
|
+
static matches(type) {
|
|
4
|
+
return type === "AboutDialog";
|
|
5
|
+
}
|
|
6
|
+
attachToParent(_parent) { }
|
|
7
|
+
attachToParentBefore(_parent, _before) { }
|
|
8
|
+
detachFromParent(_parent) {
|
|
9
|
+
this.widget.destroy();
|
|
10
|
+
}
|
|
11
|
+
mount() {
|
|
12
|
+
this.widget.present();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { ChildContainer } from "../container-interfaces.js";
|
|
3
|
+
import { Node } from "../node.js";
|
|
4
|
+
export declare class ActionBarNode extends Node<Gtk.ActionBar> implements ChildContainer {
|
|
5
|
+
static matches(type: string): boolean;
|
|
6
|
+
attachChild(child: Gtk.Widget): void;
|
|
7
|
+
insertChildBefore(child: Gtk.Widget, _before: Gtk.Widget): void;
|
|
8
|
+
detachChild(child: Gtk.Widget): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Node } from "../node.js";
|
|
2
|
+
export class ActionBarNode extends Node {
|
|
3
|
+
static matches(type) {
|
|
4
|
+
return type === "ActionBar";
|
|
5
|
+
}
|
|
6
|
+
attachChild(child) {
|
|
7
|
+
this.widget.packStart(child);
|
|
8
|
+
}
|
|
9
|
+
insertChildBefore(child, _before) {
|
|
10
|
+
this.attachChild(child);
|
|
11
|
+
}
|
|
12
|
+
detachChild(child) {
|
|
13
|
+
this.widget.remove(child);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { type ColumnContainer, type ItemContainer } from "../container-interfaces.js";
|
|
2
3
|
import type { Props } from "../factory.js";
|
|
3
4
|
import { Node } from "../node.js";
|
|
4
5
|
import type { ColumnSortFn } from "../types.js";
|
|
5
|
-
export declare class ColumnViewNode extends Node<Gtk.ColumnView> {
|
|
6
|
+
export declare class ColumnViewNode extends Node<Gtk.ColumnView> implements ItemContainer<unknown>, ColumnContainer {
|
|
6
7
|
static matches(type: string): boolean;
|
|
7
8
|
private stringList;
|
|
8
9
|
private selectionModel;
|
|
@@ -18,7 +19,7 @@ export declare class ColumnViewNode extends Node<Gtk.ColumnView> {
|
|
|
18
19
|
private sorterChangedHandlerId;
|
|
19
20
|
private lastNotifiedColumn;
|
|
20
21
|
private lastNotifiedOrder;
|
|
21
|
-
constructor(type: string, props: Props
|
|
22
|
+
constructor(type: string, props: Props);
|
|
22
23
|
private connectSorterChangedSignal;
|
|
23
24
|
private waitForSortComplete;
|
|
24
25
|
private disconnectSorterChangedSignal;
|
|
@@ -48,7 +49,7 @@ export declare class ColumnViewColumnNode extends Node {
|
|
|
48
49
|
private listItemCache;
|
|
49
50
|
private columnId;
|
|
50
51
|
private sorter;
|
|
51
|
-
constructor(type: string, props: Props
|
|
52
|
+
constructor(type: string, props: Props);
|
|
52
53
|
getColumn(): Gtk.ColumnViewColumn;
|
|
53
54
|
getId(): string | null;
|
|
54
55
|
setColumnView(columnView: ColumnViewNode | null): void;
|
|
@@ -63,7 +64,7 @@ export declare class ColumnViewItemNode extends Node {
|
|
|
63
64
|
static matches(type: string): boolean;
|
|
64
65
|
protected isVirtual(): boolean;
|
|
65
66
|
private item;
|
|
66
|
-
constructor(type: string, props: Props
|
|
67
|
+
constructor(type: string, props: Props);
|
|
67
68
|
getItem(): unknown;
|
|
68
69
|
attachToParent(parent: Node): void;
|
|
69
70
|
attachToParentBefore(parent: Node, before: Node): void;
|
|
@@ -2,6 +2,7 @@ import { getObject, getObjectId } from "@gtkx/ffi";
|
|
|
2
2
|
import * as GObject from "@gtkx/ffi/gobject";
|
|
3
3
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
4
4
|
import { scheduleFlush } from "../batch.js";
|
|
5
|
+
import { isColumnContainer, isItemContainer, } from "../container-interfaces.js";
|
|
5
6
|
import { createFiberRoot } from "../fiber-root.js";
|
|
6
7
|
import { Node } from "../node.js";
|
|
7
8
|
import { reconciler } from "../reconciler.js";
|
|
@@ -23,8 +24,8 @@ export class ColumnViewNode extends Node {
|
|
|
23
24
|
sorterChangedHandlerId = null;
|
|
24
25
|
lastNotifiedColumn = null;
|
|
25
26
|
lastNotifiedOrder = Gtk.SortType.ASCENDING;
|
|
26
|
-
constructor(type, props
|
|
27
|
-
super(type, props
|
|
27
|
+
constructor(type, props) {
|
|
28
|
+
super(type, props);
|
|
28
29
|
this.stringList = new Gtk.StringList([]);
|
|
29
30
|
this.sortListModel = new Gtk.SortListModel(this.stringList, this.widget.getSorter());
|
|
30
31
|
this.sortListModel.setIncremental(true);
|
|
@@ -46,13 +47,12 @@ export class ColumnViewNode extends Node {
|
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
waitForSortComplete(callback) {
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
|
|
50
|
+
const sortingInProgress = this.sortListModel.getPending() > 0;
|
|
51
|
+
if (sortingInProgress) {
|
|
52
|
+
setTimeout(() => this.waitForSortComplete(callback), 0);
|
|
52
53
|
}
|
|
53
54
|
else {
|
|
54
|
-
|
|
55
|
-
setTimeout(() => this.waitForSortComplete(callback), 10);
|
|
55
|
+
callback();
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
disconnectSorterChangedSignal() {
|
|
@@ -74,8 +74,8 @@ export class ColumnViewNode extends Node {
|
|
|
74
74
|
const column = sorter.getPrimarySortColumn();
|
|
75
75
|
const order = sorter.getPrimarySortOrder();
|
|
76
76
|
const columnId = column?.getId() ?? null;
|
|
77
|
-
|
|
78
|
-
if (
|
|
77
|
+
const sortStateUnchanged = columnId === this.lastNotifiedColumn && order === this.lastNotifiedOrder;
|
|
78
|
+
if (sortStateUnchanged) {
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
this.lastNotifiedColumn = columnId;
|
|
@@ -145,9 +145,8 @@ export class ColumnViewNode extends Node {
|
|
|
145
145
|
const newLength = this.items.length;
|
|
146
146
|
if (newLength === this.committedLength)
|
|
147
147
|
return;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.stringList.splice(0, this.committedLength, indices);
|
|
148
|
+
const itemIndicesForSorter = Array.from({ length: newLength }, (_, i) => String(i));
|
|
149
|
+
this.stringList.splice(0, this.committedLength, itemIndicesForSorter);
|
|
151
150
|
this.committedLength = newLength;
|
|
152
151
|
};
|
|
153
152
|
addItem(item) {
|
|
@@ -189,11 +188,12 @@ export class ColumnViewNode extends Node {
|
|
|
189
188
|
const hadCallback = this.onSortChange !== null;
|
|
190
189
|
this.onSortChange = newOnSortChange;
|
|
191
190
|
const hasCallback = this.onSortChange !== null;
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
const callbackAdded = !hadCallback && hasCallback;
|
|
192
|
+
const callbackRemoved = hadCallback && !hasCallback;
|
|
193
|
+
if (callbackAdded) {
|
|
194
194
|
this.connectSorterChangedSignal();
|
|
195
195
|
}
|
|
196
|
-
else if (
|
|
196
|
+
else if (callbackRemoved) {
|
|
197
197
|
this.disconnectSorterChangedSignal();
|
|
198
198
|
}
|
|
199
199
|
}
|
|
@@ -226,8 +226,8 @@ export class ColumnViewColumnNode extends Node {
|
|
|
226
226
|
listItemCache = new Map();
|
|
227
227
|
columnId = null;
|
|
228
228
|
sorter = null;
|
|
229
|
-
constructor(type, props
|
|
230
|
-
super(type, props
|
|
229
|
+
constructor(type, props) {
|
|
230
|
+
super(type, props);
|
|
231
231
|
this.factory = new Gtk.SignalListItemFactory();
|
|
232
232
|
this.column = new Gtk.ColumnViewColumn(props.title, this.factory);
|
|
233
233
|
this.renderCell = props.renderCell;
|
|
@@ -308,11 +308,10 @@ export class ColumnViewColumnNode extends Node {
|
|
|
308
308
|
}
|
|
309
309
|
const columnId = this.columnId;
|
|
310
310
|
const columnView = this.columnView;
|
|
311
|
-
const wrappedSortFn = (
|
|
311
|
+
const wrappedSortFn = (stringObjPtrA, stringObjPtrB) => {
|
|
312
312
|
const items = columnView.getItems();
|
|
313
|
-
|
|
314
|
-
const
|
|
315
|
-
const stringObjB = getObject(_b, Gtk.StringObject);
|
|
313
|
+
const stringObjA = getObject(stringObjPtrA, Gtk.StringObject);
|
|
314
|
+
const stringObjB = getObject(stringObjPtrB, Gtk.StringObject);
|
|
316
315
|
const indexA = Number.parseInt(stringObjA.getString(), 10);
|
|
317
316
|
const indexB = Number.parseInt(stringObjB.getString(), 10);
|
|
318
317
|
if (Number.isNaN(indexA) || Number.isNaN(indexB))
|
|
@@ -328,12 +327,12 @@ export class ColumnViewColumnNode extends Node {
|
|
|
328
327
|
this.column.setSorter(this.sorter);
|
|
329
328
|
}
|
|
330
329
|
attachToParent(parent) {
|
|
331
|
-
if (parent
|
|
330
|
+
if (isColumnContainer(parent)) {
|
|
332
331
|
parent.addColumn(this);
|
|
333
332
|
}
|
|
334
333
|
}
|
|
335
334
|
attachToParentBefore(parent, before) {
|
|
336
|
-
if (parent
|
|
335
|
+
if (isColumnContainer(parent) && before instanceof ColumnViewColumnNode) {
|
|
337
336
|
parent.insertColumnBefore(this, before);
|
|
338
337
|
}
|
|
339
338
|
else {
|
|
@@ -341,7 +340,7 @@ export class ColumnViewColumnNode extends Node {
|
|
|
341
340
|
}
|
|
342
341
|
}
|
|
343
342
|
detachFromParent(parent) {
|
|
344
|
-
if (parent
|
|
343
|
+
if (isColumnContainer(parent)) {
|
|
345
344
|
parent.removeColumn(this);
|
|
346
345
|
}
|
|
347
346
|
}
|
|
@@ -387,20 +386,20 @@ export class ColumnViewItemNode extends Node {
|
|
|
387
386
|
return true;
|
|
388
387
|
}
|
|
389
388
|
item;
|
|
390
|
-
constructor(type, props
|
|
391
|
-
super(type, props
|
|
389
|
+
constructor(type, props) {
|
|
390
|
+
super(type, props);
|
|
392
391
|
this.item = props.item;
|
|
393
392
|
}
|
|
394
393
|
getItem() {
|
|
395
394
|
return this.item;
|
|
396
395
|
}
|
|
397
396
|
attachToParent(parent) {
|
|
398
|
-
if (parent
|
|
397
|
+
if (isItemContainer(parent)) {
|
|
399
398
|
parent.addItem(this.item);
|
|
400
399
|
}
|
|
401
400
|
}
|
|
402
401
|
attachToParentBefore(parent, before) {
|
|
403
|
-
if (parent
|
|
402
|
+
if (isItemContainer(parent) && before instanceof ColumnViewItemNode) {
|
|
404
403
|
parent.insertItemBefore(this.item, before.getItem());
|
|
405
404
|
}
|
|
406
405
|
else {
|
|
@@ -408,7 +407,7 @@ export class ColumnViewItemNode extends Node {
|
|
|
408
407
|
}
|
|
409
408
|
}
|
|
410
409
|
detachFromParent(parent) {
|
|
411
|
-
if (parent
|
|
410
|
+
if (isItemContainer(parent)) {
|
|
412
411
|
parent.removeItem(this.item);
|
|
413
412
|
}
|
|
414
413
|
}
|
package/dist/nodes/dropdown.d.ts
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { type ItemContainer } from "../container-interfaces.js";
|
|
2
3
|
import type { Props } from "../factory.js";
|
|
3
4
|
import { Node } from "../node.js";
|
|
4
|
-
|
|
5
|
-
declare class DropDownStore {
|
|
6
|
-
private stringList;
|
|
7
|
-
private items;
|
|
8
|
-
private labelFn;
|
|
9
|
-
constructor(labelFn: ItemLabelFn);
|
|
10
|
-
getModel(): Gtk.StringList;
|
|
11
|
-
append(item: unknown): void;
|
|
12
|
-
remove(item: unknown): void;
|
|
13
|
-
getItem(index: number): unknown;
|
|
14
|
-
get length(): number;
|
|
15
|
-
}
|
|
16
|
-
export declare class DropDownNode extends Node<Gtk.DropDown> {
|
|
5
|
+
export declare class DropDownNode extends Node<Gtk.DropDown> implements ItemContainer<unknown> {
|
|
17
6
|
static matches(type: string): boolean;
|
|
18
7
|
private store;
|
|
19
8
|
private onSelectionChanged?;
|
|
20
|
-
constructor(type: string, props: Props
|
|
21
|
-
|
|
9
|
+
constructor(type: string, props: Props);
|
|
10
|
+
addItem(item: unknown): void;
|
|
11
|
+
insertItemBefore(item: unknown, _beforeItem: unknown): void;
|
|
12
|
+
removeItem(item: unknown): void;
|
|
22
13
|
protected consumedProps(): Set<string>;
|
|
23
14
|
updateProps(oldProps: Props, newProps: Props): void;
|
|
24
15
|
}
|
|
@@ -26,9 +17,8 @@ export declare class DropDownItemNode extends Node<never> {
|
|
|
26
17
|
static matches(type: string): boolean;
|
|
27
18
|
protected isVirtual(): boolean;
|
|
28
19
|
private item;
|
|
29
|
-
constructor(type: string, props: Props
|
|
20
|
+
constructor(type: string, props: Props);
|
|
30
21
|
getItem(): unknown;
|
|
31
22
|
attachToParent(parent: Node): void;
|
|
32
23
|
detachFromParent(parent: Node): void;
|
|
33
24
|
}
|
|
34
|
-
export {};
|
package/dist/nodes/dropdown.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { isItemContainer } from "../container-interfaces.js";
|
|
2
3
|
import { Node } from "../node.js";
|
|
3
4
|
class DropDownStore {
|
|
4
5
|
stringList;
|
|
@@ -36,8 +37,8 @@ export class DropDownNode extends Node {
|
|
|
36
37
|
}
|
|
37
38
|
store;
|
|
38
39
|
onSelectionChanged;
|
|
39
|
-
constructor(type, props
|
|
40
|
-
super(type, props
|
|
40
|
+
constructor(type, props) {
|
|
41
|
+
super(type, props);
|
|
41
42
|
const labelFn = props.itemLabel ?? ((item) => String(item));
|
|
42
43
|
this.onSelectionChanged = props.onSelectionChanged;
|
|
43
44
|
this.store = new DropDownStore(labelFn);
|
|
@@ -51,8 +52,14 @@ export class DropDownNode extends Node {
|
|
|
51
52
|
this.connectSignal(this.widget, "notify::selected", handler);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
addItem(item) {
|
|
56
|
+
this.store.append(item);
|
|
57
|
+
}
|
|
58
|
+
insertItemBefore(item, _beforeItem) {
|
|
59
|
+
this.addItem(item);
|
|
60
|
+
}
|
|
61
|
+
removeItem(item) {
|
|
62
|
+
this.store.remove(item);
|
|
56
63
|
}
|
|
57
64
|
consumedProps() {
|
|
58
65
|
const consumed = super.consumedProps();
|
|
@@ -75,21 +82,21 @@ export class DropDownItemNode extends Node {
|
|
|
75
82
|
return true;
|
|
76
83
|
}
|
|
77
84
|
item;
|
|
78
|
-
constructor(type, props
|
|
79
|
-
super(type, props
|
|
85
|
+
constructor(type, props) {
|
|
86
|
+
super(type, props);
|
|
80
87
|
this.item = props.item;
|
|
81
88
|
}
|
|
82
89
|
getItem() {
|
|
83
90
|
return this.item;
|
|
84
91
|
}
|
|
85
92
|
attachToParent(parent) {
|
|
86
|
-
if (!(parent
|
|
93
|
+
if (!isItemContainer(parent))
|
|
87
94
|
return;
|
|
88
|
-
parent.
|
|
95
|
+
parent.addItem(this.item);
|
|
89
96
|
}
|
|
90
97
|
detachFromParent(parent) {
|
|
91
|
-
if (!(parent
|
|
98
|
+
if (!isItemContainer(parent))
|
|
92
99
|
return;
|
|
93
|
-
parent.
|
|
100
|
+
parent.removeItem(this.item);
|
|
94
101
|
}
|
|
95
102
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { ChildContainer } from "../container-interfaces.js";
|
|
3
|
+
import { Node } from "../node.js";
|
|
4
|
+
export declare class FlowBoxNode extends Node<Gtk.FlowBox> implements ChildContainer {
|
|
5
|
+
static matches(type: string): boolean;
|
|
6
|
+
attachChild(child: Gtk.Widget): void;
|
|
7
|
+
insertChildBefore(child: Gtk.Widget, before: Gtk.Widget): void;
|
|
8
|
+
detachChild(child: Gtk.Widget): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Node } from "../node.js";
|
|
2
|
+
const isFlowBoxChild = (widget) => "getIndex" in widget && "getChild" in widget && typeof widget.getIndex === "function";
|
|
3
|
+
export class FlowBoxNode extends Node {
|
|
4
|
+
static matches(type) {
|
|
5
|
+
return type === "FlowBox";
|
|
6
|
+
}
|
|
7
|
+
attachChild(child) {
|
|
8
|
+
this.widget.append(child);
|
|
9
|
+
}
|
|
10
|
+
insertChildBefore(child, before) {
|
|
11
|
+
const beforeParent = before.getParent();
|
|
12
|
+
if (beforeParent && isFlowBoxChild(beforeParent)) {
|
|
13
|
+
this.widget.insert(child, beforeParent.getIndex());
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
this.widget.append(child);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
detachChild(child) {
|
|
20
|
+
const flowBoxChild = child.getParent();
|
|
21
|
+
if (flowBoxChild) {
|
|
22
|
+
this.widget.remove(flowBoxChild);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
package/dist/nodes/grid.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { type GridContainer } from "../container-interfaces.js";
|
|
2
3
|
import type { Props } from "../factory.js";
|
|
3
4
|
import { Node } from "../node.js";
|
|
4
|
-
export declare class GridNode extends Node<Gtk.Grid> {
|
|
5
|
+
export declare class GridNode extends Node<Gtk.Grid> implements GridContainer {
|
|
5
6
|
static matches(type: string): boolean;
|
|
7
|
+
attachToGrid(child: Gtk.Widget, column: number, row: number, colSpan: number, rowSpan: number): void;
|
|
8
|
+
removeFromGrid(child: Gtk.Widget): void;
|
|
6
9
|
}
|
|
7
10
|
export declare class GridChildNode extends Node<never> {
|
|
8
11
|
static matches(type: string): boolean;
|
|
@@ -12,8 +15,8 @@ export declare class GridChildNode extends Node<never> {
|
|
|
12
15
|
private columnSpan;
|
|
13
16
|
private rowSpan;
|
|
14
17
|
private childWidget;
|
|
15
|
-
private
|
|
16
|
-
constructor(type: string, props: Props
|
|
18
|
+
private parentContainer;
|
|
19
|
+
constructor(type: string, props: Props);
|
|
17
20
|
appendChild(child: Node): void;
|
|
18
21
|
removeChild(child: Node): void;
|
|
19
22
|
private attachChildToGrid;
|
package/dist/nodes/grid.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import { isGridContainer } from "../container-interfaces.js";
|
|
1
2
|
import { Node } from "../node.js";
|
|
3
|
+
import { getNumberProp } from "../props.js";
|
|
2
4
|
export class GridNode extends Node {
|
|
3
5
|
static matches(type) {
|
|
4
6
|
return type === "Grid.Root";
|
|
5
7
|
}
|
|
8
|
+
attachToGrid(child, column, row, colSpan, rowSpan) {
|
|
9
|
+
this.widget.attach(child, column, row, colSpan, rowSpan);
|
|
10
|
+
}
|
|
11
|
+
removeFromGrid(child) {
|
|
12
|
+
this.widget.remove(child);
|
|
13
|
+
}
|
|
6
14
|
}
|
|
7
15
|
export class GridChildNode extends Node {
|
|
8
16
|
static matches(type) {
|
|
@@ -16,19 +24,19 @@ export class GridChildNode extends Node {
|
|
|
16
24
|
columnSpan;
|
|
17
25
|
rowSpan;
|
|
18
26
|
childWidget = null;
|
|
19
|
-
|
|
20
|
-
constructor(type, props
|
|
21
|
-
super(type, props
|
|
22
|
-
this.column = props
|
|
23
|
-
this.row = props
|
|
24
|
-
this.columnSpan = props
|
|
25
|
-
this.rowSpan = props
|
|
27
|
+
parentContainer = null;
|
|
28
|
+
constructor(type, props) {
|
|
29
|
+
super(type, props);
|
|
30
|
+
this.column = getNumberProp(props, "column", 0);
|
|
31
|
+
this.row = getNumberProp(props, "row", 0);
|
|
32
|
+
this.columnSpan = getNumberProp(props, "columnSpan", 1);
|
|
33
|
+
this.rowSpan = getNumberProp(props, "rowSpan", 1);
|
|
26
34
|
}
|
|
27
35
|
appendChild(child) {
|
|
28
36
|
const widget = child.getWidget();
|
|
29
37
|
if (widget) {
|
|
30
38
|
this.childWidget = widget;
|
|
31
|
-
if (this.
|
|
39
|
+
if (this.parentContainer) {
|
|
32
40
|
this.attachChildToGrid();
|
|
33
41
|
}
|
|
34
42
|
}
|
|
@@ -41,33 +49,27 @@ export class GridChildNode extends Node {
|
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
51
|
attachChildToGrid() {
|
|
44
|
-
if (!this.
|
|
52
|
+
if (!this.parentContainer || !this.childWidget)
|
|
45
53
|
return;
|
|
46
|
-
|
|
47
|
-
if (!grid)
|
|
48
|
-
return;
|
|
49
|
-
grid.attach(this.childWidget, this.column, this.row, this.columnSpan, this.rowSpan);
|
|
54
|
+
this.parentContainer.attachToGrid(this.childWidget, this.column, this.row, this.columnSpan, this.rowSpan);
|
|
50
55
|
}
|
|
51
56
|
detachChildFromGrid() {
|
|
52
|
-
if (!this.
|
|
53
|
-
return;
|
|
54
|
-
const grid = this.parentGrid.getWidget();
|
|
55
|
-
if (!grid)
|
|
57
|
+
if (!this.parentContainer || !this.childWidget)
|
|
56
58
|
return;
|
|
57
|
-
|
|
59
|
+
this.parentContainer.removeFromGrid(this.childWidget);
|
|
58
60
|
}
|
|
59
61
|
attachToParent(parent) {
|
|
60
|
-
if (parent
|
|
61
|
-
this.
|
|
62
|
+
if (isGridContainer(parent)) {
|
|
63
|
+
this.parentContainer = parent;
|
|
62
64
|
if (this.childWidget) {
|
|
63
65
|
this.attachChildToGrid();
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
detachFromParent(parent) {
|
|
68
|
-
if (parent
|
|
70
|
+
if (isGridContainer(parent)) {
|
|
69
71
|
this.detachChildFromGrid();
|
|
70
|
-
this.
|
|
72
|
+
this.parentContainer = null;
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
updateProps(oldProps, newProps) {
|
|
@@ -77,10 +79,10 @@ export class GridChildNode extends Node {
|
|
|
77
79
|
oldProps.rowSpan !== newProps.rowSpan;
|
|
78
80
|
if (positionChanged) {
|
|
79
81
|
this.detachChildFromGrid();
|
|
80
|
-
this.column = newProps
|
|
81
|
-
this.row = newProps
|
|
82
|
-
this.columnSpan = newProps
|
|
83
|
-
this.rowSpan = newProps
|
|
82
|
+
this.column = getNumberProp(newProps, "column", 0);
|
|
83
|
+
this.row = getNumberProp(newProps, "row", 0);
|
|
84
|
+
this.columnSpan = getNumberProp(newProps, "columnSpan", 1);
|
|
85
|
+
this.rowSpan = getNumberProp(newProps, "rowSpan", 1);
|
|
84
86
|
this.attachChildToGrid();
|
|
85
87
|
}
|
|
86
88
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { ChildContainer } from "../container-interfaces.js";
|
|
3
|
+
import { Node } from "../node.js";
|
|
4
|
+
export declare class ListBoxNode extends Node<Gtk.ListBox> implements ChildContainer {
|
|
5
|
+
static matches(type: string): boolean;
|
|
6
|
+
attachChild(child: Gtk.Widget): void;
|
|
7
|
+
insertChildBefore(child: Gtk.Widget, before: Gtk.Widget): void;
|
|
8
|
+
detachChild(child: Gtk.Widget): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Node } from "../node.js";
|
|
2
|
+
const isListBoxRow = (widget) => "getIndex" in widget && "isSelected" in widget && typeof widget.getIndex === "function";
|
|
3
|
+
export class ListBoxNode extends Node {
|
|
4
|
+
static matches(type) {
|
|
5
|
+
return type === "ListBox";
|
|
6
|
+
}
|
|
7
|
+
attachChild(child) {
|
|
8
|
+
this.widget.append(child);
|
|
9
|
+
}
|
|
10
|
+
insertChildBefore(child, before) {
|
|
11
|
+
if (isListBoxRow(before)) {
|
|
12
|
+
this.widget.insert(child, before.getIndex());
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
this.widget.append(child);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
detachChild(child) {
|
|
19
|
+
this.widget.remove(child);
|
|
20
|
+
}
|
|
21
|
+
}
|
package/dist/nodes/list.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { type ItemContainer } from "../container-interfaces.js";
|
|
2
3
|
import type { Props } from "../factory.js";
|
|
3
4
|
import { Node } from "../node.js";
|
|
4
|
-
export declare class ListViewNode extends Node<Gtk.ListView | Gtk.GridView> {
|
|
5
|
+
export declare class ListViewNode extends Node<Gtk.ListView | Gtk.GridView> implements ItemContainer<unknown> {
|
|
5
6
|
static matches(type: string): boolean;
|
|
6
7
|
private stringList;
|
|
7
8
|
private selectionModel;
|
|
@@ -10,7 +11,7 @@ export declare class ListViewNode extends Node<Gtk.ListView | Gtk.GridView> {
|
|
|
10
11
|
private renderItem;
|
|
11
12
|
private listItemCache;
|
|
12
13
|
private committedLength;
|
|
13
|
-
constructor(type: string, props: Props
|
|
14
|
+
constructor(type: string, props: Props);
|
|
14
15
|
private syncStringList;
|
|
15
16
|
addItem(item: unknown): void;
|
|
16
17
|
insertItemBefore(item: unknown, beforeItem: unknown): void;
|
|
@@ -22,7 +23,7 @@ export declare class ListItemNode extends Node {
|
|
|
22
23
|
static matches(type: string): boolean;
|
|
23
24
|
protected isVirtual(): boolean;
|
|
24
25
|
private item;
|
|
25
|
-
constructor(type: string, props: Props
|
|
26
|
+
constructor(type: string, props: Props);
|
|
26
27
|
getItem(): unknown;
|
|
27
28
|
attachToParent(parent: Node): void;
|
|
28
29
|
attachToParentBefore(parent: Node, before: Node): void;
|