40 lines
865 B
JavaScript
40 lines
865 B
JavaScript
const St = imports.gi.St;
|
|
const Main = imports.ui.main;
|
|
const Gio = imports.gi.Gio;
|
|
const PanelMenu = imports.ui.panelMenu;
|
|
const PopupMenu = imports.ui.popupMenu;
|
|
|
|
class MyPanelButton extends PanelMenu.Button {
|
|
constructor() {
|
|
super(0.0, 'MyExtension');
|
|
|
|
let icon = new St.Icon({
|
|
icon_name: 'face-smile-symbolic',
|
|
style_class: 'system-status-icon'
|
|
});
|
|
|
|
this.add_child(icon);
|
|
|
|
this.menu.addAction('Click Me', () => {
|
|
Main.notify('Hello from MyExtension!');
|
|
});
|
|
}
|
|
}
|
|
|
|
let myPanelButton;
|
|
|
|
function init() {
|
|
// 初始化代码
|
|
}
|
|
|
|
function enable() {
|
|
myPanelButton = new MyPanelButton();
|
|
Main.panel.addToStatusArea('my-extension', myPanelButton);
|
|
}
|
|
|
|
function disable() {
|
|
if (myPanelButton) {
|
|
myPanelButton.destroy();
|
|
myPanelButton = null;
|
|
}
|
|
} |