@gtkx/react 0.17.2 → 0.18.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 +7 -7
- package/dist/factory.d.ts +0 -1
- package/dist/factory.js +21 -8
- package/dist/generated/internal.d.ts +4 -51
- package/dist/generated/internal.js +626 -412
- package/dist/generated/jsx.d.ts +453 -958
- package/dist/host-config.d.ts +1 -1
- package/dist/host-config.js +18 -23
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/jsx.d.ts +579 -302
- package/dist/jsx.js +37 -179
- package/dist/metadata.d.ts +3 -0
- package/dist/metadata.js +26 -0
- package/dist/node.d.ts +20 -12
- package/dist/node.js +72 -17
- package/dist/nodes/adjustable.d.ts +3 -16
- package/dist/nodes/adjustable.js +5 -22
- package/dist/nodes/alert-dialog-response.d.ts +14 -1
- package/dist/nodes/alert-dialog-response.js +36 -62
- package/dist/nodes/animation.d.ts +37 -1
- package/dist/nodes/animation.js +162 -105
- package/dist/nodes/application.d.ts +11 -1
- package/dist/nodes/application.js +17 -38
- package/dist/nodes/calendar.d.ts +13 -0
- package/dist/nodes/calendar.js +10 -16
- package/dist/nodes/color-dialog-button.d.ts +13 -0
- package/dist/nodes/color-dialog-button.js +10 -38
- package/dist/nodes/column-view-column.d.ts +13 -11
- package/dist/nodes/column-view-column.js +27 -23
- package/dist/nodes/column-view.d.ts +31 -0
- package/dist/nodes/column-view.js +44 -44
- package/dist/nodes/container-slot.d.ts +15 -0
- package/dist/nodes/container-slot.js +68 -0
- package/dist/nodes/dialog.d.ts +6 -8
- package/dist/nodes/dialog.js +12 -13
- package/dist/nodes/drawing-area.d.ts +12 -0
- package/dist/nodes/drawing-area.js +24 -24
- package/dist/nodes/drop-down.d.ts +22 -0
- package/dist/nodes/drop-down.js +72 -0
- package/dist/nodes/event-controller.d.ts +8 -17
- package/dist/nodes/event-controller.js +20 -42
- package/dist/nodes/fixed-child.d.ts +18 -1
- package/dist/nodes/fixed-child.js +52 -36
- package/dist/nodes/font-dialog-button.d.ts +13 -0
- package/dist/nodes/font-dialog-button.js +12 -35
- package/dist/nodes/grid-child.d.ts +17 -1
- package/dist/nodes/grid-child.js +57 -37
- package/dist/nodes/grid-view.d.ts +24 -0
- package/dist/nodes/grid-view.js +73 -0
- package/dist/nodes/internal/base-item-renderer.d.ts +7 -9
- package/dist/nodes/internal/base-item-renderer.js +15 -18
- package/dist/nodes/internal/grid-item-renderer.d.ts +17 -0
- package/dist/nodes/internal/grid-item-renderer.js +59 -0
- package/dist/nodes/internal/list-item-renderer.d.ts +14 -9
- package/dist/nodes/internal/list-item-renderer.js +96 -35
- package/dist/nodes/internal/list-store.d.ts +5 -0
- package/dist/nodes/internal/list-store.js +39 -9
- package/dist/nodes/internal/predicates.d.ts +4 -19
- package/dist/nodes/internal/predicates.js +1 -20
- package/dist/nodes/internal/props.d.ts +5 -0
- package/dist/nodes/internal/props.js +42 -0
- package/dist/nodes/internal/{selection-model.d.ts → selection-model-controller.d.ts} +4 -9
- package/dist/nodes/internal/{selection-model.js → selection-model-controller.js} +6 -15
- package/dist/nodes/internal/signal-store.js +12 -5
- package/dist/nodes/internal/simple-list-store.d.ts +5 -0
- package/dist/nodes/internal/simple-list-store.js +42 -13
- package/dist/nodes/internal/text-buffer-controller.d.ts +4 -12
- package/dist/nodes/internal/text-buffer-controller.js +32 -33
- package/dist/nodes/internal/tree-store.d.ts +7 -0
- package/dist/nodes/internal/tree-store.js +75 -18
- package/dist/nodes/internal/widget.d.ts +7 -0
- package/dist/nodes/internal/widget.js +68 -0
- package/dist/nodes/level-bar.d.ts +10 -0
- package/dist/nodes/level-bar.js +11 -22
- package/dist/nodes/list-item.d.ts +17 -9
- package/dist/nodes/list-item.js +67 -12
- package/dist/nodes/list-view.d.ts +23 -0
- package/dist/nodes/list-view.js +27 -31
- package/dist/nodes/menu.d.ts +2 -4
- package/dist/nodes/menu.js +0 -6
- package/dist/nodes/models/grid.d.ts +27 -0
- package/dist/nodes/models/grid.js +68 -0
- package/dist/nodes/models/list.d.ts +15 -13
- package/dist/nodes/models/list.js +48 -26
- package/dist/nodes/models/menu.d.ts +15 -16
- package/dist/nodes/models/menu.js +63 -93
- package/dist/nodes/navigation-page.d.ts +16 -10
- package/dist/nodes/navigation-page.js +108 -31
- package/dist/nodes/navigation-view.d.ts +15 -0
- package/dist/nodes/navigation-view.js +15 -65
- package/dist/nodes/notebook-page-tab.d.ts +10 -12
- package/dist/nodes/notebook-page-tab.js +24 -27
- package/dist/nodes/notebook-page.d.ts +19 -16
- package/dist/nodes/notebook-page.js +75 -56
- package/dist/nodes/notebook.d.ts +10 -1
- package/dist/nodes/notebook.js +10 -22
- package/dist/nodes/overlay-child.d.ts +17 -1
- package/dist/nodes/overlay-child.js +53 -75
- package/dist/nodes/popover-menu.d.ts +15 -0
- package/dist/nodes/popover-menu.js +13 -26
- package/dist/nodes/scale.d.ts +8 -0
- package/dist/nodes/scale.js +2 -11
- package/dist/nodes/scrolled-window.d.ts +9 -0
- package/dist/nodes/scrolled-window.js +5 -11
- package/dist/nodes/search-bar.d.ts +9 -0
- package/dist/nodes/search-bar.js +8 -33
- package/dist/nodes/shortcut-controller.d.ts +9 -1
- package/dist/nodes/shortcut-controller.js +12 -25
- package/dist/nodes/shortcut.d.ts +11 -33
- package/dist/nodes/shortcut.js +19 -15
- package/dist/nodes/slot.d.ts +16 -15
- package/dist/nodes/slot.js +63 -57
- package/dist/nodes/source-view.d.ts +16 -0
- package/dist/nodes/source-view.js +44 -44
- package/dist/nodes/stack-page.d.ts +21 -1
- package/dist/nodes/stack-page.js +68 -17
- package/dist/nodes/stack.d.ts +11 -0
- package/dist/nodes/stack.js +8 -26
- package/dist/nodes/text-anchor.d.ts +11 -30
- package/dist/nodes/text-anchor.js +20 -22
- package/dist/nodes/text-content.d.ts +1 -0
- package/dist/nodes/text-content.js +1 -1
- package/dist/nodes/text-paintable.d.ts +10 -15
- package/dist/nodes/text-paintable.js +16 -9
- package/dist/nodes/text-segment.d.ts +12 -10
- package/dist/nodes/text-segment.js +19 -11
- package/dist/nodes/text-tag.d.ts +20 -119
- package/dist/nodes/text-tag.js +153 -119
- package/dist/nodes/text-view.d.ts +13 -18
- package/dist/nodes/text-view.js +17 -17
- package/dist/nodes/toggle-group.d.ts +9 -0
- package/dist/nodes/toggle-group.js +8 -33
- package/dist/nodes/toggle.d.ts +15 -1
- package/dist/nodes/toggle.js +34 -52
- package/dist/nodes/virtual.d.ts +3 -10
- package/dist/nodes/virtual.js +1 -14
- package/dist/nodes/web-view.d.ts +9 -0
- package/dist/nodes/web-view.js +10 -24
- package/dist/nodes/widget.d.ts +17 -13
- package/dist/nodes/widget.js +185 -112
- package/dist/nodes/window.d.ts +20 -21
- package/dist/nodes/window.js +54 -35
- package/dist/registry.d.ts +17 -6
- package/dist/registry.js +104 -5
- package/dist/render.d.ts +1 -10
- package/dist/render.js +1 -13
- package/package.json +6 -6
- package/dist/animation/css-builder.d.ts +0 -3
- package/dist/animation/css-builder.js +0 -53
- package/dist/animation/types.d.ts +0 -120
- package/dist/animation/types.js +0 -1
- package/dist/nodes/abstract/positional-child.d.ts +0 -9
- package/dist/nodes/abstract/positional-child.js +0 -29
- package/dist/nodes/abstract/virtual-container.d.ts +0 -21
- package/dist/nodes/abstract/virtual-container.js +0 -68
- package/dist/nodes/abstract/virtual-single-child.d.ts +0 -18
- package/dist/nodes/abstract/virtual-single-child.js +0 -55
- package/dist/nodes/action-row-child.d.ts +0 -1
- package/dist/nodes/action-row-child.js +0 -30
- package/dist/nodes/autowrapped.d.ts +0 -1
- package/dist/nodes/autowrapped.js +0 -115
- package/dist/nodes/expander-row-child.d.ts +0 -1
- package/dist/nodes/expander-row-child.js +0 -30
- package/dist/nodes/grid.d.ts +0 -1
- package/dist/nodes/grid.js +0 -41
- package/dist/nodes/index.d.ts +0 -56
- package/dist/nodes/index.js +0 -56
- package/dist/nodes/internal/child-attachment.d.ts +0 -26
- package/dist/nodes/internal/child-attachment.js +0 -48
- package/dist/nodes/internal/deferred-action.d.ts +0 -9
- package/dist/nodes/internal/deferred-action.js +0 -22
- package/dist/nodes/internal/text-tag-styles.d.ts +0 -43
- package/dist/nodes/internal/text-tag-styles.js +0 -52
- package/dist/nodes/internal/tree-list-item-renderer.d.ts +0 -26
- package/dist/nodes/internal/tree-list-item-renderer.js +0 -134
- package/dist/nodes/internal/utils.d.ts +0 -12
- package/dist/nodes/internal/utils.js +0 -92
- package/dist/nodes/models/tree-list.d.ts +0 -28
- package/dist/nodes/models/tree-list.js +0 -113
- package/dist/nodes/pack-child.d.ts +0 -1
- package/dist/nodes/pack-child.js +0 -30
- package/dist/nodes/simple-list-item.d.ts +0 -9
- package/dist/nodes/simple-list-item.js +0 -9
- package/dist/nodes/simple-list-view.d.ts +0 -1
- package/dist/nodes/simple-list-view.js +0 -74
- package/dist/nodes/toolbar-child.d.ts +0 -1
- package/dist/nodes/toolbar-child.js +0 -30
- package/dist/nodes/tree-list-item.d.ts +0 -22
- package/dist/nodes/tree-list-item.js +0 -90
- package/dist/nodes/tree-list-view.d.ts +0 -1
- package/dist/nodes/tree-list-view.js +0 -77
- package/dist/scheduler.d.ts +0 -26
- package/dist/scheduler.js +0 -42
package/dist/nodes/text-tag.js
CHANGED
|
@@ -1,22 +1,107 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import {
|
|
3
|
-
import { applyStyleChanges } from "./internal/text-tag-styles.js";
|
|
4
|
-
import { hasChanged } from "./internal/utils.js";
|
|
2
|
+
import { hasChanged } from "./internal/props.js";
|
|
5
3
|
import { TextAnchorNode } from "./text-anchor.js";
|
|
6
|
-
import { TextSegmentNode } from "./text-segment.js";
|
|
4
|
+
import { isTextContentParent, TextSegmentNode } from "./text-segment.js";
|
|
7
5
|
import { VirtualNode } from "./virtual.js";
|
|
6
|
+
const STYLE_PROPS = {
|
|
7
|
+
background: "setBackground",
|
|
8
|
+
backgroundFullHeight: "setBackgroundFullHeight",
|
|
9
|
+
foreground: "setForeground",
|
|
10
|
+
family: "setFamily",
|
|
11
|
+
font: "setFont",
|
|
12
|
+
sizePoints: "setSizePoints",
|
|
13
|
+
size: "setSize",
|
|
14
|
+
scale: "setScale",
|
|
15
|
+
weight: "setWeight",
|
|
16
|
+
style: "setStyle",
|
|
17
|
+
stretch: "setStretch",
|
|
18
|
+
variant: "setVariant",
|
|
19
|
+
strikethrough: "setStrikethrough",
|
|
20
|
+
underline: "setUnderline",
|
|
21
|
+
overline: "setOverline",
|
|
22
|
+
rise: "setRise",
|
|
23
|
+
letterSpacing: "setLetterSpacing",
|
|
24
|
+
lineHeight: "setLineHeight",
|
|
25
|
+
leftMargin: "setLeftMargin",
|
|
26
|
+
rightMargin: "setRightMargin",
|
|
27
|
+
indent: "setIndent",
|
|
28
|
+
pixelsAboveLines: "setPixelsAboveLines",
|
|
29
|
+
pixelsBelowLines: "setPixelsBelowLines",
|
|
30
|
+
pixelsInsideWrap: "setPixelsInsideWrap",
|
|
31
|
+
justification: "setJustification",
|
|
32
|
+
direction: "setDirection",
|
|
33
|
+
wrapMode: "setWrapMode",
|
|
34
|
+
editable: "setEditable",
|
|
35
|
+
invisible: "setInvisible",
|
|
36
|
+
allowBreaks: "setAllowBreaks",
|
|
37
|
+
insertHyphens: "setInsertHyphens",
|
|
38
|
+
fallback: "setFallback",
|
|
39
|
+
accumulativeMargin: "setAccumulativeMargin",
|
|
40
|
+
paragraphBackground: "setParagraphBackground",
|
|
41
|
+
showSpaces: "setShowSpaces",
|
|
42
|
+
textTransform: "setTextTransform",
|
|
43
|
+
fontFeatures: "setFontFeatures",
|
|
44
|
+
language: "setLanguage",
|
|
45
|
+
};
|
|
8
46
|
export class TextTagNode extends VirtualNode {
|
|
9
|
-
static priority = 1;
|
|
10
47
|
buffer = null;
|
|
11
48
|
tag = null;
|
|
12
|
-
children = [];
|
|
13
|
-
parent = null;
|
|
14
49
|
bufferOffset = 0;
|
|
15
|
-
|
|
16
|
-
return
|
|
50
|
+
getBufferOffset() {
|
|
51
|
+
return this.bufferOffset;
|
|
17
52
|
}
|
|
18
|
-
|
|
19
|
-
this.
|
|
53
|
+
setBufferOffset(offset) {
|
|
54
|
+
this.bufferOffset = offset;
|
|
55
|
+
}
|
|
56
|
+
isValidChild(child) {
|
|
57
|
+
return this.isTextContentChild(child);
|
|
58
|
+
}
|
|
59
|
+
isValidParent(parent) {
|
|
60
|
+
return isTextContentParent(parent);
|
|
61
|
+
}
|
|
62
|
+
appendChild(child) {
|
|
63
|
+
const index = this.children.length;
|
|
64
|
+
super.appendChild(child);
|
|
65
|
+
if (child instanceof TextTagNode && this.buffer) {
|
|
66
|
+
child.setBuffer(this.buffer);
|
|
67
|
+
}
|
|
68
|
+
this.updateChildOffsets(index);
|
|
69
|
+
this.parent?.onChildInserted(child);
|
|
70
|
+
}
|
|
71
|
+
removeChild(child) {
|
|
72
|
+
const index = this.children.indexOf(child);
|
|
73
|
+
if (index !== -1) {
|
|
74
|
+
this.children.splice(index, 1);
|
|
75
|
+
child.setParent(null);
|
|
76
|
+
this.updateChildOffsets(index);
|
|
77
|
+
this.parent?.onChildRemoved(child);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
super.removeChild(child);
|
|
81
|
+
}
|
|
82
|
+
insertBefore(child, before) {
|
|
83
|
+
const beforeIndex = this.children.indexOf(before);
|
|
84
|
+
const insertIndex = beforeIndex !== -1 ? beforeIndex : this.children.length;
|
|
85
|
+
super.insertBefore(child, before);
|
|
86
|
+
if (child instanceof TextTagNode && this.buffer) {
|
|
87
|
+
child.setBuffer(this.buffer);
|
|
88
|
+
}
|
|
89
|
+
this.updateChildOffsets(insertIndex);
|
|
90
|
+
this.parent?.onChildInserted(child);
|
|
91
|
+
}
|
|
92
|
+
commitUpdate(oldProps, newProps) {
|
|
93
|
+
super.commitUpdate(oldProps, newProps);
|
|
94
|
+
this.applyOwnProps(oldProps, newProps);
|
|
95
|
+
}
|
|
96
|
+
detachDeletedInstance() {
|
|
97
|
+
if (this.buffer && this.tag) {
|
|
98
|
+
this.removeTagFromBuffer();
|
|
99
|
+
const tagTable = this.buffer.getTagTable();
|
|
100
|
+
tagTable.remove(this.tag);
|
|
101
|
+
}
|
|
102
|
+
this.tag = null;
|
|
103
|
+
this.buffer = null;
|
|
104
|
+
super.detachDeletedInstance();
|
|
20
105
|
}
|
|
21
106
|
setBuffer(buffer) {
|
|
22
107
|
this.buffer = buffer;
|
|
@@ -31,6 +116,43 @@ export class TextTagNode extends VirtualNode {
|
|
|
31
116
|
hasBuffer() {
|
|
32
117
|
return this.buffer !== null;
|
|
33
118
|
}
|
|
119
|
+
getText() {
|
|
120
|
+
let text = "";
|
|
121
|
+
for (const child of this.children) {
|
|
122
|
+
text += child.getText();
|
|
123
|
+
}
|
|
124
|
+
return text;
|
|
125
|
+
}
|
|
126
|
+
getLength() {
|
|
127
|
+
let length = 0;
|
|
128
|
+
for (const child of this.children) {
|
|
129
|
+
length += child.getLength();
|
|
130
|
+
}
|
|
131
|
+
return length;
|
|
132
|
+
}
|
|
133
|
+
reapplyTag() {
|
|
134
|
+
if (!this.buffer || !this.tag)
|
|
135
|
+
return;
|
|
136
|
+
this.removeTagFromBuffer();
|
|
137
|
+
this.applyTagToRange();
|
|
138
|
+
}
|
|
139
|
+
onChildInserted(child) {
|
|
140
|
+
const index = this.children.indexOf(child);
|
|
141
|
+
if (index !== -1) {
|
|
142
|
+
this.updateChildOffsets(index);
|
|
143
|
+
}
|
|
144
|
+
this.parent?.onChildInserted(child);
|
|
145
|
+
}
|
|
146
|
+
onChildRemoved(child) {
|
|
147
|
+
this.parent?.onChildRemoved(child);
|
|
148
|
+
}
|
|
149
|
+
onChildTextChanged(child, oldLength, newLength) {
|
|
150
|
+
const index = this.children.indexOf(child);
|
|
151
|
+
if (index !== -1) {
|
|
152
|
+
this.updateChildOffsets(index + 1);
|
|
153
|
+
}
|
|
154
|
+
this.parent?.onChildTextChanged(child, oldLength, newLength);
|
|
155
|
+
}
|
|
34
156
|
setupTag() {
|
|
35
157
|
if (!this.buffer)
|
|
36
158
|
return;
|
|
@@ -43,27 +165,30 @@ export class TextTagNode extends VirtualNode {
|
|
|
43
165
|
}
|
|
44
166
|
this.applyTagToRange();
|
|
45
167
|
}
|
|
46
|
-
|
|
168
|
+
applyOwnProps(oldProps, newProps) {
|
|
169
|
+
if (oldProps && oldProps.id !== newProps.id) {
|
|
170
|
+
throw new Error("TextTag id cannot be changed after creation");
|
|
171
|
+
}
|
|
47
172
|
if (!this.tag)
|
|
48
173
|
return;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
let text = "";
|
|
53
|
-
for (const child of this.children) {
|
|
54
|
-
text += child.getText();
|
|
174
|
+
this.applyStyleProps(oldProps, newProps);
|
|
175
|
+
if (hasChanged(oldProps, newProps, "priority") && newProps.priority !== undefined) {
|
|
176
|
+
this.tag.setPriority(newProps.priority);
|
|
55
177
|
}
|
|
56
|
-
return text;
|
|
57
178
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
179
|
+
applyStyleProps(oldProps, newProps) {
|
|
180
|
+
if (!this.tag)
|
|
181
|
+
return;
|
|
182
|
+
for (const prop of Object.keys(STYLE_PROPS)) {
|
|
183
|
+
if (hasChanged(oldProps, newProps, prop)) {
|
|
184
|
+
const value = newProps[prop];
|
|
185
|
+
const method = STYLE_PROPS[prop];
|
|
186
|
+
if (value !== undefined && method) {
|
|
187
|
+
const setter = this.tag[method];
|
|
188
|
+
setter.call(this.tag, value);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
62
191
|
}
|
|
63
|
-
return length;
|
|
64
|
-
}
|
|
65
|
-
getChildren() {
|
|
66
|
-
return this.children;
|
|
67
192
|
}
|
|
68
193
|
applyTagToRange() {
|
|
69
194
|
const buffer = this.buffer;
|
|
@@ -90,12 +215,6 @@ export class TextTagNode extends VirtualNode {
|
|
|
90
215
|
buffer.getEndIter(endIter);
|
|
91
216
|
buffer.removeTag(tag, startIter, endIter);
|
|
92
217
|
}
|
|
93
|
-
reapplyTag() {
|
|
94
|
-
if (!this.buffer || !this.tag)
|
|
95
|
-
return;
|
|
96
|
-
this.removeTagFromBuffer();
|
|
97
|
-
this.applyTagToRange();
|
|
98
|
-
}
|
|
99
218
|
updateChildOffsets(startIndex) {
|
|
100
219
|
let offset = this.bufferOffset;
|
|
101
220
|
for (let i = 0; i < startIndex; i++) {
|
|
@@ -106,97 +225,12 @@ export class TextTagNode extends VirtualNode {
|
|
|
106
225
|
for (let i = startIndex; i < this.children.length; i++) {
|
|
107
226
|
const child = this.children[i];
|
|
108
227
|
if (child) {
|
|
109
|
-
child.
|
|
228
|
+
child.setBufferOffset(offset);
|
|
110
229
|
offset += child.getLength();
|
|
111
230
|
}
|
|
112
231
|
}
|
|
113
232
|
}
|
|
114
|
-
onChildInserted(child) {
|
|
115
|
-
const index = this.children.indexOf(child);
|
|
116
|
-
if (index !== -1) {
|
|
117
|
-
this.updateChildOffsets(index);
|
|
118
|
-
}
|
|
119
|
-
this.parent?.onChildInserted(child);
|
|
120
|
-
}
|
|
121
|
-
onChildRemoved(child) {
|
|
122
|
-
this.parent?.onChildRemoved(child);
|
|
123
|
-
}
|
|
124
|
-
onChildTextChanged(child, oldLength, newLength) {
|
|
125
|
-
const index = this.children.indexOf(child);
|
|
126
|
-
if (index !== -1) {
|
|
127
|
-
this.updateChildOffsets(index + 1);
|
|
128
|
-
}
|
|
129
|
-
this.parent?.onChildTextChanged(child, oldLength, newLength);
|
|
130
|
-
}
|
|
131
|
-
appendChild(child) {
|
|
132
|
-
if (this.isTextContentChild(child)) {
|
|
133
|
-
const index = this.children.length;
|
|
134
|
-
this.children.push(child);
|
|
135
|
-
this.setChildParent(child);
|
|
136
|
-
if (child instanceof TextTagNode && this.buffer) {
|
|
137
|
-
child.setBuffer(this.buffer);
|
|
138
|
-
}
|
|
139
|
-
this.updateChildOffsets(index);
|
|
140
|
-
this.parent?.onChildInserted(child);
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
super.appendChild(child);
|
|
144
|
-
}
|
|
145
|
-
removeChild(child) {
|
|
146
|
-
const index = this.children.indexOf(child);
|
|
147
|
-
if (index !== -1) {
|
|
148
|
-
this.children.splice(index, 1);
|
|
149
|
-
this.updateChildOffsets(index);
|
|
150
|
-
this.parent?.onChildRemoved(child);
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
super.removeChild(child);
|
|
154
|
-
}
|
|
155
|
-
insertBefore(child, before) {
|
|
156
|
-
if (this.isTextContentChild(child)) {
|
|
157
|
-
const beforeIndex = this.children.indexOf(before);
|
|
158
|
-
const insertIndex = beforeIndex !== -1 ? beforeIndex : this.children.length;
|
|
159
|
-
this.children.splice(insertIndex, 0, child);
|
|
160
|
-
this.setChildParent(child);
|
|
161
|
-
if (child instanceof TextTagNode && this.buffer) {
|
|
162
|
-
child.setBuffer(this.buffer);
|
|
163
|
-
}
|
|
164
|
-
this.updateChildOffsets(insertIndex);
|
|
165
|
-
this.parent?.onChildInserted(child);
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
super.insertBefore(child, before);
|
|
169
|
-
}
|
|
170
233
|
isTextContentChild(child) {
|
|
171
234
|
return child instanceof TextSegmentNode || child instanceof TextTagNode || child instanceof TextAnchorNode;
|
|
172
235
|
}
|
|
173
|
-
setChildParent(child) {
|
|
174
|
-
if (child instanceof TextSegmentNode || child instanceof TextTagNode) {
|
|
175
|
-
child.setParent(this);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
updateProps(oldProps, newProps) {
|
|
179
|
-
super.updateProps(oldProps, newProps);
|
|
180
|
-
if (oldProps && oldProps.id !== newProps.id) {
|
|
181
|
-
throw new Error("TextTag id cannot be changed after creation");
|
|
182
|
-
}
|
|
183
|
-
if (this.tag) {
|
|
184
|
-
this.applyStyleProps(oldProps, newProps);
|
|
185
|
-
if (hasChanged(oldProps, newProps, "priority") && newProps.priority !== undefined) {
|
|
186
|
-
this.tag.setPriority(newProps.priority);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
unmount() {
|
|
191
|
-
if (this.buffer && this.tag) {
|
|
192
|
-
this.removeTagFromBuffer();
|
|
193
|
-
const tagTable = this.buffer.getTagTable();
|
|
194
|
-
tagTable.remove(this.tag);
|
|
195
|
-
}
|
|
196
|
-
this.tag = null;
|
|
197
|
-
this.buffer = null;
|
|
198
|
-
this.children = [];
|
|
199
|
-
super.unmount();
|
|
200
|
-
}
|
|
201
236
|
}
|
|
202
|
-
registerNodeClass(TextTagNode);
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { GtkTextViewProps } from "../jsx.js";
|
|
2
3
|
import type { Node } from "../node.js";
|
|
3
|
-
import
|
|
4
|
+
import { EventControllerNode } from "./event-controller.js";
|
|
4
5
|
import { TextBufferController } from "./internal/text-buffer-controller.js";
|
|
6
|
+
import { SlotNode } from "./slot.js";
|
|
5
7
|
import type { TextContentChild, TextContentParent } from "./text-content.js";
|
|
6
|
-
import
|
|
8
|
+
import { TextSegmentNode } from "./text-segment.js";
|
|
7
9
|
import { WidgetNode } from "./widget.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
onTextDeleted?: ((buffer: Gtk.TextBuffer, startOffset: number, endOffset: number) => void) | null;
|
|
13
|
-
onCanUndoChanged?: ((canUndo: boolean) => void) | null;
|
|
14
|
-
onCanRedoChanged?: ((canRedo: boolean) => void) | null;
|
|
15
|
-
};
|
|
16
|
-
export declare class TextViewNode extends WidgetNode<Gtk.TextView, TextViewProps> implements TextContentParent {
|
|
17
|
-
static priority: number;
|
|
10
|
+
declare const OWN_PROPS: readonly ["enableUndo", "onBufferChanged", "onTextInserted", "onTextDeleted", "onCanUndoChanged", "onCanRedoChanged"];
|
|
11
|
+
type TextViewProps = Pick<GtkTextViewProps, (typeof OWN_PROPS)[number]>;
|
|
12
|
+
type TextViewChild = TextContentChild | SlotNode | EventControllerNode | WidgetNode;
|
|
13
|
+
export declare class TextViewNode extends WidgetNode<Gtk.TextView, TextViewProps, TextViewChild> implements TextContentParent {
|
|
18
14
|
protected bufferController: TextBufferController | null;
|
|
19
|
-
|
|
15
|
+
isValidChild(child: Node): boolean;
|
|
20
16
|
protected ensureBufferController(): TextBufferController;
|
|
21
17
|
protected createBufferController(): TextBufferController;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
removeChild(child: Node): void;
|
|
18
|
+
commitUpdate(oldProps: TextViewProps | null, newProps: TextViewProps): void;
|
|
19
|
+
appendChild(child: TextViewChild): void;
|
|
20
|
+
insertBefore(child: TextViewChild, before: TextViewChild): void;
|
|
21
|
+
removeChild(child: TextViewChild): void;
|
|
27
22
|
onChildInserted(child: TextContentChild): void;
|
|
28
23
|
onChildRemoved(child: TextContentChild): void;
|
|
29
24
|
onChildTextChanged(child: TextSegmentNode, oldLength: number, newLength: number): void;
|
package/dist/nodes/text-view.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import { EventControllerNode } from "./event-controller.js";
|
|
3
|
+
import { filterProps } from "./internal/props.js";
|
|
4
4
|
import { TextBufferController } from "./internal/text-buffer-controller.js";
|
|
5
|
-
import {
|
|
5
|
+
import { SlotNode } from "./slot.js";
|
|
6
|
+
import { TextAnchorNode } from "./text-anchor.js";
|
|
7
|
+
import { TextPaintableNode } from "./text-paintable.js";
|
|
8
|
+
import { TextSegmentNode } from "./text-segment.js";
|
|
9
|
+
import { TextTagNode } from "./text-tag.js";
|
|
6
10
|
import { WidgetNode } from "./widget.js";
|
|
7
11
|
const OWN_PROPS = [
|
|
8
12
|
"enableUndo",
|
|
@@ -13,12 +17,15 @@ const OWN_PROPS = [
|
|
|
13
17
|
"onCanRedoChanged",
|
|
14
18
|
];
|
|
15
19
|
export class TextViewNode extends WidgetNode {
|
|
16
|
-
static priority = 1;
|
|
17
20
|
bufferController = null;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
isValidChild(child) {
|
|
22
|
+
return (child instanceof TextSegmentNode ||
|
|
23
|
+
child instanceof TextTagNode ||
|
|
24
|
+
child instanceof TextAnchorNode ||
|
|
25
|
+
child instanceof TextPaintableNode ||
|
|
26
|
+
child instanceof SlotNode ||
|
|
27
|
+
child instanceof EventControllerNode ||
|
|
28
|
+
child instanceof WidgetNode);
|
|
22
29
|
}
|
|
23
30
|
ensureBufferController() {
|
|
24
31
|
if (!this.bufferController) {
|
|
@@ -29,18 +36,14 @@ export class TextViewNode extends WidgetNode {
|
|
|
29
36
|
createBufferController() {
|
|
30
37
|
return new TextBufferController(this, this.container, () => new Gtk.TextBuffer());
|
|
31
38
|
}
|
|
32
|
-
|
|
33
|
-
super.
|
|
34
|
-
this.applyOwnProps(oldProps, newProps);
|
|
35
|
-
}
|
|
36
|
-
applyOwnProps(oldProps, newProps) {
|
|
39
|
+
commitUpdate(oldProps, newProps) {
|
|
40
|
+
super.commitUpdate(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
37
41
|
this.ensureBufferController().applyOwnProps(oldProps, newProps);
|
|
38
42
|
}
|
|
39
43
|
appendChild(child) {
|
|
40
44
|
const controller = this.ensureBufferController();
|
|
41
45
|
if (controller.isTextContentChild(child)) {
|
|
42
46
|
controller.appendChild(child);
|
|
43
|
-
return;
|
|
44
47
|
}
|
|
45
48
|
super.appendChild(child);
|
|
46
49
|
}
|
|
@@ -48,7 +51,6 @@ export class TextViewNode extends WidgetNode {
|
|
|
48
51
|
const controller = this.ensureBufferController();
|
|
49
52
|
if (controller.isTextContentChild(child)) {
|
|
50
53
|
controller.insertBefore(child, before);
|
|
51
|
-
return;
|
|
52
54
|
}
|
|
53
55
|
super.insertBefore(child, before);
|
|
54
56
|
}
|
|
@@ -56,7 +58,6 @@ export class TextViewNode extends WidgetNode {
|
|
|
56
58
|
const controller = this.ensureBufferController();
|
|
57
59
|
if (controller.isTextContentChild(child)) {
|
|
58
60
|
controller.removeChild(child);
|
|
59
|
-
return;
|
|
60
61
|
}
|
|
61
62
|
super.removeChild(child);
|
|
62
63
|
}
|
|
@@ -70,4 +71,3 @@ export class TextViewNode extends WidgetNode {
|
|
|
70
71
|
this.ensureBufferController().onChildTextChanged(child, oldLength, newLength);
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
|
-
registerNodeClass(TextViewNode);
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
import type * as Adw from "@gtkx/ffi/adw";
|
|
2
|
+
import type { AdwToggleGroupProps } from "../jsx.js";
|
|
3
|
+
import { WidgetNode } from "./widget.js";
|
|
4
|
+
declare const OWN_PROPS: readonly ["onActiveChanged"];
|
|
5
|
+
type ToggleGroupProps = Pick<AdwToggleGroupProps, (typeof OWN_PROPS)[number]>;
|
|
6
|
+
export declare class ToggleGroupNode extends WidgetNode<Adw.ToggleGroup, ToggleGroupProps> {
|
|
7
|
+
commitUpdate(oldProps: ToggleGroupProps | null, newProps: ToggleGroupProps): void;
|
|
8
|
+
private applyOwnProps;
|
|
9
|
+
}
|
|
1
10
|
export {};
|
|
@@ -1,40 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import { filterProps, hasChanged, matchesAnyClass } from "./internal/utils.js";
|
|
1
|
+
import { filterProps, hasChanged } from "./internal/props.js";
|
|
4
2
|
import { WidgetNode } from "./widget.js";
|
|
5
3
|
const OWN_PROPS = ["onActiveChanged"];
|
|
6
|
-
class ToggleGroupNode extends WidgetNode {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return matchesAnyClass([Adw.ToggleGroup], containerOrClass);
|
|
4
|
+
export class ToggleGroupNode extends WidgetNode {
|
|
5
|
+
commitUpdate(oldProps, newProps) {
|
|
6
|
+
super.commitUpdate(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
7
|
+
this.applyOwnProps(oldProps, newProps);
|
|
11
8
|
}
|
|
12
|
-
|
|
13
|
-
super.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
9
|
+
applyOwnProps(oldProps, newProps) {
|
|
14
10
|
if (hasChanged(oldProps, newProps, "onActiveChanged")) {
|
|
15
|
-
|
|
11
|
+
const callback = newProps.onActiveChanged;
|
|
12
|
+
this.signalStore.set(this, this.container, "notify::active", callback ? () => callback(this.container.getActive(), this.container.getActiveName()) : undefined);
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
|
-
setupNotifyHandler(callback) {
|
|
19
|
-
if (this.notifyHandler) {
|
|
20
|
-
this.signalStore.set(this, this.container, "notify", undefined);
|
|
21
|
-
this.notifyHandler = null;
|
|
22
|
-
}
|
|
23
|
-
if (callback) {
|
|
24
|
-
this.notifyHandler = (pspec) => {
|
|
25
|
-
if (pspec.getName() === "active") {
|
|
26
|
-
callback(this.container.getActive(), this.container.getActiveName());
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
this.signalStore.set(this, this.container, "notify", this.notifyHandler);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
unmount() {
|
|
33
|
-
if (this.notifyHandler) {
|
|
34
|
-
this.signalStore.set(this, this.container, "notify", undefined);
|
|
35
|
-
this.notifyHandler = null;
|
|
36
|
-
}
|
|
37
|
-
super.unmount();
|
|
38
|
-
}
|
|
39
15
|
}
|
|
40
|
-
registerNodeClass(ToggleGroupNode);
|
package/dist/nodes/toggle.d.ts
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import * as Adw from "@gtkx/ffi/adw";
|
|
2
|
+
import type { ToggleProps } from "../jsx.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
import { VirtualNode } from "./virtual.js";
|
|
5
|
+
import { WidgetNode } from "./widget.js";
|
|
6
|
+
export declare class ToggleNode extends VirtualNode<ToggleProps, WidgetNode<Adw.ToggleGroup>, never> {
|
|
7
|
+
private toggle;
|
|
8
|
+
isValidChild(_child: Node): boolean;
|
|
9
|
+
isValidParent(parent: Node): boolean;
|
|
10
|
+
setParent(parent: WidgetNode<Adw.ToggleGroup> | null): void;
|
|
11
|
+
commitUpdate(oldProps: ToggleProps | null, newProps: ToggleProps): void;
|
|
12
|
+
detachDeletedInstance(): void;
|
|
13
|
+
private removeFromGroup;
|
|
14
|
+
private applyOwnProps;
|
|
15
|
+
}
|
package/dist/nodes/toggle.js
CHANGED
|
@@ -1,78 +1,60 @@
|
|
|
1
1
|
import * as Adw from "@gtkx/ffi/adw";
|
|
2
|
-
import {
|
|
3
|
-
import { CommitPriority, scheduleAfterCommit } from "../scheduler.js";
|
|
4
|
-
import { hasChanged } from "./internal/utils.js";
|
|
2
|
+
import { hasChanged } from "./internal/props.js";
|
|
5
3
|
import { VirtualNode } from "./virtual.js";
|
|
6
4
|
import { WidgetNode } from "./widget.js";
|
|
7
|
-
class ToggleNode extends VirtualNode {
|
|
8
|
-
static priority = 1;
|
|
9
|
-
toggleGroup = null;
|
|
5
|
+
export class ToggleNode extends VirtualNode {
|
|
10
6
|
toggle = null;
|
|
11
|
-
|
|
12
|
-
return
|
|
7
|
+
isValidChild(_child) {
|
|
8
|
+
return false;
|
|
13
9
|
}
|
|
14
|
-
|
|
10
|
+
isValidParent(parent) {
|
|
15
11
|
return parent instanceof WidgetNode && parent.container instanceof Adw.ToggleGroup;
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
if (!
|
|
19
|
-
|
|
13
|
+
setParent(parent) {
|
|
14
|
+
if (!parent && this.parent) {
|
|
15
|
+
this.removeFromGroup();
|
|
20
16
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}, CommitPriority.NORMAL);
|
|
17
|
+
super.setParent(parent);
|
|
18
|
+
if (parent && !this.toggle) {
|
|
19
|
+
this.toggle = new Adw.Toggle();
|
|
20
|
+
this.applyOwnProps(null, this.props);
|
|
21
|
+
parent.container.add(this.toggle);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
commitUpdate(oldProps, newProps) {
|
|
25
|
+
super.commitUpdate(oldProps, newProps);
|
|
26
|
+
this.applyOwnProps(oldProps, newProps);
|
|
33
27
|
}
|
|
34
|
-
|
|
28
|
+
detachDeletedInstance() {
|
|
35
29
|
this.removeFromGroup();
|
|
30
|
+
super.detachDeletedInstance();
|
|
36
31
|
}
|
|
37
32
|
removeFromGroup() {
|
|
38
|
-
if (!this.
|
|
33
|
+
if (!this.parent || !this.toggle)
|
|
39
34
|
return;
|
|
40
|
-
|
|
41
|
-
const toggle = this.toggle;
|
|
35
|
+
this.parent.container.remove(this.toggle);
|
|
42
36
|
this.toggle = null;
|
|
43
|
-
scheduleAfterCommit(() => {
|
|
44
|
-
toggleGroup.remove(toggle);
|
|
45
|
-
}, CommitPriority.HIGH);
|
|
46
|
-
}
|
|
47
|
-
updateProps(oldProps, newProps) {
|
|
48
|
-
super.updateProps(oldProps, newProps);
|
|
49
|
-
this.applyOwnProps(oldProps, newProps);
|
|
50
37
|
}
|
|
51
38
|
applyOwnProps(oldProps, newProps) {
|
|
52
39
|
if (!this.toggle)
|
|
53
40
|
return;
|
|
54
|
-
if (hasChanged(oldProps, newProps, "id")
|
|
55
|
-
this.toggle.setName(newProps.id);
|
|
41
|
+
if (hasChanged(oldProps, newProps, "id")) {
|
|
42
|
+
this.toggle.setName(newProps.id ?? "");
|
|
56
43
|
}
|
|
57
|
-
if (hasChanged(oldProps, newProps, "label")
|
|
58
|
-
this.toggle.setLabel(newProps.label);
|
|
44
|
+
if (hasChanged(oldProps, newProps, "label")) {
|
|
45
|
+
this.toggle.setLabel(newProps.label ?? "");
|
|
59
46
|
}
|
|
60
|
-
if (hasChanged(oldProps, newProps, "iconName")
|
|
61
|
-
this.toggle.setIconName(newProps.iconName);
|
|
47
|
+
if (hasChanged(oldProps, newProps, "iconName")) {
|
|
48
|
+
this.toggle.setIconName(newProps.iconName ?? "");
|
|
62
49
|
}
|
|
63
|
-
if (hasChanged(oldProps, newProps, "tooltip")
|
|
64
|
-
this.toggle.setTooltip(newProps.tooltip);
|
|
50
|
+
if (hasChanged(oldProps, newProps, "tooltip")) {
|
|
51
|
+
this.toggle.setTooltip(newProps.tooltip ?? "");
|
|
65
52
|
}
|
|
66
|
-
if (hasChanged(oldProps, newProps, "enabled")
|
|
67
|
-
this.toggle.setEnabled(newProps.enabled);
|
|
53
|
+
if (hasChanged(oldProps, newProps, "enabled")) {
|
|
54
|
+
this.toggle.setEnabled(newProps.enabled ?? true);
|
|
68
55
|
}
|
|
69
|
-
if (hasChanged(oldProps, newProps, "useUnderline")
|
|
70
|
-
this.toggle.setUseUnderline(newProps.useUnderline);
|
|
56
|
+
if (hasChanged(oldProps, newProps, "useUnderline")) {
|
|
57
|
+
this.toggle.setUseUnderline(newProps.useUnderline ?? false);
|
|
71
58
|
}
|
|
72
59
|
}
|
|
73
|
-
unmount() {
|
|
74
|
-
this.removeFromGroup();
|
|
75
|
-
super.unmount();
|
|
76
|
-
}
|
|
77
60
|
}
|
|
78
|
-
registerNodeClass(ToggleNode);
|
package/dist/nodes/virtual.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { Node } from "../node.js";
|
|
2
|
-
import type { Container
|
|
3
|
-
export declare class VirtualNode<
|
|
4
|
-
static priority: number;
|
|
5
|
-
static matches(_type: string): boolean;
|
|
2
|
+
import type { Container } from "../types.js";
|
|
3
|
+
export declare class VirtualNode<TProps = any, TParent extends Node = any, TChild extends Node = any> extends Node<undefined, TProps, TParent, TChild> {
|
|
6
4
|
static createContainer(): void;
|
|
7
|
-
props:
|
|
8
|
-
constructor(typeName: string, props: P | undefined, container: undefined, rootContainer: Container);
|
|
9
|
-
appendChild(_child: Node): void;
|
|
10
|
-
removeChild(_child: Node): void;
|
|
11
|
-
insertBefore(_child: Node, _before: Node): void;
|
|
12
|
-
updateProps(_oldProps: P | null, newProps: P): void;
|
|
5
|
+
constructor(typeName: string, props: TProps | undefined, container: undefined, rootContainer: Container);
|
|
13
6
|
}
|
package/dist/nodes/virtual.js
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import { Node } from "../node.js";
|
|
2
|
-
|
|
2
|
+
// biome-ignore lint/suspicious/noExplicitAny: Self-referential type bounds require any
|
|
3
3
|
export class VirtualNode extends Node {
|
|
4
|
-
static priority = 1;
|
|
5
|
-
static matches(_type) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
4
|
static createContainer() { }
|
|
9
|
-
props;
|
|
10
5
|
constructor(typeName, props = {}, container, rootContainer) {
|
|
11
6
|
super(typeName, props, container, rootContainer);
|
|
12
|
-
this.props = props;
|
|
13
|
-
}
|
|
14
|
-
appendChild(_child) { }
|
|
15
|
-
removeChild(_child) { }
|
|
16
|
-
insertBefore(_child, _before) { }
|
|
17
|
-
updateProps(_oldProps, newProps) {
|
|
18
|
-
this.props = newProps;
|
|
19
7
|
}
|
|
20
8
|
}
|
|
21
|
-
registerNodeClass(VirtualNode);
|