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。我已經試着通過閱讀其他擴展來寫作。
感謝。