@gjsify/adwaita-web 0.60.0 → 0.61.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/README.md +11 -0
- package/lib/types/elements/gtk-drop-down.d.ts +4 -0
- package/lib/types/elements/gtk-label.d.ts +4 -0
- package/lib/types/elements/gtk-text-view.d.ts +15 -0
- package/lib/types/file-chooser-host.d.ts +55 -0
- package/lib/types/file-chooser.spec.d.ts +1 -0
- package/lib/types/gtk-platform.spec.d.ts +1 -0
- package/lib/types/namespace/adw.d.ts +1 -0
- package/lib/types/namespace/gdk.d.ts +2 -0
- package/lib/types/namespace/gio.d.ts +3 -0
- package/lib/types/namespace/glib.d.ts +1 -0
- package/lib/types/namespace/gtk-enums.d.ts +22 -0
- package/lib/types/namespace/gtk-platform.d.ts +13 -0
- package/lib/types/namespace/gtk.d.ts +4 -1
- package/lib/types/platform-host.d.ts +2 -0
- package/lib/types/style-manager.d.ts +7 -0
- package/package.json +18 -9
- package/src/capabilities.mjs +1 -4
- package/src/construct-vectors.spec.ts +10 -1
- package/src/elements/gtk-drop-down.ts +10 -0
- package/src/elements/gtk-label.ts +10 -0
- package/src/elements/gtk-text-view.ts +40 -0
- package/src/file-chooser-host.ts +421 -0
- package/src/file-chooser.spec.ts +376 -0
- package/src/gobject-door.ts +7 -1
- package/src/gobject-elements.ts +4 -0
- package/src/gtk-drop-down.spec.ts +11 -0
- package/src/gtk-label.spec.ts +12 -0
- package/src/gtk-platform.spec.ts +19 -0
- package/src/gtk-text-view.spec.ts +22 -0
- package/src/namespace/adw.ts +1 -0
- package/src/namespace/gdk.ts +18 -1
- package/src/namespace/gio.ts +20 -2
- package/src/namespace/glib.ts +6 -1
- package/src/namespace/gtk-enums.ts +7 -2
- package/src/namespace/gtk-platform.ts +16 -0
- package/src/namespace/gtk.ts +12 -1
- package/src/platform-host.ts +88 -0
- package/src/shared-tree-builder.ts +40 -0
- package/src/shared-trees.spec.ts +36 -0
- package/src/style-manager.ts +10 -1
- package/src/test.browser.mts +4 -0
- package/src/widget-members.spec.ts +12 -0
package/README.md
CHANGED
|
@@ -185,6 +185,17 @@ Chromium 149 to `rgb(0, 117, 255)`: both blue, neither the desktop's accent. A p
|
|
|
185
185
|
cannot tell such a default from a real accent, which is why the server handoff ranks
|
|
186
186
|
above it.
|
|
187
187
|
|
|
188
|
+
## Platform members
|
|
189
|
+
|
|
190
|
+
`Gtk.CssProvider`, `Gtk.StyleContext`, `Gtk.Settings`, `Gtk.IconTheme`, `Gtk.EventControllerKey`,
|
|
191
|
+
`Gtk.show_uri`, `Gdk.KEY_*`, `Adw.ColorScheme` and the web `Gtk.License` are ONE behaviour in
|
|
192
|
+
`adwaita-core/src/gtk-platform.ts`. Each port only supplies a `PlatformHost` (`src/platform-host.ts`):
|
|
193
|
+
a `<style>` element, `window.open` and a keydown listener on the web; `Application.addCss`, an Intent
|
|
194
|
+
and an `OnKeyListener` on NativeScript, where iOS never delivers keys.
|
|
195
|
+
|
|
196
|
+
`Gio.Settings` is `@gjsify/app-settings` (ADR 0099), an OPTIONAL peer of both ports (Tier 3, ADR 0003
|
|
197
|
+
rule 1).
|
|
198
|
+
|
|
188
199
|
## Icons, and the ones the stylesheet does not ship
|
|
189
200
|
|
|
190
201
|
A `<gtk-image icon-name="go-next">` is a CSS mask: the box takes its colour from
|
|
@@ -28,6 +28,10 @@ export declare class GtkDropDown extends HTMLElement {
|
|
|
28
28
|
/** The selected index. Out-of-range values are ignored (Gtk.DropDown:selected). */
|
|
29
29
|
get selected(): number;
|
|
30
30
|
set selected(value: number);
|
|
31
|
+
/** `gtk_drop_down_get_selected`. */
|
|
32
|
+
get_selected(): number;
|
|
33
|
+
/** `gtk_drop_down_set_selected`; an out-of-range index is ignored, as the `selected` property does. */
|
|
34
|
+
set_selected(position: number): void;
|
|
31
35
|
/** The selected option's value, or '' when empty (Gtk.DropDown:selected-item). */
|
|
32
36
|
get selectedValue(): string;
|
|
33
37
|
set selectedValue(value: string);
|
|
@@ -82,6 +82,10 @@ export declare class GtkLabel extends HTMLElement {
|
|
|
82
82
|
/** `Gtk.Label:selectable` — whether the text can be selected. GTK's default is not. */
|
|
83
83
|
get selectable(): boolean;
|
|
84
84
|
set selectable(value: boolean);
|
|
85
|
+
/** `gtk_label_get_label`. */
|
|
86
|
+
get_label(): string;
|
|
87
|
+
/** `gtk_label_set_label`. */
|
|
88
|
+
set_label(str: string): void;
|
|
85
89
|
/** `gtk_label_get_text` — the text as SHOWN, markup reduced and the marker removed. */
|
|
86
90
|
getText(): string;
|
|
87
91
|
connectedCallback(): void;
|
|
@@ -2,6 +2,13 @@ import { type LabelJustification } from '@gjsify/adwaita-core';
|
|
|
2
2
|
/** `Gtk.WrapMode`'s four nicks, in enum order — Pango's enum, and the DEFAULT is `none`. */
|
|
3
3
|
declare const WRAP_MODES: readonly ["none", "char", "word", "word-char"];
|
|
4
4
|
type TextViewWrapMode = (typeof WRAP_MODES)[number];
|
|
5
|
+
/** The members of `Gtk.TextBuffer` this element has: text in and out, and the insertion cursor. */
|
|
6
|
+
export interface GtkTextBufferSubset {
|
|
7
|
+
readonly cursor_position: number;
|
|
8
|
+
insert_at_cursor(text: string, len?: number): void;
|
|
9
|
+
set_text(text: string, len?: number): void;
|
|
10
|
+
get_text(): string;
|
|
11
|
+
}
|
|
5
12
|
export declare class GtkTextView extends HTMLElement {
|
|
6
13
|
private _area;
|
|
7
14
|
private _initialized;
|
|
@@ -39,6 +46,14 @@ export declare class GtkTextView extends HTMLElement {
|
|
|
39
46
|
/** `Gtk.TextView:right-margin` — pixels of blank space to the right of the text. */
|
|
40
47
|
get rightMargin(): number;
|
|
41
48
|
set rightMargin(value: number);
|
|
49
|
+
/**
|
|
50
|
+
* `gtk_text_view_get_buffer`: the part of `Gtk.TextBuffer` a program writes through. The text
|
|
51
|
+
* stays the element's own, so the buffer is a view onto it: the cursor is the textarea's caret,
|
|
52
|
+
* and a length of -1 means "the whole string", as in GTK.
|
|
53
|
+
*/
|
|
54
|
+
get buffer(): GtkTextBufferSubset;
|
|
55
|
+
/** `gtk_text_view_get_buffer`. */
|
|
56
|
+
get_buffer(): GtkTextBufferSubset;
|
|
42
57
|
/** The inner native textarea, for focus and selection. */
|
|
43
58
|
get textarea(): HTMLTextAreaElement;
|
|
44
59
|
connectedCallback(): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type FileChooserDriver, type FileChooserRequest, type FileFilterSpec } from '@gjsify/adwaita-core';
|
|
2
|
+
import './elements/adw-dialog.js';
|
|
3
|
+
import './elements/adw-overlay-split-view.js';
|
|
4
|
+
import './elements/adw-toolbar-view.js';
|
|
5
|
+
import './elements/gtk-button.js';
|
|
6
|
+
import './elements/gtk-drop-down.js';
|
|
7
|
+
import './elements/gtk-entry.js';
|
|
8
|
+
import './elements/gtk-list-box.js';
|
|
9
|
+
import './elements/gtk-list-box-row.js';
|
|
10
|
+
/** What the drawn dialog hands back: an OPFS entry by name, or a file the `<input>` picked. */
|
|
11
|
+
export type OpfsChoice = {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly upload: File;
|
|
15
|
+
};
|
|
16
|
+
/** File System Access `showOpenFilePicker`/`showSaveFilePicker` options, as far as the door fills them. */
|
|
17
|
+
export interface FilePickerOptions {
|
|
18
|
+
types?: {
|
|
19
|
+
description: string;
|
|
20
|
+
accept: Record<string, string[]>;
|
|
21
|
+
}[];
|
|
22
|
+
excludeAcceptAllOption?: boolean;
|
|
23
|
+
suggestedName?: string;
|
|
24
|
+
}
|
|
25
|
+
/** The platform the driver reads. {@link browserFileChooserEnv} is the real one; a spec passes fakes. */
|
|
26
|
+
export interface WebFileChooserEnv {
|
|
27
|
+
showOpenFilePicker?: (options: FilePickerOptions) => Promise<FileSystemFileHandle[]>;
|
|
28
|
+
showSaveFilePicker?: (options: FilePickerOptions) => Promise<FileSystemFileHandle>;
|
|
29
|
+
/** Transient user activation; an environment that cannot say answers `true`. */
|
|
30
|
+
isActive(): boolean;
|
|
31
|
+
opfsRoot(): Promise<FileSystemDirectoryHandle>;
|
|
32
|
+
/** The drawn dialog over `root`; `null` when the user closed it. */
|
|
33
|
+
choose(kind: 'open' | 'save', request: FileChooserRequest, root: FileSystemDirectoryHandle): Promise<OpfsChoice | null>;
|
|
34
|
+
/** Whether `handle` writes through `createWritable`; the worker writes otherwise. */
|
|
35
|
+
canStreamWrite(handle: FileSystemFileHandle): boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The File System Access options for `request`. An extension-only filter needs a MIME key, and
|
|
39
|
+
* `application/octet-stream` is the one that claims nothing about the content. A filter that
|
|
40
|
+
* accepts everything is the picker's own accept-all option, so it is not a type.
|
|
41
|
+
*/
|
|
42
|
+
export declare function filePickerOptions(request: FileChooserRequest, kind: 'open' | 'save'): FilePickerOptions;
|
|
43
|
+
/** `<input type=file accept>` for one filter: extensions and MIME types; `null` accepts every file. */
|
|
44
|
+
export declare function inputAccept(spec: FileFilterSpec | null): string | null;
|
|
45
|
+
export declare function createWebFileChooserDriver(env: WebFileChooserEnv): FileChooserDriver;
|
|
46
|
+
/**
|
|
47
|
+
* Lets the user pick an OPFS file (`open`) or name one (`save`). Resolves the choice, or `null`
|
|
48
|
+
* when the dialog closes without one. On `open`, "Upload…" picks a file through `<input type=file>`;
|
|
49
|
+
* its `cancel` event dismisses the whole open, as ADR 0100 § 5 maps it.
|
|
50
|
+
*
|
|
51
|
+
* The dialog sets `data-ready` once the list is filled, which is what a spec waits for.
|
|
52
|
+
*/
|
|
53
|
+
export declare function presentOpfsDialog(kind: 'open' | 'save', request: FileChooserRequest, root: FileSystemDirectoryHandle): Promise<OpfsChoice | null>;
|
|
54
|
+
export declare function browserFileChooserEnv(): WebFileChooserEnv;
|
|
55
|
+
export declare const webFileChooserDriver: FileChooserDriver;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FileChooserTest: () => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GtkPlatformTest: () => Promise<void>;
|
|
@@ -56,3 +56,4 @@ export { AdwWindowTitle as WindowTitle } from '../elements/adw-window-title.js';
|
|
|
56
56
|
export { AdwWrapBox as WrapBox } from '../elements/adw-wrap-box.js';
|
|
57
57
|
export { AdwApplication as Application } from '../application.js';
|
|
58
58
|
export { AdwStyleManager as StyleManager } from '../style-manager.js';
|
|
59
|
+
export { ColorScheme } from '@gjsify/adwaita-core';
|
|
@@ -5,3 +5,5 @@ export declare const Display: {
|
|
|
5
5
|
export declare const Clipboard: typeof import("@gjsify/adwaita-core").Clipboard;
|
|
6
6
|
export declare const ContentProvider: Pick<typeof import("@gjsify/adwaita-core").ContentProvider, "new_for_value">;
|
|
7
7
|
export declare const ContentFormats: typeof import("@gjsify/adwaita-core").ContentFormats;
|
|
8
|
+
export declare const CURRENT_TIME = 0;
|
|
9
|
+
export declare const KEY_space: 32, KEY_a: 97, KEY_d: 100, KEY_e: 101, KEY_q: 113, KEY_s: 115, KEY_w: 119, KEY_Return: 65293, KEY_Escape: 65307, KEY_Left: 65361, KEY_Up: 65362, KEY_Right: 65363, KEY_Down: 65364;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import '../file-chooser-host.js';
|
|
1
2
|
export { GioMenu as Menu, GioMenuItem as MenuItem } from '@gjsify/adwaita-core';
|
|
3
|
+
export { GioFile as File, GioListStore as ListStore, GioOutputStream as OutputStream, GioFileOutputStream as FileOutputStream, FileCreateFlags, IOErrorEnum, promisify as _promisify, } from '@gjsify/adwaita-core';
|
|
2
4
|
export { SimpleAction, SimpleActionGroup, ApplicationFlags } from '@gjsify/adwaita-core';
|
|
3
5
|
export { GioApplication as Application } from '../application.js';
|
|
6
|
+
export { Settings } from '@gjsify/app-settings/browser';
|
|
@@ -25,3 +25,25 @@ export declare const TextExtendSelection: Readonly<{
|
|
|
25
25
|
readonly WORD: 0;
|
|
26
26
|
readonly LINE: 1;
|
|
27
27
|
}>;
|
|
28
|
+
/** `Gtk.License`, the table `Adw.AboutDialog` reads. */
|
|
29
|
+
export declare const License: {
|
|
30
|
+
readonly UNKNOWN: 0;
|
|
31
|
+
readonly CUSTOM: 1;
|
|
32
|
+
readonly GPL_2_0: 2;
|
|
33
|
+
readonly GPL_3_0: 3;
|
|
34
|
+
readonly LGPL_2_1: 4;
|
|
35
|
+
readonly LGPL_3_0: 5;
|
|
36
|
+
readonly BSD: 6;
|
|
37
|
+
readonly MIT_X11: 7;
|
|
38
|
+
readonly ARTISTIC: 8;
|
|
39
|
+
readonly GPL_2_0_ONLY: 9;
|
|
40
|
+
readonly GPL_3_0_ONLY: 10;
|
|
41
|
+
readonly LGPL_2_1_ONLY: 11;
|
|
42
|
+
readonly LGPL_3_0_ONLY: 12;
|
|
43
|
+
readonly AGPL_3_0: 13;
|
|
44
|
+
readonly AGPL_3_0_ONLY: 14;
|
|
45
|
+
readonly BSD_3: 15;
|
|
46
|
+
readonly APACHE_2_0: 16;
|
|
47
|
+
readonly MPL_2_0: 17;
|
|
48
|
+
readonly '0BSD': 18;
|
|
49
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const CssProvider: typeof import("@gjsify/adwaita-core").CssProvider;
|
|
2
|
+
export declare const StyleContext: {
|
|
3
|
+
add_provider_for_display(display: unknown, provider: import("@gjsify/adwaita-core").CssProvider, priority: number): void;
|
|
4
|
+
remove_provider_for_display(display: unknown, provider: import("@gjsify/adwaita-core").CssProvider): void;
|
|
5
|
+
};
|
|
6
|
+
export declare const Settings: {
|
|
7
|
+
get_default(): import("@gjsify/adwaita-core").GtkSettings;
|
|
8
|
+
};
|
|
9
|
+
export declare const IconTheme: {
|
|
10
|
+
get_for_display(display: unknown): import("@gjsify/adwaita-core").IconTheme;
|
|
11
|
+
};
|
|
12
|
+
export declare const EventControllerKey: typeof import("@gjsify/adwaita-core").EventControllerKey;
|
|
13
|
+
export declare const show_uri: (parent: unknown, uri: string, timestamp: number) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { GtkAdjustment as Adjustment } from '@gjsify/adwaita-core';
|
|
2
|
-
export {
|
|
2
|
+
export { GtkFileDialog as FileDialog, GtkFileFilter as FileFilter, DialogError } from '@gjsify/adwaita-core';
|
|
3
|
+
export { License, PolicyType, TextDirection, TextExtendSelection, TextWindowType } from './gtk-enums.js';
|
|
3
4
|
export { GtkAboutDialog as AboutDialog } from '../elements/gtk-about-dialog.js';
|
|
4
5
|
export { GtkActionBar as ActionBar } from '../elements/gtk-action-bar.js';
|
|
5
6
|
export { GtkApplicationWindow as ApplicationWindow } from '../elements/gtk-application-window.js';
|
|
@@ -75,3 +76,5 @@ export { GtkWindowControls as WindowControls } from '../elements/gtk-window-cont
|
|
|
75
76
|
export { GtkViewport as Viewport } from '../elements/gtk-viewport.js';
|
|
76
77
|
export { GtkWindowHandle as WindowHandle } from '../elements/gtk-window-handle.js';
|
|
77
78
|
export { GtkApplication as Application } from '../application.js';
|
|
79
|
+
export { STYLE_PROVIDER_PRIORITY_APPLICATION, STYLE_PROVIDER_PRIORITY_FALLBACK, STYLE_PROVIDER_PRIORITY_SETTINGS, STYLE_PROVIDER_PRIORITY_THEME, STYLE_PROVIDER_PRIORITY_USER, } from '@gjsify/adwaita-core';
|
|
80
|
+
export { CssProvider, EventControllerKey, IconTheme, show_uri, StyleContext, Settings } from './gtk-platform.js';
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { StyleManagerBase, type StyleSource } from '@gjsify/adwaita-core';
|
|
2
2
|
export declare const webStyleSource: StyleSource;
|
|
3
3
|
export declare class AdwStyleManager extends StyleManagerBase {
|
|
4
|
+
static readonly ColorScheme: {
|
|
5
|
+
readonly DEFAULT: 0;
|
|
6
|
+
readonly FORCE_LIGHT: 1;
|
|
7
|
+
readonly PREFER_LIGHT: 2;
|
|
8
|
+
readonly PREFER_DARK: 3;
|
|
9
|
+
readonly FORCE_DARK: 4;
|
|
10
|
+
};
|
|
4
11
|
static source: StyleSource;
|
|
5
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/adwaita-web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.0",
|
|
4
4
|
"description": "Adwaita/Libadwaita web components for browser targets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -54,17 +54,26 @@
|
|
|
54
54
|
"@codemirror/language": "^6.12.4",
|
|
55
55
|
"@codemirror/state": "^6.7.0",
|
|
56
56
|
"@codemirror/view": "^6.43.4",
|
|
57
|
-
"@gjsify/adwaita-core": "^0.
|
|
58
|
-
"@gjsify/adwaita-fonts": "^0.
|
|
59
|
-
"@gjsify/adwaita-icons": "^0.
|
|
60
|
-
"@gjsify/gtksource-core": "^0.
|
|
57
|
+
"@gjsify/adwaita-core": "^0.61.0",
|
|
58
|
+
"@gjsify/adwaita-fonts": "^0.61.0",
|
|
59
|
+
"@gjsify/adwaita-icons": "^0.61.0",
|
|
60
|
+
"@gjsify/gtksource-core": "^0.61.0",
|
|
61
61
|
"@lezer/highlight": "^1.2.3"
|
|
62
62
|
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@gjsify/app-settings": "^0.61.0"
|
|
65
|
+
},
|
|
66
|
+
"peerDependenciesMeta": {
|
|
67
|
+
"@gjsify/app-settings": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
63
71
|
"devDependencies": {
|
|
64
|
-
"@gjsify/
|
|
65
|
-
"@gjsify/
|
|
66
|
-
"@gjsify/
|
|
67
|
-
"@gjsify/
|
|
72
|
+
"@gjsify/app-settings": "^0.61.0",
|
|
73
|
+
"@gjsify/blueprint": "^0.61.0",
|
|
74
|
+
"@gjsify/cli": "^0.61.0",
|
|
75
|
+
"@gjsify/unit": "^0.61.0",
|
|
76
|
+
"@gjsify/vite-plugin-blueprint": "^0.61.0",
|
|
68
77
|
"sass": "^1.101.0",
|
|
69
78
|
"typescript": "^6.0.3"
|
|
70
79
|
},
|
package/src/capabilities.mjs
CHANGED
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
/** @type {import('./capabilities.d.mts').capabilities} */
|
|
6
6
|
export const capabilities = {
|
|
7
|
-
layout:
|
|
8
|
-
refused:
|
|
9
|
-
'an <adw-…> element is placed by DOM order and slot=, so a layout-manager placement has no door in the markup this package reads (ADR 0092)',
|
|
10
|
-
},
|
|
7
|
+
layout: 'implemented',
|
|
11
8
|
strings: 'implemented',
|
|
12
9
|
responses: 'implemented',
|
|
13
10
|
page: 'implemented',
|
|
@@ -23,10 +23,19 @@ customElements.define('corpus-extern', CorpusExtern);
|
|
|
23
23
|
registerTemplateClass(EXTERN_VECTOR_CLASS, 'corpus-extern');
|
|
24
24
|
|
|
25
25
|
function observe(vector: ConstructVector): unknown {
|
|
26
|
-
if (vector.kind === '
|
|
26
|
+
if (vector.kind === 'sibling-object') {
|
|
27
27
|
buildSharedTree(vector.tree);
|
|
28
28
|
return undefined;
|
|
29
29
|
}
|
|
30
|
+
if (vector.kind === 'layout') {
|
|
31
|
+
// CSS Grid lines count from 1, GTK cells from 0: `2 / span 2` is column 1, columnSpan 2.
|
|
32
|
+
const start = (line: string) => Number(line.split(' / ')[0]) - 1;
|
|
33
|
+
const span = (line: string) => Number(line.split('span ')[1]);
|
|
34
|
+
return [...buildSharedTree(vector.tree).children].map((child) => {
|
|
35
|
+
const { gridRow, gridColumn } = (child as HTMLElement).style;
|
|
36
|
+
return { row: start(gridRow), column: start(gridColumn), columnSpan: span(gridColumn) };
|
|
37
|
+
});
|
|
38
|
+
}
|
|
30
39
|
if (vector.kind === 'page') {
|
|
31
40
|
const stack = buildSharedTree(vector.tree);
|
|
32
41
|
return [{ name: stack.children[0]!.getAttribute('name'), title: stack.children[0]!.getAttribute('title') }];
|
|
@@ -126,6 +126,16 @@ export class GtkDropDown extends HTMLElement {
|
|
|
126
126
|
this._selectIndex(value);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
/** `gtk_drop_down_get_selected`. */
|
|
130
|
+
get_selected(): number {
|
|
131
|
+
return this.selected;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** `gtk_drop_down_set_selected`; an out-of-range index is ignored, as the `selected` property does. */
|
|
135
|
+
set_selected(position: number): void {
|
|
136
|
+
this.selected = position;
|
|
137
|
+
}
|
|
138
|
+
|
|
129
139
|
/** The selected option's value, or '' when empty (Gtk.DropDown:selected-item). */
|
|
130
140
|
get selectedValue(): string {
|
|
131
141
|
return this._state.selectedValue;
|
|
@@ -262,6 +262,16 @@ export class GtkLabel extends HTMLElement {
|
|
|
262
262
|
this.toggleAttribute('selectable', !!value);
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
+
/** `gtk_label_get_label`. */
|
|
266
|
+
get_label(): string {
|
|
267
|
+
return this.label;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** `gtk_label_set_label`. */
|
|
271
|
+
set_label(str: string): void {
|
|
272
|
+
this.label = str;
|
|
273
|
+
}
|
|
274
|
+
|
|
265
275
|
/** `gtk_label_get_text` — the text as SHOWN, markup reduced and the marker removed. */
|
|
266
276
|
getText(): string {
|
|
267
277
|
return labelDisplayText(this.label, this.useMarkup, this.useUnderline);
|
|
@@ -75,6 +75,14 @@ const WRAP_WHITE_SPACE: Record<TextViewWrapMode, string> = {
|
|
|
75
75
|
char: 'pre-wrap',
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
+
/** The members of `Gtk.TextBuffer` this element has: text in and out, and the insertion cursor. */
|
|
79
|
+
export interface GtkTextBufferSubset {
|
|
80
|
+
readonly cursor_position: number;
|
|
81
|
+
insert_at_cursor(text: string, len?: number): void;
|
|
82
|
+
set_text(text: string, len?: number): void;
|
|
83
|
+
get_text(): string;
|
|
84
|
+
}
|
|
85
|
+
|
|
78
86
|
export class GtkTextView extends HTMLElement {
|
|
79
87
|
private _area!: HTMLTextAreaElement;
|
|
80
88
|
private _initialized = false;
|
|
@@ -195,6 +203,38 @@ export class GtkTextView extends HTMLElement {
|
|
|
195
203
|
this.setAttribute('right-margin', String(value));
|
|
196
204
|
}
|
|
197
205
|
|
|
206
|
+
/**
|
|
207
|
+
* `gtk_text_view_get_buffer`: the part of `Gtk.TextBuffer` a program writes through. The text
|
|
208
|
+
* stays the element's own, so the buffer is a view onto it: the cursor is the textarea's caret,
|
|
209
|
+
* and a length of -1 means "the whole string", as in GTK.
|
|
210
|
+
*/
|
|
211
|
+
get buffer(): GtkTextBufferSubset {
|
|
212
|
+
return {
|
|
213
|
+
cursor_position: this._area ? (this._area.selectionEnd ?? this._area.value.length) : this.text.length,
|
|
214
|
+
insert_at_cursor: (text: string, len = -1) => {
|
|
215
|
+
const piece = len < 0 ? text : text.slice(0, len);
|
|
216
|
+
const area = this._area;
|
|
217
|
+
if (!area) {
|
|
218
|
+
this.text = this.text + piece;
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const at = area.selectionEnd ?? area.value.length;
|
|
222
|
+
area.setRangeText(piece, at, at, 'end');
|
|
223
|
+
this._emitChanged();
|
|
224
|
+
},
|
|
225
|
+
set_text: (text: string, len = -1) => {
|
|
226
|
+
this.text = len < 0 ? text : text.slice(0, len);
|
|
227
|
+
if (this._area) this._emitChanged();
|
|
228
|
+
},
|
|
229
|
+
get_text: () => this.text,
|
|
230
|
+
} as GtkTextBufferSubset;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** `gtk_text_view_get_buffer`. */
|
|
234
|
+
get_buffer(): GtkTextBufferSubset {
|
|
235
|
+
return this.buffer;
|
|
236
|
+
}
|
|
237
|
+
|
|
198
238
|
/** The inner native textarea, for focus and selection. */
|
|
199
239
|
get textarea(): HTMLTextAreaElement {
|
|
200
240
|
return this._area;
|