Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions files/usr/share/cinnamon/applets/menu@cinnamon.org/appUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const Cinnamon = imports.gi.Cinnamon;
const CMenu = imports.gi.CMenu;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;

let appsys = Cinnamon.AppSystem.get_default();

Expand Down Expand Up @@ -115,3 +117,68 @@ function loadDirectory(dir, top_dir, apps) {
}
return has_entries;
}

function _launchMintinstall(pkgName) {
GLib.spawn_command_line_async(`mintinstall show ${pkgName}`);
}

// launch mintinstall on app page
function launchMintinstallForApp(app) {
if (app.get_is_flatpak()) {
const pkgName = app.get_flatpak_app_id();
_launchMintinstall(pkgName);
} else {
const filePath = app.desktop_file_path;
if (!filePath) return;

const proc = Gio.Subprocess.new(
['dpkg', '-S', filePath],
Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_PIPE
);
proc.communicate_utf8_async(null, null, (obj, res) => {
try {
let [success, stdout, stderr] = obj.communicate_utf8_finish(res);
if (success && stdout) {
const foundPkg = stdout.split(':')[0].trim();
_launchMintinstall(foundPkg);
}
} catch (e) {
global.logError("dpkg check failed: " + e.message);
}
});
}
}

function _launchPamac(pkgName) {
GLib.spawn_command_line_async(`pamac-manager --details=${pkgName}`);
}

// launch pamac-manager on app page
function launchPamacForApp(app) {
if (app.get_is_flatpak()) {
// pamac-manager doesn't open on page of flatpak apps even if flatpak
// is enabled but let's launch it anyway so user can search for it.
const pkgName = app.get_flatpak_app_id();
_launchPamac(pkgName);
} else {
const filePath = app.desktop_file_path;
if (!filePath) return;

const proc = Gio.Subprocess.new(
['pacman', '-Qqo', filePath],
Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_PIPE
);
proc.communicate_utf8_async(null, null, (obj, res) => {
try {
let [success, stdout, stderr] = obj.communicate_utf8_finish(res);
if (success && stdout) {
const foundPkg = stdout.trim();
_launchPamac(foundPkg);
}
} catch (e) {
global.logError("pacman check failed: " + e.message);
}
});
}
}

28 changes: 19 additions & 9 deletions files/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,17 @@ class ApplicationContextMenuItem extends PopupMenu.PopupBaseMenuItem {
this._action = "add_to_favorites";
closeMenu = false;
break;
case "app_info":
if (this._appButton.applet._mintinstallAvailable) {
AppUtils.launchMintinstallForApp(this._appButton.app);
} else if (this._appButton.applet._pamacManagerAvailable) {
AppUtils.launchPamacForApp(this._appButton.app);
}
closeMenu = true;
break;
case "app_properties":
Util.spawnCommandLine("cinnamon-desktop-editor -mlauncher -o" + GLib.shell_quote(this._appButton.app.get_app_info().get_filename()));
break;
case "uninstall":
Util.spawnCommandLine("/usr/bin/cinnamon-remove-application '" + this._appButton.app.get_app_info().get_filename() + "'");
break;
case "offload_launch":
try {
this._appButton.app.launch_offloaded(0, [], -1);
Expand Down Expand Up @@ -530,13 +535,17 @@ class GenericApplicationButton extends SimpleMenuItem {

const appinfo = this.app.get_app_info();

if (appinfo.get_filename() != null) {
menuItem = new ApplicationContextMenuItem(this, _("Properties"), "app_properties", "xsi-document-properties-symbolic");
menu.addMenuItem(menuItem);
if (this.applet._pamacManagerAvailable || this.applet._mintinstallAvailable) {
const filePath = this.app.desktop_file_path;
// Software managers usually only know of system installed apps.
if (!filePath.startsWith("/home/") && !filePath.includes("cinnamon-settings")) {
menuItem = new ApplicationContextMenuItem(this, _("App Info"), "app_info", "xsi-dialog-information-symbolic");
menu.addMenuItem(menuItem);
}
}

if (this.applet._canUninstallApps) {
menuItem = new ApplicationContextMenuItem(this, _("Uninstall"), "uninstall", "xsi-edit-delete");
if (appinfo.get_filename() != null) {
menuItem = new ApplicationContextMenuItem(this, _("Properties"), "app_properties", "xsi-document-properties-symbolic");
menu.addMenuItem(menuItem);
}

Expand Down Expand Up @@ -1229,7 +1238,8 @@ class CinnamonMenuApplet extends Applet.TextIconApplet {
this._activeActor = null;
this._knownApps = new Set(); // Used to keep track of apps that are already installed, so we can highlight newly installed ones
this._appsWereRefreshed = false;
this._canUninstallApps = GLib.file_test("/usr/bin/cinnamon-remove-application", GLib.FileTest.EXISTS);
this._pamacManagerAvailable = GLib.find_program_in_path("pamac-manager");
this._mintinstallAvailable = GLib.find_program_in_path("mintinstall");
this.RecentManager = DocInfo.getDocManager();
this.privacy_settings = new Gio.Settings( {schema_id: PRIVACY_SCHEMA} );
this.noRecentDocuments = true;
Expand Down
Loading