Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark event emitter and popup menu for GNOME 46 #25

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions packages/gnome-shell/src/misc/signals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ type SignalMap<K> = {
* @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");
* ```
Expand All @@ -30,21 +30,21 @@ export interface SignalMethods<S extends SignalMap<S> = any> {
/**
* 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<Name extends keyof S>(sigName: Name, callback: (self: this, ...args: S[Name]) => boolean | undefined): 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.
Expand All @@ -71,6 +71,9 @@ export interface SignalMethods<S extends SignalMap<S> = any> {

export interface EventEmitter<S extends SignalMap<S> = any> extends SignalMethods<S> {}

/**
* @version 46
*/
export class EventEmitter<S extends SignalMap<S> = any> {
connectObject(...args: any[]): number // TODO: return type is return type of imports.misc.signalTracker.connectObject

Expand All @@ -79,4 +82,4 @@ export class EventEmitter<S extends SignalMap<S> = any> {
connect_object(...args: any[]): ReturnType<typeof this.connectObject>

disconnect_object(...args: any[]): ReturnType<typeof this.disconnectObject>
}
}
3 changes: 3 additions & 0 deletions packages/gnome-shell/src/ui/popupMenu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ export namespace PopupSubMenu {
interface SignalMap extends PopupMenuBase.SignalMap {}
}

/**
* @version 46
*/
export class PopupSubMenu<S extends Signals.SignalMap<S> = PopupSubMenu.SignalMap> extends PopupMenuBase<S> {
actor: St.ScrollView;

Expand Down
Loading