2021-12-03 19:04:05 +00:00
|
|
|
const { Clutter, Gio, Meta, Shell, St } = imports.gi;
|
|
|
|
|
|
|
|
const Main = imports.ui.main;
|
|
|
|
const RealmIndicator = imports.ui.realms.realmIndicator;
|
|
|
|
const RealmSwitcher = imports.ui.realms.realmSwitcher;
|
|
|
|
const Lightbox = imports.ui.lightbox;
|
|
|
|
const RealmSearchProvider = imports.ui.realms.realmSearchProvider;
|
|
|
|
const RealmWindowFrame = imports.ui.realms.realmWindowFrame;
|
|
|
|
|
|
|
|
var 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();
|
|
|
|
});
|
|
|
|
|
|
|
|
this._switchAnimation = new RealmSwitcher.ContextSwitchAnimationController(this._realmIndicator);
|
|
|
|
|
2021-12-13 16:30:43 +00: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 19:04:05 +00: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();
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|