@gtkx/react 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/README.md +1 -0
  2. package/dist/errors.js +3 -0
  3. package/dist/factory.d.ts +3 -2
  4. package/dist/factory.js +1 -1
  5. package/dist/generated/internal.d.ts +28 -1
  6. package/dist/generated/internal.js +93 -18
  7. package/dist/generated/jsx.d.ts +1489 -1300
  8. package/dist/generated/jsx.js +475 -0
  9. package/dist/host-config.d.ts +3 -1
  10. package/dist/host-config.js +31 -11
  11. package/dist/jsx.d.ts +107 -166
  12. package/dist/jsx.js +58 -69
  13. package/dist/node.d.ts +3 -1
  14. package/dist/node.js +5 -3
  15. package/dist/nodes/abstract/positional-child.d.ts +9 -0
  16. package/dist/nodes/abstract/positional-child.js +29 -0
  17. package/dist/nodes/abstract/positional-parent.d.ts +18 -0
  18. package/dist/nodes/abstract/positional-parent.js +48 -0
  19. package/dist/nodes/abstract/virtual-container.d.ts +17 -0
  20. package/dist/nodes/abstract/virtual-container.js +59 -0
  21. package/dist/nodes/abstract/virtual-single-child.d.ts +18 -0
  22. package/dist/nodes/abstract/virtual-single-child.js +54 -0
  23. package/dist/nodes/action-row-child.d.ts +0 -13
  24. package/dist/nodes/action-row-child.js +14 -12
  25. package/dist/nodes/action-row.d.ts +6 -1
  26. package/dist/nodes/action-row.js +4 -37
  27. package/dist/nodes/adjustable.d.ts +23 -0
  28. package/dist/nodes/adjustable.js +62 -0
  29. package/dist/nodes/alert-dialog-response.d.ts +1 -0
  30. package/dist/nodes/alert-dialog-response.js +86 -0
  31. package/dist/nodes/animation/animation-controller.d.ts +17 -0
  32. package/dist/nodes/animation/animation-controller.js +107 -0
  33. package/dist/nodes/animation/animation-factory.d.ts +15 -0
  34. package/dist/nodes/animation/animation-factory.js +25 -0
  35. package/dist/nodes/animation/animation-node.d.ts +9 -0
  36. package/dist/nodes/animation/animation-node.js +126 -0
  37. package/dist/nodes/animation/animation-style-sheet.d.ts +16 -0
  38. package/dist/nodes/animation/animation-style-sheet.js +74 -0
  39. package/dist/nodes/animation/index.d.ts +4 -0
  40. package/dist/nodes/animation/index.js +1 -0
  41. package/dist/nodes/animation/property-mapper.d.ts +11 -0
  42. package/dist/nodes/animation/property-mapper.js +36 -0
  43. package/dist/nodes/animation/transform-state.d.ts +11 -0
  44. package/dist/nodes/animation/transform-state.js +57 -0
  45. package/dist/nodes/animation/widget-registry.d.ts +5 -0
  46. package/dist/nodes/animation/widget-registry.js +42 -0
  47. package/dist/nodes/application.js +17 -7
  48. package/dist/nodes/autowrapped.js +37 -43
  49. package/dist/nodes/calendar.js +17 -43
  50. package/dist/nodes/color-dialog-button.d.ts +1 -0
  51. package/dist/nodes/color-dialog-button.js +70 -0
  52. package/dist/nodes/column-view-column.d.ts +3 -3
  53. package/dist/nodes/column-view-column.js +1 -1
  54. package/dist/nodes/column-view.js +36 -39
  55. package/dist/nodes/dialog.d.ts +11 -0
  56. package/dist/nodes/dialog.js +20 -0
  57. package/dist/nodes/drawing-area.js +24 -7
  58. package/dist/nodes/event-controller.d.ts +1 -0
  59. package/dist/nodes/event-controller.js +96 -0
  60. package/dist/nodes/expander-row-child.d.ts +0 -14
  61. package/dist/nodes/expander-row-child.js +14 -12
  62. package/dist/nodes/expander-row.d.ts +6 -1
  63. package/dist/nodes/expander-row.js +11 -48
  64. package/dist/nodes/fixed-child.js +48 -36
  65. package/dist/nodes/font-dialog-button.d.ts +1 -0
  66. package/dist/nodes/font-dialog-button.js +90 -0
  67. package/dist/nodes/grid-child.js +39 -45
  68. package/dist/nodes/grid.d.ts +1 -0
  69. package/dist/nodes/grid.js +41 -0
  70. package/dist/nodes/index.d.ts +17 -9
  71. package/dist/nodes/index.js +17 -9
  72. package/dist/nodes/internal/base-item-renderer.d.ts +29 -0
  73. package/dist/nodes/internal/base-item-renderer.js +88 -0
  74. package/dist/nodes/internal/base-store.d.ts +9 -0
  75. package/dist/nodes/internal/base-store.js +20 -0
  76. package/dist/nodes/internal/child-attachment.d.ts +26 -0
  77. package/dist/nodes/internal/child-attachment.js +48 -0
  78. package/dist/nodes/internal/deferred-action.d.ts +8 -0
  79. package/dist/nodes/internal/deferred-action.js +19 -0
  80. package/dist/nodes/internal/list-item-renderer.d.ts +14 -15
  81. package/dist/nodes/internal/list-item-renderer.js +51 -77
  82. package/dist/nodes/internal/list-store.d.ts +7 -6
  83. package/dist/nodes/internal/list-store.js +20 -24
  84. package/dist/nodes/internal/predicates.d.ts +25 -2
  85. package/dist/nodes/internal/predicates.js +53 -41
  86. package/dist/nodes/internal/selection-model.d.ts +30 -0
  87. package/dist/nodes/internal/selection-model.js +91 -0
  88. package/dist/nodes/internal/signal-store.d.ts +5 -4
  89. package/dist/nodes/internal/signal-store.js +30 -28
  90. package/dist/nodes/internal/simple-list-store.js +6 -9
  91. package/dist/nodes/internal/text-buffer-controller.d.ts +43 -0
  92. package/dist/nodes/internal/text-buffer-controller.js +287 -0
  93. package/dist/nodes/internal/text-tag-styles.d.ts +43 -0
  94. package/dist/nodes/internal/text-tag-styles.js +52 -0
  95. package/dist/nodes/internal/tree-list-item-renderer.d.ts +15 -14
  96. package/dist/nodes/internal/tree-list-item-renderer.js +85 -96
  97. package/dist/nodes/internal/tree-store.d.ts +10 -9
  98. package/dist/nodes/internal/tree-store.js +31 -35
  99. package/dist/nodes/internal/utils.d.ts +7 -4
  100. package/dist/nodes/internal/utils.js +50 -5
  101. package/dist/nodes/level-bar.js +19 -54
  102. package/dist/nodes/list-item.d.ts +6 -3
  103. package/dist/nodes/list-item.js +7 -4
  104. package/dist/nodes/list-view.js +15 -11
  105. package/dist/nodes/menu.d.ts +3 -3
  106. package/dist/nodes/menu.js +3 -3
  107. package/dist/nodes/models/list.d.ts +11 -13
  108. package/dist/nodes/models/list.js +16 -73
  109. package/dist/nodes/models/menu.d.ts +8 -7
  110. package/dist/nodes/models/menu.js +43 -50
  111. package/dist/nodes/models/tree-list.d.ts +6 -12
  112. package/dist/nodes/models/tree-list.js +30 -93
  113. package/dist/nodes/navigation-page.d.ts +1 -0
  114. package/dist/nodes/navigation-page.js +27 -32
  115. package/dist/nodes/navigation-view.js +17 -28
  116. package/dist/nodes/notebook-page-tab.d.ts +3 -3
  117. package/dist/nodes/notebook-page-tab.js +11 -14
  118. package/dist/nodes/notebook-page.d.ts +7 -5
  119. package/dist/nodes/notebook-page.js +45 -25
  120. package/dist/nodes/notebook.js +2 -2
  121. package/dist/nodes/overlay-child.js +90 -30
  122. package/dist/nodes/pack-child.d.ts +0 -13
  123. package/dist/nodes/pack-child.js +14 -12
  124. package/dist/nodes/pack.d.ts +6 -1
  125. package/dist/nodes/pack.js +4 -37
  126. package/dist/nodes/popover-menu.js +2 -2
  127. package/dist/nodes/scale.js +15 -45
  128. package/dist/nodes/scrolled-window.js +7 -6
  129. package/dist/nodes/search-bar.d.ts +1 -0
  130. package/dist/nodes/search-bar.js +40 -0
  131. package/dist/nodes/shortcut-controller.d.ts +1 -37
  132. package/dist/nodes/shortcut-controller.js +24 -8
  133. package/dist/nodes/shortcut.d.ts +5 -4
  134. package/dist/nodes/shortcut.js +11 -5
  135. package/dist/nodes/simple-list-view.js +2 -3
  136. package/dist/nodes/slot.d.ts +6 -9
  137. package/dist/nodes/slot.js +27 -42
  138. package/dist/nodes/source-view.js +80 -29
  139. package/dist/nodes/stack-page.js +20 -22
  140. package/dist/nodes/stack.js +19 -5
  141. package/dist/nodes/text-anchor.d.ts +41 -0
  142. package/dist/nodes/text-anchor.js +59 -0
  143. package/dist/nodes/text-content.d.ts +10 -0
  144. package/dist/nodes/text-content.js +1 -0
  145. package/dist/nodes/text-paintable.d.ts +17 -0
  146. package/dist/nodes/text-paintable.js +34 -0
  147. package/dist/nodes/text-segment.d.ts +15 -0
  148. package/dist/nodes/text-segment.js +29 -0
  149. package/dist/nodes/text-tag.d.ts +136 -0
  150. package/dist/nodes/text-tag.js +202 -0
  151. package/dist/nodes/text-view.d.ts +30 -0
  152. package/dist/nodes/text-view.js +49 -21
  153. package/dist/nodes/toggle-group.js +24 -32
  154. package/dist/nodes/toggle.d.ts +1 -15
  155. package/dist/nodes/toggle.js +40 -32
  156. package/dist/nodes/toolbar-child.js +14 -16
  157. package/dist/nodes/tree-list-item.d.ts +7 -5
  158. package/dist/nodes/tree-list-item.js +24 -36
  159. package/dist/nodes/tree-list-view.js +7 -6
  160. package/dist/nodes/virtual.d.ts +1 -1
  161. package/dist/nodes/widget.d.ts +2 -16
  162. package/dist/nodes/widget.js +105 -294
  163. package/dist/nodes/window.d.ts +9 -3
  164. package/dist/nodes/window.js +29 -15
  165. package/dist/registry.d.ts +1 -1
  166. package/dist/render.js +8 -6
  167. package/dist/scheduler.d.ts +11 -1
  168. package/dist/scheduler.js +16 -4
  169. package/dist/types.d.ts +2 -136
  170. package/package.json +3 -3
  171. package/dist/nodes/adjustment.d.ts +0 -48
  172. package/dist/nodes/adjustment.js +0 -70
  173. package/dist/nodes/calendar-mark.d.ts +0 -15
  174. package/dist/nodes/calendar-mark.js +0 -29
  175. package/dist/nodes/internal/constants.d.ts +0 -1
  176. package/dist/nodes/internal/constants.js +0 -24
  177. package/dist/nodes/level-bar-offset.d.ts +0 -13
  178. package/dist/nodes/level-bar-offset.js +0 -35
  179. package/dist/nodes/scale-mark.d.ts +0 -17
  180. package/dist/nodes/scale-mark.js +0 -38
  181. package/dist/nodes/source-buffer.d.ts +0 -73
  182. package/dist/nodes/source-buffer.js +0 -149
  183. package/dist/nodes/text-buffer.d.ts +0 -43
  184. package/dist/nodes/text-buffer.js +0 -81
  185. package/dist/nodes/virtual-child.d.ts +0 -18
  186. package/dist/nodes/virtual-child.js +0 -62
