Skip to content

Instantly share code, notes, and snippets.

@yurenju
Created August 16, 2010 05:27
Show Gist options
  • Save yurenju/526476 to your computer and use it in GitHub Desktop.
Save yurenju/526476 to your computer and use it in GitHub Desktop.
// Sample extension code, makes clicking on the panel show a message
const St = imports.gi.St;
const Mainloop = imports.mainloop;
const Tweener = imports.ui.tweener;
const Main = imports.ui.main;
function _showHello() {
let text = new St.Label({ style_class: 'helloworld-label',
text: "Hello, world!" });
text.opacity = 0;
let monitor = global.get_primary_monitor();
global.stage.add_actor(text);
text.set_position
(Math.floor (monitor.width / 2 - text.width / 2),
Math.floor(monitor.height / 2 - text.height / 2));
Tweener.addTween (text, {opacity:255,
time: 1.5,
transition:"linear"});
global.get_windows ().forEach (function (w) {
Tweener.addTween (w,
{time: 1.5, transition: "linear",
scale_x: 0.3,
scale_y: 0.3,
opacity: 50});
});
Mainloop.timeout_add(3000, function () {
Tweener.addTween (text,
{
scale_x: 2,
scale_y: 2,
opacity: 0,
time: 0.2,
transition: "linear",
onComplete: text.destroy
}
);
global.get_windows ().forEach (function (w) {
Tweener.addTween (w, {time: 0.2, transition: "linear",
scale_x: 1,
scale_y: 1,
opacity: 255});
});
});
}
// Put your extension initialization code here
function main() {
Main.panel.actor.reactive = true;
Main.panel.actor.connect('button-release-event', _showHello);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment