import Gio from 'gi://Gio' import Meta from 'gi://Meta' import Shell from 'gi://Shell' import * as Main from '../main.js'; import * as RealmIndicator from './realmIndicator.js'; import * as RealmSwitcher from './realmSwitcher.js'; import * as RealmLabels from './realmLabels.js'; export const RealmManager = class { constructor() { this._realmIndicator = new RealmIndicator.RealmPanelIndicator(); Main.panel.addToStatusArea('RealmIndicator', this._realmIndicator); this._switchAction = Main.wm.addKeybinding('switch-realm', new Gio.Settings({ schema_id: "org.gnome.shell.keybindings"}), Meta.KeyBindingFlags.NONE, Shell.ActionMode.NORMAL, this._switchRealms.bind(this)); this._switchActionBackward = Main.wm.addKeybinding('switch-realm-backward', new Gio.Settings({ schema_id: "org.gnome.shell.keybindings"}), Meta.KeyBindingFlags.IS_REVERSED, Shell.ActionMode.NORMAL, this._switchRealms.bind(this)); const realms = Shell.Realms.get_default(); realms.connect('realm-context-switched', () => { Main.overview.dash._queueRedisplay(); this._realmIndicator.update(); }); realms.connect('notify::current-realm', () => { this._realmIndicator.update(); }); this._switchAnimation = new RealmSwitcher.ContextSwitchAnimationController(this._realmIndicator); this.labelManager = new RealmLabels.RealmLabelManager(); } createRealmLabelForApp(app) { let realmName = app.get_realm_name(); if (this.labelManager.appIconLabelsEnabled() && realmName) { return this.labelManager.createAppIconLabelForRealm(realmName); } else { return null; } } appIconLabelsEnabled() { return this.labelManager.appIconLabelsEnabled(); } animateSwitch(from, to, onComplete) { this._switchAnimation.animateSwitch(from, to, onComplete); } _switchRealms(display, window, binding) { let popup = new RealmSwitcher.SwitchRealmPopup(this._switchAction, this._switchActionBackward); if (!popup.show(binding.is_reversed(), binding.get_name(), binding.get_mask())) popup.fadeAndDestroy(); } };