@gtkx/react 0.1.47 → 0.1.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/codegen/jsx-generator.js +9 -19
- package/dist/container-interfaces.d.ts +51 -0
- package/dist/container-interfaces.js +5 -0
- package/dist/factory.d.ts +1 -1
- package/dist/factory.js +17 -3
- package/dist/generated/jsx.d.ts +9 -11
- package/dist/node.d.ts +4 -4
- package/dist/node.js +7 -6
- package/dist/nodes/about-dialog.d.ts +9 -0
- package/dist/nodes/about-dialog.js +14 -0
- package/dist/nodes/action-bar.d.ts +9 -0
- package/dist/nodes/action-bar.js +15 -0
- package/dist/nodes/column-view.d.ts +32 -7
- package/dist/nodes/column-view.js +217 -34
- package/dist/nodes/dropdown.d.ts +7 -17
- package/dist/nodes/dropdown.js +17 -10
- package/dist/nodes/flow-box.d.ts +9 -0
- package/dist/nodes/flow-box.js +25 -0
- package/dist/nodes/grid.d.ts +6 -3
- package/dist/nodes/grid.js +28 -26
- package/dist/nodes/list-box.d.ts +9 -0
- package/dist/nodes/list-box.js +21 -0
- package/dist/nodes/list.d.ts +4 -3
- package/dist/nodes/list.js +8 -7
- package/dist/nodes/notebook.d.ts +7 -3
- package/dist/nodes/notebook.js +31 -14
- package/dist/nodes/overlay.d.ts +2 -1
- package/dist/nodes/root.d.ts +2 -3
- package/dist/nodes/root.js +3 -3
- package/dist/nodes/slot.d.ts +1 -2
- package/dist/nodes/slot.js +2 -2
- package/dist/nodes/text-view.d.ts +2 -7
- package/dist/nodes/text-view.js +10 -49
- package/dist/nodes/widget.d.ts +6 -5
- package/dist/nodes/widget.js +9 -149
- package/dist/nodes/window.d.ts +11 -0
- package/dist/nodes/window.js +37 -0
- package/dist/props.d.ts +5 -0
- package/dist/props.js +10 -0
- package/dist/reconciler.js +4 -5
- package/dist/types.d.ts +22 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -186,6 +186,14 @@ A comprehensive showcase of GTK4 widgets and features:
|
|
|
186
186
|
turbo start --filter=gtk4-demo
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
+
### List Example
|
|
190
|
+
|
|
191
|
+
Comprehensive showcase of ListView, GridView, and ColumnView with sorting:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
turbo start --filter=list-example
|
|
195
|
+
```
|
|
196
|
+
|
|
189
197
|
## Packages
|
|
190
198
|
|
|
191
199
|
| Package | Description |
|
|
@@ -5,7 +5,6 @@ const COLUMN_VIEW_WIDGET = "ColumnView";
|
|
|
5
5
|
const DROPDOWN_WIDGETS = new Set(["DropDown"]);
|
|
6
6
|
const GRID_WIDGETS = new Set(["Grid"]);
|
|
7
7
|
const NOTEBOOK_WIDGET = "Notebook";
|
|
8
|
-
const TEXT_VIEW_WIDGET = "TextView";
|
|
9
8
|
const INTERNALLY_PROVIDED_PARAMS = {
|
|
10
9
|
ApplicationWindow: new Set(["application"]),
|
|
11
10
|
};
|
|
@@ -34,7 +33,6 @@ const isColumnViewWidget = (widgetName) => widgetName === COLUMN_VIEW_WIDGET;
|
|
|
34
33
|
const isDropDownWidget = (widgetName) => DROPDOWN_WIDGETS.has(widgetName);
|
|
35
34
|
const isGridWidget = (widgetName) => GRID_WIDGETS.has(widgetName);
|
|
36
35
|
const isNotebookWidget = (widgetName) => widgetName === NOTEBOOK_WIDGET;
|
|
37
|
-
const isTextViewWidget = (widgetName) => widgetName === TEXT_VIEW_WIDGET;
|
|
38
36
|
const sanitizeDoc = (doc) => {
|
|
39
37
|
let result = doc;
|
|
40
38
|
result = result.replace(/<picture>[\s\S]*?<\/picture>/gi, "");
|
|
@@ -136,14 +134,14 @@ export class JsxGenerator {
|
|
|
136
134
|
`import type { ReactNode, Ref } from "react";`,
|
|
137
135
|
...externalImports,
|
|
138
136
|
`import type * as Gtk from "@gtkx/ffi/gtk";`,
|
|
139
|
-
`import type { ColumnViewColumnProps, GridChildProps, ListItemProps, ListViewRenderProps, NotebookPageProps, SlotProps } from "../types.js";`,
|
|
137
|
+
`import type { ColumnViewColumnProps, ColumnViewRootProps, GridChildProps, ListItemProps, ListViewRenderProps, NotebookPageProps, SlotProps } from "../types.js";`,
|
|
140
138
|
"",
|
|
141
139
|
].join("\n");
|
|
142
140
|
}
|
|
143
141
|
generateCommonTypes(widgetClass) {
|
|
144
142
|
const widgetPropsContent = this.generateWidgetPropsContent(widgetClass);
|
|
145
143
|
return `
|
|
146
|
-
export { ColumnViewColumnProps, GridChildProps, ListItemProps, ListViewRenderProps, NotebookPageProps, SlotProps };
|
|
144
|
+
export { ColumnViewColumnProps, ColumnViewRootProps, GridChildProps, ListItemProps, ListViewRenderProps, NotebookPageProps, SlotProps };
|
|
147
145
|
|
|
148
146
|
${widgetPropsContent}
|
|
149
147
|
`;
|
|
@@ -336,24 +334,14 @@ ${widgetPropsContent}
|
|
|
336
334
|
lines.push(`\t * Render function for list items.`);
|
|
337
335
|
lines.push(`\t * Called with null during setup (for loading state) and with the actual item during bind.`);
|
|
338
336
|
lines.push(`\t */`);
|
|
339
|
-
lines.push(`\
|
|
340
|
-
lines.push(`\trenderItem: (item: any) => import("react").ReactElement;`);
|
|
337
|
+
lines.push(`\trenderItem: (item: unknown) => import("react").ReactElement;`);
|
|
341
338
|
}
|
|
342
339
|
if (isDropDownWidget(widget.name)) {
|
|
343
340
|
lines.push("");
|
|
344
341
|
lines.push(`\t/** Function to convert item to display label */`);
|
|
345
|
-
lines.push(`\
|
|
346
|
-
lines.push(`\titemLabel?: (item: any) => string;`);
|
|
342
|
+
lines.push(`\titemLabel?: (item: unknown) => string;`);
|
|
347
343
|
lines.push(`\t/** Called when selection changes */`);
|
|
348
|
-
lines.push(`\
|
|
349
|
-
lines.push(`\tonSelectionChanged?: (item: any, index: number) => void;`);
|
|
350
|
-
}
|
|
351
|
-
if (isTextViewWidget(widget.name)) {
|
|
352
|
-
lines.push("");
|
|
353
|
-
lines.push(`\t/** The contents of the text buffer. */`);
|
|
354
|
-
lines.push(`\ttext?: string;`);
|
|
355
|
-
lines.push(`\t/** Called when the text buffer content changes */`);
|
|
356
|
-
lines.push(`\tonChanged?: (text: string) => void;`);
|
|
344
|
+
lines.push(`\tonSelectionChanged?: (item: unknown, index: number) => void;`);
|
|
357
345
|
}
|
|
358
346
|
lines.push("");
|
|
359
347
|
lines.push(`\tref?: Ref<Gtk.${widgetName}>;`);
|
|
@@ -664,8 +652,10 @@ ${widgetPropsContent}
|
|
|
664
652
|
lines.push(`}`);
|
|
665
653
|
}
|
|
666
654
|
else if (isColumnViewWidget(widgetName)) {
|
|
667
|
-
|
|
668
|
-
lines.push(
|
|
655
|
+
lines.push(`interface ${name}RootPropsExtended<T = unknown, C extends string = string> extends ${name}Props, ColumnViewRootProps<T, C> {}`);
|
|
656
|
+
lines.push(``);
|
|
657
|
+
// Root wrapper (generic)
|
|
658
|
+
lines.push(`function ${name}Root<T = unknown, C extends string = string>(props: ${name}RootPropsExtended<T, C>): import("react").ReactElement {`);
|
|
669
659
|
lines.push(`\treturn createElement("${name}.Root", props);`);
|
|
670
660
|
lines.push(`}`);
|
|
671
661
|
lines.push(``);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { Node } from "./node.js";
|
|
3
|
+
/**
|
|
4
|
+
* Interface for containers that manage child widgets with attach/detach semantics.
|
|
5
|
+
* Used by ActionBar, FlowBox, ListBox, Overlay.
|
|
6
|
+
*/
|
|
7
|
+
export interface ChildContainer {
|
|
8
|
+
attachChild(child: Gtk.Widget): void;
|
|
9
|
+
insertChildBefore(child: Gtk.Widget, before: Gtk.Widget): void;
|
|
10
|
+
detachChild(child: Gtk.Widget): void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Interface for page-based containers like Notebook.
|
|
14
|
+
*/
|
|
15
|
+
export interface PageContainer {
|
|
16
|
+
addPage(child: Gtk.Widget, label: string): void;
|
|
17
|
+
insertPageBefore(child: Gtk.Widget, label: string, beforeChild: Gtk.Widget): void;
|
|
18
|
+
removePage(child: Gtk.Widget): void;
|
|
19
|
+
updatePageLabel(child: Gtk.Widget, label: string): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Interface for grid-based containers.
|
|
23
|
+
*/
|
|
24
|
+
export interface GridContainer {
|
|
25
|
+
attachToGrid(child: Gtk.Widget, column: number, row: number, colSpan: number, rowSpan: number): void;
|
|
26
|
+
removeFromGrid(child: Gtk.Widget): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Interface for item-based containers like ListView, ColumnView, DropDown.
|
|
30
|
+
*/
|
|
31
|
+
export interface ItemContainer<T> {
|
|
32
|
+
addItem(item: T): void;
|
|
33
|
+
insertItemBefore(item: T, beforeItem: T): void;
|
|
34
|
+
removeItem(item: T): void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Interface for column-based containers like ColumnView.
|
|
38
|
+
* Note: Column type is generic to support both raw Gtk.ColumnViewColumn and wrapper nodes.
|
|
39
|
+
*/
|
|
40
|
+
export interface ColumnContainer {
|
|
41
|
+
addColumn(column: unknown): void;
|
|
42
|
+
insertColumnBefore(column: unknown, beforeColumn: unknown): void;
|
|
43
|
+
removeColumn(column: unknown): void;
|
|
44
|
+
getItems(): unknown[];
|
|
45
|
+
getSortFn(): ((a: unknown, b: unknown, columnId: string) => number) | null;
|
|
46
|
+
}
|
|
47
|
+
export declare const isChildContainer: (node: Node) => node is Node & ChildContainer;
|
|
48
|
+
export declare const isPageContainer: (node: Node) => node is Node & PageContainer;
|
|
49
|
+
export declare const isGridContainer: (node: Node) => node is Node & GridContainer;
|
|
50
|
+
export declare const isItemContainer: <T>(node: Node) => node is Node & ItemContainer<T>;
|
|
51
|
+
export declare const isColumnContainer: (node: Node) => node is Node & ColumnContainer;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const isChildContainer = (node) => "attachChild" in node && "detachChild" in node && "insertChildBefore" in node;
|
|
2
|
+
export const isPageContainer = (node) => "addPage" in node && "removePage" in node && "insertPageBefore" in node && "updatePageLabel" in node;
|
|
3
|
+
export const isGridContainer = (node) => "attachToGrid" in node && "removeFromGrid" in node;
|
|
4
|
+
export const isItemContainer = (node) => "addItem" in node && "insertItemBefore" in node && "removeItem" in node;
|
|
5
|
+
export const isColumnContainer = (node) => "addColumn" in node && "removeColumn" in node && "getSortFn" in node;
|
package/dist/factory.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import type { Node } from "./node.js";
|
|
|
3
3
|
import { type ROOT_NODE_CONTAINER } from "./nodes/root.js";
|
|
4
4
|
export type Props = Record<string, unknown>;
|
|
5
5
|
export { ROOT_NODE_CONTAINER } from "./nodes/root.js";
|
|
6
|
-
export declare const createNode: (type: string, props: Props,
|
|
6
|
+
export declare const createNode: (type: string, props: Props, existingWidget?: Gtk.Widget | typeof ROOT_NODE_CONTAINER) => Node;
|
package/dist/factory.js
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
+
import { AboutDialogNode } from "./nodes/about-dialog.js";
|
|
2
|
+
import { ActionBarNode } from "./nodes/action-bar.js";
|
|
1
3
|
import { ColumnViewColumnNode, ColumnViewItemNode, ColumnViewNode } from "./nodes/column-view.js";
|
|
2
4
|
import { DropDownItemNode, DropDownNode } from "./nodes/dropdown.js";
|
|
5
|
+
import { FlowBoxNode } from "./nodes/flow-box.js";
|
|
3
6
|
import { GridChildNode, GridNode } from "./nodes/grid.js";
|
|
4
7
|
import { ListItemNode, ListViewNode } from "./nodes/list.js";
|
|
8
|
+
import { ListBoxNode } from "./nodes/list-box.js";
|
|
5
9
|
import { NotebookNode, NotebookPageNode } from "./nodes/notebook.js";
|
|
6
10
|
import { OverlayNode } from "./nodes/overlay.js";
|
|
7
11
|
import { RootNode } from "./nodes/root.js";
|
|
8
12
|
import { SlotNode } from "./nodes/slot.js";
|
|
9
13
|
import { TextViewNode } from "./nodes/text-view.js";
|
|
10
14
|
import { WidgetNode } from "./nodes/widget.js";
|
|
15
|
+
import { WindowNode } from "./nodes/window.js";
|
|
11
16
|
export { ROOT_NODE_CONTAINER } from "./nodes/root.js";
|
|
12
17
|
const NODE_CLASSES = [
|
|
13
18
|
RootNode,
|
|
19
|
+
// Virtual nodes (no widget)
|
|
14
20
|
ColumnViewColumnNode,
|
|
15
21
|
ColumnViewItemNode,
|
|
16
22
|
ListItemNode,
|
|
@@ -18,19 +24,27 @@ const NODE_CLASSES = [
|
|
|
18
24
|
GridChildNode,
|
|
19
25
|
NotebookPageNode,
|
|
20
26
|
SlotNode,
|
|
27
|
+
// Specialized widget nodes
|
|
28
|
+
WindowNode,
|
|
29
|
+
AboutDialogNode,
|
|
21
30
|
TextViewNode,
|
|
31
|
+
// Container nodes
|
|
32
|
+
ActionBarNode,
|
|
33
|
+
FlowBoxNode,
|
|
34
|
+
ListBoxNode,
|
|
22
35
|
DropDownNode,
|
|
23
36
|
GridNode,
|
|
24
37
|
OverlayNode,
|
|
25
38
|
ColumnViewNode,
|
|
26
39
|
ListViewNode,
|
|
27
40
|
NotebookNode,
|
|
41
|
+
// Catch-all (must be last)
|
|
28
42
|
WidgetNode,
|
|
29
43
|
];
|
|
30
|
-
export const createNode = (type, props,
|
|
44
|
+
export const createNode = (type, props, existingWidget) => {
|
|
31
45
|
for (const NodeClass of NODE_CLASSES) {
|
|
32
|
-
if (NodeClass.matches(type,
|
|
33
|
-
return new NodeClass(type, props,
|
|
46
|
+
if (NodeClass.matches(type, existingWidget)) {
|
|
47
|
+
return new NodeClass(type, props, existingWidget);
|
|
34
48
|
}
|
|
35
49
|
}
|
|
36
50
|
throw new Error(`No matching node class for type: ${type}`);
|
package/dist/generated/jsx.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type { ReactNode, Ref } from "react";
|
|
|
3
3
|
import type * as Gdk from "@gtkx/ffi/gdk";
|
|
4
4
|
import type * as Gio from "@gtkx/ffi/gio";
|
|
5
5
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
6
|
-
import type { ColumnViewColumnProps, GridChildProps, ListItemProps, ListViewRenderProps, NotebookPageProps, SlotProps } from "../types.js";
|
|
7
|
-
export { ColumnViewColumnProps, GridChildProps, ListItemProps, ListViewRenderProps, NotebookPageProps, SlotProps, };
|
|
6
|
+
import type { ColumnViewColumnProps, ColumnViewRootProps, GridChildProps, ListItemProps, ListViewRenderProps, NotebookPageProps, SlotProps } from "../types.js";
|
|
7
|
+
export { ColumnViewColumnProps, ColumnViewRootProps, GridChildProps, ListItemProps, ListViewRenderProps, NotebookPageProps, SlotProps, };
|
|
8
8
|
/**
|
|
9
9
|
* The base class for all widgets.
|
|
10
10
|
*
|
|
@@ -1861,9 +1861,9 @@ export interface DropDownProps extends WidgetProps {
|
|
|
1861
1861
|
*/
|
|
1862
1862
|
onActivate?: (self: Gtk.DropDown) => void;
|
|
1863
1863
|
/** Function to convert item to display label */
|
|
1864
|
-
itemLabel?: (item:
|
|
1864
|
+
itemLabel?: (item: unknown) => string;
|
|
1865
1865
|
/** Called when selection changes */
|
|
1866
|
-
onSelectionChanged?: (item:
|
|
1866
|
+
onSelectionChanged?: (item: unknown, index: number) => void;
|
|
1867
1867
|
ref?: Ref<Gtk.DropDown>;
|
|
1868
1868
|
}
|
|
1869
1869
|
/** Props for the {@link EditableLabel} widget. */
|
|
@@ -2917,7 +2917,7 @@ export interface GridViewProps extends ListBaseProps {
|
|
|
2917
2917
|
* Render function for list items.
|
|
2918
2918
|
* Called with null during setup (for loading state) and with the actual item during bind.
|
|
2919
2919
|
*/
|
|
2920
|
-
renderItem: (item:
|
|
2920
|
+
renderItem: (item: unknown) => import("react").ReactElement;
|
|
2921
2921
|
ref?: Ref<Gtk.GridView>;
|
|
2922
2922
|
}
|
|
2923
2923
|
/** Props for the {@link HeaderBar} widget. */
|
|
@@ -3735,7 +3735,7 @@ export interface ListViewProps extends ListBaseProps {
|
|
|
3735
3735
|
* Render function for list items.
|
|
3736
3736
|
* Called with null during setup (for loading state) and with the actual item during bind.
|
|
3737
3737
|
*/
|
|
3738
|
-
renderItem: (item:
|
|
3738
|
+
renderItem: (item: unknown) => import("react").ReactElement;
|
|
3739
3739
|
ref?: Ref<Gtk.ListView>;
|
|
3740
3740
|
}
|
|
3741
3741
|
/** Props for the {@link LockButton} widget. */
|
|
@@ -5684,10 +5684,6 @@ export interface TextViewProps extends WidgetProps {
|
|
|
5684
5684
|
* The default binding for this signal is `Insert`.
|
|
5685
5685
|
*/
|
|
5686
5686
|
onToggleOverwrite?: (self: Gtk.TextView) => void;
|
|
5687
|
-
/** The contents of the text buffer. */
|
|
5688
|
-
text?: string;
|
|
5689
|
-
/** Called when the text buffer content changes */
|
|
5690
|
-
onChanged?: (text: string) => void;
|
|
5691
5687
|
ref?: Ref<Gtk.TextView>;
|
|
5692
5688
|
}
|
|
5693
5689
|
/** Props for the {@link ToggleButton} widget. */
|
|
@@ -7075,7 +7071,9 @@ export declare const ColorChooserWidget: "ColorChooserWidget";
|
|
|
7075
7071
|
* it gets the .color style class.
|
|
7076
7072
|
*/
|
|
7077
7073
|
export declare const ColorDialogButton: "ColorDialogButton";
|
|
7078
|
-
|
|
7074
|
+
interface ColumnViewRootPropsExtended<T = unknown, C extends string = string> extends ColumnViewProps, ColumnViewRootProps<T, C> {
|
|
7075
|
+
}
|
|
7076
|
+
declare function ColumnViewRoot<T = unknown, C extends string = string>(props: ColumnViewRootPropsExtended<T, C>): import("react").ReactElement;
|
|
7079
7077
|
interface ColumnViewGenericColumnProps<T> extends Omit<ColumnViewColumnProps, "renderCell"> {
|
|
7080
7078
|
/** Render function for column cells. Called with null during setup. */
|
|
7081
7079
|
renderCell: (item: T | null) => import("react").ReactElement;
|
package/dist/node.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { Props, ROOT_NODE_CONTAINER } from "./factory.js";
|
|
3
3
|
export declare abstract class Node<T extends Gtk.Widget | undefined = Gtk.Widget | undefined> {
|
|
4
|
-
static matches(_type: string,
|
|
4
|
+
static matches(_type: string, _existingWidget?: Gtk.Widget | typeof ROOT_NODE_CONTAINER): boolean;
|
|
5
5
|
protected signalHandlers: Map<string, number>;
|
|
6
6
|
protected widget: T;
|
|
7
7
|
protected widgetType: string;
|
|
8
8
|
protected isVirtual(): boolean;
|
|
9
|
-
constructor(type: string, props: Props,
|
|
10
|
-
protected createWidget(type: string, props: Props
|
|
9
|
+
constructor(type: string, props: Props, existingWidget?: Gtk.Widget);
|
|
10
|
+
protected createWidget(type: string, props: Props): T;
|
|
11
11
|
getWidget(): T;
|
|
12
12
|
appendChild(child: Node): void;
|
|
13
13
|
removeChild(child: Node): void;
|
|
@@ -21,5 +21,5 @@ export declare abstract class Node<T extends Gtk.Widget | undefined = Gtk.Widget
|
|
|
21
21
|
protected disconnectSignal(eventName: string): void;
|
|
22
22
|
protected connectSignal(widget: Gtk.Widget, eventName: string, handler: (...args: unknown[]) => unknown): void;
|
|
23
23
|
protected setProperty(widget: Gtk.Widget, key: string, value: unknown): void;
|
|
24
|
-
mount(
|
|
24
|
+
mount(): void;
|
|
25
25
|
}
|
package/dist/node.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getCurrentApp } from "@gtkx/ffi";
|
|
1
2
|
import * as GObject from "@gtkx/ffi/gobject";
|
|
2
3
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
4
|
import { CONSTRUCTOR_PARAMS, PROP_SETTERS, SETTER_GETTERS } from "./generated/jsx.js";
|
|
@@ -9,7 +10,7 @@ const extractConstructorArgs = (type, props) => {
|
|
|
9
10
|
return params.map((p) => props[p.name]);
|
|
10
11
|
};
|
|
11
12
|
export class Node {
|
|
12
|
-
static matches(_type,
|
|
13
|
+
static matches(_type, _existingWidget) {
|
|
13
14
|
return false;
|
|
14
15
|
}
|
|
15
16
|
signalHandlers = new Map();
|
|
@@ -18,16 +19,16 @@ export class Node {
|
|
|
18
19
|
isVirtual() {
|
|
19
20
|
return false;
|
|
20
21
|
}
|
|
21
|
-
constructor(type, props,
|
|
22
|
+
constructor(type, props, existingWidget) {
|
|
22
23
|
this.widgetType = type.split(".")[0] || type;
|
|
23
24
|
if (existingWidget) {
|
|
24
25
|
this.widget = existingWidget;
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
|
-
this.widget = (this.isVirtual() ? undefined : this.createWidget(type, props
|
|
28
|
+
this.widget = (this.isVirtual() ? undefined : this.createWidget(type, props));
|
|
28
29
|
this.updateProps({}, props);
|
|
29
30
|
}
|
|
30
|
-
createWidget(type, props
|
|
31
|
+
createWidget(type, props) {
|
|
31
32
|
const normalizedType = type.split(".")[0] || type;
|
|
32
33
|
// biome-ignore lint/performance/noDynamicNamespaceImportAccess: dynamic widget creation
|
|
33
34
|
const WidgetClass = Gtk[normalizedType];
|
|
@@ -35,7 +36,7 @@ export class Node {
|
|
|
35
36
|
throw new Error(`Unknown GTK widget type: ${normalizedType}`);
|
|
36
37
|
}
|
|
37
38
|
if (WidgetClass === Gtk.ApplicationWindow) {
|
|
38
|
-
return new WidgetClass(
|
|
39
|
+
return new WidgetClass(getCurrentApp());
|
|
39
40
|
}
|
|
40
41
|
return new WidgetClass(...extractConstructorArgs(normalizedType, props));
|
|
41
42
|
}
|
|
@@ -164,5 +165,5 @@ export class Node {
|
|
|
164
165
|
}
|
|
165
166
|
setter.call(widget, value);
|
|
166
167
|
}
|
|
167
|
-
mount(
|
|
168
|
+
mount() { }
|
|
168
169
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { Node } from "../node.js";
|
|
3
|
+
export declare class AboutDialogNode extends Node<Gtk.AboutDialog> {
|
|
4
|
+
static matches(type: string): boolean;
|
|
5
|
+
attachToParent(_parent: Node): void;
|
|
6
|
+
attachToParentBefore(_parent: Node, _before: Node): void;
|
|
7
|
+
detachFromParent(_parent: Node): void;
|
|
8
|
+
mount(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Node } from "../node.js";
|
|
2
|
+
export class AboutDialogNode extends Node {
|
|
3
|
+
static matches(type) {
|
|
4
|
+
return type === "AboutDialog";
|
|
5
|
+
}
|
|
6
|
+
attachToParent(_parent) { }
|
|
7
|
+
attachToParentBefore(_parent, _before) { }
|
|
8
|
+
detachFromParent(_parent) {
|
|
9
|
+
this.widget.destroy();
|
|
10
|
+
}
|
|
11
|
+
mount() {
|
|
12
|
+
this.widget.present();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { ChildContainer } from "../container-interfaces.js";
|
|
3
|
+
import { Node } from "../node.js";
|
|
4
|
+
export declare class ActionBarNode extends Node<Gtk.ActionBar> implements ChildContainer {
|
|
5
|
+
static matches(type: string): boolean;
|
|
6
|
+
attachChild(child: Gtk.Widget): void;
|
|
7
|
+
insertChildBefore(child: Gtk.Widget, _before: Gtk.Widget): void;
|
|
8
|
+
detachChild(child: Gtk.Widget): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Node } from "../node.js";
|
|
2
|
+
export class ActionBarNode extends Node {
|
|
3
|
+
static matches(type) {
|
|
4
|
+
return type === "ActionBar";
|
|
5
|
+
}
|
|
6
|
+
attachChild(child) {
|
|
7
|
+
this.widget.packStart(child);
|
|
8
|
+
}
|
|
9
|
+
insertChildBefore(child, _before) {
|
|
10
|
+
this.attachChild(child);
|
|
11
|
+
}
|
|
12
|
+
detachChild(child) {
|
|
13
|
+
this.widget.remove(child);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,34 +1,59 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { type ColumnContainer, type ItemContainer } from "../container-interfaces.js";
|
|
2
3
|
import type { Props } from "../factory.js";
|
|
3
4
|
import { Node } from "../node.js";
|
|
4
|
-
|
|
5
|
+
import type { ColumnSortFn } from "../types.js";
|
|
6
|
+
export declare class ColumnViewNode extends Node<Gtk.ColumnView> implements ItemContainer<unknown>, ColumnContainer {
|
|
5
7
|
static matches(type: string): boolean;
|
|
6
8
|
private stringList;
|
|
7
9
|
private selectionModel;
|
|
10
|
+
private sortListModel;
|
|
8
11
|
private items;
|
|
9
12
|
private columns;
|
|
10
13
|
private committedLength;
|
|
11
|
-
|
|
14
|
+
private sortColumn;
|
|
15
|
+
private sortOrder;
|
|
16
|
+
private sortFn;
|
|
17
|
+
private isSorting;
|
|
18
|
+
private onSortChange;
|
|
19
|
+
private sorterChangedHandlerId;
|
|
20
|
+
private lastNotifiedColumn;
|
|
21
|
+
private lastNotifiedOrder;
|
|
22
|
+
constructor(type: string, props: Props);
|
|
23
|
+
private connectSorterChangedSignal;
|
|
24
|
+
private waitForSortComplete;
|
|
25
|
+
private disconnectSorterChangedSignal;
|
|
26
|
+
private notifySortChange;
|
|
12
27
|
getItems(): unknown[];
|
|
13
|
-
|
|
28
|
+
getSortFn(): ColumnSortFn<unknown, string> | null;
|
|
29
|
+
compareItems(a: unknown, b: unknown, columnId: string): number;
|
|
30
|
+
addColumn(columnNode: ColumnViewColumnNode): void;
|
|
31
|
+
private applySortByColumn;
|
|
32
|
+
findColumnById(id: string): ColumnViewColumnNode | undefined;
|
|
14
33
|
removeColumn(column: ColumnViewColumnNode): void;
|
|
15
34
|
insertColumnBefore(column: ColumnViewColumnNode, before: ColumnViewColumnNode): void;
|
|
16
35
|
private syncStringList;
|
|
17
36
|
addItem(item: unknown): void;
|
|
18
37
|
insertItemBefore(item: unknown, beforeItem: unknown): void;
|
|
19
38
|
removeItem(item: unknown): void;
|
|
39
|
+
protected consumedProps(): Set<string>;
|
|
40
|
+
updateProps(oldProps: Props, newProps: Props): void;
|
|
20
41
|
}
|
|
21
42
|
export declare class ColumnViewColumnNode extends Node {
|
|
22
43
|
static matches(type: string): boolean;
|
|
23
44
|
protected isVirtual(): boolean;
|
|
24
|
-
private
|
|
45
|
+
private column;
|
|
25
46
|
private factory;
|
|
26
47
|
private renderCell;
|
|
27
48
|
private columnView;
|
|
28
49
|
private listItemCache;
|
|
29
|
-
|
|
30
|
-
|
|
50
|
+
private columnId;
|
|
51
|
+
private sorter;
|
|
52
|
+
constructor(type: string, props: Props);
|
|
53
|
+
getColumn(): Gtk.ColumnViewColumn;
|
|
54
|
+
getId(): string | null;
|
|
31
55
|
setColumnView(columnView: ColumnViewNode | null): void;
|
|
56
|
+
updateSorterFromRoot(): void;
|
|
32
57
|
attachToParent(parent: Node): void;
|
|
33
58
|
attachToParentBefore(parent: Node, before: Node): void;
|
|
34
59
|
detachFromParent(parent: Node): void;
|
|
@@ -39,7 +64,7 @@ export declare class ColumnViewItemNode extends Node {
|
|
|
39
64
|
static matches(type: string): boolean;
|
|
40
65
|
protected isVirtual(): boolean;
|
|
41
66
|
private item;
|
|
42
|
-
constructor(type: string, props: Props
|
|
67
|
+
constructor(type: string, props: Props);
|
|
43
68
|
getItem(): unknown;
|
|
44
69
|
attachToParent(parent: Node): void;
|
|
45
70
|
attachToParentBefore(parent: Node, before: Node): void;
|