From 1e3f08df1ebdd6889f91246ff42b8058d888a786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 16 Sep 2024 23:10:44 +0200 Subject: [PATCH] appIcons: Show app details menu for snap applications If an application is a snap package, and the snap store is installed we can show the snap packages details as we do for other non-snap applications if GNOME Software is installed --- appIcons.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/appIcons.js b/appIcons.js index e26e3d7f1..14dab07e4 100644 --- a/appIcons.js +++ b/appIcons.js @@ -22,6 +22,7 @@ import { import { ParentalControlsManager, + Util, } from './dependencies/shell/misc.js'; import { @@ -937,6 +938,10 @@ const DockAbstractAppIcon = GObject.registerClass({ return [...new Set([...this._urgentWindows, ...interestingWindows])]; } + + getSnapName() { + return this.app.appInfo?.get_string('X-SnapInstanceName'); + } }); const DockAppIcon = GObject.registerClass({ @@ -1184,7 +1189,8 @@ const DockAppIconMenu = class DockAppIconMenu extends PopupMenu.PopupMenu { } if (Shell.AppSystem.get_default().lookup_app('org.gnome.Software.desktop') && - (this.sourceActor instanceof DockAppIcon)) { + this.sourceActor instanceof DockAppIcon && + !this.sourceActor.getSnapName()) { this._appendSeparator(); const item = this._appendMenuItem(_('App Details')); item.connect('activate', () => { @@ -1203,6 +1209,24 @@ const DockAppIconMenu = class DockAppIconMenu extends PopupMenu.PopupMenu { }); }); } + + if (this.sourceActor instanceof DockAppIcon) { + const snapName = this.sourceActor.getSnapName(); + const snapStore = snapName + ? Shell.AppSystem.get_default().lookup_app( + 'snap-store_snap-store.desktop') : null; + + if (snapStore) { + this._appendSeparator(); + const item = this._appendMenuItem(_('App Details')); + item.connect('activate', (_, event) => { + snapStore.activate_full(-1, event.get_time()); + Util.spawnApp( + [...snapStore.appInfo.get_commandline().split(' '), snapName]); + Main.overview.hide(); + }); + } + } } // dynamic menu