Skip to content

Commit 5fbf4fd

Browse files
committed
Migrated from gi-types to girs
1 parent 42b01b6 commit 5fbf4fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1036
-766
lines changed

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@
5050
"typescript": "^4.8.4"
5151
},
5252
"dependencies": {
53-
"@gi-types/adw1": "^1.1.1",
54-
"@gi-types/clutter10": "^10.0.1",
55-
"@gi-types/gdk4": "^4.0.1",
56-
"@gi-types/gdkpixbuf2": "^2.0.2",
57-
"@gi-types/gio2": "^2.72.1",
58-
"@gi-types/glib2": "^2.72.1",
59-
"@gi-types/gobject2": "^2.72.1",
60-
"@gi-types/gtk4": "^4.6.1",
61-
"@gi-types/soup2": "^2.74.1",
62-
"@gi-types/soup3": "^3.0.1",
63-
"@gi-types/st1": "^1.0.1"
53+
"@girs/adw-1": "^1.4.3-3.2.9",
54+
"@girs/clutter-10": "^10.0.0-3.2.9",
55+
"@girs/gdk-4.0": "^4.0.0-3.2.9",
56+
"@girs/gdkpixbuf-2.0": "^2.0.0-3.2.9",
57+
"@girs/gio-2.0": "^2.78.0-3.2.9",
58+
"@girs/glib-2.0": "^2.78.0-3.2.9",
59+
"@girs/gobject-2.0": "^2.78.0-3.2.9",
60+
"@girs/gtk-4.0": "^4.12.5-3.2.9",
61+
"@girs/soup-2.4": "^2.74.3-3.2.9",
62+
"@girs/soup-3.0": "^3.4.4-3.2.9",
63+
"@girs/st-1.0": "^1.0.0-3.2.9"
6464
}
6565
}

rollup.config.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ const metadata: ExtensionMetadata = JSON.parse(data) as ExtensionMetadata;
2424

