summaryrefslogtreecommitdiffstats
path: root/extension.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2015-05-02 17:48:01 +0200
committerMatěj Cepl <mcepl@cepl.eu>2015-05-02 17:48:01 +0200
commit6cf5b918ad54b4d674b410c6ce27a4bcb704aa76 (patch)
tree128b6981f6412f15e9ddd0045862a8a01965fc82 /extension.js
downloadISS_Above-6cf5b918ad54b4d674b410c6ce27a4bcb704aa76.tar.gz
Foundations.
Diffstat (limited to 'extension.js')
-rw-r--r--extension.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/extension.js b/extension.js
new file mode 100644
index 0000000..260aef7
--- /dev/null
+++ b/extension.js
@@ -0,0 +1,53 @@
+
+const St = imports.gi.St;
+const Main = imports.ui.main;
+const Tweener = imports.ui.tweener;
+
+let text, button;
+
+function _hideHello() {
+ Main.uiGroup.remove_actor(text);
+ text = null;
+}
+
+function _showHello() {
+ if (!text) {
+ text = new St.Label({ style_class: 'helloworld-label', text: "Hello, world!" });
+ Main.uiGroup.add_actor(text);
+ }
+
+ text.opacity = 255;
+
+ let monitor = Main.layoutManager.primaryMonitor;
+
+ text.set_position(monitor.x + Math.floor(monitor.width / 2 - text.width / 2),
+ monitor.y + Math.floor(monitor.height / 2 - text.height / 2));
+
+ Tweener.addTween(text,
+ { opacity: 0,
+ time: 2,
+ transition: 'easeOutQuad',
+ onComplete: _hideHello });
+}
+
+function init() {
+ button = new St.Bin({ style_class: 'panel-button',
+ reactive: true,
+ can_focus: true,
+ x_fill: true,
+ y_fill: false,
+ track_hover: true });
+ let icon = new St.Icon({ icon_name: 'system-run-symbolic',
+ style_class: 'system-status-icon' });
+
+ button.set_child(icon);
+ button.connect('button-press-event', _showHello);
+}
+
+function enable() {
+ Main.panel._rightBox.insert_child_at_index(button, 0);
+}
+
+function disable() {
+ Main.panel._rightBox.remove_child(button);
+}