This method has been removed from master, and replaced by Main.layoutManager.primaryMonitor
25 lines
911 B
JavaScript
25 lines
911 B
JavaScript
// Sample extension code, makes clicking on the panel show a message
|
|
const St = imports.gi.St;
|
|
const Mainloop = imports.mainloop;
|
|
|
|
const Gettext = imports.gettext.domain('gnome-shell-extensions');
|
|
const _ = Gettext.gettext;
|
|
|
|
const Main = imports.ui.main;
|
|
|
|
function _showHello() {
|
|
let text = new St.Label({ style_class: 'helloworld-label', text: _("Hello, world!") });
|
|
let monitor = Main.layoutManager.primaryMonitor;
|
|
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(metadata) {
|
|
imports.gettext.bindtextdomain('gnome-shell-extensions', metadata.localedir);
|
|
|
|
Main.panel.actor.reactive = true;
|
|
Main.panel.actor.connect('button-release-event', _showHello);
|
|
}
|