-
Notifications
You must be signed in to change notification settings - Fork 18
/
extension.js
57 lines (49 loc) · 1.67 KB
/
extension.js
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
56
57
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Main = imports.ui.main;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Docking = Me.imports.docking;
const ExtensionSystem = imports.ui.extensionSystem;
// We declare this with var so it can be accessed by other extensions in
// GNOME Shell 3.26+ (mozjs52+).
var dockManager = null
let _extensionlistenerId;
function init() {
ExtensionUtils.initTranslations('dashtodock');
}
function enable() {
/*
* Listen to enabled extension, if Dash to Dock is on the list or become active,
* we disable this dock.
*/
_extensionlistenerId = Main.extensionManager.connect('extension-state-changed',
conditionallyenabledock);
conditionallyenabledock();
}
function disable() {
try {
if (dockManager != null) {
dockManager.destroy();
dockManager = null
}
} catch(e) {
log('Failed to destroy dockManager: %s'.format(e.message));
} finally {
if (_extensionlistenerId) {
Main.extensionManager.disconnect(_extensionlistenerId);
_extensionlistenerId = 0;
}
}
}
function conditionallyenabledock() {
let to_enable = Main.extensionManager._extensionOrder.every((e) => {
return e != '[email protected]';
});
// enable or disable dock depending on dock status and to_enable state
if (to_enable && !dockManager) {
dockManager = new Docking.DockManager();
} else if (!to_enable && dockManager) {
dockManager.destroy();
dockManager = null
}
}