/usr/share/gnome-shell/extensions/dash-to-panel@jderose9.github.com/overview.js is in gnome-shell-extension-dash-to-panel 13-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | /*
* This file is part of the Dash-To-Panel extension for Gnome 3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Credits:
* This file is based on code from the Dash to Dock extension by micheleg
*
* Some code was also adapted from the upstream Gnome Shell source code.
*/
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const Lang = imports.lang;
const Main = imports.ui.main;
const Shell = imports.gi.Shell;
const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
var dtpOverview = new Lang.Class({
Name: 'DashToPanel.Overview',
_numHotkeys: 10,
_init: function(settings) {
this._dtpSettings = settings;
},
enable : function(taskbar) {
this.taskbar = taskbar;
this._injectionsHandler = new Convenience.InjectionsHandler();
this._signalsHandler = new Convenience.GlobalSignalsHandler();
// Hide usual Dash
Main.overview._controls.dash.actor.hide();
// Also set dash width to 1, so it's almost not taken into account by code
// calculaing the reserved space in the overview. The reason to keep it at 1 is
// to allow its visibility change to trigger an allocaion of the appGrid which
// in turn is triggergin the appsIcon spring animation, required when no other
// actors has this effect, i.e in horizontal mode and without the workspaceThumnails
// 1 static workspace only)
Main.overview._controls.dash.actor.set_width(1);
this._isolation = this._optionalWorkspaceIsolation();
this._optionalHotKeys();
this._optionalNumberOverlay();
this._bindSettingsChanges();
},
disable: function () {
Main.overview._controls.dash.actor.show();
Main.overview._controls.dash.actor.set_width(-1); //reset default dash size
// This force the recalculation of the icon size
Main.overview._controls.dash._maxHeight = -1;
// reset stored icon size to the default dash
Main.overview.dashIconSize = Main.overview._controls.dash.iconSize;
// Remove key bindings
this._disableHotKeys();
this._disableExtraShortcut();
this._isolation.disable.apply(this);
},
_bindSettingsChanges: function() {
},
/**
* Isolate overview to open new windows for inactive apps
*/
_optionalWorkspaceIsolation: function() {
let label = 'optionalWorkspaceIsolation';
this._dtpSettings.connect('changed::isolate-workspaces', Lang.bind(this, function() {
this.taskbar.resetAppIcons();
if (this._dtpSettings.get_boolean('isolate-workspaces'))
Lang.bind(this, enable)();
else
Lang.bind(this, disable)();
}));
if (this._dtpSettings.get_boolean('isolate-workspaces'))
Lang.bind(this, enable)();
function enable() {
this._injectionsHandler.removeWithLabel(label);
this._injectionsHandler.addWithLabel(label, [
Shell.App.prototype,
'activate',
IsolatedOverview
]);
this._signalsHandler.removeWithLabel(label);
this._signalsHandler.addWithLabel(label, [
global.window_manager,
'switch-workspace',
() => this.taskbar.handleIsolatedWorkspaceSwitch()
]);
}
function disable() {
this._signalsHandler.removeWithLabel(label);
this._injectionsHandler.removeWithLabel(label);
this._signalsHandler.destroy();
this._injectionsHandler.destroy();
}
function IsolatedOverview() {
// These lines take care of Nautilus for icons on Desktop
let windows = this.get_windows().filter(function(w) {
return w.get_workspace().index() == global.screen.get_active_workspace_index();
});
if (windows.length == 1)
if (windows[0].skip_taskbar)
return this.open_new_window(-1);
if (this.is_on_workspace(global.screen.get_active_workspace()))
return Main.activateWindow(windows[0]);
return this.open_new_window(-1);
}
return { disable: disable };
},
// Hotkeys
_activateApp: function(appIndex) {
let children = this.taskbar._box.get_children().filter(function(actor) {
return actor.child &&
actor.child._delegate &&
actor.child._delegate.app;
});
// Apps currently in the taskbar
let apps = children.map(function(actor) {
return actor.child._delegate;
});
// Activate with button = 1, i.e. same as left click
let button = 1;
if (appIndex < apps.length)
apps[appIndex].activate(button);
},
_optionalHotKeys: function() {
this._hotKeysEnabled = false;
if (this._dtpSettings.get_boolean('hot-keys'))
this._enableHotKeys();
this._signalsHandler.add([
this._dtpSettings,
'changed::hot-keys',
Lang.bind(this, function() {
if (this._dtpSettings.get_boolean('hot-keys'))
Lang.bind(this, this._enableHotKeys)();
else
Lang.bind(this, this._disableHotKeys)();
})
]);
},
_enableHotKeys: function() {
if (this._hotKeysEnabled)
return;
// Setup keyboard bindings for taskbar elements
let keys = ['app-hotkey-', 'app-shift-hotkey-', 'app-ctrl-hotkey-', // Regular numbers
'app-hotkey-kp-', 'app-shift-hotkey-kp-', 'app-ctrl-hotkey-kp-']; // Key-pad numbers
keys.forEach( function(key) {
for (let i = 0; i < this._numHotkeys; i++) {
let appNum = i;
Main.wm.addKeybinding(key + (i + 1), this._dtpSettings,
Meta.KeyBindingFlags.NONE,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
Lang.bind(this, function() {
this._activateApp(appNum);
this._showOverlay();
}));
}
}, this);
this._hotKeysEnabled = true;
if (this._dtpSettings.get_string('hotkeys-overlay-combo') === 'ALWAYS')
this.taskbar.toggleNumberOverlay(true);
},
_disableHotKeys: function() {
if (!this._hotKeysEnabled)
return;
let keys = ['app-hotkey-', 'app-shift-hotkey-', 'app-ctrl-hotkey-', // Regular numbers
'app-hotkey-kp-', 'app-shift-hotkey-kp-', 'app-ctrl-hotkey-kp-']; // Key-pad numbers
keys.forEach( function(key) {
for (let i = 0; i < this._numHotkeys; i++)
Main.wm.removeKeybinding(key + (i + 1));
}, this);
this._hotKeysEnabled = false;
this.taskbar.toggleNumberOverlay(false);
},
_optionalNumberOverlay: function() {
this._shortcutIsSet = false;
// Enable extra shortcut
if (this._dtpSettings.get_boolean('hot-keys'))
this._enableExtraShortcut();
this._signalsHandler.add([
this._dtpSettings,
'changed::hot-keys',
Lang.bind(this, this._checkHotkeysOptions)
], [
this._dtpSettings,
'changed::hotkeys-overlay-combo',
Lang.bind(this, function() {
if (this._dtpSettings.get_string('hotkeys-overlay-combo') === 'ALWAYS')
this.taskbar.toggleNumberOverlay(true);
else
this.taskbar.toggleNumberOverlay(false);
})
]);
},
_checkHotkeysOptions: function() {
if (this._dtpSettings.get_boolean('hot-keys'))
this._enableExtraShortcut();
else
this._disableExtraShortcut();
},
_enableExtraShortcut: function() {
if (!this._shortcutIsSet) {
Main.wm.addKeybinding('shortcut', this._dtpSettings,
Meta.KeyBindingFlags.NONE,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
Lang.bind(this, function() {
this._overlayFromShortcut = true;
this._showOverlay();
}));
this._shortcutIsSet = true;
}
},
_disableExtraShortcut: function() {
if (this._shortcutIsSet) {
Main.wm.removeKeybinding('shortcut');
this._shortcutIsSet = false;
}
},
_showOverlay: function() {
// Restart the counting if the shortcut is pressed again
if (this._numberOverlayTimeoutId) {
Mainloop.source_remove(this._numberOverlayTimeoutId);
this._numberOverlayTimeoutId = 0;
}
let hotkey_option = this._dtpSettings.get_string('hotkeys-overlay-combo');
// Set to true and exit if the overlay is always visible
if (hotkey_option === 'ALWAYS')
return;
if (hotkey_option === 'TEMPORARILY' || this._overlayFromShortcut)
this.taskbar.toggleNumberOverlay(true);
let timeout = this._dtpSettings.get_int('overlay-timeout');
if (this._overlayFromShortcut) {
timeout = this._dtpSettings.get_int('shortcut-timeout');
this._overlayFromShortcut = false;
}
// Hide the overlay/dock after the timeout
this._numberOverlayTimeoutId = Mainloop.timeout_add(timeout, Lang.bind(this, function() {
this._numberOverlayTimeoutId = 0;
this.taskbar.toggleNumberOverlay(false);
}));
}
});
|