Created
May 28, 2011 18:19
-
-
Save yurenju/997093 to your computer and use it in GitHub Desktop.
add label to panel
This file contains 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
// 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); | |
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(); }); | |
} | |
// Put your extension initialization code here | |
function main() { | |
let label = new St.Label({text: 'hello', reactive: true}); | |
label.connect('button-release-event', _showHello); | |
Main.panel._leftBox.add(label) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment