-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathextension.js
127 lines (106 loc) · 3.08 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
const Main = imports.ui.main;
const St = imports.gi.St;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
let bottomPanel = null;
let topPanel = null;
let leftPanel = null;
let rightPanel = null;
let settings = null;
let topSizeChangedSignal = null;
let bottomSizeChangedSignal = null;
let leftSizeChangedSignal = null;
let rightSizeChangedSignal = null;
function init () {}
function enable() {
settings = ExtensionUtils.getSettings();
let monitor = Main.layoutManager.primaryMonitor;
bottomPanel = new St.Bin({
reactive: false,
can_focus: false,
track_hover: false,
height: settings.get_int('bottom-gap-size'),
width: monitor.width,
});
topPanel = new St.Bin({
reactive: false,
can_focus: false,
track_hover: false,
height: settings.get_int('top-gap-size'),
width: monitor.width,
});
leftPanel = new St.Bin({
reactive: false,
can_focus: false,
track_hover: false,
height: monitor.height,
width: settings.get_int('left-gap-size'),
});
rightPanel = new St.Bin({
reactive: false,
can_focus: false,
track_hover: false,
height: monitor.height,
width: settings.get_int('right-gap-size'),
});
bottomPanel.set_position(0, monitor.height - settings.get_int('bottom-gap-size'));
topPanel.set_position(0, 0);
leftPanel.set_position(0, 0);
rightPanel.set_position(monitor.width - settings.get_int('right-gap-size'), 0);
Main.layoutManager.addChrome(bottomPanel, {
affectsInputRegion: true,
affectsStruts: true,
});
Main.layoutManager.addChrome(topPanel, {
affectsInputRegion: true,
affectsStruts: true,
});
Main.layoutManager.addChrome(leftPanel, {
affectsInputRegion: true,
affectsStruts: true,
});
Main.layoutManager.addChrome(rightPanel, {
affectsInputRegion: true,
affectsStruts: true,
});
topSizeChangedSignal = settings.connect('changed::top-gap-size', function (k, b) {
disable();
enable();
});
bottomSizeChangedSignal = settings.connect('changed::bottom-gap-size', function (k, b) {
disable();
enable();
});
leftSizeChangedSignal = settings.connect('changed::left-gap-size', function (k, b) {
disable();
enable();
});
rightSizeChangedSignal = settings.connect('changed::right-gap-size', function (k, b) {
disable();
enable();
});
}
function disable() {
Main.layoutManager.removeChrome(bottomPanel);
Main.layoutManager.removeChrome(topPanel);
Main.layoutManager.removeChrome(leftPanel);
Main.layoutManager.removeChrome(rightPanel);
settings.disconnect(topSizeChangedSignal);
settings.disconnect(bottomSizeChangedSignal);
settings.disconnect(leftSizeChangedSignal);
settings.disconnect(rightSizeChangedSignal);
bottomPanel.destroy();
topPanel.destroy();
leftPanel.destroy();
rightPanel.destroy();
settings.run_dispose();
topSizeChangedSignal = null;
bottomSizeChangedSignal = null;
leftSizeChangedSignal = null;
rightSizeChangedSignal = null;
bottomPanel = null;
topPanel = null;
leftPanel = null;
rightPanel = null;
settings = null;
}