Created
May 28, 2011 18:28
-
-
Save yurenju/997104 to your computer and use it in GitHub Desktop.
add button
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
// 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'}); | |
let btn = new St.Button({style_class: 'panel-button', reactive: true}); | |
btn.set_child(label); | |
btn.connect('button-release-event', _showHello); | |
Main.panel._leftBox.add(btn) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment