/** * Type Definitions for Gjs (https://gjs.guide/) * * These type definitions are automatically generated, do not edit them by hand. * If you found a bug fix it in ts-for-gir itself or create a bug report on https://github.com/gjsify/ts-for-gir */ /* import type GObject from '@girs/gobject-2.0'; import type GLib from '@girs/glib-2.0'; import gettext from './gettext.js'; import system from './system.js'; import cairo from './cairo.js'; */ /** * You can use the `Signals.addSignalMethods` method to apply the `Signals` convenience methods to an `Object`. * Generally, this is called on an object prototype, but may also be called on an object instance. * You can use this Interface for this object or prototype to make the methods in typescript known * @example * ```ts * const Signals = imports.signals; * * // Define an interface with the same name of your class to make the methods known * interface Events extends Signals.Methods {} * * class Events {} * Signals.addSignalMethods(Events.prototype); * * const events = new Events(); * * // Typescript will not complain here * events.emit("test-signal", "test argument"); * ``` */ export interface SignalMethods { /** * Connects a callback to a signal for an object. Pass the returned ID to * `disconnect()` to remove the handler. * * If `callback` returns `true`, emission will stop and no other handlers will be * invoked. * * > Warning: Unlike GObject signals, `this` within a signal callback will always * > refer to the global object (ie. `globalThis`). * * @param sigName A signal name * @param callback A callback function * @returns A handler ID */ connect(sigName: string, callback: (self: any, ...args: any[]) => void): number; /** * Emits a signal for an object. Emission stops if a signal handler returns `true`. * * Unlike GObject signals, it is not necessary to declare signals or define their * signature. Simply call `emit()` with whatever signal name you wish, with * whatever arguments you wish. * @param sigName A signal name * @param args Any number of arguments, of any type */ emit(sigName: string, ...args: any[]): void; /** * Disconnects a handler for a signal. * @param id The ID of the handler to be disconnected */ disconnect(id: number): void; /** * Disconnects all signal handlers for an object. */ disconnectAll(): void; /** * Checks if a handler ID is connected. * @param id The ID of the handler to be disconnected * @returns `true` if connected, or `false` if not */ signalHandlerIsConnected(id: number): boolean; } declare namespace signals { interface Methods { /** * Connects a callback to a signal for an object. Pass the returned ID to * `disconnect()` to remove the handler. * * If `callback` returns `true`, emission will stop and no other handlers will be * invoked. * * > Warning: Unlike GObject signals, `this` within a signal callback will always * > refer to the global object (ie. `globalThis`). * * @param sigName A signal name * @param callback A callback function * @returns A handler ID */ connect(sigName: string, callback: (self: any, ...args: any[]) => void): number; /** * Emits a signal for an object. Emission stops if a signal handler returns `true`. * * Unlike GObject signals, it is not necessary to declare signals or define their * signature. Simply call `emit()` with whatever signal name you wish, with * whatever arguments you wish. * @param sigName A signal name * @param args Any number of arguments, of any type */ emit(sigName: string, ...args: any[]): void; /** * Disconnects a handler for a signal. * @param id The ID of the handler to be disconnected */ disconnect(id: number): void; /** * Disconnects all signal handlers for an object. */ disconnectAll(): void; /** * Checks if a handler ID is connected. * @param id The ID of the handler to be disconnected * @returns `true` if connected, or `false` if not */ signalHandlerIsConnected(id: number): boolean; } export function addSignalMethods(proto: T): proto is T & Methods; } declare global { interface GjsGiImports { // Will be extended by the import of more gir types versions: { [namespace: string]: string; }; } interface GjsImports { gi: GjsGiImports; signals: typeof signals; searchPath: string[]; } /** * Run `pkg.initGettext()` before using this. * Currently not implemented. */ const N_: undefined | ((x: string) => string); function print(...args: any[]): void; function printerr(...args: any[]): void; function log(obj: object, others?: object[]): void; function log(msg: string, substitutions?: any[]): void; function logError(exception: object, message?: any): void; function logError(message?: any): void; interface BooleanConstructor { $gtype: GObject.GType; } interface NumberConstructor { $gtype: GObject.GType; } interface StringConstructor { $gtype: GObject.GType; } interface StringConstructor { $gtype: GObject.GType; } interface ObjectConstructor { $gtype: GObject.GType; } const imports: GjsImports; const ARGV: string[]; } declare const _imports: GjsImports; export default _imports; export { _imports as imports };