-
Notifications
You must be signed in to change notification settings - Fork 1
/
secondaryMenu.js
76 lines (69 loc) · 2.67 KB
/
secondaryMenu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Zorin Menu: The official applications menu for Zorin OS.
* Copyright (C) 2017 Zorin OS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* Credits:
* This file is based on code from the Dash to Dock extension by micheleg.
* Some code was adapted from Configurable Menu by lestcape.
*/
const AppDisplay = imports.ui.appDisplay;
const Lang = imports.lang;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Util = imports.misc.util;
/**
* Extend AppIconMenu
*
* - set popup arrow side based on taskbar orientation
* - Add close windows option based on quitfromdash extension
* (https://github.com/deuill/shell-extension-quitfromdash)
*/
const AppItemMenu = new Lang.Class({
Name: 'AppItemMenu',
Extends: AppDisplay.AppIconMenu,
_init: function(source) {
this.parent(source);
},
_addToDesktop: function() {
try {
let app = this._source.app;
let file = Gio.file_new_for_path(app.get_app_info().get_filename());
let path = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP);
let destFile = Gio.file_new_for_path(path + "/" + app.get_id());
file.copy(destFile, 0, null, function(){});
// Need to find a way to do that using the Gio library, but modifying the access::can-execute attribute on the file object seems unsupported
Util.spawnCommandLine("chmod +x \"" + path + "/" + app.get_id() + "\"");
return true;
} catch(e) {
global.log(e);
}
return false;
},
_redisplay: function() {
this.parent();
let app = this._source.app;
let path = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP);
let file = Gio.file_new_for_path(path + "/" + app.get_id());
if (!file.query_exists(null)){
this._appendSeparator();
this._addToDesktopItem = this._appendMenuItem("Add to Desktop");
this._addToDesktopItem.connect('activate', Lang.bind(this, function() {
this._addToDesktop();
}));
}
}
});