mirror of
https://github.com/zoriya/ags.git
synced 2025-12-06 00:06:10 +00:00
migrate to girs types
This commit is contained in:
@@ -22,8 +22,8 @@ plugins:
|
||||
rules:
|
||||
'@typescript-eslint/ban-ts-comment':
|
||||
- 'off'
|
||||
|
||||
|
||||
'@typescript-eslint/no-non-null-assertion':
|
||||
- 'off'
|
||||
'@typescript-eslint/no-unused-vars':
|
||||
- error
|
||||
# Vars use a suffix _ instead of a prefix because of file-scope private vars
|
||||
|
||||
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -1,7 +1,3 @@
|
||||
[submodule "gi-types"]
|
||||
path = gi-types
|
||||
url = https://gitlab.gnome.org/BrainBlasted/gi-typescript-definitions
|
||||
branch = nightly
|
||||
[submodule "subprojects/gvc"]
|
||||
path = subprojects/gvc
|
||||
url = https://gitlab.gnome.org/GNOME/libgnome-volume-control
|
||||
|
||||
1
gi-types
1
gi-types
Submodule gi-types deleted from eb2a87a25c
@@ -29,13 +29,6 @@ let
|
||||
rev = "8e7a5a4c3e51007ce6579292642517e3d3eb9c50";
|
||||
sha256 = "sha256-FosJwgTCp6/EI6WVbJhPisokRBA6oT0eo7d+Ya7fFX8=";
|
||||
};
|
||||
gi-types-src = fetchFromGitLab {
|
||||
domain = "gitlab.gnome.org";
|
||||
owner = "BrainBlasted";
|
||||
repo = "gi-typescript-definitions";
|
||||
rev = "eb2a87a25c5e2fb580b605fbec0bd312fe34c492";
|
||||
sha256 = "sha256-MNLrlKeWZI9EDO/8/gaXpAlrWv9B49jSu4keWDh3q9g=";
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "ags";
|
||||
@@ -57,9 +50,7 @@ stdenv.mkDerivation {
|
||||
|
||||
prePatch = ''
|
||||
mkdir -p ./subprojects/gvc
|
||||
mkdir -p ./gi-types
|
||||
cp -r ${gvc-src}/* ./subprojects/gvc
|
||||
cp -r ${gi-types-src}/* ./gi-types
|
||||
'';
|
||||
|
||||
postPatch = ''
|
||||
|
||||
11
src/app.ts
11
src/app.ts
@@ -93,6 +93,7 @@ export class App extends Gtk.Application {
|
||||
this._load();
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
connect(signal = 'window-toggled', callback: (_: this, ...args: any[]) => void): number {
|
||||
return super.connect(signal, callback);
|
||||
}
|
||||
@@ -133,7 +134,7 @@ export class App extends Gtk.Application {
|
||||
}
|
||||
|
||||
removeWindow(w: Gtk.Window | string) {
|
||||
const name = typeof w === 'string' ? w : w.name;
|
||||
const name = typeof w === 'string' ? w : w.name || 'gtk-layer-shell';
|
||||
|
||||
const win = this._windows.get(name);
|
||||
if (!win) {
|
||||
@@ -147,11 +148,13 @@ export class App extends Gtk.Application {
|
||||
|
||||
addWindow(w: Gtk.Window) {
|
||||
if (!(w instanceof Gtk.Window)) {
|
||||
console.error(Error(`${w} is not an instanceof Gtk.Window, ` +
|
||||
return console.error(Error(`${w} is not an instanceof Gtk.Window, ` +
|
||||
` but it is of type ${typeof w}`));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!w.name)
|
||||
return console.error(Error(`${w} has no name`));
|
||||
|
||||
w.connect('notify::visible',
|
||||
() => this.emit('window-toggled', w.name, w.visible));
|
||||
|
||||
@@ -207,7 +210,7 @@ export class App extends Gtk.Application {
|
||||
Gio.BusNameOwnerFlags.NONE,
|
||||
(connection: Gio.DBusConnection) => {
|
||||
this._dbus = Gio.DBusExportedObject
|
||||
.wrapJSObject(AgsIFace(this.application_id) as string, this);
|
||||
.wrapJSObject(AgsIFace(this.application_id!) as string, this);
|
||||
|
||||
this._dbus.export(connection, this._objectPath);
|
||||
},
|
||||
|
||||
@@ -6,10 +6,10 @@ import { loadInterfaceXML } from './utils.js';
|
||||
import { type AgsProxy } from './dbus/types.js';
|
||||
|
||||
const AgsIFace = (bus: string) =>
|
||||
loadInterfaceXML('com.github.Aylur.ags')?.replace('@BUS@', bus);
|
||||
loadInterfaceXML('com.github.Aylur.ags')!.replace('@BUS@', bus);
|
||||
|
||||
const ClientIFace = (bus: string) =>
|
||||
loadInterfaceXML('com.github.Aylur.ags.client')?.replace('@BUS@', bus);
|
||||
loadInterfaceXML('com.github.Aylur.ags.client')!.replace('@BUS@', bus);
|
||||
|
||||
const TIME = `${GLib.DateTime.new_now_local().to_unix()}`;
|
||||
|
||||
@@ -44,11 +44,11 @@ class Client extends Gtk.Application {
|
||||
private _register() {
|
||||
Gio.bus_own_name(
|
||||
Gio.BusType.SESSION,
|
||||
this.applicationId,
|
||||
this.application_id,
|
||||
Gio.BusNameOwnerFlags.NONE,
|
||||
(connection: Gio.DBusConnection) => {
|
||||
this._dbus = Gio.DBusExportedObject
|
||||
.wrapJSObject(ClientIFace(this.applicationId) as string, this);
|
||||
.wrapJSObject(ClientIFace(this.application_id!) as string, this);
|
||||
|
||||
this._dbus.export(connection, this._objectPath);
|
||||
},
|
||||
@@ -68,7 +68,7 @@ class Client extends Gtk.Application {
|
||||
this._register();
|
||||
this._proxy.RunPromiseRemote(
|
||||
this._promiseJs,
|
||||
this.applicationId,
|
||||
this.application_id!,
|
||||
this._objectPath,
|
||||
);
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class Client extends Gtk.Application {
|
||||
|
||||
export default function(bus: string, path: string, flags: Flags) {
|
||||
const AgsProxy = Gio.DBusProxy.makeProxyWrapper(AgsIFace(bus));
|
||||
const proxy = new AgsProxy(Gio.DBus.session, bus, path) as AgsProxy;
|
||||
const proxy = AgsProxy(Gio.DBus.session, bus, path) as AgsProxy;
|
||||
|
||||
if (flags.toggleWindow)
|
||||
print(proxy.ToggleWindowSync(flags.toggleWindow));
|
||||
|
||||
@@ -30,7 +30,6 @@ function isRunning(dbusName: string) {
|
||||
'/org/freedesktop/DBus',
|
||||
'org.freedesktop.DBus',
|
||||
'NameHasOwner',
|
||||
// @ts-expect-error
|
||||
GLib.Variant.new_tuple([new GLib.Variant('s', dbusName)]),
|
||||
new GLib.VariantType('(b)'),
|
||||
Gio.DBusCallFlags.NONE,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import GObject from 'gi://GObject';
|
||||
import { type Ctor } from 'gi-types/gobject2.js';
|
||||
|
||||
type PspecType = 'jsobject' | 'string' | 'int' | 'float' | 'double' | 'boolean' | 'gobject';
|
||||
type PspecFlag = 'rw' | 'r' | 'w';
|
||||
@@ -42,16 +41,15 @@ export default class Service extends GObject.Object {
|
||||
name, name, name, flags, false);
|
||||
|
||||
case 'gobject': return GObject.ParamSpec.object(
|
||||
name, name, name, flags, GObject.Object);
|
||||
name, name, name, flags, GObject.Object.$gtype);
|
||||
|
||||
// @ts-expect-error
|
||||
default: return GObject.ParamSpec.jsobject(
|
||||
name, name, name, flags, null);
|
||||
name, name, name, flags);
|
||||
}
|
||||
}
|
||||
|
||||
static register(
|
||||
service: Ctor,
|
||||
service: new (...args: any[]) => GObject.Object,
|
||||
signals?: { [signal: string]: string[] },
|
||||
properties?: { [prop: string]: [type?: PspecType, handle?: PspecFlag] },
|
||||
) {
|
||||
@@ -80,6 +78,7 @@ export default class Service extends GObject.Object {
|
||||
GObject.registerClass({ Signals, Properties }, service);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
connect(signal = 'changed', callback: (_: this, ...args: any[]) => void): number {
|
||||
return super.connect(signal, callback);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@ import { timeout } from '../utils.js';
|
||||
import { loadInterfaceXML } from '../utils.js';
|
||||
import { type BatteryProxy } from '../dbus/types.js';
|
||||
|
||||
const BatteryIFace = loadInterfaceXML('org.freedesktop.UPower.Device');
|
||||
const PowerManagerProxy =
|
||||
Gio.DBusProxy.makeProxyWrapper(BatteryIFace) as BatteryProxy;
|
||||
const BatteryIFace = loadInterfaceXML('org.freedesktop.UPower.Device')!;
|
||||
const PowerManagerProxy = Gio.DBusProxy.makeProxyWrapper(BatteryIFace) as unknown as BatteryProxy;
|
||||
|
||||
const DeviceState = {
|
||||
CHARGING: 1,
|
||||
|
||||
@@ -6,12 +6,12 @@ import { CACHE_DIR } from '../utils.js';
|
||||
import { loadInterfaceXML } from '../utils.js';
|
||||
import { DBusProxy, PlayerProxy, MprisProxy } from '../dbus/types.js';
|
||||
|
||||
const DBusIFace = loadInterfaceXML('org.freedesktop.DBus');
|
||||
const PlayerIFace = loadInterfaceXML('org.mpris.MediaPlayer2.Player');
|
||||
const MprisIFace = loadInterfaceXML('org.mpris.MediaPlayer2');
|
||||
const DBusProxy = Gio.DBusProxy.makeProxyWrapper(DBusIFace) as DBusProxy;
|
||||
const PlayerProxy = Gio.DBusProxy.makeProxyWrapper(PlayerIFace) as PlayerProxy;
|
||||
const MprisProxy = Gio.DBusProxy.makeProxyWrapper(MprisIFace) as MprisProxy;
|
||||
const DBusIFace = loadInterfaceXML('org.freedesktop.DBus')!;
|
||||
const PlayerIFace = loadInterfaceXML('org.mpris.MediaPlayer2.Player')!;
|
||||
const MprisIFace = loadInterfaceXML('org.mpris.MediaPlayer2')!;
|
||||
const DBusProxy = Gio.DBusProxy.makeProxyWrapper(DBusIFace) as unknown as DBusProxy;
|
||||
const PlayerProxy = Gio.DBusProxy.makeProxyWrapper(PlayerIFace) as unknown as PlayerProxy;
|
||||
const MprisProxy = Gio.DBusProxy.makeProxyWrapper(MprisIFace) as unknown as MprisProxy;
|
||||
|
||||
const MEDIA_CACHE_PATH = `${CACHE_DIR}/media`;
|
||||
|
||||
@@ -144,7 +144,7 @@ class MprisPlayer extends Service {
|
||||
private _updateState() {
|
||||
const metadata = {} as MprisMetadata;
|
||||
for (const prop in this._playerProxy.Metadata)
|
||||
metadata[prop] = this._playerProxy.Metadata[prop].deep_unpack();
|
||||
metadata[prop] = this._playerProxy.Metadata[prop].deepUnpack();
|
||||
|
||||
let trackArtists = metadata['xesam:artist'];
|
||||
if (!Array.isArray(trackArtists) ||
|
||||
@@ -199,7 +199,7 @@ class MprisPlayer extends Service {
|
||||
Gio.FileCopyFlags.OVERWRITE,
|
||||
GLib.PRIORITY_DEFAULT,
|
||||
// @ts-expect-error
|
||||
null, null, (source, result) => {
|
||||
null, null, (source: Gio.File, result: Gio.AsyncResult) => {
|
||||
try {
|
||||
source.copy_finish(result);
|
||||
this.changed('cover-path');
|
||||
@@ -335,7 +335,7 @@ class Mpris extends Service {
|
||||
}
|
||||
|
||||
private _onNameOwnerChanged(
|
||||
_proxy: string,
|
||||
_proxy: Gio.DBusProxy,
|
||||
_sender: string,
|
||||
[name, oldOwner, newOwner]: string[],
|
||||
) {
|
||||
|
||||
@@ -19,9 +19,9 @@ interface Action {
|
||||
}
|
||||
|
||||
interface Hints {
|
||||
'image-data'?: GLib.Variant<'(iiibiiay)'>
|
||||
'desktop-entry'?: GLib.Variant<'s'>
|
||||
'urgency'?: GLib.Variant<'y'>
|
||||
'image-data'?: InstanceType<typeof GLib.Variant>
|
||||
'desktop-entry'?: InstanceType<typeof GLib.Variant>
|
||||
'urgency'?: InstanceType<typeof GLib.Variant>
|
||||
}
|
||||
|
||||
interface NotifcationJson {
|
||||
@@ -37,7 +37,13 @@ interface NotifcationJson {
|
||||
image: string | null
|
||||
}
|
||||
|
||||
const _URGENCY = ['low', 'normal', 'critical'];
|
||||
const _URGENCY = (urgency?: number) => {
|
||||
switch (urgency) {
|
||||
case 0: return 'low';
|
||||
case 2: return 'critical';
|
||||
default: return 'normal';
|
||||
}
|
||||
};
|
||||
|
||||
class Notification extends Service {
|
||||
static {
|
||||
@@ -103,10 +109,10 @@ class Notification extends Service {
|
||||
});
|
||||
}
|
||||
|
||||
this._urgency = _URGENCY[hints['urgency']?.unpack() || 1];
|
||||
this._urgency = _URGENCY(hints['urgency']?.unpack<number>());
|
||||
this._id = id;
|
||||
this._appName = appName;
|
||||
this._appEntry = hints['desktop-entry']?.unpack() || null;
|
||||
this._appEntry = hints['desktop-entry']?.unpack<string>() || null;
|
||||
this._appIcon = appIcon;
|
||||
this._summary = summary;
|
||||
this._body = body;
|
||||
@@ -162,13 +168,15 @@ class Notification extends Service {
|
||||
return GLib.file_test(this._appIcon, GLib.FileTest.EXISTS) ? this._appIcon : null;
|
||||
}
|
||||
|
||||
private _parseImageData(imageData?: GLib.Variant<'(iiibiiay)'>) {
|
||||
private _parseImageData(imageData?: InstanceType<typeof GLib.Variant>) {
|
||||
if (!imageData)
|
||||
return null;
|
||||
|
||||
ensureDirectory(NOTIFICATIONS_CACHE_PATH);
|
||||
const fileName = NOTIFICATIONS_CACHE_PATH + `/${this._id}`;
|
||||
const [w, h, rs, alpha, bps, _, data] = imageData.recursiveUnpack();
|
||||
const [w, h, rs, alpha, bps, _, data] = imageData // iiibiiay
|
||||
.recursiveUnpack<[number, number, number, boolean, number, number, GLib.Bytes]>();
|
||||
|
||||
const pixbuf = GdkPixbuf.Pixbuf.new_from_bytes(
|
||||
data, GdkPixbuf.Colorspace.RGB, alpha, bps, w, h, rs);
|
||||
|
||||
@@ -298,7 +306,7 @@ class Notifications extends Service {
|
||||
|
||||
private _onClosed(n: Notification) {
|
||||
this._dbus.emit_signal('NotificationClosed',
|
||||
GLib.Variant.new('(uu)', [n.id, 3]));
|
||||
new GLib.Variant('(uu)', [n.id, 3]));
|
||||
|
||||
this._notifications.delete(n.id);
|
||||
this.notify('notifications');
|
||||
@@ -310,7 +318,7 @@ class Notifications extends Service {
|
||||
|
||||
private _onInvoked(n: Notification, id: string) {
|
||||
this._dbus.emit_signal('ActionInvoked',
|
||||
GLib.Variant.new('(us)', [n.id, id]));
|
||||
new GLib.Variant('(us)', [n.id, id]));
|
||||
}
|
||||
|
||||
private _register() {
|
||||
|
||||
@@ -9,10 +9,10 @@ import { StatusNotifierItemProxy } from '../dbus/types.js';
|
||||
import { bulkConnect, loadInterfaceXML } from '../utils.js';
|
||||
import Widget from '../widget.js';
|
||||
|
||||
const StatusNotifierWatcherIFace = loadInterfaceXML('org.kde.StatusNotifierWatcher');
|
||||
const StatusNotifierItemIFace = loadInterfaceXML('org.kde.StatusNotifierItem');
|
||||
const StatusNotifierWatcherIFace = loadInterfaceXML('org.kde.StatusNotifierWatcher')!;
|
||||
const StatusNotifierItemIFace = loadInterfaceXML('org.kde.StatusNotifierItem')!;
|
||||
const StatusNotifierItemProxy =
|
||||
Gio.DBusProxy.makeProxyWrapper(StatusNotifierItemIFace) as StatusNotifierItemProxy;
|
||||
Gio.DBusProxy.makeProxyWrapper(StatusNotifierItemIFace) as unknown as StatusNotifierItemProxy;
|
||||
|
||||
export class TrayItem extends Service {
|
||||
static {
|
||||
@@ -71,8 +71,8 @@ export class TrayItem extends Service {
|
||||
}
|
||||
|
||||
openMenu(event: Gdk.Event) {
|
||||
this.menu // DbusmenuGtk3 imports the gdk type from @girs
|
||||
? (this.menu as unknown as Gtk.Menu).popup_at_pointer(event)
|
||||
this.menu
|
||||
? this.menu.popup_at_pointer(event)
|
||||
: this._proxy.ContextMenuAsync(event.get_root_coords()[1], event.get_root_coords()[2]);
|
||||
}
|
||||
|
||||
@@ -117,8 +117,9 @@ export class TrayItem extends Service {
|
||||
private _itemProxyAcquired(proxy: StatusNotifierItemProxy) {
|
||||
if (proxy.Menu) {
|
||||
const menu = Widget({
|
||||
// @ts-expect-error
|
||||
type: DbusmenuGtk3.Menu,
|
||||
// FIXME
|
||||
// @ts-expect-error
|
||||
dbus_name: proxy.g_name_owner,
|
||||
dbus_object: proxy.Menu,
|
||||
});
|
||||
@@ -161,15 +162,15 @@ export class TrayItem extends Service {
|
||||
this._proxy.g_object_path,
|
||||
'org.freedesktop.DBus.Properties',
|
||||
'GetAll',
|
||||
GLib.Variant.new('(s)', [this._proxy.g_interface_name]),
|
||||
GLib.VariantType.new('(a{sv})'),
|
||||
new GLib.Variant('(s)', [this._proxy.g_interface_name]),
|
||||
new GLib.VariantType('(a{sv})'),
|
||||
Gio.DBusCallFlags.NONE, -1,
|
||||
null,
|
||||
(proxy, result) => {
|
||||
const variant = proxy?.call_finish(result) as GLib.Variant<'(a{sv})'>;
|
||||
const variant = proxy?.call_finish(result) as GLib.Variant;
|
||||
if (!variant)
|
||||
return;
|
||||
const [properties] = variant.deep_unpack();
|
||||
const [properties] = variant.deepUnpack<Record<string, GLib.Variant>[]>();
|
||||
Object.entries(properties).map(([propertyName, value]) => {
|
||||
this._proxy.set_cached_property(propertyName, value);
|
||||
});
|
||||
@@ -195,7 +196,7 @@ export class TrayItem extends Service {
|
||||
array[i + 3] = alpha;
|
||||
}
|
||||
return GdkPixbuf.Pixbuf.new_from_bytes(
|
||||
array,
|
||||
new GLib.Bytes(array),
|
||||
GdkPixbuf.Colorspace.RGB,
|
||||
true,
|
||||
8,
|
||||
@@ -255,7 +256,7 @@ class SystemTray extends Service {
|
||||
const [service] = serviceName;
|
||||
if (service.startsWith('/')) {
|
||||
objectPath = service;
|
||||
busName = invocation.get_sender();
|
||||
busName = invocation.get_sender()!;
|
||||
} else {
|
||||
busName = service;
|
||||
objectPath = '/StatusNotifierItem';
|
||||
|
||||
@@ -195,8 +195,8 @@ export function execAsync(cmd: string | string[]): Promise<string> {
|
||||
|
||||
const [, stdout, stderr] = proc.communicate_utf8_finish(res);
|
||||
proc.get_successful()
|
||||
? resolve(stdout.trim())
|
||||
: reject(stderr.trim());
|
||||
? resolve(stdout!.trim())
|
||||
: reject(stderr!.trim());
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import GObject from 'gi://GObject';
|
||||
import Gio from 'gi://Gio';
|
||||
import GLib from 'gi://GLib';
|
||||
@@ -18,22 +17,21 @@ export class Variable extends GObject.Object {
|
||||
GTypeName: 'AgsVariable',
|
||||
Signals: { 'changed': {} },
|
||||
Properties: {
|
||||
// @ts-expect-error
|
||||
'value': GObject.ParamSpec.jsobject(
|
||||
'value', 'value', 'value',
|
||||
GObject.ParamFlags.READWRITE, null,
|
||||
GObject.ParamFlags.READWRITE,
|
||||
),
|
||||
},
|
||||
}, this);
|
||||
}
|
||||
|
||||
private _value: any;
|
||||
private _value: unknown;
|
||||
private _poll?: Poll;
|
||||
private _listen?: Listen;
|
||||
private _interval?: number;
|
||||
private _subprocess?: Gio.Subprocess | null;
|
||||
|
||||
constructor(value: any, { poll, listen }: Options = {}) {
|
||||
constructor(value: unknown, { poll, listen }: Options = {}) {
|
||||
super();
|
||||
this.value = value;
|
||||
|
||||
@@ -48,6 +46,7 @@ export class Variable extends GObject.Object {
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
connect(signal = 'notify::value', callback: (_: this, ...args: any[]) => void): number {
|
||||
return super.connect(signal, callback);
|
||||
}
|
||||
@@ -131,14 +130,14 @@ export class Variable extends GObject.Object {
|
||||
}
|
||||
|
||||
getValue() { return this._value; }
|
||||
setValue(value: any) {
|
||||
setValue(value: unknown) {
|
||||
this._value = value;
|
||||
this.notify('value');
|
||||
this.emit('changed');
|
||||
}
|
||||
|
||||
get value() { return this._value; }
|
||||
set value(value: any) { this.setValue(value); }
|
||||
set value(value: unknown) { this.setValue(value); }
|
||||
}
|
||||
|
||||
export default (value: any, options: Options) => new Variable(value, options);
|
||||
export default (value: unknown, options: Options) => new Variable(value, options);
|
||||
|
||||
@@ -24,13 +24,13 @@ export default class AgsEntry extends Gtk.Entry {
|
||||
this.connect('activate', () => {
|
||||
typeof this.onAccept === 'function'
|
||||
? this.onAccept(this)
|
||||
: runCmd(this.onAccept.replace(/\{\}/g, this.text));
|
||||
: runCmd(this.onAccept.replace(/\{\}/g, this.text || ''));
|
||||
});
|
||||
|
||||
this.connect('notify::text', ({ text }, event) => {
|
||||
typeof this.onChange === 'function'
|
||||
? this.onChange(this, event)
|
||||
: runCmd(this.onChange.replace(/\{\}/g, text));
|
||||
: runCmd(this.onChange.replace(/\{\}/g, text || ''));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ import Gtk from 'gi://Gtk?version=3.0';
|
||||
import GLib from 'gi://GLib';
|
||||
import GdkPixbuf from 'gi://GdkPixbuf';
|
||||
import Gdk from 'gi://Gdk?version=3.0';
|
||||
import { Context } from 'gi-types/cairo1';
|
||||
import Service from '../service.js';
|
||||
import cairo from '@girs/cairo-1.0';
|
||||
|
||||
export default class AgsIcon extends Gtk.Image {
|
||||
static {
|
||||
@@ -84,8 +84,7 @@ export default class AgsIcon extends Gtk.Image {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vfunc_draw(cr: Context): boolean {
|
||||
vfunc_draw(cr: cairo.Context): boolean {
|
||||
if (this._size > 1)
|
||||
return super.vfunc_draw(cr);
|
||||
|
||||
|
||||
@@ -22,15 +22,15 @@ export default class AgsLabel extends Gtk.Label {
|
||||
super(typeof params === 'string' ? { label: params } : params);
|
||||
}
|
||||
|
||||
get label() { return super.label; }
|
||||
get label() { return super.label || ''; }
|
||||
set label(label: string) {
|
||||
if (this.useMarkup) {
|
||||
if (this.use_markup) {
|
||||
try {
|
||||
// @ts-expect-error
|
||||
Pango.parse_markup(label, label.length, '0');
|
||||
} catch (e) {
|
||||
// @ts-expect-error
|
||||
if (e instanceof GLib.MarkupError)
|
||||
label = GLib.markup_escape_text(label, -1);
|
||||
label = GLib.markup_escape_text(label, -1) || '';
|
||||
else
|
||||
console.error(e as Error);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ function setCss(widget: Gtk.Widget, css: string) {
|
||||
|
||||
const provider = new Gtk.CssProvider();
|
||||
widgetProviders.set(widget, provider);
|
||||
provider.load_from_data(css);
|
||||
provider.load_from_data(new TextEncoder().encode(css));
|
||||
widget.get_style_context()
|
||||
.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_USER);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export default class AgsRevealer extends Gtk.Revealer {
|
||||
}, this);
|
||||
}
|
||||
|
||||
get transition() { return transitions[this.transitionType]; }
|
||||
get transition() { return transitions[this.transition_type]; }
|
||||
set transition(transition: string) {
|
||||
if (!transition || this.transition === transition)
|
||||
return;
|
||||
@@ -28,6 +28,6 @@ export default class AgsRevealer extends Gtk.Revealer {
|
||||
return;
|
||||
}
|
||||
|
||||
this.transitionType = transitions.findIndex(t => t === transition);
|
||||
this.transition_type = transitions.findIndex(t => t === transition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import GObject from 'gi://GObject';
|
||||
import Gtk from 'gi://Gtk?version=3.0';
|
||||
import Gdk from 'gi://Gdk?version=3.0';
|
||||
import { runCmd } from '../utils.js';
|
||||
import { EventButton, EventScroll, EventKey } from 'gi-types/gdk3';
|
||||
import { Command } from './constructor.js';
|
||||
import Service from '../service.js';
|
||||
|
||||
@@ -43,7 +43,7 @@ export default class AgsSlider extends Gtk.Scale {
|
||||
adjustment: new Gtk.Adjustment({
|
||||
lower: min,
|
||||
upper: max,
|
||||
stepIncrement: step,
|
||||
step_increment: step,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ export default class AgsSlider extends Gtk.Scale {
|
||||
|
||||
typeof this.onChange === 'function'
|
||||
? this.onChange(this, event, value)
|
||||
: runCmd((onChange as string).replace(/\{\}/g, value));
|
||||
: runCmd((onChange as string).replace(/\{\}/g, `${value}`));
|
||||
});
|
||||
|
||||
if (value)
|
||||
@@ -89,12 +89,12 @@ export default class AgsSlider extends Gtk.Scale {
|
||||
this.notify('max');
|
||||
}
|
||||
|
||||
get step() { return this.adjustment.stepIncrement; }
|
||||
get step() { return this.adjustment.step_increment; }
|
||||
set step(step: number) {
|
||||
if (this.step === step)
|
||||
return;
|
||||
|
||||
this.adjustment.stepIncrement = step;
|
||||
this.adjustment.step_increment = step;
|
||||
this.notify('step');
|
||||
}
|
||||
|
||||
@@ -120,27 +120,27 @@ export default class AgsSlider extends Gtk.Scale {
|
||||
this.notify('vertical');
|
||||
}
|
||||
|
||||
vfunc_button_release_event(event: EventButton): boolean {
|
||||
vfunc_button_release_event(event: Gdk.EventButton): boolean {
|
||||
this.dragging = false;
|
||||
return super.vfunc_button_release_event(event);
|
||||
}
|
||||
|
||||
vfunc_button_press_event(event: EventButton): boolean {
|
||||
vfunc_button_press_event(event: Gdk.EventButton): boolean {
|
||||
this.dragging = true;
|
||||
return super.vfunc_button_press_event(event);
|
||||
}
|
||||
|
||||
vfunc_key_press_event(event: EventKey): boolean {
|
||||
vfunc_key_press_event(event: Gdk.EventKey): boolean {
|
||||
this.dragging = true;
|
||||
return super.vfunc_key_press_event(event);
|
||||
}
|
||||
|
||||
vfunc_key_release_event(event: EventKey): boolean {
|
||||
vfunc_key_release_event(event: Gdk.EventKey): boolean {
|
||||
this.dragging = false;
|
||||
return super.vfunc_key_release_event(event);
|
||||
}
|
||||
|
||||
vfunc_scroll_event(event: EventScroll): boolean {
|
||||
vfunc_scroll_event(event: Gdk.EventScroll): boolean {
|
||||
this.dragging = true;
|
||||
event.delta_y > 0
|
||||
? this.adjustment.value -= this.step
|
||||
|
||||
@@ -60,7 +60,7 @@ export default class AgsStack extends Gtk.Stack {
|
||||
this.show_all();
|
||||
}
|
||||
|
||||
get transition() { return transitions[this.transitionType]; }
|
||||
get transition() { return transitions[this.transition_type]; }
|
||||
set transition(transition: string) {
|
||||
if (this.transition === transition)
|
||||
return;
|
||||
@@ -70,12 +70,12 @@ export default class AgsStack extends Gtk.Stack {
|
||||
return;
|
||||
}
|
||||
|
||||
this.transitionType = transitions.findIndex(t => t === transition);
|
||||
this.transition_type = transitions.findIndex(t => t === transition);
|
||||
this.notify('transition');
|
||||
}
|
||||
|
||||
get shown() { return this.visible_child_name; }
|
||||
set shown(name: string) {
|
||||
set shown(name: string | null) {
|
||||
if (!this.get_child_by_name(name)) {
|
||||
this.visible = false;
|
||||
return;
|
||||
|
||||
@@ -180,8 +180,8 @@ export default class AgsWindow extends Gtk.Window {
|
||||
if (popup) {
|
||||
this.connect('key-press-event', (_, event) => {
|
||||
if (event.get_keyval()[1] === Gdk.KEY_Escape) {
|
||||
App.getWindow(this.name)
|
||||
? App.closeWindow(this.name)
|
||||
App.getWindow(this.name!)
|
||||
? App.closeWindow(this.name!)
|
||||
: this.hide();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,33 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2022",
|
||||
"module": "ES2020",
|
||||
"lib": [
|
||||
"ES2017"
|
||||
],
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"lib": ["ES2017"],
|
||||
"allowJs": true,
|
||||
"checkJs": false,
|
||||
"outDir": "_build/tsc-out",
|
||||
"strict": true,
|
||||
"moduleResolution": "node",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"*": [
|
||||
"*",
|
||||
"types/*",
|
||||
"gi-types/*"
|
||||
]
|
||||
},
|
||||
"typeRoots": [
|
||||
"gi-types"
|
||||
"./node_modules/@girs"
|
||||
],
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"include": [
|
||||
"gi-types/gi.d.ts",
|
||||
"@girs",
|
||||
"types/*",
|
||||
"src/*",
|
||||
"src/*/*"
|
||||
"src"
|
||||
]
|
||||
}
|
||||
|
||||
15
types/ambient.d.ts
vendored
15
types/ambient.d.ts
vendored
@@ -39,18 +39,3 @@ declare class TextEncoder {
|
||||
constructor();
|
||||
encode(input?: string): Uint8Array;
|
||||
}
|
||||
|
||||
declare module 'gi://Gvc' {
|
||||
import Gvc10 from '@girs/gvc-1.0';
|
||||
export default Gvc10;
|
||||
}
|
||||
|
||||
declare module 'gi://NM' {
|
||||
import NM10 from '@girs/nm-1.0';
|
||||
export default NM10;
|
||||
}
|
||||
|
||||
declare module 'gi://DbusmenuGtk3' {
|
||||
import Dbusmenu from '@girs/dbusmenugtk3-0.4';
|
||||
export default Dbusmenu;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user