Skip to content

Commit

Permalink
appIcons: Show app details menu for snap applications
Browse files Browse the repository at this point in the history
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
  • Loading branch information
3v1n0 committed Sep 23, 2024
1 parent f322cc5 commit 1e3f08d
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion appIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {

import {
ParentalControlsManager,
Util,
} from './dependencies/shell/misc.js';

import {
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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', () => {
Expand All @@ -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
Expand Down

0 comments on commit 1e3f08d

Please sign in to comment.