-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.js
65 lines (53 loc) · 1.64 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
/** AUTHOR: Ostanin Dmitry **/
const St = imports.gi.St;
const Main = imports.ui.main;
const Tweener = imports.ui.tweener;
const PopupMenu = imports.ui.popupMenu;
const Switcher = imports.ui.switcherPopup;
const Util = imports.misc.util;
const Extension = imports.misc.extensionUtils.getCurrentExtension();
const Config = Extension.imports.config;
let textbox, switcher, config;
function _showTextbox(textmsg) {
if(!textbox) {
textbox = new St.Label({ style_class: 'textbox-label', text: "Hello, world!" });
Main.uiGroup.add_actor(textbox);
}
textbox.text = textmsg;
textbox.opacity = 255;
let monitor = Main.layoutManager.primaryMonitor;
textbox.set_position(Math.floor(monitor.width / 2 - textbox.width / 2),
Math.floor(monitor.height / 2 - textbox.height / 2));
Tweener.addTween(textbox,
{ opacity: 0,
time: 2,
transition: 'easeOutQuad',
onComplete: _hideTextbox });
}
function _hideTextbox() {
Main.uiGroup.remove_actor(textbox);
textbox = null;
}
function _onRouter() {
if(switcher.state) {
Util.spawnCommandLine('i2prouter', 'start');
_showTextbox(_("I2P вкл."));
} else {
Util.spawnCommandLine('i2prouter', 'stop');
_showTextbox(_("I2P выкл."));
}
}
function init() {
config = new Config.Config();
}
function enable() {
switcher = new PopupMenu.PopupSwitchMenuItem('');
//switcher.icon.icon_name = '';
switcher.label.text = 'I2P';
switcher.connect('toggled', _onRouter);
let statusMenu = Main.panel.statusArea.aggregateMenu._network;
statusMenu.menu.addMenuItem(switcher);
}
function disable() {
switcher.destroy();
}