Files
gnome-shell-extensions/extensions/example/extension.js
Giovanni Campagna 2962768a6f Make extensions translatable
Introduce a translation domain, gnome-shell-extensions, and use it
in extensions that have user-facing strings, instead of abusing
of translations provided by gnome-shell.
Also includes an example translation for italian, and bump the
required version for xrandr-indicator.

Depends on GNOME bug 621017.
2011-02-07 23:06:33 +01:00

25 lines
906 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 = 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(metadata) {
imports.gettext.bindtextdomain('gnome-shell-extensions', metadata.localedir);
Main.panel.actor.reactive = true;
Main.panel.actor.connect('button-release-event', _showHello);
}