@gtkx/react 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/errors.js +3 -0
- package/dist/factory.d.ts +3 -2
- package/dist/factory.js +1 -1
- package/dist/generated/internal.d.ts +28 -1
- package/dist/generated/internal.js +93 -18
- package/dist/generated/jsx.d.ts +1489 -1300
- package/dist/generated/jsx.js +475 -0
- package/dist/host-config.d.ts +3 -1
- package/dist/host-config.js +31 -11
- package/dist/jsx.d.ts +107 -166
- package/dist/jsx.js +58 -69
- package/dist/node.d.ts +3 -1
- package/dist/node.js +5 -3
- package/dist/nodes/abstract/positional-child.d.ts +9 -0
- package/dist/nodes/abstract/positional-child.js +29 -0
- package/dist/nodes/abstract/positional-parent.d.ts +18 -0
- package/dist/nodes/abstract/positional-parent.js +48 -0
- package/dist/nodes/abstract/virtual-container.d.ts +17 -0
- package/dist/nodes/abstract/virtual-container.js +59 -0
- package/dist/nodes/abstract/virtual-single-child.d.ts +18 -0
- package/dist/nodes/abstract/virtual-single-child.js +54 -0
- package/dist/nodes/action-row-child.d.ts +0 -13
- package/dist/nodes/action-row-child.js +14 -12
- package/dist/nodes/action-row.d.ts +6 -1
- package/dist/nodes/action-row.js +4 -37
- package/dist/nodes/adjustable.d.ts +23 -0
- package/dist/nodes/adjustable.js +62 -0
- package/dist/nodes/alert-dialog-response.d.ts +1 -0
- package/dist/nodes/alert-dialog-response.js +86 -0
- package/dist/nodes/animation/animation-controller.d.ts +17 -0
- package/dist/nodes/animation/animation-controller.js +107 -0
- package/dist/nodes/animation/animation-factory.d.ts +15 -0
- package/dist/nodes/animation/animation-factory.js +25 -0
- package/dist/nodes/animation/animation-node.d.ts +9 -0
- package/dist/nodes/animation/animation-node.js +126 -0
- package/dist/nodes/animation/animation-style-sheet.d.ts +16 -0
- package/dist/nodes/animation/animation-style-sheet.js +74 -0
- package/dist/nodes/animation/index.d.ts +4 -0
- package/dist/nodes/animation/index.js +1 -0
- package/dist/nodes/animation/property-mapper.d.ts +11 -0
- package/dist/nodes/animation/property-mapper.js +36 -0
- package/dist/nodes/animation/transform-state.d.ts +11 -0
- package/dist/nodes/animation/transform-state.js +57 -0
- package/dist/nodes/animation/widget-registry.d.ts +5 -0
- package/dist/nodes/animation/widget-registry.js +42 -0
- package/dist/nodes/application.js +17 -7
- package/dist/nodes/autowrapped.js +37 -43
- package/dist/nodes/calendar.js +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 +1 -0
- package/dist/nodes/event-controller.js +96 -0
- package/dist/nodes/expander-row-child.d.ts +0 -14
- package/dist/nodes/expander-row-child.js +14 -12
- package/dist/nodes/expander-row.d.ts +6 -1
- package/dist/nodes/expander-row.js +11 -48
- package/dist/nodes/fixed-child.js +48 -36
- package/dist/nodes/font-dialog-button.d.ts +1 -0
- package/dist/nodes/font-dialog-button.js +90 -0
- package/dist/nodes/grid-child.js +39 -45
- package/dist/nodes/grid.d.ts +1 -0
- package/dist/nodes/grid.js +41 -0
- package/dist/nodes/index.d.ts +17 -9
- package/dist/nodes/index.js +17 -9
- package/dist/nodes/internal/base-item-renderer.d.ts +29 -0
- package/dist/nodes/internal/base-item-renderer.js +88 -0
- package/dist/nodes/internal/base-store.d.ts +9 -0
- package/dist/nodes/internal/base-store.js +20 -0
- package/dist/nodes/internal/child-attachment.d.ts +26 -0
- package/dist/nodes/internal/child-attachment.js +48 -0
- package/dist/nodes/internal/deferred-action.d.ts +8 -0
- package/dist/nodes/internal/deferred-action.js +19 -0
- package/dist/nodes/internal/list-item-renderer.d.ts +14 -15
- package/dist/nodes/internal/list-item-renderer.js +51 -77
- package/dist/nodes/internal/list-store.d.ts +7 -6
- package/dist/nodes/internal/list-store.js +20 -24
- package/dist/nodes/internal/predicates.d.ts +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 +91 -0
- package/dist/nodes/internal/signal-store.d.ts +5 -4
- package/dist/nodes/internal/signal-store.js +30 -28
- 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 +10 -9
- package/dist/nodes/internal/tree-store.js +31 -35
- package/dist/nodes/internal/utils.d.ts +7 -4
- package/dist/nodes/internal/utils.js +50 -5
- package/dist/nodes/level-bar.js +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 +15 -11
- package/dist/nodes/menu.d.ts +3 -3
- package/dist/nodes/menu.js +3 -3
- package/dist/nodes/models/list.d.ts +11 -13
- package/dist/nodes/models/list.js +16 -73
- package/dist/nodes/models/menu.d.ts +8 -7
- package/dist/nodes/models/menu.js +43 -50
- package/dist/nodes/models/tree-list.d.ts +6 -12
- package/dist/nodes/models/tree-list.js +30 -93
- package/dist/nodes/navigation-page.d.ts +1 -0
- package/dist/nodes/navigation-page.js +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 +14 -12
- package/dist/nodes/pack.d.ts +6 -1
- package/dist/nodes/pack.js +4 -37
- package/dist/nodes/popover-menu.js +2 -2
- package/dist/nodes/scale.js +15 -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 +24 -8
- 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 +14 -16
- package/dist/nodes/tree-list-item.d.ts +7 -5
- package/dist/nodes/tree-list-item.js +24 -36
- package/dist/nodes/tree-list-view.js +7 -6
- package/dist/nodes/virtual.d.ts +1 -1
- 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 +8 -6
- package/dist/scheduler.d.ts +11 -1
- package/dist/scheduler.js +16 -4
- package/dist/types.d.ts +2 -136
- package/package.json +3 -3
- 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/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/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
|
@@ -1 +1,31 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { Node } from "../node.js";
|
|
3
|
+
import type { Container, ContainerClass, Props } from "../types.js";
|
|
4
|
+
import { TextBufferController } from "./internal/text-buffer-controller.js";
|
|
5
|
+
import type { TextContentChild, TextContentParent } from "./text-content.js";
|
|
6
|
+
import type { TextSegmentNode } from "./text-segment.js";
|
|
7
|
+
import { WidgetNode } from "./widget.js";
|
|
8
|
+
type TextViewProps = Props & {
|
|
9
|
+
enableUndo?: boolean;
|
|
10
|
+
onBufferChanged?: ((buffer: Gtk.TextBuffer) => void) | null;
|
|
11
|
+
onTextInserted?: ((buffer: Gtk.TextBuffer, offset: number, text: string) => void) | null;
|
|
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;
|
|
18
|
+
protected bufferController: TextBufferController | null;
|
|
19
|
+
static matches(_type: string, containerOrClass?: Container | ContainerClass | null): boolean;
|
|
20
|
+
protected ensureBufferController(): TextBufferController;
|
|
21
|
+
protected createBufferController(): TextBufferController;
|
|
22
|
+
updateProps(oldProps: TextViewProps | null, newProps: TextViewProps): void;
|
|
23
|
+
protected applyOwnProps(oldProps: TextViewProps | null, newProps: TextViewProps): void;
|
|
24
|
+
appendChild(child: Node): void;
|
|
25
|
+
insertBefore(child: Node, before: Node): void;
|
|
26
|
+
removeChild(child: Node): void;
|
|
27
|
+
onChildInserted(child: TextContentChild): void;
|
|
28
|
+
onChildRemoved(child: TextContentChild): void;
|
|
29
|
+
onChildTextChanged(child: TextSegmentNode, oldLength: number, newLength: number): void;
|
|
30
|
+
}
|
|
1
31
|
export {};
|
package/dist/nodes/text-view.js
CHANGED
|
@@ -1,45 +1,73 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import * as GtkSource from "@gtkx/ffi/gtksource";
|
|
3
3
|
import { registerNodeClass } from "../registry.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { TextBufferController } from "./internal/text-buffer-controller.js";
|
|
5
|
+
import { filterProps, matchesAnyClass } from "./internal/utils.js";
|
|
6
6
|
import { WidgetNode } from "./widget.js";
|
|
7
|
-
|
|
7
|
+
const OWN_PROPS = [
|
|
8
|
+
"enableUndo",
|
|
9
|
+
"onBufferChanged",
|
|
10
|
+
"onTextInserted",
|
|
11
|
+
"onTextDeleted",
|
|
12
|
+
"onCanUndoChanged",
|
|
13
|
+
"onCanRedoChanged",
|
|
14
|
+
];
|
|
15
|
+
export class TextViewNode extends WidgetNode {
|
|
8
16
|
static priority = 1;
|
|
9
|
-
|
|
17
|
+
bufferController = null;
|
|
10
18
|
static matches(_type, containerOrClass) {
|
|
11
|
-
if (
|
|
19
|
+
if (matchesAnyClass([GtkSource.View], containerOrClass))
|
|
12
20
|
return false;
|
|
13
|
-
return
|
|
21
|
+
return matchesAnyClass([Gtk.TextView], containerOrClass);
|
|
22
|
+
}
|
|
23
|
+
ensureBufferController() {
|
|
24
|
+
if (!this.bufferController) {
|
|
25
|
+
this.bufferController = this.createBufferController();
|
|
26
|
+
}
|
|
27
|
+
return this.bufferController;
|
|
28
|
+
}
|
|
29
|
+
createBufferController() {
|
|
30
|
+
return new TextBufferController(this, this.container, () => new Gtk.TextBuffer());
|
|
31
|
+
}
|
|
32
|
+
updateProps(oldProps, newProps) {
|
|
33
|
+
super.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
34
|
+
this.applyOwnProps(oldProps, newProps);
|
|
35
|
+
}
|
|
36
|
+
applyOwnProps(oldProps, newProps) {
|
|
37
|
+
this.ensureBufferController().applyOwnProps(oldProps, newProps);
|
|
14
38
|
}
|
|
15
39
|
appendChild(child) {
|
|
16
|
-
|
|
40
|
+
const controller = this.ensureBufferController();
|
|
41
|
+
if (controller.isTextContentChild(child)) {
|
|
42
|
+
controller.appendChild(child);
|
|
17
43
|
return;
|
|
44
|
+
}
|
|
18
45
|
super.appendChild(child);
|
|
19
46
|
}
|
|
20
47
|
insertBefore(child, before) {
|
|
21
|
-
|
|
48
|
+
const controller = this.ensureBufferController();
|
|
49
|
+
if (controller.isTextContentChild(child)) {
|
|
50
|
+
controller.insertBefore(child, before);
|
|
22
51
|
return;
|
|
52
|
+
}
|
|
23
53
|
super.insertBefore(child, before);
|
|
24
54
|
}
|
|
25
55
|
removeChild(child) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
56
|
+
const controller = this.ensureBufferController();
|
|
57
|
+
if (controller.isTextContentChild(child)) {
|
|
58
|
+
controller.removeChild(child);
|
|
30
59
|
return;
|
|
31
60
|
}
|
|
32
61
|
super.removeChild(child);
|
|
33
62
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return true;
|
|
63
|
+
onChildInserted(child) {
|
|
64
|
+
this.ensureBufferController().onChildInserted(child);
|
|
65
|
+
}
|
|
66
|
+
onChildRemoved(child) {
|
|
67
|
+
this.ensureBufferController().onChildRemoved(child);
|
|
68
|
+
}
|
|
69
|
+
onChildTextChanged(child, oldLength, newLength) {
|
|
70
|
+
this.ensureBufferController().onChildTextChanged(child, oldLength, newLength);
|
|
43
71
|
}
|
|
44
72
|
}
|
|
45
73
|
registerNodeClass(TextViewNode);
|
|
@@ -1,48 +1,40 @@
|
|
|
1
1
|
import * as Adw from "@gtkx/ffi/adw";
|
|
2
2
|
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import {
|
|
4
|
-
import { SlotNode } from "./slot.js";
|
|
5
|
-
import { ToggleNode } from "./toggle.js";
|
|
3
|
+
import { filterProps, hasChanged, matchesAnyClass } from "./internal/utils.js";
|
|
6
4
|
import { WidgetNode } from "./widget.js";
|
|
5
|
+
const OWN_PROPS = ["onActiveChanged"];
|
|
7
6
|
class ToggleGroupNode extends WidgetNode {
|
|
8
7
|
static priority = 1;
|
|
8
|
+
notifyHandler = null;
|
|
9
9
|
static matches(_type, containerOrClass) {
|
|
10
|
-
return
|
|
10
|
+
return matchesAnyClass([Adw.ToggleGroup], containerOrClass);
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return;
|
|
12
|
+
updateProps(oldProps, newProps) {
|
|
13
|
+
super.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
14
|
+
if (hasChanged(oldProps, newProps, "onActiveChanged")) {
|
|
15
|
+
this.setupNotifyHandler(newProps.onActiveChanged);
|
|
17
16
|
}
|
|
18
|
-
if (child instanceof SlotNode || child instanceof WidgetNode) {
|
|
19
|
-
super.appendChild(child);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
throw new Error(`Cannot append '${child.typeName}' to 'ToggleGroup': expected x.Toggle or Widget`);
|
|
23
17
|
}
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return;
|
|
18
|
+
setupNotifyHandler(callback) {
|
|
19
|
+
if (this.notifyHandler) {
|
|
20
|
+
this.signalStore.set(this, this.container, "notify", undefined);
|
|
21
|
+
this.notifyHandler = null;
|
|
29
22
|
}
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
if (callback) {
|
|
24
|
+
this.notifyHandler = (pspec, _toggleGroup) => {
|
|
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);
|
|
33
30
|
}
|
|
34
|
-
throw new Error(`Cannot insert '${child.typeName}' into 'ToggleGroup': expected x.Toggle or Widget`);
|
|
35
31
|
}
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
if (child instanceof SlotNode || child instanceof WidgetNode) {
|
|
42
|
-
super.removeChild(child);
|
|
43
|
-
return;
|
|
32
|
+
unmount() {
|
|
33
|
+
if (this.notifyHandler) {
|
|
34
|
+
this.signalStore.set(this, this.container, "notify", undefined);
|
|
35
|
+
this.notifyHandler = null;
|
|
44
36
|
}
|
|
45
|
-
|
|
37
|
+
super.unmount();
|
|
46
38
|
}
|
|
47
39
|
}
|
|
48
40
|
registerNodeClass(ToggleGroupNode);
|
package/dist/nodes/toggle.d.ts
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ToggleProps } from "../jsx.js";
|
|
3
|
-
import { VirtualNode } from "./virtual.js";
|
|
4
|
-
export declare class ToggleNode extends VirtualNode<ToggleProps> {
|
|
5
|
-
static priority: number;
|
|
6
|
-
private toggleGroup?;
|
|
7
|
-
private toggle?;
|
|
8
|
-
static matches(type: string): boolean;
|
|
9
|
-
setToggleGroup(toggleGroup: Adw.ToggleGroup): void;
|
|
10
|
-
addToGroup(): void;
|
|
11
|
-
removeFromGroup(): void;
|
|
12
|
-
updateProps(oldProps: ToggleProps | null, newProps: ToggleProps): void;
|
|
13
|
-
unmount(): void;
|
|
14
|
-
private applyProps;
|
|
15
|
-
}
|
|
1
|
+
export {};
|
package/dist/nodes/toggle.js
CHANGED
|
@@ -1,70 +1,78 @@
|
|
|
1
1
|
import * as Adw from "@gtkx/ffi/adw";
|
|
2
2
|
import { registerNodeClass } from "../registry.js";
|
|
3
3
|
import { CommitPriority, scheduleAfterCommit } from "../scheduler.js";
|
|
4
|
+
import { hasChanged } from "./internal/utils.js";
|
|
4
5
|
import { VirtualNode } from "./virtual.js";
|
|
5
|
-
|
|
6
|
+
import { WidgetNode } from "./widget.js";
|
|
7
|
+
class ToggleNode extends VirtualNode {
|
|
6
8
|
static priority = 1;
|
|
7
|
-
toggleGroup;
|
|
8
|
-
toggle;
|
|
9
|
+
toggleGroup = null;
|
|
10
|
+
toggle = null;
|
|
9
11
|
static matches(type) {
|
|
10
12
|
return type === "Toggle";
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
canBeChildOf(parent) {
|
|
15
|
+
return parent instanceof WidgetNode && parent.container instanceof Adw.ToggleGroup;
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
if (!
|
|
17
|
+
attachTo(parent) {
|
|
18
|
+
if (!(parent instanceof WidgetNode) || !(parent.container instanceof Adw.ToggleGroup)) {
|
|
17
19
|
return;
|
|
20
|
+
}
|
|
21
|
+
if (this.toggle)
|
|
22
|
+
return;
|
|
23
|
+
this.toggleGroup = parent.container;
|
|
18
24
|
const toggleGroup = this.toggleGroup;
|
|
19
25
|
this.toggle = new Adw.Toggle();
|
|
20
26
|
scheduleAfterCommit(() => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
const toggle = this.toggle;
|
|
28
|
+
if (toggle) {
|
|
29
|
+
this.applyOwnProps(null, this.props);
|
|
30
|
+
toggleGroup.add(toggle);
|
|
24
31
|
}
|
|
25
|
-
});
|
|
32
|
+
}, CommitPriority.NORMAL);
|
|
33
|
+
}
|
|
34
|
+
detachFrom(_parent) {
|
|
35
|
+
this.removeFromGroup();
|
|
26
36
|
}
|
|
27
37
|
removeFromGroup() {
|
|
28
38
|
if (!this.toggleGroup || !this.toggle)
|
|
29
39
|
return;
|
|
30
40
|
const toggleGroup = this.toggleGroup;
|
|
31
41
|
const toggle = this.toggle;
|
|
32
|
-
this.toggle =
|
|
42
|
+
this.toggle = null;
|
|
33
43
|
scheduleAfterCommit(() => {
|
|
34
44
|
toggleGroup.remove(toggle);
|
|
35
45
|
}, CommitPriority.HIGH);
|
|
36
46
|
}
|
|
37
47
|
updateProps(oldProps, newProps) {
|
|
38
48
|
super.updateProps(oldProps, newProps);
|
|
39
|
-
|
|
40
|
-
this.applyProps(newProps);
|
|
41
|
-
}
|
|
49
|
+
this.applyOwnProps(oldProps, newProps);
|
|
42
50
|
}
|
|
43
|
-
|
|
44
|
-
this.removeFromGroup();
|
|
45
|
-
super.unmount();
|
|
46
|
-
}
|
|
47
|
-
applyProps(props) {
|
|
51
|
+
applyOwnProps(oldProps, newProps) {
|
|
48
52
|
if (!this.toggle)
|
|
49
53
|
return;
|
|
50
|
-
if (
|
|
51
|
-
this.toggle.setName(
|
|
54
|
+
if (hasChanged(oldProps, newProps, "id") && newProps.id !== undefined) {
|
|
55
|
+
this.toggle.setName(newProps.id);
|
|
52
56
|
}
|
|
53
|
-
if (
|
|
54
|
-
this.toggle.setLabel(
|
|
57
|
+
if (hasChanged(oldProps, newProps, "label") && newProps.label !== undefined) {
|
|
58
|
+
this.toggle.setLabel(newProps.label);
|
|
55
59
|
}
|
|
56
|
-
if (
|
|
57
|
-
this.toggle.setIconName(
|
|
60
|
+
if (hasChanged(oldProps, newProps, "iconName") && newProps.iconName !== undefined) {
|
|
61
|
+
this.toggle.setIconName(newProps.iconName);
|
|
58
62
|
}
|
|
59
|
-
if (
|
|
60
|
-
this.toggle.setTooltip(
|
|
63
|
+
if (hasChanged(oldProps, newProps, "tooltip") && newProps.tooltip !== undefined) {
|
|
64
|
+
this.toggle.setTooltip(newProps.tooltip);
|
|
61
65
|
}
|
|
62
|
-
if (
|
|
63
|
-
this.toggle.setEnabled(
|
|
66
|
+
if (hasChanged(oldProps, newProps, "enabled") && newProps.enabled !== undefined) {
|
|
67
|
+
this.toggle.setEnabled(newProps.enabled);
|
|
64
68
|
}
|
|
65
|
-
if (
|
|
66
|
-
this.toggle.setUseUnderline(
|
|
69
|
+
if (hasChanged(oldProps, newProps, "useUnderline") && newProps.useUnderline !== undefined) {
|
|
70
|
+
this.toggle.setUseUnderline(newProps.useUnderline);
|
|
67
71
|
}
|
|
68
72
|
}
|
|
73
|
+
unmount() {
|
|
74
|
+
this.removeFromGroup();
|
|
75
|
+
super.unmount();
|
|
76
|
+
}
|
|
69
77
|
}
|
|
70
78
|
registerNodeClass(ToggleNode);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isObjectEqual } from "@gtkx/ffi";
|
|
2
2
|
import { registerNodeClass } from "../registry.js";
|
|
3
3
|
import { SlotNode } from "./slot.js";
|
|
4
4
|
class ToolbarChildNode extends SlotNode {
|
|
@@ -17,23 +17,21 @@ class ToolbarChildNode extends SlotNode {
|
|
|
17
17
|
}
|
|
18
18
|
onChildChange(oldChild) {
|
|
19
19
|
const toolbar = this.getToolbar();
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
toolbar.remove(oldChild);
|
|
25
|
-
}
|
|
20
|
+
if (oldChild) {
|
|
21
|
+
const parent = oldChild.getParent();
|
|
22
|
+
if (parent && isObjectEqual(parent, toolbar)) {
|
|
23
|
+
toolbar.remove(oldChild);
|
|
26
24
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
}
|
|
26
|
+
if (this.child) {
|
|
27
|
+
const position = this.getPosition();
|
|
28
|
+
if (position === "top") {
|
|
29
|
+
toolbar.addTopBar(this.child);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
toolbar.addBottomBar(this.child);
|
|
35
33
|
}
|
|
36
|
-
}
|
|
34
|
+
}
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
registerNodeClass(ToolbarChildNode);
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import type { TreeListItemProps } from "../jsx.js";
|
|
2
2
|
import type { Node } from "../node.js";
|
|
3
|
-
import type { TreeStore } from "./internal/tree-store.js";
|
|
3
|
+
import type { TreeItemData, TreeStore } from "./internal/tree-store.js";
|
|
4
4
|
import { VirtualNode } from "./virtual.js";
|
|
5
5
|
type Props = Partial<TreeListItemProps>;
|
|
6
|
+
export declare const createTreeItemData: (props: Props) => TreeItemData;
|
|
6
7
|
export declare class TreeListItemNode extends VirtualNode<Props> {
|
|
7
8
|
static priority: number;
|
|
8
|
-
private store
|
|
9
|
-
private parentItemId
|
|
9
|
+
private store;
|
|
10
|
+
private parentItemId;
|
|
10
11
|
private childNodes;
|
|
11
12
|
static matches(type: string): boolean;
|
|
12
|
-
setStore(store
|
|
13
|
-
|
|
13
|
+
setStore(store: TreeStore | null): void;
|
|
14
|
+
getChildNodes(): readonly TreeListItemNode[];
|
|
15
|
+
setParentItemId(parentId: string | null): void;
|
|
14
16
|
getParentItemId(): string | null;
|
|
15
17
|
appendChild(child: Node): void;
|
|
16
18
|
insertBefore(child: Node, before: Node): void;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { registerNodeClass } from "../registry.js";
|
|
2
|
-
import { scheduleAfterCommit } from "../scheduler.js";
|
|
3
2
|
import { VirtualNode } from "./virtual.js";
|
|
3
|
+
export const createTreeItemData = (props) => ({
|
|
4
|
+
value: props.value,
|
|
5
|
+
indentForDepth: props.indentForDepth,
|
|
6
|
+
indentForIcon: props.indentForIcon,
|
|
7
|
+
hideExpander: props.hideExpander,
|
|
8
|
+
});
|
|
4
9
|
export class TreeListItemNode extends VirtualNode {
|
|
5
10
|
static priority = 1;
|
|
6
|
-
store;
|
|
7
|
-
parentItemId;
|
|
11
|
+
store = null;
|
|
12
|
+
parentItemId = null;
|
|
8
13
|
childNodes = [];
|
|
9
14
|
static matches(type) {
|
|
10
15
|
return type === "TreeListItem";
|
|
@@ -15,36 +20,32 @@ export class TreeListItemNode extends VirtualNode {
|
|
|
15
20
|
child.setStore(store);
|
|
16
21
|
}
|
|
17
22
|
}
|
|
23
|
+
getChildNodes() {
|
|
24
|
+
return this.childNodes;
|
|
25
|
+
}
|
|
18
26
|
setParentItemId(parentId) {
|
|
19
27
|
this.parentItemId = parentId;
|
|
20
28
|
}
|
|
21
29
|
getParentItemId() {
|
|
22
|
-
return this.parentItemId
|
|
30
|
+
return this.parentItemId;
|
|
23
31
|
}
|
|
24
32
|
appendChild(child) {
|
|
25
33
|
if (!(child instanceof TreeListItemNode)) {
|
|
26
34
|
return;
|
|
27
35
|
}
|
|
28
36
|
child.setStore(this.store);
|
|
29
|
-
child.setParentItemId(this.props.id);
|
|
37
|
+
child.setParentItemId(this.props.id ?? null);
|
|
30
38
|
this.childNodes.push(child);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
value: child.props.value,
|
|
35
|
-
indentForDepth: child.props.indentForDepth,
|
|
36
|
-
indentForIcon: child.props.indentForIcon,
|
|
37
|
-
hideExpander: child.props.hideExpander,
|
|
38
|
-
}, this.props.id);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
39
|
+
if (this.store && child.props.id !== undefined) {
|
|
40
|
+
this.store.addItem(child.props.id, createTreeItemData(child.props), this.props.id);
|
|
41
|
+
}
|
|
41
42
|
}
|
|
42
43
|
insertBefore(child, before) {
|
|
43
44
|
if (!(child instanceof TreeListItemNode) || !(before instanceof TreeListItemNode)) {
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
47
|
child.setStore(this.store);
|
|
47
|
-
child.setParentItemId(this.props.id);
|
|
48
|
+
child.setParentItemId(this.props.id ?? null);
|
|
48
49
|
const beforeIndex = this.childNodes.indexOf(before);
|
|
49
50
|
if (beforeIndex === -1) {
|
|
50
51
|
this.childNodes.push(child);
|
|
@@ -52,16 +53,9 @@ export class TreeListItemNode extends VirtualNode {
|
|
|
52
53
|
else {
|
|
53
54
|
this.childNodes.splice(beforeIndex, 0, child);
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
value: child.props.value,
|
|
59
|
-
indentForDepth: child.props.indentForDepth,
|
|
60
|
-
indentForIcon: child.props.indentForIcon,
|
|
61
|
-
hideExpander: child.props.hideExpander,
|
|
62
|
-
}, this.props.id);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
56
|
+
if (this.store && child.props.id !== undefined && before.props.id !== undefined) {
|
|
57
|
+
this.store.insertItemBefore(child.props.id, before.props.id, createTreeItemData(child.props), this.props.id);
|
|
58
|
+
}
|
|
65
59
|
}
|
|
66
60
|
removeChild(child) {
|
|
67
61
|
if (!(child instanceof TreeListItemNode)) {
|
|
@@ -82,20 +76,14 @@ export class TreeListItemNode extends VirtualNode {
|
|
|
82
76
|
if (!this.store) {
|
|
83
77
|
return;
|
|
84
78
|
}
|
|
85
|
-
|
|
79
|
+
const propsChanged = !oldProps ||
|
|
86
80
|
oldProps.id !== newProps.id ||
|
|
87
81
|
oldProps.value !== newProps.value ||
|
|
88
82
|
oldProps.indentForDepth !== newProps.indentForDepth ||
|
|
89
83
|
oldProps.indentForIcon !== newProps.indentForIcon ||
|
|
90
|
-
oldProps.hideExpander !== newProps.hideExpander
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
value: newProps.value,
|
|
94
|
-
indentForDepth: newProps.indentForDepth,
|
|
95
|
-
indentForIcon: newProps.indentForIcon,
|
|
96
|
-
hideExpander: newProps.hideExpander,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
84
|
+
oldProps.hideExpander !== newProps.hideExpander;
|
|
85
|
+
if (propsChanged && newProps.id !== undefined) {
|
|
86
|
+
this.store.updateItem(newProps.id, createTreeItemData(newProps));
|
|
99
87
|
}
|
|
100
88
|
}
|
|
101
89
|
}
|
|
@@ -25,9 +25,10 @@ class TreeListViewNode extends WidgetNode {
|
|
|
25
25
|
selectionMode: props.selectionMode,
|
|
26
26
|
selected: props.selected,
|
|
27
27
|
onSelectionChanged: props.onSelectionChanged,
|
|
28
|
-
});
|
|
29
|
-
this.itemRenderer = new TreeListItemRenderer();
|
|
28
|
+
}, rootContainer);
|
|
29
|
+
this.itemRenderer = new TreeListItemRenderer(this.signalStore);
|
|
30
30
|
this.itemRenderer.setStore(this.treeList.getStore());
|
|
31
|
+
this.treeList.getStore().setOnItemUpdated((id) => this.itemRenderer.rebindItem(id));
|
|
31
32
|
this.container.setFactory(this.itemRenderer.getFactory());
|
|
32
33
|
}
|
|
33
34
|
mount() {
|
|
@@ -58,18 +59,18 @@ class TreeListViewNode extends WidgetNode {
|
|
|
58
59
|
}
|
|
59
60
|
updateProps(oldProps, newProps) {
|
|
60
61
|
if (!oldProps || oldProps.renderItem !== newProps.renderItem) {
|
|
61
|
-
this.itemRenderer.setRenderFn(newProps.renderItem);
|
|
62
|
+
this.itemRenderer.setRenderFn(newProps.renderItem ?? null);
|
|
62
63
|
}
|
|
63
64
|
if (!oldProps || oldProps.estimatedItemHeight !== newProps.estimatedItemHeight) {
|
|
64
|
-
this.itemRenderer.setEstimatedItemHeight(newProps.estimatedItemHeight);
|
|
65
|
+
this.itemRenderer.setEstimatedItemHeight(newProps.estimatedItemHeight ?? null);
|
|
65
66
|
}
|
|
66
67
|
const previousModel = this.treeList.getSelectionModel();
|
|
67
|
-
this.treeList.updateProps(filterProps(oldProps
|
|
68
|
+
this.treeList.updateProps(oldProps ? filterProps(oldProps, RENDERER_PROP_NAMES) : null, filterProps(newProps, RENDERER_PROP_NAMES));
|
|
68
69
|
const currentModel = this.treeList.getSelectionModel();
|
|
69
70
|
if (previousModel !== currentModel) {
|
|
70
71
|
this.container.setModel(currentModel);
|
|
71
72
|
}
|
|
72
|
-
super.updateProps(filterProps(oldProps
|
|
73
|
+
super.updateProps(oldProps ? filterProps(oldProps, PROP_NAMES) : null, filterProps(newProps, PROP_NAMES));
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
registerNodeClass(TreeListViewNode);
|
package/dist/nodes/virtual.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class VirtualNode<P = Props> extends Node<undefined, P> {
|
|
|
5
5
|
static matches(_type: string): boolean;
|
|
6
6
|
static createContainer(): void;
|
|
7
7
|
props: P;
|
|
8
|
-
constructor(typeName: string, props: P | undefined, container: undefined, rootContainer
|
|
8
|
+
constructor(typeName: string, props: P | undefined, container: undefined, rootContainer: Container);
|
|
9
9
|
appendChild(_child: Node): void;
|
|
10
10
|
removeChild(_child: Node): void;
|
|
11
11
|
insertBefore(_child: Node, _before: Node): void;
|
package/dist/nodes/widget.d.ts
CHANGED
|
@@ -3,16 +3,8 @@ import { Node } from "../node.js";
|
|
|
3
3
|
import type { Container, ContainerClass, Props } from "../types.js";
|
|
4
4
|
export declare class WidgetNode<T extends Gtk.Widget = Gtk.Widget, P extends Props = Props> extends Node<T, P> {
|
|
5
5
|
static priority: number;
|
|
6
|
-
private motionController?;
|
|
7
|
-
private clickController?;
|
|
8
|
-
private keyController?;
|
|
9
|
-
private scrollController?;
|
|
10
|
-
private dragSourceController?;
|
|
11
|
-
private dropTargetController?;
|
|
12
|
-
private gestureDragController?;
|
|
13
|
-
private adjustmentChild?;
|
|
14
6
|
static matches(_type: string, containerOrClass?: Container | ContainerClass | null): boolean;
|
|
15
|
-
static createContainer(props: Props, containerClass: typeof Gtk.Widget): Container | null;
|
|
7
|
+
static createContainer(props: Props, containerClass: typeof Gtk.Widget, _rootContainer?: Container): Container | null;
|
|
16
8
|
appendChild(child: Node): void;
|
|
17
9
|
removeChild(child: Node): void;
|
|
18
10
|
insertBefore(child: Node, before: Node): void;
|
|
@@ -21,13 +13,7 @@ export declare class WidgetNode<T extends Gtk.Widget = Gtk.Widget, P extends Pro
|
|
|
21
13
|
updateProps(oldProps: P | null, newProps: P): void;
|
|
22
14
|
private updateSizeRequest;
|
|
23
15
|
private updateGrabFocus;
|
|
24
|
-
private
|
|
25
|
-
private ensureDragSource;
|
|
26
|
-
private ensureDropTarget;
|
|
27
|
-
private ensureGestureDrag;
|
|
28
|
-
private updateNotifyHandler;
|
|
29
|
-
private propNameToSignalName;
|
|
30
|
-
private getProperty;
|
|
16
|
+
private getPropertyDefaultValue;
|
|
31
17
|
private setProperty;
|
|
32
18
|
private detachChildFromParent;
|
|
33
19
|
private attachChild;
|