mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
Implement gnome-extensions:// protocol.
Add a simple protocol to install extensions. Currently supports gnome-extensions://install?uuid=name@name.com
This commit is contained in:
parent
fcb70ff654
commit
9a63beca91
2 changed files with 48 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ Name=Extensions
|
|||
Icon=@app_id@
|
||||
Comment=Configure GNOME Shell Extensions
|
||||
Exec=@bindir@/@prgname@
|
||||
MimeType=x-scheme-handler/gnome-extensions;
|
||||
DBusActivatable=true
|
||||
Categories=GNOME;GTK;Utility;
|
||||
OnlyShowIn=GNOME;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,10 @@ var Application = GObject.registerClass(
|
|||
class Application extends Gtk.Application {
|
||||
_init() {
|
||||
GLib.set_prgname('gnome-extensions-app');
|
||||
super._init({ application_id: Package.name });
|
||||
super._init({
|
||||
application_id: Package.name,
|
||||
flags: Gio.ApplicationFlags.HANDLES_OPEN,
|
||||
});
|
||||
|
||||
this.connect('window-removed', (a, window) => window.run_dispose());
|
||||
}
|
||||
|
|
@ -55,6 +58,49 @@ class Application extends Gtk.Application {
|
|||
this._window.present();
|
||||
}
|
||||
|
||||
vfunc_open(files) {
|
||||
this.activate();
|
||||
|
||||
let fileUris = files.map(f => f.get_uri());
|
||||
if (fileUris.length !== 1)
|
||||
return;
|
||||
|
||||
const [fileUri] = fileUris;
|
||||
|
||||
try {
|
||||
const uri = GLib.Uri.parse(fileUri, GLib.UriFlags.NONE);
|
||||
|
||||
const scheme = uri.get_scheme();
|
||||
const host = uri.get_host();
|
||||
const params = GLib.Uri.parse_params(uri.get_query(), -1, ';', GLib.UriFlags.NONE);
|
||||
|
||||
if (scheme !== 'gnome-extensions') {
|
||||
log(`Invalid protocol: ${scheme}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (host === 'install' && 'uuid' in params) {
|
||||
const uuid = params['uuid'];
|
||||
this._shellProxy.InstallRemoteExtensionRemote(uuid, (res, error) => {
|
||||
if (res.toString() === 'successful' && !error)
|
||||
log(`Installed ${uuid}`);
|
||||
|
||||
if (!error)
|
||||
return;
|
||||
|
||||
if (error.message.endsWith('404'))
|
||||
log(`Extension not found: ${uuid}`);
|
||||
else
|
||||
log(`Failed to install ${uuid}: ${error.message}`);
|
||||
});
|
||||
} else {
|
||||
log(`Unsupported action or missing parameters: ${host}`);
|
||||
}
|
||||
} catch (e) {
|
||||
logError(e, `Failed to open ${fileUri}`);
|
||||
}
|
||||
}
|
||||
|
||||
vfunc_startup() {
|
||||
super.vfunc_startup();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue