1
我正在尝试使用JavaScript编写扩展。我用Python通过Hello World写了它!码。但是,在一开始,我的菜单项按钮不起作用。另外,我无法在Hello World中添加菜单项!码。我想,我想念一些事情。GNOME外壳扩展按钮
按钮的代码是在这里:
const Lang = imports.lang;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const St = imports.gi.St;
const TimeButton = new Lang.Class({
Name: "Salah Time",
Extends: PanelMenu.Button,
_init: function() {
let box = new St.BoxLayout({
style_class: "system-status-icon"
});
let label = new St.Label({text: "Salah Time"});
box.add_child(label);
this.actor.addActor(box);
}
});
function init() {
}
function enable() {
let but = new TimeButton();
Main.panel._leftBox.insert_child_at_index(but, 1);
}
function disable() {
Main.panel._leftBox.remove_child(but);
}
没有很多教程GJS。我已经试着通过阅读其他扩展来写作。
感谢。