@gtkx/react 0.9.0 → 0.9.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/README.md +4 -14
- package/dist/batch.d.ts +0 -15
- package/dist/batch.js +0 -15
- package/dist/codegen/jsx-generator.d.ts +1 -25
- package/dist/codegen/jsx-generator.js +13 -51
- package/dist/factory.d.ts +0 -7
- package/dist/factory.js +0 -4
- package/dist/fiber-root.d.ts +0 -5
- package/dist/fiber-root.js +0 -5
- package/dist/generated/jsx.d.ts +1947 -1928
- package/dist/generated/jsx.js +1308 -1300
- package/dist/node.d.ts +0 -4
- package/dist/node.js +1 -5
- package/dist/nodes/column-view.d.ts +4 -2
- package/dist/nodes/column-view.js +24 -8
- package/dist/nodes/flow-box.js +1 -1
- package/dist/nodes/list-box.js +2 -2
- package/dist/nodes/list-item-factory.js +3 -3
- package/dist/nodes/menu.d.ts +1 -1
- package/dist/nodes/menu.js +11 -11
- package/dist/nodes/notebook.js +3 -3
- package/dist/nodes/overlay.js +1 -1
- package/dist/nodes/paged-stack.d.ts +0 -12
- package/dist/nodes/paged-stack.js +0 -4
- package/dist/nodes/selectable-list.js +3 -3
- package/dist/nodes/stack.js +1 -1
- package/dist/nodes/string-list-container.d.ts +1 -1
- package/dist/nodes/string-list-container.js +2 -2
- package/dist/nodes/toggle-button.d.ts +0 -8
- package/dist/nodes/toggle-button.js +0 -8
- package/dist/nodes/toolbar-view.d.ts +0 -4
- package/dist/nodes/toolbar-view.js +0 -4
- package/dist/nodes/view-stack.js +2 -2
- package/dist/nodes/virtual-item.d.ts +0 -5
- package/dist/nodes/virtual-item.js +0 -5
- package/dist/nodes/widget.d.ts +0 -5
- package/dist/nodes/widget.js +0 -5
- package/dist/nodes/window.js +3 -3
- package/dist/types.d.ts +2 -0
- package/package.json +5 -5
package/dist/node.d.ts
CHANGED
|
@@ -15,10 +15,6 @@ export declare abstract class Node<T extends Gtk.Widget | undefined = Gtk.Widget
|
|
|
15
15
|
protected isVirtual(): boolean;
|
|
16
16
|
protected isStandalone(): boolean;
|
|
17
17
|
constructor(type: string, widget?: Gtk.Widget);
|
|
18
|
-
/**
|
|
19
|
-
* Initializes the node with props. Called by the reconciler after construction.
|
|
20
|
-
* Subclasses can override to perform custom initialization.
|
|
21
|
-
*/
|
|
22
18
|
initialize(props: Props): void;
|
|
23
19
|
protected createWidget(type: string, props: Props): T;
|
|
24
20
|
getWidget(): T;
|
package/dist/node.js
CHANGED
|
@@ -62,10 +62,6 @@ export class Node {
|
|
|
62
62
|
this.widget = widget;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Initializes the node with props. Called by the reconciler after construction.
|
|
67
|
-
* Subclasses can override to perform custom initialization.
|
|
68
|
-
*/
|
|
69
65
|
initialize(props) {
|
|
70
66
|
if (!this.widget && !this.isVirtual()) {
|
|
71
67
|
this.widget = this.createWidget(this.nodeType, props);
|
|
@@ -92,7 +88,7 @@ export class Node {
|
|
|
92
88
|
this.attachChild(childWidget);
|
|
93
89
|
}
|
|
94
90
|
else if (this.widget && isAppendable(this.widget)) {
|
|
95
|
-
childWidget.insertBefore(this.widget
|
|
91
|
+
childWidget.insertBefore(this.widget);
|
|
96
92
|
}
|
|
97
93
|
else if (this.widget && isAddable(this.widget)) {
|
|
98
94
|
this.widget.add(childWidget);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import { StringSorter } from "@gtkx/ffi/gtk";
|
|
2
3
|
import type { ColumnContainer } from "../containers.js";
|
|
3
4
|
import type { Props } from "../factory.js";
|
|
4
5
|
import { Node } from "../node.js";
|
|
@@ -37,8 +38,9 @@ type ColumnViewColumnState = {
|
|
|
37
38
|
factory: Gtk.SignalListItemFactory;
|
|
38
39
|
factoryHandlers: ListItemFactoryHandlers | null;
|
|
39
40
|
renderCell: RenderItemFn<unknown>;
|
|
40
|
-
columnId
|
|
41
|
+
columnId?: string;
|
|
41
42
|
listItemCache: Map<number, ListItemInfo>;
|
|
43
|
+
sorter?: StringSorter;
|
|
42
44
|
};
|
|
43
45
|
export declare class ColumnViewColumnNode extends Node<never, ColumnViewColumnState> {
|
|
44
46
|
static consumedPropNames: string[];
|
|
@@ -47,7 +49,7 @@ export declare class ColumnViewColumnNode extends Node<never, ColumnViewColumnSt
|
|
|
47
49
|
private columnView;
|
|
48
50
|
initialize(props: Props): void;
|
|
49
51
|
getColumn(): Gtk.ColumnViewColumn;
|
|
50
|
-
getId(): string |
|
|
52
|
+
getId(): string | undefined;
|
|
51
53
|
setColumnView(columnView: ColumnViewNode | null): void;
|
|
52
54
|
unmount(): void;
|
|
53
55
|
updateProps(oldProps: Props, newProps: Props): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getObject } from "@gtkx/ffi";
|
|
2
1
|
import * as GObject from "@gtkx/ffi/gobject";
|
|
3
2
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
+
import { StringSorter } from "@gtkx/ffi/gtk";
|
|
4
4
|
import { Node } from "../node.js";
|
|
5
5
|
import { connectListItemFactorySignals } from "./list-item-factory.js";
|
|
6
6
|
import { SelectableListNode } from "./selectable-list.js";
|
|
@@ -53,10 +53,9 @@ export class ColumnViewNode extends SelectableListNode {
|
|
|
53
53
|
notifySortChange() {
|
|
54
54
|
if (!this.state.onSortChange)
|
|
55
55
|
return;
|
|
56
|
-
const
|
|
57
|
-
if (!
|
|
56
|
+
const sorter = this.widget.getSorter();
|
|
57
|
+
if (!sorter)
|
|
58
58
|
return;
|
|
59
|
-
const sorter = getObject(baseSorter.id);
|
|
60
59
|
const column = sorter.getPrimarySortColumn();
|
|
61
60
|
const order = sorter.getPrimarySortOrder();
|
|
62
61
|
const columnId = column?.getId() ?? null;
|
|
@@ -122,7 +121,7 @@ export class ColumnViewNode extends SelectableListNode {
|
|
|
122
121
|
}
|
|
123
122
|
applySortIndicator() {
|
|
124
123
|
if (this.state.sortColumn === null) {
|
|
125
|
-
this.widget.sortByColumn(this.state.sortOrder
|
|
124
|
+
this.widget.sortByColumn(this.state.sortOrder);
|
|
126
125
|
return;
|
|
127
126
|
}
|
|
128
127
|
const column = this.state.columns.find((c) => c.getId() === this.state.sortColumn);
|
|
@@ -158,7 +157,7 @@ export class ColumnViewNode extends SelectableListNode {
|
|
|
158
157
|
}
|
|
159
158
|
}
|
|
160
159
|
export class ColumnViewColumnNode extends Node {
|
|
161
|
-
static consumedPropNames = ["renderCell", "title", "expand", "resizable", "fixedWidth", "id"];
|
|
160
|
+
static consumedPropNames = ["renderCell", "title", "expand", "resizable", "fixedWidth", "id", "sortable"];
|
|
162
161
|
static matches(type) {
|
|
163
162
|
return type === "ColumnView.Column";
|
|
164
163
|
}
|
|
@@ -169,7 +168,9 @@ export class ColumnViewColumnNode extends Node {
|
|
|
169
168
|
initialize(props) {
|
|
170
169
|
const factory = new Gtk.SignalListItemFactory();
|
|
171
170
|
const column = new Gtk.ColumnViewColumn(props.title, factory);
|
|
172
|
-
const columnId = props.id ??
|
|
171
|
+
const columnId = props.id ?? undefined;
|
|
172
|
+
const sortable = props.sortable;
|
|
173
|
+
const sorter = sortable ? new StringSorter() : undefined;
|
|
173
174
|
this.state = {
|
|
174
175
|
column,
|
|
175
176
|
factory,
|
|
@@ -177,7 +178,11 @@ export class ColumnViewColumnNode extends Node {
|
|
|
177
178
|
renderCell: props.renderCell,
|
|
178
179
|
columnId,
|
|
179
180
|
listItemCache: new Map(),
|
|
181
|
+
sorter,
|
|
180
182
|
};
|
|
183
|
+
if (sorter) {
|
|
184
|
+
column.setSorter(sorter);
|
|
185
|
+
}
|
|
181
186
|
super.initialize(props);
|
|
182
187
|
if (columnId !== null) {
|
|
183
188
|
column.setId(columnId);
|
|
@@ -228,9 +233,20 @@ export class ColumnViewColumnNode extends Node {
|
|
|
228
233
|
this.state.column.setFixedWidth(newProps.fixedWidth);
|
|
229
234
|
}
|
|
230
235
|
if (oldProps.id !== newProps.id) {
|
|
231
|
-
this.state.columnId = newProps.id ??
|
|
236
|
+
this.state.columnId = newProps.id ?? undefined;
|
|
232
237
|
this.state.column.setId(this.state.columnId);
|
|
233
238
|
}
|
|
239
|
+
if (oldProps.sortable !== newProps.sortable) {
|
|
240
|
+
const sortable = newProps.sortable;
|
|
241
|
+
if (sortable && !this.state.sorter) {
|
|
242
|
+
this.state.sorter = new StringSorter();
|
|
243
|
+
this.state.column.setSorter(this.state.sorter);
|
|
244
|
+
}
|
|
245
|
+
else if (!sortable && this.state.sorter) {
|
|
246
|
+
this.state.column.setSorter(undefined);
|
|
247
|
+
this.state.sorter = undefined;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
234
250
|
}
|
|
235
251
|
}
|
|
236
252
|
export class ColumnViewItemNode extends VirtualItemNode {
|
package/dist/nodes/flow-box.js
CHANGED
|
@@ -16,7 +16,7 @@ export class FlowBoxNode extends IndexedChildContainerNode {
|
|
|
16
16
|
const parent = child.getParent();
|
|
17
17
|
if (parent && isFlowBoxChild(parent)) {
|
|
18
18
|
beginBatch();
|
|
19
|
-
parent.setChild(
|
|
19
|
+
parent.setChild(undefined);
|
|
20
20
|
this.widget.remove(parent);
|
|
21
21
|
endBatch();
|
|
22
22
|
}
|
package/dist/nodes/list-box.js
CHANGED
|
@@ -16,7 +16,7 @@ export class ListBoxNode extends IndexedChildContainerNode {
|
|
|
16
16
|
const parent = child.getParent();
|
|
17
17
|
if (parent && isListBoxRow(parent)) {
|
|
18
18
|
beginBatch();
|
|
19
|
-
parent.setChild(
|
|
19
|
+
parent.setChild(undefined);
|
|
20
20
|
this.widget.remove(parent);
|
|
21
21
|
endBatch();
|
|
22
22
|
}
|
|
@@ -38,7 +38,7 @@ export class ListBoxNode extends IndexedChildContainerNode {
|
|
|
38
38
|
detachChild(child) {
|
|
39
39
|
if (isListBoxRow(child)) {
|
|
40
40
|
beginBatch();
|
|
41
|
-
child.setChild(
|
|
41
|
+
child.setChild(undefined);
|
|
42
42
|
this.widget.remove(child);
|
|
43
43
|
endBatch();
|
|
44
44
|
return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getObjectId } from "@gtkx/ffi";
|
|
2
2
|
import * as GObject from "@gtkx/ffi/gobject";
|
|
3
3
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
4
4
|
import { createFiberRoot } from "../fiber-root.js";
|
|
@@ -7,7 +7,7 @@ export function connectListItemFactorySignals(config) {
|
|
|
7
7
|
const { factory, listItemCache, getRenderFn, getItemAtPosition } = config;
|
|
8
8
|
const handlerIds = [];
|
|
9
9
|
const setupId = factory.connect("setup", (_self, listItemObj) => {
|
|
10
|
-
const listItem =
|
|
10
|
+
const listItem = listItemObj;
|
|
11
11
|
const id = getObjectId(listItemObj.id);
|
|
12
12
|
const box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
|
|
13
13
|
listItem.setChild(box);
|
|
@@ -18,7 +18,7 @@ export function connectListItemFactorySignals(config) {
|
|
|
18
18
|
});
|
|
19
19
|
handlerIds.push(setupId);
|
|
20
20
|
const bindId = factory.connect("bind", (_self, listItemObj) => {
|
|
21
|
-
const listItem =
|
|
21
|
+
const listItem = listItemObj;
|
|
22
22
|
const id = getObjectId(listItemObj.id);
|
|
23
23
|
const info = listItemCache.get(id);
|
|
24
24
|
if (!info)
|
package/dist/nodes/menu.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ declare abstract class MenuContainerNode<T extends Gtk.Widget | undefined> exten
|
|
|
37
37
|
protected onMenuRebuilt(): void;
|
|
38
38
|
}
|
|
39
39
|
type MenuWidget = Gtk.Widget & {
|
|
40
|
-
setMenuModel(model
|
|
40
|
+
setMenuModel(model?: Gio.MenuModel): void;
|
|
41
41
|
};
|
|
42
42
|
declare abstract class MenuWidgetNode<T extends MenuWidget> extends MenuContainerNode<T> {
|
|
43
43
|
protected abstract createMenuWidget(menu: Gio.Menu): T;
|
package/dist/nodes/menu.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getApplication, getNativeObject } from "@gtkx/ffi";
|
|
2
2
|
import * as Gio from "@gtkx/ffi/gio";
|
|
3
3
|
import * as GObject from "@gtkx/ffi/gobject";
|
|
4
4
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
@@ -67,13 +67,13 @@ class MenuContainerNode extends NodeClass {
|
|
|
67
67
|
this.menu.removeAll();
|
|
68
68
|
for (const entry of this.entries) {
|
|
69
69
|
if (entry.type === "item") {
|
|
70
|
-
this.menu.append(entry.label
|
|
70
|
+
this.menu.append(entry.label, entry.action);
|
|
71
71
|
}
|
|
72
72
|
else if (entry.type === "section" && entry.menu) {
|
|
73
|
-
this.menu.appendSection(entry.menu, entry.label
|
|
73
|
+
this.menu.appendSection(entry.menu, entry.label);
|
|
74
74
|
}
|
|
75
75
|
else if (entry.type === "submenu" && entry.menu) {
|
|
76
|
-
this.menu.appendSubmenu(entry.menu, entry.label
|
|
76
|
+
this.menu.appendSubmenu(entry.menu, entry.label);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
this.onMenuRebuilt();
|
|
@@ -116,14 +116,14 @@ export class ApplicationMenuNode extends MenuContainerNode {
|
|
|
116
116
|
if (!(this.parent instanceof RootNode)) {
|
|
117
117
|
throw new Error("ApplicationMenu must be a direct child of a fragment at the root level");
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
getApplication().setMenubar(this.menu);
|
|
120
120
|
}
|
|
121
121
|
unmount() {
|
|
122
|
-
|
|
122
|
+
getApplication().setMenubar(undefined);
|
|
123
123
|
super.unmount();
|
|
124
124
|
}
|
|
125
125
|
onMenuRebuilt() {
|
|
126
|
-
|
|
126
|
+
getApplication().setMenubar(this.menu);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
export class MenuItemNode extends NodeClass {
|
|
@@ -198,8 +198,8 @@ export class MenuItemNode extends NodeClass {
|
|
|
198
198
|
this.actionName = generateActionName();
|
|
199
199
|
this.action = new Gio.SimpleAction(this.actionName);
|
|
200
200
|
this.signalHandlerId = this.action.connect("activate", () => this.invokeCurrentCallback());
|
|
201
|
-
const app =
|
|
202
|
-
const action =
|
|
201
|
+
const app = getApplication();
|
|
202
|
+
const action = getNativeObject(this.action.id, Gio.Action);
|
|
203
203
|
if (!action) {
|
|
204
204
|
throw new Error("Failed to get Gio.Action interface from SimpleAction");
|
|
205
205
|
}
|
|
@@ -211,7 +211,7 @@ export class MenuItemNode extends NodeClass {
|
|
|
211
211
|
}
|
|
212
212
|
cleanupAction() {
|
|
213
213
|
if (this.actionName) {
|
|
214
|
-
const app =
|
|
214
|
+
const app = getApplication();
|
|
215
215
|
app.removeAction(this.actionName);
|
|
216
216
|
if (this.currentAccels) {
|
|
217
217
|
app.setAccelsForAction(`app.${this.actionName}`, []);
|
|
@@ -228,7 +228,7 @@ export class MenuItemNode extends NodeClass {
|
|
|
228
228
|
updateAccels(accels) {
|
|
229
229
|
if (!this.actionName)
|
|
230
230
|
return;
|
|
231
|
-
const app =
|
|
231
|
+
const app = getApplication();
|
|
232
232
|
const accelArray = accels ? (Array.isArray(accels) ? accels : [accels]) : [];
|
|
233
233
|
app.setAccelsForAction(`app.${this.actionName}`, accelArray);
|
|
234
234
|
}
|
package/dist/nodes/notebook.js
CHANGED
|
@@ -34,15 +34,15 @@ export class NotebookNode extends Node {
|
|
|
34
34
|
this.widget.setTabLabel(child, tabLabel);
|
|
35
35
|
}
|
|
36
36
|
attachChild(child) {
|
|
37
|
-
this.widget.appendPage(child
|
|
37
|
+
this.widget.appendPage(child);
|
|
38
38
|
}
|
|
39
39
|
insertChildBefore(child, before) {
|
|
40
40
|
const beforePageNum = this.widget.pageNum(before);
|
|
41
41
|
if (beforePageNum >= 0) {
|
|
42
|
-
this.widget.insertPage(child, beforePageNum
|
|
42
|
+
this.widget.insertPage(child, beforePageNum);
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
|
-
this.widget.appendPage(child
|
|
45
|
+
this.widget.appendPage(child);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
detachChild(child) {
|
package/dist/nodes/overlay.js
CHANGED
|
@@ -10,22 +10,10 @@ type StackWidget = Gtk.Widget & {
|
|
|
10
10
|
remove(child: Gtk.Widget): void;
|
|
11
11
|
getPage(child: Gtk.Widget): StackPageLike;
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
14
|
-
* Abstract node for paged stack widgets (Gtk.Stack, Adw.ViewStack).
|
|
15
|
-
* Handles visible child deferral and common page operations.
|
|
16
|
-
*/
|
|
17
13
|
export declare abstract class PagedStackNode<T extends StackWidget> extends NodeClass<T> implements StackPageContainer, ChildContainer {
|
|
18
14
|
static consumedPropNames: string[];
|
|
19
15
|
private pendingVisibleChildName;
|
|
20
|
-
/**
|
|
21
|
-
* Add a page to the stack widget. Must be implemented by subclasses
|
|
22
|
-
* due to API differences between Gtk.Stack and Adw.ViewStack.
|
|
23
|
-
*/
|
|
24
16
|
abstract addStackPage(child: Gtk.Widget, props: StackPageProps): void;
|
|
25
|
-
/**
|
|
26
|
-
* Add a child directly to the stack widget (without page props).
|
|
27
|
-
* Must be implemented by subclasses due to API differences.
|
|
28
|
-
*/
|
|
29
17
|
protected abstract addChildToWidget(child: Gtk.Widget): void;
|
|
30
18
|
protected applyPendingVisibleChild(): void;
|
|
31
19
|
insertStackPageBefore(child: Gtk.Widget, props: StackPageProps, _beforeChild: Gtk.Widget): void;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { Node as NodeClass } from "../node.js";
|
|
2
2
|
import { StackPageNode } from "./stack.js";
|
|
3
3
|
import { applyStackPageProps } from "./stack-page-props.js";
|
|
4
|
-
/**
|
|
5
|
-
* Abstract node for paged stack widgets (Gtk.Stack, Adw.ViewStack).
|
|
6
|
-
* Handles visible child deferral and common page operations.
|
|
7
|
-
*/
|
|
8
4
|
export class PagedStackNode extends NodeClass {
|
|
9
5
|
static consumedPropNames = ["visibleChildName"];
|
|
10
6
|
pendingVisibleChildName = null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getNativeObject } from "@gtkx/ffi";
|
|
2
2
|
import * as Gio from "@gtkx/ffi/gio";
|
|
3
3
|
import * as GObject from "@gtkx/ffi/gobject";
|
|
4
4
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
@@ -41,7 +41,7 @@ export class SelectableListNode extends NodeClass {
|
|
|
41
41
|
initializeSelectionState(props) {
|
|
42
42
|
const selectionMode = props.selectionMode ?? Gtk.SelectionMode.SINGLE;
|
|
43
43
|
const stringList = new Gtk.StringList([]);
|
|
44
|
-
const listModel =
|
|
44
|
+
const listModel = getNativeObject(stringList.id, Gio.ListModel) ?? undefined;
|
|
45
45
|
const selectionModel = selectionMode === Gtk.SelectionMode.MULTIPLE
|
|
46
46
|
? new Gtk.MultiSelection(listModel)
|
|
47
47
|
: new Gtk.SingleSelection(listModel);
|
|
@@ -100,7 +100,7 @@ export class SelectableListNode extends NodeClass {
|
|
|
100
100
|
const currentSelection = this.getSelectedIds();
|
|
101
101
|
const hadHandler = this.state.selectionHandlerId !== null;
|
|
102
102
|
this.disconnectSelectionHandler();
|
|
103
|
-
const listModel =
|
|
103
|
+
const listModel = getNativeObject(this.state.stringList.id, Gio.ListModel) ?? undefined;
|
|
104
104
|
const newSelectionModel = newSelectionMode === Gtk.SelectionMode.MULTIPLE
|
|
105
105
|
? new Gtk.MultiSelection(listModel)
|
|
106
106
|
: new Gtk.SingleSelection(listModel);
|
package/dist/nodes/stack.js
CHANGED
|
@@ -11,7 +11,7 @@ export class StackNode extends PagedStackNode {
|
|
|
11
11
|
const { name, title } = props;
|
|
12
12
|
let stackPage;
|
|
13
13
|
if (title !== undefined) {
|
|
14
|
-
stackPage = this.widget.addTitled(child, title, name
|
|
14
|
+
stackPage = this.widget.addTitled(child, title, name);
|
|
15
15
|
}
|
|
16
16
|
else if (name !== undefined) {
|
|
17
17
|
stackPage = this.widget.addNamed(child, name);
|
|
@@ -12,7 +12,7 @@ type StringListContainerState = {
|
|
|
12
12
|
hasAppliedInitialSelection: boolean;
|
|
13
13
|
};
|
|
14
14
|
type StringListWidget = Gtk.Widget & {
|
|
15
|
-
setModel(model
|
|
15
|
+
setModel(model?: Gio.ListModel): void;
|
|
16
16
|
getSelected(): number;
|
|
17
17
|
setSelected(position: number): void;
|
|
18
18
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getNativeObject } from "@gtkx/ffi";
|
|
2
2
|
import * as Gio from "@gtkx/ffi/gio";
|
|
3
3
|
import { Node as NodeClass } from "../node.js";
|
|
4
4
|
import { getCallbackChange } from "../props.js";
|
|
@@ -44,7 +44,7 @@ export class StringListContainerNode extends NodeClass {
|
|
|
44
44
|
const initialSelection = props.selectedId;
|
|
45
45
|
this.state = { store, onSelectionChanged, initialSelection, hasAppliedInitialSelection: false };
|
|
46
46
|
super.initialize(props);
|
|
47
|
-
this.widget.setModel(
|
|
47
|
+
this.widget.setModel(getNativeObject(store.getModel().id, Gio.ListModel) ?? undefined);
|
|
48
48
|
}
|
|
49
49
|
connectSelectionHandler() {
|
|
50
50
|
const handler = () => {
|
|
@@ -4,14 +4,6 @@ import { Node } from "../node.js";
|
|
|
4
4
|
type ToggleButtonState = {
|
|
5
5
|
lastPropsActive: boolean | undefined;
|
|
6
6
|
};
|
|
7
|
-
/**
|
|
8
|
-
* Specialized node for GtkToggleButton that prevents signal feedback loops.
|
|
9
|
-
*
|
|
10
|
-
* When multiple ToggleButtons share the same state (controlled components),
|
|
11
|
-
* React syncing the `active` prop via setActive() triggers the `toggled` signal.
|
|
12
|
-
* This node guards against that by tracking the expected active state and
|
|
13
|
-
* suppressing callbacks when the signal was caused by a programmatic update.
|
|
14
|
-
*/
|
|
15
7
|
export declare class ToggleButtonNode extends Node<Gtk.ToggleButton, ToggleButtonState> {
|
|
16
8
|
static consumedPropNames: string[];
|
|
17
9
|
static matches(type: string): boolean;
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { Node } from "../node.js";
|
|
2
|
-
/**
|
|
3
|
-
* Specialized node for GtkToggleButton that prevents signal feedback loops.
|
|
4
|
-
*
|
|
5
|
-
* When multiple ToggleButtons share the same state (controlled components),
|
|
6
|
-
* React syncing the `active` prop via setActive() triggers the `toggled` signal.
|
|
7
|
-
* This node guards against that by tracking the expected active state and
|
|
8
|
-
* suppressing callbacks when the signal was caused by a programmatic update.
|
|
9
|
-
*/
|
|
10
2
|
export class ToggleButtonNode extends Node {
|
|
11
3
|
static consumedPropNames = ["active"];
|
|
12
4
|
static matches(type) {
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { Node } from "../node.js";
|
|
2
|
-
/**
|
|
3
|
-
* Virtual node for AdwToolbarView Top and Bottom slots.
|
|
4
|
-
* These slots use addTopBar/addBottomBar instead of setChild.
|
|
5
|
-
*/
|
|
6
2
|
export declare class ToolbarViewSlotNode extends Node<never> {
|
|
7
3
|
static matches(type: string): boolean;
|
|
8
4
|
protected isVirtual(): boolean;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { Node } from "../node.js";
|
|
2
|
-
/**
|
|
3
|
-
* Virtual node for AdwToolbarView Top and Bottom slots.
|
|
4
|
-
* These slots use addTopBar/addBottomBar instead of setChild.
|
|
5
|
-
*/
|
|
6
2
|
export class ToolbarViewSlotNode extends Node {
|
|
7
3
|
static matches(type) {
|
|
8
4
|
if (!type.startsWith("AdwToolbarView."))
|
package/dist/nodes/view-stack.js
CHANGED
|
@@ -8,10 +8,10 @@ export class ViewStackNode extends PagedStackNode {
|
|
|
8
8
|
const { name, title, iconName } = props;
|
|
9
9
|
let page;
|
|
10
10
|
if (title !== undefined && iconName !== undefined) {
|
|
11
|
-
page = this.widget.addTitledWithIcon(child, title, iconName, name
|
|
11
|
+
page = this.widget.addTitledWithIcon(child, title, iconName, name);
|
|
12
12
|
}
|
|
13
13
|
else if (title !== undefined) {
|
|
14
|
-
page = this.widget.addTitled(child, title, name
|
|
14
|
+
page = this.widget.addTitled(child, title, name);
|
|
15
15
|
}
|
|
16
16
|
else if (name !== undefined) {
|
|
17
17
|
page = this.widget.addNamed(child, name);
|
|
@@ -2,11 +2,6 @@ import type { ItemContainer } from "../containers.js";
|
|
|
2
2
|
import type { Props } from "../factory.js";
|
|
3
3
|
import type { Node } from "../node.js";
|
|
4
4
|
import { Node as NodeClass } from "../node.js";
|
|
5
|
-
/**
|
|
6
|
-
* Base class for virtual item nodes used in list-based containers.
|
|
7
|
-
* Virtual nodes don't create GTK widgets directly but represent items
|
|
8
|
-
* in list models (ListView, GridView, ColumnView).
|
|
9
|
-
*/
|
|
10
5
|
export declare abstract class VirtualItemNode extends NodeClass<never> {
|
|
11
6
|
static consumedPropNames: string[];
|
|
12
7
|
protected isVirtual(): boolean;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { Node as NodeClass } from "../node.js";
|
|
2
2
|
import { isItemContainer } from "../predicates.js";
|
|
3
|
-
/**
|
|
4
|
-
* Base class for virtual item nodes used in list-based containers.
|
|
5
|
-
* Virtual nodes don't create GTK widgets directly but represent items
|
|
6
|
-
* in list models (ListView, GridView, ColumnView).
|
|
7
|
-
*/
|
|
8
3
|
export class VirtualItemNode extends NodeClass {
|
|
9
4
|
static consumedPropNames = ["id", "item"];
|
|
10
5
|
isVirtual() {
|
package/dist/nodes/widget.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import { Node } from "../node.js";
|
|
3
|
-
/**
|
|
4
|
-
* Catch-all node for standard GTK widgets that don't need special handling.
|
|
5
|
-
* Specialized widgets (Window, AboutDialog, ActionBar, FlowBox, ListBox, etc.)
|
|
6
|
-
* are handled by their own dedicated Node classes.
|
|
7
|
-
*/
|
|
8
3
|
export declare class WidgetNode extends Node<Gtk.Widget> {
|
|
9
4
|
static matches(_type: string): boolean;
|
|
10
5
|
}
|
package/dist/nodes/widget.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { Node } from "../node.js";
|
|
2
|
-
/**
|
|
3
|
-
* Catch-all node for standard GTK widgets that don't need special handling.
|
|
4
|
-
* Specialized widgets (Window, AboutDialog, ActionBar, FlowBox, ListBox, etc.)
|
|
5
|
-
* are handled by their own dedicated Node classes.
|
|
6
|
-
*/
|
|
7
2
|
export class WidgetNode extends Node {
|
|
8
3
|
static matches(_type) {
|
|
9
4
|
return true;
|
package/dist/nodes/window.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getApplication } from "@gtkx/ffi";
|
|
2
2
|
import * as Adw from "@gtkx/ffi/adw";
|
|
3
3
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
4
4
|
import { Node, normalizeWidgetType } from "../node.js";
|
|
@@ -14,10 +14,10 @@ export class WindowNode extends Node {
|
|
|
14
14
|
createWidget(type, _props) {
|
|
15
15
|
const widgetType = normalizeWidgetType(type);
|
|
16
16
|
if (widgetType === "ApplicationWindow") {
|
|
17
|
-
return new Gtk.ApplicationWindow(
|
|
17
|
+
return new Gtk.ApplicationWindow(getApplication());
|
|
18
18
|
}
|
|
19
19
|
if (widgetType === "AdwApplicationWindow") {
|
|
20
|
-
return new Adw.ApplicationWindow(
|
|
20
|
+
return new Adw.ApplicationWindow(getApplication());
|
|
21
21
|
}
|
|
22
22
|
if (widgetType === "AdwWindow") {
|
|
23
23
|
return new Adw.Window();
|
package/dist/types.d.ts
CHANGED
|
@@ -61,6 +61,8 @@ export type ColumnViewColumnProps<T = unknown> = {
|
|
|
61
61
|
fixedWidth?: number;
|
|
62
62
|
/** Unique identifier for the column. Used for sorting. */
|
|
63
63
|
id?: string;
|
|
64
|
+
/** Whether this column header can be clicked to trigger sorting. */
|
|
65
|
+
sortable?: boolean;
|
|
64
66
|
/**
|
|
65
67
|
* Render function for column cells.
|
|
66
68
|
* Called with null during setup (for loading state) and with the actual item during bind.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/react",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Build GTK4 desktop applications with React and TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtk",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"react-reconciler": "^0.33.0",
|
|
39
|
-
"@gtkx/ffi": "0.9.
|
|
39
|
+
"@gtkx/ffi": "0.9.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@gtkx/
|
|
43
|
-
"@gtkx/
|
|
42
|
+
"@gtkx/gir": "0.9.2",
|
|
43
|
+
"@gtkx/native": "0.9.2"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": "^19"
|
|
@@ -48,6 +48,6 @@
|
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "tsc -b && cp ../../README.md .",
|
|
50
50
|
"codegen": "tsx scripts/codegen.ts",
|
|
51
|
-
"test": "
|
|
51
|
+
"test": "../../scripts/run-tests.sh"
|
|
52
52
|
}
|
|
53
53
|
}
|