42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
import Clutter from 'gi://Clutter';
|
|
import GObject from 'gi://GObject';
|
|
import Shell from 'gi://Shell';
|
|
import St from 'gi://St';
|
|
|
|
import * as PanelMenu from '../panelMenu.js';
|
|
|
|
export const 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('');
|
|
}
|
|
}
|
|
});
|