gnome-shell/js/ui/realms/realmManager.js

59 lines
2.3 KiB
JavaScript

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);
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");
}
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();
}
};