Retrieve Convenience from the extension helper object (Me), and pass no arguments to initTranslations and getSettings (since the metadata has all that is required)
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
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;
|
|
|
|
const ExtensionUtils = imports.misc.extensionUtils;
|
|
const Me = ExtensionUtils.getCurrentExtension();
|
|
const Convenience = Me.imports.convenience;
|
|
|
|
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 init(metadata) {
|
|
log ('Example extension initalized');
|
|
|
|
Convenience.initTranslations();
|
|
}
|
|
|
|
let signalId;
|
|
|
|
function enable() {
|
|
log ('Example extension enabled');
|
|
|
|
Main.panel.actor.reactive = true;
|
|
signalId = Main.panel.actor.connect('button-release-event', _showHello);
|
|
}
|
|
|
|
function disable() {
|
|
log ('Example extension disabled');
|
|
|
|
if (signalId) {
|
|
Main.panel.actor.disconnect(signalId);
|
|
signalId = 0;
|
|
}
|
|
}
|