@gtkx/react 0.18.0 → 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/errors.d.ts +1 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +1 -0
- package/dist/errors.js.map +1 -0
- package/dist/factory.d.ts +1 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +1 -0
- package/dist/factory.js.map +1 -0
- package/dist/fiber-root.d.ts +1 -0
- package/dist/fiber-root.d.ts.map +1 -0
- package/dist/fiber-root.js +1 -0
- package/dist/fiber-root.js.map +1 -0
- package/dist/generated/internal.d.ts +1 -0
- package/dist/generated/internal.d.ts.map +1 -0
- package/dist/generated/internal.js +1 -0
- package/dist/generated/internal.js.map +1 -0
- package/dist/generated/jsx.d.ts +1 -0
- package/dist/generated/jsx.d.ts.map +1 -0
- package/dist/generated/jsx.js +1 -0
- package/dist/generated/jsx.js.map +1 -0
- package/dist/generated/registry.d.ts +1 -0
- package/dist/generated/registry.d.ts.map +1 -0
- package/dist/generated/registry.js +1 -0
- package/dist/generated/registry.js.map +1 -0
- package/dist/host-config.d.ts +1 -0
- package/dist/host-config.d.ts.map +1 -0
- package/dist/host-config.js +1 -0
- package/dist/host-config.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx.d.ts +1 -0
- package/dist/jsx.d.ts.map +1 -0
- package/dist/jsx.js +1 -0
- package/dist/jsx.js.map +1 -0
- package/dist/metadata.d.ts +1 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/metadata.js +1 -0
- package/dist/metadata.js.map +1 -0
- package/dist/node.d.ts +1 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +1 -0
- package/dist/node.js.map +1 -0
- package/dist/nodes/adjustable.d.ts +1 -0
- package/dist/nodes/adjustable.d.ts.map +1 -0
- package/dist/nodes/adjustable.js +1 -0
- package/dist/nodes/adjustable.js.map +1 -0
- package/dist/nodes/alert-dialog-response.d.ts +1 -0
- package/dist/nodes/alert-dialog-response.d.ts.map +1 -0
- package/dist/nodes/alert-dialog-response.js +1 -0
- package/dist/nodes/alert-dialog-response.js.map +1 -0
- package/dist/nodes/animation.d.ts +1 -0
- package/dist/nodes/animation.d.ts.map +1 -0
- package/dist/nodes/animation.js +1 -0
- package/dist/nodes/animation.js.map +1 -0
- package/dist/nodes/application.d.ts +1 -0
- package/dist/nodes/application.d.ts.map +1 -0
- package/dist/nodes/application.js +1 -0
- package/dist/nodes/application.js.map +1 -0
- package/dist/nodes/calendar.d.ts +1 -0
- package/dist/nodes/calendar.d.ts.map +1 -0
- package/dist/nodes/calendar.js +1 -0
- package/dist/nodes/calendar.js.map +1 -0
- package/dist/nodes/color-dialog-button.d.ts +1 -0
- package/dist/nodes/color-dialog-button.d.ts.map +1 -0
- package/dist/nodes/color-dialog-button.js +1 -0
- package/dist/nodes/color-dialog-button.js.map +1 -0
- package/dist/nodes/column-view-column.d.ts +1 -0
- package/dist/nodes/column-view-column.d.ts.map +1 -0
- package/dist/nodes/column-view-column.js +1 -0
- package/dist/nodes/column-view-column.js.map +1 -0
- package/dist/nodes/column-view.d.ts +1 -0
- package/dist/nodes/column-view.d.ts.map +1 -0
- package/dist/nodes/column-view.js +1 -0
- package/dist/nodes/column-view.js.map +1 -0
- package/dist/nodes/container-slot.d.ts +1 -0
- package/dist/nodes/container-slot.d.ts.map +1 -0
- package/dist/nodes/container-slot.js +1 -0
- package/dist/nodes/container-slot.js.map +1 -0
- package/dist/nodes/dialog.d.ts +1 -0
- package/dist/nodes/dialog.d.ts.map +1 -0
- package/dist/nodes/dialog.js +1 -0
- package/dist/nodes/dialog.js.map +1 -0
- package/dist/nodes/drawing-area.d.ts +1 -0
- package/dist/nodes/drawing-area.d.ts.map +1 -0
- package/dist/nodes/drawing-area.js +1 -0
- package/dist/nodes/drawing-area.js.map +1 -0
- package/dist/nodes/drop-down.d.ts +1 -0
- package/dist/nodes/drop-down.d.ts.map +1 -0
- package/dist/nodes/drop-down.js +1 -0
- package/dist/nodes/drop-down.js.map +1 -0
- package/dist/nodes/event-controller.d.ts +1 -0
- package/dist/nodes/event-controller.d.ts.map +1 -0
- package/dist/nodes/event-controller.js +1 -0
- package/dist/nodes/event-controller.js.map +1 -0
- package/dist/nodes/fixed-child.d.ts +1 -0
- package/dist/nodes/fixed-child.d.ts.map +1 -0
- package/dist/nodes/fixed-child.js +1 -0
- package/dist/nodes/fixed-child.js.map +1 -0
- package/dist/nodes/font-dialog-button.d.ts +1 -0
- package/dist/nodes/font-dialog-button.d.ts.map +1 -0
- package/dist/nodes/font-dialog-button.js +1 -0
- package/dist/nodes/font-dialog-button.js.map +1 -0
- package/dist/nodes/grid-child.d.ts +1 -0
- package/dist/nodes/grid-child.d.ts.map +1 -0
- package/dist/nodes/grid-child.js +1 -0
- package/dist/nodes/grid-child.js.map +1 -0
- package/dist/nodes/grid-view.d.ts +1 -0
- package/dist/nodes/grid-view.d.ts.map +1 -0
- package/dist/nodes/grid-view.js +1 -0
- package/dist/nodes/grid-view.js.map +1 -0
- package/dist/nodes/internal/base-item-renderer.d.ts +1 -0
- package/dist/nodes/internal/base-item-renderer.d.ts.map +1 -0
- package/dist/nodes/internal/base-item-renderer.js +1 -0
- package/dist/nodes/internal/base-item-renderer.js.map +1 -0
- package/dist/nodes/internal/grid-item-renderer.d.ts +1 -0
- package/dist/nodes/internal/grid-item-renderer.d.ts.map +1 -0
- package/dist/nodes/internal/grid-item-renderer.js +1 -0
- package/dist/nodes/internal/grid-item-renderer.js.map +1 -0
- package/dist/nodes/internal/list-item-renderer.d.ts +1 -0
- package/dist/nodes/internal/list-item-renderer.d.ts.map +1 -0
- package/dist/nodes/internal/list-item-renderer.js +1 -0
- package/dist/nodes/internal/list-item-renderer.js.map +1 -0
- package/dist/nodes/internal/list-store.d.ts +1 -0
- package/dist/nodes/internal/list-store.d.ts.map +1 -0
- package/dist/nodes/internal/list-store.js +1 -0
- package/dist/nodes/internal/list-store.js.map +1 -0
- package/dist/nodes/internal/predicates.d.ts +1 -0
- package/dist/nodes/internal/predicates.d.ts.map +1 -0
- package/dist/nodes/internal/predicates.js +1 -0
- package/dist/nodes/internal/predicates.js.map +1 -0
- package/dist/nodes/internal/props.d.ts +1 -0
- package/dist/nodes/internal/props.d.ts.map +1 -0
- package/dist/nodes/internal/props.js +1 -0
- package/dist/nodes/internal/props.js.map +1 -0
- package/dist/nodes/internal/selection-model-controller.d.ts +1 -0
- package/dist/nodes/internal/selection-model-controller.d.ts.map +1 -0
- package/dist/nodes/internal/selection-model-controller.js +1 -0
- package/dist/nodes/internal/selection-model-controller.js.map +1 -0
- package/dist/nodes/internal/signal-store.d.ts +1 -0
- package/dist/nodes/internal/signal-store.d.ts.map +1 -0
- package/dist/nodes/internal/signal-store.js +1 -0
- package/dist/nodes/internal/signal-store.js.map +1 -0
- package/dist/nodes/internal/simple-list-store.d.ts +1 -0
- package/dist/nodes/internal/simple-list-store.d.ts.map +1 -0
- package/dist/nodes/internal/simple-list-store.js +1 -0
- package/dist/nodes/internal/simple-list-store.js.map +1 -0
- package/dist/nodes/internal/text-buffer-controller.d.ts +1 -0
- package/dist/nodes/internal/text-buffer-controller.d.ts.map +1 -0
- package/dist/nodes/internal/text-buffer-controller.js +1 -0
- package/dist/nodes/internal/text-buffer-controller.js.map +1 -0
- package/dist/nodes/internal/tree-store.d.ts +1 -0
- package/dist/nodes/internal/tree-store.d.ts.map +1 -0
- package/dist/nodes/internal/tree-store.js +1 -0
- package/dist/nodes/internal/tree-store.js.map +1 -0
- package/dist/nodes/internal/widget.d.ts +1 -0
- package/dist/nodes/internal/widget.d.ts.map +1 -0
- package/dist/nodes/internal/widget.js +1 -0
- package/dist/nodes/internal/widget.js.map +1 -0
- package/dist/nodes/level-bar.d.ts +1 -0
- package/dist/nodes/level-bar.d.ts.map +1 -0
- package/dist/nodes/level-bar.js +1 -0
- package/dist/nodes/level-bar.js.map +1 -0
- package/dist/nodes/list-item.d.ts +1 -0
- package/dist/nodes/list-item.d.ts.map +1 -0
- package/dist/nodes/list-item.js +1 -0
- package/dist/nodes/list-item.js.map +1 -0
- package/dist/nodes/list-view.d.ts +1 -0
- package/dist/nodes/list-view.d.ts.map +1 -0
- package/dist/nodes/list-view.js +1 -0
- package/dist/nodes/list-view.js.map +1 -0
- package/dist/nodes/menu.d.ts +1 -0
- package/dist/nodes/menu.d.ts.map +1 -0
- package/dist/nodes/menu.js +1 -0
- package/dist/nodes/menu.js.map +1 -0
- package/dist/nodes/models/grid.d.ts +1 -0
- package/dist/nodes/models/grid.d.ts.map +1 -0
- package/dist/nodes/models/grid.js +1 -0
- package/dist/nodes/models/grid.js.map +1 -0
- package/dist/nodes/models/list.d.ts +1 -0
- package/dist/nodes/models/list.d.ts.map +1 -0
- package/dist/nodes/models/list.js +1 -0
- package/dist/nodes/models/list.js.map +1 -0
- package/dist/nodes/models/menu.d.ts +1 -0
- package/dist/nodes/models/menu.d.ts.map +1 -0
- package/dist/nodes/models/menu.js +1 -0
- package/dist/nodes/models/menu.js.map +1 -0
- package/dist/nodes/navigation-page.d.ts +1 -0
- package/dist/nodes/navigation-page.d.ts.map +1 -0
- package/dist/nodes/navigation-page.js +1 -0
- package/dist/nodes/navigation-page.js.map +1 -0
- package/dist/nodes/navigation-view.d.ts +1 -0
- package/dist/nodes/navigation-view.d.ts.map +1 -0
- package/dist/nodes/navigation-view.js +1 -0
- package/dist/nodes/navigation-view.js.map +1 -0
- package/dist/nodes/notebook-page-tab.d.ts +1 -0
- package/dist/nodes/notebook-page-tab.d.ts.map +1 -0
- package/dist/nodes/notebook-page-tab.js +1 -0
- package/dist/nodes/notebook-page-tab.js.map +1 -0
- package/dist/nodes/notebook-page.d.ts +1 -0
- package/dist/nodes/notebook-page.d.ts.map +1 -0
- package/dist/nodes/notebook-page.js +1 -0
- package/dist/nodes/notebook-page.js.map +1 -0
- package/dist/nodes/notebook.d.ts +1 -0
- package/dist/nodes/notebook.d.ts.map +1 -0
- package/dist/nodes/notebook.js +1 -0
- package/dist/nodes/notebook.js.map +1 -0
- package/dist/nodes/overlay-child.d.ts +1 -0
- package/dist/nodes/overlay-child.d.ts.map +1 -0
- package/dist/nodes/overlay-child.js +1 -0
- package/dist/nodes/overlay-child.js.map +1 -0
- package/dist/nodes/popover-menu.d.ts +1 -0
- package/dist/nodes/popover-menu.d.ts.map +1 -0
- package/dist/nodes/popover-menu.js +1 -0
- package/dist/nodes/popover-menu.js.map +1 -0
- package/dist/nodes/scale.d.ts +1 -0
- package/dist/nodes/scale.d.ts.map +1 -0
- package/dist/nodes/scale.js +1 -0
- package/dist/nodes/scale.js.map +1 -0
- package/dist/nodes/scrolled-window.d.ts +1 -0
- package/dist/nodes/scrolled-window.d.ts.map +1 -0
- package/dist/nodes/scrolled-window.js +1 -0
- package/dist/nodes/scrolled-window.js.map +1 -0
- package/dist/nodes/search-bar.d.ts +1 -0
- package/dist/nodes/search-bar.d.ts.map +1 -0
- package/dist/nodes/search-bar.js +1 -0
- package/dist/nodes/search-bar.js.map +1 -0
- package/dist/nodes/shortcut-controller.d.ts +1 -0
- package/dist/nodes/shortcut-controller.d.ts.map +1 -0
- package/dist/nodes/shortcut-controller.js +1 -0
- package/dist/nodes/shortcut-controller.js.map +1 -0
- package/dist/nodes/shortcut.d.ts +1 -0
- package/dist/nodes/shortcut.d.ts.map +1 -0
- package/dist/nodes/shortcut.js +1 -0
- package/dist/nodes/shortcut.js.map +1 -0
- package/dist/nodes/slot.d.ts +1 -0
- package/dist/nodes/slot.d.ts.map +1 -0
- package/dist/nodes/slot.js +1 -0
- package/dist/nodes/slot.js.map +1 -0
- package/dist/nodes/source-view.d.ts +1 -0
- package/dist/nodes/source-view.d.ts.map +1 -0
- package/dist/nodes/source-view.js +1 -0
- package/dist/nodes/source-view.js.map +1 -0
- package/dist/nodes/stack-page.d.ts +1 -0
- package/dist/nodes/stack-page.d.ts.map +1 -0
- package/dist/nodes/stack-page.js +1 -0
- package/dist/nodes/stack-page.js.map +1 -0
- package/dist/nodes/stack.d.ts +1 -0
- package/dist/nodes/stack.d.ts.map +1 -0
- package/dist/nodes/stack.js +1 -0
- package/dist/nodes/stack.js.map +1 -0
- package/dist/nodes/text-anchor.d.ts +1 -0
- package/dist/nodes/text-anchor.d.ts.map +1 -0
- package/dist/nodes/text-anchor.js +1 -0
- package/dist/nodes/text-anchor.js.map +1 -0
- package/dist/nodes/text-content.d.ts +1 -0
- package/dist/nodes/text-content.d.ts.map +1 -0
- package/dist/nodes/text-content.js +1 -0
- package/dist/nodes/text-content.js.map +1 -0
- package/dist/nodes/text-paintable.d.ts +1 -0
- package/dist/nodes/text-paintable.d.ts.map +1 -0
- package/dist/nodes/text-paintable.js +1 -0
- package/dist/nodes/text-paintable.js.map +1 -0
- package/dist/nodes/text-segment.d.ts +1 -0
- package/dist/nodes/text-segment.d.ts.map +1 -0
- package/dist/nodes/text-segment.js +1 -0
- package/dist/nodes/text-segment.js.map +1 -0
- package/dist/nodes/text-tag.d.ts +1 -0
- package/dist/nodes/text-tag.d.ts.map +1 -0
- package/dist/nodes/text-tag.js +1 -0
- package/dist/nodes/text-tag.js.map +1 -0
- package/dist/nodes/text-view.d.ts +1 -0
- package/dist/nodes/text-view.d.ts.map +1 -0
- package/dist/nodes/text-view.js +1 -0
- package/dist/nodes/text-view.js.map +1 -0
- package/dist/nodes/toggle-group.d.ts +1 -0
- package/dist/nodes/toggle-group.d.ts.map +1 -0
- package/dist/nodes/toggle-group.js +1 -0
- package/dist/nodes/toggle-group.js.map +1 -0
- package/dist/nodes/toggle.d.ts +1 -0
- package/dist/nodes/toggle.d.ts.map +1 -0
- package/dist/nodes/toggle.js +1 -0
- package/dist/nodes/toggle.js.map +1 -0
- package/dist/nodes/virtual.d.ts +1 -0
- package/dist/nodes/virtual.d.ts.map +1 -0
- package/dist/nodes/virtual.js +1 -0
- package/dist/nodes/virtual.js.map +1 -0
- package/dist/nodes/web-view.d.ts +1 -0
- package/dist/nodes/web-view.d.ts.map +1 -0
- package/dist/nodes/web-view.js +1 -0
- package/dist/nodes/web-view.js.map +1 -0
- package/dist/nodes/widget.d.ts +1 -0
- package/dist/nodes/widget.d.ts.map +1 -0
- package/dist/nodes/widget.js +1 -0
- package/dist/nodes/widget.js.map +1 -0
- package/dist/nodes/window.d.ts +1 -0
- package/dist/nodes/window.d.ts.map +1 -0
- package/dist/nodes/window.js +1 -0
- package/dist/nodes/window.js.map +1 -0
- package/dist/portal.d.ts +1 -0
- package/dist/portal.d.ts.map +1 -0
- package/dist/portal.js +1 -0
- package/dist/portal.js.map +1 -0
- package/dist/reconciler.d.ts +1 -0
- package/dist/reconciler.d.ts.map +1 -0
- package/dist/reconciler.js +1 -0
- package/dist/reconciler.js.map +1 -0
- package/dist/registry.d.ts +1 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +1 -0
- package/dist/registry.js.map +1 -0
- package/dist/render.d.ts +1 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +1 -0
- package/dist/render.js.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +6 -4
- package/src/errors.ts +52 -0
- package/src/factory.ts +62 -0
- package/src/fiber-root.ts +20 -0
- package/src/generated/internal.ts +2134 -0
- package/src/generated/jsx.ts +20068 -0
- package/src/generated/registry.ts +16 -0
- package/src/host-config.ts +186 -0
- package/src/index.ts +11 -0
- package/src/jsx.ts +1294 -0
- package/src/metadata.ts +36 -0
- package/src/node.ts +109 -0
- package/src/nodes/adjustable.ts +68 -0
- package/src/nodes/alert-dialog-response.ts +78 -0
- package/src/nodes/animation.ts +402 -0
- package/src/nodes/application.ts +56 -0
- package/src/nodes/calendar.ts +38 -0
- package/src/nodes/color-dialog-button.ts +69 -0
- package/src/nodes/column-view-column.ts +84 -0
- package/src/nodes/column-view.ts +192 -0
- package/src/nodes/container-slot.ts +87 -0
- package/src/nodes/dialog.ts +25 -0
- package/src/nodes/drawing-area.ts +51 -0
- package/src/nodes/drop-down.ts +92 -0
- package/src/nodes/event-controller.ts +100 -0
- package/src/nodes/fixed-child.ts +108 -0
- package/src/nodes/font-dialog-button.ts +97 -0
- package/src/nodes/grid-child.ts +103 -0
- package/src/nodes/grid-view.ts +96 -0
- package/src/nodes/internal/base-item-renderer.ts +108 -0
- package/src/nodes/internal/grid-item-renderer.ts +71 -0
- package/src/nodes/internal/list-item-renderer.ts +155 -0
- package/src/nodes/internal/list-store.ts +105 -0
- package/src/nodes/internal/predicates.ts +80 -0
- package/src/nodes/internal/props.ts +51 -0
- package/src/nodes/internal/selection-model-controller.ts +115 -0
- package/src/nodes/internal/signal-store.ts +141 -0
- package/src/nodes/internal/simple-list-store.ts +99 -0
- package/src/nodes/internal/text-buffer-controller.ts +374 -0
- package/src/nodes/internal/tree-store.ts +237 -0
- package/src/nodes/internal/widget.ts +78 -0
- package/src/nodes/level-bar.ts +36 -0
- package/src/nodes/list-item.ts +107 -0
- package/src/nodes/list-view.ts +97 -0
- package/src/nodes/menu.ts +27 -0
- package/src/nodes/models/grid.ts +105 -0
- package/src/nodes/models/list.ts +140 -0
- package/src/nodes/models/menu.ts +310 -0
- package/src/nodes/navigation-page.ts +154 -0
- package/src/nodes/navigation-view.ts +58 -0
- package/src/nodes/notebook-page-tab.ts +55 -0
- package/src/nodes/notebook-page.ts +185 -0
- package/src/nodes/notebook.ts +28 -0
- package/src/nodes/overlay-child.ts +109 -0
- package/src/nodes/popover-menu.ts +59 -0
- package/src/nodes/scale.ts +28 -0
- package/src/nodes/scrolled-window.ts +23 -0
- package/src/nodes/search-bar.ts +27 -0
- package/src/nodes/shortcut-controller.ts +27 -0
- package/src/nodes/shortcut.ts +69 -0
- package/src/nodes/slot.ts +138 -0
- package/src/nodes/source-view.ts +130 -0
- package/src/nodes/stack-page.ts +170 -0
- package/src/nodes/stack.ts +35 -0
- package/src/nodes/text-anchor.ts +74 -0
- package/src/nodes/text-content.ts +14 -0
- package/src/nodes/text-paintable.ts +51 -0
- package/src/nodes/text-segment.ts +55 -0
- package/src/nodes/text-tag.ts +287 -0
- package/src/nodes/text-view.ts +93 -0
- package/src/nodes/toggle-group.ts +27 -0
- package/src/nodes/toggle.ts +72 -0
- package/src/nodes/virtual.ts +16 -0
- package/src/nodes/web-view.ts +22 -0
- package/src/nodes/widget.ts +398 -0
- package/src/nodes/window.ts +159 -0
- package/src/portal.ts +37 -0
- package/src/reconciler.ts +52 -0
- package/src/registry.ts +123 -0
- package/src/render.tsx +192 -0
- package/src/types.ts +7 -0
|
@@ -0,0 +1,92 @@
|
|
|
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 { filterProps, hasChanged } from "./internal/props.js";
|
|
6
|
+
import { SimpleListStore } from "./internal/simple-list-store.js";
|
|
7
|
+
import { ListItemNode } from "./list-item.js";
|
|
8
|
+
import { WidgetNode } from "./widget.js";
|
|
9
|
+
|
|
10
|
+
const OWN_PROPS = ["selectedId", "onSelectionChanged"] as const;
|
|
11
|
+
|
|
12
|
+
type DropDownProps = Pick<GtkDropDownProps | AdwComboRowProps, (typeof OWN_PROPS)[number]>;
|
|
13
|
+
|
|
14
|
+
export class DropDownNode extends WidgetNode<DropDownWidget, DropDownProps, ListItemNode> {
|
|
15
|
+
private store = new SimpleListStore();
|
|
16
|
+
private initialSelectedId: string | null | undefined;
|
|
17
|
+
|
|
18
|
+
public override isValidChild(child: Node): boolean {
|
|
19
|
+
return child instanceof ListItemNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
constructor(typeName: string, props: DropDownProps, container: DropDownWidget, rootContainer: Container) {
|
|
23
|
+
super(typeName, props, container, rootContainer);
|
|
24
|
+
this.store.beginBatch();
|
|
25
|
+
this.initialSelectedId = props.selectedId;
|
|
26
|
+
this.container.setModel(this.store.getModel());
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public override finalizeInitialChildren(props: DropDownProps): boolean {
|
|
30
|
+
super.finalizeInitialChildren(props);
|
|
31
|
+
this.store.flushBatch();
|
|
32
|
+
this.reapplyInitialSelectedId();
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private reapplyInitialSelectedId(): void {
|
|
37
|
+
if (this.initialSelectedId == null) return;
|
|
38
|
+
const index = this.store.getIndexById(this.initialSelectedId);
|
|
39
|
+
this.initialSelectedId = undefined;
|
|
40
|
+
if (index !== null) {
|
|
41
|
+
this.container.setSelected(index);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public override appendChild(child: ListItemNode): void {
|
|
46
|
+
super.appendChild(child);
|
|
47
|
+
child.setStore(this.store);
|
|
48
|
+
this.store.addItem(child.props.id, child.props.value as string);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public override insertBefore(child: ListItemNode, before: ListItemNode): void {
|
|
52
|
+
super.insertBefore(child, before);
|
|
53
|
+
child.setStore(this.store);
|
|
54
|
+
this.store.insertItemBefore(child.props.id, before.props.id, child.props.value as string);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public override removeChild(child: ListItemNode): void {
|
|
58
|
+
this.store.removeItem(child.props.id);
|
|
59
|
+
super.removeChild(child);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public override commitUpdate(oldProps: DropDownProps | null, newProps: DropDownProps): void {
|
|
63
|
+
super.commitUpdate(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
64
|
+
this.applyOwnProps(oldProps, newProps);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private applyOwnProps(oldProps: DropDownProps | null, newProps: DropDownProps): void {
|
|
68
|
+
if (hasChanged(oldProps, newProps, "onSelectionChanged")) {
|
|
69
|
+
const onSelectionChanged = newProps.onSelectionChanged;
|
|
70
|
+
|
|
71
|
+
const handleSelectionChange = onSelectionChanged
|
|
72
|
+
? () => {
|
|
73
|
+
const selectedIndex = this.container.getSelected();
|
|
74
|
+
const id = this.store.getIdAtIndex(selectedIndex);
|
|
75
|
+
if (id !== null) {
|
|
76
|
+
onSelectionChanged(id);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
: undefined;
|
|
80
|
+
|
|
81
|
+
this.signalStore.set(this, this.container, "notify::selected", handleSelectionChange);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (hasChanged(oldProps, newProps, "selectedId")) {
|
|
85
|
+
const index = newProps.selectedId != null ? this.store.getIndexById(newProps.selectedId) : null;
|
|
86
|
+
|
|
87
|
+
if (index !== null) {
|
|
88
|
+
this.container.setSelected(index);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { CONSTRUCTOR_PROPS } from "../generated/internal.js";
|
|
3
|
+
import { resolvePropMeta, resolveSignal } from "../metadata.js";
|
|
4
|
+
import { Node } from "../node.js";
|
|
5
|
+
import type { Props } from "../types.js";
|
|
6
|
+
import type { SignalHandler } from "./internal/signal-store.js";
|
|
7
|
+
import { WidgetNode } from "./widget.js";
|
|
8
|
+
|
|
9
|
+
const G_TYPE_INVALID = 0;
|
|
10
|
+
|
|
11
|
+
export class EventControllerNode<
|
|
12
|
+
T extends Gtk.EventController = Gtk.EventController,
|
|
13
|
+
// biome-ignore lint/suspicious/noExplicitAny: Self-referential type bounds require any
|
|
14
|
+
TChild extends Node = any,
|
|
15
|
+
> extends Node<T, Props, WidgetNode, TChild> {
|
|
16
|
+
public static override createContainer(
|
|
17
|
+
props: Props,
|
|
18
|
+
containerClass: typeof Gtk.EventController,
|
|
19
|
+
): Gtk.EventController {
|
|
20
|
+
const typeName = containerClass.glibTypeName;
|
|
21
|
+
|
|
22
|
+
if (typeName === "GtkDropTarget") {
|
|
23
|
+
const actions = (props.actions as number | undefined) ?? 0;
|
|
24
|
+
return new Gtk.DropTarget(G_TYPE_INVALID, actions);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const args = (CONSTRUCTOR_PROPS[typeName] ?? []).map((name) => props[name]);
|
|
28
|
+
|
|
29
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic constructor invocation
|
|
30
|
+
return new (containerClass as any)(...args);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public override isValidParent(parent: Node): boolean {
|
|
34
|
+
return parent instanceof WidgetNode;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public override setParent(parent: WidgetNode | null): void {
|
|
38
|
+
if (!parent && this.parent) {
|
|
39
|
+
this.parent.container.removeController(this.container);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
super.setParent(parent);
|
|
43
|
+
|
|
44
|
+
if (parent) {
|
|
45
|
+
parent.container.addController(this.container);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public override commitUpdate(oldProps: Props | null, newProps: Props): void {
|
|
50
|
+
super.commitUpdate(oldProps, newProps);
|
|
51
|
+
this.applyOwnProps(oldProps, newProps);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public override detachDeletedInstance(): void {
|
|
55
|
+
if (this.parent && this.container.getWidget() === this.parent.container) {
|
|
56
|
+
this.parent.container.removeController(this.container);
|
|
57
|
+
}
|
|
58
|
+
super.detachDeletedInstance();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private applyOwnProps(oldProps: Props | null, newProps: Props): void {
|
|
62
|
+
const propNames = new Set([...Object.keys(oldProps ?? {}), ...Object.keys(newProps ?? {})]);
|
|
63
|
+
|
|
64
|
+
for (const name of propNames) {
|
|
65
|
+
if (name === "children") continue;
|
|
66
|
+
|
|
67
|
+
const oldValue = oldProps?.[name];
|
|
68
|
+
const newValue = newProps[name];
|
|
69
|
+
|
|
70
|
+
if (oldValue === newValue) continue;
|
|
71
|
+
|
|
72
|
+
const signalName = resolveSignal(this.container, name);
|
|
73
|
+
|
|
74
|
+
if (signalName) {
|
|
75
|
+
const handler = typeof newValue === "function" ? (newValue as SignalHandler) : undefined;
|
|
76
|
+
this.signalStore.set(this, this.container, signalName, handler, { blockable: false });
|
|
77
|
+
} else if (newValue !== undefined) {
|
|
78
|
+
this.setProperty(name, newValue);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private setProperty(name: string, value: unknown): void {
|
|
84
|
+
if (name === "types" && this.container instanceof Gtk.DropTarget) {
|
|
85
|
+
const types = value as number[];
|
|
86
|
+
this.container.setGtypes(types.length, types);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const propMeta = resolvePropMeta(this.container, name);
|
|
91
|
+
|
|
92
|
+
if (propMeta) {
|
|
93
|
+
const [, setterName] = propMeta;
|
|
94
|
+
const setterFn = (this.container as unknown as Record<string, (v: unknown) => void>)[setterName];
|
|
95
|
+
if (typeof setterFn === "function") {
|
|
96
|
+
setterFn.call(this.container, value);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { FixedChildProps } from "../jsx.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
import { hasChanged } from "./internal/props.js";
|
|
5
|
+
import { VirtualNode } from "./virtual.js";
|
|
6
|
+
import { WidgetNode } from "./widget.js";
|
|
7
|
+
|
|
8
|
+
export class FixedChildNode extends VirtualNode<FixedChildProps, WidgetNode<Gtk.Fixed>, WidgetNode> {
|
|
9
|
+
public override isValidChild(child: Node): boolean {
|
|
10
|
+
return child instanceof WidgetNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public override isValidParent(parent: Node): boolean {
|
|
14
|
+
return parent instanceof WidgetNode && parent.container instanceof Gtk.Fixed;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public override setParent(parent: WidgetNode<Gtk.Fixed> | null): void {
|
|
18
|
+
if (!parent && this.parent && this.children[0]) {
|
|
19
|
+
this.detachFromParent(this.parent.container, this.children[0].container);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
super.setParent(parent);
|
|
23
|
+
|
|
24
|
+
if (parent && this.children[0]) {
|
|
25
|
+
this.attachToParent(parent.container, this.children[0].container);
|
|
26
|
+
this.applyTransform();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public override appendChild(child: WidgetNode): void {
|
|
31
|
+
super.appendChild(child);
|
|
32
|
+
|
|
33
|
+
if (this.parent) {
|
|
34
|
+
this.attachToParent(this.parent.container, child.container);
|
|
35
|
+
this.applyTransform();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public override removeChild(child: WidgetNode): void {
|
|
40
|
+
if (this.parent) {
|
|
41
|
+
this.detachFromParent(this.parent.container, child.container);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
super.removeChild(child);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public override commitUpdate(oldProps: FixedChildProps | null, newProps: FixedChildProps): void {
|
|
48
|
+
super.commitUpdate(oldProps, newProps);
|
|
49
|
+
|
|
50
|
+
if (!this.parent || !this.children[0]) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const positionChanged = hasChanged(oldProps, newProps, "x") || hasChanged(oldProps, newProps, "y");
|
|
55
|
+
|
|
56
|
+
if (positionChanged) {
|
|
57
|
+
this.repositionChild();
|
|
58
|
+
} else if (hasChanged(oldProps, newProps, "transform")) {
|
|
59
|
+
this.applyTransform();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public override detachDeletedInstance(): void {
|
|
64
|
+
if (this.parent && this.children[0]) {
|
|
65
|
+
this.detachFromParent(this.parent.container, this.children[0].container);
|
|
66
|
+
}
|
|
67
|
+
super.detachDeletedInstance();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private attachToParent(parent: Gtk.Fixed, child: Gtk.Widget): void {
|
|
71
|
+
const x = this.props.x ?? 0;
|
|
72
|
+
const y = this.props.y ?? 0;
|
|
73
|
+
parent.put(child, x, y);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private detachFromParent(parent: Gtk.Fixed, child: Gtk.Widget): void {
|
|
77
|
+
const childParent = child.getParent();
|
|
78
|
+
if (childParent && childParent === parent) {
|
|
79
|
+
parent.remove(child);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private repositionChild(): void {
|
|
84
|
+
if (!this.parent || !this.children[0]) return;
|
|
85
|
+
|
|
86
|
+
const x = this.props.x ?? 0;
|
|
87
|
+
const y = this.props.y ?? 0;
|
|
88
|
+
|
|
89
|
+
this.parent.container.remove(this.children[0].container);
|
|
90
|
+
this.parent.container.put(this.children[0].container, x, y);
|
|
91
|
+
this.applyTransform();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private applyTransform(): void {
|
|
95
|
+
if (!this.parent || !this.children[0] || !this.props.transform) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const layoutManager = this.parent.container.getLayoutManager();
|
|
100
|
+
|
|
101
|
+
if (!layoutManager) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const layoutChild = layoutManager.getLayoutChild(this.children[0].container) as Gtk.FixedLayoutChild;
|
|
106
|
+
layoutChild.setTransform(this.props.transform);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { GtkFontDialogButtonProps } from "../jsx.js";
|
|
3
|
+
import type { Container } from "../types.js";
|
|
4
|
+
import { filterProps, hasChanged } from "./internal/props.js";
|
|
5
|
+
import { WidgetNode } from "./widget.js";
|
|
6
|
+
|
|
7
|
+
const OWN_PROPS = [
|
|
8
|
+
"fontDesc",
|
|
9
|
+
"onFontDescChanged",
|
|
10
|
+
"title",
|
|
11
|
+
"modal",
|
|
12
|
+
"language",
|
|
13
|
+
"useFont",
|
|
14
|
+
"useSize",
|
|
15
|
+
"level",
|
|
16
|
+
] as const;
|
|
17
|
+
|
|
18
|
+
type FontDialogButtonProps = Pick<GtkFontDialogButtonProps, (typeof OWN_PROPS)[number]>;
|
|
19
|
+
|
|
20
|
+
export class FontDialogButtonNode extends WidgetNode<Gtk.FontDialogButton, FontDialogButtonProps> {
|
|
21
|
+
private dialog: Gtk.FontDialog;
|
|
22
|
+
|
|
23
|
+
public static override createContainer(
|
|
24
|
+
_props: FontDialogButtonProps,
|
|
25
|
+
containerClass: typeof Gtk.Widget,
|
|
26
|
+
): Container | null {
|
|
27
|
+
const dialog = new Gtk.FontDialog();
|
|
28
|
+
const button = new (containerClass as typeof Gtk.FontDialogButton)(dialog);
|
|
29
|
+
return button;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
constructor(
|
|
33
|
+
typeName: string,
|
|
34
|
+
props: FontDialogButtonProps,
|
|
35
|
+
container: Gtk.FontDialogButton,
|
|
36
|
+
rootContainer: Container,
|
|
37
|
+
) {
|
|
38
|
+
super(typeName, props, container, rootContainer);
|
|
39
|
+
const dialog = container.getDialog();
|
|
40
|
+
if (!dialog) {
|
|
41
|
+
throw new Error("FontDialogButton must have a dialog");
|
|
42
|
+
}
|
|
43
|
+
this.dialog = dialog;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public override commitUpdate(oldProps: FontDialogButtonProps | null, newProps: FontDialogButtonProps): void {
|
|
47
|
+
super.commitUpdate(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
48
|
+
this.applyOwnProps(oldProps, newProps);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private applyOwnProps(oldProps: FontDialogButtonProps | null, newProps: FontDialogButtonProps): void {
|
|
52
|
+
if (hasChanged(oldProps, newProps, "title")) {
|
|
53
|
+
this.dialog.setTitle(newProps.title ?? "");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (hasChanged(oldProps, newProps, "modal")) {
|
|
57
|
+
this.dialog.setModal(newProps.modal ?? true);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (hasChanged(oldProps, newProps, "language") && newProps.language) {
|
|
61
|
+
this.dialog.setLanguage(newProps.language);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (hasChanged(oldProps, newProps, "useFont")) {
|
|
65
|
+
this.container.setUseFont(newProps.useFont ?? false);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (hasChanged(oldProps, newProps, "useSize")) {
|
|
69
|
+
this.container.setUseSize(newProps.useSize ?? false);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (hasChanged(oldProps, newProps, "level")) {
|
|
73
|
+
this.container.setLevel(newProps.level ?? Gtk.FontLevel.FONT);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (hasChanged(oldProps, newProps, "fontDesc") && newProps.fontDesc) {
|
|
77
|
+
this.container.setFontDesc(newProps.fontDesc);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (hasChanged(oldProps, newProps, "onFontDescChanged")) {
|
|
81
|
+
const callback = newProps.onFontDescChanged;
|
|
82
|
+
this.signalStore.set(
|
|
83
|
+
this,
|
|
84
|
+
this.container,
|
|
85
|
+
"notify::font-desc",
|
|
86
|
+
callback
|
|
87
|
+
? () => {
|
|
88
|
+
const fontDesc = this.container.getFontDesc();
|
|
89
|
+
if (fontDesc) {
|
|
90
|
+
callback(fontDesc);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
: undefined,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { GridChildProps } from "../jsx.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
import { hasChanged } from "./internal/props.js";
|
|
5
|
+
import { VirtualNode } from "./virtual.js";
|
|
6
|
+
import { WidgetNode } from "./widget.js";
|
|
7
|
+
|
|
8
|
+
export class GridChildNode extends VirtualNode<GridChildProps, WidgetNode<Gtk.Grid>, WidgetNode> {
|
|
9
|
+
public override isValidChild(child: Node): boolean {
|
|
10
|
+
return child instanceof WidgetNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public override isValidParent(parent: Node): boolean {
|
|
14
|
+
return parent instanceof WidgetNode && parent.container instanceof Gtk.Grid;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public override setParent(parent: WidgetNode<Gtk.Grid> | null): void {
|
|
18
|
+
if (!parent && this.parent && this.children[0]) {
|
|
19
|
+
this.detachFromParent(this.parent.container, this.children[0].container);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
super.setParent(parent);
|
|
23
|
+
|
|
24
|
+
if (parent && this.children[0]) {
|
|
25
|
+
this.attachToParent(parent.container, this.children[0].container);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public override appendChild(child: WidgetNode): void {
|
|
30
|
+
super.appendChild(child);
|
|
31
|
+
|
|
32
|
+
if (this.parent) {
|
|
33
|
+
this.attachToParent(this.parent.container, child.container);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public override removeChild(child: WidgetNode): void {
|
|
38
|
+
if (this.parent) {
|
|
39
|
+
this.detachFromParent(this.parent.container, child.container);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
super.removeChild(child);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public override commitUpdate(oldProps: GridChildProps | null, newProps: GridChildProps): void {
|
|
46
|
+
super.commitUpdate(oldProps, newProps);
|
|
47
|
+
|
|
48
|
+
const positionChanged =
|
|
49
|
+
hasChanged(oldProps, newProps, "column") ||
|
|
50
|
+
hasChanged(oldProps, newProps, "row") ||
|
|
51
|
+
hasChanged(oldProps, newProps, "columnSpan") ||
|
|
52
|
+
hasChanged(oldProps, newProps, "rowSpan");
|
|
53
|
+
|
|
54
|
+
if (positionChanged && this.parent && this.children[0]) {
|
|
55
|
+
this.reattachChild();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public override detachDeletedInstance(): void {
|
|
60
|
+
if (this.parent && this.children[0]) {
|
|
61
|
+
this.detachFromParent(this.parent.container, this.children[0].container);
|
|
62
|
+
}
|
|
63
|
+
super.detachDeletedInstance();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private attachToParent(parent: Gtk.Grid, child: Gtk.Widget): void {
|
|
67
|
+
const column = this.props.column ?? 0;
|
|
68
|
+
const row = this.props.row ?? 0;
|
|
69
|
+
const columnSpan = this.props.columnSpan ?? 1;
|
|
70
|
+
const rowSpan = this.props.rowSpan ?? 1;
|
|
71
|
+
|
|
72
|
+
const existingChild = parent.getChildAt(column, row);
|
|
73
|
+
if (existingChild && existingChild !== child) {
|
|
74
|
+
parent.remove(existingChild);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
parent.attach(child, column, row, columnSpan, rowSpan);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private detachFromParent(parent: Gtk.Grid, child: Gtk.Widget): void {
|
|
81
|
+
const childParent = child.getParent();
|
|
82
|
+
if (childParent && childParent === parent) {
|
|
83
|
+
parent.remove(child);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private reattachChild(): void {
|
|
88
|
+
if (!this.parent || !this.children[0]) return;
|
|
89
|
+
|
|
90
|
+
const column = this.props.column ?? 0;
|
|
91
|
+
const row = this.props.row ?? 0;
|
|
92
|
+
const columnSpan = this.props.columnSpan ?? 1;
|
|
93
|
+
const rowSpan = this.props.rowSpan ?? 1;
|
|
94
|
+
|
|
95
|
+
const existingChild = this.parent.container.getChildAt(column, row);
|
|
96
|
+
if (existingChild && existingChild !== this.children[0].container) {
|
|
97
|
+
this.parent.container.remove(existingChild);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this.parent.container.remove(this.children[0].container);
|
|
101
|
+
this.parent.container.attach(this.children[0].container, column, row, columnSpan, rowSpan);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { GtkGridViewProps } from "../jsx.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
import type { Container } from "../types.js";
|
|
5
|
+
import { GridItemRenderer } from "./internal/grid-item-renderer.js";
|
|
6
|
+
import { filterProps, hasChanged } from "./internal/props.js";
|
|
7
|
+
import { ListItemNode } from "./list-item.js";
|
|
8
|
+
import { GridModel, type GridModelProps } from "./models/grid.js";
|
|
9
|
+
import { WidgetNode } from "./widget.js";
|
|
10
|
+
|
|
11
|
+
const OWN_PROPS = ["renderItem", "estimatedItemHeight"] as const;
|
|
12
|
+
|
|
13
|
+
type GridViewProps = Pick<GtkGridViewProps, (typeof OWN_PROPS)[number]> & GridModelProps;
|
|
14
|
+
|
|
15
|
+
export class GridViewNode extends WidgetNode<Gtk.GridView, GridViewProps, ListItemNode> {
|
|
16
|
+
private itemRenderer: GridItemRenderer;
|
|
17
|
+
private grid: GridModel;
|
|
18
|
+
|
|
19
|
+
constructor(typeName: string, props: GridViewProps, container: Gtk.GridView, rootContainer: Container) {
|
|
20
|
+
super(typeName, props, container, rootContainer);
|
|
21
|
+
this.grid = new GridModel(
|
|
22
|
+
{ owner: this, signalStore: this.signalStore },
|
|
23
|
+
{
|
|
24
|
+
selectionMode: props.selectionMode,
|
|
25
|
+
selected: props.selected,
|
|
26
|
+
onSelectionChanged: props.onSelectionChanged,
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
this.itemRenderer = new GridItemRenderer(this.signalStore);
|
|
30
|
+
this.itemRenderer.setStore(this.grid.getStore());
|
|
31
|
+
this.grid.getStore().setOnItemUpdated((id) => this.itemRenderer.rebindItem(id));
|
|
32
|
+
this.container.setFactory(this.itemRenderer.getFactory());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public override isValidChild(child: Node): boolean {
|
|
36
|
+
if (!(child instanceof ListItemNode)) return false;
|
|
37
|
+
if (child.getChildNodes().length > 0) {
|
|
38
|
+
throw new Error("GtkGridView does not support nested ListItems. Use GtkListView for tree lists.");
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public override appendChild(child: ListItemNode): void {
|
|
44
|
+
super.appendChild(child);
|
|
45
|
+
this.grid.appendChild(child);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public override insertBefore(child: ListItemNode, before: ListItemNode): void {
|
|
49
|
+
super.insertBefore(child, before);
|
|
50
|
+
this.grid.insertBefore(child, before);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public override removeChild(child: ListItemNode): void {
|
|
54
|
+
this.grid.removeChild(child);
|
|
55
|
+
super.removeChild(child);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public override finalizeInitialChildren(props: GridViewProps): boolean {
|
|
59
|
+
super.finalizeInitialChildren(props);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public override commitUpdate(oldProps: GridViewProps | null, newProps: GridViewProps): void {
|
|
64
|
+
super.commitUpdate(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
65
|
+
this.applyOwnProps(oldProps, newProps);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public override commitMount(): void {
|
|
69
|
+
super.commitMount();
|
|
70
|
+
this.grid.flushBatch();
|
|
71
|
+
this.container.setModel(this.grid.getSelectionModel());
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public override detachDeletedInstance(): void {
|
|
75
|
+
this.itemRenderer.dispose();
|
|
76
|
+
super.detachDeletedInstance();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private applyOwnProps(oldProps: GridViewProps | null, newProps: GridViewProps): void {
|
|
80
|
+
if (hasChanged(oldProps, newProps, "renderItem")) {
|
|
81
|
+
this.itemRenderer.setRenderFn(newProps.renderItem ?? null);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (hasChanged(oldProps, newProps, "estimatedItemHeight")) {
|
|
85
|
+
this.itemRenderer.setEstimatedItemHeight(newProps.estimatedItemHeight ?? null);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const previousModel = this.grid.getSelectionModel();
|
|
89
|
+
this.grid.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
|
|
90
|
+
const currentModel = this.grid.getSelectionModel();
|
|
91
|
+
|
|
92
|
+
if (previousModel !== currentModel) {
|
|
93
|
+
this.container.setModel(currentModel);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|