-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,32 @@ | ||
import '@girs/gjs'; // For global types like `log()` | ||
import St from '@girs/st-14'; | ||
import GObject from '@girs/gobject-2.0'; | ||
|
||
import "@girs/gnome-shell/extensions/global"; // For global shell types | ||
import { Extension, gettext as _ } from '@girs/gnome-shell/extensions/extension'; | ||
import * as panelMenu from '@girs/gnome-shell/ui/panelMenu'; | ||
import { PopupMenuItem } from '@girs/gnome-shell/ui/popupMenu'; | ||
import PanelMenu from '@girs/gnome-shell/ui/panelMenu'; | ||
import * as Main from '@girs/gnome-shell/ui/main'; | ||
|
||
import * as test from '@girs/gnome-shell/extensions'; | ||
export default class ExampleExtension extends Extension { | ||
|
||
const PanelMenuButton = panelMenu.Button; | ||
_indicator: PanelMenu.Button; | ||
|
||
class TIndicator extends PanelMenuButton { | ||
constructor() { | ||
super(0.0, _('My Shiny Indicator')); | ||
} | ||
_init() { | ||
super._init(0.0, _('My Shiny Indicator')); | ||
enable() { | ||
// Create a panel button | ||
this._indicator = new PanelMenu.Button(0.0, this.metadata.name, false); | ||
|
||
this.add_child(new St.Icon({ | ||
iconName: 'face-smile-symbolic', | ||
// Add an icon | ||
const icon = new St.Icon({ | ||
iconName: 'face-laugh-symbolic', | ||
styleClass: 'system-status-icon', | ||
})); | ||
|
||
let item = new PopupMenuItem(_('Show Notification')); | ||
item.connect('activate', () => { | ||
Main.notify(_('Hello %s! :)').format("World")); | ||
}); | ||
this._indicator.add_child(icon); | ||
|
||
this.menu.addMenuItem(item); | ||
} | ||
} | ||
|
||
const Indicator = GObject.registerClass(TIndicator); | ||
|
||
export default class HelloWorldExtension extends Extension { | ||
|
||
_indicator: TIndicator | null = null; | ||
|
||
enable() { | ||
log(`enabling ${JSON.stringify(this.metadata, null, 2)}`); | ||
this._indicator = new Indicator(); | ||
// Add the indicator to the panel | ||
Main.panel.addToStatusArea(this.uuid, this._indicator); | ||
log(`enabled test ${typeof test.extension.gettext}`); | ||
} | ||
|
||
disable() { | ||
Main.panel.remove_child(this._indicator); | ||
this._indicator?.destroy(); | ||
this._indicator = null; | ||
} | ||
} | ||
} |