@gtkx/react 0.1.48 → 0.1.49
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/dist/codegen/jsx-generator.js +4 -21
- 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/jsx.d.ts +5 -11
- package/dist/node.d.ts +4 -4
- package/dist/node.js +7 -6
- 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.js +4 -5
- package/dist/types.d.ts +4 -4
- package/package.json +3 -3
|
@@ -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;
|
package/dist/nodes/list.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getObject, getObjectId } from "@gtkx/ffi";
|
|
2
2
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
3
|
import { scheduleFlush } from "../batch.js";
|
|
4
|
+
import { isItemContainer } from "../container-interfaces.js";
|
|
4
5
|
import { createFiberRoot } from "../fiber-root.js";
|
|
5
6
|
import { Node } from "../node.js";
|
|
6
7
|
import { reconciler } from "../reconciler.js";
|
|
@@ -15,8 +16,8 @@ export class ListViewNode extends Node {
|
|
|
15
16
|
renderItem;
|
|
16
17
|
listItemCache = new Map();
|
|
17
18
|
committedLength = 0;
|
|
18
|
-
constructor(type, props
|
|
19
|
-
super(type, props
|
|
19
|
+
constructor(type, props) {
|
|
20
|
+
super(type, props);
|
|
20
21
|
this.stringList = new Gtk.StringList([]);
|
|
21
22
|
this.selectionModel = new Gtk.SingleSelection(this.stringList);
|
|
22
23
|
this.factory = new Gtk.SignalListItemFactory();
|
|
@@ -109,20 +110,20 @@ export class ListItemNode extends Node {
|
|
|
109
110
|
return true;
|
|
110
111
|
}
|
|
111
112
|
item;
|
|
112
|
-
constructor(type, props
|
|
113
|
-
super(type, props
|
|
113
|
+
constructor(type, props) {
|
|
114
|
+
super(type, props);
|
|
114
115
|
this.item = props.item;
|
|
115
116
|
}
|
|
116
117
|
getItem() {
|
|
117
118
|
return this.item;
|
|
118
119
|
}
|
|
119
120
|
attachToParent(parent) {
|
|
120
|
-
if (parent
|
|
121
|
+
if (isItemContainer(parent)) {
|
|
121
122
|
parent.addItem(this.item);
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
attachToParentBefore(parent, before) {
|
|
125
|
-
if (parent
|
|
126
|
+
if (isItemContainer(parent) && before instanceof ListItemNode) {
|
|
126
127
|
parent.insertItemBefore(this.item, before.getItem());
|
|
127
128
|
}
|
|
128
129
|
else {
|
|
@@ -130,7 +131,7 @@ export class ListItemNode extends Node {
|
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
detachFromParent(parent) {
|
|
133
|
-
if (parent
|
|
134
|
+
if (isItemContainer(parent)) {
|
|
134
135
|
parent.removeItem(this.item);
|
|
135
136
|
}
|
|
136
137
|
}
|
package/dist/nodes/notebook.d.ts
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { type ChildContainer, type PageContainer } from "../container-interfaces.js";
|
|
2
3
|
import type { Props } from "../factory.js";
|
|
3
4
|
import { Node } from "../node.js";
|
|
4
|
-
export declare class NotebookNode extends Node<Gtk.Notebook> {
|
|
5
|
+
export declare class NotebookNode extends Node<Gtk.Notebook> implements PageContainer, ChildContainer {
|
|
5
6
|
static matches(type: string): boolean;
|
|
6
7
|
addPage(child: Gtk.Widget, label: string): void;
|
|
7
8
|
insertPageBefore(child: Gtk.Widget, label: string, beforeChild: Gtk.Widget): void;
|
|
8
9
|
removePage(child: Gtk.Widget): void;
|
|
9
10
|
updatePageLabel(child: Gtk.Widget, label: string): void;
|
|
11
|
+
attachChild(child: Gtk.Widget): void;
|
|
12
|
+
insertChildBefore(child: Gtk.Widget, before: Gtk.Widget): void;
|
|
13
|
+
detachChild(child: Gtk.Widget): void;
|
|
10
14
|
}
|
|
11
15
|
export declare class NotebookPageNode extends Node {
|
|
12
16
|
static matches(type: string): boolean;
|
|
13
17
|
protected isVirtual(): boolean;
|
|
14
18
|
private label;
|
|
15
19
|
private childWidget;
|
|
16
|
-
private
|
|
17
|
-
constructor(type: string, props: Props
|
|
20
|
+
private parentContainer;
|
|
21
|
+
constructor(type: string, props: Props);
|
|
18
22
|
getLabel(): string;
|
|
19
23
|
setChildWidget(widget: Gtk.Widget): void;
|
|
20
24
|
getChildWidget(): Gtk.Widget | null;
|
package/dist/nodes/notebook.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { isPageContainer } from "../container-interfaces.js";
|
|
2
3
|
import { Node } from "../node.js";
|
|
4
|
+
import { getStringProp } from "../props.js";
|
|
3
5
|
export class NotebookNode extends Node {
|
|
4
6
|
static matches(type) {
|
|
5
|
-
return type === "Notebook.Root";
|
|
7
|
+
return type === "Notebook" || type === "Notebook.Root";
|
|
6
8
|
}
|
|
7
9
|
addPage(child, label) {
|
|
8
10
|
const tabLabel = new Gtk.Label();
|
|
@@ -31,6 +33,21 @@ export class NotebookNode extends Node {
|
|
|
31
33
|
tabLabel.setLabel(label);
|
|
32
34
|
this.widget.setTabLabel(child, tabLabel);
|
|
33
35
|
}
|
|
36
|
+
attachChild(child) {
|
|
37
|
+
this.widget.appendPage(child, null);
|
|
38
|
+
}
|
|
39
|
+
insertChildBefore(child, before) {
|
|
40
|
+
const beforePageNum = this.widget.pageNum(before);
|
|
41
|
+
if (beforePageNum >= 0) {
|
|
42
|
+
this.widget.insertPage(child, beforePageNum, null);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.widget.appendPage(child, null);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
detachChild(child) {
|
|
49
|
+
this.removePage(child);
|
|
50
|
+
}
|
|
34
51
|
}
|
|
35
52
|
export class NotebookPageNode extends Node {
|
|
36
53
|
static matches(type) {
|
|
@@ -41,10 +58,10 @@ export class NotebookPageNode extends Node {
|
|
|
41
58
|
}
|
|
42
59
|
label;
|
|
43
60
|
childWidget = null;
|
|
44
|
-
|
|
45
|
-
constructor(type, props
|
|
46
|
-
super(type, props
|
|
47
|
-
this.label = props
|
|
61
|
+
parentContainer = null;
|
|
62
|
+
constructor(type, props) {
|
|
63
|
+
super(type, props);
|
|
64
|
+
this.label = getStringProp(props, "label", "");
|
|
48
65
|
}
|
|
49
66
|
getLabel() {
|
|
50
67
|
return this.label;
|
|
@@ -62,14 +79,14 @@ export class NotebookPageNode extends Node {
|
|
|
62
79
|
}
|
|
63
80
|
}
|
|
64
81
|
attachToParent(parent) {
|
|
65
|
-
if (parent
|
|
66
|
-
this.
|
|
82
|
+
if (isPageContainer(parent) && this.childWidget) {
|
|
83
|
+
this.parentContainer = parent;
|
|
67
84
|
parent.addPage(this.childWidget, this.label);
|
|
68
85
|
}
|
|
69
86
|
}
|
|
70
87
|
attachToParentBefore(parent, before) {
|
|
71
|
-
if (parent
|
|
72
|
-
this.
|
|
88
|
+
if (isPageContainer(parent) && this.childWidget) {
|
|
89
|
+
this.parentContainer = parent;
|
|
73
90
|
const beforePage = before instanceof NotebookPageNode ? before.getChildWidget() : before.getWidget();
|
|
74
91
|
if (beforePage) {
|
|
75
92
|
parent.insertPageBefore(this.childWidget, this.label, beforePage);
|
|
@@ -80,9 +97,9 @@ export class NotebookPageNode extends Node {
|
|
|
80
97
|
}
|
|
81
98
|
}
|
|
82
99
|
detachFromParent(parent) {
|
|
83
|
-
if (parent
|
|
100
|
+
if (isPageContainer(parent) && this.childWidget) {
|
|
84
101
|
parent.removePage(this.childWidget);
|
|
85
|
-
this.
|
|
102
|
+
this.parentContainer = null;
|
|
86
103
|
}
|
|
87
104
|
}
|
|
88
105
|
consumedProps() {
|
|
@@ -92,9 +109,9 @@ export class NotebookPageNode extends Node {
|
|
|
92
109
|
}
|
|
93
110
|
updateProps(oldProps, newProps) {
|
|
94
111
|
if (oldProps.label !== newProps.label) {
|
|
95
|
-
this.label = newProps
|
|
96
|
-
if (this.
|
|
97
|
-
this.
|
|
112
|
+
this.label = getStringProp(newProps, "label", "");
|
|
113
|
+
if (this.parentContainer && this.childWidget) {
|
|
114
|
+
this.parentContainer.updatePageLabel(this.childWidget, this.label);
|
|
98
115
|
}
|
|
99
116
|
}
|
|
100
117
|
super.updateProps(oldProps, newProps);
|
package/dist/nodes/overlay.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { ChildContainer } from "../container-interfaces.js";
|
|
2
3
|
import { Node } from "../node.js";
|
|
3
|
-
export declare class OverlayNode extends Node<Gtk.Overlay> {
|
|
4
|
+
export declare class OverlayNode extends Node<Gtk.Overlay> implements ChildContainer {
|
|
4
5
|
static matches(type: string): boolean;
|
|
5
6
|
private mainChild;
|
|
6
7
|
private overlayChildren;
|
package/dist/nodes/root.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import type { Props } from "../factory.js";
|
|
3
2
|
import { Node } from "../node.js";
|
|
4
3
|
export declare const ROOT_NODE_CONTAINER: unique symbol;
|
|
5
4
|
export declare class RootNode extends Node<never> {
|
|
6
|
-
static matches(_type: string,
|
|
5
|
+
static matches(_type: string, existingWidget?: Gtk.Widget | typeof ROOT_NODE_CONTAINER): boolean;
|
|
7
6
|
protected isVirtual(): boolean;
|
|
8
|
-
constructor(
|
|
7
|
+
constructor();
|
|
9
8
|
}
|
package/dist/nodes/root.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Node } from "../node.js";
|
|
2
2
|
export const ROOT_NODE_CONTAINER = Symbol.for("ROOT_NODE_CONTAINER");
|
|
3
3
|
export class RootNode extends Node {
|
|
4
|
-
static matches(_type,
|
|
4
|
+
static matches(_type, existingWidget) {
|
|
5
5
|
return existingWidget === ROOT_NODE_CONTAINER;
|
|
6
6
|
}
|
|
7
7
|
isVirtual() {
|
|
8
8
|
return true;
|
|
9
9
|
}
|
|
10
|
-
constructor(
|
|
11
|
-
super("", {}
|
|
10
|
+
constructor() {
|
|
11
|
+
super("", {});
|
|
12
12
|
}
|
|
13
13
|
}
|
package/dist/nodes/slot.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
1
|
import type { Props } from "../factory.js";
|
|
3
2
|
import { Node } from "../node.js";
|
|
4
3
|
export declare class SlotNode extends Node<never> {
|
|
@@ -7,7 +6,7 @@ export declare class SlotNode extends Node<never> {
|
|
|
7
6
|
private child;
|
|
8
7
|
private slotName;
|
|
9
8
|
private parentNode;
|
|
10
|
-
constructor(type: string, props: Props
|
|
9
|
+
constructor(type: string, props: Props);
|
|
11
10
|
private updateParentSlot;
|
|
12
11
|
appendChild(child: Node): void;
|
|
13
12
|
removeChild(_child: Node): void;
|
package/dist/nodes/slot.js
CHANGED
|
@@ -15,8 +15,8 @@ export class SlotNode extends Node {
|
|
|
15
15
|
child = null;
|
|
16
16
|
slotName;
|
|
17
17
|
parentNode = null;
|
|
18
|
-
constructor(type, props
|
|
19
|
-
super(type, props
|
|
18
|
+
constructor(type, props) {
|
|
19
|
+
super(type, props);
|
|
20
20
|
const dotIndex = type.indexOf(".");
|
|
21
21
|
if (dotIndex === -1) {
|
|
22
22
|
throw new Error(`Invalid slot type: ${type}`);
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import * as Gtk from "@gtkx/ffi/gtk";
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { Props } from "../factory.js";
|
|
3
3
|
import { Node } from "../node.js";
|
|
4
4
|
export declare class TextViewNode extends Node<Gtk.TextView> {
|
|
5
5
|
static matches(type: string): boolean;
|
|
6
|
-
|
|
7
|
-
private onChanged?;
|
|
8
|
-
private bufferChangedHandlerId?;
|
|
9
|
-
constructor(type: string, props: Props, app: Gtk.Application);
|
|
10
|
-
private connectBufferSignal;
|
|
11
|
-
private disconnectBufferSignal;
|
|
6
|
+
constructor(type: string, props: Props);
|
|
12
7
|
protected consumedProps(): Set<string>;
|
|
13
8
|
updateProps(oldProps: Props, newProps: Props): void;
|
|
14
9
|
}
|
package/dist/nodes/text-view.js
CHANGED
|
@@ -1,64 +1,25 @@
|
|
|
1
|
-
import { createRef } from "@gtkx/ffi";
|
|
2
|
-
import * as GObject from "@gtkx/ffi/gobject";
|
|
3
|
-
import * as Gtk from "@gtkx/ffi/gtk";
|
|
4
1
|
import { Node } from "../node.js";
|
|
5
|
-
const getBufferText = (buffer) => {
|
|
6
|
-
const startRef = createRef(new Gtk.TextIter());
|
|
7
|
-
const endRef = createRef(new Gtk.TextIter());
|
|
8
|
-
buffer.getStartIter(startRef);
|
|
9
|
-
buffer.getEndIter(endRef);
|
|
10
|
-
return buffer.getText(startRef.value, endRef.value, true);
|
|
11
|
-
};
|
|
12
|
-
const setBufferText = (buffer, text) => {
|
|
13
|
-
buffer.setText(text, -1);
|
|
14
|
-
};
|
|
15
2
|
export class TextViewNode extends Node {
|
|
16
3
|
static matches(type) {
|
|
17
4
|
return type === "TextView";
|
|
18
5
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.buffer = this.widget.getBuffer();
|
|
25
|
-
this.onChanged = props.onChanged;
|
|
26
|
-
if (typeof props.text === "string") {
|
|
27
|
-
setBufferText(this.buffer, props.text);
|
|
28
|
-
}
|
|
29
|
-
// Connect after a microtask to avoid signal firing during widget construction
|
|
30
|
-
queueMicrotask(() => this.connectBufferSignal());
|
|
31
|
-
}
|
|
32
|
-
connectBufferSignal() {
|
|
33
|
-
if (this.onChanged && this.bufferChangedHandlerId === undefined) {
|
|
34
|
-
this.bufferChangedHandlerId = this.buffer.connect("changed", () => {
|
|
35
|
-
const text = getBufferText(this.buffer);
|
|
36
|
-
this.onChanged?.(text);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
disconnectBufferSignal() {
|
|
41
|
-
if (this.bufferChangedHandlerId !== undefined) {
|
|
42
|
-
GObject.signalHandlerDisconnect(this.buffer, this.bufferChangedHandlerId);
|
|
43
|
-
this.bufferChangedHandlerId = undefined;
|
|
6
|
+
constructor(type, props) {
|
|
7
|
+
super(type, props);
|
|
8
|
+
const buffer = props.buffer;
|
|
9
|
+
if (buffer) {
|
|
10
|
+
this.widget.setBuffer(buffer);
|
|
44
11
|
}
|
|
45
12
|
}
|
|
46
13
|
consumedProps() {
|
|
47
14
|
const consumed = super.consumedProps();
|
|
48
|
-
consumed.add("
|
|
49
|
-
consumed.add("onChanged");
|
|
15
|
+
consumed.add("buffer");
|
|
50
16
|
return consumed;
|
|
51
17
|
}
|
|
52
18
|
updateProps(oldProps, newProps) {
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
if (this.buffer && oldProps.text !== newProps.text && typeof newProps.text === "string") {
|
|
59
|
-
const currentText = getBufferText(this.buffer);
|
|
60
|
-
if (currentText !== newProps.text) {
|
|
61
|
-
setBufferText(this.buffer, newProps.text);
|
|
19
|
+
if (oldProps.buffer !== newProps.buffer) {
|
|
20
|
+
const buffer = newProps.buffer;
|
|
21
|
+
if (buffer) {
|
|
22
|
+
this.widget.setBuffer(buffer);
|
|
62
23
|
}
|
|
63
24
|
}
|
|
64
25
|
super.updateProps(oldProps, newProps);
|
package/dist/nodes/widget.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import type { Props } from "../factory.js";
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
3
2
|
import { Node } from "../node.js";
|
|
3
|
+
/**
|
|
4
|
+
* Catch-all node for standard GTK widgets that don't need special handling.
|
|
5
|
+
* Specialized widgets (Window, AboutDialog, ActionBar, FlowBox, ListBox, etc.)
|
|
6
|
+
* are handled by their own dedicated Node classes.
|
|
7
|
+
*/
|
|
4
8
|
export declare class WidgetNode extends Node<Gtk.Widget> {
|
|
5
9
|
static matches(_type: string): boolean;
|
|
6
10
|
attachToParent(parent: Node): void;
|
|
7
11
|
attachToParentBefore(parent: Node, before: Node): void;
|
|
8
12
|
detachFromParent(parent: Node): void;
|
|
9
|
-
protected consumedProps(): Set<string>;
|
|
10
|
-
updateProps(oldProps: Props, newProps: Props): void;
|
|
11
|
-
mount(_app: Gtk.Application): void;
|
|
12
13
|
}
|