Created
May 28, 2011 19:08
-
-
Save yurenju/997127 to your computer and use it in GitHub Desktop.
panel menu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!" }); | |
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)); | |
Mainloop.timeout_add(3000, function () { text.destroy(); }); | |
} | |
function _rotateDate() { | |
let t = Main.panel._dateMenu.actor; | |
Tweener.addTween(t, | |
{ time: 2.0, | |
rotation_angle_z: t.rotation_angle_z+360 | |
}); | |
} | |
function HelloPanelButton() { | |
this._init(); | |
} | |
HelloPanelButton.prototype = { | |
__proto__: PanelMenu.Button.prototype, | |
_init: function() { | |
PanelMenu.Button.prototype._init.call(this, 0.0); | |
let btn = new St.Label({text: 'hello'}); | |
this.actor.set_child(btn); | |
let box = new St.BoxLayout({vertical: true}); | |
this.menu.addActor(box); | |
let item = new PopupMenu.PopupMenuItem('hello'); | |
item.connect('activate', _showHello); | |
box.add(item.actor); | |
item = new PopupMenu.PopupMenuItem('rotate'); | |
item.connect('activate', _rotateDate); | |
box.add(item.actor); | |
}, | |
}; | |
function main() { | |
let hbtn = new HelloPanelButton(); | |
Main.panel._leftBox.add(hbtn.actor); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment