@gtkx/react 0.1.11 → 0.1.14

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.
@@ -2,19 +2,18 @@ import type * as Gtk from "@gtkx/ffi/gtk";
2
2
  import type { Application } from "@gtkx/ffi/gtk";
3
3
  import Reconciler from "react-reconciler";
4
4
  import type { Node } from "./node.js";
5
- export declare const getCurrentApp: () => Application | null;
6
- export declare const getActiveWindow: () => Gtk.Window | null;
7
- export declare const disposeAllInstances: () => void;
8
- import { TextNode } from "./nodes/text.js";
9
- type PublicInstance = Node;
5
+ type TextInstance = Node;
10
6
  export declare class GtkReconciler {
11
7
  private reconciler;
8
+ private currentApp;
12
9
  constructor();
13
10
  setCurrentApp(app: Application): void;
11
+ getCurrentApp(): Application | null;
14
12
  getReconciler(): typeof this.reconciler;
15
13
  private createHostConfig;
16
14
  private createReconcilerContext;
17
15
  }
18
- export declare const reconciler: Reconciler.Reconciler<unknown, Node<Gtk.Widget>, TextNode, never, never, PublicInstance>;
16
+ export declare const reconciler: Reconciler.Reconciler<unknown, Node<Gtk.Widget | undefined>, TextInstance, never, never, Gtk.Widget>;
19
17
  export declare const setCurrentApp: (app: Application) => void;
18
+ export declare const getCurrentApp: () => Application | null;
20
19
  export {};
@@ -1,24 +1,17 @@
1
1
  import React from "react";
2
2
  import Reconciler from "react-reconciler";
3
3
  import { createNode } from "./factory.js";
