2023-05-25 21:23:24 +02:00
|
|
|
import Adw from 'gi://Adw?version=1';
|
|
|
|
import GLib from 'gi://GLib';
|
|
|
|
import Gio from 'gi://Gio';
|
|
|
|
import GObject from 'gi://GObject';
|
|
|
|
|
2023-12-19 13:11:11 +01:00
|
|
|
import {setConsoleLogDomain} from 'console';
|
2020-03-19 20:38:16 +01:00
|
|
|
const Package = imports.package;
|
2012-01-18 21:21:56 -05:00
|
|
|
|
2020-03-19 20:38:16 +01:00
|
|
|
Package.initFormat();
|
2012-01-18 21:21:56 -05:00
|
|
|
|
2023-12-19 15:14:19 +01:00
|
|
|
import {ExtensionsWindow} from './extensionsWindow.js';
|
2018-11-01 13:55:17 +01:00
|
|
|
|
2018-09-06 02:55:20 +02:00
|
|
|
const GnomeShellIface = loadInterfaceXML('org.gnome.Shell.Extensions');
|
2012-01-18 21:21:56 -05:00
|
|
|
const GnomeShellProxy = Gio.DBusProxy.makeProxyWrapper(GnomeShellIface);
|
|
|
|
|
2020-03-07 19:26:06 +01:00
|
|
|
function loadInterfaceXML(iface) {
|
2022-02-07 15:14:06 +01:00
|
|
|
const uri = `resource:///org/gnome/Extensions/dbus-interfaces/${iface}.xml`;
|
2020-03-07 19:26:06 +01:00
|
|
|
const f = Gio.File.new_for_uri(uri);
|
|
|
|
|
|
|
|
try {
|
|
|
|
let [ok_, bytes] = f.load_contents(null);
|
2021-08-12 16:38:57 +02:00
|
|
|
return new TextDecoder().decode(bytes);
|
2020-03-07 19:26:06 +01:00
|
|
|
} catch (e) {
|
2023-12-19 13:11:11 +01:00
|
|
|
console.error(`Failed to load D-Bus interface ${iface}`);
|
2020-03-07 19:26:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-10-28 19:35:33 +01:00
|
|
|
var Application = GObject.registerClass(
|
2021-10-04 15:18:51 +02:00
|
|
|
class Application extends Adw.Application {
|
2019-05-28 23:22:37 +02:00
|
|
|
_init() {
|
2020-04-10 04:27:31 +02:00
|
|
|
GLib.set_prgname('gnome-extensions-app');
|
2023-08-07 00:40:20 +02:00
|
|
|
super._init({application_id: Package.name});
|
2020-11-18 02:16:26 +01:00
|
|
|
|
|
|
|
this.connect('window-removed', (a, window) => window.run_dispose());
|
2019-11-30 02:48:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
get shellProxy() {
|
|
|
|
return this._shellProxy;
|
|
|
|
}
|
|
|
|
|
|
|
|
vfunc_activate() {
|
2023-12-19 13:11:11 +01:00
|
|
|
this._shellProxy.CheckForUpdatesAsync().catch(console.error);
|
2019-11-30 02:48:18 +01:00
|
|
|
this._window.present();
|
|
|
|
}
|
|
|
|
|
|
|
|
vfunc_startup() {
|
|
|
|
super.vfunc_startup();
|
|
|
|
|
2022-07-06 14:16:38 +02:00
|
|
|
this.add_action_entries(
|
|
|
|
[{
|
|
|
|
name: 'quit',
|
|
|
|
activate: () => this._window.close(),
|
|
|
|
}]);
|
2020-10-28 21:42:48 +01:00
|
|
|
|
|
|
|
this.set_accels_for_action('app.quit', ['<Primary>q']);
|
|
|
|
|
2020-03-04 05:05:08 +01:00
|
|
|
this._shellProxy = new GnomeShellProxy(Gio.DBus.session,
|
|
|
|
'org.gnome.Shell.Extensions', '/org/gnome/Shell/Extensions');
|
|
|
|
|
2023-08-07 00:40:20 +02:00
|
|
|
this._window = new ExtensionsWindow({application: this});
|
2019-11-30 02:48:18 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-05-25 21:23:24 +02:00
|
|
|
/**
|
2023-07-30 15:56:59 +03:00
|
|
|
* Main entrypoint for the app
|
|
|
|
*
|
2023-05-25 21:23:24 +02:00
|
|
|
* @param {string[]} argv - command line arguments
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
export async function main(argv) {
|
2020-03-19 20:38:16 +01:00
|
|
|
Package.initGettext();
|
2023-12-19 13:11:11 +01:00
|
|
|
setConsoleLogDomain('Extensions');
|
2012-01-18 21:21:56 -05:00
|
|
|
|
2023-05-25 21:23:24 +02:00
|
|
|
await new Application().runAsync(argv);
|
2012-01-18 21:21:56 -05:00
|
|
|
}
|