Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// 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 Clutter = imports.gi.Clutter;
const Main = imports.ui.main;
function _eatMushroom () {
global.log ("eat mushroom");
let button = Main.panel._clockButton;
let popup = button._calendarPopup.actor;
global.log (popup.get_scale());
if (popup.get_scale()[0] >= 1.5) {
global.log ("< 1.0");
Tweener.addTween (popup, {scale_x: 1.0,
scale_y: 1.0,
time: 1.5,
transition:"linear"});
}
else {
global.log ("> 1.0");
Tweener.addTween (popup, {scale_x: 3.0,
scale_y: 3.0,
time: 1.5,
transition:"linear"});
}
}
function _showHello() {
_eatMushroom();
var icon = new Clutter.Texture ({filename: "/home/yurenju/mario_mushroom.png", reactive: true});
//let text = new St.Label({ style_class: 'helloworld-label',
// text: "Hello, world!" });
icon.opacity = 0;
let monitor = global.get_primary_monitor();
global.stage.add_actor(icon);
icon.set_position
(Math.floor (monitor.width / 2 - icon.width / 2),
Math.floor(monitor.height / 2 - icon.height / 2));
Tweener.addTween (icon, {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 (icon,
{
scale_x: 2,
scale_y: 2,
opacity: 0,
time: 0.2,
transition: "linear",
onComplete: icon.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