summaryrefslogtreecommitdiffstats
path: root/extensions/vertical-workspaces/workspaceSwitcherPopup.js
blob: 5401903b18b55e758116b17ba580016a98a88d27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
 * Vertical Workspaces
 * workspacesSwitcherPopup.js
 * 
 * @author     GdH <G-dH@github.com>
 * @copyright  2022 - 2023
 * @license    GPL-3.0
 *
 */

'use strict';

const Main = imports.ui.main;
const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup;

const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();

const _Util = Me.imports.util;
let _overrides;

let opt;
var _activateSearchProvider;

function update(reset = false) {
    if (_overrides) {
        _overrides.removeAll();
    }

    if (reset) {
        _overrides = null;
        opt = null;
        return;
    }

    opt = Me.imports.settings.opt;

    _overrides = new _Util.Overrides();

    if (opt.ORIENTATION) {// 1-VERTICAL, 0-HORIZONTAL
        const settings = ExtensionUtils.getSettings('org.gnome.shell');
        const enabled = settings.get_strv('enabled-extensions');
        const allowWsPopupInjection = !(enabled.includes('workspace-switcher-manager@G-dH.github.com') || enabled.includes('WsSwitcherPopupManager@G-dH.github.com-dev'));
        if (opt.shellVersion >= 42 && allowWsPopupInjection)
            _overrides.addInjection('WorkspaceSwitcherPopup', WorkspaceSwitcherPopup.WorkspaceSwitcherPopup.prototype, WorkspaceSwitcherPopupInjections);
    }
}

const WorkspaceSwitcherPopupInjections = {
    _init: function() {
        if (this._list) {
            this._list.vertical = true;
        }
    }
}