-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathextension.js
55 lines (39 loc) · 1.08 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
const St = imports.gi.St;
const Main = imports.ui.main;
const Lang = imports.lang;
const PanelMenu = imports.ui.panelMenu;
const Clutter = imports.gi.Clutter;
const Mainloop = imports.mainloop;
let coord;
const CoordManager = new Lang.Class({
Name: 'CoordManager',
Extends: PanelMenu.Button,
_init: function() {
this.parent(0.0, "Coordinates");
this.label = new St.Label({
text: "XY",
y_expand: true,
y_align: Clutter.ActorAlign.CENTER
});
this.actor.add_actor(this.label);
Mainloop.timeout_add(100, Lang.bind(this, this.update_label));
},
update_label: function() {
let [mouse_x, mouse_y, mask] = global.get_pointer();
let newLabel = "X: " + mouse_x + " Y: " + mouse_y;
this.label.set_text(newLabel);
return true;
},
destroy: function() {
this.parent();
},
});
function init() {
}
function enable() {
coord = new CoordManager();
Main.panel.addToStatusArea('coord-menu', coord, 1, 'right');
}
function disable() {
coord.destroy();
}