diff --git a/subprojects/extensions-app/data/org.gnome.Extensions.desktop.in.in b/subprojects/extensions-app/data/org.gnome.Extensions.desktop.in.in index a935780b7df3571892080db68a0dd548bde88eeb..3a1d4d961714c60609fac16d9be233514b931ba3 100644 --- a/subprojects/extensions-app/data/org.gnome.Extensions.desktop.in.in +++ b/subprojects/extensions-app/data/org.gnome.Extensions.desktop.in.in @@ -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; diff --git a/subprojects/extensions-app/js/main.js b/subprojects/extensions-app/js/main.js index d4b6ec79fde377748f4ec07e310dda7d906a1546..a691cac93089be55b52b0274a2dc920729c6186c 100644 --- a/subprojects/extensions-app/js/main.js +++ b/subprojects/extensions-app/js/main.js @@ -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();