@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
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { ColumnViewColumnProps } from "../jsx.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
3
4
|
import type { Container } from "../types.js";
|
|
4
|
-
import type {
|
|
5
|
+
import type { TreeStore } from "./internal/tree-store.js";
|
|
5
6
|
import { VirtualNode } from "./virtual.js";
|
|
6
|
-
|
|
7
|
-
export declare class ColumnViewColumnNode extends VirtualNode<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
column
|
|
7
|
+
import { WidgetNode } from "./widget.js";
|
|
8
|
+
export declare class ColumnViewColumnNode extends VirtualNode<ColumnViewColumnProps, WidgetNode<Gtk.ColumnView>, never> {
|
|
9
|
+
isValidChild(_child: Node): boolean;
|
|
10
|
+
isValidParent(parent: Node): boolean;
|
|
11
|
+
private column;
|
|
11
12
|
private itemRenderer;
|
|
12
|
-
constructor(typeName: string, props:
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
constructor(typeName: string, props: ColumnViewColumnProps, container: undefined, rootContainer: Container);
|
|
14
|
+
commitUpdate(oldProps: ColumnViewColumnProps | null, newProps: ColumnViewColumnProps): void;
|
|
15
|
+
detachDeletedInstance(): void;
|
|
16
|
+
getColumn(): Gtk.ColumnViewColumn;
|
|
17
|
+
setStore(model: TreeStore | null): void;
|
|
15
18
|
setEstimatedRowHeight(height: number | null): void;
|
|
16
|
-
|
|
19
|
+
private applyOwnProps;
|
|
17
20
|
}
|
|
18
|
-
export {};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import { registerNodeClass } from "../registry.js";
|
|
3
2
|
import { ListItemRenderer } from "./internal/list-item-renderer.js";
|
|
3
|
+
import { hasChanged } from "./internal/props.js";
|
|
4
4
|
import { VirtualNode } from "./virtual.js";
|
|
5
|
+
import { WidgetNode } from "./widget.js";
|
|
5
6
|
export class ColumnViewColumnNode extends VirtualNode {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
isValidChild(_child) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
isValidParent(parent) {
|
|
11
|
+
return parent instanceof WidgetNode && parent.container instanceof Gtk.ColumnView;
|
|
9
12
|
}
|
|
10
13
|
column;
|
|
11
14
|
itemRenderer;
|
|
@@ -15,9 +18,16 @@ export class ColumnViewColumnNode extends VirtualNode {
|
|
|
15
18
|
this.column = new Gtk.ColumnViewColumn();
|
|
16
19
|
this.column.setFactory(this.itemRenderer.getFactory());
|
|
17
20
|
}
|
|
18
|
-
|
|
21
|
+
commitUpdate(oldProps, newProps) {
|
|
22
|
+
super.commitUpdate(oldProps, newProps);
|
|
23
|
+
this.applyOwnProps(oldProps, newProps);
|
|
24
|
+
}
|
|
25
|
+
detachDeletedInstance() {
|
|
19
26
|
this.itemRenderer.dispose();
|
|
20
|
-
super.
|
|
27
|
+
super.detachDeletedInstance();
|
|
28
|
+
}
|
|
29
|
+
getColumn() {
|
|
30
|
+
return this.column;
|
|
21
31
|
}
|
|
22
32
|
setStore(model) {
|
|
23
33
|
this.itemRenderer.setStore(model);
|
|
@@ -25,30 +35,26 @@ export class ColumnViewColumnNode extends VirtualNode {
|
|
|
25
35
|
setEstimatedRowHeight(height) {
|
|
26
36
|
this.itemRenderer.setEstimatedItemHeight(height);
|
|
27
37
|
}
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
this.itemRenderer.setRenderFn(newProps.renderCell);
|
|
32
|
-
}
|
|
38
|
+
applyOwnProps(oldProps, newProps) {
|
|
39
|
+
if (hasChanged(oldProps, newProps, "renderCell")) {
|
|
40
|
+
this.itemRenderer.setRenderFn(newProps.renderCell);
|
|
33
41
|
}
|
|
34
|
-
if (
|
|
35
|
-
this.column.setTitle(newProps.title
|
|
42
|
+
if (hasChanged(oldProps, newProps, "title")) {
|
|
43
|
+
this.column.setTitle(newProps.title);
|
|
36
44
|
}
|
|
37
|
-
if (
|
|
45
|
+
if (hasChanged(oldProps, newProps, "expand")) {
|
|
38
46
|
this.column.setExpand(newProps.expand ?? false);
|
|
39
47
|
}
|
|
40
|
-
if (
|
|
48
|
+
if (hasChanged(oldProps, newProps, "resizable")) {
|
|
41
49
|
this.column.setResizable(newProps.resizable ?? false);
|
|
42
50
|
}
|
|
43
|
-
if (
|
|
51
|
+
if (hasChanged(oldProps, newProps, "fixedWidth")) {
|
|
44
52
|
this.column.setFixedWidth(newProps.fixedWidth ?? -1);
|
|
45
53
|
}
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
this.column.setId(newProps.id);
|
|
49
|
-
}
|
|
54
|
+
if (hasChanged(oldProps, newProps, "id")) {
|
|
55
|
+
this.column.setId(newProps.id);
|
|
50
56
|
}
|
|
51
|
-
if (
|
|
57
|
+
if (hasChanged(oldProps, newProps, "sortable")) {
|
|
52
58
|
if (newProps.sortable) {
|
|
53
59
|
this.column.setSorter(new Gtk.StringSorter());
|
|
54
60
|
}
|
|
@@ -56,7 +62,5 @@ export class ColumnViewColumnNode extends VirtualNode {
|
|
|
56
62
|
this.column.setSorter(null);
|
|
57
63
|
}
|
|
58
64
|
}
|
|
59
|
-
super.updateProps(oldProps, newProps);
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
|
-
registerNodeClass(ColumnViewColumnNode);
|
|
@@ -1 +1,32 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { GtkColumnViewProps } from "../jsx.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
import type { Container } from "../types.js";
|
|
5
|
+
import { ColumnViewColumnNode } from "./column-view-column.js";
|
|
6
|
+
import { ListItemNode } from "./list-item.js";
|
|
7
|
+
import { type ListModelProps } from "./models/list.js";
|
|
8
|
+
import { WidgetNode } from "./widget.js";
|
|
9
|
+
declare const OWN_PROPS: readonly ["sortColumn", "sortOrder", "onSortChanged", "estimatedRowHeight"];
|
|
10
|
+
type ColumnViewProps = Pick<GtkColumnViewProps, (typeof OWN_PROPS)[number]> & ListModelProps;
|
|
11
|
+
type ColumnViewChild = ListItemNode | ColumnViewColumnNode;
|
|
12
|
+
export declare class ColumnViewNode extends WidgetNode<Gtk.ColumnView, ColumnViewProps, ColumnViewChild> {
|
|
13
|
+
private handleSortChange;
|
|
14
|
+
private list;
|
|
15
|
+
isValidChild(child: Node): boolean;
|
|
16
|
+
private columnNodes;
|
|
17
|
+
private estimatedRowHeight;
|
|
18
|
+
constructor(typeName: string, props: ColumnViewProps, container: Gtk.ColumnView, rootContainer: Container);
|
|
19
|
+
appendChild(child: ColumnViewChild): void;
|
|
20
|
+
insertBefore(child: ColumnViewChild, before: ColumnViewChild): void;
|
|
21
|
+
removeChild(child: ColumnViewChild): void;
|
|
22
|
+
finalizeInitialChildren(props: ColumnViewProps): boolean;
|
|
23
|
+
commitUpdate(oldProps: ColumnViewProps | null, newProps: ColumnViewProps): void;
|
|
24
|
+
commitMount(): void;
|
|
25
|
+
detachDeletedInstance(): void;
|
|
26
|
+
private applyOwnProps;
|
|
27
|
+
private findColumn;
|
|
28
|
+
private getColumn;
|
|
29
|
+
private getColumnIndex;
|
|
30
|
+
private findColumnInView;
|
|
31
|
+
}
|
|
1
32
|
export {};
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
-
import { COLUMN_VIEW_CLASSES } from "../generated/internal.js";
|
|
3
|
-
import { registerNodeClass } from "../registry.js";
|
|
4
2
|
import { ColumnViewColumnNode } from "./column-view-column.js";
|
|
5
|
-
import { filterProps,
|
|
3
|
+
import { filterProps, hasChanged } from "./internal/props.js";
|
|
6
4
|
import { ListItemNode } from "./list-item.js";
|
|
7
5
|
import { ListModel } from "./models/list.js";
|
|
8
6
|
import { WidgetNode } from "./widget.js";
|
|
9
|
-
const
|
|
10
|
-
class ColumnViewNode extends WidgetNode {
|
|
11
|
-
static priority = 1;
|
|
7
|
+
const OWN_PROPS = ["sortColumn", "sortOrder", "onSortChanged", "estimatedRowHeight"];
|
|
8
|
+
export class ColumnViewNode extends WidgetNode {
|
|
12
9
|
handleSortChange = null;
|
|
13
10
|
list;
|
|
11
|
+
isValidChild(child) {
|
|
12
|
+
return child instanceof ListItemNode || child instanceof ColumnViewColumnNode;
|
|
13
|
+
}
|
|
14
14
|
columnNodes = new Set();
|
|
15
15
|
estimatedRowHeight = null;
|
|
16
|
-
static matches(_type, containerOrClass) {
|
|
17
|
-
return matchesAnyClass(COLUMN_VIEW_CLASSES, containerOrClass);
|
|
18
|
-
}
|
|
19
16
|
constructor(typeName, props, container, rootContainer) {
|
|
20
17
|
super(typeName, props, container, rootContainer);
|
|
21
18
|
this.list = new ListModel({ owner: this, signalStore: this.signalStore }, {
|
|
@@ -24,82 +21,88 @@ class ColumnViewNode extends WidgetNode {
|
|
|
24
21
|
onSelectionChanged: props.onSelectionChanged,
|
|
25
22
|
});
|
|
26
23
|
}
|
|
27
|
-
mount() {
|
|
28
|
-
super.mount();
|
|
29
|
-
this.container.setModel(this.list.getSelectionModel());
|
|
30
|
-
}
|
|
31
24
|
appendChild(child) {
|
|
25
|
+
super.appendChild(child);
|
|
32
26
|
if (child instanceof ListItemNode) {
|
|
33
27
|
this.list.appendChild(child);
|
|
34
28
|
return;
|
|
35
29
|
}
|
|
36
|
-
|
|
37
|
-
throw new Error(`Cannot append '${child.typeName}' to 'ColumnView': expected x.ColumnViewColumn or x.ListItem`);
|
|
38
|
-
}
|
|
39
|
-
const existingColumn = this.findColumnInView(child.column);
|
|
30
|
+
const existingColumn = this.findColumnInView(child.getColumn());
|
|
40
31
|
if (existingColumn) {
|
|
41
32
|
this.container.removeColumn(existingColumn);
|
|
42
33
|
}
|
|
43
34
|
child.setStore(this.list.getStore());
|
|
44
35
|
child.setEstimatedRowHeight(this.estimatedRowHeight);
|
|
45
|
-
this.container.appendColumn(child.
|
|
36
|
+
this.container.appendColumn(child.getColumn());
|
|
46
37
|
this.columnNodes.add(child);
|
|
47
38
|
}
|
|
48
39
|
insertBefore(child, before) {
|
|
40
|
+
super.insertBefore(child, before);
|
|
49
41
|
if (child instanceof ListItemNode) {
|
|
50
|
-
|
|
42
|
+
if (before instanceof ListItemNode) {
|
|
43
|
+
this.list.insertBefore(child, before);
|
|
44
|
+
}
|
|
51
45
|
return;
|
|
52
46
|
}
|
|
53
|
-
|
|
54
|
-
throw new Error(`Cannot insert '${child.typeName}' into 'ColumnView': expected x.ColumnViewColumn or x.ListItem`);
|
|
55
|
-
}
|
|
56
|
-
const existingColumn = this.findColumnInView(child.column);
|
|
47
|
+
const existingColumn = this.findColumnInView(child.getColumn());
|
|
57
48
|
if (existingColumn) {
|
|
58
49
|
this.container.removeColumn(existingColumn);
|
|
59
50
|
}
|
|
60
51
|
child.setStore(this.list.getStore());
|
|
61
52
|
child.setEstimatedRowHeight(this.estimatedRowHeight);
|
|
62
53
|
if (before instanceof ColumnViewColumnNode) {
|
|
63
|
-
const beforeIndex = this.getColumnIndex(before.
|
|
64
|
-
this.container.insertColumn(beforeIndex, child.
|
|
54
|
+
const beforeIndex = this.getColumnIndex(before.getColumn());
|
|
55
|
+
this.container.insertColumn(beforeIndex, child.getColumn());
|
|
65
56
|
}
|
|
66
57
|
else {
|
|
67
|
-
this.container.appendColumn(child.
|
|
58
|
+
this.container.appendColumn(child.getColumn());
|
|
68
59
|
}
|
|
69
60
|
this.columnNodes.add(child);
|
|
70
61
|
}
|
|
71
62
|
removeChild(child) {
|
|
72
63
|
if (child instanceof ListItemNode) {
|
|
73
64
|
this.list.removeChild(child);
|
|
65
|
+
super.removeChild(child);
|
|
74
66
|
return;
|
|
75
67
|
}
|
|
76
|
-
|
|
77
|
-
throw new Error(`Cannot remove '${child.typeName}' from 'ColumnView': expected x.ColumnViewColumn or x.ListItem`);
|
|
78
|
-
}
|
|
79
|
-
const existingColumn = this.findColumnInView(child.column);
|
|
68
|
+
const existingColumn = this.findColumnInView(child.getColumn());
|
|
80
69
|
if (existingColumn) {
|
|
81
70
|
this.container.removeColumn(existingColumn);
|
|
82
71
|
}
|
|
83
72
|
child.setStore(null);
|
|
84
73
|
this.columnNodes.delete(child);
|
|
74
|
+
super.removeChild(child);
|
|
85
75
|
}
|
|
86
|
-
|
|
87
|
-
super.
|
|
76
|
+
finalizeInitialChildren(props) {
|
|
77
|
+
super.finalizeInitialChildren(props);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
commitUpdate(oldProps, newProps) {
|
|
81
|
+
super.commitUpdate(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
88
82
|
this.applyOwnProps(oldProps, newProps);
|
|
89
|
-
this.list.updateProps(oldProps, newProps);
|
|
83
|
+
this.list.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
84
|
+
}
|
|
85
|
+
commitMount() {
|
|
86
|
+
super.commitMount();
|
|
87
|
+
this.list.flushBatch();
|
|
88
|
+
this.container.setModel(this.list.getSelectionModel());
|
|
89
|
+
}
|
|
90
|
+
detachDeletedInstance() {
|
|
91
|
+
this.columnNodes.clear();
|
|
92
|
+
super.detachDeletedInstance();
|
|
90
93
|
}
|
|
91
94
|
applyOwnProps(oldProps, newProps) {
|
|
92
|
-
if (
|
|
95
|
+
if (hasChanged(oldProps, newProps, "onSortChanged")) {
|
|
93
96
|
const sorter = this.container.getSorter();
|
|
94
97
|
const onSortChanged = newProps.onSortChanged;
|
|
95
|
-
if (sorter) {
|
|
98
|
+
if (sorter instanceof Gtk.ColumnViewSorter) {
|
|
96
99
|
this.handleSortChange = () => {
|
|
97
100
|
onSortChanged?.(sorter.getPrimarySortColumn()?.getId() ?? null, sorter.getPrimarySortOrder());
|
|
98
101
|
};
|
|
99
102
|
this.signalStore.set(this, sorter, "changed", this.handleSortChange);
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
|
-
if (
|
|
105
|
+
if (hasChanged(oldProps, newProps, "sortColumn") || hasChanged(oldProps, newProps, "sortOrder")) {
|
|
103
106
|
const sortColumn = newProps.sortColumn;
|
|
104
107
|
const sortOrder = newProps.sortOrder ?? Gtk.SortType.ASCENDING;
|
|
105
108
|
if (!sortColumn) {
|
|
@@ -109,7 +112,7 @@ class ColumnViewNode extends WidgetNode {
|
|
|
109
112
|
this.container.sortByColumn(sortOrder, this.getColumn(sortColumn));
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
|
-
if (
|
|
115
|
+
if (hasChanged(oldProps, newProps, "estimatedRowHeight")) {
|
|
113
116
|
this.estimatedRowHeight = newProps.estimatedRowHeight ?? null;
|
|
114
117
|
for (const column of this.columnNodes) {
|
|
115
118
|
column.setEstimatedRowHeight(this.estimatedRowHeight);
|
|
@@ -120,6 +123,8 @@ class ColumnViewNode extends WidgetNode {
|
|
|
120
123
|
const columns = this.container.getColumns();
|
|
121
124
|
for (let i = 0; i < columns.getNItems(); i++) {
|
|
122
125
|
const column = columns.getObject(i);
|
|
126
|
+
if (!(column instanceof Gtk.ColumnViewColumn))
|
|
127
|
+
continue;
|
|
123
128
|
const result = predicate(column, i);
|
|
124
129
|
if (result !== null)
|
|
125
130
|
return result;
|
|
@@ -129,7 +134,7 @@ class ColumnViewNode extends WidgetNode {
|
|
|
129
134
|
getColumn(columnId) {
|
|
130
135
|
const column = this.findColumn((col) => (col.getId() === columnId ? col : null));
|
|
131
136
|
if (!column) {
|
|
132
|
-
throw new Error(`Unable to find column '${columnId}' in
|
|
137
|
+
throw new Error(`Unable to find column '${columnId}' in ${this.typeName}`);
|
|
133
138
|
}
|
|
134
139
|
return column;
|
|
135
140
|
}
|
|
@@ -137,7 +142,7 @@ class ColumnViewNode extends WidgetNode {
|
|
|
137
142
|
const targetId = column.getId();
|
|
138
143
|
const index = this.findColumn((col, i) => (col.getId() === targetId ? i : null));
|
|
139
144
|
if (index === null) {
|
|
140
|
-
throw new Error(`Unable to find column '${targetId}' in
|
|
145
|
+
throw new Error(`Unable to find column '${targetId}' in ${this.typeName}`);
|
|
141
146
|
}
|
|
142
147
|
return index;
|
|
143
148
|
}
|
|
@@ -145,9 +150,4 @@ class ColumnViewNode extends WidgetNode {
|
|
|
145
150
|
const targetId = column.getId();
|
|
146
151
|
return this.findColumn((col) => (col.getId() === targetId ? col : null));
|
|
147
152
|
}
|
|
148
|
-
unmount() {
|
|
149
|
-
this.columnNodes.clear();
|
|
150
|
-
super.unmount();
|
|
151
|
-
}
|
|
152
153
|
}
|
|
153
|
-
registerNodeClass(ColumnViewNode);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ContainerSlotProps } from "../jsx.js";
|
|
2
|
+
import type { Node } from "../node.js";
|
|
3
|
+
import { VirtualNode } from "./virtual.js";
|
|
4
|
+
import { WidgetNode } from "./widget.js";
|
|
5
|
+
export declare class ContainerSlotNode extends VirtualNode<ContainerSlotProps, WidgetNode, WidgetNode> {
|
|
6
|
+
isValidChild(child: Node): boolean;
|
|
7
|
+
isValidParent(parent: Node): boolean;
|
|
8
|
+
setParent(parent: WidgetNode | null): void;
|
|
9
|
+
appendChild(child: WidgetNode): void;
|
|
10
|
+
insertBefore(child: WidgetNode, before: WidgetNode): void;
|
|
11
|
+
removeChild(child: WidgetNode): void;
|
|
12
|
+
detachDeletedInstance(): void;
|
|
13
|
+
private attachToParent;
|
|
14
|
+
private detachAllChildren;
|
|
15
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { isRemovable } from "./internal/predicates.js";
|
|
2
|
+
import { VirtualNode } from "./virtual.js";
|
|
3
|
+
import { WidgetNode } from "./widget.js";
|
|
4
|
+
export class ContainerSlotNode extends VirtualNode {
|
|
5
|
+
isValidChild(child) {
|
|
6
|
+
return child instanceof WidgetNode;
|
|
7
|
+
}
|
|
8
|
+
isValidParent(parent) {
|
|
9
|
+
return parent instanceof WidgetNode;
|
|
10
|
+
}
|
|
11
|
+
setParent(parent) {
|
|
12
|
+
if (!parent && this.parent) {
|
|
13
|
+
this.detachAllChildren(this.parent.container);
|
|
14
|
+
}
|
|
15
|
+
super.setParent(parent);
|
|
16
|
+
if (parent) {
|
|
17
|
+
for (const child of this.children) {
|
|
18
|
+
this.attachToParent(parent.container, child.container);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
appendChild(child) {
|
|
23
|
+
super.appendChild(child);
|
|
24
|
+
if (this.parent) {
|
|
25
|
+
this.attachToParent(this.parent.container, child.container);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
insertBefore(child, before) {
|
|
29
|
+
super.insertBefore(child, before);
|
|
30
|
+
if (this.parent) {
|
|
31
|
+
this.attachToParent(this.parent.container, child.container);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
removeChild(child) {
|
|
35
|
+
if (this.parent && isRemovable(this.parent.container)) {
|
|
36
|
+
const widget = child.container;
|
|
37
|
+
const currentParent = widget.getParent();
|
|
38
|
+
if (currentParent && currentParent === this.parent.container) {
|
|
39
|
+
this.parent.container.remove(widget);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
super.removeChild(child);
|
|
43
|
+
}
|
|
44
|
+
detachDeletedInstance() {
|
|
45
|
+
if (this.parent) {
|
|
46
|
+
this.detachAllChildren(this.parent.container);
|
|
47
|
+
}
|
|
48
|
+
super.detachDeletedInstance();
|
|
49
|
+
}
|
|
50
|
+
attachToParent(parent, child) {
|
|
51
|
+
const methodName = this.props.id;
|
|
52
|
+
const method = parent[methodName];
|
|
53
|
+
if (typeof method !== "function") {
|
|
54
|
+
throw new Error(`Method '${methodName}' not found on '${parent.constructor.name}'`);
|
|
55
|
+
}
|
|
56
|
+
method.call(parent, child);
|
|
57
|
+
}
|
|
58
|
+
detachAllChildren(parent) {
|
|
59
|
+
if (!isRemovable(parent))
|
|
60
|
+
return;
|
|
61
|
+
for (const child of this.children) {
|
|
62
|
+
const currentParent = child.container.getParent();
|
|
63
|
+
if (currentParent && currentParent === parent) {
|
|
64
|
+
parent.remove(child.container);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
package/dist/nodes/dialog.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import * as Adw from "@gtkx/ffi/adw";
|
|
2
|
-
import type
|
|
3
|
-
import type { Container, ContainerClass } from "../types.js";
|
|
1
|
+
import type * as Adw from "@gtkx/ffi/adw";
|
|
2
|
+
import type { Props } from "../types.js";
|
|
4
3
|
import { WidgetNode } from "./widget.js";
|
|
5
4
|
export declare class DialogNode extends WidgetNode<Adw.Dialog> {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
unmount(): void;
|
|
5
|
+
protected shouldAttachToParent(): boolean;
|
|
6
|
+
finalizeInitialChildren(props: Props): boolean;
|
|
7
|
+
commitMount(): void;
|
|
8
|
+
detachDeletedInstance(): void;
|
|
11
9
|
}
|
package/dist/nodes/dialog.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import * as Adw from "@gtkx/ffi/adw";
|
|
2
|
-
import { registerNodeClass } from "../registry.js";
|
|
3
|
-
import { matchesAnyClass } from "./internal/utils.js";
|
|
4
1
|
import { WidgetNode } from "./widget.js";
|
|
2
|
+
import { WindowNode } from "./window.js";
|
|
5
3
|
export class DialogNode extends WidgetNode {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
static matches(_type, containerOrClass) {
|
|
9
|
-
return matchesAnyClass([Adw.Dialog], containerOrClass);
|
|
4
|
+
shouldAttachToParent() {
|
|
5
|
+
return false;
|
|
10
6
|
}
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
|
|
7
|
+
finalizeInitialChildren(props) {
|
|
8
|
+
this.commitUpdate(null, props);
|
|
9
|
+
return true;
|
|
14
10
|
}
|
|
15
|
-
|
|
11
|
+
commitMount() {
|
|
12
|
+
const parent = this.parent instanceof WindowNode ? this.parent.container : undefined;
|
|
13
|
+
this.container.present(parent);
|
|
14
|
+
}
|
|
15
|
+
detachDeletedInstance() {
|
|
16
16
|
this.container.forceClose();
|
|
17
|
-
super.
|
|
17
|
+
super.detachDeletedInstance();
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
registerNodeClass(DialogNode);
|
|
@@ -1 +1,13 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { GtkDrawingAreaProps } from "../jsx.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
import { EventControllerNode } from "./event-controller.js";
|
|
5
|
+
import { WidgetNode } from "./widget.js";
|
|
6
|
+
declare const OWN_PROPS: readonly ["onDraw"];
|
|
7
|
+
type DrawingAreaProps = Pick<GtkDrawingAreaProps, (typeof OWN_PROPS)[number]>;
|
|
8
|
+
export declare class DrawingAreaNode extends WidgetNode<Gtk.DrawingArea, DrawingAreaProps, EventControllerNode> {
|
|
9
|
+
isValidChild(child: Node): boolean;
|
|
10
|
+
commitUpdate(oldProps: DrawingAreaProps | null, newProps: DrawingAreaProps): void;
|
|
11
|
+
private applyOwnProps;
|
|
12
|
+
}
|
|
1
13
|
export {};
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { filterProps, hasChanged, matchesAnyClass } from "./internal/utils.js";
|
|
1
|
+
import { EventControllerNode } from "./event-controller.js";
|
|
2
|
+
import { filterProps, hasChanged } from "./internal/props.js";
|
|
4
3
|
import { WidgetNode } from "./widget.js";
|
|
5
4
|
const OWN_PROPS = ["onDraw"];
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return matchesAnyClass([Gtk.DrawingArea], containerOrClass);
|
|
5
|
+
const pendingDrawFuncs = [];
|
|
6
|
+
function ensurePendingBatch() {
|
|
7
|
+
if (pendingDrawFuncs.length === 0) {
|
|
8
|
+
queueMicrotask(flushPendingDrawFuncs);
|
|
11
9
|
}
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
return pendingDrawFuncs;
|
|
11
|
+
}
|
|
12
|
+
function flushPendingDrawFuncs() {
|
|
13
|
+
const batch = pendingDrawFuncs.splice(0);
|
|
14
|
+
for (const { container, fn } of batch) {
|
|
15
|
+
container.setDrawFunc(fn);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class DrawingAreaNode extends WidgetNode {
|
|
19
|
+
isValidChild(child) {
|
|
20
|
+
return child instanceof EventControllerNode;
|
|
21
|
+
}
|
|
22
|
+
commitUpdate(oldProps, newProps) {
|
|
23
|
+
super.commitUpdate(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
14
24
|
this.applyOwnProps(oldProps, newProps);
|
|
15
25
|
}
|
|
16
26
|
applyOwnProps(oldProps, newProps) {
|
|
17
|
-
if (hasChanged(oldProps, newProps, "onDraw")
|
|
18
|
-
if (this.container.
|
|
27
|
+
if (hasChanged(oldProps, newProps, "onDraw")) {
|
|
28
|
+
if (this.container.getAllocatedWidth() > 0) {
|
|
19
29
|
this.container.setDrawFunc(newProps.onDraw);
|
|
20
30
|
}
|
|
21
|
-
else {
|
|
22
|
-
this.
|
|
23
|
-
this.signalStore.set(this, this.container, "realize", this.onRealize.bind(this));
|
|
31
|
+
else if (newProps.onDraw) {
|
|
32
|
+
ensurePendingBatch().push({ container: this.container, fn: newProps.onDraw });
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
35
|
}
|
|
27
|
-
onRealize() {
|
|
28
|
-
if (this.pendingDrawFunc) {
|
|
29
|
-
const drawFunc = this.pendingDrawFunc;
|
|
30
|
-
this.pendingDrawFunc = null;
|
|
31
|
-
queueMicrotask(() => this.container.setDrawFunc(drawFunc));
|
|
32
|
-
}
|
|
33
|
-
this.signalStore.set(this, this.container, "realize", null);
|
|
34
|
-
}
|
|
35
36
|
}
|
|
36
|
-
registerNodeClass(DrawingAreaNode);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AdwComboRowProps, GtkDropDownProps } from "../jsx.js";
|
|
2
|
+
import type { Node } from "../node.js";
|
|
3
|
+
import type { DropDownWidget } from "../registry.js";
|
|
4
|
+
import type { Container } from "../types.js";
|
|
5
|
+
import { ListItemNode } from "./list-item.js";
|
|
6
|
+
import { WidgetNode } from "./widget.js";
|
|
7
|
+
declare const OWN_PROPS: readonly ["selectedId", "onSelectionChanged"];
|
|
8
|
+
type DropDownProps = Pick<GtkDropDownProps | AdwComboRowProps, (typeof OWN_PROPS)[number]>;
|
|
9
|
+
export declare class DropDownNode extends WidgetNode<DropDownWidget, DropDownProps, ListItemNode> {
|
|
10
|
+
private store;
|
|
11
|
+
private initialSelectedId;
|
|
12
|
+
isValidChild(child: Node): boolean;
|
|
13
|
+
constructor(typeName: string, props: DropDownProps, container: DropDownWidget, rootContainer: Container);
|
|
14
|
+
finalizeInitialChildren(props: DropDownProps): boolean;
|
|
15
|
+
private reapplyInitialSelectedId;
|
|
16
|
+
appendChild(child: ListItemNode): void;
|
|
17
|
+
insertBefore(child: ListItemNode, before: ListItemNode): void;
|
|
18
|
+
removeChild(child: ListItemNode): void;
|
|
19
|
+
commitUpdate(oldProps: DropDownProps | null, newProps: DropDownProps): void;
|
|
20
|
+
private applyOwnProps;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { filterProps, hasChanged } from "./internal/props.js";
|
|
2
|
+
import { SimpleListStore } from "./internal/simple-list-store.js";
|
|
3
|
+
import { ListItemNode } from "./list-item.js";
|
|
4
|
+
import { WidgetNode } from "./widget.js";
|
|
5
|
+
const OWN_PROPS = ["selectedId", "onSelectionChanged"];
|
|
6
|
+
export class DropDownNode extends WidgetNode {
|
|
7
|
+
store = new SimpleListStore();
|
|
8
|
+
initialSelectedId;
|
|
9
|
+
isValidChild(child) {
|
|
10
|
+
return child instanceof ListItemNode;
|
|
11
|
+
}
|
|
12
|
+
constructor(typeName, props, container, rootContainer) {
|
|
13
|
+
super(typeName, props, container, rootContainer);
|
|
14
|
+
this.store.beginBatch();
|
|
15
|
+
this.initialSelectedId = props.selectedId;
|
|
16
|
+
this.container.setModel(this.store.getModel());
|
|
17
|
+
}
|
|
18
|
+
finalizeInitialChildren(props) {
|
|
19
|
+
super.finalizeInitialChildren(props);
|
|
20
|
+
this.store.flushBatch();
|
|
21
|
+
this.reapplyInitialSelectedId();
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
reapplyInitialSelectedId() {
|
|
25
|
+
if (this.initialSelectedId == null)
|
|
26
|
+
return;
|
|
27
|
+
const index = this.store.getIndexById(this.initialSelectedId);
|
|
28
|
+
this.initialSelectedId = undefined;
|
|
29
|
+
if (index !== null) {
|
|
30
|
+
this.container.setSelected(index);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
appendChild(child) {
|
|
34
|
+
super.appendChild(child);
|
|
35
|
+
child.setStore(this.store);
|
|
36
|
+
this.store.addItem(child.props.id, child.props.value);
|
|
37
|
+
}
|
|
38
|
+
insertBefore(child, before) {
|
|
39
|
+
super.insertBefore(child, before);
|
|
40
|
+
child.setStore(this.store);
|
|
41
|
+
this.store.insertItemBefore(child.props.id, before.props.id, child.props.value);
|
|
42
|
+
}
|
|
43
|
+
removeChild(child) {
|
|
44
|
+
this.store.removeItem(child.props.id);
|
|
45
|
+
super.removeChild(child);
|
|
46
|
+
}
|
|
47
|
+
commitUpdate(oldProps, newProps) {
|
|
48
|
+
super.commitUpdate(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
49
|
+
this.applyOwnProps(oldProps, newProps);
|
|
50
|
+
}
|
|
51
|
+
applyOwnProps(oldProps, newProps) {
|
|
52
|
+
if (hasChanged(oldProps, newProps, "onSelectionChanged")) {
|
|
53
|
+
const onSelectionChanged = newProps.onSelectionChanged;
|
|
54
|
+
const handleSelectionChange = onSelectionChanged
|
|
55
|
+
? () => {
|
|
56
|
+
const selectedIndex = this.container.getSelected();
|
|
57
|
+
const id = this.store.getIdAtIndex(selectedIndex);
|
|
58
|
+
if (id !== null) {
|
|
59
|
+
onSelectionChanged(id);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
: undefined;
|
|
63
|
+
this.signalStore.set(this, this.container, "notify::selected", handleSelectionChange);
|
|
64
|
+
}
|
|
65
|
+
if (hasChanged(oldProps, newProps, "selectedId")) {
|
|
66
|
+
const index = newProps.selectedId != null ? this.store.getIndexById(newProps.selectedId) : null;
|
|
67
|
+
if (index !== null) {
|
|
68
|
+
this.container.setSelected(index);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|