Skip to content

Commit 3396b8d

Browse files
committed
Update example
1 parent e42efd8 commit 3396b8d

File tree

1 file changed

+12
-34
lines changed

1 file changed

+12
-34
lines changed

Diff for: examples/hello-world/src/extension.ts

+12-34
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,32 @@
11
import '@girs/gjs'; // For global types like `log()`
22
import St from '@girs/st-14';
3-
import GObject from '@girs/gobject-2.0';
43

54
import "@girs/gnome-shell/extensions/global"; // For global shell types
65
import { Extension, gettext as _ } from '@girs/gnome-shell/extensions/extension';
7-
import * as panelMenu from '@girs/gnome-shell/ui/panelMenu';
8-
import { PopupMenuItem } from '@girs/gnome-shell/ui/popupMenu';
6+
import PanelMenu from '@girs/gnome-shell/ui/panelMenu';
97
import * as Main from '@girs/gnome-shell/ui/main';
108

11-
import * as test from '@girs/gnome-shell/extensions';
9+
export default class ExampleExtension extends Extension {
1210

13-
const PanelMenuButton = panelMenu.Button;
11+
_indicator: PanelMenu.Button;
1412

15-
class TIndicator extends PanelMenuButton {
16-
constructor() {
17-
super(0.0, _('My Shiny Indicator'));
18-
}
19-
_init() {
20-
super._init(0.0, _('My Shiny Indicator'));
13+
enable() {
14+
// Create a panel button
15+
this._indicator = new PanelMenu.Button(0.0, this.metadata.name, false);
2116

22-
this.add_child(new St.Icon({
23-
iconName: 'face-smile-symbolic',
17+
// Add an icon
18+
const icon = new St.Icon({
19+
iconName: 'face-laugh-symbolic',
2420
styleClass: 'system-status-icon',
25-
}));
26-
27-
let item = new PopupMenuItem(_('Show Notification'));
28-
item.connect('activate', () => {
29-
Main.notify(_('Hello %s! :)').format("World"));
3021
});
22+
this._indicator.add_child(icon);
3123

32-
this.menu.addMenuItem(item);
33-
}
34-
}
35-
36-
const Indicator = GObject.registerClass(TIndicator);
37-
38-
export default class HelloWorldExtension extends Extension {
39-
40-
_indicator: TIndicator | null = null;
41-
42-
enable() {
43-
log(`enabling ${JSON.stringify(this.metadata, null, 2)}`);
44-
this._indicator = new Indicator();
24+
// Add the indicator to the panel
4525
Main.panel.addToStatusArea(this.uuid, this._indicator);
46-
log(`enabled test ${typeof test.extension.gettext}`);
4726
}
4827

4928
disable() {
50-
Main.panel.remove_child(this._indicator);
5129
this._indicator?.destroy();
5230
this._indicator = null;
5331
}
54-
}
32+
}

0 commit comments

Comments
 (0)