2023-09-25 12:59:10 -04:00
|
|
|
import Clutter from 'gi://Clutter'
|
|
|
|
import Gio from 'gi://Gio'
|
|
|
|
import Meta from 'gi://Meta'
|
|
|
|
import Shell from 'gi://Shell'
|
|
|
|
import St from 'gi://St'
|
2021-12-03 14:04:05 -05:00
|
|
|
|
2023-09-25 12:59:10 -04:00
|
|
|
import * as Main from '../main.js';
|
|
|
|
import * as RealmIndicator from './realmIndicator.js';
|
|
|
|
import * as RealmSwitcher from './realmSwitcher.js';
|
|
|
|
import * as Lightbox from '../lightbox.js';
|
|
|
|
import * as RealmSearchProvider from './realmSearchProvider.js';
|
|
|
|
import * as RealmWindowFrame from './realmWindowFrame.js';
|
2021-12-03 14:04:05 -05:00
|
|
|
|
2023-09-25 12:59:10 -04:00
|
|
|
export const RealmManager = class {
|
2021-12-03 14:04:05 -05:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
|
|
|
|
this._switchAnimation = new RealmSwitcher.ContextSwitchAnimationController(this._realmIndicator);
|
|
|
|
|
2021-12-13 11:30:43 -05:00
|
|
|
if (Main.overview._overview) {
|
|
|
|
this._searchResults = Main.overview._overview.controls._searchController._searchResults;
|
|
|
|
this._searchProvider = new RealmSearchProvider.RealmSearchProvider();
|
|
|
|
this._searchProvider.createResultDisplay(this._searchResults);
|
|
|
|
this._searchResults._registerProvider(this._searchProvider);
|
|
|
|
} else {
|
|
|
|
log("Not creating search provider because Main.overview._overview does not exist");
|
|
|
|
}
|
2021-12-03 14:04:05 -05:00
|
|
|
|
|
|
|
this._frameManager = new RealmWindowFrame.WindowFrameManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|