@gtkx/cli 0.13.3 → 0.14.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.
package/dist/dev-server.d.ts
CHANGED
package/dist/dev-server.js
CHANGED
|
@@ -21,7 +21,7 @@ import { swcSsrRefresh } from "./vite-plugin-swc-ssr-refresh.js";
|
|
|
21
21
|
* import { render } from "@gtkx/react";
|
|
22
22
|
*
|
|
23
23
|
* const server = await createDevServer({
|
|
24
|
-
*
|
|
24
|
+
* entry: "./src/dev.tsx",
|
|
25
25
|
* });
|
|
26
26
|
*
|
|
27
27
|
* const mod = await server.ssrLoadModule("./src/dev.tsx");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "CLI for GTKX - create and develop GTK4 React applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -58,19 +58,19 @@
|
|
|
58
58
|
"ejs": "^3.1.10",
|
|
59
59
|
"react-refresh": "^0.18.0",
|
|
60
60
|
"vite": "^7.3.1",
|
|
61
|
-
"@gtkx/
|
|
62
|
-
"@gtkx/
|
|
63
|
-
"@gtkx/react": "0.
|
|
61
|
+
"@gtkx/ffi": "0.14.0",
|
|
62
|
+
"@gtkx/mcp": "0.14.0",
|
|
63
|
+
"@gtkx/react": "0.14.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/ejs": "^3.1.5",
|
|
67
67
|
"@types/react-refresh": "^0.14.7",
|
|
68
68
|
"memfs": "^4.51.1",
|
|
69
|
-
"@gtkx/testing": "0.
|
|
69
|
+
"@gtkx/testing": "0.14.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"react": "^19",
|
|
73
|
-
"@gtkx/testing": "0.
|
|
73
|
+
"@gtkx/testing": "0.14.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependenciesMeta": {
|
|
76
76
|
"@gtkx/testing": {
|
|
@@ -127,14 +127,14 @@ const TodoList = () => {
|
|
|
127
127
|
|
|
128
128
|
return (
|
|
129
129
|
<GtkBox orientation={Gtk.Orientation.VERTICAL} spacing={12} marginStart={16} marginEnd={16} marginTop={16} marginBottom={16}>
|
|
130
|
-
<GtkBox
|
|
130
|
+
<GtkBox spacing={8}>
|
|
131
131
|
<GtkEntry text={input} onChanged={(e) => setInput(e.getText())} hexpand placeholderText="New todo..." />
|
|
132
132
|
<GtkButton label="Add" onClicked={addTodo} cssClasses={["suggested-action"]} />
|
|
133
133
|
</GtkBox>
|
|
134
134
|
<GtkScrolledWindow vexpand cssClasses={["card"]}>
|
|
135
135
|
<x.ListView<Todo>
|
|
136
136
|
renderItem={(todo) => (
|
|
137
|
-
<GtkBox
|
|
137
|
+
<GtkBox spacing={8} marginStart={12} marginEnd={12} marginTop={8} marginBottom={8}>
|
|
138
138
|
<GtkLabel label={todo?.text ?? ""} hexpand halign={Gtk.Align.START} />
|
|
139
139
|
<GtkButton iconName="edit-delete-symbolic" cssClasses={["flat"]} onClicked={() => todo && deleteTodo(todo.id)} />
|
|
140
140
|
</GtkBox>
|
|
@@ -176,7 +176,7 @@ const SidebarNav = () => {
|
|
|
176
176
|
const [currentPage, setCurrentPage] = useState("home");
|
|
177
177
|
|
|
178
178
|
return (
|
|
179
|
-
<GtkPaned
|
|
179
|
+
<GtkPaned position={200}>
|
|
180
180
|
<x.Slot for={GtkPaned} id="startChild">
|
|
181
181
|
<GtkScrolledWindow cssClasses={["sidebar"]}>
|
|
182
182
|
<x.ListView<Page>
|
|
@@ -287,7 +287,7 @@ const SettingsPage = () => {
|
|
|
287
287
|
<AdwExpanderRow title="Notification Settings" subtitle="Configure alerts">
|
|
288
288
|
<AdwSwitchRow title="Sound" active />
|
|
289
289
|
<AdwSwitchRow title="Badges" active />
|
|
290
|
-
<AdwSwitchRow title="Lock Screen"
|
|
290
|
+
<AdwSwitchRow title="Lock Screen" />
|
|
291
291
|
</AdwExpanderRow>
|
|
292
292
|
</AdwPreferencesGroup>
|
|
293
293
|
</AdwPreferencesPage>
|
|
@@ -668,7 +668,7 @@ const FileBrowser = () => {
|
|
|
668
668
|
selected={selected ? [selected] : []}
|
|
669
669
|
onSelectionChanged={(ids) => setSelected(ids[0] ?? null)}
|
|
670
670
|
renderItem={(item) => (
|
|
671
|
-
<GtkBox
|
|
671
|
+
<GtkBox spacing={8}>
|
|
672
672
|
<GtkImage iconName={item?.isDirectory ? "folder-symbolic" : "text-x-generic-symbolic"} />
|
|
673
673
|
<GtkLabel label={item?.name ?? ""} halign={Gtk.Align.START} />
|
|
674
674
|
</GtkBox>
|
|
@@ -52,7 +52,7 @@ GTK signals map to `on<SignalName>` props: `clicked` → `onClicked`, `toggled`
|
|
|
52
52
|
Some widgets require children in specific slots:
|
|
53
53
|
|
|
54
54
|
```tsx
|
|
55
|
-
<GtkPaned
|
|
55
|
+
<GtkPaned>
|
|
56
56
|
<x.Slot for={GtkPaned} id="startChild"><Sidebar /></x.Slot>
|
|
57
57
|
<x.Slot for={GtkPaned} id="endChild"><Content /></x.Slot>
|
|
58
58
|
</GtkPaned>
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
Linear layout (horizontal or vertical).
|
|
21
21
|
|
|
22
22
|
```tsx
|
|
23
|
-
<GtkBox orientation={Gtk.Orientation.VERTICAL} spacing={12}
|
|
23
|
+
<GtkBox orientation={Gtk.Orientation.VERTICAL} spacing={12}>
|
|
24
24
|
{children}
|
|
25
25
|
</GtkBox>
|
|
26
26
|
```
|
|
@@ -68,7 +68,7 @@ Custom tab widget:
|
|
|
68
68
|
```tsx
|
|
69
69
|
<x.NotebookPage>
|
|
70
70
|
<x.NotebookPageTab>
|
|
71
|
-
<GtkBox
|
|
71
|
+
<GtkBox spacing={4}>
|
|
72
72
|
<GtkImage iconName="folder-symbolic" />
|
|
73
73
|
<GtkLabel label="Files" />
|
|
74
74
|
</GtkBox>
|
|
@@ -81,7 +81,7 @@ Custom tab widget:
|
|
|
81
81
|
Resizable split with draggable divider. **Requires Slot components.**
|
|
82
82
|
|
|
83
83
|
```tsx
|
|
84
|
-
<GtkPaned
|
|
84
|
+
<GtkPaned position={280} shrinkStartChild={false}>
|
|
85
85
|
<x.Slot for={GtkPaned} id="startChild"><Sidebar /></x.Slot>
|
|
86
86
|
<x.Slot for={GtkPaned} id="endChild"><MainContent /></x.Slot>
|
|
87
87
|
</GtkPaned>
|
|
@@ -99,6 +99,22 @@ Stack widgets on top of each other. First child is base layer, additional childr
|
|
|
99
99
|
</GtkOverlay>
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
+
### GtkFixed
|
|
103
|
+
Absolute positioning. Use `x.FixedChild` wrapper for children.
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
<GtkFixed>
|
|
107
|
+
<x.FixedChild x={20} y={30}>
|
|
108
|
+
<GtkLabel label="Top Left" />
|
|
109
|
+
</x.FixedChild>
|
|
110
|
+
<x.FixedChild x={200} y={100}>
|
|
111
|
+
<GtkLabel label="Middle" />
|
|
112
|
+
</x.FixedChild>
|
|
113
|
+
</GtkFixed>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**FixedChild props:** `x`, `y` (pixel coordinates)
|
|
117
|
+
|
|
102
118
|
### GtkScrolledWindow
|
|
103
119
|
Scrollable container.
|
|
104
120
|
|
|
@@ -193,7 +209,7 @@ Hierarchical tree with expand/collapse.
|
|
|
193
209
|
selected={selectedId ? [selectedId] : []}
|
|
194
210
|
onSelectionChanged={(ids) => setSelectedId(ids[0])}
|
|
195
211
|
renderItem={(item, row) => (
|
|
196
|
-
<GtkBox
|
|
212
|
+
<GtkBox spacing={8}>
|
|
197
213
|
<GtkImage iconName={item?.isDirectory ? "folder-symbolic" : "text-x-generic-symbolic"} />
|
|
198
214
|
<GtkLabel label={item?.name ?? ""} />
|
|
199
215
|
</GtkBox>
|
|
@@ -256,7 +272,6 @@ Slider with optional marks.
|
|
|
256
272
|
|
|
257
273
|
```tsx
|
|
258
274
|
<GtkScale
|
|
259
|
-
orientation={Gtk.Orientation.HORIZONTAL}
|
|
260
275
|
drawValue
|
|
261
276
|
valuePos={Gtk.PositionType.TOP}
|
|
262
277
|
>
|
|
@@ -466,7 +481,7 @@ Expandable settings row with optional action widget.
|
|
|
466
481
|
</x.ExpanderRowAction>
|
|
467
482
|
<x.ExpanderRowRow>
|
|
468
483
|
<AdwSwitchRow title="Option 1" active />
|
|
469
|
-
<AdwSwitchRow title="Option 2"
|
|
484
|
+
<AdwSwitchRow title="Option 2" />
|
|
470
485
|
</x.ExpanderRowRow>
|
|
471
486
|
</AdwExpanderRow>
|
|
472
487
|
```
|
|
@@ -554,3 +569,47 @@ const [selected, setSelected] = useState(items[0]);
|
|
|
554
569
|
| `AdwSpinner` | Loading indicator |
|
|
555
570
|
| `AdwWindowTitle` | Title + subtitle for header bars |
|
|
556
571
|
| `AdwButtonRow` | Button styled as list row |
|
|
572
|
+
|
|
573
|
+
---
|
|
574
|
+
|
|
575
|
+
## Drag and Drop
|
|
576
|
+
|
|
577
|
+
All widgets support drag-and-drop through props. Use `onDragPrepare`, `onDragBegin`, and `onDragEnd` to make a widget draggable, and `dropTypes`, `onDrop`, `onDropEnter`, and `onDropLeave` to accept drops.
|
|
578
|
+
|
|
579
|
+
```tsx
|
|
580
|
+
import * as Gdk from "@gtkx/ffi/gdk";
|
|
581
|
+
import * as GObject from "@gtkx/ffi/gobject";
|
|
582
|
+
import { typeFromName } from "@gtkx/ffi/gobject";
|
|
583
|
+
import { GtkButton, GtkBox, GtkLabel } from "@gtkx/react";
|
|
584
|
+
import { useState } from "react";
|
|
585
|
+
|
|
586
|
+
const DraggableButton = ({ label }: { label: string }) => {
|
|
587
|
+
const stringType = typeFromName("gchararray");
|
|
588
|
+
const value = new GObject.Value();
|
|
589
|
+
value.init(stringType);
|
|
590
|
+
value.setString(label);
|
|
591
|
+
|
|
592
|
+
return (
|
|
593
|
+
<GtkButton
|
|
594
|
+
label={label}
|
|
595
|
+
onDragPrepare={() => Gdk.ContentProvider.newForValue(value)}
|
|
596
|
+
/>
|
|
597
|
+
);
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
const DropZone = () => {
|
|
601
|
+
const [dropped, setDropped] = useState<string | null>(null);
|
|
602
|
+
const stringType = typeFromName("gchararray");
|
|
603
|
+
|
|
604
|
+
return (
|
|
605
|
+
<GtkBox
|
|
606
|
+
dropTypes={[stringType]}
|
|
607
|
+
onDrop={(value: GObject.Value) => {
|
|
608
|
+
setDropped(value.getString());
|
|
609
|
+
return true;
|
|
610
|
+
}}
|
|
611
|
+
>
|
|
612
|
+
<GtkLabel label={dropped ?? "Drop here"} />
|
|
613
|
+
</GtkBox>
|
|
614
|
+
);
|
|
615
|
+
};
|