mirror of
https://github.com/Hopiu/RandomWallpaperGnome3.git
synced 2026-05-22 05:41:52 +00:00
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
|
|
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(Math.floor(monitor.width / 2 - text.width / 2),
|
|
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, 2);
|
|
}
|
|
|
|
function disable() {
|
|
Main.panel._rightBox.remove_child(button);
|
|
}
|