Skip to content

Commit

Permalink
Merge pull request #11 from swsnr/improve-type-definitions
Browse files Browse the repository at this point in the history
Improve type definitions
  • Loading branch information
schnz authored Jan 1, 2024
2 parents 2ae398b + 88206fa commit 537042d
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 47 deletions.
2 changes: 1 addition & 1 deletion packages/gnome-shell/src/misc/extensionUtils.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://gitlab.gnome.org/GNOME/gnome-shell/blob/main/js/misc/extensionUtils.js

import type { Extension } from "../extensions/extension";
import type { Extension } from "../extensions/extension.js";

export enum ExtensionType {
SYSTEM = 1,
Expand Down
2 changes: 1 addition & 1 deletion packages/gnome-shell/src/misc/loginManager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import GLib from '@girs/glib-2.0';
import Gio from '@girs/gio-2.0';
import * as Signals from './signals';
import * as Signals from './signals.js';

/**
* Class representing an interface to the systemd login manager.
Expand Down
4 changes: 2 additions & 2 deletions packages/gnome-shell/src/misc/systemActions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import Gio from '@girs/gio-2.0';
import GLib from '@girs/glib-2.0';
import GObject from '@girs/gobject-2.0';

import { SessionManager } from './gnomeSession';
import * as LoginManager from './loginManager';
import { SessionManager } from './gnomeSession.js';
import * as LoginManager from './loginManager.js';

export interface ActionDetails {
name: string;
Expand Down
27 changes: 16 additions & 11 deletions packages/gnome-shell/src/types/extension-metadata.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import type Gio from "@girs/gio-2.0";

export interface ExtensionMetadata {
uuid: string;
name?: string;
description?: string;
version?: string;
url?: string;
"shell-version"?: string[];
"settings-schema"?: string;
"gettext-domain"?: string;
"original-author"?: string[];
"extension-id"?: string;
}
readonly uuid: string;
readonly dir: Gio.File,
readonly path: string,
readonly name: string;
readonly description: string;
readonly version?: string;
readonly url?: string;
readonly "shell-version": string[];
readonly "settings-schema"?: string;
readonly "gettext-domain"?: string;
readonly "original-author"?: string[];
readonly "extension-id"?: string;
readonly "version-name"?: string;
}
4 changes: 2 additions & 2 deletions packages/gnome-shell/src/ui/main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { AudioDeviceSelectionDBus } from './audioDeviceSelection.js';
// import * as InputMethod from '../misc/inputMethod.js'
// import * as Introspect from '../misc/introspect.js'
// import * as Keyboard from './keyboard.js';
// import * as MessageTray from './messageTray.js';
import { MessageTray } from './messageTray.js';
// import * as ModalDialog from './modalDialog.js';
// import * as OsdWindow from './osdWindow.js';
// import * as OsdMonitorLabeler from './osdMonitorLabeler.js';
Expand Down Expand Up @@ -65,7 +65,7 @@ export declare const welcomeDialog: any;

export declare const wm: WindowManager;

export declare const messageTray: any;
export declare const messageTray: MessageTray;

export declare const screenShield: any;

Expand Down
8 changes: 4 additions & 4 deletions packages/gnome-shell/src/ui/messageTray.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ export class Notification extends GObject.Object {
protected _soundFile: Gio.File | null;
protected _soundPlayed: boolean;

constructor(source: Source, title: string, banner: string, params: Notification.Params);
constructor(source: Source, title: string, banner: string, params?: Notification.Params);
/** @hidden */
override _init(config?: GObject.Object.ConstructorProperties): void;
public _init(source: Source, title: string, banner: string, params: Notification.Params): void;
public _init(source: Source, title: string, banner: string, params?: Notification.Params): void;

/**
* Updates the notification by regenerating its icon and updating
Expand All @@ -185,7 +185,7 @@ export class Notification extends GObject.Object {
* @param banner the new banner
* @param params as in the Notification constructor
*/
public update(title: string, banner: string, params: Notification.Params): void;
public update(title: string, banner: string, params?: Notification.Params): void;

/**
* @param label the label for the action's button
Expand Down Expand Up @@ -291,7 +291,7 @@ export class Source extends GObject.Object {
*/
public createIcon(size: number): St.Icon;

public getIcon(): Gio.ThemedIcon;
public getIcon(): Gio.Icon;

public pushNotification(notification: Notification): void;

Expand Down
12 changes: 6 additions & 6 deletions packages/gnome-shell/src/ui/modalDialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export enum State {

export namespace ModalDialog {
export interface ConstructorProperties {
shellReactive: boolean;
styleClass: string | null;
actionMode: Shell.ActionMode;
shouldFadeIn: boolean;
shouldFadeOut: boolean;
destroyOnClose: boolean;
shellReactive?: boolean;
styleClass?: string | null;
actionMode?: Shell.ActionMode;
shouldFadeIn?: boolean;
shouldFadeOut?: boolean;
destroyOnClose?: boolean;
}
}

Expand Down
54 changes: 41 additions & 13 deletions packages/gnome-shell/src/ui/popupMenu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,15 @@ export namespace PopupMenuItem {
export class PopupMenuItem extends PopupBaseMenuItem {
constructor(text: string, params?: PopupMenuItem.ConstructorProperties);
override _init(text: string, params?: PopupMenuItem.ConstructorProperties): void;

readonly label: St.Label;
}

export class PopupSeparatorMenuItem extends PopupBaseMenuItem {
constructor(text: string);
override _init(text: string): void;
constructor(text?: string);
override _init(text?: string): void;

readonly label: St.Label;
}

export class Switch extends St.Bin {
Expand Down Expand Up @@ -114,31 +118,47 @@ export class PopupImageMenuItem extends PopupBaseMenuItem {
setIcon(icon: Gio.Icon): void;
}

declare class PopupMenuBase extends Signals.EventEmitter {
export namespace PopupMenuBase {
interface SignalMap {}

// PopupMenuBase.addMenuItem explicitly checks for any of these specific
// types
type MenuItemType = PopupMenuSection |
PopupSubMenuMenuItem |
PopupSeparatorMenuItem |
PopupBaseMenuItem
}

export class PopupMenuBase<S extends Signals.SignalMap<S> = PopupMenuBase.SignalMap> extends Signals.EventEmitter<S> {
protected constructor(sourceActor: St.Widget, styleClass?: string);
readonly sourceActor: St.Widget;
readonly focusActor: St.Widget;
readonly length: number;
readonly isOpen: boolean;
readonly box: St.BoxLayout;
sensitive: boolean;
readonly firstMenuItem: PopupBaseMenuItem | null;
// PopupMenuBase._getMenuItems explicitly filters for these two types
readonly firstMenuItem: PopupBaseMenuItem | PopupMenuSection;
readonly numMenuItems: number;

getSensitive(): boolean;
setSensitive(sensitive: boolean): void;
addAction(title: string, callback: () => void, icon: Gio.Icon): void;
addAction(title: string, callback: () => void, icon?: Gio.Icon): void;
addSettingsAction(title: string, desktopFile: string): void;
isEmpty(): boolean;
itemActivated(animate: boolean): void;
moveMenuItem(item: PopupBaseMenuItem, position: number): void;
addMenuItem(item: PopupBaseMenuItem, position?: number): void;
moveMenuItem(item: PopupMenuBase.MenuItemType, position: number): void;
addMenuItem(item: PopupMenuBase.MenuItemType, position?: number): void;
removeAll(): void;
toggle(): void;
destroy(): void;
}

export class PopupMenu extends PopupMenuBase {
export namespace PopupMenu {
interface SignalMap extends PopupMenuBase.SignalMap {}
}

export class PopupMenu<S extends Signals.SignalMap<S> = PopupMenu.SignalMap> extends PopupMenuBase<S> {
constructor(sourceActor: St.Widget, arrowAlignment: number, arrowSide: St.Side);

setArrowOrigin(origin: number): void;
Expand All @@ -160,7 +180,11 @@ export class PopupDummyMenu extends Signals.EventEmitter {
destroy(): void;
}

export class PopupSubMenu extends PopupMenuBase {
export namespace PopupSubMenu {
interface SignalMap extends PopupMenuBase.SignalMap {}
}

export class PopupSubMenu<S extends Signals.SignalMap<S> = PopupSubMenu.SignalMap> extends PopupMenuBase<S> {
actor: St.ScrollView;

constructor(sourceActor: St.Widget, sourceArrow: St.Widget);
Expand All @@ -173,6 +197,10 @@ export class PopupSubMenu extends PopupMenuBase {
}


export namespace PopupMenuSection {
interface SignalMap extends PopupMenuBase.SignalMap {}
}

/**
* PopupMenuSection:
*
Expand All @@ -181,18 +209,18 @@ export class PopupSubMenu extends PopupMenuBase {
* can add it to another menu), but is completely transparent
* to the user
*/
export class PopupMenuSection extends PopupMenuBase {
export class PopupMenuSection<S extends Signals.SignalMap<S> = PopupMenuSection.SignalMap> extends PopupMenuBase<S>{
constructor();

readonly sensitive: boolean;

open(): void;
close(): void;
}

export class PopupSubMenuMenuItem extends PopupBaseMenuItem {
readonly menu: PopupSubMenu;

readonly label: St.Label;

constructor(text: string, wantIcon?: boolean);
override _init(text: string, wantIcon?: boolean): void;

Expand Down
2 changes: 1 addition & 1 deletion packages/gnome-shell/src/ui/slider.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/slider.js

import Clutter from '@girs/clutter-13';
import * as BarLevel from './barLevel';
import * as BarLevel from './barLevel.js';

/**
* Represents a slider UI component extending the BarLevel.
Expand Down
2 changes: 1 addition & 1 deletion packages/gnome-shell/src/ui/status/system.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Clutter from '@girs/clutter-13';
import Gio from '@girs/gio-2.0';
import St from '@girs/st-13';

import { QuickSettingsItem, QuickToggle, SystemIndicator } from '../quickSettings';
import { QuickSettingsItem, QuickToggle, SystemIndicator } from '../quickSettings.js';

declare const BUS_NAME: string;
declare const OBJECT_PATH: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/gnome-shell/src/ui/status/thunderbolt.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import Gio from '@girs/gio-2.0';

import * as Signals from '../../misc/signals';
import { SystemIndicator } from '../quickSettings';
import * as Signals from '../../misc/signals.js';
import { SystemIndicator } from '../quickSettings.js';
import * as MessageTray from '../messageTray.js';

declare const BoltClientInterface: string;
Expand Down
6 changes: 3 additions & 3 deletions packages/gnome-shell/src/ui/status/volume.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import Gio from '@girs/gio-2.0';
import GLib from '@girs/glib-2.0';
import GObject from '@girs/gobject-2.0';
import Gvc from '@girs/gvc-1.0';
import * as Main from '../main';
import * as PopupMenu from '../popupMenu';
import { QuickSlider, SystemIndicator } from '../quickSettings';
import * as Main from '../main.js';
import * as PopupMenu from '../popupMenu.js';
import { QuickSlider, SystemIndicator } from '../quickSettings.js';

declare const ALLOW_AMPLIFIED_VOLUME_KEY = 'allow-volume-above-100-percent';
declare const UNMUTE_DEFAULT_VOLUME = 0.25;
Expand Down

0 comments on commit 537042d

Please sign in to comment.