forked from gnome-extensions/vertical-overview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.js
More file actions
163 lines (135 loc) · 6.15 KB
/
extension.js
File metadata and controls
163 lines (135 loc) · 6.15 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
const __DEBUG__ = true;
const { Gio, Meta, Shell, Clutter, GObject, Graphene, St } = imports.gi;
const WindowManager = imports.ui.windowManager;
const Main = imports.ui.main;
const Self = imports.misc.extensionUtils.getCurrentExtension();
const Util = Self.imports.util;
const OverviewControlsOverride = Self.imports.overviewControls;
const WorkspacesViewOverrides = Self.imports.workspacesView;
const WorkspaceThumbnailOverrides = Self.imports.workspaceThumbnail;
const DashOverride = Self.imports.dash;
const Gestures = Self.imports.gestures;
const Background = imports.ui.background;
const WorkspaceOverrides = Self.imports.workspace;
function init() {
}
function enable() {
if (__DEBUG__) global.log("[VERTICAL-OVERVIEW] starting overrides");
global.vertical_overview = {};
global.vertical_overview.GSFunctions = {};
bindSettings();
OverviewControlsOverride.override();
WorkspacesViewOverrides.override();
WorkspaceThumbnailOverrides.override();
WorkspaceOverrides.override();
Gestures.override();
DashOverride.override();
//this is the magic function that switches the internal layout to vertical
global.workspace_manager.override_workspace_layout(Meta.DisplayCorner.TOPLEFT, true, -1, 1);
//rebinding keys is necessary because bound functions don't update if the prototype for that function is changed
rebind_keys(Main.overview._overview._controls);
if (__DEBUG__) global.log("[VERTICAL_OVERVIEW] enabled");
}
function disable() {
if (__DEBUG__) global.log("[VERTICAL-OVERVIEW] resetting overrides");
OverviewControlsOverride.reset();
WorkspacesViewOverrides.reset();
WorkspaceOverrides.reset();
WorkspaceThumbnailOverrides.reset();
Gestures.reset();
DashOverride.reset(true);
rebind_keys(Main.overview._overview._controls);
global.workspaceManager.override_workspace_layout(Meta.DisplayCorner.TOPLEFT, false, 1, -1);
for (var key in global.vertical_overview.settings.signals) {
Util.unbindSetting(key);
};
delete global.vertical_overview;
if (__DEBUG__) global.log("[VERTICAL-OVERVIEW] disabled");
}
function bindSettings() {
let controlsManager = Main.overview._overview._controls;
Util.bindSetting('left-offset', (settings, label) => {
controlsManager.layoutManager.leftOffset = settings.get_int(label);
});
Util.bindSetting('right-offset', (settings, label) => {
controlsManager.layoutManager.rightOffset = settings.get_int(label);
});
Util.bindSetting('scaling-workspace-background', (settings, label) => {
global.vertical_overview.scaling_workspaces_hidden = settings.get_boolean(label);
if (settings.get_boolean(label)) {
WorkspaceOverrides.scalingWorkspaceBackgroundOverride();
} else {
WorkspaceOverrides.scalingWorkspaceBackgroundReset();
}
});
Util.bindSetting('static-background', (settings, label) => {
if (settings.get_boolean(label)) {
WorkspaceOverrides.staticBackgroundOverride();
} else {
WorkspaceOverrides.staticBackgroundReset();
}
});
Util.bindSetting('workspace-peek-distance', (settings, label) => {
global.vertical_overview.workspacePeek = settings.get_int(label);
});
Util.bindSetting('dash-to-panel-left-right-fix', (settings, label) => {
global.vertical_overview.misc_dTPLeftRightFix = settings.get_boolean(label);
});
Util.bindSetting('default-old-style', (settings, label) => {
global.vertical_overview.default_old_style_enabled = settings.get_boolean(label);
DashOverride.dash_old_style();
WorkspaceThumbnailOverrides.thumbnails_old_style();
});
Util.bindSetting('old-style', (settings, label) => {
global.vertical_overview.old_style_enabled = settings.get_boolean(label);
DashOverride.dash_old_style();
WorkspaceThumbnailOverrides.thumbnails_old_style();
});
Util.bindSetting('panel-in-overview', (settings, label) => {
if (settings.get_boolean(label)) {
if (global.vertical_overview.panel_signal_found) {
global.vertical_overview.panel_signal.disconnected = true;
} else {
const callbackString = "()=>{this.add_style_pseudo_class('overview');}";
let i = 0;
while (i < Main.overview._signalConnections.length) {
const signal = Main.overview._signalConnections[i];
if (signal.name == 'showing') {
if (signal.callback.toString().replace(/[\ \n]/g, "") == callbackString) {
global.vertical_overview.panel_signal = signal;
global.vertical_overview.panel_signal_found = true;
signal.disconnected = true;
break;
}
}
i++;
}
}
} else {
if (global.vertical_overview.panel_signal_found) {
global.vertical_overview.panel_signal.disconnected = false;
}
}
});
}
function rebind_keys(self) {
Main.wm.removeKeybinding('toggle-application-view');
Main.wm.removeKeybinding('shift-overview-up');
Main.wm.removeKeybinding('shift-overview-down');
Main.wm.addKeybinding(
'toggle-application-view',
new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
self._toggleAppsPage.bind(self));
Main.wm.addKeybinding('shift-overview-up',
new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
() => self._shiftState(Meta.MotionDirection.UP));
Main.wm.addKeybinding('shift-overview-down',
new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
() => self._shiftState(Meta.MotionDirection.DOWN))
}