@gjsify/adwaita-core 0.64.12-next.280 → 0.64.12
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/lib/esm/conformance/gobject.js +1 -1
- package/lib/esm/conformance/index.js +1 -1
- package/lib/esm/conformance/list.js +1 -1
- package/lib/esm/conformance/rows.js +1 -1
- package/lib/esm/gobject.js +1 -1
- package/lib/esm/gtk-platform.js +1 -1
- package/lib/esm/gtk-string-list.js +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/list.js +1 -1
- package/lib/esm/markup.js +1 -1
- package/lib/esm/option-list.js +1 -0
- package/lib/esm/rows.js +1 -1
- package/lib/types/conformance/gobject.d.ts +23 -1
- package/lib/types/conformance/index.d.ts +4 -4
- package/lib/types/conformance/list.d.ts +46 -39
- package/lib/types/conformance/rows.d.ts +62 -2
- package/lib/types/engine.d.ts +50 -6
- package/lib/types/gobject.d.ts +75 -4
- package/lib/types/gtk-platform.d.ts +9 -0
- package/lib/types/gtk-string-list.d.ts +89 -44
- package/lib/types/index.d.ts +9 -7
- package/lib/types/list-view.d.ts +4 -4
- package/lib/types/list.d.ts +33 -19
- package/lib/types/option-list.d.ts +128 -0
- package/lib/types/option-list.spec.d.ts +2 -0
- package/lib/types/rows.d.ts +162 -56
- package/package.json +4 -5
|
@@ -1,72 +1,117 @@
|
|
|
1
|
+
import { GIR_TYPE, GObjectObject, type GType } from './gobject.js';
|
|
2
|
+
/** `gtk_string_list_find`'s "not found" — `GTK_INVALID_LIST_POSITION`, a `guint` of all ones. */
|
|
3
|
+
export declare const INVALID_LIST_POSITION = 4294967295;
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
* construct-time properties.
|
|
5
|
+
* `Gtk.StringObject` — one string, as the `GObject` a `GListModel` is allowed to hand out.
|
|
4
6
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* It exists for the reason it exists in GTK: `g_list_model_get_item` returns a `GObject`, and a
|
|
8
|
+
* string is not one. Two objects holding the same string are NOT equal (measured), so identity
|
|
9
|
+
* here means "this entry of this list", never "this text".
|
|
10
|
+
*/
|
|
11
|
+
export declare class GtkStringObject extends GObjectObject {
|
|
12
|
+
static [GIR_TYPE]: string;
|
|
13
|
+
constructor(props?: Record<string, unknown> | null);
|
|
14
|
+
/** `gtk_string_object_new` — the only way to put a string in one. */
|
|
15
|
+
static new(string: string): GtkStringObject;
|
|
16
|
+
/**
|
|
17
|
+
* `Gtk.StringObject:string`.
|
|
18
|
+
*
|
|
19
|
+
* `null` on one built without a string: `new Gtk.StringObject().string` is `null`, measured,
|
|
20
|
+
* and the GIR's non-null typing describes only the items a list hands out.
|
|
21
|
+
*/
|
|
22
|
+
get string(): string | null;
|
|
23
|
+
set string(_value: string);
|
|
24
|
+
/** `gtk_string_object_get_string`. */
|
|
25
|
+
get_string(): string | null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* What `new Gtk.StringList({ … })` takes.
|
|
29
|
+
*
|
|
30
|
+
* `strings` only, and CONSTRUCT-ONLY, as GTK declares it. The other two the type has —
|
|
31
|
+
* `item-type` and `n-items` — are `GListModel`'s read-only pair.
|
|
8
32
|
*/
|
|
9
33
|
export interface GtkStringListProps {
|
|
10
34
|
/** The strings the list starts with. */
|
|
11
|
-
strings?: readonly string[] | null;
|
|
35
|
+
strings?: readonly (string | null)[] | null;
|
|
12
36
|
}
|
|
13
37
|
/**
|
|
14
|
-
*
|
|
15
|
-
* JS array.
|
|
38
|
+
* `Gtk.StringList` — a `Gio.ListModel` of {@link GtkStringObject}s.
|
|
16
39
|
*
|
|
17
|
-
* `new GtkStringList()` is empty, as `gtk_string_list_new(NULL)` is, and the instance
|
|
18
|
-
*
|
|
40
|
+
* `new GtkStringList()` is empty, as `gtk_string_list_new(NULL)` is, and the instance is what
|
|
41
|
+
* every `model` property takes. It is NOT an array and nothing array-shaped reaches it.
|
|
19
42
|
*/
|
|
20
|
-
export declare class GtkStringList extends
|
|
21
|
-
|
|
22
|
-
|
|
43
|
+
export declare class GtkStringList extends GObjectObject {
|
|
44
|
+
static [GIR_TYPE]: string;
|
|
45
|
+
/** Installed by the core from {@link ListModel}; declared here for the type alone. */
|
|
46
|
+
readonly get_item: (position: number) => GtkStringObject | null;
|
|
47
|
+
readonly get_item_type: () => GType;
|
|
48
|
+
readonly get_n_items: () => number;
|
|
49
|
+
readonly items_changed: (position: number, removed: number, added: number) => void;
|
|
23
50
|
constructor(props?: GtkStringListProps | null);
|
|
24
51
|
/** `gtk_string_list_new`: a list holding `strings`, or an empty one for `null`. */
|
|
25
|
-
static new(strings: readonly string[] | null): GtkStringList;
|
|
52
|
+
static new(strings: readonly (string | null)[] | null): GtkStringList;
|
|
26
53
|
/**
|
|
27
|
-
* `Gtk.StringList:strings
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
54
|
+
* `Gtk.StringList:strings` as GTK leaves it after construction: unreadable, and unwritable
|
|
55
|
+
* without saying so.
|
|
56
|
+
*
|
|
57
|
+
* Both halves are measured, not chosen. The property is construct-only, so GJS installs a
|
|
58
|
+
* getter that answers `undefined` and a setter GObject refuses — with a CRITICAL on stderr
|
|
59
|
+
* and NO exception, leaving the list exactly as it was. Omitting the pair would turn
|
|
60
|
+
* `list.strings = […]` into a silent own-property write that looks like it worked.
|
|
32
61
|
*/
|
|
33
|
-
get strings():
|
|
34
|
-
set strings(
|
|
62
|
+
get strings(): undefined;
|
|
63
|
+
set strings(_value: readonly string[] | undefined);
|
|
64
|
+
/** `Gtk.StringList:item-type` — see the file header on why it is `GObject`. */
|
|
65
|
+
get item_type(): GType;
|
|
66
|
+
set item_type(_value: GType);
|
|
67
|
+
get itemType(): GType;
|
|
68
|
+
set itemType(_value: GType);
|
|
69
|
+
/** `Gtk.StringList:n-items` — the `ParamSpec`'s reader, and `get_n_items`'s answer. */
|
|
70
|
+
get n_items(): number;
|
|
71
|
+
set n_items(_value: number);
|
|
72
|
+
/** `vfunc_get_item_type` — what the interface's `get_item_type()` calls through to. */
|
|
73
|
+
vfunc_get_item_type(): GType;
|
|
74
|
+
/** `vfunc_get_n_items`. */
|
|
75
|
+
vfunc_get_n_items(): number;
|
|
76
|
+
/** `vfunc_get_item` — `null` past the end, as `g_list_model_get_item` returns `NULL`. */
|
|
77
|
+
vfunc_get_item(position: number): GtkStringObject | null;
|
|
35
78
|
/** `gtk_string_list_append`. */
|
|
36
79
|
append(string: string): void;
|
|
37
80
|
/**
|
|
38
81
|
* `gtk_string_list_take` — `append` without the copy.
|
|
39
82
|
*
|
|
40
|
-
* The copy is what the two differ by in C ("this variant … is convenient for
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* something `append` does not.
|
|
83
|
+
* The copy is what the two differ by in C ("this variant … is convenient for formatting
|
|
84
|
+
* strings"), and JS strings are immutable, so here the two are one function. It exists so
|
|
85
|
+
* code ported from GJS keeps working rather than to say something `append` does not.
|
|
44
86
|
*/
|
|
45
87
|
take(string: string): void;
|
|
46
88
|
/** `gtk_string_list_remove` — the string at `position`, which must be in range. */
|
|
47
89
|
remove(position: number): void;
|
|
48
90
|
/**
|
|
49
|
-
* `gtk_string_list_splice
|
|
91
|
+
* `gtk_string_list_splice(position, n_removals, additions)` — the C signature, all three
|
|
92
|
+
* arguments, additions as ONE array.
|
|
50
93
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* the
|
|
54
|
-
*
|
|
55
|
-
* strings instead of silently inserting one array as an element.
|
|
56
|
-
*
|
|
57
|
-
* `nRemovals` omitted is `Array.prototype.splice`'s "to the end", which is a different
|
|
58
|
-
* thing from passing `undefined` — so it is spelled as the count that reaches the end,
|
|
59
|
-
* which `splice` clamps the same way for a negative `position` as the one-argument form
|
|
60
|
-
* does.
|
|
61
|
-
*
|
|
62
|
-
* Flattened by hand, not `Array.prototype.flatMap` (ES2019): this source is also
|
|
63
|
-
* type-checked through `@gjsify/gtk-host`'s type-surface gate, whose `tsconfig`s
|
|
64
|
-
* pin `lib` to ES2017 for reasons of their own (`type-tests/{jsx,react}/tsconfig.json`)
|
|
65
|
-
* — a method this file alone would happily target ES2020 for is invisible there.
|
|
94
|
+
* Not `Array.prototype.splice`'s rest-argument form: this class is no longer an array, so the
|
|
95
|
+
* overload that used to serve both spellings would now be the subset inventing one. Each of
|
|
96
|
+
* the three refusals below is GJS's own, measured: a short call, a bare string where a strv
|
|
97
|
+
* belongs, and `undefined` in a slot that takes `null`.
|
|
66
98
|
*/
|
|
67
|
-
splice(position: number, nRemovals
|
|
99
|
+
splice(position: number, nRemovals: number, additions: readonly (string | null)[] | null): void;
|
|
68
100
|
/** `gtk_string_list_get_string` — `null` past the end, as C returns `NULL`. */
|
|
69
101
|
get_string(position: number): string | null;
|
|
70
|
-
/**
|
|
71
|
-
|
|
102
|
+
/**
|
|
103
|
+
* `gtk_string_list_find` — the POSITION of the first equal string, GTK's meaning of the name,
|
|
104
|
+
* not `Array.prototype.find`'s. {@link INVALID_LIST_POSITION} when there is none.
|
|
105
|
+
*/
|
|
106
|
+
find(string: string): number;
|
|
107
|
+
/**
|
|
108
|
+
* The one mutation, so the emission rule is written once: `items-changed` first, then
|
|
109
|
+
* `notify::n-items` and only when the count actually moved, and NEITHER when the splice
|
|
110
|
+
* removes nothing and adds nothing. All three measured; GTK's own
|
|
111
|
+
* `gtk_string_list_items_changed` is the same two lines.
|
|
112
|
+
*
|
|
113
|
+
* Out of range is a CRITICAL and a no-op, not an exception — `remove` past the end lands on
|
|
114
|
+
* the same assertion, because `gtk_string_list_remove` IS a splice in C.
|
|
115
|
+
*/
|
|
116
|
+
private spliceItems;
|
|
72
117
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export { Toast, ToastOverlayQueue, ToastPriority } from './toast-object.js';
|
|
|
32
32
|
export type { ToastOverlayQueueOptions } from './toast-object.js';
|
|
33
33
|
export { AdwAlertResponses, BottomSheetPresentation, resolveBottomSheetChrome, resolveBottomSheetClose, resolveBottomSheetOpen, resolveBottomSheetSwipeTracker, } from './dialog.js';
|
|
34
34
|
export type { AdwAlertResponse, AdwResponseAppearance, AdwResponseOptions, BottomSheetChrome, BottomSheetChromeState, BottomSheetCloseOutcome, BottomSheetCloseSource, BottomSheetCloseState, BottomSheetLayer, BottomSheetOpenOutcome, BottomSheetOpenSource, BottomSheetOpenState, BottomSheetPresentationListener, BottomSheetPresentationOptions, BottomSheetSwipeTrackerConfig, BottomSheetSwipeTrackerState, BottomSheetTeardownCallback, OrderedConfirmResponses, } from './dialog.js';
|
|
35
|
-
export { ADW_COMBO_NO_SELECTION,
|
|
35
|
+
export { ADW_COMBO_NO_SELECTION, listItemsChanged, normalizeComboOptions, parseListModel } from './list.js';
|
|
36
36
|
export type { AdwComboOption, AdwComboOptionInput, AdwListItemsChanged, AdwListModel, AdwListModelInput, } from './list.js';
|
|
37
37
|
export { ADW_COLUMN_VIEW_NO_FIXED_WIDTH, ADW_GRID_VIEW_MAX_COLUMNS, ADW_GRID_VIEW_MIN_COLUMNS, columnViewSort, columnViewTracks, gridViewColumns, listItemField, listViewSelect, listViewSelectAll, ListViewState, normalizeColumnViewColumns, normalizeListSelectionMode, parseColumnViewColumns, } from './list-view.js';
|
|
38
38
|
export type { AdwColumnViewColumn, AdwColumnViewSort, AdwListItemContext, AdwListItemFactory, AdwListItemField, AdwListSelectStep, AdwListSelection, AdwListSelectionMode, AdwListSelectResult, ListViewItemsListener, ListViewSelectionChange, ListViewSelectionListener, } from './list-view.js';
|
|
@@ -46,17 +46,19 @@ export { ADW_ADJUSTMENT_DEFAULTS, adjustmentRange, clampAdjustmentValue, normali
|
|
|
46
46
|
export type { AdwAdjustment, AdwAdjustmentInput, SpinStateChange, SpinStateListener, SpinStateRangeListener, } from './adjustment.js';
|
|
47
47
|
export { GtkAdjustment } from './gtk-adjustment.js';
|
|
48
48
|
export type { GtkAdjustmentProps } from './gtk-adjustment.js';
|
|
49
|
-
export { GtkStringList } from './gtk-string-list.js';
|
|
49
|
+
export { GtkStringList, GtkStringObject, INVALID_LIST_POSITION } from './gtk-string-list.js';
|
|
50
50
|
export type { GtkStringListProps } from './gtk-string-list.js';
|
|
51
|
+
export { GjsifyOptionList, GjsifyOptionObject, readModelWrite } from './option-list.js';
|
|
52
|
+
export type { GjsifyOptionListProps } from './option-list.js';
|
|
51
53
|
export { ComboState, ExpanderState, ToggleGroupState, keptToggles, toggleIndexOfName } from './rows.js';
|
|
52
|
-
export type { ComboItemsListener, ComboStateChange, ComboStateListener, ExpanderStateListener, ToggleGroupStateChange, ToggleGroupStateListener, } from './rows.js';
|
|
54
|
+
export type { ComboItemsListener, ComboNotify, ComboNotifyListener, ComboStateChange, ComboStateListener, ComboWatchableModel, ExpanderStateListener, ToggleGroupStateChange, ToggleGroupStateListener, } from './rows.js';
|
|
53
55
|
export { DEFAULT_BOX_SPACING, normalizeBoxOrientation, normalizeBoxSpacing } from './box.js';
|
|
54
56
|
export type { BoxOrientation } from './box.js';
|
|
55
57
|
export { DEFAULT_LABEL_ELLIPSIZE, DEFAULT_LABEL_LINES, DEFAULT_LABEL_MAX_WIDTH_CHARS, DEFAULT_LABEL_WIDTH_CHARS, DEFAULT_LABEL_WRAP_MODE, DEFAULT_LABEL_XALIGN, DEFAULT_LABEL_YALIGN, LABEL_ELLIPSIZE_MODES, LABEL_JUSTIFICATIONS, LABEL_WRAP_MODES, labelDisplayText, labelEffectiveLines, labelEllipsizeOverflowValue, labelMarkupIsUnparseable, labelWidthCharsExtent, labelYalignAlignItems, normalizeLabelEllipsize, normalizeLabelJustify, normalizeLabelLines, normalizeLabelMaxWidthChars, normalizeLabelWidthChars, normalizeLabelWrapMode, normalizeLabelXalign, normalizeLabelYalign, } from './label.js';
|
|
56
58
|
export type { LabelAlignItems, LabelEllipsizeMode, LabelJustification, LabelWidthCharsExtent, LabelWrapMode, } from './label.js';
|
|
57
59
|
export { glibClamp, gStrStrip, stringIsNotEmpty } from './glib.js';
|
|
58
60
|
export { AppLaunchContext as GdkAppLaunchContext, ContentFormats, ContentProvider, Clipboard, Display, createGdk, widgetDisplayMembers, } from './gdk.js';
|
|
59
|
-
export { CURRENT_TIME, CssProvider, EventControllerKey, GDK_KEYS, GtkSettings, IconTheme, STYLE_PROVIDER_PRIORITY_APPLICATION, STYLE_PROVIDER_PRIORITY_FALLBACK, STYLE_PROVIDER_PRIORITY_SETTINGS, STYLE_PROVIDER_PRIORITY_THEME, STYLE_PROVIDER_PRIORITY_USER, createGtkPlatform, keyvalOfKey, widgetControllerMembers, } from './gtk-platform.js';
|
|
61
|
+
export { CURRENT_TIME, CssProvider, EventControllerKey, GDK_KEYS, GtkSettings, IconTheme, STYLE_PROVIDER_PRIORITY_APPLICATION, STYLE_PROVIDER_PRIORITY_FALLBACK, STYLE_PROVIDER_PRIORITY_SETTINGS, STYLE_PROVIDER_PRIORITY_THEME, STYLE_PROVIDER_PRIORITY_USER, createGtkPlatform, deliverKeyToControllers, keyvalOfKey, widgetControllerMembers, } from './gtk-platform.js';
|
|
60
62
|
export type { GtkPlatform, HostKeyEvent, PlatformHost } from './gtk-platform.js';
|
|
61
63
|
export { iconLookupNames, lookupResourceIcon } from './icon-theme-resources.js';
|
|
62
64
|
export type { IconDirection, ResourceIconMatch, ResourceIconRequest } from './icon-theme-resources.js';
|
|
@@ -130,7 +132,7 @@ export { ADW_WRAP_BOX_DEFAULT_ALIGN, ADW_WRAP_BOX_DEFAULT_JUSTIFY, ADW_WRAP_BOX_
|
|
|
130
132
|
export type { AdwWrapBoxJustify, AdwWrapBoxOrientation, AdwWrapBoxPackDirection, AdwWrapPolicy, WrapBoxChildFlex, WrapBoxChildOrderOp, WrapBoxFlexInput, WrapBoxFlexStyle, WrapBoxLineLayout, } from './wrap-box.js';
|
|
131
133
|
export { ADW_SOURCE_6502_DIRECTIVES, ADW_SOURCE_6502_LINE_COMMENT, ADW_SOURCE_6502_OPCODES, ADW_SOURCE_6502_REGISTERS, ADW_SOURCE_6502_TOKEN_ROLES, ADW_SOURCE_HEX_STRIDE, ADW_SOURCE_PALETTE_DARK, ADW_SOURCE_PALETTE_LIGHT, ADW_SOURCE_SYNTAX_ROLES, classifyAsm6502Word, formatHexAddress, formatLineNumber, stripSourceWhitespace, tokenizeAsm6502, } from './source.js';
|
|
132
134
|
export type { AdwSourcePalette, AdwSourceSyntaxRole, AdwSourceTokenClass, AdwSourceTokenStream } from './source.js';
|
|
133
|
-
export { GObjectObject, META_SYMBOLS, ParamFlags, ParamSpec, Value, TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_INT, TYPE_STRING, TYPE_UINT, UnsupportedGObjectError, bindProperties, connectInstance, constructRegistered, createClosure, createGObject, disconnectInstance, emitInstance, gobjectEngineName, notifyInstance, PURE_JS_ENGINE, registeredClassOf, registerBaseClass, STOP_EMISSION, usePureJsGObjectEngine, type StoppableEmitter, UNLOCKED_VFUNCS, GIR_TYPE, } from './gobject.js';
|
|
135
|
+
export { GObjectObject, ListModel, META_SYMBOLS, ParamFlags, ParamSpec, Value, TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_INT, TYPE_OBJECT, TYPE_STRING, TYPE_UINT, UnsupportedGObjectError, bindProperties, connectInstance, constructRegistered, createClosure, createGObject, disconnectInstance, emitInstance, gobjectEngineName, notifyInstance, PURE_JS_ENGINE, refuseForeignInterfaces, registeredClassOf, registerBaseClass, STOP_EMISSION, usePureJsGObjectEngine, type StoppableEmitter, UNLOCKED_VFUNCS, GIR_TYPE, } from './gobject.js';
|
|
134
136
|
export { ApplicationFlags, ApplicationInhibitFlags, GioApplicationBase, GtkApplicationBase, withGtkApplication, defineWindowApplicationMembers, dispatchAccelerator, isValidApplicationId, } from './application.js';
|
|
135
137
|
export { CloseRequestState, HandledAccumulator, WindowMemberState, stepDefaultSize } from './window-members.js';
|
|
136
138
|
export type { CloseOutcome, CloseRequestSteps, DefaultSizeProperty, DefaultSizeStep, WindowCommon, WindowMemberInit, WindowMemberProperty, } from './window-members.js';
|
|
@@ -139,9 +141,9 @@ export type { Accelerator } from './accelerators.js';
|
|
|
139
141
|
export type { ApplicationHost, GtkApplicationMembers, GtkApplicationConstructor } from './application.js';
|
|
140
142
|
export { ActionRegistry, SimpleAction, actionRegistryOf, activateWidgetAction, applicationOfWindow, findActionGroup, insertActionGroup, installActionMap, linkWindow, SimpleActionGroup, } from './gio-actions.js';
|
|
141
143
|
export type { ActionActivateHandler, ActionGroupLike, ActionLike, SimpleActionProps } from './gio-actions.js';
|
|
142
|
-
export type { Binding, BindingFlag, BlueprintTemplate, BuiltTemplate, ClassLike, ClassMeta, GObjectConstructor, GObjectDoor, GObjectInstance, GObjectNamespace, GType, ParamKind, RegisterClass, RegisteredClass, SignalHandler, SignalMeta, TemplateScope, } from './gobject.js';
|
|
144
|
+
export type { Binding, BindingFlag, BlueprintTemplate, BuiltTemplate, ClassLike, ClassMeta, GInterface, GObjectConstructor, GObjectDoor, GObjectInstance, GObjectNamespace, GType, ParamKind, RegisterClass, RegisteredClass, SignalHandler, SignalMeta, TemplateScope, } from './gobject.js';
|
|
143
145
|
export { engineForTarget, registerGObjectEngine, registeredEngine, resetRegisteredEngine } from './engine.js';
|
|
144
|
-
export type { EngineTarget, ForeignClassMeta, ForeignProperty, ForeignPropertyKind, ForeignSignal, GObjectEngine, } from './engine.js';
|
|
146
|
+
export type { EngineTarget, ForeignClassMeta, ForeignObjectProperty, ForeignProperty, ForeignPropertyKind, ForeignScalarKind, ForeignScalarProperty, ForeignSignal, GObjectEngine, } from './engine.js';
|
|
145
147
|
export { MAXUINT32, buildFilenamev, getCurrentDir, getSystemDataDirs } from './glib-paths.js';
|
|
146
148
|
export { uriEscapeString } from './glib-uri.js';
|
|
147
149
|
export { computeLanguageNames, languageNamesFromTags, localeFromLanguageTag } from './glib-language.js';
|
package/lib/types/list-view.d.ts
CHANGED
|
@@ -138,10 +138,10 @@ export declare class ListViewState {
|
|
|
138
138
|
* any selected position the new model does not have.
|
|
139
139
|
*
|
|
140
140
|
* A VIEW DOES NOT AUTOSELECT, and that is the one place this class deliberately
|
|
141
|
-
* differs from `ComboState
|
|
142
|
-
* `autoselect
|
|
143
|
-
* has no inline value and GTK's own `GtkMultiSelection` keeps nothing
|
|
144
|
-
* a model it cannot map. So positions are filtered, not
|
|
141
|
+
* differs from `ComboState`, whose model write resets the selection to 0:
|
|
142
|
+
* `GtkSingleSelection:autoselect` exists so a combo row always has a value to SHOW; a
|
|
143
|
+
* list view has no inline value and GTK's own `GtkMultiSelection` keeps nothing
|
|
144
|
+
* selected after a model it cannot map. So positions are filtered, not reset.
|
|
145
145
|
*/
|
|
146
146
|
setModel(model: readonly AdwComboOption[] | null | undefined): void;
|
|
147
147
|
/** `Gtk.SelectionModel` choice. Narrowing it drops what the new mode cannot hold. */
|
package/lib/types/list.d.ts
CHANGED
|
@@ -16,8 +16,34 @@ export type AdwComboOptionInput = string | {
|
|
|
16
16
|
};
|
|
17
17
|
/** A normalised portable list model — what a `model` property holds on every surface. */
|
|
18
18
|
export type AdwListModel = ReadonlyArray<AdwComboOption>;
|
|
19
|
-
/**
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The two methods this module needs off a REAL model — `g_list_model_get_n_items` and
|
|
21
|
+
* `g_list_model_get_item`, nothing else.
|
|
22
|
+
*
|
|
23
|
+
* Duck-typed on purpose. This module is pure data and must not import `Gtk.StringList`, which
|
|
24
|
+
* is a GObject and would drag the whole object system into every surface that only wants to
|
|
25
|
+
* normalise items. `Gio.ListModel` IS these two methods, so matching them is matching the
|
|
26
|
+
* interface rather than guessing at a class.
|
|
27
|
+
*/
|
|
28
|
+
export interface AdwListModelSource {
|
|
29
|
+
/** `g_list_model_get_n_items`. */
|
|
30
|
+
get_n_items(): number;
|
|
31
|
+
/** `g_list_model_get_item` — `null` past the end. */
|
|
32
|
+
get_item(position: number): unknown;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* What {@link normalizeComboOptions} ACCEPTS: the widened form of {@link AdwListModel}, plus a
|
|
36
|
+
* real {@link AdwListModelSource}.
|
|
37
|
+
*
|
|
38
|
+
* IT IS THE NORMALISER'S INPUT TYPE AND NOT A PROPERTY TYPE, which is the whole of what ADR
|
|
39
|
+
* 0122 § 6 changed about it. `Adw.ComboRow:model` and `Gtk.DropDown:model` are a
|
|
40
|
+
* `Gio.ListModel` and nothing else now — an array assigned to either is a `TypeError` naming
|
|
41
|
+
* the type. The union stays because the AUTHORED vocabulary is still both: a JSON markup
|
|
42
|
+
* attribute parses to an array, a `Gtk.StringList` handed to `GjsifyOptionList` is a model,
|
|
43
|
+
* and both arrive here on their way to becoming descriptors. The arms are the two forms a
|
|
44
|
+
* caller can WRITE DOWN, not the two values a property will take.
|
|
45
|
+
*/
|
|
46
|
+
export type AdwListModelInput = ReadonlyArray<AdwComboOptionInput> | AdwListModelSource;
|
|
21
47
|
/**
|
|
22
48
|
* Raw authored items → the stable `{ value, label }` descriptors every list surface
|
|
23
49
|
* works with.
|
|
@@ -28,6 +54,11 @@ export type AdwListModelInput = ReadonlyArray<AdwComboOptionInput>;
|
|
|
28
54
|
* by `undefined`. ONE home for the rule, so no two list widgets can accept two different
|
|
29
55
|
* item vocabularies.
|
|
30
56
|
*
|
|
57
|
+
* A REAL `Gio.ListModel` is read through {@link AdwListModelSource}, and its items through the
|
|
58
|
+
* same three rules as any other entry: a `Gtk.StringObject` arrives as the string it holds,
|
|
59
|
+
* anything else falls to the descriptor rule it already matches or does not. There is no
|
|
60
|
+
* fourth vocabulary for items that came out of a model rather than out of an array.
|
|
61
|
+
*
|
|
31
62
|
* TOTAL — it throws for no input. The doors this reaches are a property assignment and a
|
|
32
63
|
* markup attribute, and an author's typo must not take the widget down.
|
|
33
64
|
*/
|
|
@@ -55,23 +86,6 @@ export declare function parseListModel(raw: string | null | undefined): AdwCombo
|
|
|
55
86
|
* draw a placeholder has nothing to test.
|
|
56
87
|
*/
|
|
57
88
|
export declare const ADW_COMBO_NO_SELECTION = -1;
|
|
58
|
-
/**
|
|
59
|
-
* Where a selection lands after the model under it was REPLACED.
|
|
60
|
-
*
|
|
61
|
-
* `GtkSingleSelection` autoselects, so a position the new model does not have falls back
|
|
62
|
-
* to 0 — including the sentinel, which is how a widget recovers a selection when its model
|
|
63
|
-
* grows. An EMPTY model has no 0 to fall back to and lands on
|
|
64
|
-
* {@link ADW_COMBO_NO_SELECTION}.
|
|
65
|
-
*
|
|
66
|
-
* The test is membership and not `selected >= length`: the sentinel is BELOW the range, so
|
|
67
|
-
* a one-sided comparison leaves a `-1` in place and a model that was emptied and refilled
|
|
68
|
-
* comes back with nothing selected.
|
|
69
|
-
*
|
|
70
|
-
* Lifted out of `ComboState.setModel` so a second list widget cannot re-derive it. The
|
|
71
|
-
* cross-renderer rule it encodes was already conformance data — `conformance/rows.ts`
|
|
72
|
-
* carries it as "the ports' shared answer" — it just had no name of its own.
|
|
73
|
-
*/
|
|
74
|
-
export declare function clampListSelection(selected: number, length: number): number;
|
|
75
89
|
/**
|
|
76
90
|
* One positional change — `Gio.ListModel::items-changed`'s own three parameters.
|
|
77
91
|
*
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { GObjectObject, type GType } from './gobject.js';
|
|
2
|
+
import { type AdwComboOption, type AdwComboOptionInput } from './list.js';
|
|
3
|
+
import type { ComboWatchableModel } from './rows.js';
|
|
4
|
+
/**
|
|
5
|
+
* One selectable item, as the `GObject` a `GListModel` is allowed to hand out.
|
|
6
|
+
*
|
|
7
|
+
* Both properties are READ-ONLY, and that is not caution: an item is what a model contains, and
|
|
8
|
+
* a model reports a content change through `items-changed`. A writable `label` would let the
|
|
9
|
+
* text under a selection move with nothing emitted, which is the failure
|
|
10
|
+
* `GtkStringObject`'s read-only `string` exists to prevent.
|
|
11
|
+
*
|
|
12
|
+
* It deliberately has NO `string` property. `readListModel` unwraps an item that has one as a
|
|
13
|
+
* bare string — that is `Gtk.StringObject`'s shape — and an option that answered to it would
|
|
14
|
+
* lose its `value` on the way out, which is the whole reason this type exists.
|
|
15
|
+
*/
|
|
16
|
+
export declare class GjsifyOptionObject extends GObjectObject {
|
|
17
|
+
constructor(props?: Record<string, unknown> | null);
|
|
18
|
+
/** An item holding `value` and `label` — the only way to put either in one. */
|
|
19
|
+
static new(value: string, label: string): GjsifyOptionObject;
|
|
20
|
+
/** An item for one authored entry, through the normaliser every surface already shares. */
|
|
21
|
+
static fromInput(entry: AdwComboOptionInput): GjsifyOptionObject;
|
|
22
|
+
/** The value this item is addressed by. */
|
|
23
|
+
get value(): string;
|
|
24
|
+
set value(_value: string);
|
|
25
|
+
/** The text this item draws as. */
|
|
26
|
+
get label(): string;
|
|
27
|
+
set label(_value: string);
|
|
28
|
+
/** The descriptor this item holds, as a COPY — nothing hands out the stored record. */
|
|
29
|
+
toOption(): AdwComboOption;
|
|
30
|
+
}
|
|
31
|
+
/** What `new GjsifyOptionList({ … })` takes. */
|
|
32
|
+
export interface GjsifyOptionListProps {
|
|
33
|
+
/** The options the list starts with, in any form {@link normalizeComboOptions} accepts. */
|
|
34
|
+
options?: readonly AdwComboOptionInput[] | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A `Gio.ListModel` of {@link GjsifyOptionObject}s — what a `model` property holds once the
|
|
38
|
+
* array door is closed.
|
|
39
|
+
*
|
|
40
|
+
* `new GjsifyOptionList()` is empty. The instance is a GObject with a real identity, so a
|
|
41
|
+
* `model` write that assigns the SAME list again is the no-op GTK makes it, and
|
|
42
|
+
* `row.model === list` answers true.
|
|
43
|
+
*/
|
|
44
|
+
export declare class GjsifyOptionList extends GObjectObject {
|
|
45
|
+
/** Installed by the core from {@link ListModel}; declared here for the type alone. */
|
|
46
|
+
readonly get_item: (position: number) => GjsifyOptionObject | null;
|
|
47
|
+
readonly get_item_type: () => GType;
|
|
48
|
+
readonly get_n_items: () => number;
|
|
49
|
+
readonly items_changed: (position: number, removed: number, added: number) => void;
|
|
50
|
+
constructor(props?: GjsifyOptionListProps | null);
|
|
51
|
+
/** A list holding `options`, or an empty one for `null` — the markup door's constructor. */
|
|
52
|
+
static new(options: readonly AdwComboOptionInput[] | null): GjsifyOptionList;
|
|
53
|
+
/** The item type, which here is the specific one: this list holds nothing else. */
|
|
54
|
+
get item_type(): GType;
|
|
55
|
+
set item_type(_value: GType);
|
|
56
|
+
get itemType(): GType;
|
|
57
|
+
set itemType(_value: GType);
|
|
58
|
+
/** `n-items` — the `ParamSpec`'s reader, and `get_n_items`'s answer. */
|
|
59
|
+
get n_items(): number;
|
|
60
|
+
set n_items(_value: number);
|
|
61
|
+
/** `vfunc_get_item_type` — what the interface's `get_item_type()` calls through to. */
|
|
62
|
+
vfunc_get_item_type(): GType;
|
|
63
|
+
/** `vfunc_get_n_items`. */
|
|
64
|
+
vfunc_get_n_items(): number;
|
|
65
|
+
/** `vfunc_get_item` — `null` past the end, as `g_list_model_get_item` returns `NULL`. */
|
|
66
|
+
vfunc_get_item(position: number): GjsifyOptionObject | null;
|
|
67
|
+
/** The descriptors this list holds, as copies — the form every renderer draws from. */
|
|
68
|
+
toOptions(): AdwComboOption[];
|
|
69
|
+
/** One more option at the end. */
|
|
70
|
+
append(option: AdwComboOptionInput): void;
|
|
71
|
+
/** The option at `position`, which must be in range. */
|
|
72
|
+
remove(position: number): void;
|
|
73
|
+
/**
|
|
74
|
+
* `g_list_store_splice(position, n_removals, additions)` — the C signature, all three
|
|
75
|
+
* arguments, additions as ONE array, so a hundred-item replacement is one emission.
|
|
76
|
+
*
|
|
77
|
+
* Out of range is a CRITICAL and a no-op rather than an exception, which is the shape
|
|
78
|
+
* `Gtk.StringList` measured for the same call: this door is reachable from a markup
|
|
79
|
+
* attribute, and an author's slip must not take the widget down.
|
|
80
|
+
*/
|
|
81
|
+
splice(position: number, nRemovals: number, additions: readonly AdwComboOptionInput[] | null): void;
|
|
82
|
+
/**
|
|
83
|
+
* The POSITION of the first option with this value, {@link INVALID_LIST_POSITION} when there
|
|
84
|
+
* is none — `gtk_string_list_find`'s meaning of the name, over the half a descriptor is
|
|
85
|
+
* addressed by.
|
|
86
|
+
*/
|
|
87
|
+
find(value: string): number;
|
|
88
|
+
/**
|
|
89
|
+
* Replace the contents with `next` IN PLACE, as the ONE splice that turns one into the
|
|
90
|
+
* other — {@link listItemsChanged}'s minimal range.
|
|
91
|
+
*
|
|
92
|
+
* This is the markup door's update path and it keeps the list's IDENTITY, which is what
|
|
93
|
+
* makes it different from a `model` write. Re-parsing an attribute must not look to the
|
|
94
|
+
* widget like a new model: a model REPLACEMENT re-runs autoselect and resets the selection
|
|
95
|
+
* to 0 (ADR 0122 § 4, measured), while appending one option to the end of the list the
|
|
96
|
+
* widget already holds moves nothing. An author editing `model='[…]'` means the second.
|
|
97
|
+
*/
|
|
98
|
+
reconcile(next: readonly AdwComboOptionInput[] | null): void;
|
|
99
|
+
/** The one mutation, so the emission rule is written once. See the file header. */
|
|
100
|
+
private spliceItems;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* What a write to a `model` property reads as — the ONE door, for all four surfaces.
|
|
104
|
+
*
|
|
105
|
+
* ADR 0122 § 6 makes `model` an object property over `Gio.ListModel`, and § 5 leaves the JSON
|
|
106
|
+
* markup attribute open, so every `model` setter in this repository has the same three-way
|
|
107
|
+
* answer to give. It is written here once because it was about to be written four times:
|
|
108
|
+
*
|
|
109
|
+
* - a real model — anything with `get_n_items` and `get_item`, which is what
|
|
110
|
+
* {@link AdwListModelSource}'s docblock argues is the test — is handed through by IDENTITY,
|
|
111
|
+
* so `widget.model === model` holds as it is measured to in libadwaita;
|
|
112
|
+
* - `null` / `undefined` is the "no model" write, which notifies `model` alone;
|
|
113
|
+
* - a STRING is the markup attribute, parsed and reconciled into `authored` — the surface's
|
|
114
|
+
* OWN list, whose identity survives the edit so an author appending one option to
|
|
115
|
+
* `model='[…]'` gets one splice instead of a replacement that resets the selection;
|
|
116
|
+
* - anything else, an ARRAY above all, is a `TypeError`.
|
|
117
|
+
*
|
|
118
|
+
* THE REFUSAL IS THE PROPERTY'S, not a second opinion: the message comes out of
|
|
119
|
+
* {@link checkPropertyValue} against `model`'s own ParamSpec, which is where GJS's measured
|
|
120
|
+
* wording lives. Reaching it is already the failure case, and it always throws for a value that
|
|
121
|
+
* gets that far — the one thing it accepts is a registered implementor of `Gio.ListModel`, and
|
|
122
|
+
* the interface installs the two getters the duck test above just failed to find.
|
|
123
|
+
*
|
|
124
|
+
* The duck test and not `checkPropertyValue` alone, because a REAL `Gio.ListStore` reached
|
|
125
|
+
* through node-gi (ADR 0104) is no registered class of this subset and `implementsInterface`
|
|
126
|
+
* would refuse it — and handing one to `Adw.ComboRow:model` is the whole point of having it.
|
|
127
|
+
*/
|
|
128
|
+
export declare function readModelWrite(value: unknown, authored: GjsifyOptionList): ComboWatchableModel | null;
|