-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
77 lines (63 loc) · 2.09 KB
/
extension.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
77
const Main = imports.ui.main;
const Util = imports.misc.util;
const Lang = imports.lang;
function init() {
this.systemMenu = Main.panel.statusArea['aggregateMenu']._system;
}
function enable() {
this._createActions();
this._removeDefaultButton();
this._addButtons();
}
function disable() {
this._destroyActions();
this._restoreDefaultButton();
}
function _removeDefaultButton() {
this.systemMenu._actionsItem.actor.remove_child(
this.systemMenu._altSwitcher.actor);
}
function _restoreDefaultButton() {
this.systemMenu._actionsItem.actor.add(
this.systemMenu._altSwitcher.actor, { expand: true, x_fill: false });
}
function _addButtons() {
this.systemMenu._actionsItem.actor.add(
this._altRebootAction, { expand: true, x_fill: false });
this.systemMenu._actionsItem.actor.add(
this._altpowerOffAction, { expand: true, x_fill: false });
}
function _createActions() {
this._altRebootAction = this.systemMenu._createActionButton(
'view-refresh-symbolic', "Restart");
this._altRebootActionID = this._altRebootAction.connect(
'clicked', Lang.bind(this, this._onRestartClicked));
this._altpowerOffAction = this.systemMenu._createActionButton(
'system-shutdown-symbolic', "Shutdown");
this._altpowerOffActionId = this._altpowerOffAction.connect(
'clicked', Lang.bind(this, this._onPowerOffClicked));
}
function _destroyActions() {
if (this._altRebootActionId) {
this._altRebootAction.disconnect(this._altRebootActionId);
this._altRebootActionId = 0;
}
if (this._altpowerOffActionId) {
this._altpowerOffAction.disconnect(this._altpowerOffActionId);
this._altpowerOffActionId = 0;
}
if (this._altRebootAction) {
this._altRebootAction.destroy();
this._altRebootAction = 0;
}
if (this._altpowerOffAction) {
this._altpowerOffAction.destroy();
this._altpowerOffAction = 0;
}
}
function _onPowerOffClicked() {
Util.spawnCommandLine("poweroff");
}
function _onRestartClicked() {
Util.spawnCommandLine("reboot");
}