Drop ES5 support

This commit is contained in:
Charles Gagnon
2022-04-01 22:32:15 -04:00
parent 5d1f8239f4
commit c1c30ce9fa
14 changed files with 926 additions and 1039 deletions

View File

@@ -26,6 +26,7 @@ const Clutter = imports.gi.Clutter;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
const GObject = imports.gi.GObject;
const Signals = imports.signals;
const Lang = imports.lang;
const Meta = imports.gi.Meta;
@@ -51,7 +52,6 @@ const BoxPointer = imports.ui.boxpointer;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Utils = Me.imports.utils;
const Panel = Me.imports.panel;
const PanelSettings = Me.imports.panelSettings;
const Taskbar = Me.imports.taskbar;
const Progress = Me.imports.progress;
@@ -110,12 +110,10 @@ let tracker = Shell.WindowTracker.get_default();
*
*/
var taskbarAppIcon = Utils.defineClass({
Name: 'DashToPanel.TaskbarAppIcon',
Extends: AppDisplay.AppIcon,
ParentConstrParams: [[0, 'app'], [2]],
var TaskbarAppIcon = GObject.registerClass({
}, class TaskbarAppIcon extends AppDisplay.AppIcon {
_init: function(appInfo, panel, iconParams, previewMenu, iconAnimator) {
_init(appInfo, panel, iconParams, previewMenu, iconAnimator) {
this.dtpPanel = panel;
this._nWindows = 0;
this.window = appInfo.window;
@@ -123,6 +121,8 @@ var taskbarAppIcon = Utils.defineClass({
this._previewMenu = previewMenu;
this.iconAnimator = iconAnimator;
super._init(appInfo.app, iconParams);
this._timeoutsHandler = new Utils.TimeoutsHandler();
// Fix touchscreen issues before the listener is added by the parent constructor.
@@ -146,8 +146,6 @@ var taskbarAppIcon = Utils.defineClass({
this._removeMenuTimeout();
};
this.callParent('_init', appInfo.app, iconParams);
Utils.wrapActor(this.icon);
Utils.wrapActor(this);
@@ -269,14 +267,14 @@ var taskbarAppIcon = Utils.defineClass({
this._progressIndicator = new Progress.ProgressIndicator(this, panel.progressManager);
this._numberOverlay();
},
}
getDragActor: function() {
getDragActor() {
return this.app.create_icon_texture(this.dtpPanel.taskbar.iconSize);
},
}
// Used by TaskbarItemContainer to animate appIcons on hover
getCloneButton: function() {
getCloneButton() {
// The source of the clone is this._container,
// using this.actor directly would break DnD style.
let clone = new Clutter.Clone({
@@ -296,9 +294,9 @@ var taskbarAppIcon = Utils.defineClass({
width: this.actor.width, height: this.actor.height,
reactive: false,
});
},
}
shouldShowTooltip: function() {
shouldShowTooltip() {
if (!Me.settings.get_boolean('show-tooltip') ||
(!this.isLauncher && Me.settings.get_boolean("show-window-previews") &&
this.getAppIconInterestingWindows().length > 0)) {
@@ -308,9 +306,9 @@ var taskbarAppIcon = Utils.defineClass({
(!this._menu || !this._menu.isOpen) &&
(this._previewMenu.getCurrentAppIcon() !== this);
}
},
}
_onAppIconHoverChanged: function() {
_onAppIconHoverChanged() {
if (!Me.settings.get_boolean('show-window-previews') ||
(!this.window && !this._nWindows)) {
return;
@@ -321,10 +319,10 @@ var taskbarAppIcon = Utils.defineClass({
} else {
this._previewMenu.requestClose();
}
},
}
_onDestroy: function() {
this.callParent('_onDestroy');
_onDestroy() {
super._onDestroy();
this._destroyed = true;
this._timeoutsHandler.destroy();
@@ -368,26 +366,26 @@ var taskbarAppIcon = Utils.defineClass({
for (let i = 0; i < this._dtpSettingsSignalIds.length; ++i) {
Me.settings.disconnect(this._dtpSettingsSignalIds[i]);
}
},
}
onWindowsChanged: function() {
onWindowsChanged() {
this._updateWindows();
this.updateIcon();
},
}
onWindowEnteredOrLeft: function() {
onWindowEnteredOrLeft() {
if (this._checkIfFocusedApp()) {
this._updateWindows();
this._displayProperIndicator();
}
},
}
updateTitleStyle: function() {
updateTitleStyle() {
this._updateWindowTitleStyle();
},
}
// Update indicator and target for minimization animation
updateIcon: function() {
updateIcon() {
// If (for unknown reason) the actor is not on the stage the reported size
// and position are random values, which might exceeds the integer range
@@ -405,9 +403,9 @@ var taskbarAppIcon = Utils.defineClass({
windows.forEach(function(w) {
w.set_icon_geometry(rect);
});
},
}
_onAnimateAppiconHoverChanged: function() {
_onAnimateAppiconHoverChanged() {
if (Me.settings.get_boolean('animate-appicon-hover')) {
this._container.add_style_class_name('animate-appicon-hover');
@@ -435,9 +433,9 @@ var taskbarAppIcon = Utils.defineClass({
this.icon.createIcon = Lang.bind(this, this._createIcon);
}
}
},
}
_onMouseScroll: function(actor, event) {
_onMouseScroll(actor, event) {
let scrollAction = Me.settings.get_string('scroll-icon-action');
if (scrollAction === 'PASS_THROUGH') {
@@ -456,9 +454,9 @@ var taskbarAppIcon = Utils.defineClass({
windows.sort(Taskbar.sortWindowsCompareFunction);
Utils.activateSiblingWindow(windows, direction, this.window);
}
},
}
_showDots: function() {
_showDots() {
// Just update style if dots already exist
if (this._focusedDots && this._unfocusedDots) {
this._updateWindows();
@@ -513,9 +511,9 @@ var taskbarAppIcon = Utils.defineClass({
}
this._dotsContainer.add_child(this._focusedDots);
},
}
_resetDots: function() {
_resetDots() {
let position = Me.settings.get_string('dot-position');
let isHorizontalDots = position == DOT_POSITION.TOP || position == DOT_POSITION.BOTTOM;
@@ -527,9 +525,9 @@ var taskbarAppIcon = Utils.defineClass({
d[isHorizontalDots ? 'width' : 'height'] = 1;
d[(isHorizontalDots ? 'y' : 'x') + '_expand'] = true;
});
},
}
_settingsChangeRefresh: function() {
_settingsChangeRefresh() {
if (this._isGroupApps) {
this._updateWindows();
this._resetDots();
@@ -538,9 +536,9 @@ var taskbarAppIcon = Utils.defineClass({
}
this._displayProperIndicator(true);
},
}
_updateWindowTitleStyle: function() {
_updateWindowTitleStyle() {
if (this._windowTitle) {
let useFixedWidth = Me.settings.get_boolean('group-apps-use-fixed-width');
let variableWidth = !useFixedWidth || this.dtpPanel.checkIfVertical() || this.dtpPanel.taskbar.fullScrollView;
@@ -563,9 +561,9 @@ var taskbarAppIcon = Utils.defineClass({
(useFixedWidth ? '' : 'max-width: ' + maxLabelWidth + 'px;') +
'color: ' + fontColor);
}
},
}
_updateWindowTitle: function() {
_updateWindowTitle() {
if (this._windowTitle.text != this.window.title) {
this._windowTitle.text = (this.window.title ? this.window.title : this.app.get_name()).replace(/\r?\n|\r/g, '').trim();
@@ -573,9 +571,9 @@ var taskbarAppIcon = Utils.defineClass({
this._displayProperIndicator();
}
}
},
}
_setIconStyle: function(isFocused) {
_setIconStyle(isFocused) {
let inlineStyle = 'margin: 0;';
if(Me.settings.get_boolean('focus-highlight') &&
@@ -620,33 +618,33 @@ var taskbarAppIcon = Utils.defineClass({
this._timeoutsHandler.add([T1, 0, () => this._dotsContainer.set_style(inlineStyle)]);
}
}
},
}
_checkIfFocusedApp: function() {
_checkIfFocusedApp() {
return tracker.focus_app == this.app;
},
}
_checkIfMonitorHasFocus: function() {
_checkIfMonitorHasFocus() {
return global.display.focus_window &&
(!Me.settings.get_boolean('multi-monitors') || // only check same monitor index if multi window is enabled.
!Me.settings.get_boolean('isolate-monitors') ||
global.display.focus_window.get_monitor() === this.dtpPanel.monitor.index);
},
}
_setAppIconPadding: function() {
_setAppIconPadding() {
let padding = getIconPadding(this.dtpPanel.monitor.index);
let margin = Me.settings.get_int('appicon-margin');
this.actor.set_style('padding:' + (this.dtpPanel.checkIfVertical() ? margin + 'px 0' : '0 ' + margin + 'px;'));
this._iconContainer.set_style('padding: ' + padding + 'px;');
},
}
popupMenu: function() {
popupMenu() {
this._removeMenuTimeout();
this.fake_release();
if (!this._menu) {
this._menu = new taskbarSecondaryMenu(this, this.dtpPanel.geom.position);
this._menu = new TaskbarSecondaryMenu(this, this.dtpPanel.geom.position);
this._menu.setApp(this.app);
this._menu.connect('open-state-changed', (menu, isPoppedUp) => {
if (!isPoppedUp)
@@ -675,25 +673,25 @@ var taskbarAppIcon = Utils.defineClass({
this.emit('sync-tooltip');
return false;
},
}
_onFocusAppChanged: function(windowTracker) {
_onFocusAppChanged(windowTracker) {
this._displayProperIndicator(true);
},
}
_onOverviewWindowDragEnd: function(windowTracker) {
_onOverviewWindowDragEnd(windowTracker) {
this._timeoutsHandler.add([T4, 0, () => this._displayProperIndicator()]);
},
}
_onSwitchWorkspace: function(windowTracker) {
_onSwitchWorkspace(windowTracker) {
if (this._isGroupApps) {
this._timeoutsHandler.add([T5, 0, () => this._displayProperIndicator(true)]);
} else {
this._displayProperIndicator();
}
},
}
_displayProperIndicator: function (force) {
_displayProperIndicator(force) {
let isFocused = this._isFocusedWindow();
let position = Me.settings.get_string('dot-position');
let isHorizontalDots = position == DOT_POSITION.TOP || position == DOT_POSITION.BOTTOM;
@@ -770,9 +768,9 @@ var taskbarAppIcon = Utils.defineClass({
this._unfocusedDots[sizeProp] = newUnfocusedDotsSize;
}
}
},
}
_animateDotDisplay: function (dots, newSize, otherDots, newOtherOpacity, force, sizeProp) {
_animateDotDisplay(dots, newSize, otherDots, newOtherOpacity, force, sizeProp) {
if((dots[sizeProp] != newSize && dots._tweeningToSize !== newSize) || force) {
let tweenOpts = {
time: Taskbar.DASH_ANIMATION_TIME,
@@ -792,9 +790,9 @@ var taskbarAppIcon = Utils.defineClass({
Utils.animate(dots, tweenOpts);
}
},
}
_isFocusedWindow: function() {
_isFocusedWindow() {
let focusedWindow = global.display.focus_window;
while (focusedWindow) {
@@ -806,24 +804,24 @@ var taskbarAppIcon = Utils.defineClass({
}
return false;
},
}
_isWideDotStyle: function(dotStyle) {
_isWideDotStyle(dotStyle) {
return dotStyle == DOT_STYLE.SEGMENTED ||
dotStyle == DOT_STYLE.CILIORA ||
dotStyle == DOT_STYLE.METRO ||
dotStyle == DOT_STYLE.SOLID;
},
}
_isThemeProvidingIndicator: function () {
_isThemeProvidingIndicator() {
// This is an attempt to determine if the theme is providing their own
// running indicator by way of a border image on the icon, for example in
// the theme Ciliora
return (this.icon.actor.get_stage() &&
this.icon.actor.get_theme_node().get_border_image());
},
}
activate: function(button, handleAsGrouped) {
activate(button, handleAsGrouped) {
let event = Clutter.get_current_event();
let modifiers = event ? event.get_state() : 0;
@@ -836,7 +834,7 @@ var taskbarAppIcon = Utils.defineClass({
// Keep default behaviour: launch new window
// By calling the parent method I make it compatible
// with other extensions tweaking ctrl + click
this.callParent('activate', button);
super.activate(button);
return;
}
@@ -990,9 +988,9 @@ var taskbarAppIcon = Utils.defineClass({
}
Main.overview.hide();
},
}
_launchNewInstance: function() {
_launchNewInstance() {
if (this.app.can_open_new_window()) {
let appActions = this.app.get_app_info().list_actions();
let newWindowIndex = appActions.indexOf('new-window');
@@ -1015,9 +1013,9 @@ var taskbarAppIcon = Utils.defineClass({
this.app.activate();
}
}
},
}
_updateWindows: function() {
_updateWindows() {
let windows = [this.window];
if (!this.window) {
@@ -1035,17 +1033,17 @@ var taskbarAppIcon = Utils.defineClass({
}
this._previewMenu.update(this, windows);
},
}
_getRunningIndicatorCount: function() {
_getRunningIndicatorCount() {
return Math.min(this._nWindows, MAX_INDICATORS);
},
}
_getRunningIndicatorSize: function() {
_getRunningIndicatorSize() {
return Me.settings.get_int('dot-size') * Utils.getScaleFactor();
},
}
_getRunningIndicatorColor: function(isFocused) {
_getRunningIndicatorColor(isFocused) {
let color;
const fallbackColor = new Clutter.Color({ red: 82, green: 148, blue: 226, alpha: 255 });
@@ -1079,18 +1077,18 @@ var taskbarAppIcon = Utils.defineClass({
}
return color;
},
}
_getFocusHighlightColor: function() {
_getFocusHighlightColor() {
if (Me.settings.get_boolean('focus-highlight-dominant')) {
let dce = new Utils.DominantColorExtractor(this.app);
let palette = dce._getColorPalette();
if (palette) return palette.original;
}
return Me.settings.get_string('focus-highlight-color');
},
}
_drawRunningIndicator: function(area, type, isFocused) {
_drawRunningIndicator(area, type, isFocused) {
let n = this._getRunningIndicatorCount();
if (!n) {
@@ -1226,9 +1224,9 @@ var taskbarAppIcon = Utils.defineClass({
}
cr.$dispose();
},
}
_numberOverlay: function() {
_numberOverlay() {
// Add label for a Hot-Key visual aid
this._numberOverlayLabel = new St.Label({ style_class: 'badge' });
this._numberOverlayBin = new St.Bin({
@@ -1239,13 +1237,13 @@ var taskbarAppIcon = Utils.defineClass({
this._numberOverlayBin.hide();
this._dtpIconContainer.add_child(this._numberOverlayBin);
},
}
updateHotkeyNumberOverlay: function() {
updateHotkeyNumberOverlay() {
this.updateNumberOverlay(this._numberOverlayBin, true);
},
}
updateNumberOverlay: function(bin, fixedSize) {
updateNumberOverlay(bin, fixedSize) {
// We apply an overall scale factor that might come from a HiDPI monitor.
// Clutter dimensions are in physical pixels, but CSS measures are in logical
// pixels, so make sure to consider the scale.
@@ -1267,38 +1265,38 @@ var taskbarAppIcon = Utils.defineClass({
bin.x = fixedSize ? natWidth - size - 2 : 2;
label.set_style(style);
},
}
setNumberOverlay: function(number) {
setNumberOverlay(number) {
this._numberOverlayOrder = number;
this._numberOverlayLabel.set_text(number.toString());
},
}
toggleNumberOverlay: function(activate) {
toggleNumberOverlay(activate) {
if (activate && this._numberOverlayOrder > -1)
this._numberOverlayBin.show();
else
this._numberOverlayBin.hide();
},
}
handleDragOver: function(source, actor, x, y, time) {
handleDragOver(source, actor, x, y, time) {
if (source == Main.xdndHandler) {
this._previewMenu.close(true);
}
return DND.DragMotionResult.CONTINUE;
},
}
// Disable all DnD methods on gnome-shell 3.34
_onDragBegin: function() {},
_onDragEnd: function() {},
acceptDrop: function() { return false; },
_onDragBegin() {}
_onDragEnd() {}
acceptDrop() { return false; }
getAppIconInterestingWindows: function(isolateMonitors) {
getAppIconInterestingWindows(isolateMonitors) {
return getInterestingWindows(this.app, this.dtpPanel.monitor, isolateMonitors);
}
});
taskbarAppIcon.prototype.scaleAndFade = taskbarAppIcon.prototype.undoScaleAndFade = () => {};
TaskbarAppIcon.prototype.scaleAndFade = TaskbarAppIcon.prototype.undoScaleAndFade = () => {};
function minimizeWindow(app, param, monitor){
// Param true make all app windows minimize
@@ -1458,13 +1456,10 @@ function getIconPadding(monitorIndex) {
* (https://github.com/deuill/shell-extension-quitfromdash)
*/
var taskbarSecondaryMenu = Utils.defineClass({
Name: 'DashToPanel.SecondaryMenu',
Extends: AppMenu.AppMenu,
ParentConstrParams: [[0], [1]],
class TaskbarSecondaryMenu extends AppMenu.AppMenu {
_init: function(source, side) {
this.callParent('_init', source, side);
constructor(source, side) {
super(source, side);
// constructor parameter does nos work for some reason
this._enableFavorites = true;
this._showSingleWindows = true;
@@ -1485,9 +1480,9 @@ function getIconPadding(monitorIndex) {
// replace quit item
delete this._quitItem;
this._quitItem = this.addAction(_('Quit'), () => this._quitFromTaskbar());
},
}
updateQuitText: function() {
updateQuitText() {
let count = this.sourceActor.window ? 1 : getInterestingWindows(this.sourceActor.app).length;
if ( count > 0) {
let quitFromTaskbarMenuText = "";
@@ -1498,21 +1493,21 @@ function getIconPadding(monitorIndex) {
this._quitItem.label.set_text(quitFromTaskbarMenuText);
}
},
}
_quitFromTaskbar: function() {
_quitFromTaskbar() {
let windows = this.sourceActor.window ? [this.sourceActor.window] : this._app.get_windows();
for (i = 0; i < windows.length; i++) {
for (let i = 0; i < windows.length; i++) {
windows[i].delete(global.get_current_time());
}
},
});
taskbarSecondaryMenu.prototype['_updateWindowsSection'] = function() {
}
};
TaskbarSecondaryMenu.prototype['_updateWindowsSection'] = function() {
if (Me.settings.get_boolean('show-window-previews')) {
this._windowSection.removeAll();
this._openWindowsHeader.hide();
} else {
this.callParent('_updateWindowsSection');
this._updateWindowsSection();
}
}
@@ -1600,10 +1595,9 @@ function ItemShowLabel() {
* use of this class in place of the original showAppsButton.
*
*/
var ShowAppsIconWrapper = Utils.defineClass({
Name: 'DashToPanel.ShowAppsIconWrapper',
var ShowAppsIconWrapper = class {
_init: function(dtpPanel) {
constructor(dtpPanel) {
this.realShowAppsIcon = new Dash.ShowAppsIcon();
Utils.wrapActor(this.realShowAppsIcon);
@@ -1661,9 +1655,9 @@ var ShowAppsIconWrapper = Utils.defineClass({
this._changedAppIconSidePaddingId = Me.settings.connect('changed::show-apps-icon-side-padding', () => this.setShowAppsPadding());
this.setShowAppsPadding();
},
}
_onButtonPress: function(_actor, event) {
_onButtonPress(_actor, event) {
let button = event.get_button();
if (button == 1) {
this._setPopupTimeout();
@@ -1672,35 +1666,35 @@ var ShowAppsIconWrapper = Utils.defineClass({
return Clutter.EVENT_STOP;
}
return Clutter.EVENT_PROPAGATE;
},
}
_onLeaveEvent: function(_actor, _event) {
_onLeaveEvent(_actor, _event) {
this.actor.fake_release();
this._removeMenuTimeout();
},
}
_onTouchEvent: function(actor, event) {
_onTouchEvent(actor, event) {
if (event.type() == Clutter.EventType.TOUCH_BEGIN)
this._setPopupTimeout();
return Clutter.EVENT_PROPAGATE;
},
}
_onMenuPoppedDown: function() {
_onMenuPoppedDown() {
this._menu.sourceActor = this.actor;
this.actor.sync_hover();
this.emit('menu-state-changed', false);
},
}
setShowAppsPadding: function() {
setShowAppsPadding() {
let padding = getIconPadding(this.realShowAppsIcon._dtpPanel.monitor.index);
let sidePadding = Me.settings.get_int('show-apps-icon-side-padding');
let isVertical = this.realShowAppsIcon._dtpPanel.checkIfVertical();
this.actor.set_style('padding:' + (padding + (isVertical ? sidePadding : 0)) + 'px ' + (padding + (isVertical ? 0 : sidePadding)) + 'px;');
},
}
createMenu: function() {
createMenu() {
if (!this._menu) {
this._menu = new MyShowAppsIconMenu(this.realShowAppsIcon, this.realShowAppsIcon._dtpPanel);
this._menu.connect('open-state-changed', (menu, isPoppedUp) => {
@@ -1720,9 +1714,9 @@ var ShowAppsIconWrapper = Utils.defineClass({
Main.uiGroup.add_actor(this._menu.actor);
this._menuManager.addMenu(this._menu);
}
},
}
popupMenu: function(sourceActor = null) {
popupMenu(sourceActor = null) {
this._removeMenuTimeout();
this.actor.fake_release();
this.createMenu();
@@ -1735,21 +1729,21 @@ var ShowAppsIconWrapper = Utils.defineClass({
this.emit('sync-tooltip');
return false;
},
}
shouldShowTooltip: function() {
shouldShowTooltip() {
return Me.settings.get_boolean('show-tooltip') &&
(this.actor.hover && (!this._menu || !this._menu.isOpen));
},
}
destroy: function() {
destroy() {
Me.settings.disconnect(this._changedShowAppsIconId);
Me.settings.disconnect(this._changedAppIconSidePaddingId);
Me.settings.disconnect(this._changedAppIconPaddingId);
this.realShowAppsIcon.destroy();
}
});
};
Signals.addSignalMethods(ShowAppsIconWrapper.prototype);
/**

View File

@@ -32,7 +32,7 @@ const Signals = imports.signals;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const PanelManager = Me.imports.panelManager;
const { PanelManager } = Me.imports.panelManager;
const Utils = Me.imports.utils;
const UBUNTU_DOCK_UUID = 'ubuntu-dock@ubuntu.com';
@@ -101,7 +101,7 @@ function _enable() {
});
}
panelManager = new PanelManager.dtpPanelManager();
panelManager = new PanelManager();
panelManager.enable();

View File

@@ -52,10 +52,9 @@ var Hold = {
PERMANENT: 2
};
var Intellihide = Utils.defineClass({
Name: 'DashToPanel.Intellihide',
var Intellihide = class {
_init: function(dtpPanel) {
constructor(dtpPanel) {
this._dtpPanel = dtpPanel;
this._panelBox = dtpPanel.panelBox;
this._panelManager = dtpPanel.panelManager;
@@ -70,9 +69,9 @@ var Intellihide = Utils.defineClass({
this.enabled = false;
this._changeEnabledStatus();
},
}
enable: function() {
enable() {
this.enabled = true;
this._monitor = this._dtpPanel.monitor;
this._animationDestination = -1;
@@ -101,9 +100,9 @@ var Intellihide = Utils.defineClass({
this._setRevealMechanism();
this._queueUpdatePanelPosition();
},
}
disable: function(reset) {
disable(reset) {
if (this._proximityWatchId) {
this._proximityManager.removeWatch(this._proximityWatchId);
}
@@ -118,43 +117,43 @@ var Intellihide = Utils.defineClass({
this._revealPanel(!reset);
this.enabled = false;
},
}
destroy: function() {
destroy() {
Me.settings.disconnect(this._intellihideChangedId);
Me.settings.disconnect(this._intellihideOnlySecondaryChangedId);
if (this.enabled) {
this.disable();
}
},
}
toggle: function() {
toggle() {
this[this._holdStatus & Hold.PERMANENT ? 'release' : 'revealAndHold'](Hold.PERMANENT);
},
}
revealAndHold: function(holdStatus) {
revealAndHold(holdStatus) {
if (this.enabled && !this._holdStatus) {
this._revealPanel();
}
this._holdStatus |= holdStatus;
},
}
release: function(holdStatus) {
release(holdStatus) {
this._holdStatus -= holdStatus;
if (this.enabled && !this._holdStatus) {
this._queueUpdatePanelPosition();
}
},
}
reset: function() {
reset() {
this.disable(true);
this.enable();
},
}
_changeEnabledStatus: function() {
_changeEnabledStatus() {
let intellihide = Me.settings.get_boolean('intellihide');
let onlySecondary = Me.settings.get_boolean('intellihide-only-secondary');
let enabled = intellihide && !(this._dtpPanel.isPrimary && onlySecondary);
@@ -162,9 +161,9 @@ var Intellihide = Utils.defineClass({
if (this.enabled !== enabled) {
this[enabled ? 'enable' : 'disable']();
}
},
}
_bindGeneralSignals: function() {
_bindGeneralSignals() {
this._signalsHandler.add(
[
this._dtpPanel.taskbar,
@@ -201,14 +200,14 @@ var Intellihide = Utils.defineClass({
() => this._queueUpdatePanelPosition()
]
);
},
}
_onHoverChanged: function() {
_onHoverChanged() {
this._hoveredOut = !this._panelBox.hover;
this._queueUpdatePanelPosition();
},
}
_setTrackPanel: function(enable) {
_setTrackPanel(enable) {
let trackedIndex = Main.layoutManager._findActor(this._panelBox);
let actorData = Main.layoutManager._trackedActors[trackedIndex]
@@ -220,9 +219,9 @@ var Intellihide = Utils.defineClass({
this._panelBox.visible = enable ? enable : this._panelBox.visible;
Main.layoutManager._queueUpdateRegions();
},
}
_setRevealMechanism: function() {
_setRevealMechanism() {
if (global.display.supports_extended_barriers() && Me.settings.get_boolean('intellihide-use-pressure')) {
this._edgeBarrier = this._createBarrier();
this._pressureBarrier = new Layout.PressureBarrier(
@@ -236,9 +235,9 @@ var Intellihide = Utils.defineClass({
this._pointerWatch = PointerWatcher.getPointerWatcher()
.addWatch(CHECK_POINTER_MS, (x, y) => this._checkMousePointer(x, y));
}
},
}
_removeRevealMechanism: function() {
_removeRevealMechanism() {
if (this._pointerWatch) {
PointerWatcher.getPointerWatcher()._removeWatch(this._pointerWatch);
}
@@ -247,9 +246,9 @@ var Intellihide = Utils.defineClass({
this._pressureBarrier.destroy();
this._edgeBarrier.destroy();
}
},
}
_createBarrier: function() {
_createBarrier() {
let position = this._dtpPanel.geom.position;
let opts = { display: global.display };
@@ -276,9 +275,9 @@ var Intellihide = Utils.defineClass({
}
return new Meta.Barrier(opts);
},
}
_checkMousePointer: function(x, y) {
_checkMousePointer(x, y) {
let position = this._dtpPanel.geom.position;
if (!this._panelBox.hover && !Main.overview.visible &&
@@ -290,9 +289,9 @@ var Intellihide = Utils.defineClass({
(y >= this._monitor.y && y < this._monitor.y + this._monitor.height))) {
this._queueUpdatePanelPosition(true);
}
},
}
_queueUpdatePanelPosition: function(fromRevealMechanism) {
_queueUpdatePanelPosition(fromRevealMechanism) {
if (!fromRevealMechanism && this._timeoutsHandler.getId(T2) && !Main.overview.visible) {
//unless this is a mouse interaction or entering/leaving the overview, limit the number
//of updates, but remember to update again when the limit timeout is reached
@@ -301,16 +300,16 @@ var Intellihide = Utils.defineClass({
this._checkIfShouldBeVisible(fromRevealMechanism) ? this._revealPanel() : this._hidePanel();
this._timeoutsHandler.add([T2, MIN_UPDATE_MS, () => this._endLimitUpdate()]);
}
},
}
_endLimitUpdate: function() {
_endLimitUpdate() {
if (this._pendingUpdate) {
this._pendingUpdate = false;
this._queueUpdatePanelPosition();
}
},
}
_checkIfShouldBeVisible: function(fromRevealMechanism) {
_checkIfShouldBeVisible(fromRevealMechanism) {
if (Main.overview.visibleTarget || this._dtpPanel.taskbar.previewMenu.opened ||
this._panelBox.get_hover() || this._checkIfGrab()) {
return true;
@@ -332,35 +331,35 @@ var Intellihide = Utils.defineClass({
}
return !this._windowOverlap;
},
}
_checkIfGrab: function() {
_checkIfGrab() {
if (GrabHelper._grabHelperStack && GrabHelper._grabHelperStack.some(gh => gh._owner == this._dtpPanel.panel.actor)) {
//there currently is a grab on a child of the panel, check again soon to catch its release
this._timeoutsHandler.add([T1, CHECK_GRAB_MS, () => this._queueUpdatePanelPosition()]);
return true;
}
},
}
_revealPanel: function(immediate) {
_revealPanel(immediate) {
if (!this._panelBox.visible) {
this._panelBox.visible = true;
this._dtpPanel.taskbar._shownInitially = false;
}
this._animatePanel(0, immediate);
},
}
_hidePanel: function(immediate) {
_hidePanel(immediate) {
let position = this._dtpPanel.geom.position;
let size = this._panelBox[position == St.Side.LEFT || position == St.Side.RIGHT ? 'width' : 'height'];
let coefficient = position == St.Side.TOP || position == St.Side.LEFT ? -1 : 1;
this._animatePanel(size * coefficient, immediate);
},
}
_animatePanel: function(destination, immediate) {
_animatePanel(destination, immediate) {
let animating = Utils.isAnimating(this._panelBox, this._translationProp);
if (!((animating && destination === this._animationDestination) ||
@@ -397,5 +396,5 @@ var Intellihide = Utils.defineClass({
}
this._hoveredOut = false;
},
});
}
}

View File

@@ -50,15 +50,14 @@ const DASH_MAX_HEIGHT_RATIO = 0.15;
//timeout names
const T1 = 'swipeEndTimeout';
var dtpOverview = Utils.defineClass({
Name: 'DashToPanel.Overview',
var Overview = class {
_init: function() {
constructor() {
this._numHotkeys = 10;
this._timeoutsHandler = new Utils.TimeoutsHandler();
},
}
enable : function(panel) {
enable (panel) {
this._panel = panel;
this.taskbar = panel.taskbar;
@@ -78,9 +77,9 @@ var dtpOverview = Utils.defineClass({
() => this._toggleDash()
]);
},
}
disable: function () {
disable() {
Utils.hookVfunc(Workspace.WorkspaceBackground.prototype, 'allocate', Workspace.WorkspaceBackground.prototype.vfunc_allocate);
Utils.hookVfunc(OverviewControls.ControlsManagerLayout.prototype, 'allocate', OverviewControls.ControlsManagerLayout.prototype.vfunc_allocate);
OverviewControls.ControlsManagerLayout.prototype._computeWorkspacesBoxForState = this._oldComputeWorkspacesBoxForState;
@@ -94,9 +93,9 @@ var dtpOverview = Utils.defineClass({
this._disableHotKeys();
this._disableExtraShortcut();
this._disableClickToExit();
},
}
_toggleDash: function(visible) {
_toggleDash(visible) {
// To hide the dash, set its 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
@@ -117,12 +116,12 @@ var dtpOverview = Utils.defineClass({
// This force the recalculation of the icon size
overviewControls.dash._maxHeight = -1;
},
}
/**
* Isolate overview to open new windows for inactive apps
*/
_optionalWorkspaceIsolation: function() {
_optionalWorkspaceIsolation() {
let label = 'optionalWorkspaceIsolation';
this._signalsHandler.add([
@@ -176,10 +175,10 @@ var dtpOverview = Utils.defineClass({
return this.open_new_window(-1);
}
},
}
// Hotkeys
_activateApp: function(appIndex) {
_activateApp(appIndex) {
let seenApps = {};
let apps = [];
@@ -232,9 +231,9 @@ var dtpOverview = Utils.defineClass({
appIcon.activate(button, true);
}
}
},
}
_endHotkeyPreviewCycle: function(focusWindow) {
_endHotkeyPreviewCycle(focusWindow) {
if (this._hotkeyPreviewCycleInfo) {
global.stage.disconnect(this._hotkeyPreviewCycleInfo.capturedEventId);
this._hotkeyPreviewCycleInfo.appIcon.actor.disconnect(this._hotkeyPreviewCycleInfo.keyFocusOutId);
@@ -247,9 +246,9 @@ var dtpOverview = Utils.defineClass({
delete this._hotkeyPreviewCycleInfo.appIcon._hotkeysCycle;
this._hotkeyPreviewCycleInfo = 0;
}
},
}
_optionalHotKeys: function() {
_optionalHotKeys() {
this._hotKeysEnabled = false;
if (Me.settings.get_boolean('hot-keys'))
this._enableHotKeys();
@@ -264,14 +263,14 @@ var dtpOverview = Utils.defineClass({
Lang.bind(this, this._disableHotKeys)();
})
]);
},
}
_resetHotkeys: function() {
_resetHotkeys() {
this._disableHotKeys();
this._enableHotKeys();
},
}
_enableHotKeys: function() {
_enableHotKeys() {
if (this._hotKeysEnabled)
return;
@@ -307,9 +306,9 @@ var dtpOverview = Utils.defineClass({
if (Me.settings.get_string('hotkeys-overlay-combo') === 'ALWAYS')
this.taskbar.toggleNumberOverlay(true);
},
}
_disableHotKeys: function() {
_disableHotKeys() {
if (!this._hotKeysEnabled)
return;
@@ -332,9 +331,9 @@ var dtpOverview = Utils.defineClass({
this._hotKeysEnabled = false;
this.taskbar.toggleNumberOverlay(false);
},
}
_optionalNumberOverlay: function() {
_optionalNumberOverlay() {
// Enable extra shortcut
if (Me.settings.get_boolean('hot-keys'))
this._enableExtraShortcut();
@@ -357,24 +356,24 @@ var dtpOverview = Utils.defineClass({
'changed::shortcut-num-keys',
() => this._resetHotkeys()
]);
},
}
_checkHotkeysOptions: function() {
_checkHotkeysOptions() {
if (Me.settings.get_boolean('hot-keys'))
this._enableExtraShortcut();
else
this._disableExtraShortcut();
},
}
_enableExtraShortcut: function() {
_enableExtraShortcut() {
Utils.addKeybinding('shortcut', Me.settings, () => this._showOverlay(true));
},
}
_disableExtraShortcut: function() {
_disableExtraShortcut() {
Utils.removeKeybinding('shortcut');
},
}
_showOverlay: function(overlayFromShortcut) {
_showOverlay(overlayFromShortcut) {
//wait for intellihide timeout initialization
if (!this._panel.intellihide) {
return;
@@ -412,9 +411,9 @@ var dtpOverview = Utils.defineClass({
this._panel.intellihide.release(Intellihide.Hold.TEMPORARY);
}));
},
}
_optionalClickToExit: function() {
_optionalClickToExit() {
this._clickToExitEnabled = false;
if (Me.settings.get_boolean('overview-click-to-exit'))
this._enableClickToExit();
@@ -429,9 +428,9 @@ var dtpOverview = Utils.defineClass({
Lang.bind(this, this._disableClickToExit)();
})
]);
},
}
_enableClickToExit: function() {
_enableClickToExit() {
if (this._clickToExitEnabled)
return;
@@ -454,9 +453,9 @@ var dtpOverview = Utils.defineClass({
Main.overview._overview.add_action(this._clickAction);
this._clickToExitEnabled = true;
},
}
_disableClickToExit: function () {
_disableClickToExit() {
if (!this._clickToExitEnabled)
return;
@@ -466,23 +465,23 @@ var dtpOverview = Utils.defineClass({
this._signalsHandler.removeWithLabel('clickToExit');
this._clickToExitEnabled = false;
},
}
_onSwipeBegin: function() {
_onSwipeBegin() {
this._swiping = true;
return true;
},
}
_onSwipeEnd: function() {
_onSwipeEnd() {
this._timeoutsHandler.add([
T1,
0,
() => this._swiping = false
]);
return true;
},
}
_hookupAllocation: function() {
_hookupAllocation() {
Utils.hookVfunc(OverviewControls.ControlsManagerLayout.prototype, 'allocate', function vfunc_allocate(container, box) {
const childBox = new Clutter.ActorBox();
@@ -709,4 +708,4 @@ var dtpOverview = Utils.defineClass({
});
}
});
}

218
panel.js
View File

@@ -31,19 +31,20 @@ const Me = imports.misc.extensionUtils.getCurrentExtension();
const Clutter = imports.gi.Clutter;
const Config = imports.misc.config;
const Gtk = imports.gi.Gtk;
const GObject = imports.gi.GObject;
const Gi = imports._gi;
const AppIcons = Me.imports.appIcons;
const Utils = Me.imports.utils;
const Taskbar = Me.imports.taskbar;
const { Taskbar, TaskbarItemContainer } = Me.imports.taskbar;
const Pos = Me.imports.panelPositions;
const PanelSettings = Me.imports.panelSettings;
const PanelStyle = Me.imports.panelStyle;
const { PanelStyle } = Me.imports.panelStyle;
const Lang = imports.lang;
const Main = imports.ui.main;
const Mainloop = imports.mainloop;
const Dash = imports.ui.dash;
const CtrlAltTab = imports.ui.ctrlAltTab;
const Panel = imports.ui.panel;
const GSPanel = imports.ui.panel;
const PanelMenu = imports.ui.panelMenu;
const St = imports.gi.St;
const GLib = imports.gi.GLib;
@@ -73,18 +74,17 @@ const T5 = 'trackerFocusAppTimeout';
const T6 = 'scrollPanelDelayTimeout';
const T7 = 'waitPanelBoxAllocation';
var dtpPanel = Utils.defineClass({
Name: 'DashToPanel-Panel',
Extends: St.Widget,
var Panel = GObject.registerClass({
}, class Panel extends St.Widget {
_init: function(panelManager, monitor, panelBox, isStandalone) {
this.callParent('_init', { layout_manager: new Clutter.BinLayout() });
_init(panelManager, monitor, panelBox, isStandalone) {
super._init({ layout_manager: new Clutter.BinLayout() });
this._timeoutsHandler = new Utils.TimeoutsHandler();
this._signalsHandler = new Utils.GlobalSignalsHandler();
this.panelManager = panelManager;
this.panelStyle = new PanelStyle.dtpPanelStyle();
this.panelStyle = new PanelStyle();
this.monitor = monitor;
this.panelBox = panelBox;
@@ -104,7 +104,7 @@ var dtpPanel = Utils.defineClass({
let position = this.getPosition();
if (isStandalone) {
this.panel = new dtpSecondaryPanel({ name: 'panel', reactive: true });
this.panel = new SecondaryPanel({ name: 'panel', reactive: true });
this.statusArea = this.panel.statusArea = {};
Utils.wrapActor(this.panel);
@@ -128,9 +128,9 @@ var dtpPanel = Utils.defineClass({
this.menuManager = this.panel.menuManager = new PopupMenu.PopupMenuManager(this.panel);
this._setPanelMenu('aggregateMenu', dtpSecondaryAggregateMenu, this.panel.actor);
this._setPanelMenu('aggregateMenu', SecondaryAggregateMenu, this.panel.actor);
this._setPanelMenu('dateMenu', DateMenu.DateMenuButton, this.panel.actor);
this._setPanelMenu('activities', Panel.ActivitiesButton, this.panel.actor);
this._setPanelMenu('activities', GSPanel.ActivitiesButton, this.panel.actor);
this.panel.add_child(this._leftBox);
this.panel.add_child(this._centerBox);
@@ -180,9 +180,9 @@ var dtpPanel = Utils.defineClass({
Main.ctrlAltTabManager.addGroup(this, _("Top Bar")+" "+ monitor.index, 'focus-top-bar-symbolic',
{ sortGroup: CtrlAltTab.SortGroup.TOP });
},
}
enable : function() {
enable () {
let position = this.getPosition();
if (this.statusArea.aggregateMenu) {
@@ -205,8 +205,8 @@ var dtpPanel = Utils.defineClass({
if (isTop) {
if (Config.PACKAGE_VERSION < '42') {
this.panel._leftCorner = this.panel._leftCorner || new Panel.PanelCorner(St.Side.LEFT);
this.panel._rightCorner = this.panel._rightCorner || new Panel.PanelCorner(St.Side.RIGHT);
this.panel._leftCorner = this.panel._leftCorner || new GSPanel.PanelCorner(St.Side.LEFT);
this.panel._rightCorner = this.panel._rightCorner || new GSPanel.PanelCorner(St.Side.RIGHT);
}
Main.overview._overview.insert_child_at_index(this._myPanelGhost, 0);
@@ -276,7 +276,7 @@ var dtpPanel = Utils.defineClass({
this.dynamicTransparency = new Transparency.DynamicTransparency(this);
this.taskbar = new Taskbar.taskbar(this);
this.taskbar = new Taskbar(this);
this.panel.actor.add_child(this.taskbar.actor);
@@ -389,9 +389,9 @@ var dtpPanel = Utils.defineClass({
this.set_offscreen_redirect(Clutter.OffscreenRedirect.ALWAYS);
this._initProgressManager();
},
}
disable: function () {
disable() {
this.panelStyle.disable();
this._timeoutsHandler.destroy();
@@ -472,9 +472,9 @@ var dtpPanel = Utils.defineClass({
}
Main.ctrlAltTabManager.removeGroup(this);
},
}
handleDragOver: function(source, actor, x, y, time) {
handleDragOver(source, actor, x, y, time) {
if (source == Main.xdndHandler) {
// open overview so they can choose a window for focusing
@@ -484,9 +484,9 @@ var dtpPanel = Utils.defineClass({
}
return DND.DragMotionResult.CONTINUE;
},
}
getPosition: function() {
getPosition() {
let position = PanelSettings.getPanelPosition(Me.settings, this.monitor.index);
if (position == Pos.TOP) {
@@ -498,19 +498,19 @@ var dtpPanel = Utils.defineClass({
}
return St.Side.LEFT;
},
}
checkIfVertical: function() {
checkIfVertical() {
let position = this.getPosition();
return (position == St.Side.LEFT || position == St.Side.RIGHT);
},
}
getOrientation: function() {
getOrientation() {
return (this.checkIfVertical() ? 'vertical' : 'horizontal');
},
}
updateElementPositions: function() {
updateElementPositions() {
let panelPositions = this.panelManager.panelsElementPositions[this.monitor.index] || Pos.defaults;
this._updateGroupedElements(panelPositions);
@@ -537,9 +537,9 @@ var dtpPanel = Utils.defineClass({
this.panel.actor.hide();
this.panel.actor.show();
},
}
_updateGroupedElements: function(panelPositions) {
_updateGroupedElements(panelPositions) {
let previousPosition = 0;
let previousCenteredPosition = 0;
let currentGroup = -1;
@@ -587,9 +587,9 @@ var dtpPanel = Utils.defineClass({
previousPosition = currentPosition;
}
});
},
}
_disablePanelCornerSignals: function() {
_disablePanelCornerSignals() {
if (Config.PACKAGE_VERSION < '42') {
if (this.panel._rightCorner && this.panel._rightCorner._buttonStyleChangedSignalId) {
this.panel._rightCorner._button.disconnect(this.panel._rightCorner._buttonStyleChangedSignalId);
@@ -601,9 +601,9 @@ var dtpPanel = Utils.defineClass({
delete this.panel._leftCorner._buttonStyleChangedSignalId;
}
}
},
}
_bindSettingsChanges: function() {
_bindSettingsChanges() {
let isVertical = this.checkIfVertical();
this._signalsHandler.add(
@@ -665,17 +665,17 @@ var dtpPanel = Utils.defineClass({
if (isVertical) {
this._signalsHandler.add([Me.settings, 'changed::group-apps-label-max-width', () => this._resetGeometry()]);
}
},
}
_setPanelMenu: function(propName, constr, container) {
_setPanelMenu(propName, constr, container) {
if (!this.statusArea[propName]) {
this.statusArea[propName] = this._getPanelMenu(propName, constr);
this.menuManager.addMenu(this.statusArea[propName].menu);
container.insert_child_at_index(this.statusArea[propName].container, 0);
}
},
}
_removePanelMenu: function(propName) {
_removePanelMenu(propName) {
if (this.statusArea[propName]) {
let parent = this.statusArea[propName].container.get_parent();
@@ -694,9 +694,9 @@ var dtpPanel = Utils.defineClass({
Me.persistentStorage[propName].push(panelMenu);
this.statusArea[propName] = null;
}
},
}
_getPanelMenu: function(propName, constr) {
_getPanelMenu(propName, constr) {
Me.persistentStorage[propName] = Me.persistentStorage[propName] || [];
if (!Me.persistentStorage[propName].length) {
@@ -704,13 +704,13 @@ var dtpPanel = Utils.defineClass({
}
return Me.persistentStorage[propName].pop();
},
}
_setPanelGhostSize: function() {
_setPanelGhostSize() {
this._myPanelGhost.set_size(this.width, this.checkIfVertical() ? 1 : this.height);
},
}
_setSearchEntryOffset: function(offset) {
_setSearchEntryOffset(offset) {
if (this.isPrimary) {
//In the overview, when the panel is vertical the search-entry is the only element
//that doesn't natively take into account the size of a side dock, as it is always
@@ -722,9 +722,9 @@ var dtpPanel = Utils.defineClass({
let searchEntry = Main.overview._overview._controls._searchEntry;
searchEntry.get_parent().set_style(style);
}
},
}
_adjustForOverview: function() {
_adjustForOverview() {
let isFocusedMonitor = this.panelManager.checkIfFocusedMonitor(this.monitor);
let isOverview = !!Main.overview.visibleTarget;
let isOverviewFocusedMonitor = isOverview && isFocusedMonitor;
@@ -739,9 +739,9 @@ var dtpPanel = Utils.defineClass({
Utils.getPanelGhost().set_size(1, this.geom.position == St.Side.TOP ? 0 : 32);
}
}
},
}
_resetGeometry: function() {
_resetGeometry() {
this.geom = this.getGeometry();
this._setPanelGhostSize();
this._setPanelPosition();
@@ -757,9 +757,9 @@ var dtpPanel = Utils.defineClass({
this._refreshVerticalAlloc();
this._setSearchEntryOffset(this.geom.w);
}
},
}
getGeometry: function() {
getGeometry() {
let scaleFactor = Utils.getScaleFactor();
let panelBoxTheme = this.panelBox.get_theme_node();
let lrPadding = panelBoxTheme.get_padding(St.Side.RIGHT) + panelBoxTheme.get_padding(St.Side.LEFT);
@@ -787,7 +787,7 @@ var dtpPanel = Utils.defineClass({
}
this.sizeFunc = 'get_preferred_height',
this.fixedCoord = { c1: 'x1', c2: 'x2' },
this.fixedCoord = { c1: 'x1', c2: 'x2' }
this.varCoord = { c1: 'y1', c2: 'y2' };
w = this.dtpSize;
@@ -841,9 +841,9 @@ var dtpPanel = Utils.defineClass({
tbPadding: tbPadding,
position: position
};
},
}
_setAllocationMap: function() {
_setAllocationMap() {
this.allocationMap = {};
let setMap = (name, actor, isBox) => this.allocationMap[name] = {
actor: actor,
@@ -860,13 +860,13 @@ var dtpPanel = Utils.defineClass({
setMap(Pos.SYSTEM_MENU, this.statusArea.aggregateMenu.container);
setMap(Pos.RIGHT_BOX, this._rightBox, 1);
setMap(Pos.DESKTOP_BTN, this._showDesktopButton);
},
}
_mainPanelAllocate: function(actor, box, flags) {
_mainPanelAllocate(actor, box, flags) {
Utils.setAllocation(this.panel.actor, box, flags);
},
}
vfunc_allocate: function(box, flags) {
vfunc_allocate(box, flags) {
Utils.setAllocation(this, box, flags);
let fixed = 0;
@@ -1035,9 +1035,9 @@ var dtpPanel = Utils.defineClass({
}
}
}
},
}
_setPanelPosition: function() {
_setPanelPosition() {
let clipContainer = this.panelBox.get_parent();
this.set_size(this.geom.w, this.geom.h);
@@ -1056,14 +1056,14 @@ var dtpPanel = Utils.defineClass({
Main.layoutManager._updateHotCorners();
Main.layoutManager._updatePanelBarrier(this);
},
}
_setPanelClip: function(clipContainer) {
_setPanelClip(clipContainer) {
clipContainer = clipContainer || this.panelBox.get_parent();
this._timeoutsHandler.add([T7, 0, () => Utils.setClip(clipContainer, clipContainer.x, clipContainer.y, this.panelBox.width, this.panelBox.height + this.cornerSize)]);
},
}
_onButtonPress: function(actor, event) {
_onButtonPress(actor, event) {
let type = event.type();
let isPress = type == Clutter.EventType.BUTTON_PRESS;
let button = isPress ? event.get_button() : -1;
@@ -1099,9 +1099,9 @@ var dtpPanel = Utils.defineClass({
stageX, stageY);
return Clutter.EVENT_STOP;
},
}
_getDraggableWindowForPosition: function(stageCoord, coord, dimension, maximizedProp) {
_getDraggableWindowForPosition(stageCoord, coord, dimension, maximizedProp) {
let workspace = Utils.getCurrentWorkspace();
let allWindowsByStacking = global.display.sort_windows_by_stacking(
workspace.list_windows()
@@ -1116,23 +1116,23 @@ var dtpPanel = Utils.defineClass({
metaWindow[maximizedProp] &&
stageCoord > rect[coord] && stageCoord < rect[coord] + rect[dimension];
});
},
}
_onBoxActorAdded: function(box) {
_onBoxActorAdded(box) {
if (this.checkIfVertical()) {
this._setVertical(box, true);
}
},
}
_refreshVerticalAlloc: function() {
_refreshVerticalAlloc() {
this._setVertical(this._centerBox, true);
this._setVertical(this._rightBox, true);
this._formatVerticalClock();
},
}
_setVertical: function(actor, isVertical) {
_setVertical(actor, isVertical) {
let _set = (actor, isVertical) => {
if (!actor || actor instanceof Dash.DashItemContainer || actor instanceof Taskbar.TaskbarItemContainer) {
if (!actor || actor instanceof Dash.DashItemContainer || actor instanceof TaskbarItemContainer) {
return;
}
@@ -1165,9 +1165,9 @@ var dtpPanel = Utils.defineClass({
_set(actor, false);
_set(actor, isVertical);
},
}
_disconnectVisibleId: function(actor) {
_disconnectVisibleId(actor) {
actor.disconnect(actor._dtpVisibleId);
actor.disconnect(actor._dtpDestroyId);
@@ -1175,9 +1175,9 @@ var dtpPanel = Utils.defineClass({
delete actor._dtpDestroyId;
this._unmappedButtons.splice(this._unmappedButtons.indexOf(actor), 1);
},
}
_setAppmenuVisible: function(isVisible) {
_setAppmenuVisible(isVisible) {
let parent;
let appMenu = this.statusArea.appMenu;
@@ -1191,9 +1191,9 @@ var dtpPanel = Utils.defineClass({
if (isVisible && appMenu) {
this._leftBox.insert_child_above(appMenu.container, null);
}
},
}
_formatVerticalClock: function() {
_formatVerticalClock() {
// https://github.com/GNOME/gnome-desktop/blob/master/libgnome-desktop/gnome-wall-clock.c#L310
if (this.statusArea.dateMenu) {
let datetime = this.statusArea.dateMenu._clock.clock;
@@ -1238,9 +1238,9 @@ var dtpPanel = Utils.defineClass({
setClockText(timeParts);
}
}
},
}
_setShowDesktopButton: function (add) {
_setShowDesktopButton(add) {
if (add) {
if(this._showDesktopButton)
return;
@@ -1289,9 +1289,9 @@ var dtpPanel = Utils.defineClass({
this._showDesktopButton.destroy();
this._showDesktopButton = null;
}
},
}
_setShowDesktopButtonStyle: function() {
_setShowDesktopButtonStyle() {
let rgb = this._getBackgroundBrightness() ? "rgba(55, 55, 55, .2)" : "rgba(200, 200, 200, .2)";
let isLineCustom = Me.settings.get_boolean('desktop-line-use-custom-color');
@@ -1307,14 +1307,14 @@ var dtpPanel = Utils.defineClass({
this._showDesktopButton.set_style(sytle);
this._showDesktopButton[(isVertical ? 'x' : 'y') + '_expand'] = true;
}
},
}
// _getBackgroundBrightness: return true if panel has a bright background color
_getBackgroundBrightness: function() {
_getBackgroundBrightness() {
return Utils.checkIfColorIsBright(this.dynamicTransparency.backgroundColorRgb);
},
}
_toggleWorkspaceWindows: function(hide, workspace) {
_toggleWorkspaceWindows(hide, workspace) {
let time = Me.settings.get_int('show-showdesktop-time') * .001;
workspace.list_windows().forEach(w => {
@@ -1328,9 +1328,9 @@ var dtpPanel = Utils.defineClass({
Utils.animateWindowOpacity(w.get_compositor_private(), tweenOpts);
}
});
},
}
_onShowDesktopButtonPress: function() {
_onShowDesktopButtonPress() {
let label = 'trackerFocusApp';
this._signalsHandler.removeWithLabel(label);
@@ -1370,9 +1370,9 @@ var dtpPanel = Utils.defineClass({
}
Main.overview.hide();
},
}
_onPanelMouseScroll: function(actor, event) {
_onPanelMouseScroll(actor, event) {
let scrollAction = Me.settings.get_string('scroll-panel-action');
let direction = Utils.getMouseScrollDirection(event);
@@ -1411,45 +1411,43 @@ var dtpPanel = Utils.defineClass({
this._timeoutsHandler.add([T6, scrollDelay, () => {}]);
}
}
},
}
_checkIfIgnoredScrollSource: function(source) {
_checkIfIgnoredScrollSource(source) {
let ignoredConstr = ['WorkspaceIndicator'];
return source.get_parent()._dtpIgnoreScroll || ignoredConstr.indexOf(source.constructor.name) >= 0;
},
}
_initProgressManager: function() {
_initProgressManager() {
if(!this.progressManager && (Me.settings.get_boolean('progress-show-bar') || Me.settings.get_boolean('progress-show-count')))
this.progressManager = new Progress.ProgressManager();
},
}
});
var dtpSecondaryPanel = Utils.defineClass({
Name: 'DashToPanel-SecondaryPanel',
Extends: St.Widget,
var SecondaryPanel = GObject.registerClass({
}, class SecondaryPanel extends St.Widget {
_init: function(params) {
this.callParent('_init', params);
},
_init(params) {
super._init(params);
}
vfunc_allocate: function(box, flags) {
vfunc_allocate(box, flags) {
Utils.setAllocation(this, box, flags);
}
});
var dtpSecondaryAggregateMenu = Utils.defineClass({
Name: 'DashToPanel-SecondaryAggregateMenu',
Extends: PanelMenu.Button,
var SecondaryAggregateMenu = GObject.registerClass({
}, class SecondaryAggregateMenu extends PanelMenu.Button {
_init: function() {
this.callParent('_init', 0.0, C_("System menu in the top bar", "System"), false);
_init() {
super._init(0.0, C_("System menu in the top bar", "System"), false);
Utils.wrapActor(this);
this.menu.actor.add_style_class_name('aggregate-menu');
let menuLayout = new Panel.AggregateLayout();
let menuLayout = new GSPanel.AggregateLayout();
this.menu.box.set_layout_manager(menuLayout);
this._indicators = new St.BoxLayout({ style_class: 'panel-status-indicators-box' });
@@ -1515,5 +1513,5 @@ var dtpSecondaryAggregateMenu = Utils.defineClass({
menuLayout.addSizeChild(this._power.menu.actor);
menuLayout.addSizeChild(this._system.menu.actor);
},
}
});

View File

@@ -28,8 +28,8 @@
*/
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Overview = Me.imports.overview;
const Panel = Me.imports.panel;
const { Overview } = Me.imports.overview;
const { Panel, panelBoxes } = Me.imports.panel;
const PanelSettings = Me.imports.panelSettings;
const Proximity = Me.imports.proximity;
const Taskbar = Me.imports.taskbar;
@@ -55,11 +55,10 @@ const Layout = imports.ui.layout;
const WM = imports.ui.windowManager;
const WorkspacesView = imports.ui.workspacesView;
var dtpPanelManager = Utils.defineClass({
Name: 'DashToPanel.PanelManager',
var PanelManager = class {
_init: function() {
this.overview = new Overview.dtpOverview();
constructor() {
this.overview = new Overview();
this.panelsElementPositions = {};
this._saveMonitors();
@@ -68,9 +67,9 @@ var dtpPanelManager = Utils.defineClass({
Utils.wrapActor(v.view);
Utils.wrapActor(v.view._grid);
});
},
}
enable: function(reset) {
enable(reset) {
let dtpPrimaryIndex = Me.settings.get_int('primary-monitor');
this.dtpPrimaryMonitor = Main.layoutManager.monitors[dtpPrimaryIndex] || Main.layoutManager.primaryMonitor;
@@ -254,7 +253,7 @@ var dtpPanelManager = Utils.defineClass({
]
);
Panel.panelBoxes.forEach(c => this._signalsHandler.add(
panelBoxes.forEach(c => this._signalsHandler.add(
[Main.panel[c], 'actor-added', (parent, child) => this._adjustPanelMenuButton(this._getPanelMenuButton(child), this.primaryPanel.monitor, this.primaryPanel.getPosition())]
));
@@ -262,10 +261,10 @@ var dtpPanelManager = Utils.defineClass({
// keep GS overview.js from blowing away custom panel styles
if(!Me.settings.get_boolean('stockgs-keep-top-panel'))
Object.defineProperty(Main.panel, "style", {configurable: true, set: function(v) {}});
},
Object.defineProperty(Main.panel, "style", {configurable: true, set(v) {}});
}
disable: function(reset) {
disable(reset) {
this.overview.disable();
this.proximityManager.destroy();
@@ -351,9 +350,9 @@ var dtpPanelManager = Utils.defineClass({
delete LookingGlass.LookingGlass.prototype._oldOpen
delete Main.panel.style;
},
}
setFocusedMonitor: function(monitor, ignoreRelayout) {
setFocusedMonitor(monitor, ignoreRelayout) {
// todo show overview on non primary monitor is not working right now on gnome40
// this._needsIconAllocate = 1;
@@ -364,9 +363,9 @@ var dtpPanelManager = Utils.defineClass({
// Main.overview._overview.clear_constraints();
// Main.overview._overview.add_constraint(new Layout.MonitorConstraint({ index: monitor.index }));
// }
},
}
_saveMonitors: function() {
_saveMonitors() {
//Mutter meta_monitor_manager_get_primary_monitor (global.display.get_primary_monitor()) doesn't return the same
//monitor as GDK gdk_screen_get_primary_monitor (imports.gi.Gdk.Screen.get_default().get_primary_monitor()).
//Since the Mutter function is what's used in gnome-shell and we can't access it from the settings dialog, store
@@ -376,13 +375,13 @@ var dtpPanelManager = Utils.defineClass({
Main.layoutManager.monitors.filter(m => m.index != primaryIndex).forEach(m => monitors.push(m.index));
Me.settings.set_value('available-monitors', new GLib.Variant('ai', monitors));
},
}
checkIfFocusedMonitor: function(monitor) {
checkIfFocusedMonitor(monitor) {
return Main.overview._overview._controls._workspacesDisplay._primaryIndex == monitor.index;
},
}
_createPanel: function(monitor, isStandalone) {
_createPanel(monitor, isStandalone) {
let panelBox;
let panel;
let clipContainer = new Clutter.Actor();
@@ -400,7 +399,7 @@ var dtpPanelManager = Utils.defineClass({
clipContainer.add_child(panelBox);
Main.layoutManager.trackChrome(panelBox, { trackFullscreen: true, affectsStruts: true, affectsInputRegion: true });
panel = new Panel.dtpPanel(this, monitor, panelBox, isStandalone);
panel = new Panel(this, monitor, panelBox, isStandalone);
panelBox.add(panel);
panel.enable();
@@ -411,20 +410,20 @@ var dtpPanelManager = Utils.defineClass({
panelBox.set_position(0, 0);
return panel;
},
}
_reset: function() {
_reset() {
this.disable(true);
this.allPanels = [];
this.enable(true);
},
}
_updatePanelElementPositions: function() {
_updatePanelElementPositions() {
this.panelsElementPositions = PanelSettings.getSettingsJson(Me.settings, 'panel-element-positions');
this.allPanels.forEach(p => p.updateElementPositions());
},
}
_adjustPanelMenuButton: function(button, monitor, arrowSide) {
_adjustPanelMenuButton(button, monitor, arrowSide) {
if (button) {
Utils.wrapActor(button);
button.menu._boxPointer._dtpSourceActor = button.menu._boxPointer.sourceActor;
@@ -438,9 +437,9 @@ var dtpPanelManager = Utils.defineClass({
});
}
}
},
}
_getBoxPointerPreferredHeight: function(boxPointer, alloc, monitor) {
_getBoxPointerPreferredHeight(boxPointer, alloc, monitor) {
if (boxPointer._dtpInPanel && boxPointer.sourceActor && Me.settings.get_boolean('intellihide')) {
monitor = monitor || Main.layoutManager.findMonitorForActor(boxPointer.sourceActor);
let panel = Utils.find(global.dashToPanel.panels, p => p.monitor == monitor);
@@ -452,9 +451,9 @@ var dtpPanelManager = Utils.defineClass({
}
return [alloc.min_size, alloc.natural_size];
},
}
_findPanelMenuButtons: function(container) {
_findPanelMenuButtons(container) {
let panelMenuButtons = [];
let panelMenuButton;
@@ -469,9 +468,9 @@ var dtpPanelManager = Utils.defineClass({
find(container);
return panelMenuButtons;
},
}
_removePanelBarriers: function(panel) {
_removePanelBarriers(panel) {
if (panel.isStandalone && panel._rightPanelBarrier) {
panel._rightPanelBarrier.destroy();
}
@@ -480,13 +479,13 @@ var dtpPanelManager = Utils.defineClass({
panel._leftPanelBarrier.destroy();
delete panel._leftPanelBarrier;
}
},
}
_getPanelMenuButton: function(obj) {
_getPanelMenuButton(obj) {
return obj._delegate && obj._delegate instanceof PanelMenu.Button ? obj._delegate : 0;
},
}
_setKeyBindings: function(enable) {
_setKeyBindings(enable) {
let keys = {
'intellihide-key-toggle': () => this.allPanels.forEach(p => p.intellihide.toggle())
};
@@ -498,21 +497,20 @@ var dtpPanelManager = Utils.defineClass({
Utils.addKeybinding(k, Me.settings, keys[k], Shell.ActionMode.NORMAL);
}
});
},
}
_newGetShowAppsButton: function() {
_newGetShowAppsButton() {
let focusedMonitorIndex = Utils.findIndex(this.allPanels, p => this.checkIfFocusedMonitor(p.monitor));
return this.allPanels[focusedMonitorIndex].taskbar.showAppsButton;
}
});
};
// This class drives long-running icon animations, to keep them running in sync
// with each other.
var IconAnimator = Utils.defineClass({
Name: 'DashToPanel.IconAnimator',
var IconAnimator = class {
_init: function(actor) {
constructor(actor) {
this._count = 0;
this._started = false;
this._animations = {
@@ -535,9 +533,9 @@ var IconAnimator = Utils.defineClass({
dancers[i].target.rotation_angle_z = danceRotation;
}
});
},
}
destroy: function() {
destroy() {
this._timeline.stop();
this._timeline = null;
for (let name in this._animations) {
@@ -548,32 +546,32 @@ var IconAnimator = Utils.defineClass({
}
}
this._animations = null;
},
}
pause: function() {
pause() {
if (this._started && this._count > 0) {
this._timeline.stop();
}
this._started = false;
},
}
start: function() {
start() {
if (!this._started && this._count > 0) {
this._timeline.start();
}
this._started = true;
},
}
addAnimation: function(target, name) {
addAnimation(target, name) {
const targetDestroyId = target.connect('destroy', () => this.removeAnimation(target, name));
this._animations[name].push({ target: target, targetDestroyId: targetDestroyId });
if (this._started && this._count === 0) {
this._timeline.start();
}
this._count++;
},
}
removeAnimation: function(target, name) {
removeAnimation(target, name) {
const pairs = this._animations[name];
for (let i = 0, iMax = pairs.length; i < iMax; i++) {
const pair = pairs[i];
@@ -588,7 +586,7 @@ var IconAnimator = Utils.defineClass({
}
}
}
});
};
function newGetPositionForDirection(direction, fromWs, toWs) {
let [xDest, yDest] = WM.WindowManager.prototype._getPositionForDirection(direction, fromWs, toWs);

View File

@@ -33,30 +33,25 @@ const Panel = Me.imports.panel;
const Taskbar = Me.imports.taskbar;
const Utils = Me.imports.utils;
var dtpPanelStyle = Utils.defineClass({
Name: 'DashToPanel.PanelStyle',
var PanelStyle = class {
_init: function() {
},
enable : function(panel) {
enable(panel) {
this.panel = panel;
this._applyStyles();
this._bindSettingsChanges();
},
}
disable: function () {
disable() {
for (let i = 0; i < this._dtpSettingsSignalIds.length; ++i) {
Me.settings.disconnect(this._dtpSettingsSignalIds[i]);
}
this._removeStyles();
},
}
_bindSettingsChanges: function() {
_bindSettingsChanges() {
let configKeys = [
"tray-size",
"leftbox-size",
@@ -73,9 +68,9 @@ var dtpPanelStyle = Utils.defineClass({
this._applyStyles();
})));
}
},
}
_applyStyles: function() {
_applyStyles() {
this._rightBoxOperations = [];
let trayPadding = Me.settings.get_int('tray-padding');
@@ -218,9 +213,9 @@ var dtpPanelStyle = Utils.defineClass({
this._recursiveApply(actor, this._leftBoxOperations);
})
);
},
}
_removeStyles: function() {
_removeStyles() {
/* disconnect signal */
if (this._rightBoxActorAddedID)
this.panel._rightBox.disconnect(this._rightBoxActorAddedID);
@@ -234,9 +229,9 @@ var dtpPanelStyle = Utils.defineClass({
this._restoreOriginalStyle(this.panel._leftBox);
this._applyStylesRecursively(true);
},
}
_applyStylesRecursively: function(restore) {
_applyStylesRecursively(restore) {
/*recurse actors */
if(this._rightBoxOperations.length) {
// add the system menu as we move it from the rightbox to the panel to position it independently
@@ -257,9 +252,9 @@ var dtpPanelStyle = Utils.defineClass({
for(let i in children)
this._recursiveApply(children[i], this._leftBoxOperations, restore);
}
},
}
_recursiveApply: function(actor, operations, restore) {
_recursiveApply(actor, operations, restore) {
for(let i in operations) {
let o = operations[i];
if(o.compareFn(actor))
@@ -275,9 +270,9 @@ var dtpPanelStyle = Utils.defineClass({
this._recursiveApply(children[i], operations, restore);
}
}
},
}
_overrideStyle: function(actor, styleLine, operationIdx) {
_overrideStyle(actor, styleLine, operationIdx) {
if (actor._dtp_original_inline_style === undefined) {
actor._dtp_original_inline_style = actor.get_style();
}
@@ -291,9 +286,9 @@ var dtpPanelStyle = Utils.defineClass({
for(let i in actor._dtp_style_overrides)
newStyleLine += actor._dtp_style_overrides[i] + '; ';
actor.set_style(newStyleLine + (actor._dtp_original_inline_style || ''));
},
}
_restoreOriginalStyle: function(actor) {
_restoreOriginalStyle(actor) {
if (actor._dtp_original_inline_style !== undefined) {
actor.set_style(actor._dtp_original_inline_style);
delete actor._dtp_original_inline_style;
@@ -303,9 +298,9 @@ var dtpPanelStyle = Utils.defineClass({
if (actor.has_style_class_name('panel-button')) {
this._refreshPanelButton(actor);
}
},
}
_refreshPanelButton: function(actor) {
_refreshPanelButton(actor) {
if (actor.visible && imports.misc.config.PACKAGE_VERSION >= '3.34.0') {
//force gnome 3.34+ to refresh (having problem with the -natural-hpadding)
let parent = actor.get_parent();
@@ -323,4 +318,4 @@ var dtpPanelStyle = Utils.defineClass({
}
}
});
}

View File

@@ -26,7 +26,6 @@ const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
const Adw = imports.gi.Adw;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Config = imports.misc.config;
@@ -2466,7 +2465,8 @@ function fillPreferencesWindow(window) {
let preferences = new Preferences();
let box = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL});
box.append(new Adw.HeaderBar);
imports.gi.Adw && box.append(new imports.gi.Adw.HeaderBar);
box.append(preferences.notebook);
window.set_content(box);
}

View File

@@ -29,11 +29,9 @@ const Signals = imports.signals;
const Utils = Me.imports.utils;
var ProgressManager = Utils.defineClass({
Name: 'DashToPanel.ProgressManager',
_init: function() {
var ProgressManager = class {
constructor() {
this._entriesByDBusName = {};
this._launcher_entry_dbus_signal_id =
@@ -55,9 +53,9 @@ var ProgressManager = Utils.defineClass({
this._onDBusNameOwnerChanged.bind(this));
this._acquireUnityDBus();
},
}
destroy: function() {
destroy() {
if (this._launcher_entry_dbus_signal_id) {
Gio.DBus.session.signal_unsubscribe(this._launcher_entry_dbus_signal_id);
}
@@ -67,17 +65,17 @@ var ProgressManager = Utils.defineClass({
}
this._releaseUnityDBus();
},
}
size: function() {
size() {
return Object.keys(this._entriesByDBusName).length;
},
}
lookupByDBusName: function(dbusName) {
lookupByDBusName(dbusName) {
return this._entriesByDBusName.hasOwnProperty(dbusName) ? this._entriesByDBusName[dbusName] : null;
},
}
lookupById: function(appId) {
lookupById(appId) {
let ret = [];
for (let dbusName in this._entriesByDBusName) {
let entry = this._entriesByDBusName[dbusName];
@@ -87,9 +85,9 @@ var ProgressManager = Utils.defineClass({
}
return ret;
},
}
addEntry: function(entry) {
addEntry(entry) {
let existingEntry = this.lookupByDBusName(entry.dbusName());
if (existingEntry) {
existingEntry.update(entry);
@@ -97,28 +95,28 @@ var ProgressManager = Utils.defineClass({
this._entriesByDBusName[entry.dbusName()] = entry;
this.emit('progress-entry-added', entry);
}
},
}
removeEntry: function(entry) {
removeEntry(entry) {
delete this._entriesByDBusName[entry.dbusName()]
this.emit('progress-entry-removed', entry);
},
}
_acquireUnityDBus: function() {
_acquireUnityDBus() {
if (!this._unity_bus_id) {
Gio.DBus.session.own_name('com.canonical.Unity',
Gio.BusNameOwnerFlags.ALLOW_REPLACEMENT, null, null);
}
},
}
_releaseUnityDBus: function() {
_releaseUnityDBus() {
if (this._unity_bus_id) {
Gio.DBus.session.unown_name(this._unity_bus_id);
this._unity_bus_id = 0;
}
},
}
_onEntrySignalReceived: function(connection, sender_name, object_path,
_onEntrySignalReceived(connection, sender_name, object_path,
interface_name, signal_name, parameters, user_data) {
if (!parameters || !signal_name)
return;
@@ -130,9 +128,9 @@ var ProgressManager = Utils.defineClass({
this._handleUpdateRequest(sender_name, parameters);
}
},
}
_onDBusNameOwnerChanged: function(connection, sender_name, object_path,
_onDBusNameOwnerChanged(connection, sender_name, object_path,
interface_name, signal_name, parameters, user_data) {
if (!parameters || !this.size())
return;
@@ -144,9 +142,9 @@ var ProgressManager = Utils.defineClass({
this.removeEntry(this._entriesByDBusName[before]);
}
}
},
}
_handleUpdateRequest: function(senderName, parameters) {
_handleUpdateRequest(senderName, parameters) {
if (!senderName || !parameters) {
return;
}
@@ -163,13 +161,12 @@ var ProgressManager = Utils.defineClass({
this.addEntry(entry);
}
}
});
};
Signals.addSignalMethods(ProgressManager.prototype);
var AppProgress = Utils.defineClass({
Name: 'DashToPanel.AppProgress',
class AppProgress {
_init: function(dbusName, appId, properties) {
constructor(dbusName, appId, properties) {
this._dbusName = dbusName;
this._appId = appId;
this._count = 0;
@@ -178,80 +175,80 @@ var AppProgress = Utils.defineClass({
this._progressVisible = false;
this._urgent = false;
this.update(properties);
},
}
appId: function() {
appId() {
return this._appId;
},
}
dbusName: function() {
dbusName() {
return this._dbusName;
},
}
count: function() {
count() {
return this._count;
},
}
setCount: function(count) {
setCount(count) {
if (this._count != count) {
this._count = count;
this.emit('count-changed', this._count);
}
},
}
countVisible: function() {
countVisible() {
return this._countVisible;
},
}
setCountVisible: function(countVisible) {
setCountVisible(countVisible) {
if (this._countVisible != countVisible) {
this._countVisible = countVisible;
this.emit('count-visible-changed', this._countVisible);
}
},
}
progress: function() {
progress() {
return this._progress;
},
}
setProgress: function(progress) {
setProgress(progress) {
if (this._progress != progress) {
this._progress = progress;
this.emit('progress-changed', this._progress);
}
},
}
progressVisible: function() {
progressVisible() {
return this._progressVisible;
},
}
setProgressVisible: function(progressVisible) {
setProgressVisible(progressVisible) {
if (this._progressVisible != progressVisible) {
this._progressVisible = progressVisible;
this.emit('progress-visible-changed', this._progressVisible);
}
},
}
urgent: function() {
urgent() {
return this._urgent;
},
}
setUrgent: function(urgent) {
setUrgent(urgent) {
if (this._urgent != urgent) {
this._urgent = urgent;
this.emit('urgent-changed', this._urgent);
}
},
}
setDBusName: function(dbusName) {
setDBusName(dbusName) {
if (this._dbusName != dbusName) {
let oldName = this._dbusName;
this._dbusName = dbusName;
this.emit('dbus-name-changed', oldName);
}
},
}
update: function(other) {
update(other) {
if (other instanceof AppProgress) {
this.setDBusName(other.dbusName())
this.setCount(other.count());
@@ -279,14 +276,13 @@ var AppProgress = Utils.defineClass({
}
}
}
});
};
Signals.addSignalMethods(AppProgress.prototype);
var ProgressIndicator = Utils.defineClass({
Name: 'DashToPanel.ProgressIndicator',
var ProgressIndicator = class {
_init: function(source, progressManager) {
constructor(source, progressManager) {
this._source = source;
this._progressManager = progressManager;
this._signalsHandler = new Utils.GlobalSignalsHandler();
@@ -322,36 +318,36 @@ var ProgressIndicator = Utils.defineClass({
'progress-entry-removed',
this._onEntryRemoved.bind(this)
]);
},
}
destroy: function() {
destroy() {
this._source.actor.disconnect(this._sourceDestroyId);
this._signalsHandler.destroy();
},
}
_onEntryAdded: function(appProgress, entry) {
_onEntryAdded(appProgress, entry) {
if (!entry || !entry.appId())
return;
if (this._source && this._source.app && this._source.app.id == entry.appId()) {
this.insertEntry(entry);
}
},
}
_onEntryRemoved: function(appProgress, entry) {
_onEntryRemoved(appProgress, entry) {
if (!entry || !entry.appId())
return;
if (this._source && this._source.app && this._source.app.id == entry.appId()) {
this.removeEntry(entry);
}
},
}
updateNotificationBadge: function() {
updateNotificationBadge() {
this._source.updateNumberOverlay(this._notificationBadgeBin);
this._notificationBadgeLabel.clutter_text.ellipsize = Pango.EllipsizeMode.MIDDLE;
},
}
_notificationBadgeCountToText: function(count) {
_notificationBadgeCountToText(count) {
if (count <= 9999) {
return count.toString();
} else if (count < 1e5) {
@@ -370,24 +366,24 @@ var ProgressIndicator = Utils.defineClass({
let billions = count / 1e9;
return billions.toFixed(1).toString() + "B";
}
},
}
setNotificationBadge: function(count) {
setNotificationBadge(count) {
this._notificationBadgeCount = count;
let text = this._notificationBadgeCountToText(count);
this._notificationBadgeLabel.set_text(text);
},
}
toggleNotificationBadge: function(activate) {
toggleNotificationBadge(activate) {
if (activate && this._notificationBadgeCount > 0) {
this.updateNotificationBadge();
this._notificationBadgeBin.show();
}
else
this._notificationBadgeBin.hide();
},
}
_showProgressOverlay: function() {
_showProgressOverlay() {
if (this._progressOverlayArea) {
this._updateProgressOverlay();
return;
@@ -415,25 +411,25 @@ var ProgressIndicator = Utils.defineClass({
this._progressbar_border = new Clutter.Color({red: 230, green: 230, blue: 230, alpha: 255});
this._updateProgressOverlay();
},
}
_hideProgressOverlay: function() {
_hideProgressOverlay() {
if (this._progressOverlayArea)
this._progressOverlayArea.destroy();
this._progressOverlayArea = null;
this._progressbar_background = null;
this._progressbar_border = null;
},
}
_updateProgressOverlay: function() {
_updateProgressOverlay() {
if (this._progressOverlayArea) {
this._progressOverlayArea.queue_repaint();
}
},
}
_drawProgressOverlay: function(area) {
_drawProgressOverlay(area) {
let scaleFactor = Utils.getScaleFactor();
let [surfaceWidth, surfaceHeight] = area.get_surface_size();
let cr = area.get_context();
@@ -491,31 +487,31 @@ var ProgressIndicator = Utils.defineClass({
Utils.drawRoundedLine(cr, x + lineWidth/2.0, y + lineWidth/2.0, finishedWidth, height, true, true, stroke, fill);
cr.$dispose();
},
}
setProgress: function(progress) {
setProgress(progress) {
this._progress = Math.min(Math.max(progress, 0.0), 1.0);
this._updateProgressOverlay();
},
}
toggleProgressOverlay: function(activate) {
toggleProgressOverlay(activate) {
if (activate) {
this._showProgressOverlay();
}
else {
this._hideProgressOverlay();
}
},
}
insertEntry: function(appProgress) {
insertEntry(appProgress) {
if (!appProgress || this._progressManagerEntries.indexOf(appProgress) !== -1)
return;
this._progressManagerEntries.push(appProgress);
this._selectEntry(appProgress);
},
}
removeEntry: function(appProgress) {
removeEntry(appProgress) {
if (!appProgress || this._progressManagerEntries.indexOf(appProgress) == -1)
return;
@@ -530,9 +526,9 @@ var ProgressIndicator = Utils.defineClass({
this.toggleProgressOverlay(false);
this.setUrgent(false);
}
},
}
_selectEntry: function(appProgress) {
_selectEntry(appProgress) {
if (!appProgress)
return;
@@ -577,9 +573,9 @@ var ProgressIndicator = Utils.defineClass({
this.toggleProgressOverlay(appProgress.progressVisible());
this._isUrgent = false;
},
}
setUrgent: function(urgent) {
setUrgent(urgent) {
const icon = this._source.icon._iconBin;
if (urgent) {
if (!this._isUrgent) {
@@ -595,4 +591,4 @@ var ProgressIndicator = Utils.defineClass({
icon.rotation_angle_z = 0;
}
}
});
};

View File

@@ -36,10 +36,9 @@ var Mode = {
MAXIMIZED_WINDOWS: 2
};
var ProximityWatch = Utils.defineClass({
Name: 'DashToPanel.ProximityWatch',
class ProximityWatch {
_init: function(actor, mode, xThreshold, yThreshold, handler) {
constructor(actor, mode, xThreshold, yThreshold, handler) {
this.actor = actor;
this.overlap = 0;
this.mode = mode;
@@ -49,19 +48,19 @@ var ProximityWatch = Utils.defineClass({
this._allocationChangedId = actor.connect('notify::allocation', () => this._update());
this._update();
},
}
destroy: function() {
destroy() {
this.actor.disconnect(this._allocationChangedId);
},
_update: function() {
}
_update() {
this.monitorIndex = Main.layoutManager.findIndexForActor(this.actor);
this._updateWatchRect();
},
}
_updateWatchRect: function() {
_updateWatchRect() {
let [actorX, actorY] = this.actor.get_position();
this.rect = new Meta.Rectangle({
@@ -70,13 +69,12 @@ var ProximityWatch = Utils.defineClass({
width: this.actor.width + this.threshold[0] * 2,
height: this.actor.height + this.threshold[1] * 2
});
},
});
}
};
var ProximityManager = Utils.defineClass({
Name: 'DashToPanel.ProximityManager',
var ProximityManager = class {
_init: function() {
constructor() {
this._counter = 1;
this._watches = {};
this._focusedWindowInfo = null;
@@ -86,36 +84,36 @@ var ProximityManager = Utils.defineClass({
this._bindSignals();
this._setFocusedWindow();
},
}
createWatch: function(actor, mode, xThreshold, yThreshold, handler) {
createWatch(actor, mode, xThreshold, yThreshold, handler) {
let watch = new ProximityWatch(actor, mode, xThreshold, yThreshold, handler);
this._watches[this._counter] = watch;
this.update();
return this._counter++;
},
}
removeWatch: function(id) {
removeWatch(id) {
if (this._watches[id]) {
this._watches[id].destroy();
delete this._watches[id];
}
},
}
update: function() {
update() {
this._queueUpdate(true);
},
}
destroy: function() {
destroy() {
this._signalsHandler.destroy();
this._timeoutsHandler.destroy();
this._disconnectFocusedWindow();
Object.keys(this._watches).forEach(id => this.removeWatch(id));
},
}
_bindSignals: function() {
_bindSignals() {
this._signalsHandler.add(
[
global.window_manager,
@@ -144,9 +142,9 @@ var ProximityManager = Utils.defineClass({
() => this._queueUpdate()
]
);
},
}
_setFocusedWindow: function() {
_setFocusedWindow() {
this._disconnectFocusedWindow();
let focusedWindow = global.display.focus_window;
@@ -161,9 +159,9 @@ var ProximityManager = Utils.defineClass({
this._focusedWindowInfo = focusedWindowInfo;
}
}
},
}
_getFocusedWindowInfo: function(focusedWindow) {
_getFocusedWindowInfo(focusedWindow) {
let window = focusedWindow.get_compositor_private();
let focusedWindowInfo;
@@ -182,38 +180,38 @@ var ProximityManager = Utils.defineClass({
}
return focusedWindowInfo;
},
}
_disconnectFocusedWindow: function(destroy) {
_disconnectFocusedWindow(destroy) {
if (this._focusedWindowInfo && !destroy) {
this._focusedWindowInfo.window.disconnect(this._focusedWindowInfo.allocationId);
this._focusedWindowInfo.window.disconnect(this._focusedWindowInfo.destroyId);
}
this._focusedWindowInfo = null;
},
}
_getHandledWindows: function() {
_getHandledWindows() {
return global.get_window_actors()
.filter(w => w.visible)
.map(w => w.get_meta_window())
.filter(mw => this._checkIfHandledWindow(mw));
},
}
_checkIfHandledWindow: function(metaWindow) {
_checkIfHandledWindow(metaWindow) {
return metaWindow && !metaWindow.minimized &&
this._checkIfHandledWindowType(metaWindow);
},
}
_checkIfHandledWindowType: function(metaWindow) {
_checkIfHandledWindowType(metaWindow) {
let metaWindowType = metaWindow.get_window_type();
//https://www.roojs.org/seed/gir-1.2-gtk-3.0/seed/Meta.WindowType.html
return metaWindowType <= Meta.WindowType.SPLASHSCREEN &&
metaWindowType != Meta.WindowType.DESKTOP;
},
}
_queueUpdate: function(noDelay) {
_queueUpdate(noDelay) {
if (!noDelay && this._timeoutsHandler.getId(T1)) {
//limit the number of updates
this._pendingUpdate = true;
@@ -233,16 +231,16 @@ var ProximityManager = Utils.defineClass({
watch.overlap = overlap;
}
});
},
}
_endLimitUpdate: function() {
_endLimitUpdate() {
if (this._pendingUpdate) {
this._pendingUpdate = false;
this._queueUpdate();
}
},
}
_update: function(watch, metaWindows) {
_update(watch, metaWindows) {
if (watch.mode === Mode.FOCUSED_WINDOWS) {
return (this._focusedWindowInfo &&
this._checkIfHandledWindow(this._focusedWindowInfo.metaWindow) &&
@@ -254,9 +252,9 @@ var ProximityManager = Utils.defineClass({
//Mode.ALL_WINDOWS
return metaWindows.some(mw => this._checkProximity(mw, watch));
},
}
_checkProximity: function(metaWindow, watch) {
_checkProximity(metaWindow, watch) {
return metaWindow.get_frame_rect().overlap(watch.rect);
},
});
}
};

View File

@@ -72,7 +72,7 @@ function extendDashItemContainer(dashItemContainer) {
};
const iconAnimationSettings = {
_getDictValue: function(key) {
_getDictValue(key) {
let type = Me.settings.get_string('animate-appicon-hover-animation-type');
return Me.settings.get_value(key).deep_unpack()[type] || 0;
},
@@ -115,19 +115,17 @@ const iconAnimationSettings = {
* - modified chldBox calculations for when 'show-apps-at-top' option is checked
* - handle horizontal dash
*/
var taskbarActor = Utils.defineClass({
Name: 'DashToPanel-TaskbarActor',
Extends: St.Widget,
_init: function(delegate) {
var TaskbarActor = GObject.registerClass({
}, class TaskbarActor extends St.Widget {
_init(delegate) {
this._delegate = delegate;
this._currentBackgroundColor = 0;
this.callParent('_init', { name: 'dashtopanelTaskbar',
layout_manager: new Clutter.BoxLayout({ orientation: Clutter.Orientation[delegate.dtpPanel.getOrientation().toUpperCase()] }),
clip_to_allocation: true });
},
super._init({ name: 'dashtopanelTaskbar',
layout_manager: new Clutter.BoxLayout({ orientation: Clutter.Orientation[delegate.dtpPanel.getOrientation().toUpperCase()] }),
clip_to_allocation: true });
}
vfunc_allocate: function(box, flags)  {
vfunc_allocate(box, flags) {
Utils.setAllocation(this, box, flags);
let panel = this._delegate.dtpPanel;
@@ -166,22 +164,22 @@ var taskbarActor = Utils.defineClass({
childBox[panel.varCoord.c1] = box[panel.varCoord.c2] - (value + pageSize < upper ? scrollview._dtpFadeSize : 0);
childBox[panel.varCoord.c2] = box[panel.varCoord.c2];
Utils.allocate(rightFade, childBox, flags);
},
}
// We want to request the natural size of all our children
// as our natural width, so we chain up to StWidget (which
// then calls BoxLayout)
vfunc_get_preferred_width: function(forHeight) {
vfunc_get_preferred_width(forHeight) {
let [, natWidth] = St.Widget.prototype.vfunc_get_preferred_width.call(this, forHeight);
return [0, natWidth];
},
}
vfunc_get_preferred_height: function(forWidth) {
vfunc_get_preferred_height(forWidth) {
let [, natHeight] = St.Widget.prototype.vfunc_get_preferred_height.call(this, forWidth);
return [0, natHeight];
},
}
});
/* This class is a fork of the upstream dash class (ui.dash.js)
@@ -198,10 +196,9 @@ var taskbarActor = Utils.defineClass({
* - Sync minimization application target position.
*/
var taskbar = Utils.defineClass({
Name: 'DashToPanel.Taskbar',
var Taskbar = class {
_init : function(panel) {
constructor(panel) {
this.dtpPanel = panel;
// start at smallest size due to running indicator drawing area expanding but not shrinking
@@ -224,7 +221,7 @@ var taskbar = Utils.defineClass({
x_align: Clutter.ActorAlign.START,
y_align: Clutter.ActorAlign.START });
this._container = new taskbarActor(this);
this._container = new TaskbarActor(this);
this._scrollView = new St.ScrollView({ name: 'dashtopanelScrollview',
hscrollbar_policy: Gtk.PolicyType.NEVER,
vscrollbar_policy: Gtk.PolicyType.NEVER,
@@ -398,9 +395,9 @@ var taskbar = Utils.defineClass({
this._onScrollSizeChange(adjustment);
this._connectWorkspaceSignals();
},
}
destroy: function() {
destroy() {
this.iconAnimator.destroy();
this._signalsHandler.destroy();
@@ -412,16 +409,16 @@ var taskbar = Utils.defineClass({
this.previewMenu.destroy();
this._disconnectWorkspaceSignals();
},
}
_dropIconAnimations: function() {
_dropIconAnimations() {
this._getTaskbarIcons().forEach(item => {
item.raise(0);
item.stretch(0);
});
},
}
_updateIconAnimations: function(pointerX, pointerY) {
_updateIconAnimations(pointerX, pointerY) {
this._iconAnimationTimestamp = Date.now();
let type = iconAnimationSettings.type;
@@ -458,18 +455,18 @@ var taskbar = Utils.defineClass({
item.raise(0);
}
});
},
}
_onLeaveEvent: function(actor) {
_onLeaveEvent(actor) {
let [stageX, stageY] = global.get_pointer();
let [success, x, y] = actor.transform_stage_point(stageX, stageY);
if (success && !actor.allocation.contains(x, y) && (iconAnimationSettings.type == 'RIPPLE' || iconAnimationSettings.type == 'PLANK'))
this._dropIconAnimations();
return Clutter.EVENT_PROPAGATE;
},
}
_onMotionEvent: function(actor_, event) {
_onMotionEvent(actor_, event) {
if (iconAnimationSettings.type == 'RIPPLE' || iconAnimationSettings.type == 'PLANK') {
let timestamp = Date.now();
if (!this._iconAnimationTimestamp ||
@@ -480,9 +477,9 @@ var taskbar = Utils.defineClass({
}
return Clutter.EVENT_PROPAGATE;
},
}
_onScrollEvent: function(actor, event) {
_onScrollEvent(actor, event) {
let orientation = this.dtpPanel.getOrientation();
@@ -523,9 +520,9 @@ var taskbar = Utils.defineClass({
return Clutter.EVENT_STOP;
},
}
_onScrollSizeChange: function(adjustment) {
_onScrollSizeChange(adjustment) {
// Update minimization animation target position on scrollview change.
this._updateAppIcons();
@@ -546,9 +543,9 @@ var taskbar = Utils.defineClass({
this._getAppIcons().forEach(a => a.updateTitleStyle());
}
}
},
}
_onDragBegin: function() {
_onDragBegin() {
this._dragCancelled = false;
this._dragMonitor = {
dragMotion: Lang.bind(this, this._onDragMotion)
@@ -562,9 +559,9 @@ var taskbar = Utils.defineClass({
}
this._toggleFavortieHighlight(true);
},
}
_onDragCancelled: function() {
_onDragCancelled() {
this._dragCancelled = true;
if (this._dragInfo) {
@@ -572,16 +569,16 @@ var taskbar = Utils.defineClass({
}
this._endDrag();
},
}
_onDragEnd: function() {
_onDragEnd() {
if (this._dragCancelled)
return;
this._endDrag();
},
}
_endDrag: function() {
_endDrag() {
if (this._dragInfo && this._dragInfo[1]._dashItemContainer instanceof DragPlaceholderItem) {
this._box.remove_child(this._dragInfo[1]._dashItemContainer);
this._dragInfo[1]._dashItemContainer.destroy();
@@ -594,9 +591,9 @@ var taskbar = Utils.defineClass({
DND.removeDragMonitor(this._dragMonitor);
this._toggleFavortieHighlight();
},
}
_onDragMotion: function(dragEvent) {
_onDragMotion(dragEvent) {
let app = Dash.getAppFromSource(dragEvent.source);
if (app == null)
return DND.DragMotionResult.CONTINUE;
@@ -609,44 +606,44 @@ var taskbar = Utils.defineClass({
this._showAppsIcon.setDragApp(null);
return DND.DragMotionResult.CONTINUE;
},
}
_toggleFavortieHighlight: function(show) {
_toggleFavortieHighlight(show) {
let appFavorites = AppFavorites.getAppFavorites();
let cssFuncName = (show ? 'add' : 'remove') + '_style_class_name';
this._getAppIcons().filter(appIcon => appFavorites.isFavorite(appIcon.app.get_id()))
.forEach(fav => fav._container[cssFuncName]('favorite'));
},
}
handleIsolatedWorkspaceSwitch: function() {
handleIsolatedWorkspaceSwitch() {
this._shownInitially = this.isGroupApps;
this._queueRedisplay();
},
}
_connectWorkspaceSignals: function() {
_connectWorkspaceSignals() {
this._disconnectWorkspaceSignals();
this._lastWorkspace = Utils.DisplayWrapper.getWorkspaceManager().get_active_workspace();
this._workspaceWindowAddedId = this._lastWorkspace.connect('window-added', () => this._queueRedisplay());
this._workspaceWindowRemovedId = this._lastWorkspace.connect('window-removed', () => this._queueRedisplay());
},
}
_disconnectWorkspaceSignals: function() {
_disconnectWorkspaceSignals() {
if (this._lastWorkspace) {
this._lastWorkspace.disconnect(this._workspaceWindowAddedId);
this._lastWorkspace.disconnect(this._workspaceWindowRemovedId);
this._lastWorkspace = null;
}
},
}
_queueRedisplay: function () {
_queueRedisplay() {
Main.queueDeferredWork(this._workId);
},
}
_hookUpLabel: function(item, syncHandler) {
_hookUpLabel(item, syncHandler) {
item.child.connect('notify::hover', Lang.bind(this, function() {
this._syncLabel(item, syncHandler);
}));
@@ -654,14 +651,14 @@ var taskbar = Utils.defineClass({
syncHandler.connect('sync-tooltip', Lang.bind(this, function() {
this._syncLabel(item, syncHandler);
}));
},
}
_createAppItem: function(app, window, isLauncher) {
let appIcon = new AppIcons.taskbarAppIcon(
_createAppItem(app, window, isLauncher) {
let appIcon = new AppIcons.TaskbarAppIcon(
{
app: app,
window: window,
isLauncher: isLauncher
app,
window,
isLauncher
},
this.dtpPanel,
{
@@ -749,36 +746,36 @@ var taskbar = Utils.defineClass({
this._hookUpLabel(item, appIcon);
return item;
},
}
// Return an array with the "proper" appIcons currently in the taskbar
_getAppIcons: function() {
_getAppIcons() {
// Only consider children which are "proper" icons and which are not
// animating out (which means they will be destroyed at the end of
// the animation)
return this._getTaskbarIcons().map(function(actor){
return actor.child._delegate;
});
},
}
_getTaskbarIcons: function(includeAnimated) {
_getTaskbarIcons(includeAnimated) {
return this._box.get_children().filter(function(actor) {
return actor.child &&
actor.child._delegate &&
actor.child._delegate.icon &&
(includeAnimated || !actor.animatingOut);
});
},
}
_updateAppIcons: function() {
_updateAppIcons() {
let appIcons = this._getAppIcons();
appIcons.filter(icon => icon.constructor === AppIcons.taskbarAppIcon).forEach(icon => {
appIcons.filter(icon => icon.constructor === AppIcons.TaskbarAppIcon).forEach(icon => {
icon.updateIcon();
});
},
}
_itemMenuStateChanged: function(item, opened) {
_itemMenuStateChanged(item, opened) {
// When the menu closes, it calls sync_hover, which means
// that the notify::hover handler does everything we need to.
if (opened) {
@@ -802,9 +799,9 @@ var taskbar = Utils.defineClass({
this._dropIconAnimations();
}
}
},
}
_syncLabel: function (item, syncHandler) {
_syncLabel(item, syncHandler) {
let shouldShow = syncHandler ? syncHandler.shouldShowTooltip() : item.child.get_hover();
if (shouldShow) {
@@ -838,9 +835,9 @@ var taskbar = Utils.defineClass({
GLib.Source.set_name_by_id(this._resetHoverTimeoutId, '[gnome-shell] this._labelShowing');
}
}
},
}
_adjustIconSize: function() {
_adjustIconSize() {
const thisMonitorIndex = this.dtpPanel.monitor.index;
let panelSize = PanelSettings.getPanelSize(Me.settings, thisMonitorIndex);
let availSize = panelSize - Me.settings.get_int('appicon-padding') * 2;
@@ -888,14 +885,14 @@ var taskbar = Utils.defineClass({
transition: 'easeOutQuad',
});
}
},
}
sortAppsCompareFunction: function(appA, appB) {
sortAppsCompareFunction(appA, appB) {
return getAppStableSequence(appA, this.dtpPanel.monitor) -
getAppStableSequence(appB, this.dtpPanel.monitor);
},
}
getAppInfos: function() {
getAppInfos() {
//get the user's favorite apps
let favoriteApps = this._checkIfShowingFavorites() ? AppFavorites.getAppFavorites().getFavorites() : [];
@@ -912,9 +909,9 @@ var taskbar = Utils.defineClass({
return this._createAppInfos(favoriteApps.concat(runningApps.filter(app => favoriteApps.indexOf(app) < 0)))
.filter(appInfo => appInfo.windows.length || favoriteApps.indexOf(appInfo.app) >= 0);
}
},
}
_redisplay: function () {
_redisplay() {
if (!this._signalsHandler) {
return;
}
@@ -985,18 +982,18 @@ var taskbar = Utils.defineClass({
}
this._shownInitially = true;
},
}
_checkIfShowingRunningApps: function() {
_checkIfShowingRunningApps() {
return Me.settings.get_boolean('show-running-apps');
},
}
_checkIfShowingFavorites: function() {
_checkIfShowingFavorites() {
return Me.settings.get_boolean('show-favorites') &&
(this.dtpPanel.isPrimary || Me.settings.get_boolean('show-favorites-all-monitors'));
},
}
_getRunningApps: function() {
_getRunningApps() {
let tracker = Shell.WindowTracker.get_default();
let windows = global.get_window_actors();
let apps = [];
@@ -1010,19 +1007,19 @@ var taskbar = Utils.defineClass({
}
return apps;
},
}
_createAppInfos: function(apps, defaultWindows, defaultIsLauncher) {
_createAppInfos(apps, defaultWindows, defaultIsLauncher) {
return apps.map(app => ({
app: app,
isLauncher: defaultIsLauncher || false,
windows: defaultWindows || AppIcons.getInterestingWindows(app, this.dtpPanel.monitor)
.sort(sortWindowsCompareFunction)
}));
},
}
// Reset the displayed apps icon to mantain the correct order
resetAppIcons : function(geometryChange) {
resetAppIcons (geometryChange) {
let children = this._getTaskbarIcons(true);
for (let i = 0; i < children.length; i++) {
@@ -1037,9 +1034,9 @@ var taskbar = Utils.defineClass({
if (geometryChange && this.dtpPanel.checkIfVertical()) {
this.previewMenu._updateClip();
}
},
}
_updateNumberOverlay: function() {
_updateNumberOverlay() {
let seenApps = {};
let counter = 0;
@@ -1062,23 +1059,23 @@ var taskbar = Utils.defineClass({
if (Me.settings.get_boolean('hot-keys') &&
Me.settings.get_string('hotkeys-overlay-combo') === 'ALWAYS')
this.toggleNumberOverlay(true);
},
}
toggleNumberOverlay: function(activate) {
toggleNumberOverlay(activate) {
let appIcons = this._getAppIcons();
appIcons.forEach(function(icon) {
icon.toggleNumberOverlay(activate);
});
},
}
_clearEmptyDropTarget: function() {
_clearEmptyDropTarget() {
if (this._emptyDropTarget) {
this._emptyDropTarget.animateOutAndDestroy();
this._emptyDropTarget = null;
}
},
}
handleDragOver: function(source, actor, x, y, time) {
handleDragOver(source, actor, x, y, time) {
if (source == Main.xdndHandler)
return DND.DragMotionResult.CONTINUE;
@@ -1135,10 +1132,10 @@ var taskbar = Utils.defineClass({
}
return this._dragInfo[0] !== sourceIndex ? DND.DragMotionResult.MOVE_DROP : DND.DragMotionResult.CONTINUE;
},
}
// Draggable target interface
acceptDrop : function(source, actor, x, y, time) {
acceptDrop (source, actor, x, y, time) {
// Don't allow favoriting of transient apps
if (!source.app || source.app.is_window_backed() || !this._settings.is_writable('favorite-apps')) {
return false;
@@ -1208,9 +1205,9 @@ var taskbar = Utils.defineClass({
appFavorites.emit('changed');
return true;
},
}
_onShowAppsButtonToggled: function() {
_onShowAppsButtonToggled() {
// Sync the status of the default appButtons. Only if the two statuses are
// different, that means the user interacted with the extension provided
// application button, cutomize the behaviour. Otherwise the shell has changed the
@@ -1267,21 +1264,21 @@ var taskbar = Utils.defineClass({
}
}
}
},
}
_syncShowAppsButtonToggled: function() {
_syncShowAppsButtonToggled() {
let status = SearchController._showAppsButton.checked;
if (this.showAppsButton.checked !== status)
this.showAppsButton.checked = status;
},
}
showShowAppsButton: function() {
showShowAppsButton() {
this.showAppsButton.visible = true;
this.showAppsButton.set_width(-1);
this.showAppsButton.set_height(-1);
},
}
popupFocusedAppSecondaryMenu: function() {
popupFocusedAppSecondaryMenu() {
let appIcons = this._getAppIcons();
let tracker = Shell.WindowTracker.get_default();
@@ -1297,16 +1294,15 @@ var taskbar = Utils.defineClass({
break;
}
}
},
});
}
};
Signals.addSignalMethods(taskbar.prototype);
Signals.addSignalMethods(Taskbar.prototype);
const CloneContainerConstraint = Utils.defineClass({
Name: 'DashToPanel-CloneContainerConstraint',
Extends: Clutter.BindConstraint,
const CloneContainerConstraint = GObject.registerClass({
}, class CloneContainerConstraint extends Clutter.BindConstraint {
vfunc_update_allocation: function(actor, actorBox) {
vfunc_update_allocation(actor, actorBox) {
if (!this.source)
return;
@@ -1315,14 +1311,18 @@ const CloneContainerConstraint = Utils.defineClass({
actorBox.set_origin(stageX, stageY);
actorBox.set_size(width, height);
},
}
});
var TaskbarItemContainer = Utils.defineClass({
Name: 'DashToPanel-TaskbarItemContainer',
Extends: Dash.DashItemContainer,
var TaskbarItemContainer = GObject.registerClass({
vfunc_allocate: function(box, flags) {
}, class TaskbarItemContainer extends Dash.DashItemContainer {
_init() {
super._init()
}
vfunc_allocate(box, flags) {
if (this.child == null)
return;
@@ -1343,39 +1343,39 @@ var TaskbarItemContainer = Utils.defineClass({
childBox.y2 = childBox.y1 + childHeight;
Utils.allocate(this.child, childBox, flags);
},
}
// In case appIcon is removed from the taskbar while it is hovered,
// restore opacity before dashItemContainer.animateOutAndDestroy does the destroy animation.
animateOutAndDestroy: function() {
animateOutAndDestroy() {
if (this._raisedClone) {
this._raisedClone.source.opacity = 255;
this._raisedClone.destroy();
}
this.callParent('animateOutAndDestroy');
},
super.animateOutAndDestroy();
}
// For ItemShowLabel
_getIconAnimationOffset: function() {
_getIconAnimationOffset() {
if (!Me.settings.get_boolean('animate-appicon-hover'))
return 0;
let travel = iconAnimationSettings.travel;
let zoom = iconAnimationSettings.zoom;
return this._dtpPanel.dtpSize * (travel + (zoom - 1) / 2);
},
}
_updateCloneContainerPosition: function(cloneContainer) {
_updateCloneContainerPosition(cloneContainer) {
let [stageX, stageY] = this.get_transformed_position();
if (Config.PACKAGE_VERSION >= '3.36')
cloneContainer.set_position(stageX - this.translation_x, stageY - this.translation_y);
else
cloneContainer.set_position(stageX, stageY);
},
}
_createRaisedClone: function() {
_createRaisedClone() {
let [width, height] = this.get_transformed_size();
// "clone" of this child (appIcon actor)
@@ -1419,12 +1419,12 @@ var TaskbarItemContainer = Utils.defineClass({
this._raisedClone.source.opacity = 0;
Main.uiGroup.add_actor(cloneContainer);
},
}
// Animate the clone.
// AppIcon actors cannot go outside the taskbar so the animation is done with a clone.
// If level is zero, the clone is dropped and destroyed.
raise: function(level) {
raise(level) {
if (this._raisedClone)
Utils.stopAnimations(this._raisedClone);
else if (level)
@@ -1476,15 +1476,15 @@ var TaskbarItemContainer = Utils.defineClass({
this._raisedClone.destroy();
delete this._raisedClone;
}
},
}
};
options[vertical ? 'translation_x' : 'translation_y'] = translationDirection * translationEnd;
Utils.animate(this._raisedClone, options);
},
}
// Animate this and cloneContainer, since cloneContainer translation is bound to this.
stretch: function(translation) {
stretch(translation) {
let duration = iconAnimationSettings.duration / 1000;
let zoom = iconAnimationSettings.zoom;
let animatedProperty = this._dtpPanel.checkIfVertical() ? 'translation_y' : 'translation_x';
@@ -1503,15 +1503,14 @@ var TaskbarItemContainer = Utils.defineClass({
Utils.stopAnimations(this);
Utils.animate(this, options);
}
},
}
});
var DragPlaceholderItem = Utils.defineClass({
Name: 'DashToPanel-DragPlaceholderItem',
Extends: St.Widget,
var DragPlaceholderItem = GObject.registerClass({
}, class DragPlaceholderItem extends St.Widget {
_init: function(appIcon, iconSize, isVertical) {
this.callParent('_init', { style: AppIcons.getIconContainerStyle(isVertical), layout_manager: new Clutter.BinLayout() });
_init(appIcon, iconSize, isVertical) {
super._init({ style: AppIcons.getIconContainerStyle(isVertical), layout_manager: new Clutter.BinLayout() });
this.child = { _delegate: appIcon };
@@ -1522,12 +1521,12 @@ var DragPlaceholderItem = Utils.defineClass({
});
this.add_actor(this._clone);
},
}
destroy: function() {
destroy() {
this._clone.destroy();
this.callParent('destroy');
},
super.destroy();
}
});
function getAppStableSequence(app, monitor) {

View File

@@ -28,10 +28,9 @@ const Panel = Me.imports.panel;
const Proximity = Me.imports.proximity;
const Utils = Me.imports.utils;
var DynamicTransparency = Utils.defineClass({
Name: 'DashToPanel.DynamicTransparency',
var DynamicTransparency = class {
_init: function(dtpPanel) {
constructor(dtpPanel) {
this._dtpPanel = dtpPanel;
this._proximityManager = dtpPanel.panelManager.proximityManager;
this._proximityWatchId = 0;
@@ -50,9 +49,9 @@ var DynamicTransparency = Utils.defineClass({
this._updateAnimationDuration();
this._updateAllAndSet();
this._updateProximityWatch();
},
}
destroy: function() {
destroy() {
this._signalsHandler.destroy();
this._proximityManager.removeWatch(this._proximityWatchId);
@@ -62,14 +61,14 @@ var DynamicTransparency = Utils.defineClass({
this._dtpPanel.panel._leftCorner.actor.set_style(this._initialPanelCornerStyle);
this._dtpPanel.panel._rightCorner.actor.set_style(this._initialPanelCornerStyle);
}
},
}
updateExternalStyle: function() {
updateExternalStyle() {
this._updateComplementaryStyles();
this._setBackground();
},
}
_bindSignals: function() {
_bindSignals() {
this._signalsHandler.add(
[
Utils.getStageTheme(),
@@ -129,9 +128,9 @@ var DynamicTransparency = Utils.defineClass({
() => this._updateAnimationDuration()
]
);
},
}
_updateProximityWatch: function() {
_updateProximityWatch() {
this._proximityManager.removeWatch(this._proximityWatchId);
if (Me.settings.get_boolean('trans-use-dynamic-opacity')) {
@@ -149,13 +148,13 @@ var DynamicTransparency = Utils.defineClass({
}
);
}
},
}
_updateAnimationDuration: function() {
_updateAnimationDuration() {
this.animationDuration = (Me.settings.get_int('trans-dynamic-anim-time') * 0.001) + 's;';
},
}
_updateAllAndSet: function() {
_updateAllAndSet() {
let themeBackground = this._getThemeBackground(true);
this._updateColor(themeBackground);
@@ -164,36 +163,36 @@ var DynamicTransparency = Utils.defineClass({
this._updateGradient();
this._setBackground();
this._setGradient();
},
}
_updateColorAndSet: function() {
_updateColorAndSet() {
this._updateColor();
this._setBackground();
},
}
_updateAlphaAndSet: function() {
_updateAlphaAndSet() {
this._updateAlpha();
this._setBackground();
},
}
_updateGradientAndSet: function() {
_updateGradientAndSet() {
this._updateGradient();
this._setGradient();
},
}
_updateComplementaryStyles: function() {
_updateComplementaryStyles() {
let panelThemeNode = this._dtpPanel.panel.actor.get_theme_node();
this._complementaryStyles = 'border-radius: ' + panelThemeNode.get_border_radius(0) + 'px;';
},
}
_updateColor: function(themeBackground) {
_updateColor(themeBackground) {
this.backgroundColorRgb = Me.settings.get_boolean('trans-use-custom-bg') ?
Me.settings.get_string('trans-bg-color') :
(themeBackground || this._getThemeBackground());
},
}
_updateAlpha: function(themeBackground) {
_updateAlpha(themeBackground) {
if (this._windowOverlap && !Main.overview.visibleTarget && Me.settings.get_boolean('trans-use-dynamic-opacity')) {
this.alpha = Me.settings.get_double('trans-dynamic-anim-target');
} else {
@@ -201,9 +200,9 @@ var DynamicTransparency = Utils.defineClass({
Me.settings.get_double('trans-panel-opacity') :
(themeBackground || this._getThemeBackground()).alpha * 0.003921569; // 1 / 255 = 0.003921569
}
},
}
_updateGradient: function() {
_updateGradient() {
this._gradientStyle = '';
if (Me.settings.get_boolean('trans-use-custom-gradient')) {
@@ -213,9 +212,9 @@ var DynamicTransparency = Utils.defineClass({
'background-gradient-end: ' + Utils.getrgbaColor(Me.settings.get_string('trans-gradient-bottom-color'),
Me.settings.get_double('trans-gradient-bottom-opacity'));
}
},
}
_setBackground: function() {
_setBackground() {
this.currentBackgroundColor = Utils.getrgbaColor(this.backgroundColorRgb, this.alpha);
let transition = 'transition-duration:' + this.animationDuration;
@@ -227,9 +226,9 @@ var DynamicTransparency = Utils.defineClass({
this._dtpPanel.panel._leftCorner.actor.set_style(cornerStyle);
this._dtpPanel.panel._rightCorner.actor.set_style(cornerStyle);
}
},
}
_setGradient: function() {
_setGradient() {
this._dtpPanel.panel.actor.set_style(
'background: none; ' +
'border-image: none; ' +
@@ -237,9 +236,9 @@ var DynamicTransparency = Utils.defineClass({
this._gradientStyle +
'transition-duration:' + this.animationDuration
);
},
}
_getThemeBackground: function(reload) {
_getThemeBackground(reload) {
if (reload || !this._themeBackground) {
let fakePanel = new St.Bin({ name: 'panel' });
Main.uiGroup.add_child(fakePanel);
@@ -249,9 +248,9 @@ var DynamicTransparency = Utils.defineClass({
}
return this._themeBackground;
},
}
_getBackgroundImageColor: function(theme) {
_getBackgroundImageColor(theme) {
let bg = null;
try {
@@ -267,4 +266,4 @@ var DynamicTransparency = Utils.defineClass({
return bg;
}
});
}

198
utils.js
View File

@@ -27,7 +27,6 @@ const GdkPixbuf = imports.gi.GdkPixbuf;
const Gi = imports._gi;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
@@ -46,106 +45,28 @@ if (Config.PACKAGE_VERSION < '3.34') {
var Tweener = imports.ui.tweener;
}
var defineClass = function (classDef) {
let parentProto = classDef.Extends ? classDef.Extends.prototype : null;
if (Config.PACKAGE_VERSION < '3.31.9') {
if (parentProto && (classDef.Extends.name || classDef.Extends.toString()).indexOf('DashToPanel.') < 0) {
classDef.callParent = function() {
let args = Array.prototype.slice.call(arguments);
let func = args.shift();
classDef.Extends.prototype[func].apply(this, args);
};
}
return new imports.lang.Class(classDef);
}
let isGObject = parentProto instanceof GObject.Object;
let needsSuper = parentProto && !isGObject;
let getParentArgs = function(args) {
let parentArgs = [];
(classDef.ParentConstrParams || parentArgs).forEach(p => {
if (p.constructor === Array) {
let param = args[p[0]];
parentArgs.push(p[1] ? param[p[1]] : param);
} else {
parentArgs.push(p);
}
});
return parentArgs;
};
let C;
if (isGObject) {
C = eval(
'(class C extends GObject.Object { ' +
' callParent(...args) { ' +
' let func = args.shift(); ' +
' super[func](...args); ' +
' }' +
'})'
);
} else {
C = eval(
'(class C ' + (needsSuper ? 'extends Object' : '') + ' { ' +
' constructor(...args) { ' +
(needsSuper ? 'super(...getParentArgs(args));' : '') +
(needsSuper || !parentProto ? 'this._init(...args);' : '') +
' }' +
' callParent(...args) { ' +
' let func = args.shift(); ' +
' if (!(func === \'_init\' && needsSuper))' +
' super[func](...args); ' +
' }' +
'})'
);
}
if (parentProto) {
Object.setPrototypeOf(C.prototype, parentProto);
Object.setPrototypeOf(C, classDef.Extends);
}
Object.defineProperty(C, 'name', { value: classDef.Name });
Object.keys(classDef)
.filter(k => classDef.hasOwnProperty(k) && classDef[k] instanceof Function)
.forEach(k => C.prototype[k] = classDef[k]);
if (isGObject) {
C = GObject.registerClass({ Signals: classDef.Signals || {} }, C);
}
return C;
};
// simplify global signals and function injections handling
// abstract class
var BasicHandler = defineClass({
Name: 'DashToPanel.BasicHandler',
var BasicHandler = class {
_init: function(){
constructor() {
this._storage = new Object();
},
}
add: function(/*unlimited 3-long array arguments*/){
add(/*unlimited 3-long array arguments*/){
// convert arguments object to array, concatenate with generic
let args = [].concat('generic', [].slice.call(arguments));
// call addWithLabel with ags as if they were passed arguments
this.addWithLabel.apply(this, args);
},
}
destroy: function() {
destroy() {
for( let label in this._storage )
this.removeWithLabel(label);
},
}
addWithLabel: function( label /* plus unlimited 3-long array arguments*/) {
addWithLabel( label /* plus unlimited 3-long array arguments*/) {
if(this._storage[label] == undefined)
this._storage[label] = new Array();
@@ -160,9 +81,9 @@ var BasicHandler = defineClass({
}
}
},
}
removeWithLabel: function(label){
removeWithLabel(label){
if(this._storage[label]) {
for( let i = 0; i < this._storage[label].length; i++ ) {
@@ -171,26 +92,24 @@ var BasicHandler = defineClass({
delete this._storage[label];
}
},
}
/* Virtual methods to be implemented by subclass */
// create single element to be stored in the storage structure
_create: function(item){
_create(item){
throw new Error('no implementation of _create in ' + this);
},
}
// correctly delete single element
_remove: function(item){
_remove(item){
throw new Error('no implementation of _remove in ' + this);
}
});
}
// Manage global signals
var GlobalSignalsHandler = defineClass({
Name: 'DashToPanel.GlobalSignalsHandler',
Extends: BasicHandler,
var GlobalSignalsHandler = class extends BasicHandler {
_create: function(item) {
_create(item) {
let handlers = [];
item[1] = [].concat(item[1]);
@@ -210,22 +129,20 @@ var GlobalSignalsHandler = defineClass({
}
return handlers;
},
}
_remove: function(item){
_remove(item){
item[0].disconnect(item[1]);
}
});
};
/**
* Manage function injection: both instances and prototype can be overridden
* and restored
*/
var InjectionsHandler = defineClass({
Name: 'DashToPanel.InjectionsHandler',
Extends: BasicHandler,
var InjectionsHandler = class extends BasicHandler {
_create: function(item) {
_create(item) {
let object = item[0];
let name = item[1];
let injectedFunction = item[2];
@@ -233,24 +150,22 @@ var InjectionsHandler = defineClass({
object[name] = injectedFunction;
return [[object, name, injectedFunction, original]];
},
}
_remove: function(item) {
_remove(item) {
let object = item[0];
let name = item[1];
let original = item[3];
object[name] = original;
}
});
};
/**
* Manage timeouts: the added timeouts have their id reset on completion
*/
var TimeoutsHandler = defineClass({
Name: 'DashToPanel.TimeoutsHandler',
Extends: BasicHandler,
var TimeoutsHandler = class extends BasicHandler {
_create: function(item) {
_create(item) {
let name = item[0];
let delay = item[1];
let timeoutHandler = item[2];
@@ -263,38 +178,38 @@ var TimeoutsHandler = defineClass({
});
return [[name]];
},
}
remove: function(name) {
remove(name) {
this._remove([name])
},
}
_remove: function(item) {
_remove(item) {
let name = item[0];
if (this[name]) {
Mainloop.source_remove(this[name]);
this[name] = 0;
}
},
}
getId: function(name) {
getId(name) {
return this[name] ? this[name] : 0;
}
});
};
// This is wrapper to maintain compatibility with GNOME-Shell 3.30+ as well as
// previous versions.
var DisplayWrapper = {
getScreen: function() {
getScreen() {
return global.screen || global.display;
},
getWorkspaceManager: function() {
getWorkspaceManager() {
return global.screen || global.workspace_manager;
},
getMonitorManager: function() {
getMonitorManager() {
return global.screen || Meta.MonitorManager.get();
}
};
@@ -357,12 +272,12 @@ var mergeObjects = function(main, bck) {
};
var hookVfunc = function(proto, symbol, func) {
if (Gi.hook_up_vfunc_symbol && func) {
try {
proto[Gi.gobject_prototype_symbol][Gi.hook_up_vfunc_symbol] (symbol, func);
} catch (e) {
proto[Gi.hook_up_vfunc_symbol] (symbol, func);
}
if (!func) return
if (Gi.gobject_prototype_symbol) {
proto[Gi.gobject_prototype_symbol][Gi.hook_up_vfunc_symbol] (symbol, func);
} else {
proto[Gi.hook_up_vfunc_symbol] (symbol, func);
}
};
@@ -706,7 +621,7 @@ var ensureActorVisibleInScrollView = function(scrollView, actor, fadeSize, onCom
* ColorUtils is adapted from https://github.com/micheleg/dash-to-dock
*/
var ColorUtils = {
colorLuminance: function(r, g, b, dlum) {
colorLuminance(r, g, b, dlum) {
// Darken or brighten color by a fraction dlum
// Each rgb value is modified by the same fraction.
// Return "#rrggbb" strin
@@ -720,7 +635,7 @@ var ColorUtils = {
return rgbString;
},
_decimalToHex: function(d, padding) {
_decimalToHex(d, padding) {
// Convert decimal to an hexadecimal string adding the desired padding
let hex = d.toString(16);
@@ -729,7 +644,7 @@ var ColorUtils = {
return hex;
},
HSVtoRGB: function(h, s, v) {
HSVtoRGB(h, s, v) {
// Convert hsv ([0-1, 0-1, 0-1]) to rgb ([0-255, 0-255, 0-255]).
// Following algorithm in https://en.wikipedia.org/wiki/HSL_and_HSV
// here with h = [0,1] instead of [0, 360]
@@ -768,7 +683,7 @@ var ColorUtils = {
};
},
RGBtoHSV: function(r, g, b) {
RGBtoHSV(r, g, b) {
// Convert rgb ([0-255, 0-255, 0-255]) to hsv ([0-1, 0-1, 0-1]).
// Following algorithm in https://en.wikipedia.org/wiki/HSL_and_HSV
// here with h = [0,1] instead of [0, 360]
@@ -816,17 +731,16 @@ const MAX_CACHED_ITEMS = 1000;
const BATCH_SIZE_TO_DELETE = 50;
const DOMINANT_COLOR_ICON_SIZE = 64;
var DominantColorExtractor = defineClass({
Name: 'DashToPanel.DominantColorExtractor',
var DominantColorExtractor = class {
_init: function(app){
constructor(app){
this._app = app;
},
}
/**
* Try to get the pixel buffer for the current icon, if not fail gracefully
*/
_getIconPixBuf: function() {
_getIconPixBuf() {
let iconTexture = this._app.create_icon_texture(16);
if (themeLoader === null) {
@@ -861,7 +775,7 @@ var DominantColorExtractor = defineClass({
}
return null;
},
}
/**
* The backlight color choosing algorithm was mostly ported to javascript from the
@@ -869,7 +783,7 @@ var DominantColorExtractor = defineClass({
* https://bazaar.launchpad.net/~unity-team/unity/trunk/view/head:/launcher/LauncherIcon.cpp
* so it more or less works the same way.
*/
_getColorPalette: function() {
_getColorPalette() {
if (iconCacheMap.get(this._app.get_id())) {
// We already know the answer
return iconCacheMap.get(this._app.get_id());
@@ -962,7 +876,7 @@ var DominantColorExtractor = defineClass({
iconCacheMap.set(this._app.get_id(), backgroundColor);
return backgroundColor;
},
}
/**
* Downsample large icons before scanning for the backlight color to
@@ -975,7 +889,7 @@ var DominantColorExtractor = defineClass({
*
* @return [];
*/
_resamplePixels: function (pixels, resampleX, resampleY) {
_resamplePixels(pixels, resampleX, resampleY) {
let resampledPixels = [];
// computing the limit outside the for (where it would be repeated at each iteration)
// for performance reasons
@@ -992,7 +906,7 @@ var DominantColorExtractor = defineClass({
return resampledPixels;
}
});
};
var drawRoundedLine = function(cr, x, y, width, height, isRoundLeft, isRoundRight, stroke, fill) {
if (height > width) {

View File

@@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const GObject = imports.gi.GObject;
const Clutter = imports.gi.Clutter;
const Config = imports.misc.config;
const GLib = imports.gi.GLib;
@@ -60,13 +61,12 @@ let scaleFactor = 1;
let animationTime = 0;
let aspectRatio = {};
var PreviewMenu = Utils.defineClass({
Name: 'DashToPanel-PreviewMenu',
Extends: St.Widget,
Signals: { 'open-state-changed': {} },
var PreviewMenu = GObject.registerClass({
Signals: { 'open-state-changed': {} }
}, class PreviewMenu extends St.Widget {
_init: function(panel) {
this.callParent('_init', { layout_manager: new Clutter.BinLayout() });
_init(panel) {
super._init({ layout_manager: new Clutter.BinLayout() });
let geom = panel.geom;
this.panel = panel;
@@ -102,9 +102,9 @@ var PreviewMenu = Utils.defineClass({
this._scrollView.add_actor(this._box);
this.menu.add_child(this._scrollView);
this.add_child(this.menu);
},
}
enable: function() {
enable() {
this._timeoutsHandler = new Utils.TimeoutsHandler();
this._signalsHandler = new Utils.GlobalSignalsHandler();
@@ -155,9 +155,9 @@ var PreviewMenu = Utils.defineClass({
}
]
);
},
}
disable: function() {
disable() {
this._timeoutsHandler.destroy();
this._signalsHandler.destroy();
@@ -165,9 +165,9 @@ var PreviewMenu = Utils.defineClass({
Main.layoutManager.untrackChrome(this.menu);
Main.layoutManager.removeChrome(this);
},
}
requestOpen: function(appIcon) {
requestOpen(appIcon) {
let timeout = Me.settings.get_int('show-window-previews-timeout');
if (this.opened) {
@@ -176,14 +176,14 @@ var PreviewMenu = Utils.defineClass({
this._endOpenCloseTimeouts();
this._timeoutsHandler.add([T1, timeout, () => this.open(appIcon)]);
},
}
requestClose: function() {
requestClose() {
this._endOpenCloseTimeouts();
this._addCloseTimeout();
},
}
open: function(appIcon) {
open(appIcon) {
if (this.currentAppIcon != appIcon) {
this.currentAppIcon = appIcon;
@@ -203,9 +203,9 @@ var PreviewMenu = Utils.defineClass({
this._setReactive(true);
this._setOpenedState(true);
}
},
}
close: function(immediate) {
close(immediate) {
this._endOpenCloseTimeouts();
this._removeFocus();
this._endPeek();
@@ -219,9 +219,9 @@ var PreviewMenu = Utils.defineClass({
this._setReactive(false);
this.currentAppIcon = null;
},
}
update: function(appIcon, windows) {
update(appIcon, windows) {
if (this.currentAppIcon == appIcon) {
if (windows && !windows.length) {
this.close();
@@ -230,13 +230,13 @@ var PreviewMenu = Utils.defineClass({
this._updatePosition();
}
}
},
}
updatePosition: function() {
updatePosition() {
this._updatePosition();
},
}
focusNext: function() {
focusNext() {
let previews = this._box.get_children();
let currentIndex = this._focusedPreview ? previews.indexOf(this._focusedPreview) : -1;
let nextIndex = currentIndex + 1;
@@ -250,15 +250,15 @@ var PreviewMenu = Utils.defineClass({
}
return nextIndex;
},
}
activateFocused: function() {
activateFocused() {
if (this.opened && this._focusedPreview) {
this._focusedPreview.activate();
}
},
}
requestPeek: function(window) {
requestPeek(window) {
this._timeoutsHandler.remove(T3);
if (Me.settings.get_boolean('peek-mode')) {
@@ -268,13 +268,13 @@ var PreviewMenu = Utils.defineClass({
this._peek(window);
}
}
},
}
endPeekHere: function() {
endPeekHere() {
this._endPeek(true);
},
}
ensureVisible: function(preview) {
ensureVisible(preview) {
let [ , upper, pageSize] = this._getScrollAdjustmentValues();
if (upper > pageSize) {
@@ -284,39 +284,39 @@ var PreviewMenu = Utils.defineClass({
() => Utils.ensureActorVisibleInScrollView(this._scrollView, preview, MIN_DIMENSION, () => this._updateScrollFade())
]);
}
},
}
getCurrentAppIcon: function() {
getCurrentAppIcon() {
return this.currentAppIcon;
},
}
_setReactive: function(reactive) { 
_setReactive(reactive) {
this._box.get_children().forEach(c => c.reactive = reactive);
this.menu.reactive = reactive;
},
}
_setOpenedState: function(opened) {
_setOpenedState(opened) {
this.opened = opened;
this.emit('open-state-changed');
},
}
_resetHiddenState: function() {
_resetHiddenState() {
this.menu.hide();
this.set_height(0);
this._setOpenedState(false);
this.menu.opacity = 0;
this.menu[this._translationProp] = this._translationOffset;
this._box.get_children().forEach(c => c.destroy());
},
}
_removeFocus: function() {
_removeFocus() {
if (this._focusedPreview) {
this._focusedPreview.setFocus(false);
this._focusedPreview = null;
}
},
}
_mergeWindows: function(appIcon, windows) {
_mergeWindows(appIcon, windows) {
windows = windows || (appIcon.window ? [appIcon.window] : appIcon.getAppIconInterestingWindows());
windows.sort(Taskbar.sortWindowsCompareFunction);
@@ -332,9 +332,9 @@ var PreviewMenu = Utils.defineClass({
currentPreviews[i][!this.opened ? 'destroy' : 'animateOut']();
}
}
},
}
_addAndRemoveWindows: function(windows) {
_addAndRemoveWindows(windows) {
let currentPreviews = this._box.get_children();
windows.sort(Taskbar.sortWindowsCompareFunction);
@@ -355,30 +355,30 @@ var PreviewMenu = Utils.defineClass({
}
currentPreviews.forEach(c => c.animateOut());
},
}
_addNewPreview: function(window) {
_addNewPreview(window) {
let preview = new Preview(this);
this._box.add_child(preview);
preview.adjustOnStage();
preview.assignWindow(window, this.opened);
},
}
_addCloseTimeout: function() {
_addCloseTimeout() {
this._timeoutsHandler.add([T2, Me.settings.get_int('leave-timeout'), () => this.close()]);
},
}
_onHoverChanged: function() {
_onHoverChanged() {
this._endOpenCloseTimeouts();
if (this.currentAppIcon && !this.menu.hover) {
this._addCloseTimeout();
this._endPeek();
}
},
}
_onScrollEvent: function(actor, event) {
_onScrollEvent(actor, event) {
if (!event.is_pointer_emulated()) {
let vOrh = this.isVertical ? 'v' : 'h';
let adjustment = this._scrollView['get_' + vOrh + 'scroll_bar']().get_adjustment();
@@ -401,15 +401,15 @@ var PreviewMenu = Utils.defineClass({
}
return Clutter.EVENT_STOP;
},
}
_endOpenCloseTimeouts: function() {
_endOpenCloseTimeouts() {
this._timeoutsHandler.remove(T1);
this._timeoutsHandler.remove(T2);
this._timeoutsHandler.remove(T4);
},
}
_refreshGlobals: function() {
_refreshGlobals() {
isLeftButtons = Meta.prefs_get_button_layout().left_buttons.indexOf(Meta.ButtonFunction.CLOSE) >= 0;
isTopHeader = Me.settings.get_string('window-preview-title-position') == 'TOP';
isManualStyling = Me.settings.get_boolean('window-preview-manual-styling');
@@ -428,9 +428,9 @@ var PreviewMenu = Utils.defineClass({
alphaBg = Me.settings.get_boolean('preview-use-custom-opacity') ?
Me.settings.get_int('preview-custom-opacity') * .01 :
this.panel.dynamicTransparency.alpha;
},
}
_updateClip: function() {
_updateClip() {
let x, y, w;
let geom = this.panel.getGeometry();
let panelBoxTheme = this.panel.panelBox.get_theme_node();
@@ -458,9 +458,9 @@ var PreviewMenu = Utils.defineClass({
}
Utils.setClip(this, x, y, w, this.clipHeight);
},
}
_updatePosition: function() {
_updatePosition() {
let sourceNode = this.currentAppIcon.actor.get_theme_node();
let sourceContentBox = sourceNode.get_content_box(this.currentAppIcon.actor.get_allocation_box());
let sourceAllocation = Utils.getTransformedAllocation(this.currentAppIcon.actor);
@@ -488,9 +488,9 @@ var PreviewMenu = Utils.defineClass({
} else {
Utils.animate(this.menu, getTweenOpts({ x: x, y: y, width: previewsWidth, height: previewsHeight }));
}
},
}
_updateScrollFade: function(remove) {
_updateScrollFade(remove) {
let [value, upper, pageSize] = this._getScrollAdjustmentValues();
let needsFade = Math.round(upper) > Math.round(pageSize);
let fadeWidgets = this.menu.get_children().filter(c => c != this._scrollView);
@@ -509,15 +509,15 @@ var PreviewMenu = Utils.defineClass({
} else if (remove || (!needsFade && fadeWidgets.length)) {
fadeWidgets.forEach(fw => fw.destroy());
}
},
}
_getScrollAdjustmentValues: function() {
_getScrollAdjustmentValues() {
let [value , , upper, , , pageSize] = this._scrollView[(this.isVertical ? 'v' : 'h') + 'scroll'].adjustment.get_values();
return [value, upper, pageSize];
},
}
_getFadeWidget: function(end) {
_getFadeWidget(end) {
let x = 0, y = 0;
let startBg = Utils.getrgbaColor(this.panel.dynamicTransparency.backgroundColorRgb, Math.min(alphaBg + .1, 1));
let endBg = Utils.getrgbaColor(this.panel.dynamicTransparency.backgroundColorRgb, 0)
@@ -542,9 +542,9 @@ var PreviewMenu = Utils.defineClass({
});
return fadeWidget;
},
}
_getPreviewsSize: function() {
_getPreviewsSize() {
let previewsWidth = 0;
let previewsHeight = 0;
@@ -563,9 +563,9 @@ var PreviewMenu = Utils.defineClass({
});
return [previewsWidth, previewsHeight];
},
}
_animateOpenOrClose: function(show, onComplete) {
_animateOpenOrClose(show, onComplete) {
let isTranslationAnimation = this.menu[this._translationProp] != 0;
let tweenOpts = {
opacity: show ? 255 : 0,
@@ -582,9 +582,9 @@ var PreviewMenu = Utils.defineClass({
tweenOpts[this._translationProp] = show ? this._translationDirection : this._translationOffset;
Utils.animate(this.menu, getTweenOpts(tweenOpts));
},
}
_peek: function(window) {
_peek(window) {
let currentWorkspace = Utils.getCurrentWorkspace();
let windowWorkspace = window.get_workspace();
let focusWindow = () => this._focusMetaWindow(Me.settings.get_int('peek-mode-opacity'), window);
@@ -602,9 +602,9 @@ var PreviewMenu = Utils.defineClass({
if (this.peekInitialWorkspaceIndex < 0) {
this.peekInitialWorkspaceIndex = currentWorkspace.index();
}
},
}
_endPeek: function(stayHere) {
_endPeek(stayHere) {
this._timeoutsHandler.remove(T3);
if (this._peekedWindow) {
@@ -620,9 +620,9 @@ var PreviewMenu = Utils.defineClass({
this.peekInitialWorkspaceIndex = -1;
}
},
}
_switchToWorkspaceImmediate: function(workspaceIndex) {
_switchToWorkspaceImmediate(workspaceIndex) {
let workspace = Utils.getWorkspaceByIndex(workspaceIndex);
let shouldAnimate = Main.wm._shouldAnimate;
@@ -634,9 +634,9 @@ var PreviewMenu = Utils.defineClass({
Main.wm._shouldAnimate = () => false;
workspace.activate(global.display.get_current_time_roundtrip());
Main.wm._shouldAnimate = shouldAnimate;
},
}
_focusMetaWindow: function(dimOpacity, window, immediate, ignoreFocus) {
_focusMetaWindow(dimOpacity, window, immediate, ignoreFocus) {
window.get_workspace().list_windows().forEach(mw => {
let wa = mw.get_compositor_private();
let isFocused = !ignoreFocus && mw == window;
@@ -662,9 +662,9 @@ var PreviewMenu = Utils.defineClass({
}
}
});
},
}
_restorePeekedWindowStack: function() {
_restorePeekedWindowStack() {
let windowActor = this._peekedWindow ? this._peekedWindow.get_compositor_private() : null;
if (windowActor) {
@@ -677,15 +677,14 @@ var PreviewMenu = Utils.defineClass({
windowActor.hide();
}
}
},
}
});
var Preview = Utils.defineClass({
Name: 'DashToPanel-Preview',
Extends: St.Widget,
var Preview = GObject.registerClass({
}, class Preview extends St.Widget {
_init: function(previewMenu) {
this.callParent('_init', {
_init(previewMenu) {
super._init({
style_class: 'preview-container',
reactive: true,
track_hover: true,
@@ -759,9 +758,9 @@ var Preview = Utils.defineClass({
this.connect('notify::hover', () => this._onHoverChanged());
this.connect('button-release-event', (actor, e) => this._onButtonReleaseEvent(e));
this.connect('destroy', () => this._onDestroy());
},
}
adjustOnStage: function() {
adjustOnStage() {
let closeButton = this._closeButtonBin.get_first_child();
let closeButtonHeight = closeButton.height;
let maxCloseButtonSize = MAX_CLOSE_BUTTON_SIZE * scaleFactor;
@@ -788,9 +787,9 @@ var Preview = Utils.defineClass({
this._getBackgroundColor(HEADER_COLOR_OFFSET, headerHeight ? 1 : .6) +
closeButtonBorderRadius
);
},
}
assignWindow: function(window, animateSize) {
assignWindow(window, animateSize) {
if (this.window != window) {
let _assignWindowClone = () => {
if (window.get_compositor_private()) {
@@ -818,9 +817,9 @@ var Preview = Utils.defineClass({
this.window = window;
this._needsCloseButton = window.can_close() && !Utils.checkIfWindowHasTransient(window);
this._updateHeader();
},
}
animateOut: function() {
animateOut() {
if (!this.animatingOut) {
let tweenOpts = getTweenOpts({ opacity: 0, width: 0, height: 0, onComplete: () => this.destroy() });
@@ -829,18 +828,18 @@ var Preview = Utils.defineClass({
Utils.stopAnimations(this);
Utils.animate(this, tweenOpts);
}
},
}
getSize: function() {
getSize() {
let [binWidth, binHeight] = this._getBinSize();
binWidth = Math.max(binWidth, this.cloneWidth + this._padding * 2);
binHeight = Math.max(binHeight, this.cloneHeight + this._padding * 2) + headerHeight;
return [binWidth, binHeight];
},
}
setFocus: function(focused) {
setFocus(focused) {
this._hideOrShowCloseButton(!focused);
setStyle(this, this._getBackgroundColor(FOCUSED_COLOR_OFFSET, focused ? '-' : 0));
@@ -848,28 +847,28 @@ var Preview = Utils.defineClass({
this._previewMenu.ensureVisible(this);
this._previewMenu.requestPeek(this.window);
}
},
}
activate: function() {
activate() {
this._previewMenu.endPeekHere();
this._previewMenu.close();
Main.activateWindow(this.window);
},
}
_onDestroy: function() {
_onDestroy() {
if (this._waitWindowId) {
GLib.source_remove(this._waitWindowId);
this._waitWindowId = 0;
}
this._removeWindowSignals();
},
}
_onHoverChanged: function() {
_onHoverChanged() {
this.setFocus(this.hover);
},
}
_onCloseBtnClick: function() {
_onCloseBtnClick() {
this._hideOrShowCloseButton(true);
this.reactive = false;
@@ -880,9 +879,9 @@ var Preview = Utils.defineClass({
}
this.window.delete(global.get_current_time());
},
}
_onButtonReleaseEvent: function(e) {
_onButtonReleaseEvent(e) {
switch (e.get_button()) {
case 1: // Left click
this.activate();
@@ -898,18 +897,18 @@ var Preview = Utils.defineClass({
}
return Clutter.EVENT_STOP;
},
}
_cancelAnimateOut: function() {
_cancelAnimateOut() {
if (this.animatingOut) {
this.animatingOut = false;
Utils.stopAnimations(this);
Utils.animate(this, getTweenOpts({ opacity: 255, width: this.cloneWidth, height: this.cloneHeight }));
}
},
}
_showContextMenu: function(e) {
_showContextMenu(e) {
let coords = e.get_coords();
let currentWorkspace = this._previewMenu.peekInitialWorkspaceIndex < 0 ?
Utils.getCurrentWorkspace() :
@@ -935,16 +934,16 @@ var Preview = Utils.defineClass({
ctxMenuData.menu.addMenuItem(menuItem, insertIndex);
menuItem.connect('activate', () => this.window.change_workspace(currentWorkspace));
}
},
}
_removeWindowSignals: function() {
_removeWindowSignals() {
if (this._titleWindowChangeId) {
this.window.disconnect(this._titleWindowChangeId);
this._titleWindowChangeId = 0;
}
},
}
_updateHeader: function() {
_updateHeader() {
if (headerHeight) {
let iconTextureSize = Me.settings.get_boolean('window-preview-use-custom-icon-size') ?
Me.settings.get_int('window-preview-custom-icon-size') :
@@ -973,24 +972,24 @@ var Preview = Utils.defineClass({
setStyle(this._windowTitle, 'max-width: 0px; padding-right: 4px;' + commonTitleStyles);
this._updateWindowTitle();
}
},
}
_updateWindowTitle: function() {
_updateWindowTitle() {
this._windowTitle.text = this.window.title;
},
}
_hideOrShowCloseButton: function(hide) {
_hideOrShowCloseButton(hide) {
if (this._needsCloseButton) {
Utils.animate(this._closeButtonBin, getTweenOpts({ opacity: hide ? 0 : 255 }));
}
},
}
_getBackgroundColor: function(offset, alpha) {
_getBackgroundColor(offset, alpha) {
return 'background-color: ' + this._getRgbaColor(offset, alpha) +
'transition-duration:' + this._previewMenu.panel.dynamicTransparency.animationDuration;
},
}
_getRgbaColor: function(offset, alpha) {
_getRgbaColor(offset, alpha) {
alpha = Math.abs(alpha);
if (isNaN(alpha)) {
@@ -998,9 +997,9 @@ var Preview = Utils.defineClass({
}
return Utils.getrgbaColor(this._previewMenu.panel.dynamicTransparency.backgroundColorRgb, alpha, offset);
},
}
_addClone: function(newCloneBin, animateSize) {
_addClone(newCloneBin, animateSize) {
let currentClones = this._previewBin.get_children();
let newCloneOpts = getTweenOpts({ opacity: 255 });
@@ -1034,9 +1033,9 @@ var Preview = Utils.defineClass({
}
Utils.animate(newCloneBin, newCloneOpts);
},
}
_getWindowCloneBin: function(window) {
_getWindowCloneBin(window) {
let frameRect = window.get_frame_rect();
let bufferRect = window.get_buffer_rect();
let clone = new Clutter.Clone({ source: window.get_compositor_private() });
@@ -1051,18 +1050,18 @@ var Preview = Utils.defineClass({
cloneBin.add_child(clone);
return cloneBin;
},
}
_getBinSize: function() {
_getBinSize() {
let [fixedWidth, fixedHeight] = this._previewDimensions;
return [
aspectRatio.x.fixed ? fixedWidth + this._padding * 2 : -1,
aspectRatio.y.fixed ? fixedHeight + this._padding * 2 : -1
];
},
}
_resizeClone: function(cloneBin, window) {
_resizeClone(cloneBin, window) {
let frameRect = cloneBin.layout_manager.frameRect || window.get_frame_rect();
let [fixedWidth, fixedHeight] = this._previewDimensions;
let ratio = Math.min(fixedWidth / frameRect.width, fixedHeight / frameRect.height, 1);
@@ -1082,9 +1081,9 @@ var Preview = Utils.defineClass({
cloneBin.layout_manager.padding = [clonePaddingLeft * scaleFactor, clonePaddingTop * scaleFactor];
cloneBin.get_first_child().set_size(cloneWidth, cloneHeight);
},
}
_getPreviewDimensions: function() {
_getPreviewDimensions() {
let size = Me.settings.get_int('window-preview-size') * scaleFactor;
let w, h;
@@ -1100,19 +1099,18 @@ var Preview = Utils.defineClass({
}
});
var WindowCloneLayout = Utils.defineClass({
Name: 'DashToPanel-WindowCloneLayout',
Extends: Clutter.BinLayout,
var WindowCloneLayout = GObject.registerClass({
}, class WindowCloneLayout extends Clutter.BinLayout {
_init: function(frameRect, bufferRect) {
this.callParent('_init');
_init(frameRect, bufferRect) {
super._init();
//the buffer_rect contains the transparent padding that must be removed
this.frameRect = frameRect;
this.bufferRect = bufferRect;
},
}
vfunc_allocate: function(actor, box, flags) {
vfunc_allocate(actor, box, flags) {
let [width, height] = box.get_size();
box.set_origin(