Skip to content

Instantly share code, notes, and snippets.

@yurenju
yurenju / gist:994377
Created May 26, 2011 23:48
clutter-basic
const Clutter = imports.gi.Clutter;
Clutter.init(0, null);
let stage = new Clutter.Stage();
let texture = new Clutter.Texture({ filename: 'test.jpg',
reactive: true });
stage.add_actor(texture);
stage.show();
Clutter.main();
const Clutter = imports.gi.Clutter;
const Tweener = imports.tweener.tweener;
function click(actor, ev) {
let properties = { time: 1.0,
x: texture.x+100,
y: texture.y+100,
scale_x: texture.scale_x*0.8,
scale_y: texture.scale_y*0.8,
opacity: texture.opacity*0.8
@yurenju
yurenju / gist:996736
Created May 28, 2011 09:22
delay, onComplete
const Clutter = imports.gi.Clutter;
const Tweener = imports.tweener.tweener;
function click(actor, ev) {
if (ev.get_button() == 1) {
Tweener.addTween(t, {time: 1.0, x: t.x+100});
Tweener.addTween(t, {time: 1.0, y: t.y+100, delay: 1.0});
Tweener.addTween(t, {time: 1.0, scale_x:t.scale_x*0.5, delay: 2.0});
}
else {
@yurenju
yurenju / gist:996839
Created May 28, 2011 12:48
transition
const Clutter = imports.gi.Clutter;
const Tweener = imports.tweener.tweener;
/*
easeInQuad, easeOutQuad, easeInOutQuad
easeInCubic, easeOutCubic, easeInOutCubic
easeInQuart, easeOutQuart, easeInOutQuart
easeInQuint, easeOutQuint, easeInOutQuint
easeInSine, easeOutSine, easeInOutSine
@yurenju
yurenju / gist:996870
Created May 28, 2011 13:45
default gnome-shell extension
// Sample extension code, makes clicking on the panel show a message
const St = imports.gi.St;
const Mainloop = imports.mainloop;
const Main = imports.ui.main;
function _showHello() {
let text = new St.Label({ style_class: 'helloworld-label',
text: "Hello, world!" });
let monitor = global.get_primary_monitor();
@yurenju
yurenju / gist:997043
Created May 28, 2011 17:21
default stylesheet
/* Example stylesheet */
.helloworld-label {
font-size: 36px;
font-weight: bold;
color: #ffffff;
background-color: rgba(10,10,10,0.7);
border-radius: 5px;
}
@yurenju
yurenju / gist:997093
Created May 28, 2011 18:19
add label to panel
// Sample extension code, makes clicking on the panel show a message
const St = imports.gi.St;
const Mainloop = imports.mainloop;
const Main = imports.ui.main;
function _showHello() {
let text = new St.Label({ style_class: 'helloworld-label',
text: "Hello, world!" });
let monitor = global.get_primary_monitor();
global.stage.add_actor(text);
@yurenju
yurenju / gist:997104
Created May 28, 2011 18:28
add button
// Sample extension code, makes clicking on the panel show a message
const St = imports.gi.St;
const Mainloop = imports.mainloop;
const Main = imports.ui.main;
function _showHello() {
let text = new St.Label({ style_class: 'helloworld-label',
text: "Hello, world!" });
let monitor = global.get_primary_monitor();
global.stage.add_actor(text);
@yurenju
yurenju / gist:997116
Created May 28, 2011 18:43
PanelButton
const St = imports.gi.St;
const PanelMenu = imports.ui.panelMenu;
const Main = imports.ui.main;
function HelloPanelButton() {
this._init();
}
HelloPanelButton.prototype = {
__proto__: PanelMenu.Button.prototype,
@yurenju
yurenju / gist:997127
Created May 28, 2011 19:08
panel menu
const St = imports.gi.St;
const Mainloop = imports.mainloop;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const Main = imports.ui.main;
const Tweener = imports.tweener.tweener;
function _showHello() {
let text = new St.Label({ style_class: 'helloworld-label',
text: "Hello, world!" });