4
- const allInstances = new Set();
5
- let currentApp = null;
6
- export const getCurrentApp = () => currentApp;
7
- export const getActiveWindow = () => currentApp?.getActiveWindow() ?? null;
8
- export const disposeAllInstances = () => {
9
- for (const instance of allInstances) {
10
- instance.dispose?.();
11
- }
12
- allInstances.clear();
13
- };
14
- import { TextNode } from "./nodes/text.js";
15
4
  export class GtkReconciler {
16
5
  reconciler;
6
+ currentApp = null;
17
7
  constructor() {
18
8
  this.reconciler = Reconciler(this.createHostConfig());
19
9
  }
20
10
  setCurrentApp(app) {
21
- currentApp = app;
11
+ this.currentApp = app;
12
+ }
13
+ getCurrentApp() {
14
+ return this.currentApp;
22
15
  }
23
16
  getReconciler() {
24
17
  return this.reconciler;
@@ -33,14 +26,8 @@ export class GtkReconciler {
33
26
  getRootHostContext: () => ({}),
34
27
  getChildHostContext: (parentHostContext) => parentHostContext,
35
28
  shouldSetTextContent: () => false,
36
- createInstance: (type, props) => {
37
- const instance = createNode(type, props, currentApp);
38
- allInstances.add(instance);
39
- return instance;
40
- },
41
- createTextInstance: (text) => {
42
- return new TextNode(text);
43
- },
29
+ createInstance: (type, props) => createNode(type, props, this.currentApp),
30
+ createTextInstance: (text) => createNode("Label.Root", { label: text }, this.currentApp),
44
31
  appendInitialChild: (parent, child) => parent.appendChild(child),
45
32
  finalizeInitialChildren: () => true,
46
33
  commitUpdate: (instance, _type, oldProps, newProps) => {
@@ -53,16 +40,12 @@ export class GtkReconciler {
53
40
  removeChild: (parent, child) => parent.removeChild(child),
54
41
  insertBefore: (parent, child, beforeChild) => parent.insertBefore(child, beforeChild),
55
42
  removeChildFromContainer: (_container, _child) => { },
56
- appendChildToContainer: (_container, child) => {
57
- child.mount();
58
- },
59
- insertInContainerBefore: (_container, child, _beforeChild) => {
60
- child.mount();
61
- },
43
+ appendChildToContainer: (_container, _child) => { },
44
+ insertInContainerBefore: (_container, _child, _beforeChild) => { },
62
45
  prepareForCommit: () => null,
63
46
  resetAfterCommit: () => { },
64
- commitTextUpdate: (textInstance, _oldText, newText) => {
65
- textInstance.updateText(newText);
47
+ commitTextUpdate: (textInstance, oldText, newText) => {
48
+ textInstance.updateProps({ label: oldText }, { label: newText });
66
49
  },
67
50
  clearContainer: () => { },
68
51
  preparePortalMount: () => { },
@@ -73,7 +56,7 @@ export class GtkReconciler {
73
56
  cancelTimeout: (id) => {
74
57
  clearTimeout(id);
75
58
  },
76
- getPublicInstance: (instance) => instance,
59
+ getPublicInstance: (instance) => instance.getWidget(),
77
60
  getCurrentUpdatePriority: () => 2,
78
61
  setCurrentUpdatePriority: () => { },
79
62
  resolveUpdatePriority: () => 2,
@@ -85,8 +68,7 @@ export class GtkReconciler {
85
68
  prepareScopeUpdate: () => { },
86
69
  getInstanceFromScope: () => null,
87
70
  detachDeletedInstance: (instance) => {
88
- instance.dispose?.();
89
- allInstances.delete(instance);
71
+ instance.dispose();
90
72
  },
91
73
  resetFormInstance: () => { },
92
74
  requestPostPaintCallback: () => { },
@@ -109,3 +91,4 @@ export class GtkReconciler {
109
91
  const gtkReconciler = new GtkReconciler();
110
92
  export const reconciler = gtkReconciler.getReconciler();
111
93
  export const setCurrentApp = (app) => gtkReconciler.setCurrentApp(app);
94
+ export const getCurrentApp = () => gtkReconciler.getCurrentApp();
package/dist/types.d.ts CHANGED
@@ -2,8 +2,8 @@ import type { ReactNode } from "react";
2
2
  export interface SlotProps {
3
3
  children?: ReactNode;
4
4
  }
5
- export interface ItemProps<T> {
6
- item: T;
5
+ export interface ListItemProps {
6
+ item: any;
7
7
  }
8
8
  export interface GridChildProps extends SlotProps {
9
9
  column?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/react",
3
- "version": "0.1.11",
3
+ "version": "0.1.14",
4
4
  "description": "Build GTK4 desktop applications with React and TypeScript",
5
5
  "keywords": [
6
6
  "gtk",
@@ -37,16 +37,17 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "react-reconciler": "0.33.0",
40
- "@gtkx/ffi": "0.1.11"
40
+ "@gtkx/ffi": "0.1.14"
41
41
  },
42
42
  "devDependencies": {
43
- "@gtkx/gir": "0.1.11"
43
+ "@gtkx/gir": "0.1.14"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "react": "19"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "tsc -b",
50
- "codegen": "tsx scripts/codegen.ts"
50
+ "codegen": "tsx scripts/codegen.ts",
51
+ "test": "xvfb-run -a vitest run"
51
52
  }
52
53
  }
@@ -1,27 +0,0 @@
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 {};
@@ -1,88 +0,0 @@
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
- }
@@ -1,19 +0,0 @@
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
- }
@@ -1,87 +0,0 @@
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
- }
@@ -1,25 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import type { Props } from "../factory.js";
3
- import type { Node } from "../node.js";
4
- import { type NotebookLike } from "../widget-capabilities.js";
5
- interface NotebookWidget extends Gtk.Widget, NotebookLike {
6
- }
7
- export declare class NotebookNode implements Node<NotebookWidget> {
8
- static needsWidget: boolean;
9
- static matches(type: string, widget: Gtk.Widget | null): widget is NotebookWidget;
10
- private widget;
11
- private signalHandlers;
12
- constructor(_type: string, widget: Gtk.Widget, _props: Props);
13
- getWidget(): NotebookWidget;
14
- appendChild(child: Node): void;
15
- removeChild(child: Node): void;
16
- insertBefore(child: Node, _before: Node): void;
17
- attachToParent(parent: Node): void;
18
- detachFromParent(parent: Node): void;
19
- attachChild(childWidget: Gtk.Widget): void;
20
- detachChild(childWidget: Gtk.Widget): void;
21
- updateProps(oldProps: Props, newProps: Props): void;
22
- mount(): void;
23
- dispose(): void;
24
- }
25
- export {};
@@ -1,88 +0,0 @@
1
- import { appendChild, disconnectSignalHandlers, isConnectable, isNotebookLike, removeChild, } from "../widget-capabilities.js";
2
- const isNotebookWidget = (widget) => isNotebookLike(widget);
3
- export class NotebookNode {
4
- static needsWidget = true;
5
- static matches(type, widget) {
6
- if (type !== "Notebook" && type !== "Notebook.Root")
7
- return false;
8
- return widget !== null && isNotebookWidget(widget);
9
- }
10
- widget;
11
- signalHandlers = new Map();
12
- constructor(_type, widget, _props) {
13
- if (!isNotebookWidget(widget)) {
14
- throw new Error("NotebookNode requires a Notebook widget");
15
- }
16
- this.widget = widget;
17
- }
18
- getWidget() {
19
- return this.widget;
20
- }
21
- appendChild(child) {
22
- child.attachToParent(this);
23
- }
24
- removeChild(child) {
25
- child.detachFromParent(this);
26
- }
27
- insertBefore(child, _before) {
28
- this.appendChild(child);
29
- }
30
- attachToParent(parent) {
31
- const parentWidget = parent.getWidget?.();
32
- if (parentWidget) {
33
- appendChild(parentWidget, this.widget);
34
- }
35
- }
36
- detachFromParent(parent) {
37
- const parentWidget = parent.getWidget?.();
38
- if (parentWidget) {
39
- removeChild(parentWidget, this.widget);
40
- }
41
- }
42
- attachChild(childWidget) {
43
- this.widget.appendPage(childWidget.ptr, undefined);
44
- }
45
- detachChild(childWidget) {
46
- const pageNum = this.widget.pageNum(childWidget.ptr);
47
- if (pageNum >= 0) {
48
- this.widget.removePage(pageNum);
49
- }
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
- }
@@ -1,16 +0,0 @@
1
- import * as Gtk from "@gtkx/ffi/gtk";
2
- import type { Props } from "../factory.js";
3
- import type { Node } from "../node.js";
4
- export declare class TextNode implements Node<Gtk.Label> {
5
- private label;
6
- constructor(text: string);
7
- getWidget(): Gtk.Label;
8
- updateText(text: string): void;
9
- appendChild(_child: Node): void;
10
- removeChild(_child: Node): void;
11
- insertBefore(_child: Node, _before: Node): void;
12
- updateProps(_oldProps: Props, _newProps: Props): void;
13
- mount(): void;
14
- attachToParent(parent: Node): void;
15
- detachFromParent(parent: Node): void;
16
- }
@@ -1,31 +0,0 @@
1
- import * as Gtk from "@gtkx/ffi/gtk";
2
- import { appendChild, removeChild } from "../widget-capabilities.js";
3
- export class TextNode {
4
- label;
5
- constructor(text) {
6
- this.label = new Gtk.Label(text);
7
- }
8
- getWidget() {
9
- return this.label;
10
- }
11
- updateText(text) {
12
- this.label.setLabel(text);
13
- }
14
- appendChild(_child) { }
15
- removeChild(_child) { }
16
- insertBefore(_child, _before) { }
17
- updateProps(_oldProps, _newProps) { }
18
- mount() { }
19
- attachToParent(parent) {
20
- const parentWidget = parent.getWidget?.();
21
- if (parentWidget) {
22
- appendChild(parentWidget, this.label);
23
- }
24
- }
25
- detachFromParent(parent) {
26
- const parentWidget = parent.getWidget?.();
27
- if (parentWidget) {
28
- removeChild(parentWidget, this.label);
29
- }
30
- }
31
- }
@@ -1,4 +0,0 @@
1
- import * as GObject from "@gtkx/ffi/gobject";
2
- type SignalHandlerMap = Map<string, number>;
3
- export declare const disconnectSignalHandlers: (gobject: GObject.GObject, handlers: SignalHandlerMap) => void;
4
- export {};
@@ -1,7 +0,0 @@
1
- import * as GObject from "@gtkx/ffi/gobject";
2
- export const disconnectSignalHandlers = (gobject, handlers) => {
3
- for (const handlerId of handlers.values()) {
4
- GObject.signalHandlerDisconnect(gobject, handlerId);
5
- }
6
- handlers.clear();
7
- };
@@ -1,46 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- export interface Appendable extends Gtk.Widget {
3
- append(child: unknown): void;
4
- }
5
- export interface SingleChild extends Gtk.Widget {
6
- setChild(child: unknown): void;
7
- }
8
- export interface Removable extends Gtk.Widget {
9
- remove(child: unknown): void;
10
- }
11
- export interface Presentable extends Gtk.Widget {
12
- present(): void;
13
- }
14
- export interface Connectable extends Gtk.Widget {
15
- connect(signal: string, handler: (...args: unknown[]) => unknown, after?: boolean): number;
16
- }
17
- export interface DefaultSizable extends Gtk.Widget {
18
- setDefaultSize(width: number, height: number): void;
19
- }
20
- export interface ModelSettable extends Gtk.Widget {
21
- setModel(model: unknown): void;
22
- }
23
- export interface Selectable extends Gtk.Widget {
24
- getSelected(): number;
25
- }
26
- export interface GridAttachable extends Gtk.Widget {
27
- attach(child: unknown, column: number, row: number, width: number, height: number): void;
28
- }
29
- export interface NotebookLike extends Gtk.Widget {
30
- appendPage(child: unknown, tabLabel?: unknown): number;
31
- pageNum(child: unknown): number;
32
- removePage(pageNum: number): void;
33
- }
34
- export declare const isAppendable: (widget: Gtk.Widget) => widget is Appendable;
35
- export declare const isSingleChild: (widget: Gtk.Widget) => widget is SingleChild;
36
- export declare const isRemovable: (widget: Gtk.Widget) => widget is Removable;
37
- export declare const isPresentable: (widget: Gtk.Widget) => widget is Presentable;
38
- export declare const isConnectable: (widget: Gtk.Widget) => widget is Connectable;
39
- export declare const isDefaultSizable: (widget: Gtk.Widget) => widget is DefaultSizable;
40
- export declare const isModelSettable: (widget: Gtk.Widget) => widget is ModelSettable;
41
- export declare const isSelectable: (widget: Gtk.Widget) => widget is Selectable;
42
- export declare const isGridAttachable: (widget: Gtk.Widget) => widget is GridAttachable;
43
- export declare const isNotebookLike: (widget: Gtk.Widget) => widget is NotebookLike;
44
- export declare const appendChild: (parent: Gtk.Widget, child: Gtk.Widget) => void;
45
- export declare const removeChild: (parent: Gtk.Widget, child: Gtk.Widget) => void;
46
- export { disconnectSignalHandlers } from "./signal-utils.js";
@@ -1,32 +0,0 @@
1
- export const isAppendable = (widget) => "append" in widget && typeof widget.append === "function";
2
- export const isSingleChild = (widget) => "setChild" in widget && typeof widget.setChild === "function";
3
- export const isRemovable = (widget) => "remove" in widget && typeof widget.remove === "function";
4
- export const isPresentable = (widget) => "present" in widget && typeof widget.present === "function";
5
- export const isConnectable = (widget) => "connect" in widget && typeof widget.connect === "function";
6
- export const isDefaultSizable = (widget) => "setDefaultSize" in widget && typeof widget.setDefaultSize === "function";
7
- export const isModelSettable = (widget) => "setModel" in widget && typeof widget.setModel === "function";
8
- export const isSelectable = (widget) => "getSelected" in widget && typeof widget.getSelected === "function";
9
- export const isGridAttachable = (widget) => "attach" in widget && typeof widget.attach === "function";
10
- export const isNotebookLike = (widget) => "appendPage" in widget &&
11
- typeof widget.appendPage === "function" &&
12
- "pageNum" in widget &&
13
- typeof widget.pageNum === "function" &&
14
- "removePage" in widget &&
15
- typeof widget.removePage === "function";
16
- export const appendChild = (parent, child) => {
17
- if (isSingleChild(parent)) {
18
- parent.setChild(child.ptr);
19
- }
20
- else if (isAppendable(parent)) {
21
- parent.append(child.ptr);
22
- }
23
- };
24
- export const removeChild = (parent, child) => {
25
- if (isRemovable(parent)) {
26
- parent.remove(child.ptr);
27
- }
28
- else if (isSingleChild(parent)) {
29
- parent.setChild(null);
30
- }
31
- };
32
- export { disconnectSignalHandlers } from "./signal-utils.js";