@@ -1,53 +1,65 @@
1
- import { batch, isObjectEqual } from "@gtkx/ffi";
2
1
  import { registerNodeClass } from "../registry.js";
3
- import { SlotNode } from "./slot.js";
4
- class FixedChildNode extends SlotNode {
2
+ import { PositionalChildNode } from "./abstract/positional-child.js";
3
+ import { hasChanged } from "./internal/utils.js";
4
+ class FixedChildNode extends PositionalChildNode {
5
5
  static priority = 1;
6
6
  static matches(type) {
7
7
  return type === "FixedChild";
8
8
  }
9
- getFixed() {
10
- if (!this.parent) {
11
- throw new Error("Expected Fixed reference to be set on FixedChildNode");
9
+ onChildChange(oldChild) {
10
+ super.onChildChange(oldChild);
11
+ if (this.child) {
12
+ this.applyTransform();
12
13
  }
13
- return this.parent;
14
+ }
15
+ attachToParent(parent, child) {
16
+ const fixed = parent;
17
+ const x = this.props.x ?? 0;
18
+ const y = this.props.y ?? 0;
19
+ fixed.put(child, x, y);
20
+ }
21
+ detachFromParent(parent, child) {
22
+ parent.remove(child);
14
23
  }
15
24
  updateProps(oldProps, newProps) {
16
25
  super.updateProps(oldProps, newProps);
17
- if (!oldProps || oldProps.x !== newProps.x || oldProps.y !== newProps.y) {
18
- if (this.parent && this.child) {
19
- this.positionChild();
20
- }
26
+ this.applyOwnProps(oldProps, newProps);
27
+ }
28
+ applyOwnProps(oldProps, newProps) {
29
+ if (!this.parent || !this.child) {
30
+ return;
31
+ }
32
+ const positionChanged = hasChanged(oldProps, newProps, "x") || hasChanged(oldProps, newProps, "y");
33
+ if (positionChanged) {
34
+ this.repositionChild();
35
+ }
36
+ else if (hasChanged(oldProps, newProps, "transform")) {
37
+ this.applyTransform();
21
38
  }
22
39
  }
23
- positionChild() {
24
- const fixed = this.getFixed();
40
+ repositionChild() {
41
+ const fixed = this.getTypedParent();
42
+ const child = this.child;
43
+ if (!child) {
44
+ return;
45
+ }
25
46
  const x = this.props.x ?? 0;
26
47
  const y = this.props.y ?? 0;
27
- if (this.child) {
28
- const child = this.child;
29
- batch(() => {
30
- const currentParent = child.getParent();
31
- if (currentParent && isObjectEqual(currentParent, fixed)) {
32
- fixed.remove(child);
33
- }
34
- fixed.put(child, x, y);
35
- });
36
- }
48
+ fixed.remove(child);
49
+ fixed.put(child, x, y);
50
+ this.applyTransform();
37
51
  }
38
- onChildChange(oldChild) {
39
- const fixed = this.getFixed();
40
- batch(() => {
41
- if (oldChild) {
42
- const parent = oldChild.getParent();
43
- if (parent && isObjectEqual(parent, fixed)) {
44
- fixed.remove(oldChild);
45
- }
46
- }
47
- if (this.child) {
48
- this.positionChild();
49
- }
50
- });
52
+ applyTransform() {
53
+ if (!this.child || !this.props.transform) {
54
+ return;
55
+ }
56
+ const fixed = this.getTypedParent();
57
+ const layoutManager = fixed.getLayoutManager();
58
+ if (!layoutManager) {
59
+ return;
60
+ }
61
+ const layoutChild = layoutManager.getLayoutChild(this.child);
62
+ layoutChild.setTransform(this.props.transform);
51
63
  }
52
64
  }
53
65
  registerNodeClass(FixedChildNode);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,90 @@
1
+ import * as Gtk from "@gtkx/ffi/gtk";
2
+ import { registerNodeClass } from "../registry.js";
3
+ import { filterProps, hasChanged, matchesAnyClass } from "./internal/utils.js";
4
+ import { WidgetNode } from "./widget.js";
5
+ const OWN_PROPS = [
6
+ "fontDesc",
7
+ "onFontDescChanged",
8
+ "title",
9
+ "modal",
10
+ "language",
11
+ "useFont",
12
+ "useSize",
13
+ "level",
14
+ ];
15
+ class FontDialogButtonNode extends WidgetNode {
16
+ static priority = 1;
17
+ dialog;
18
+ notifyHandler = null;
19
+ static matches(_type, containerOrClass) {
20
+ return matchesAnyClass([Gtk.FontDialogButton], containerOrClass);
21
+ }
22
+ static createContainer(_props, containerClass) {
23
+ const dialog = new Gtk.FontDialog();
24
+ const button = new containerClass(dialog);
25
+ return button;
26
+ }
27
+ constructor(type, props, container, rootContainer) {
28
+ super(type, props, container, rootContainer);
29
+ const dialog = container.getDialog();
30
+ if (!dialog) {
31
+ throw new Error("FontDialogButton must have a dialog");
32
+ }
33
+ this.dialog = dialog;
34
+ }
35
+ updateProps(oldProps, newProps) {
36
+ super.updateProps(oldProps ? filterProps(oldProps, OWN_PROPS) : null, filterProps(newProps, OWN_PROPS));
37
+ this.applyOwnProps(oldProps, newProps);
38
+ }
39
+ applyOwnProps(oldProps, newProps) {
40
+ if (hasChanged(oldProps, newProps, "title") && newProps.title !== undefined) {
41
+ this.dialog.setTitle(newProps.title);
42
+ }
43
+ if (hasChanged(oldProps, newProps, "modal")) {
44
+ this.dialog.setModal(newProps.modal ?? true);
45
+ }
46
+ if (hasChanged(oldProps, newProps, "language") && newProps.language) {
47
+ this.dialog.setLanguage(newProps.language);
48
+ }
49
+ if (hasChanged(oldProps, newProps, "useFont")) {
50
+ this.container.setUseFont(newProps.useFont ?? false);
51
+ }
52
+ if (hasChanged(oldProps, newProps, "useSize")) {
53
+ this.container.setUseSize(newProps.useSize ?? false);
54
+ }
55
+ if (hasChanged(oldProps, newProps, "level")) {
56
+ this.container.setLevel(newProps.level ?? Gtk.FontLevel.FONT);
57
+ }
58
+ if (hasChanged(oldProps, newProps, "fontDesc") && newProps.fontDesc) {
59
+ this.container.setFontDesc(newProps.fontDesc);
60
+ }
61
+ if (hasChanged(oldProps, newProps, "onFontDescChanged")) {
62
+ this.setupNotifyHandler(newProps.onFontDescChanged);
63
+ }
64
+ }
65
+ setupNotifyHandler(callback) {
66
+ if (this.notifyHandler) {
67
+ this.signalStore.set(this, this.container, "notify", undefined);
68
+ this.notifyHandler = null;
69
+ }
70
+ if (callback) {
71
+ this.notifyHandler = (_button, pspec) => {
72
+ if (pspec.getName() === "font-desc") {
73
+ const fontDesc = this.container.getFontDesc();
74
+ if (fontDesc) {
75
+ callback(fontDesc);
76
+ }
77
+ }
78
+ };
79
+ this.signalStore.set(this, this.container, "notify", this.notifyHandler);
80
+ }
81
+ }
82
+ unmount() {
83
+ if (this.notifyHandler) {
84
+ this.signalStore.set(this, this.container, "notify", undefined);
85
+ this.notifyHandler = null;
86
+ }
87
+ super.unmount();
88
+ }
89
+ }
90
+ registerNodeClass(FontDialogButtonNode);
@@ -1,62 +1,56 @@
1
- import { batch, isObjectEqual } from "@gtkx/ffi";
1
+ import { isObjectEqual } from "@gtkx/ffi";
2
2
  import { registerNodeClass } from "../registry.js";
3
- import { SlotNode } from "./slot.js";
4
- class GridChildNode extends SlotNode {
3
+ import { PositionalChildNode } from "./abstract/positional-child.js";
4
+ import { hasChanged } from "./internal/utils.js";
5
+ class GridChildNode extends PositionalChildNode {
5
6
  static priority = 1;
6
7
  static matches(type) {
7
8
  return type === "GridChild";
8
9
  }
10
+ attachToParent(parent, child) {
11
+ const grid = parent;
12
+ const column = this.props.column ?? 0;
13
+ const row = this.props.row ?? 0;
14
+ const columnSpan = this.props.columnSpan ?? 1;
15
+ const rowSpan = this.props.rowSpan ?? 1;
16
+ const existingChild = grid.getChildAt(column, row);
17
+ if (existingChild && !isObjectEqual(existingChild, child)) {
18
+ grid.remove(existingChild);
19
+ }
20
+ grid.attach(child, column, row, columnSpan, rowSpan);
21
+ }
22
+ detachFromParent(parent, child) {
23
+ parent.remove(child);
24
+ }
9
25
  updateProps(oldProps, newProps) {
10
26
  super.updateProps(oldProps, newProps);
11
- if (!oldProps ||
12
- oldProps.column !== newProps.column ||
13
- oldProps.row !== newProps.row ||
14
- oldProps.columnSpan !== newProps.columnSpan ||
15
- oldProps.rowSpan !== newProps.rowSpan) {
16
- if (this.parent && this.child) {
17
- this.attachChild();
18
- }
19
- }
27
+ this.applyOwnProps(oldProps, newProps);
20
28
  }
21
- getGrid() {
22
- if (!this.parent) {
23
- throw new Error("Expected Grid reference to be set on GridChildNode");
29
+ applyOwnProps(oldProps, newProps) {
30
+ const positionChanged = hasChanged(oldProps, newProps, "column") ||
31
+ hasChanged(oldProps, newProps, "row") ||
32
+ hasChanged(oldProps, newProps, "columnSpan") ||
33
+ hasChanged(oldProps, newProps, "rowSpan");
34
+ if (positionChanged && this.parent && this.child) {
35
+ this.reattachChild();
24
36
  }
25
- return this.parent;
26
37
  }
27
- attachChild() {
28
- const grid = this.getGrid();
38
+ reattachChild() {
39
+ const grid = this.getTypedParent();
40
+ const child = this.child;
41
+ if (!child) {
42
+ return;
43
+ }
29
44
  const column = this.props.column ?? 0;
30
45
  const row = this.props.row ?? 0;
31
46
  const columnSpan = this.props.columnSpan ?? 1;
32
47
  const rowSpan = this.props.rowSpan ?? 1;
33
- batch(() => {
34
- const existingChild = grid.getChildAt(column, row);
35
- if (existingChild && this.child && !isObjectEqual(existingChild, this.child)) {
36
- grid.remove(existingChild);
37
- }
38
- if (this.child) {
39
- const currentParent = this.child.getParent();
40
- if (currentParent && isObjectEqual(currentParent, grid)) {
41
- grid.remove(this.child);
42
- }
43
- grid.attach(this.child, column, row, columnSpan, rowSpan);
44
- }
45
- });
46
- }
47
- onChildChange(oldChild) {
48
- const grid = this.getGrid();
49
- batch(() => {
50
- if (oldChild) {
51
- const parent = oldChild.getParent();
52
- if (parent && isObjectEqual(parent, grid)) {
53
- grid.remove(oldChild);
54
- }
55
- }
56
- if (this.child) {
57
- this.attachChild();
58
- }
59
- });
48
+ const existingChild = grid.getChildAt(column, row);
49
+ if (existingChild && !isObjectEqual(existingChild, child)) {
50
+ grid.remove(existingChild);
51
+ }
52
+ grid.remove(child);
53
+ grid.attach(child, column, row, columnSpan, rowSpan);
60
54
  }
61
55
  }
62
56
  registerNodeClass(GridChildNode);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ import * as Gtk from "@gtkx/ffi/gtk";
2
+ import { registerNodeClass } from "../registry.js";
3
+ import { isAttachable } from "./internal/predicates.js";
4
+ import { matchesAnyClass } from "./internal/utils.js";
5
+ import { SlotNode } from "./slot.js";
6
+ import { WidgetNode } from "./widget.js";
7
+ class GridNode extends WidgetNode {
8
+ static priority = 0;
9
+ static matches(_type, containerOrClass) {
10
+ return matchesAnyClass([Gtk.Grid], containerOrClass);
11
+ }
12
+ isGridChild(child) {
13
+ return child.typeName === "GridChild";
14
+ }
15
+ appendChild(child) {
16
+ if (child instanceof SlotNode) {
17
+ super.appendChild(child);
18
+ return;
19
+ }
20
+ if (isAttachable(child) && this.isGridChild(child)) {
21
+ child.attachTo(this);
22
+ return;
23
+ }
24
+ throw new Error(`Cannot append '${child.typeName}' to 'Grid': expected x.GridChild`);
25
+ }
26
+ insertBefore(child, _before) {
27
+ this.appendChild(child);
28
+ }
29
+ removeChild(child) {
30
+ if (child instanceof SlotNode) {
31
+ super.removeChild(child);
32
+ return;
33
+ }
34
+ if (isAttachable(child) && this.isGridChild(child)) {
35
+ child.detachFrom(this);
36
+ return;
37
+ }
38
+ throw new Error(`Cannot remove '${child.typeName}' from 'Grid': expected x.GridChild`);
39
+ }
40
+ }
41
+ registerNodeClass(GridNode);
@@ -1,17 +1,20 @@
1
- import "./action-row-child.js";
2
1
  import "./action-row.js";
2
+ import "./adjustable.js";
3
+ import "./animation/index.js";
4
+ import "./alert-dialog-response.js";
3
5
  import "./application.js";
4
6
  import "./autowrapped.js";
5
- import "./calendar-mark.js";
6
7
  import "./calendar.js";
8
+ import "./color-dialog-button.js";
7
9
  import "./column-view-column.js";
8
10
  import "./column-view.js";
11
+ import "./dialog.js";
9
12
  import "./drawing-area.js";
10
- import "./expander-row-child.js";
11
13
  import "./expander-row.js";
12
14
  import "./fixed-child.js";
15
+ import "./font-dialog-button.js";
16
+ import "./grid.js";
13
17
  import "./grid-child.js";
14
- import "./level-bar-offset.js";
15
18
  import "./level-bar.js";
16
19
  import "./list-item.js";
17
20
  import "./list-view.js";
@@ -22,23 +25,25 @@ import "./notebook-page-tab.js";
22
25
  import "./notebook-page.js";
23
26
  import "./notebook.js";
24
27
  import "./overlay-child.js";
25
- import "./pack-child.js";
26
28
  import "./pack.js";
27
29
  import "./popover-menu.js";
28
- import "./adjustment.js";
29
- import "./scale-mark.js";
30
30
  import "./scale.js";
31
31
  import "./scrolled-window.js";
32
+ import "./search-bar.js";
32
33
  import "./shortcut-controller.js";
33
34
  import "./shortcut.js";
35
+ import "./event-controller.js";
34
36
  import "./simple-list-item.js";
35
37
  import "./simple-list-view.js";
36
38
  import "./slot.js";
37
- import "./source-buffer.js";
38
39
  import "./source-view.js";
39
40
  import "./stack-page.js";
40
41
  import "./stack.js";
41
- import "./text-buffer.js";
42
+ import "./text-anchor.js";
43
+ import "./text-content.js";
44
+ import "./text-paintable.js";
45
+ import "./text-segment.js";
46
+ import "./text-tag.js";
42
47
  import "./text-view.js";
43
48
  import "./toggle.js";
44
49
  import "./toggle-group.js";
@@ -46,5 +51,8 @@ import "./toolbar-child.js";
46
51
  import "./tree-list-item.js";
47
52
  import "./tree-list-view.js";
48
53
  import "./virtual.js";
54
+ import "./action-row-child.js";
55
+ import "./expander-row-child.js";
56
+ import "./pack-child.js";
49
57
  import "./widget.js";
50
58
  import "./window.js";
@@ -1,17 +1,20 @@
1
- import "./action-row-child.js";
2
1
  import "./action-row.js";
2
+ import "./adjustable.js";
3
+ import "./animation/index.js";
4
+ import "./alert-dialog-response.js";
3
5
  import "./application.js";
4
6
  import "./autowrapped.js";
5
- import "./calendar-mark.js";
6
7
  import "./calendar.js";
8
+ import "./color-dialog-button.js";
7
9
  import "./column-view-column.js";
8
10
  import "./column-view.js";
11
+ import "./dialog.js";
9
12
  import "./drawing-area.js";
10
- import "./expander-row-child.js";
11
13
  import "./expander-row.js";
12
14
  import "./fixed-child.js";
15
+ import "./font-dialog-button.js";
16
+ import "./grid.js";
13
17
  import "./grid-child.js";
14
- import "./level-bar-offset.js";
15
18
  import "./level-bar.js";
16
19
  import "./list-item.js";
17
20
  import "./list-view.js";
@@ -22,23 +25,25 @@ import "./notebook-page-tab.js";
22
25
  import "./notebook-page.js";
23
26
  import "./notebook.js";
24
27
  import "./overlay-child.js";
25
- import "./pack-child.js";
26
28
  import "./pack.js";
27
29
  import "./popover-menu.js";
28
- import "./adjustment.js";
29
- import "./scale-mark.js";
30
30
  import "./scale.js";
31
31
  import "./scrolled-window.js";
32
+ import "./search-bar.js";
32
33
  import "./shortcut-controller.js";
33
34
  import "./shortcut.js";
35
+ import "./event-controller.js";
34
36
  import "./simple-list-item.js";
35
37
  import "./simple-list-view.js";
36
38
  import "./slot.js";
37
- import "./source-buffer.js";
38
39
  import "./source-view.js";
39
40
  import "./stack-page.js";
40
41
  import "./stack.js";
41
- import "./text-buffer.js";
42
+ import "./text-anchor.js";
43
+ import "./text-content.js";
44
+ import "./text-paintable.js";
45
+ import "./text-segment.js";
46
+ import "./text-tag.js";
42
47
  import "./text-view.js";
43
48
  import "./toggle.js";
44
49
  import "./toggle-group.js";
@@ -46,5 +51,8 @@ import "./toolbar-child.js";
46
51
  import "./tree-list-item.js";
47
52
  import "./tree-list-view.js";
48
53
  import "./virtual.js";
54
+ import "./action-row-child.js";
55
+ import "./expander-row-child.js";
56
+ import "./pack-child.js";
49
57
  import "./widget.js";
50
58
  import "./window.js";
@@ -0,0 +1,29 @@
1
+ import * as Gtk from "@gtkx/ffi/gtk";
2
+ import type { ReactNode } from "react";
3
+ import type Reconciler from "react-reconciler";
4
+ import type { SignalStore } from "./signal-store.js";
5
+ export declare abstract class BaseItemRenderer<TStore = unknown> {
6
+ protected factory: Gtk.SignalListItemFactory;
7
+ protected fiberRoots: Map<number, any>;
8
+ protected tornDown: Set<number>;
9
+ protected estimatedItemHeight: number | null;
10
+ private store;
11
+ protected signalStore: SignalStore;
12
+ protected abstract getStoreTypeName(): string;
13
+ constructor(signalStore: SignalStore);
14
+ getFactory(): Gtk.SignalListItemFactory;
15
+ setEstimatedItemHeight(height: number | null): void;
16
+ setStore(store: TStore | null): void;
17
+ protected getStore(): TStore;
18
+ dispose(): void;
19
+ protected abstract renderItem(ptr: number): ReactNode;
20
+ protected abstract getItemFromListItem(listItem: Gtk.ListItem): unknown;
21
+ protected abstract onSetup(listItem: Gtk.ListItem, ptr: number): Gtk.Widget;
22
+ protected abstract onBind(listItem: Gtk.ListItem, ptr: number, fiberRoot: Reconciler.FiberRoot): void;
23
+ protected abstract onUnbind(listItem: Gtk.ListItem): void;
24
+ protected abstract onTeardown(listItem: Gtk.ListItem, ptr: number): void;
25
+ protected onSetupComplete(_ptr: number): void;
26
+ protected createBox(): Gtk.Box;
27
+ protected clearBoxSizeRequest(box: Gtk.Widget): void;
28
+ private initializeFactory;
29
+ }
@@ -0,0 +1,88 @@
1
+ import { getNativeId } from "@gtkx/ffi";
2
+ import * as Gtk from "@gtkx/ffi/gtk";
3
+ import { createFiberRoot } from "../../fiber-root.js";
4
+ import { reconciler } from "../../reconciler.js";
5
+ export class BaseItemRenderer {
6
+ factory;
7
+ fiberRoots = new Map();
8
+ tornDown = new Set();
9
+ estimatedItemHeight = null;
10
+ store = null;
11
+ signalStore;
12
+ constructor(signalStore) {
13
+ this.signalStore = signalStore;
14
+ this.factory = new Gtk.SignalListItemFactory();
15
+ this.initializeFactory();
16
+ }
17
+ getFactory() {
18
+ return this.factory;
19
+ }
20
+ setEstimatedItemHeight(height) {
21
+ this.estimatedItemHeight = height;
22
+ }
23
+ setStore(store) {
24
+ this.store = store;
25
+ }
26
+ getStore() {
27
+ if (!this.store) {
28
+ throw new Error(`Expected ${this.getStoreTypeName()} to be set on ${this.constructor.name}`);
29
+ }
30
+ return this.store;
31
+ }
32
+ dispose() {
33
+ this.signalStore.clear(this);
34
+ this.fiberRoots.clear();
35
+ this.tornDown.clear();
36
+ }
37
+ onSetupComplete(_ptr) { }
38
+ createBox() {
39
+ const box = new Gtk.Box(Gtk.Orientation.HORIZONTAL);
40
+ box.setValign(Gtk.Align.CENTER);
41
+ if (this.estimatedItemHeight !== null) {
42
+ box.setSizeRequest(-1, this.estimatedItemHeight);
43
+ }
44
+ return box;
45
+ }
46
+ clearBoxSizeRequest(box) {
47
+ if (box instanceof Gtk.Box) {
48
+ box.setSizeRequest(-1, -1);
49
+ }
50
+ }
51
+ initializeFactory() {
52
+ this.signalStore.set(this, this.factory, "setup", (listItem) => {
53
+ const ptr = getNativeId(listItem.handle);
54
+ const container = this.onSetup(listItem, ptr);
55
+ const fiberRoot = createFiberRoot(container);
56
+ this.fiberRoots.set(ptr, fiberRoot);
57
+ const element = this.renderItem(ptr);
58
+ reconciler.getInstance().updateContainer(element, fiberRoot, null, () => {
59
+ if (this.tornDown.has(ptr))
60
+ return;
61
+ this.onSetupComplete(ptr);
62
+ });
63
+ });
64
+ this.signalStore.set(this, this.factory, "bind", (listItem) => {
65
+ const ptr = getNativeId(listItem.handle);
66
+ const fiberRoot = this.fiberRoots.get(ptr);
67
+ if (!fiberRoot)
68
+ return;
69
+ this.onBind(listItem, ptr, fiberRoot);
70
+ });
71
+ this.signalStore.set(this, this.factory, "unbind", (listItem) => {
72
+ this.onUnbind(listItem);
73
+ });
74
+ this.signalStore.set(this, this.factory, "teardown", (listItem) => {
75
+ const ptr = getNativeId(listItem.handle);
76
+ const fiberRoot = this.fiberRoots.get(ptr);
77
+ if (fiberRoot) {
78
+ this.tornDown.add(ptr);
79
+ this.onTeardown(listItem, ptr);
80
+ reconciler.getInstance().updateContainer(null, fiberRoot, null, () => { });
81
+ queueMicrotask(() => {
82
+ this.fiberRoots.delete(ptr);
83
+ this.tornDown.delete(ptr);
84
+ });
85
+ }
86
+ });
87
+ }
88
+ }
@@ -0,0 +1,9 @@
1
+ export declare abstract class BaseStore<TItem = unknown> {
2
+ protected items: Map<string, TItem>;
3
+ private syncAction;
4
+ constructor();
5
+ getItem(id: string): TItem | undefined;
6
+ updateItem(id: string, item: TItem): void;
7
+ protected scheduleSync(): void;
8
+ protected abstract sync(): void;
9
+ }
@@ -0,0 +1,20 @@
1
+ import { CommitPriority } from "../../scheduler.js";
2
+ import { DeferredAction } from "./deferred-action.js";
3
+ export class BaseStore {
4
+ items = new Map();
5
+ syncAction;
6
+ constructor() {
7
+ this.syncAction = new DeferredAction(() => this.sync(), CommitPriority.LOW);
8
+ }
9
+ getItem(id) {
10
+ return this.items.get(id);
11
+ }
12
+ updateItem(id, item) {
13
+ if (this.items.has(id)) {
14
+ this.items.set(id, item);
15
+ }
16
+ }
17
+ scheduleSync() {
18
+ this.syncAction.schedule();
19
+ }
20
+ }
@@ -0,0 +1,26 @@
1
+ import type * as Gtk from "@gtkx/ffi/gtk";
2
+ type AttachmentStrategy = {
3
+ type: "appendable";
4
+ container: Gtk.Widget & {
5
+ append(child: Gtk.Widget): void;
6
+ };
7
+ } | {
8
+ type: "addable";
9
+ container: Gtk.Widget & {
10
+ add(child: Gtk.Widget): void;
11
+ };
12
+ } | {
13
+ type: "content";
14
+ container: Gtk.Widget & {
15
+ setContent(content: Gtk.Widget | null): void;
16
+ };
17
+ } | {
18
+ type: "singleChild";
19
+ container: Gtk.Widget & {
20
+ setChild(child: Gtk.Widget | null): void;
21
+ };
22
+ };
23
+ export declare const getAttachmentStrategy: (container: Gtk.Widget) => AttachmentStrategy | null;
24
+ export declare const attachChild: (child: Gtk.Widget, strategy: AttachmentStrategy) => void;
25
+ export declare const detachChild: (child: Gtk.Widget, strategy: AttachmentStrategy) => void;
26
+ export {};