@gtkx/react 0.1.11
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/LICENSE +373 -0
- package/README.md +390 -0
- package/dist/codegen/jsx-generator.d.ts +37 -0
- package/dist/codegen/jsx-generator.js +554 -0
- package/dist/factory.d.ts +3 -0
- package/dist/factory.js +59 -0
- package/dist/generated/jsx.d.ts +1598 -0
- package/dist/generated/jsx.js +264 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +14 -0
- package/dist/node.d.ts +13 -0
- package/dist/node.js +1 -0
- package/dist/nodes/action-bar.d.ts +27 -0
- package/dist/nodes/action-bar.js +88 -0
- package/dist/nodes/dialog.d.ts +19 -0
- package/dist/nodes/dialog.js +87 -0
- package/dist/nodes/dropdown.d.ts +41 -0
- package/dist/nodes/dropdown.js +163 -0
- package/dist/nodes/grid.d.ts +41 -0
- package/dist/nodes/grid.js +140 -0
- package/dist/nodes/list.d.ts +46 -0
- package/dist/nodes/list.js +165 -0
- package/dist/nodes/notebook.d.ts +25 -0
- package/dist/nodes/notebook.js +88 -0
- package/dist/nodes/overlay.d.ts +29 -0
- package/dist/nodes/overlay.js +109 -0
- package/dist/nodes/slot.d.ts +17 -0
- package/dist/nodes/slot.js +55 -0
- package/dist/nodes/text.d.ts +16 -0
- package/dist/nodes/text.js +31 -0
- package/dist/nodes/widget.d.ts +19 -0
- package/dist/nodes/widget.js +136 -0
- package/dist/portal.d.ts +3 -0
- package/dist/portal.js +11 -0
- package/dist/reconciler.d.ts +20 -0
- package/dist/reconciler.js +111 -0
- package/dist/render.d.ts +5 -0
- package/dist/render.js +12 -0
- package/dist/signal-utils.d.ts +4 -0
- package/dist/signal-utils.js +7 -0
- package/dist/types.d.ts +13 -0
- package/dist/types.js +1 -0
- package/dist/widget-capabilities.d.ts +46 -0
- package/dist/widget-capabilities.js +32 -0
- package/package.json +52 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
export const CONSTRUCTOR_PARAMS = {
|
|
2
|
+
AppChooserButton: [{ name: "contentType", hasDefault: false }],
|
|
3
|
+
AppChooserDialog: [
|
|
4
|
+
{ name: "parent", hasDefault: true },
|
|
5
|
+
{ name: "flags", hasDefault: false },
|
|
6
|
+
{ name: "file", hasDefault: false },
|
|
7
|
+
],
|
|
8
|
+
AppChooserWidget: [{ name: "contentType", hasDefault: false }],
|
|
9
|
+
ApplicationWindow: [{ name: "application", hasDefault: false }],
|
|
10
|
+
AspectFrame: [
|
|
11
|
+
{ name: "xalign", hasDefault: false },
|
|
12
|
+
{ name: "yalign", hasDefault: false },
|
|
13
|
+
{ name: "ratio", hasDefault: false },
|
|
14
|
+
{ name: "obeyChild", hasDefault: false },
|
|
15
|
+
],
|
|
16
|
+
Box: [
|
|
17
|
+
{ name: "orientation", hasDefault: false },
|
|
18
|
+
{ name: "spacing", hasDefault: false },
|
|
19
|
+
],
|
|
20
|
+
ColorChooserDialog: [
|
|
21
|
+
{ name: "title", hasDefault: true },
|
|
22
|
+
{ name: "parent", hasDefault: true },
|
|
23
|
+
],
|
|
24
|
+
ColorDialogButton: [{ name: "dialog", hasDefault: true }],
|
|
25
|
+
ColumnView: [{ name: "model", hasDefault: true }],
|
|
26
|
+
DropDown: [
|
|
27
|
+
{ name: "model", hasDefault: true },
|
|
28
|
+
{ name: "expression", hasDefault: true },
|
|
29
|
+
],
|
|
30
|
+
EditableLabel: [{ name: "str", hasDefault: false }],
|
|
31
|
+
Expander: [{ name: "label", hasDefault: true }],
|
|
32
|
+
FileChooserWidget: [{ name: "action", hasDefault: false }],
|
|
33
|
+
FontChooserDialog: [
|
|
34
|
+
{ name: "title", hasDefault: true },
|
|
35
|
+
{ name: "parent", hasDefault: true },
|
|
36
|
+
],
|
|
37
|
+
FontDialogButton: [{ name: "dialog", hasDefault: true }],
|
|
38
|
+
Frame: [{ name: "label", hasDefault: true }],
|
|
39
|
+
GraphicsOffload: [{ name: "child", hasDefault: true }],
|
|
40
|
+
GridView: [
|
|
41
|
+
{ name: "model", hasDefault: true },
|
|
42
|
+
{ name: "factory", hasDefault: true },
|
|
43
|
+
],
|
|
44
|
+
Inscription: [{ name: "text", hasDefault: true }],
|
|
45
|
+
Label: [{ name: "str", hasDefault: true }],
|
|
46
|
+
LinkButton: [{ name: "uri", hasDefault: false }],
|
|
47
|
+
ListView: [
|
|
48
|
+
{ name: "model", hasDefault: true },
|
|
49
|
+
{ name: "factory", hasDefault: true },
|
|
50
|
+
],
|
|
51
|
+
LockButton: [{ name: "permission", hasDefault: true }],
|
|
52
|
+
MediaControls: [{ name: "stream", hasDefault: true }],
|
|
53
|
+
PageSetupUnixDialog: [
|
|
54
|
+
{ name: "title", hasDefault: true },
|
|
55
|
+
{ name: "parent", hasDefault: true },
|
|
56
|
+
],
|
|
57
|
+
Paned: [{ name: "orientation", hasDefault: false }],
|
|
58
|
+
PrintUnixDialog: [
|
|
59
|
+
{ name: "title", hasDefault: true },
|
|
60
|
+
{ name: "parent", hasDefault: true },
|
|
61
|
+
],
|
|
62
|
+
Scale: [
|
|
63
|
+
{ name: "orientation", hasDefault: false },
|
|
64
|
+
{ name: "adjustment", hasDefault: true },
|
|
65
|
+
],
|
|
66
|
+
ScaleButton: [
|
|
67
|
+
{ name: "min", hasDefault: false },
|
|
68
|
+
{ name: "max", hasDefault: false },
|
|
69
|
+
{ name: "step", hasDefault: false },
|
|
70
|
+
{ name: "icons", hasDefault: true },
|
|
71
|
+
],
|
|
72
|
+
Scrollbar: [
|
|
73
|
+
{ name: "orientation", hasDefault: false },
|
|
74
|
+
{ name: "adjustment", hasDefault: true },
|
|
75
|
+
],
|
|
76
|
+
Separator: [{ name: "orientation", hasDefault: false }],
|
|
77
|
+
ShortcutLabel: [{ name: "accelerator", hasDefault: false }],
|
|
78
|
+
SpinButton: [
|
|
79
|
+
{ name: "adjustment", hasDefault: true },
|
|
80
|
+
{ name: "climbRate", hasDefault: false },
|
|
81
|
+
{ name: "digits", hasDefault: false },
|
|
82
|
+
],
|
|
83
|
+
Viewport: [
|
|
84
|
+
{ name: "hadjustment", hasDefault: true },
|
|
85
|
+
{ name: "vadjustment", hasDefault: true },
|
|
86
|
+
],
|
|
87
|
+
WindowControls: [{ name: "side", hasDefault: false }],
|
|
88
|
+
};
|
|
89
|
+
export const Widget = "Widget";
|
|
90
|
+
export const Window = {
|
|
91
|
+
Root: "Window.Root",
|
|
92
|
+
Child: "Window.Child",
|
|
93
|
+
DefaultWidget: "Window.DefaultWidget",
|
|
94
|
+
FocusWidget: "Window.FocusWidget",
|
|
95
|
+
Titlebar: "Window.Titlebar",
|
|
96
|
+
TransientFor: "Window.TransientFor",
|
|
97
|
+
};
|
|
98
|
+
export const AboutDialog = "AboutDialog";
|
|
99
|
+
export const ActionBar = "ActionBar";
|
|
100
|
+
export const AppChooserButton = "AppChooserButton";
|
|
101
|
+
export const AppChooserDialog = "AppChooserDialog";
|
|
102
|
+
export const AppChooserWidget = "AppChooserWidget";
|
|
103
|
+
export const ApplicationWindow = "ApplicationWindow";
|
|
104
|
+
export const AspectFrame = "AspectFrame";
|
|
105
|
+
export const Assistant = "Assistant";
|
|
106
|
+
export const Box = "Box";
|
|
107
|
+
export const Button = "Button";
|
|
108
|
+
export const Calendar = "Calendar";
|
|
109
|
+
export const CellView = "CellView";
|
|
110
|
+
export const CenterBox = {
|
|
111
|
+
Root: "CenterBox.Root",
|
|
112
|
+
CenterWidget: "CenterBox.CenterWidget",
|
|
113
|
+
EndWidget: "CenterBox.EndWidget",
|
|
114
|
+
StartWidget: "CenterBox.StartWidget",
|
|
115
|
+
};
|
|
116
|
+
export const CheckButton = {
|
|
117
|
+
Root: "CheckButton.Root",
|
|
118
|
+
Child: "CheckButton.Child",
|
|
119
|
+
Group: "CheckButton.Group",
|
|
120
|
+
};
|
|
121
|
+
export const ColorButton = "ColorButton";
|
|
122
|
+
export const ColorChooserDialog = "ColorChooserDialog";
|
|
123
|
+
export const ColorChooserWidget = "ColorChooserWidget";
|
|
124
|
+
export const ColorDialogButton = "ColorDialogButton";
|
|
125
|
+
export const ColumnView = {
|
|
126
|
+
Root: "ColumnView.Root",
|
|
127
|
+
Item: "ColumnView.Item",
|
|
128
|
+
};
|
|
129
|
+
export const ComboBox = "ComboBox";
|
|
130
|
+
export const ComboBoxText = "ComboBoxText";
|
|
131
|
+
export const Dialog = "Dialog";
|
|
132
|
+
export const DragIcon = "DragIcon";
|
|
133
|
+
export const DrawingArea = "DrawingArea";
|
|
134
|
+
export const DropDown = {
|
|
135
|
+
Root: "DropDown.Root",
|
|
136
|
+
Item: "DropDown.Item",
|
|
137
|
+
};
|
|
138
|
+
export const EditableLabel = "EditableLabel";
|
|
139
|
+
export const EmojiChooser = "EmojiChooser";
|
|
140
|
+
export const Entry = "Entry";
|
|
141
|
+
export const Expander = {
|
|
142
|
+
Root: "Expander.Root",
|
|
143
|
+
Child: "Expander.Child",
|
|
144
|
+
LabelWidget: "Expander.LabelWidget",
|
|
145
|
+
};
|
|
146
|
+
export const FileChooserDialog = "FileChooserDialog";
|
|
147
|
+
export const FileChooserWidget = "FileChooserWidget";
|
|
148
|
+
export const Fixed = "Fixed";
|
|
149
|
+
export const FlowBox = "FlowBox";
|
|
150
|
+
export const FlowBoxChild = "FlowBoxChild";
|
|
151
|
+
export const FontButton = "FontButton";
|
|
152
|
+
export const FontChooserDialog = "FontChooserDialog";
|
|
153
|
+
export const FontChooserWidget = "FontChooserWidget";
|
|
154
|
+
export const FontDialogButton = "FontDialogButton";
|
|
155
|
+
export const Frame = {
|
|
156
|
+
Root: "Frame.Root",
|
|
157
|
+
Child: "Frame.Child",
|
|
158
|
+
LabelWidget: "Frame.LabelWidget",
|
|
159
|
+
};
|
|
160
|
+
export const GLArea = "GLArea";
|
|
161
|
+
export const GraphicsOffload = "GraphicsOffload";
|
|
162
|
+
export const Grid = {
|
|
163
|
+
Root: "Grid.Root",
|
|
164
|
+
Child: "Grid.Child",
|
|
165
|
+
};
|
|
166
|
+
export const GridView = {
|
|
167
|
+
Root: "GridView.Root",
|
|
168
|
+
Item: "GridView.Item",
|
|
169
|
+
};
|
|
170
|
+
export const HeaderBar = {
|
|
171
|
+
Root: "HeaderBar.Root",
|
|
172
|
+
TitleWidget: "HeaderBar.TitleWidget",
|
|
173
|
+
};
|
|
174
|
+
export const IconView = "IconView";
|
|
175
|
+
export const Image = "Image";
|
|
176
|
+
export const InfoBar = "InfoBar";
|
|
177
|
+
export const Inscription = "Inscription";
|
|
178
|
+
export const Label = {
|
|
179
|
+
Root: "Label.Root",
|
|
180
|
+
MnemonicWidget: "Label.MnemonicWidget",
|
|
181
|
+
};
|
|
182
|
+
export const LevelBar = "LevelBar";
|
|
183
|
+
export const LinkButton = "LinkButton";
|
|
184
|
+
export const ListBase = "ListBase";
|
|
185
|
+
export const ListBox = "ListBox";
|
|
186
|
+
export const ListBoxRow = "ListBoxRow";
|
|
187
|
+
export const ListView = {
|
|
188
|
+
Root: "ListView.Root",
|
|
189
|
+
Item: "ListView.Item",
|
|
190
|
+
};
|
|
191
|
+
export const LockButton = "LockButton";
|
|
192
|
+
export const MediaControls = "MediaControls";
|
|
193
|
+
export const MenuButton = {
|
|
194
|
+
Root: "MenuButton.Root",
|
|
195
|
+
Child: "MenuButton.Child",
|
|
196
|
+
Popover: "MenuButton.Popover",
|
|
197
|
+
};
|
|
198
|
+
export const MessageDialog = "MessageDialog";
|
|
199
|
+
export const Notebook = "Notebook";
|
|
200
|
+
export const Overlay = "Overlay";
|
|
201
|
+
export const PageSetupUnixDialog = "PageSetupUnixDialog";
|
|
202
|
+
export const Paned = {
|
|
203
|
+
Root: "Paned.Root",
|
|
204
|
+
EndChild: "Paned.EndChild",
|
|
205
|
+
StartChild: "Paned.StartChild",
|
|
206
|
+
};
|
|
207
|
+
export const PasswordEntry = "PasswordEntry";
|
|
208
|
+
export const Picture = "Picture";
|
|
209
|
+
export const Popover = {
|
|
210
|
+
Root: "Popover.Root",
|
|
211
|
+
Child: "Popover.Child",
|
|
212
|
+
DefaultWidget: "Popover.DefaultWidget",
|
|
213
|
+
};
|
|
214
|
+
export const PopoverMenu = "PopoverMenu";
|
|
215
|
+
export const PopoverMenuBar = "PopoverMenuBar";
|
|
216
|
+
export const PrintUnixDialog = "PrintUnixDialog";
|
|
217
|
+
export const ProgressBar = "ProgressBar";
|
|
218
|
+
export const Range = "Range";
|
|
219
|
+
export const Revealer = "Revealer";
|
|
220
|
+
export const Scale = "Scale";
|
|
221
|
+
export const ScaleButton = "ScaleButton";
|
|
222
|
+
export const Scrollbar = "Scrollbar";
|
|
223
|
+
export const ScrolledWindow = "ScrolledWindow";
|
|
224
|
+
export const SearchBar = {
|
|
225
|
+
Root: "SearchBar.Root",
|
|
226
|
+
Child: "SearchBar.Child",
|
|
227
|
+
KeyCaptureWidget: "SearchBar.KeyCaptureWidget",
|
|
228
|
+
};
|
|
229
|
+
export const SearchEntry = "SearchEntry";
|
|
230
|
+
export const Separator = "Separator";
|
|
231
|
+
export const ShortcutLabel = "ShortcutLabel";
|
|
232
|
+
export const ShortcutsGroup = "ShortcutsGroup";
|
|
233
|
+
export const ShortcutsSection = "ShortcutsSection";
|
|
234
|
+
export const ShortcutsShortcut = "ShortcutsShortcut";
|
|
235
|
+
export const ShortcutsWindow = "ShortcutsWindow";
|
|
236
|
+
export const SpinButton = "SpinButton";
|
|
237
|
+
export const Spinner = "Spinner";
|
|
238
|
+
export const Stack = {
|
|
239
|
+
Root: "Stack.Root",
|
|
240
|
+
VisibleChild: "Stack.VisibleChild",
|
|
241
|
+
};
|
|
242
|
+
export const StackSidebar = {
|
|
243
|
+
Root: "StackSidebar.Root",
|
|
244
|
+
Stack: "StackSidebar.Stack",
|
|
245
|
+
};
|
|
246
|
+
export const StackSwitcher = {
|
|
247
|
+
Root: "StackSwitcher.Root",
|
|
248
|
+
Stack: "StackSwitcher.Stack",
|
|
249
|
+
};
|
|
250
|
+
export const Statusbar = "Statusbar";
|
|
251
|
+
export const Switch = "Switch";
|
|
252
|
+
export const Text = "Text";
|
|
253
|
+
export const TextView = "TextView";
|
|
254
|
+
export const ToggleButton = {
|
|
255
|
+
Root: "ToggleButton.Root",
|
|
256
|
+
Group: "ToggleButton.Group",
|
|
257
|
+
};
|
|
258
|
+
export const TreeExpander = "TreeExpander";
|
|
259
|
+
export const TreeView = "TreeView";
|
|
260
|
+
export const Video = "Video";
|
|
261
|
+
export const Viewport = "Viewport";
|
|
262
|
+
export const VolumeButton = "VolumeButton";
|
|
263
|
+
export const WindowControls = "WindowControls";
|
|
264
|
+
export const WindowHandle = "WindowHandle";
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { createRef } from "@gtkx/ffi";
|
|
2
|
+
export * from "./generated/jsx.js";
|
|
3
|
+
export { createPortal } from "./portal.js";
|
|
4
|
+
export { render } from "./render.js";
|
|
5
|
+
import { stop } from "@gtkx/ffi";
|
|
6
|
+
import { disposeAllInstances, reconciler } from "./reconciler.js";
|
|
7
|
+
import { container } from "./render.js";
|
|
8
|
+
export const quit = () => {
|
|
9
|
+
reconciler.updateContainer(null, container, null, () => {
|
|
10
|
+
disposeAllInstances();
|
|
11
|
+
stop();
|
|
12
|
+
});
|
|
13
|
+
return false;
|
|
14
|
+
};
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { Props } from "./factory.js";
|
|
3
|
+
export interface Node<W extends Gtk.Widget = Gtk.Widget> {
|
|
4
|
+
getWidget?(): W;
|
|
5
|
+
appendChild(child: Node): void;
|
|
6
|
+
removeChild(child: Node): void;
|
|
7
|
+
insertBefore(child: Node, before: Node): void;
|
|
8
|
+
updateProps(oldProps: Props, newProps: Props): void;
|
|
9
|
+
mount(): void;
|
|
10
|
+
attachToParent(parent: Node): void;
|
|
11
|
+
detachFromParent(parent: Node): void;
|
|
12
|
+
dispose?(): void;
|
|
13
|
+
}
|
package/dist/node.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { Props } from "../factory.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
interface ActionBarWidget extends Gtk.Widget {
|
|
5
|
+
packStart(child: unknown): void;
|
|
6
|
+
remove(child: unknown): void;
|
|
7
|
+
setRevealed(revealed: boolean): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class ActionBarNode implements Node<ActionBarWidget> {
|
|
10
|
+
static needsWidget: boolean;
|
|
11
|
+
static matches(type: string, widget: Gtk.Widget | null): widget is ActionBarWidget;
|
|
12
|
+
private widget;
|
|
13
|
+
private signalHandlers;
|
|
14
|
+
constructor(_type: string, widget: Gtk.Widget, _props: Props);
|
|
15
|
+
getWidget(): ActionBarWidget;
|
|
16
|
+
appendChild(child: Node): void;
|
|
17
|
+
removeChild(child: Node): void;
|
|
18
|
+
insertBefore(child: Node, _before: Node): void;
|
|
19
|
+
attachToParent(parent: Node): void;
|
|
20
|
+
detachFromParent(parent: Node): void;
|
|
21
|
+
attachChild(childWidget: Gtk.Widget): void;
|
|
22
|
+
detachChild(childWidget: Gtk.Widget): void;
|
|
23
|
+
updateProps(oldProps: Props, newProps: Props): void;
|
|
24
|
+
mount(): void;
|
|
25
|
+
dispose(): void;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { appendChild, disconnectSignalHandlers, isConnectable, removeChild } from "../widget-capabilities.js";
|
|
2
|
+
const isActionBarWidget = (widget) => "packStart" in widget &&
|
|
3
|
+
typeof widget.packStart === "function" &&
|
|
4
|
+
"remove" in widget &&
|
|
5
|
+
typeof widget.remove === "function";
|
|
6
|
+
export class ActionBarNode {
|
|
7
|
+
static needsWidget = true;
|
|
8
|
+
static matches(type, widget) {
|
|
9
|
+
if (type !== "ActionBar" && type !== "ActionBar.Root")
|
|
10
|
+
return false;
|
|
11
|
+
return widget !== null && isActionBarWidget(widget);
|
|
12
|
+
}
|
|
13
|
+
widget;
|
|
14
|
+
signalHandlers = new Map();
|
|
15
|
+
constructor(_type, widget, _props) {
|
|
16
|
+
if (!isActionBarWidget(widget)) {
|
|
17
|
+
throw new Error("ActionBarNode requires an ActionBar widget");
|
|
18
|
+
}
|
|
19
|
+
this.widget = widget;
|
|
20
|
+
}
|
|
21
|
+
getWidget() {
|
|
22
|
+
return this.widget;
|
|
23
|
+
}
|
|
24
|
+
appendChild(child) {
|
|
25
|
+
child.attachToParent(this);
|
|
26
|
+
}
|
|
27
|
+
removeChild(child) {
|
|
28
|
+
child.detachFromParent(this);
|
|
29
|
+
}
|
|
30
|
+
insertBefore(child, _before) {
|
|
31
|
+
this.appendChild(child);
|
|
32
|
+
}
|
|
33
|
+
attachToParent(parent) {
|
|
34
|
+
const parentWidget = parent.getWidget?.();
|
|
35
|
+
if (parentWidget) {
|
|
36
|
+
appendChild(parentWidget, this.widget);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
detachFromParent(parent) {
|
|
40
|
+
const parentWidget = parent.getWidget?.();
|
|
41
|
+
if (parentWidget) {
|
|
42
|
+
removeChild(parentWidget, this.widget);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
attachChild(childWidget) {
|
|
46
|
+
this.widget.packStart(childWidget.ptr);
|
|
47
|
+
}
|
|
48
|
+
detachChild(childWidget) {
|
|
49
|
+
this.widget.remove(childWidget.ptr);
|
|
50
|
+
}
|
|
51
|
+
updateProps(oldProps, newProps) {
|
|
52
|
+
const consumedProps = new Set(["children"]);
|
|
53
|
+
const allKeys = new Set([...Object.keys(oldProps), ...Object.keys(newProps)]);
|
|
54
|
+
for (const key of allKeys) {
|
|
55
|
+
if (consumedProps.has(key))
|
|
56
|
+
continue;
|
|
57
|
+
const oldValue = oldProps[key];
|
|
58
|
+
const newValue = newProps[key];
|
|
59
|
+
if (oldValue === newValue)
|
|
60
|
+
continue;
|
|
61
|
+
if (key.startsWith("on")) {
|
|
62
|
+
const eventName = key
|
|
63
|
+
.slice(2)
|
|
64
|
+
.replace(/([A-Z])/g, "-$1")
|
|
65
|
+
.toLowerCase()
|
|
66
|
+
.replace(/^-/, "");
|
|
67
|
+
const oldHandlerId = this.signalHandlers.get(eventName);
|
|
68
|
+
if (oldHandlerId !== undefined && isConnectable(this.widget)) {
|
|
69
|
+
this.signalHandlers.delete(eventName);
|
|
70
|
+
}
|
|
71
|
+
if (typeof newValue === "function" && isConnectable(this.widget)) {
|
|
72
|
+
const handlerId = this.widget.connect(eventName, newValue);
|
|
73
|
+
this.signalHandlers.set(eventName, handlerId);
|
|
74
|
+
}
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const setterName = `set${key.charAt(0).toUpperCase()}${key.slice(1)}`;
|
|
78
|
+
const setter = this.widget[setterName];
|
|
79
|
+
if (typeof setter === "function") {
|
|
80
|
+
setter.call(this.widget, newValue);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
mount() { }
|
|
85
|
+
dispose() {
|
|
86
|
+
disconnectSignalHandlers(this.widget, this.signalHandlers);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { Props } from "../factory.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
export declare class DialogNode implements Node {
|
|
5
|
+
static needsWidget: boolean;
|
|
6
|
+
static matches(type: string, widget: Gtk.Widget | null): widget is Gtk.Widget;
|
|
7
|
+
private widget;
|
|
8
|
+
private signalHandlers;
|
|
9
|
+
constructor(_type: string, widget: Gtk.Widget, _props: Props);
|
|
10
|
+
getWidget(): Gtk.Widget;
|
|
11
|
+
appendChild(_child: Node): void;
|
|
12
|
+
removeChild(_child: Node): void;
|
|
13
|
+
insertBefore(_child: Node, _before: Node): void;
|
|
14
|
+
attachToParent(_parent: Node): void;
|
|
15
|
+
detachFromParent(_parent: Node): void;
|
|
16
|
+
updateProps(oldProps: Props, newProps: Props): void;
|
|
17
|
+
mount(): void;
|
|
18
|
+
dispose(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as GObject from "@gtkx/ffi/gobject";
|
|
2
|
+
import { getActiveWindow } from "../reconciler.js";
|
|
3
|
+
import { disconnectSignalHandlers, isConnectable } from "../widget-capabilities.js";
|
|
4
|
+
const DIALOG_TYPES = new Set([
|
|
5
|
+
"AboutDialog",
|
|
6
|
+
"Dialog",
|
|
7
|
+
"AppChooserDialog",
|
|
8
|
+
"ColorChooserDialog",
|
|
9
|
+
"FontChooserDialog",
|
|
10
|
+
"FileChooserDialog",
|
|
11
|
+
"MessageDialog",
|
|
12
|
+
"PageSetupUnixDialog",
|
|
13
|
+
"PrintUnixDialog",
|
|
14
|
+
"Assistant",
|
|
15
|
+
"ShortcutsWindow",
|
|
16
|
+
]);
|
|
17
|
+
const isDialog = (widget) => {
|
|
18
|
+
return "setTransientFor" in widget && "present" in widget;
|
|
19
|
+
};
|
|
20
|
+
export class DialogNode {
|
|
21
|
+
static needsWidget = true;
|
|
22
|
+
static matches(type, widget) {
|
|
23
|
+
const normalizedType = type.endsWith(".Root") ? type.slice(0, -5) : type;
|
|
24
|
+
return widget !== null && DIALOG_TYPES.has(normalizedType);
|
|
25
|
+
}
|
|
26
|
+
widget;
|
|
27
|
+
signalHandlers = new Map();
|
|
28
|
+
constructor(_type, widget, _props) {
|
|
29
|
+
this.widget = widget;
|
|
30
|
+
}
|
|
31
|
+
getWidget() {
|
|
32
|
+
return this.widget;
|
|
33
|
+
}
|
|
34
|
+
appendChild(_child) { }
|
|
35
|
+
removeChild(_child) { }
|
|
36
|
+
insertBefore(_child, _before) { }
|
|
37
|
+
attachToParent(_parent) { }
|
|
38
|
+
detachFromParent(_parent) { }
|
|
39
|
+
updateProps(oldProps, newProps) {
|
|
40
|
+
const consumedProps = new Set(["children"]);
|
|
41
|
+
const allKeys = new Set([...Object.keys(oldProps), ...Object.keys(newProps)]);
|
|
42
|
+
for (const key of allKeys) {
|
|
43
|
+
if (consumedProps.has(key))
|
|
44
|
+
continue;
|
|
45
|
+
const oldValue = oldProps[key];
|
|
46
|
+
const newValue = newProps[key];
|
|
47
|
+
if (oldValue === newValue)
|
|
48
|
+
continue;
|
|
49
|
+
if (key.startsWith("on")) {
|
|
50
|
+
const eventName = key
|
|
51
|
+
.slice(2)
|
|
52
|
+
.replace(/([A-Z])/g, "-$1")
|
|
53
|
+
.toLowerCase()
|
|
54
|
+
.replace(/^-/, "");
|
|
55
|
+
const oldHandlerId = this.signalHandlers.get(eventName);
|
|
56
|
+
if (oldHandlerId !== undefined) {
|
|
57
|
+
GObject.signalHandlerDisconnect(this.widget, oldHandlerId);
|
|
58
|
+
this.signalHandlers.delete(eventName);
|
|
59
|
+
}
|
|
60
|
+
if (typeof newValue === "function" && isConnectable(this.widget)) {
|
|
61
|
+
const handlerId = this.widget.connect(eventName, newValue);
|
|
62
|
+
this.signalHandlers.set(eventName, handlerId);
|
|
63
|
+
}
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (newValue === undefined)
|
|
67
|
+
continue;
|
|
68
|
+
const setterName = `set${key.charAt(0).toUpperCase()}${key.slice(1)}`;
|
|
69
|
+
const setter = this.widget[setterName];
|
|
70
|
+
if (typeof setter === "function") {
|
|
71
|
+
setter.call(this.widget, newValue);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
mount() {
|
|
76
|
+
if (isDialog(this.widget)) {
|
|
77
|
+
const activeWindow = getActiveWindow();
|
|
78
|
+
if (activeWindow) {
|
|
79
|
+
this.widget.setTransientFor(activeWindow);
|
|
80
|
+
}
|
|
81
|
+
this.widget.present();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
dispose() {
|
|
85
|
+
disconnectSignalHandlers(this.widget, this.signalHandlers);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
|
+
import type { Props } from "../factory.js";
|
|
3
|
+
import type { Node } from "../node.js";
|
|
4
|
+
import { type Connectable, type ModelSettable, type Selectable } from "../widget-capabilities.js";
|
|
5
|
+
type ItemLabelFn<T> = (item: T) => string;
|
|
6
|
+
interface DropDownWidget extends Gtk.Widget, ModelSettable, Selectable, Connectable {
|
|
7
|
+
}
|
|
8
|
+
export declare class DropDownNode implements Node<DropDownWidget> {
|
|
9
|
+
static needsWidget: boolean;
|
|
10
|
+
static matches(type: string, widget: Gtk.Widget | null): widget is DropDownWidget;
|
|
11
|
+
private widget;
|
|
12
|
+
private labelFn;
|
|
13
|
+
private onSelectionChanged?;
|
|
14
|
+
private signalHandlers;
|
|
15
|
+
constructor(_type: string, widget: Gtk.Widget, props: Props);
|
|
16
|
+
getWidget(): DropDownWidget;
|
|
17
|
+
getLabelFn(): ItemLabelFn<unknown>;
|
|
18
|
+
appendChild(child: Node): void;
|
|
19
|
+
removeChild(child: Node): void;
|
|
20
|
+
insertBefore(child: Node, _before: Node): void;
|
|
21
|
+
attachToParent(parent: Node): void;
|
|
22
|
+
detachFromParent(parent: Node): void;
|
|
23
|
+
updateProps(oldProps: Props, newProps: Props): void;
|
|
24
|
+
mount(): void;
|
|
25
|
+
dispose(): void;
|
|
26
|
+
}
|
|
27
|
+
export declare class DropDownItemNode<T = unknown> implements Node {
|
|
28
|
+
static needsWidget: boolean;
|
|
29
|
+
static matches(type: string, _widget: Gtk.Widget | null): _widget is Gtk.Widget;
|
|
30
|
+
private item;
|
|
31
|
+
constructor(_type: string, _widget: Gtk.Widget, props: Props);
|
|
32
|
+
getItem(): T;
|
|
33
|
+
appendChild(_child: Node): void;
|
|
34
|
+
removeChild(_child: Node): void;
|
|
35
|
+
insertBefore(_child: Node, _before: Node): void;
|
|
36
|
+
attachToParent(parent: Node): void;
|
|
37
|
+
detachFromParent(parent: Node): void;
|
|
38
|
+
updateProps(_oldProps: Props, _newProps: Props): void;
|
|
39
|
+
mount(): void;
|
|
40
|
+
}
|
|
41
|
+
export {};
|