@gtkx/react 0.1.49 → 0.1.51

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/node.d.ts CHANGED
@@ -1,12 +1,21 @@
1
1
  import * as Gtk from "@gtkx/ffi/gtk";
2
2
  import type { Props, ROOT_NODE_CONTAINER } from "./factory.js";
3
- export declare abstract class Node<T extends Gtk.Widget | undefined = Gtk.Widget | undefined> {
3
+ export declare abstract class Node<T extends Gtk.Widget | undefined = Gtk.Widget | undefined, S extends object | undefined = object | undefined> {
4
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
+ protected nodeType: string;
9
+ private _state;
10
+ protected get state(): S;
11
+ protected set state(value: S);
8
12
  protected isVirtual(): boolean;
9
- constructor(type: string, props: Props, existingWidget?: Gtk.Widget);
13
+ constructor(type: string, existingWidget?: Gtk.Widget);
14
+ /**
15
+ * Initializes the node with props. Called by the reconciler after construction.
16
+ * Subclasses can override to perform custom initialization.
17
+ */
18
+ initialize(props: Props): void;
10
19
  protected createWidget(type: string, props: Props): T;
11
20
  getWidget(): T;
12
21
  appendChild(child: Node): void;
package/dist/node.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getCurrentApp } from "@gtkx/ffi";
2
2
  import * as GObject from "@gtkx/ffi/gobject";
3
3
  import * as Gtk from "@gtkx/ffi/gtk";
4
- import { CONSTRUCTOR_PARAMS, PROP_SETTERS, SETTER_GETTERS } from "./generated/jsx.js";
4
+ import { CONSTRUCTOR_PARAMS, PROP_SETTERS, SETTER_GETTERS } from "./generated/internal.js";
5
5
  import { isAppendable, isRemovable, isSingleChild } from "./predicates.js";
6
6
  const extractConstructorArgs = (type, props) => {
7
7
  const params = CONSTRUCTOR_PARAMS[type];
@@ -14,18 +14,37 @@ export class Node {
14
14
  return false;
15
15
  }
16
16
  signalHandlers = new Map();
17
- widget;
17
+ widget = undefined;
18
18
  widgetType;
19
+ nodeType;
20
+ _state = null;
21
+ get state() {
22
+ if (this._state === null) {
23
+ throw new Error(`${this.constructor.name} not initialized`);
24
+ }
25
+ return this._state;
26
+ }
27
+ set state(value) {
28
+ this._state = value;
29
+ }
19
30
  isVirtual() {
20
31
  return false;
21
32
  }
22
- constructor(type, props, existingWidget) {
33
+ constructor(type, existingWidget) {
34
+ this.nodeType = type;
23
35
  this.widgetType = type.split(".")[0] || type;
24
36
  if (existingWidget) {
25
37
  this.widget = existingWidget;
26
- return;
27
38
  }
28
- this.widget = (this.isVirtual() ? undefined : this.createWidget(type, props));
39
+ }
40
+ /**
41
+ * Initializes the node with props. Called by the reconciler after construction.
42
+ * Subclasses can override to perform custom initialization.
43
+ */
44
+ initialize(props) {
45
+ if (!this.widget && !this.isVirtual()) {
46
+ this.widget = this.createWidget(this.nodeType, props);
47
+ }
29
48
  this.updateProps({}, props);
30
49
  }
31
50
  createWidget(type, props) {
@@ -1,25 +1,28 @@
1
1
  import * as Gtk from "@gtkx/ffi/gtk";
2
+ import type Reconciler from "react-reconciler";
2
3
  import { type ColumnContainer, type ItemContainer } from "../container-interfaces.js";
3
4
  import type { Props } from "../factory.js";
4
5
  import { Node } from "../node.js";
5
- import type { ColumnSortFn } from "../types.js";
6
- export declare class ColumnViewNode extends Node<Gtk.ColumnView> implements ItemContainer<unknown>, ColumnContainer {
6
+ import type { ColumnSortFn, RenderItemFn } from "../types.js";
7
+ interface ColumnViewState {
8
+ stringList: Gtk.StringList;
9
+ selectionModel: Gtk.SingleSelection;
10
+ sortListModel: Gtk.SortListModel;
11
+ items: unknown[];
12
+ columns: ColumnViewColumnNode[];
13
+ committedLength: number;
14
+ sortColumn: string | null;
15
+ sortOrder: Gtk.SortType;
16
+ sortFn: ColumnSortFn<unknown, string> | null;
17
+ isSorting: boolean;
18
+ onSortChange: ((column: string | null, order: Gtk.SortType) => void) | null;
19
+ sorterChangedHandlerId: number | null;
20
+ lastNotifiedColumn: string | null;
21
+ lastNotifiedOrder: Gtk.SortType;
22
+ }
23
+ export declare class ColumnViewNode extends Node<Gtk.ColumnView, ColumnViewState> implements ItemContainer<unknown>, ColumnContainer {
7
24
  static matches(type: string): boolean;
8
- private stringList;
9
- private selectionModel;
10
- private sortListModel;
11
- private items;
12
- private columns;
13
- private committedLength;
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);
25
+ initialize(props: Props): void;
23
26
  private connectSorterChangedSignal;
24
27
  private waitForSortComplete;
25
28
  private disconnectSorterChangedSignal;
@@ -39,17 +42,23 @@ export declare class ColumnViewNode extends Node<Gtk.ColumnView> implements Item
39
42
  protected consumedProps(): Set<string>;
40
43
  updateProps(oldProps: Props, newProps: Props): void;
41
44
  }
42
- export declare class ColumnViewColumnNode extends Node {
45
+ interface ListItemInfo {
46
+ box: Gtk.Box;
47
+ fiberRoot: Reconciler.FiberRoot;
48
+ }
49
+ interface ColumnViewColumnState {
50
+ column: Gtk.ColumnViewColumn;
51
+ factory: Gtk.SignalListItemFactory;
52
+ renderCell: RenderItemFn<unknown>;
53
+ columnId: string | null;
54
+ sorter: Gtk.CustomSorter | null;
55
+ listItemCache: Map<number, ListItemInfo>;
56
+ }
57
+ export declare class ColumnViewColumnNode extends Node<never, ColumnViewColumnState> {
43
58
  static matches(type: string): boolean;
44
59
  protected isVirtual(): boolean;
45
- private column;
46
- private factory;
47
- private renderCell;
48
60
  private columnView;
49
- private listItemCache;
50
- private columnId;
51
- private sorter;
52
- constructor(type: string, props: Props);
61
+ initialize(props: Props): void;
53
62
  getColumn(): Gtk.ColumnViewColumn;
54
63
  getId(): string | null;
55
64
  setColumnView(columnView: ColumnViewNode | null): void;
@@ -64,9 +73,10 @@ export declare class ColumnViewItemNode extends Node {
64
73
  static matches(type: string): boolean;
65
74
  protected isVirtual(): boolean;
66
75
  private item;
67
- constructor(type: string, props: Props);
76
+ initialize(props: Props): void;
68
77
  getItem(): unknown;
69
78
  attachToParent(parent: Node): void;
70
79
  attachToParentBefore(parent: Node, before: Node): void;
71
80
  detachFromParent(parent: Node): void;
72
81
  }
82
+ export {};
@@ -10,44 +10,45 @@ export class ColumnViewNode extends Node {
10
10
  static matches(type) {
11
11
  return type === "ColumnView.Root";
12
12
  }
13
- stringList;
14
- selectionModel;
15
- sortListModel;
16
- items = [];
17
- columns = [];
18
- committedLength = 0;
19
- sortColumn = null;
20
- sortOrder = Gtk.SortType.ASCENDING;
21
- sortFn = null;
22
- isSorting = false;
23
- onSortChange = null;
24
- sorterChangedHandlerId = null;
25
- lastNotifiedColumn = null;
26
- lastNotifiedOrder = Gtk.SortType.ASCENDING;
27
- constructor(type, props) {
28
- super(type, props);
29
- this.stringList = new Gtk.StringList([]);
30
- this.sortListModel = new Gtk.SortListModel(this.stringList, this.widget.getSorter());
31
- this.sortListModel.setIncremental(true);
32
- this.selectionModel = new Gtk.SingleSelection(this.sortListModel);
33
- this.widget.setModel(this.selectionModel);
34
- this.sortColumn = props.sortColumn ?? null;
35
- this.sortOrder = props.sortOrder ?? Gtk.SortType.ASCENDING;
36
- this.sortFn = props.sortFn ?? null;
37
- this.onSortChange =
38
- props.onSortChange ?? null;
13
+ initialize(props) {
14
+ // Initialize state before super.initialize() since updateProps accesses this.state
15
+ this.state = {
16
+ stringList: null,
17
+ selectionModel: null,
18
+ sortListModel: null,
19
+ items: [],
20
+ columns: [],
21
+ committedLength: 0,
22
+ sortColumn: props.sortColumn ?? null,
23
+ sortOrder: props.sortOrder ?? Gtk.SortType.ASCENDING,
24
+ sortFn: props.sortFn ?? null,
25
+ isSorting: false,
26
+ onSortChange: props.onSortChange ?? null,
27
+ sorterChangedHandlerId: null,
28
+ lastNotifiedColumn: null,
29
+ lastNotifiedOrder: Gtk.SortType.ASCENDING,
30
+ };
31
+ super.initialize(props);
32
+ const stringList = new Gtk.StringList([]);
33
+ const sortListModel = new Gtk.SortListModel(stringList, this.widget.getSorter());
34
+ sortListModel.setIncremental(true);
35
+ const selectionModel = new Gtk.SingleSelection(sortListModel);
36
+ this.widget.setModel(selectionModel);
37
+ this.state.stringList = stringList;
38
+ this.state.sortListModel = sortListModel;
39
+ this.state.selectionModel = selectionModel;
39
40
  this.connectSorterChangedSignal();
40
41
  }
41
42
  connectSorterChangedSignal() {
42
43
  const sorter = this.widget.getSorter();
43
- if (!sorter || !this.onSortChange)
44
+ if (!sorter || !this.state.onSortChange)
44
45
  return;
45
- this.sorterChangedHandlerId = sorter.connect("changed", () => {
46
+ this.state.sorterChangedHandlerId = sorter.connect("changed", () => {
46
47
  this.waitForSortComplete(() => this.notifySortChange());
47
48
  });
48
49
  }
49
50
  waitForSortComplete(callback) {
50
- const sortingInProgress = this.sortListModel.getPending() > 0;
51
+ const sortingInProgress = this.state.sortListModel.getPending() > 0;
51
52
  if (sortingInProgress) {
52
53
  setTimeout(() => this.waitForSortComplete(callback), 0);
53
54
  }
@@ -56,16 +57,16 @@ export class ColumnViewNode extends Node {
56
57
  }
57
58
  }
58
59
  disconnectSorterChangedSignal() {
59
- if (this.sorterChangedHandlerId === null)
60
+ if (this.state.sorterChangedHandlerId === null)
60
61
  return;
61
62
  const sorter = this.widget.getSorter();
62
63
  if (sorter) {
63
- GObject.signalHandlerDisconnect(sorter, this.sorterChangedHandlerId);
64
+ GObject.signalHandlerDisconnect(sorter, this.state.sorterChangedHandlerId);
64
65
  }
65
- this.sorterChangedHandlerId = null;
66
+ this.state.sorterChangedHandlerId = null;
66
67
  }
67
68
  notifySortChange() {
68
- if (!this.onSortChange)
69
+ if (!this.state.onSortChange)
69
70
  return;
70
71
  const baseSorter = this.widget.getSorter();
71
72
  if (!baseSorter)
@@ -74,99 +75,97 @@ export class ColumnViewNode extends Node {
74
75
  const column = sorter.getPrimarySortColumn();
75
76
  const order = sorter.getPrimarySortOrder();
76
77
  const columnId = column?.getId() ?? null;
77
- const sortStateUnchanged = columnId === this.lastNotifiedColumn && order === this.lastNotifiedOrder;
78
+ const sortStateUnchanged = columnId === this.state.lastNotifiedColumn && order === this.state.lastNotifiedOrder;
78
79
  if (sortStateUnchanged) {
79
80
  return;
80
81
  }
81
- this.lastNotifiedColumn = columnId;
82
- this.lastNotifiedOrder = order;
83
- this.onSortChange(columnId, order);
82
+ this.state.lastNotifiedColumn = columnId;
83
+ this.state.lastNotifiedOrder = order;
84
+ this.state.onSortChange(columnId, order);
84
85
  }
85
86
  getItems() {
86
- return this.items;
87
+ return this.state.items;
87
88
  }
88
89
  getSortFn() {
89
- return this.sortFn;
90
+ return this.state.sortFn;
90
91
  }
91
92
  compareItems(a, b, columnId) {
92
- if (this.isSorting || !this.sortFn)
93
+ if (this.state.isSorting || !this.state.sortFn)
93
94
  return 0;
94
- this.isSorting = true;
95
+ this.state.isSorting = true;
95
96
  try {
96
- return this.sortFn(a, b, columnId);
97
+ return this.state.sortFn(a, b, columnId);
97
98
  }
98
99
  finally {
99
- this.isSorting = false;
100
+ this.state.isSorting = false;
100
101
  }
101
102
  }
102
103
  addColumn(columnNode) {
103
- this.columns.push(columnNode);
104
+ this.state.columns.push(columnNode);
104
105
  const column = columnNode.getColumn();
105
106
  this.widget.appendColumn(column);
106
107
  columnNode.setColumnView(this);
107
- if (columnNode.getId() === this.sortColumn && this.sortColumn !== null) {
108
+ if (columnNode.getId() === this.state.sortColumn && this.state.sortColumn !== null) {
108
109
  this.applySortByColumn();
109
110
  }
110
111
  }
111
112
  applySortByColumn() {
112
- if (this.sortColumn === null) {
113
- this.widget.sortByColumn(this.sortOrder, null);
113
+ if (this.state.sortColumn === null) {
114
+ this.widget.sortByColumn(this.state.sortOrder, null);
114
115
  return;
115
116
  }
116
- if (!this.columns)
117
- return;
118
- const column = this.columns.find((c) => c.getId() === this.sortColumn);
117
+ const column = this.state.columns.find((c) => c.getId() === this.state.sortColumn);
119
118
  if (column) {
120
- this.widget.sortByColumn(this.sortOrder, column.getColumn());
119
+ this.widget.sortByColumn(this.state.sortOrder, column.getColumn());
121
120
  }
122
121
  }
123
122
  findColumnById(id) {
124
- return this.columns.find((c) => c.getId() === id);
123
+ return this.state.columns.find((c) => c.getId() === id);
125
124
  }
126
125
  removeColumn(column) {
127
- const index = this.columns.indexOf(column);
126
+ const index = this.state.columns.indexOf(column);
128
127
  if (index !== -1) {
129
- this.columns.splice(index, 1);
128
+ this.state.columns.splice(index, 1);
130
129
  this.widget.removeColumn(column.getColumn());
131
130
  column.setColumnView(null);
132
131
  }
133
132
  }
134
133
  insertColumnBefore(column, before) {
135
- const beforeIndex = this.columns.indexOf(before);
134
+ const beforeIndex = this.state.columns.indexOf(before);
136
135
  if (beforeIndex === -1) {
137
136
  this.addColumn(column);
138
137
  return;
139
138
  }
140
- this.columns.splice(beforeIndex, 0, column);
139
+ this.state.columns.splice(beforeIndex, 0, column);
141
140
  this.widget.insertColumn(beforeIndex, column.getColumn());
142
141
  column.setColumnView(this);
143
142
  }
144
143
  syncStringList = () => {
145
- const newLength = this.items.length;
146
- if (newLength === this.committedLength)
144
+ const newLength = this.state.items.length;
145
+ if (newLength === this.state.committedLength)
147
146
  return;
148
147
  const itemIndicesForSorter = Array.from({ length: newLength }, (_, i) => String(i));
149
- this.stringList.splice(0, this.committedLength, itemIndicesForSorter);
150
- this.committedLength = newLength;
148
+ this.state.stringList.splice(0, this.state.committedLength, itemIndicesForSorter);
149
+ this.state.committedLength = newLength;
151
150
  };
152
151
  addItem(item) {
153
- this.items.push(item);
152
+ this.state.items.push(item);
154
153
  scheduleFlush(this.syncStringList);
155
154
  }
156
155
  insertItemBefore(item, beforeItem) {
157
- const beforeIndex = this.items.indexOf(beforeItem);
156
+ const beforeIndex = this.state.items.indexOf(beforeItem);
158
157
  if (beforeIndex === -1) {
159
- this.items.push(item);
158
+ this.state.items.push(item);
160
159
  }
161
160
  else {
162
- this.items.splice(beforeIndex, 0, item);
161
+ this.state.items.splice(beforeIndex, 0, item);
163
162
  }
164
163
  scheduleFlush(this.syncStringList);
165
164
  }
166
165
  removeItem(item) {
167
- const index = this.items.indexOf(item);
166
+ const index = this.state.items.indexOf(item);
168
167
  if (index !== -1) {
169
- this.items.splice(index, 1);
168
+ this.state.items.splice(index, 1);
170
169
  scheduleFlush(this.syncStringList);
171
170
  }
172
171
  }
@@ -185,9 +184,9 @@ export class ColumnViewNode extends Node {
185
184
  const newSortFn = newProps.sortFn ?? null;
186
185
  const newOnSortChange = newProps.onSortChange ?? null;
187
186
  if (oldProps.onSortChange !== newProps.onSortChange) {
188
- const hadCallback = this.onSortChange !== null;
189
- this.onSortChange = newOnSortChange;
190
- const hasCallback = this.onSortChange !== null;
187
+ const hadCallback = this.state.onSortChange !== null;
188
+ this.state.onSortChange = newOnSortChange;
189
+ const hasCallback = this.state.onSortChange !== null;
191
190
  const callbackAdded = !hadCallback && hasCallback;
192
191
  const callbackRemoved = hadCallback && !hasCallback;
193
192
  if (callbackAdded) {
@@ -198,16 +197,14 @@ export class ColumnViewNode extends Node {
198
197
  }
199
198
  }
200
199
  if (oldProps.sortFn !== newProps.sortFn) {
201
- this.sortFn = newSortFn;
202
- if (this.columns) {
203
- for (const column of this.columns) {
204
- column.updateSorterFromRoot();
205
- }
200
+ this.state.sortFn = newSortFn;
201
+ for (const column of this.state.columns) {
202
+ column.updateSorterFromRoot();
206
203
  }
207
204
  }
208
205
  if (oldProps.sortColumn !== newProps.sortColumn || oldProps.sortOrder !== newProps.sortOrder) {
209
- this.sortColumn = newSortColumn;
210
- this.sortOrder = newSortOrder;
206
+ this.state.sortColumn = newSortColumn;
207
+ this.state.sortOrder = newSortOrder;
211
208
  this.applySortByColumn();
212
209
  }
213
210
  }
@@ -219,94 +216,96 @@ export class ColumnViewColumnNode extends Node {
219
216
  isVirtual() {
220
217
  return true;
221
218
  }
222
- column;
223
- factory;
224
- renderCell;
225
219
  columnView = null;
226
- listItemCache = new Map();
227
- columnId = null;
228
- sorter = null;
229
- constructor(type, props) {
230
- super(type, props);
231
- this.factory = new Gtk.SignalListItemFactory();
232
- this.column = new Gtk.ColumnViewColumn(props.title, this.factory);
233
- this.renderCell = props.renderCell;
234
- this.columnId = props.id ?? null;
235
- if (this.columnId !== null) {
236
- this.column.setId(this.columnId);
220
+ initialize(props) {
221
+ // Initialize state before super.initialize() since updateProps accesses this.state
222
+ const factory = new Gtk.SignalListItemFactory();
223
+ const column = new Gtk.ColumnViewColumn(props.title, factory);
224
+ const columnId = props.id ?? null;
225
+ this.state = {
226
+ column,
227
+ factory,
228
+ renderCell: props.renderCell,
229
+ columnId,
230
+ sorter: null,
231
+ listItemCache: new Map(),
232
+ };
233
+ super.initialize(props);
234
+ if (columnId !== null) {
235
+ column.setId(columnId);
237
236
  }
238
237
  if (props.expand !== undefined) {
239
- this.column.setExpand(props.expand);
238
+ column.setExpand(props.expand);
240
239
  }
241
240
  if (props.resizable !== undefined) {
242
- this.column.setResizable(props.resizable);
241
+ column.setResizable(props.resizable);
243
242
  }
244
243
  if (props.fixedWidth !== undefined) {
245
- this.column.setFixedWidth(props.fixedWidth);
244
+ column.setFixedWidth(props.fixedWidth);
246
245
  }
247
- this.factory.connect("setup", (_self, listItemObj) => {
246
+ factory.connect("setup", (_self, listItemObj) => {
248
247
  const listItem = getObject(listItemObj.ptr, Gtk.ListItem);
249
248
  const id = getObjectId(listItemObj.ptr);
250
249
  const box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
251
250
  listItem.setChild(box);
252
251
  const fiberRoot = createFiberRoot(box);
253
- this.listItemCache.set(id, { box, fiberRoot });
254
- const element = this.renderCell(null);
252
+ this.state.listItemCache.set(id, { box, fiberRoot });
253
+ const element = this.state.renderCell(null);
255
254
  reconciler.getInstance().updateContainer(element, fiberRoot, null, () => { });
256
255
  });
257
- this.factory.connect("bind", (_self, listItemObj) => {
256
+ factory.connect("bind", (_self, listItemObj) => {
258
257
  const listItem = getObject(listItemObj.ptr, Gtk.ListItem);
259
258
  const id = getObjectId(listItemObj.ptr);
260
- const info = this.listItemCache.get(id);
259
+ const info = this.state.listItemCache.get(id);
261
260
  if (!info)
262
261
  return;
263
262
  const position = listItem.getPosition();
264
263
  if (this.columnView) {
265
264
  const items = this.columnView.getItems();
266
265
  const item = items[position];
267
- const element = this.renderCell(item ?? null);
266
+ const element = this.state.renderCell(item ?? null);
268
267
  reconciler.getInstance().updateContainer(element, info.fiberRoot, null, () => { });
269
268
  }
270
269
  });
271
- this.factory.connect("unbind", (_self, listItemObj) => {
270
+ factory.connect("unbind", (_self, listItemObj) => {
272
271
  const id = getObjectId(listItemObj.ptr);
273
- const info = this.listItemCache.get(id);
272
+ const info = this.state.listItemCache.get(id);
274
273
  if (!info)
275
274
  return;
276
275
  reconciler.getInstance().updateContainer(null, info.fiberRoot, null, () => { });
277
276
  });
278
- this.factory.connect("teardown", (_self, listItemObj) => {
277
+ factory.connect("teardown", (_self, listItemObj) => {
279
278
  const id = getObjectId(listItemObj.ptr);
280
- const info = this.listItemCache.get(id);
279
+ const info = this.state.listItemCache.get(id);
281
280
  if (info) {
282
281
  reconciler.getInstance().updateContainer(null, info.fiberRoot, null, () => { });
283
- this.listItemCache.delete(id);
282
+ this.state.listItemCache.delete(id);
284
283
  }
285
284
  });
286
285
  }
287
286
  getColumn() {
288
- return this.column;
287
+ return this.state.column;
289
288
  }
290
289
  getId() {
291
- return this.columnId;
290
+ return this.state.columnId;
292
291
  }
293
292
  setColumnView(columnView) {
294
293
  this.columnView = columnView;
295
294
  this.updateSorterFromRoot();
296
295
  }
297
296
  updateSorterFromRoot() {
298
- if (!this.columnView || this.columnId === null) {
299
- this.column.setSorter(null);
300
- this.sorter = null;
297
+ if (!this.columnView || this.state.columnId === null) {
298
+ this.state.column.setSorter(null);
299
+ this.state.sorter = null;
301
300
  return;
302
301
  }
303
302
  const rootSortFn = this.columnView.getSortFn();
304
303
  if (rootSortFn === null) {
305
- this.column.setSorter(null);
306
- this.sorter = null;
304
+ this.state.column.setSorter(null);
305
+ this.state.sorter = null;
307
306
  return;
308
307
  }
309
- const columnId = this.columnId;
308
+ const columnId = this.state.columnId;
310
309
  const columnView = this.columnView;
311
310
  const wrappedSortFn = (stringObjPtrA, stringObjPtrB) => {
312
311
  const items = columnView.getItems();
@@ -323,8 +322,8 @@ export class ColumnViewColumnNode extends Node {
323
322
  const result = columnView.compareItems(itemA, itemB, columnId);
324
323
  return typeof result === "number" ? result : 0;
325
324
  };
326
- this.sorter = new Gtk.CustomSorter(wrappedSortFn);
327
- this.column.setSorter(this.sorter);
325
+ this.state.sorter = new Gtk.CustomSorter(wrappedSortFn);
326
+ this.state.column.setSorter(this.state.sorter);
328
327
  }
329
328
  attachToParent(parent) {
330
329
  if (isColumnContainer(parent)) {
@@ -356,25 +355,23 @@ export class ColumnViewColumnNode extends Node {
356
355
  }
357
356
  updateProps(oldProps, newProps) {
358
357
  if (oldProps.renderCell !== newProps.renderCell) {
359
- this.renderCell = newProps.renderCell;
358
+ this.state.renderCell = newProps.renderCell;
360
359
  }
361
- if (!this.column)
362
- return;
363
360
  if (oldProps.title !== newProps.title) {
364
- this.column.setTitle(newProps.title);
361
+ this.state.column.setTitle(newProps.title);
365
362
  }
366
363
  if (oldProps.expand !== newProps.expand) {
367
- this.column.setExpand(newProps.expand);
364
+ this.state.column.setExpand(newProps.expand);
368
365
  }
369
366
  if (oldProps.resizable !== newProps.resizable) {
370
- this.column.setResizable(newProps.resizable);
367
+ this.state.column.setResizable(newProps.resizable);
371
368
  }
372
369
  if (oldProps.fixedWidth !== newProps.fixedWidth) {
373
- this.column.setFixedWidth(newProps.fixedWidth);
370
+ this.state.column.setFixedWidth(newProps.fixedWidth);
374
371
  }
375
372
  if (oldProps.id !== newProps.id) {
376
- this.columnId = newProps.id ?? null;
377
- this.column.setId(this.columnId);
373
+ this.state.columnId = newProps.id ?? null;
374
+ this.state.column.setId(this.state.columnId);
378
375
  }
379
376
  }
380
377
  }
@@ -386,9 +383,9 @@ export class ColumnViewItemNode extends Node {
386
383
  return true;
387
384
  }
388
385
  item;
389
- constructor(type, props) {
390
- super(type, props);
386
+ initialize(props) {
391
387
  this.item = props.item;
388
+ super.initialize(props);
392
389
  }
393
390
  getItem() {
394
391
  return this.item;
@@ -6,7 +6,7 @@ export declare class DropDownNode extends Node<Gtk.DropDown> implements ItemCont
6
6
  static matches(type: string): boolean;
7
7
  private store;
8
8
  private onSelectionChanged?;
9
- constructor(type: string, props: Props);
9
+ initialize(props: Props): void;
10
10
  addItem(item: unknown): void;
11
11
  insertItemBefore(item: unknown, _beforeItem: unknown): void;
12
12
  removeItem(item: unknown): void;
@@ -17,7 +17,7 @@ export declare class DropDownItemNode extends Node<never> {
17
17
  static matches(type: string): boolean;
18
18
  protected isVirtual(): boolean;
19
19
  private item;
20
- constructor(type: string, props: Props);
20
+ initialize(props: Props): void;
21
21
  getItem(): unknown;
22
22
  attachToParent(parent: Node): void;
23
23
  detachFromParent(parent: Node): void;
@@ -37,8 +37,8 @@ export class DropDownNode extends Node {
37
37
  }
38
38
  store;
39
39
  onSelectionChanged;
40
- constructor(type, props) {
41
- super(type, props);
40
+ initialize(props) {
41
+ super.initialize(props);
42
42
  const labelFn = props.itemLabel ?? ((item) => String(item));
43
43
  this.onSelectionChanged = props.onSelectionChanged;
44
44
  this.store = new DropDownStore(labelFn);
@@ -82,8 +82,8 @@ export class DropDownItemNode extends Node {
82
82
  return true;
83
83
  }
84
84
  item;
85
- constructor(type, props) {
86
- super(type, props);
85
+ initialize(props) {
86
+ super.initialize(props);
87
87
  this.item = props.item;
88
88
  }
89
89
  getItem() {
@@ -16,7 +16,7 @@ export declare class GridChildNode extends Node<never> {
16
16
  private rowSpan;
17
17
  private childWidget;
18
18
  private parentContainer;
19
- constructor(type: string, props: Props);
19
+ initialize(props: Props): void;
20
20
  appendChild(child: Node): void;
21
21
  removeChild(child: Node): void;
22
22
  private attachChildToGrid;