38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
const { Clutter, GObject, Shell, St } = imports.gi;
|
|
const PanelMenu = imports.ui.panelMenu;
|
|
|
|
var RealmPanelIndicator = GObject.registerClass(
|
|
class RealmPanelIndicator extends PanelMenu.Button {
|
|
_init() {
|
|
super._init(0.5, "Current Realm");
|
|
|
|
this._label = new St.Label({
|
|
style_class: 'current-realm-label',
|
|
y_align: Clutter.ActorAlign.CENTER
|
|
});
|
|
this.add_child(this._label);
|
|
|
|
this.update();
|
|
}
|
|
|
|
clear() {
|
|
this._label.set_text('');
|
|
}
|
|
|
|
update() {
|
|
let realm_name = '';
|
|
const realms = Shell.Realms.get_default();
|
|
let current = realms.current_realm;
|
|
if (current) {
|
|
realm_name = current.realm_name;
|
|
this._label.set_text(`realm-${realm_name}`);
|
|
}
|
|
|
|
if (realm_name.length > 0) {
|
|
this._label.set_text(`realm-${realm_name}`);
|
|
} else {
|
|
this._label.set_text('');
|
|
}
|
|
}
|
|
});
|