1
1
import '@girs/gjs' ; // For global types like `log()`
2
2
import St from '@girs/st-14' ;
3
- import GObject from '@girs/gobject-2.0' ;
4
3
5
4
import "@girs/gnome-shell/extensions/global" ; // For global shell types
6
5
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' ;
9
7
import * as Main from '@girs/gnome-shell/ui/main' ;
10
8
11
- import * as test from '@girs/gnome-shell/extensions' ;
9
+ export default class ExampleExtension extends Extension {
12
10
13
- const PanelMenuButton = panelMenu . Button ;
11
+ _indicator : PanelMenu . Button ;
14
12
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 ) ;
21
16
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' ,
24
20
styleClass : 'system-status-icon' ,
25
- } ) ) ;
26
-
27
- let item = new PopupMenuItem ( _ ( 'Show Notification' ) ) ;
28
- item . connect ( 'activate' , ( ) => {
29
- Main . notify ( _ ( 'Hello %s! :)' ) . format ( "World" ) ) ;
30
21
} ) ;
22
+ this . _indicator . add_child ( icon ) ;
31
23
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
45
25
Main . panel . addToStatusArea ( this . uuid , this . _indicator ) ;
46
- log ( `enabled test ${ typeof test . extension . gettext } ` ) ;
47
26
}
48
27
49
28
disable ( ) {
50
- Main . panel . remove_child ( this . _indicator ) ;
51
29
this . _indicator ?. destroy ( ) ;
52
30
this . _indicator = null ;
53
31
}
54
- }
32
+ }
0 commit comments