const St = imports.gi.St;
const Main = imports.ui.main;
const Lang = imports.lang;
const Clutter = imports.gi.Clutter;
const PanelMenu = imports.ui.panelMenu;
const TestIndicator = new Lang.Class({
Name: 'TestIndicator',
Extends: PanelMenu.Button,
_init: function () {
this.parent(0.0, "Test Indicator", false);
this.buttonText = new St.Label({
text: _("Test..."),
y_align: Clutter.ActorAlign.CENTER
});
this.actor.connect('button-press-event', this._showData);
//this.actor.connect('enter-event', this._showData);
this.actor.connect('leave-event', this._hideData);
this.actor.add_actor(this.buttonText);
},
_showData: function () {
this.label = new St.Label({ style_class: 'test-label', text: "TEST" });
let monitor = Main.layoutManager.primaryMonitor;
this.label.set_position(Math.floor(monitor.width / 2 - this.label.width / 2),
Math.floor(monitor.height / 2 - this.label.height / 2));
Main.uiGroup.add_actor(this.label);
},
_hideData: function () {
if (Main.uiGroup.contains(this.label)) {
Main.uiGroup.remove_actor(this.label);
}
},
stop: function() {
this.menu.removeAll();
}
});
function init() {
}
function enable() {
testIndicator = new TestIndicator;
Main.panel.addToStatusArea('test-indicator', testIndicator);
}
function disable() {
testIndicator.stop();
testIndicator.destroy();
}
=============
metadata.json
==============
{"shell-version": ["3.10", "3.14", "3.18"], "uuid": "test", "name": "test", "description": "shows test label"}
==============
stylesheet.css
==============
.test-label {
font-size: 36px;
font-weight: bold;
color: #DC143C;
background-color: rgba(10,10,10,0.7);
border-radius: 5px;
padding: .5em;
}