2525
const globals = {
2626
// Dirty hack to make class that require Adwaita to work even in Gnome < 42
27-
'@gi-types/adw1': 'imports.gi.versions.Adw ? imports.gi.Adw : { ActionRow: imports.gi.Gtk.Widget }',
28-
'@gi-types/clutter10': 'imports.gi.Clutter',
29-
'@gi-types/gdk4': 'imports.gi.Gdk',
30-
'@gi-types/gdkpixbuf2': 'imports.gi.GdkPixbuf',
31-
'@gi-types/gio2': 'imports.gi.Gio',
32-
'@gi-types/glib2': 'imports.gi.GLib',
33-
'@gi-types/gobject2': 'imports.gi.GObject',
34-
'@gi-types/gtk4': 'imports.gi.Gtk',
35-
'@gi-types/soup2': 'imports.gi.Soup',
36-
'@gi-types/soup3': 'imports.gi.Soup',
37-
'@gi-types/st1': 'imports.gi.St',
27+
'@girs/adw-1': 'imports.gi.versions.Adw ? imports.gi.Adw : { ActionRow: imports.gi.Gtk.Widget }',
28+
'@girs/clutter-10': 'imports.gi.Clutter',
29+
'@girs/gdk-4.0': 'imports.gi.Gdk',
30+
'@girs/gdkpixbuf-2.0': 'imports.gi.GdkPixbuf',
31+
'@girs/gio-2.0': 'imports.gi.Gio',
32+
'@girs/glib-2.0': 'imports.gi.GLib',
33+
'@girs/gobject-2.0': 'imports.gi.GObject',
34+
'@girs/gtk-4.0': 'imports.gi.Gtk',
35+
'@girs/soup-2.4': 'imports.gi.Soup',
36+
'@girs/soup-3.0': 'imports.gi.Soup',
37+
'@girs/st-1.0': 'imports.gi.St',
3838
'@gnome-shell/misc/extensionUtils': 'imports.misc.extensionUtils',
3939
'@gnome-shell/ui': 'imports.ui',
4040
'@gnome-shell/ui/panel': 'imports.ui.panel',

src/main/types/gnome-shell/misc/extensionUtils.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { File, Settings } from '@gi-types/gio2';
1+
import Gio from '@girs/gio-2.0';
22

33
export interface ExtensionMetadata {
44
uuid: string;
@@ -15,7 +15,7 @@ export interface Extension {
1515
metadata: ExtensionMetadata;
1616
uuid: string;
1717
type: number;
18-
dir: File;
18+
dir: Gio.File;
1919
path: string;
2020
error: string;
2121
hasPrefs: boolean;
@@ -27,4 +27,4 @@ export interface Extension {
2727
export function initTranslations(domain: string): void;
2828
export function openPrefs(): void;
2929
export function getCurrentExtension(): Extension;
30-
export function getSettings(name?: string): Settings;
30+
export function getSettings(name?: string): Gio.Settings;
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { Actor } from '@gi-types/clutter10';
2-
import { Icon } from '@gi-types/gio2';
3-
import { DateTime } from '@gi-types/glib2';
4-
import { Object as GObject } from '@gi-types/gobject2';
5-
import { Button, Widget } from '@gi-types/st1';
1+
import Clutter from '@girs/clutter-10';
2+
import Gio from '@girs/gio-2.0';
3+
import GLib from '@girs/glib-2.0';
4+
import GObject from '@girs/gobject-2.0';
5+
import St from '@girs/st-1.0';
66

77
export interface NotificationProperties {
8-
gicon: Icon;
9-
secondaryGIcon: Icon;
8+
gicon: Gio.Icon;
9+
secondaryGIcon: Gio.Icon;
1010
bannerMarkup: boolean;
1111
clear: boolean;
12-
datetime: DateTime;
12+
datetime: GLib.DateTime;
1313
soundName: string;
1414
soundFile: string;
1515
}
1616

17-
export class Notification extends GObject {
17+
export class Notification extends GObject.Object {
1818
public constructor(source: Source, title: string, banner: string, params?: Partial<NotificationProperties>);
1919

2020
public title: string;
@@ -33,18 +33,18 @@ export class Notification extends GObject {
3333

3434
// NotificationBanner actually extends Calendar.NotificationMessage but it's not needed for this project
3535
export class NotificationBanner {
36-
public addButton(button: Button, callback: () => void): Button;
37-
public addAction(label: string, callback: () => void): Button;
36+
public addButton(button: St.Button, callback: () => void): St.Button;
37+
public addAction(label: string, callback: () => void): St.Button;
3838
}
3939

40-
export class Source extends GObject {
40+
export class Source extends GObject.Object {
4141
public notifications: Notification[];
4242

4343
public constructor(title: string, iconName: string);
4444

4545
public open(): void;
4646
public destroy(reson?: string): void;
47-
public getIcon(): Icon;
47+
public getIcon(): Gio.Icon;
4848

4949
public showNotification(notification: Notification): void;
5050
public pushNotification(notification: Notification): void;
@@ -56,7 +56,7 @@ export class SystemNotificationSource extends Source {
5656
public constructor();
5757
}
5858

59-
export interface MessageTray extends Widget {
59+
export interface MessageTray extends St.Widget {
6060
add(source: Source): void;
61-
contains(source: Source | Actor): boolean;
61+
contains(source: Source | Clutter.Actor): boolean;
6262
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { BoxLayout, Widget } from '@gi-types/st1';
1+
import St from '@girs/st-1.0';
22

33
import { Button } from './panelMenu';
44

5-
export interface Panel extends Widget {
6-
_rightBox: BoxLayout;
5+
export interface Panel extends St.Widget {
6+
_rightBox: St.BoxLayout;
77

88
addToStatusArea(role: string, indicator: Button, position?: number, box?: number): Button;
99
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Widget } from '@gi-types/st1';
1+
import St from '@girs/st-1.0';
22

3-
export class ButtonBox extends Widget {}
3+
export class ButtonBox extends St.Widget {}
44

55
export class Button extends ButtonBox {
66
public constructor(menuAlignment: number, nameText: string, dontCreateMenu: boolean);
7-
public add_actor(widget: Widget): void;
7+
public add_actor(widget: St.Widget): void;
88
}

src/main/typescript/client/Soup2HttpEngine.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
import { MemoryUse, Message, Session, URI } from '@gi-types/soup2';
1+
import Soup from '@girs/soup-2.4';
22

33
import { HttpEngine, HttpRequest, HttpResponse } from './Http';
44

55
export class Soup2HttpEngine implements HttpEngine {
6-
private readonly session: Session;
6+
private readonly session: Soup.Session;
77

88
public constructor(userAgent: string) {
9-
this.session = new Session();
10-
this.session.user_agent = `${userAgent} via Soup2`;
9+
this.session = new Soup.Session();
10+
this.session.userAgent = `${userAgent} via Soup2`;
1111
}
1212

1313
public send(request: HttpRequest): Promise<HttpResponse> {
14-
const soupUri = URI.new(request.url);
15-
const message = new Message({ method: request.method, uri: soupUri });
14+
const soupUri = Soup.URI.new(request.url);
15+
const message = new Soup.Message({ method: request.method, uri: soupUri });
1616

1717
// Set the headers
1818
request.headers.forEach((value: string, name: string) => message.requestHeaders.append(name, value));
1919

2020
// Set the request body, if available
2121
if (request.body !== undefined) {
2222
const encoder = new TextEncoder();
23-
message.set_request(request.body.contentType, MemoryUse.COPY, encoder.encode(request.body.data));
23+
message.set_request(request.body.contentType, Soup.MemoryUse.COPY, encoder.encode(request.body.data));
2424
}
2525

2626
return new Promise<HttpResponse>((resolve, reject) => {
2727
try {
28-
this.session.queue_message(message, (_: Session, msg: Message) => {
28+
this.session.queue_message(message, (_: Soup.Session, msg: Soup.Message) => {
2929
const headers = new Map<string, string>();
3030
msg.requestHeaders.foreach((name, value) => headers.set(name, value));
3131

src/main/typescript/client/Soup3HttpEngine.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
import { Bytes, PRIORITY_DEFAULT, Uri } from '@gi-types/glib2';
2-
import { HTTP_URI_FLAGS, Message, Session } from '@gi-types/soup3';
1+
import GLib from '@girs/glib-2.0';
2+
import Soup from '@girs/soup-3.0';
33

44
import { HttpEngine, HttpRequest, HttpResponse } from './Http';
55

66
export class Soup3HttpEngine implements HttpEngine {
7-
private readonly session: Session;
7+
private readonly session: Soup.Session;
88

99
public constructor(userAgent: string) {
10-
this.session = new Session();
11-
this.session.user_agent = `${userAgent} via Soup3`;
10+
this.session = new Soup.Session();
11+
this.session.userAgent = `${userAgent} via Soup3`;
1212
}
1313

1414
public async send(request: HttpRequest): Promise<HttpResponse> {
15-
const message = Message.new_from_uri(request.method, Uri.parse(request.url, HTTP_URI_FLAGS));
15+
const message = Soup.Message.new_from_uri(request.method, GLib.Uri.parse(request.url, Soup.HTTP_URI_FLAGS));
1616

1717
// Set the headers
1818
request.headers.forEach((value: string, name: string) => message.requestHeaders.append(name, value));
1919

2020
// Set the request body, if available
2121
if (request.body !== undefined) {
2222
const encoder = new TextEncoder();
23-
message.set_request_body_from_bytes(request.body.contentType, new Bytes(encoder.encode(request.body.data)));
23+
message.set_request_body_from_bytes(
24+
request.body.contentType,
25+
new GLib.Bytes(encoder.encode(request.body.data))
26+
);
2427
}
2528

2629
const responseBody: string = await this.session
27-
.send_and_read_async(message, PRIORITY_DEFAULT, null)
30+
.send_and_read_async(message, GLib.PRIORITY_DEFAULT, null)
2831
.then((bytes) => bytes.get_data() ?? new Uint8Array())
2932
.then((data) => new TextDecoder('utf-8').decode(data));
3033

src/main/typescript/core/GitHubManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Icon, icon_new_for_string } from '@gi-types/gio2';
1+
import Gio from '@girs/gio-2.0';
22
import { getCurrentExtension, getSettings } from '@gnome-shell/misc/extensionUtils';
33

44
import { NotificationController } from '@github-manager/notifications';
@@ -10,7 +10,7 @@ export class GitHubManager implements Disposable {
1010
@lazy
1111
private static readonly LOGGER: Logger = new Logger('core::GitHubManager');
1212

13-
private readonly githubIcon: Icon;
13+
private readonly githubIcon: Gio.Icon;
1414

1515
private readonly eventDispatcher: EventDispatcher;
1616

@@ -23,7 +23,7 @@ export class GitHubManager implements Disposable {
2323
public constructor() {
2424
GitHubManager.LOGGER.trace('Building and wiring components');
2525

26-
this.githubIcon = icon_new_for_string(`${getCurrentExtension().path}/github.svg`);
26+
this.githubIcon = Gio.icon_new_for_string(`${getCurrentExtension().path}/github.svg`);
2727

2828
this.eventDispatcher = new EventDispatcher();
2929
this.settings = new SettingsWrapper(getSettings(), this.eventDispatcher);

src/main/typescript/index.d.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import GObject from '@girs/gobject-2.0';
2+
13
export {};
24

35
declare global {
@@ -15,18 +17,3 @@ declare global {
1517
export function log(message: string): void;
1618
export function logError(e: unknown, message: string): void;
1719
}
18-
19-
declare module '@gi-types/gobject2' {
20-
export interface MetaInfo {
21-
GTypeName: string;
22-
GTypeFlags?: TypeFlags;
23-
Implements?: { $gtype: GType }[];
24-
Properties?: Record<string, ParamSpec>;
25-
Signals?: Record<string, SignalDefinition>;
26-
Requires?: { $gtype: GType }[];
27-
CssName?: string;
28-
Template?: string;
29-
Children?: string[];
30-
InternalChildren?: string[];
31-
}
32-
}

0 commit comments

Comments
 (0)