From 3aadb81c29c1287de38ddedddefb6dcf7c7dd808 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Sat, 31 Aug 2019 15:50:53 -0400 Subject: [PATCH] Globalize settings --- appIcons.js | 240 +++++++++++++++++++++++------------------------ extension.js | 9 +- intellihide.js | 35 ++++--- overview.js | 43 +++++---- panel.js | 73 +++++++------- panelManager.js | 28 +++--- panelStyle.js | 18 ++-- taskbar.js | 60 ++++++------ transparency.js | 41 ++++---- windowPreview.js | 59 ++++++------ 10 files changed, 295 insertions(+), 311 deletions(-) diff --git a/appIcons.js b/appIcons.js index 594198a..da69ab9 100644 --- a/appIcons.js +++ b/appIcons.js @@ -92,12 +92,9 @@ let tracker = Shell.WindowTracker.get_default(); var taskbarAppIcon = Utils.defineClass({ Name: 'DashToPanel.TaskbarAppIcon', Extends: (Dash.DashIcon || AppDisplay.AppIcon), - ParentConstrParams: [[1, 'app'], [3]], + ParentConstrParams: [[0, 'app'], [2]], - _init: function(settings, appInfo, panelWrapper, iconParams, previewMenu) { - - // a prefix is required to avoid conflicting with the parent class variable - this._dtpSettings = settings; + _init: function(appInfo, panelWrapper, iconParams, previewMenu) { this.panelWrapper = panelWrapper; this._nWindows = 0; this.window = appInfo.window; @@ -130,7 +127,7 @@ var taskbarAppIcon = Utils.defineClass({ Utils.wrapActor(this.icon); this._dot.set_width(0); - this._isGroupApps = this._dtpSettings.get_boolean('group-apps'); + this._isGroupApps = Me.settings.get_boolean('group-apps'); this._container = new St.Widget({ style_class: 'dtp-container', layout_manager: new Clutter.BinLayout() }); this._dotsContainer = new St.Widget({ layout_manager: new Clutter.BinLayout() }); @@ -182,7 +179,7 @@ var taskbarAppIcon = Utils.defineClass({ this._stateChangedId = this.app.connect('windows-changed', Lang.bind(this, this.onWindowsChanged)); if (!this.window) { - if (this._dtpSettings.get_boolean('isolate-monitors')) { + if (Me.settings.get_boolean('isolate-monitors')) { this._windowEnteredMonitorId = Utils.DisplayWrapper.getScreen().connect('window-entered-monitor', this.onWindowEnteredOrLeft.bind(this)); this._windowLeftMonitorId = Utils.DisplayWrapper.getScreen().connect('window-left-monitor', this.onWindowEnteredOrLeft.bind(this)); } @@ -204,31 +201,31 @@ var taskbarAppIcon = Utils.defineClass({ this._hoverChangeId = this.actor.connect('notify::hover', () => this._onAppIconHoverChanged()); this._dtpSettingsSignalIds = [ - this._dtpSettings.connect('changed::dot-position', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::dot-size', Lang.bind(this, this._updateDotSize)), - this._dtpSettings.connect('changed::dot-style-focused', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::dot-style-unfocused', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::dot-color-dominant', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::dot-color-override', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::dot-color-1', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::dot-color-2', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::dot-color-3', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::dot-color-4', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::dot-color-unfocused-different', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::dot-color-unfocused-1', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::dot-color-unfocused-2', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::dot-color-unfocused-3', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::dot-color-unfocused-4', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::focus-highlight', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::focus-highlight-dominant', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::focus-highlight-color', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::focus-highlight-opacity', Lang.bind(this, this._settingsChangeRefresh)), - this._dtpSettings.connect('changed::group-apps-label-font-size', Lang.bind(this, this._updateWindowTitleStyle)), - this._dtpSettings.connect('changed::group-apps-label-font-weight', Lang.bind(this, this._updateWindowTitleStyle)), - this._dtpSettings.connect('changed::group-apps-label-font-color', Lang.bind(this, this._updateWindowTitleStyle)), - this._dtpSettings.connect('changed::group-apps-label-max-width', Lang.bind(this, this._updateWindowTitleStyle)), - this._dtpSettings.connect('changed::group-apps-use-fixed-width', Lang.bind(this, this._updateWindowTitleStyle)), - this._dtpSettings.connect('changed::group-apps-underline-unfocused', Lang.bind(this, this._settingsChangeRefresh)) + Me.settings.connect('changed::dot-position', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::dot-size', Lang.bind(this, this._updateDotSize)), + Me.settings.connect('changed::dot-style-focused', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::dot-style-unfocused', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::dot-color-dominant', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::dot-color-override', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::dot-color-1', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::dot-color-2', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::dot-color-3', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::dot-color-4', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::dot-color-unfocused-different', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::dot-color-unfocused-1', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::dot-color-unfocused-2', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::dot-color-unfocused-3', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::dot-color-unfocused-4', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::focus-highlight', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::focus-highlight-dominant', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::focus-highlight-color', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::focus-highlight-opacity', Lang.bind(this, this._settingsChangeRefresh)), + Me.settings.connect('changed::group-apps-label-font-size', Lang.bind(this, this._updateWindowTitleStyle)), + Me.settings.connect('changed::group-apps-label-font-weight', Lang.bind(this, this._updateWindowTitleStyle)), + Me.settings.connect('changed::group-apps-label-font-color', Lang.bind(this, this._updateWindowTitleStyle)), + Me.settings.connect('changed::group-apps-label-max-width', Lang.bind(this, this._updateWindowTitleStyle)), + Me.settings.connect('changed::group-apps-use-fixed-width', Lang.bind(this, this._updateWindowTitleStyle)), + Me.settings.connect('changed::group-apps-underline-unfocused', Lang.bind(this, this._settingsChangeRefresh)) ] this.forcedOverview = false; @@ -237,8 +234,8 @@ var taskbarAppIcon = Utils.defineClass({ }, shouldShowTooltip: function() { - if (!this._dtpSettings.get_boolean('show-tooltip') || - (!this.isLauncher && this._dtpSettings.get_boolean("show-window-previews") && + if (!Me.settings.get_boolean('show-tooltip') || + (!this.isLauncher && Me.settings.get_boolean("show-window-previews") && this.getAppIconInterestingWindows().length > 0)) { return false; } else { @@ -249,7 +246,7 @@ var taskbarAppIcon = Utils.defineClass({ }, _onAppIconHoverChanged: function() { - if (!this._dtpSettings.get_boolean('show-window-previews') || + if (!Me.settings.get_boolean('show-window-previews') || (!this.window && !this._nWindows)) { return; } @@ -304,7 +301,7 @@ var taskbarAppIcon = Utils.defineClass({ } for (let i = 0; i < this._dtpSettingsSignalIds.length; ++i) { - this._dtpSettings.disconnect(this._dtpSettingsSignalIds[i]); + Me.settings.disconnect(this._dtpSettingsSignalIds[i]); } }, @@ -342,7 +339,7 @@ var taskbarAppIcon = Utils.defineClass({ }, _onMouseScroll: function(actor, event) { - if (this._dtpSettings.get_string('scroll-icon-action') === 'NOTHING' || + if (Me.settings.get_string('scroll-icon-action') === 'NOTHING' || (!this.window && !this._nWindows)) { return; } @@ -350,7 +347,7 @@ var taskbarAppIcon = Utils.defineClass({ let direction = Utils.getMouseScrollDirection(event); if (direction && !this._scrollIconDelayTimeoutId) { - this._scrollIconDelayTimeoutId = Mainloop.timeout_add(this._dtpSettings.get_int('scroll-icon-delay'), () => { + this._scrollIconDelayTimeoutId = Mainloop.timeout_add(Me.settings.get_int('scroll-icon-delay'), () => { this._scrollIconDelayTimeoutId = 0; }); @@ -392,7 +389,7 @@ var taskbarAppIcon = Utils.defineClass({ // being added to the panel return; } - this._drawRunningIndicator(this._focusedDots, this._dtpSettings.get_string('dot-style-focused'), true); + this._drawRunningIndicator(this._focusedDots, Me.settings.get_string('dot-style-focused'), true); this._displayProperIndicator(); })); @@ -402,7 +399,7 @@ var taskbarAppIcon = Utils.defineClass({ // being added to the panel return; } - this._drawRunningIndicator(this._unfocusedDots, this._dtpSettings.get_string('dot-style-unfocused'), false); + this._drawRunningIndicator(this._unfocusedDots, Me.settings.get_string('dot-style-unfocused'), false); this._displayProperIndicator(); })); @@ -434,19 +431,19 @@ var taskbarAppIcon = Utils.defineClass({ _updateWindowTitleStyle: function() { if (this._windowTitle) { - let useFixedWidth = this._dtpSettings.get_boolean('group-apps-use-fixed-width'); - let maxLabelWidth = this._dtpSettings.get_int('group-apps-label-max-width') * + let useFixedWidth = Me.settings.get_boolean('group-apps-use-fixed-width'); + let maxLabelWidth = Me.settings.get_int('group-apps-label-max-width') * St.ThemeContext.get_for_stage(global.stage).scale_factor; - let fontWeight = this._dtpSettings.get_string('group-apps-label-font-weight'); + let fontWeight = Me.settings.get_string('group-apps-label-font-weight'); this._windowTitle[(maxLabelWidth > 0 ? 'show' : 'hide')](); this._windowTitle.clutter_text.natural_width = useFixedWidth ? maxLabelWidth : 0; this._windowTitle.clutter_text.natural_width_set = useFixedWidth; - this._windowTitle.set_style('font-size: ' + this._dtpSettings.get_int('group-apps-label-font-size') + 'px;' + + this._windowTitle.set_style('font-size: ' + Me.settings.get_int('group-apps-label-font-size') + 'px;' + 'font-weight: ' + fontWeight + ';' + (useFixedWidth ? '' : 'max-width: ' + maxLabelWidth + 'px;') + - 'color: ' + this._dtpSettings.get_string('group-apps-label-font-color')); + 'color: ' + Me.settings.get_string('group-apps-label-font-color')); } }, @@ -463,13 +460,13 @@ var taskbarAppIcon = Utils.defineClass({ _setIconStyle: function(isFocused) { let inlineStyle = 'margin: 0;'; - if(this._dtpSettings.get_boolean('focus-highlight') && + if(Me.settings.get_boolean('focus-highlight') && this._checkIfFocusedApp() && !this.isLauncher && (!this.window || isFocused) && !this._isThemeProvidingIndicator() && this._checkIfMonitorHasFocus()) { - let focusedDotStyle = this._dtpSettings.get_string('dot-style-focused'); + let focusedDotStyle = Me.settings.get_string('dot-style-focused'); let isWide = this._isWideDotStyle(focusedDotStyle); - let pos = this._dtpSettings.get_string('dot-position'); - let highlightMargin = isWide ? this._dtpSettings.get_int('dot-size') : 0; + let pos = Me.settings.get_string('dot-position'); + let highlightMargin = isWide ? Me.settings.get_int('dot-size') : 0; if(!this.window) { let containerWidth = this._dtpIconContainer.get_width() / St.ThemeContext.get_for_stage(global.stage).scale_factor; @@ -487,7 +484,7 @@ var taskbarAppIcon = Utils.defineClass({ } let highlightColor = this._getFocusHighlightColor(); - inlineStyle += "background-color: " + cssHexTocssRgba(highlightColor, this._dtpSettings.get_int('focus-highlight-opacity') * 0.01); + inlineStyle += "background-color: " + cssHexTocssRgba(highlightColor, Me.settings.get_int('focus-highlight-opacity') * 0.01); } if(this._dotsContainer.get_style() != inlineStyle) { @@ -507,14 +504,14 @@ var taskbarAppIcon = Utils.defineClass({ _checkIfMonitorHasFocus: function() { return global.display.focus_window && - (!this._dtpSettings.get_boolean('multi-monitors') || // only check same monitor index if multi window is enabled. - !this._dtpSettings.get_boolean('isolate-monitors') || + (!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.panelWrapper.monitor.index); }, _setAppIconPadding: function() { - let padding = getIconPadding(this._dtpSettings); - let margin = this._dtpSettings.get_int('appicon-margin'); + let padding = getIconPadding(Me.settings); + let margin = Me.settings.get_int('appicon-margin'); this.actor.set_style('padding: 0 ' + margin + 'px;'); this._iconContainer.set_style('padding: ' + padding + 'px;'); @@ -529,9 +526,9 @@ var taskbarAppIcon = Utils.defineClass({ } if (!this._menu) { - this._menu = new taskbarSecondaryMenu(this, this._dtpSettings); + this._menu = new taskbarSecondaryMenu(this); this._menu.connect('activate-window', Lang.bind(this, function (menu, window) { - this.activateWindow(window, this._dtpSettings); + this.activateWindow(window, Me.settings); })); this._menu.connect('open-state-changed', Lang.bind(this, function (menu, isPoppedUp) { if (!isPoppedUp) @@ -586,8 +583,8 @@ var taskbarAppIcon = Utils.defineClass({ this._setIconStyle(isFocused); if(!this._isGroupApps) { - if (this.window && (this._dtpSettings.get_boolean('group-apps-underline-unfocused') || isFocused)) { - let dotPosition = this._dtpSettings.get_string('dot-position'); + if (this.window && (Me.settings.get_boolean('group-apps-underline-unfocused') || isFocused)) { + let dotPosition = Me.settings.get_string('dot-position'); this._focusedDots.y_align = dotPosition == DOT_POSITION.TOP ? Clutter.ActorAlign.START : Clutter.ActorAlign.END; this._focusedDots.background_color = this._getRunningIndicatorColor(isFocused); @@ -597,8 +594,8 @@ var taskbarAppIcon = Utils.defineClass({ } } else { let containerWidth = this._container.width; - let focusedDotStyle = this._dtpSettings.get_string('dot-style-focused'); - let unfocusedDotStyle = this._dtpSettings.get_string('dot-style-unfocused'); + let focusedDotStyle = Me.settings.get_string('dot-style-focused'); + let unfocusedDotStyle = Me.settings.get_string('dot-style-unfocused'); let focusedIsWide = this._isWideDotStyle(focusedDotStyle); let unfocusedIsWide = this._isWideDotStyle(unfocusedDotStyle); @@ -638,7 +635,7 @@ var taskbarAppIcon = Utils.defineClass({ // animation is enabled in settings // AND (going from a wide style to a narrow style indicator or vice-versa // OR going from an open app to a closed app or vice versa) - if(this._dtpSettings.get_boolean('animate-app-switch') && + if(Me.settings.get_boolean('animate-app-switch') && ((focusedIsWide != unfocusedIsWide) || (this._focusedDots.width != newUnfocusedDotsWidth || this._unfocusedDots.width != newFocusedDotsWidth))) { this._animateDotDisplay(this._focusedDots, newFocusedDotsWidth, this._unfocusedDots, newUnfocusedDotsOpacity, force); @@ -724,20 +721,20 @@ var taskbarAppIcon = Utils.defineClass({ let buttonAction = 0; if (button && button == 2 ) { if (modifiers & Clutter.ModifierType.SHIFT_MASK) - buttonAction = this._dtpSettings.get_string('shift-middle-click-action'); + buttonAction = Me.settings.get_string('shift-middle-click-action'); else - buttonAction = this._dtpSettings.get_string('middle-click-action'); + buttonAction = Me.settings.get_string('middle-click-action'); } else if (button && button == 1) { if (modifiers & Clutter.ModifierType.SHIFT_MASK) - buttonAction = this._dtpSettings.get_string('shift-click-action'); + buttonAction = Me.settings.get_string('shift-click-action'); else - buttonAction = this._dtpSettings.get_string('click-action'); + buttonAction = Me.settings.get_string('click-action'); } let appCount = this.getAppIconInterestingWindows().length; let previewedAppIcon = this._previewMenu.getCurrentAppIcon(); - this._previewMenu.close(this._dtpSettings.get_boolean('window-preview-hide-immediate-click')); + this._previewMenu.close(Me.settings.get_boolean('window-preview-hide-immediate-click')); // We check if the app is running, and that the # of windows is > 0 in // case we use workspace isolation, @@ -774,7 +771,7 @@ var taskbarAppIcon = Utils.defineClass({ switch (buttonAction) { case "RAISE": - activateAllWindows(this.app, this._dtpSettings, monitor); + activateAllWindows(this.app, monitor); break; case "LAUNCH": @@ -791,10 +788,10 @@ var taskbarAppIcon = Utils.defineClass({ // minimize all windows on double click and always in the case of primary click without // additional modifiers let all_windows = (button == 1 && ! modifiers) || event.get_click_count() > 1; - minimizeWindow(this.app, all_windows, this._dtpSettings, monitor); + minimizeWindow(this.app, all_windows, monitor); } else - activateAllWindows(this.app, this._dtpSettings, monitor); + activateAllWindows(this.app, monitor); } else this.app.activate(); @@ -803,9 +800,9 @@ var taskbarAppIcon = Utils.defineClass({ case "CYCLE": if (!Main.overview._shown){ if (appHasFocus) - cycleThroughWindows(this.app, this._dtpSettings, false, false, monitor); + cycleThroughWindows(this.app, false, false, monitor); else { - activateFirstWindow(this.app, this._dtpSettings, monitor); + activateFirstWindow(this.app, monitor); } } else @@ -814,9 +811,9 @@ var taskbarAppIcon = Utils.defineClass({ case "CYCLE-MIN": if (!Main.overview._shown){ if (appHasFocus || (recentlyClickedApp == this.app && recentlyClickedAppWindows[recentlyClickedAppIndex % recentlyClickedAppWindows.length] == "MINIMIZE")) - cycleThroughWindows(this.app, this._dtpSettings, false, true, monitor); + cycleThroughWindows(this.app, false, true, monitor); else { - activateFirstWindow(this.app, this._dtpSettings, monitor); + activateFirstWindow(this.app, monitor); } } else @@ -826,13 +823,13 @@ var taskbarAppIcon = Utils.defineClass({ if (!Main.overview._shown) { if (appCount == 1) { if (appHasFocus) - minimizeWindow(this.app, false, this._dtpSettings, monitor); + minimizeWindow(this.app, false, monitor); else - activateFirstWindow(this.app, this._dtpSettings, monitor); + activateFirstWindow(this.app, monitor); } else { if (event.get_click_count() > 1) { // minimize all windows if double clicked - minimizeWindow(this.app, true, this._dtpSettings, monitor); + minimizeWindow(this.app, true, monitor); } else if (previewedAppIcon != this) { this._previewMenu.open(this); } @@ -845,7 +842,7 @@ var taskbarAppIcon = Utils.defineClass({ break; case "QUIT": - closeAllWindows(this.app, this._dtpSettings, monitor); + closeAllWindows(this.app, monitor); break; } } @@ -862,7 +859,7 @@ var taskbarAppIcon = Utils.defineClass({ let appActions = this.app.get_app_info().list_actions(); let newWindowIndex = appActions.indexOf('new-window'); - if(this._dtpSettings.get_boolean('animate-window-launch')) { + if(Me.settings.get_boolean('animate-window-launch')) { this.animateLaunch(); } @@ -907,14 +904,14 @@ var taskbarAppIcon = Utils.defineClass({ }, _getRunningIndicatorHeight: function() { - return this._dtpSettings.get_int('dot-size') * St.ThemeContext.get_for_stage(global.stage).scale_factor; + return Me.settings.get_int('dot-size') * St.ThemeContext.get_for_stage(global.stage).scale_factor; }, _getRunningIndicatorColor: function(isFocused) { let color; const fallbackColor = new Clutter.Color({ red: 82, green: 148, blue: 226, alpha: 255 }); - if (this._dtpSettings.get_boolean('dot-color-dominant')) { + if (Me.settings.get_boolean('dot-color-dominant')) { let dce = new Utils.DominantColorExtractor(this.app); let palette = dce._getColorPalette(); if (palette) { @@ -926,13 +923,13 @@ var taskbarAppIcon = Utils.defineClass({ // theme didn't provide one, use a default if(color.alpha == 0) color = fallbackColor; } - } else if(this._dtpSettings.get_boolean('dot-color-override')) { + } else if(Me.settings.get_boolean('dot-color-override')) { let dotColorSettingPrefix = 'dot-color-'; - if(!isFocused && this._dtpSettings.get_boolean('dot-color-unfocused-different')) + if(!isFocused && Me.settings.get_boolean('dot-color-unfocused-different')) dotColorSettingPrefix = 'dot-color-unfocused-'; - color = Clutter.color_from_string(this._dtpSettings.get_string(dotColorSettingPrefix + (this._getRunningIndicatorCount() || 1) ))[1]; + color = Clutter.color_from_string(Me.settings.get_string(dotColorSettingPrefix + (this._getRunningIndicatorCount() || 1) ))[1]; } else { // Re-use the style - background color, and border width and color - // of the default dot @@ -947,12 +944,12 @@ var taskbarAppIcon = Utils.defineClass({ }, _getFocusHighlightColor: function() { - if (this._dtpSettings.get_boolean('focus-highlight-dominant')) { + 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 this._dtpSettings.get_string('focus-highlight-color'); + return Me.settings.get_string('focus-highlight-color'); }, _drawRunningIndicator: function(area, type, isFocused) { @@ -967,7 +964,7 @@ var taskbarAppIcon = Utils.defineClass({ let cr = area.get_context(); let size = this._getRunningIndicatorHeight(); let padding = 0; // distance from the margin - let yOffset = this._dtpSettings.get_string('dot-position') == DOT_POSITION.TOP ? 0 : (height - padding - size); + let yOffset = Me.settings.get_string('dot-position') == DOT_POSITION.TOP ? 0 : (height - padding - size); if(type == DOT_STYLE.DOTS) { // Draw the required numbers of dots @@ -1124,15 +1121,15 @@ var taskbarAppIcon = Utils.defineClass({ }, getAppIconInterestingWindows: function(isolateMonitors) { - return getInterestingWindows(this.app, this._dtpSettings, this.panelWrapper.monitor, isolateMonitors); + return getInterestingWindows(this.app, this.panelWrapper.monitor, isolateMonitors); } }); taskbarAppIcon.prototype.scaleAndFade = taskbarAppIcon.prototype.undoScaleAndFade = () => {}; -function minimizeWindow(app, param, settings, monitor){ +function minimizeWindow(app, param, monitor){ // Param true make all app windows minimize - let windows = getInterestingWindows(app, settings, monitor); + let windows = getInterestingWindows(app, monitor); let current_workspace = Utils.DisplayWrapper.getWorkspaceManager().get_active_workspace(); for (let i = 0; i < windows.length; i++) { let w = windows[i]; @@ -1150,11 +1147,11 @@ function minimizeWindow(app, param, settings, monitor){ * By default only non minimized windows are activated. * This activates all windows in the current workspace. */ -function activateAllWindows(app, settings, monitor){ +function activateAllWindows(app, monitor){ // First activate first window so workspace is switched if needed, // then activate all other app windows in the current workspace. - let windows = getInterestingWindows(app, settings, monitor); + let windows = getInterestingWindows(app, monitor); let w = windows[0]; Main.activateWindow(w); let activeWorkspace = Utils.DisplayWrapper.getWorkspaceManager().get_active_workspace_index(); @@ -1169,18 +1166,18 @@ function activateAllWindows(app, settings, monitor){ } } -function activateFirstWindow(app, settings, monitor){ +function activateFirstWindow(app, monitor){ - let windows = getInterestingWindows(app, settings, monitor); + let windows = getInterestingWindows(app, monitor); Main.activateWindow(windows[0]); } -function cycleThroughWindows(app, settings, reversed, shouldMinimize, monitor) { +function cycleThroughWindows(app, reversed, shouldMinimize, monitor) { // Store for a little amount of time last clicked app and its windows // since the order changes upon window interaction let MEMORY_TIME=3000; - let app_windows = getInterestingWindows(app, settings, monitor); + let app_windows = getInterestingWindows(app, monitor); if(shouldMinimize) app_windows.push("MINIMIZE"); @@ -1210,7 +1207,7 @@ function cycleThroughWindows(app, settings, reversed, shouldMinimize, monitor) { let index = recentlyClickedAppIndex % recentlyClickedAppWindows.length; if(recentlyClickedAppWindows[index] === "MINIMIZE") - minimizeWindow(app, true, settings, monitor); + minimizeWindow(app, true, monitor); else Main.activateWindow(recentlyClickedAppWindows[index]); } @@ -1227,27 +1224,27 @@ function resetRecentlyClickedApp() { return false; } -function closeAllWindows(app, settings, monitor) { - let windows = getInterestingWindows(app, settings, monitor); +function closeAllWindows(app, monitor) { + let windows = getInterestingWindows(app, monitor); for (let i = 0; i < windows.length; i++) windows[i].delete(global.get_current_time()); } // Filter out unnecessary windows, for instance // nautilus desktop window. -function getInterestingWindows(app, settings, monitor, isolateMonitors) { +function getInterestingWindows(app, monitor, isolateMonitors) { let windows = app.get_windows().filter(function(w) { return !w.skip_taskbar; }); // When using workspace or monitor isolation, we filter out windows // that are not in the current workspace or on the same monitor as the appicon - if (settings.get_boolean('isolate-workspaces')) + if (Me.settings.get_boolean('isolate-workspaces')) windows = windows.filter(function(w) { return w.get_workspace().index() == Utils.DisplayWrapper.getWorkspaceManager().get_active_workspace_index(); }); - if (monitor && settings.get_boolean('multi-monitors') && (isolateMonitors || settings.get_boolean('isolate-monitors'))) { + if (monitor && Me.settings.get_boolean('multi-monitors') && (isolateMonitors || Me.settings.get_boolean('isolate-monitors'))) { windows = windows.filter(function(w) { return w.get_monitor() == monitor.index; }); @@ -1290,9 +1287,7 @@ var taskbarSecondaryMenu = Utils.defineClass({ Extends: AppDisplay.AppIconMenu, ParentConstrParams: [[0]], - _init: function(source, settings) { - this._dtpSettings = settings; - + _init: function(source) { // Damm it, there has to be a proper way of doing this... // As I can't call the parent parent constructor (?) passing the side // parameter, I overwite what I need later @@ -1314,7 +1309,7 @@ var taskbarSecondaryMenu = Utils.defineClass({ this.callParent('_redisplay'); // Remove "Show Details" menu item - if(!this._dtpSettings.get_boolean('secondarymenu-contains-showdetails')) { + if(!Me.settings.get_boolean('secondarymenu-contains-showdetails')) { let existingMenuItems = this._getMenuItems(); for(let idx in existingMenuItems) { if(existingMenuItems[idx].actor.label_actor.text == _("Show Details")) { @@ -1327,7 +1322,7 @@ var taskbarSecondaryMenu = Utils.defineClass({ } // prepend items from the appMenu (for native gnome apps) - if(this._dtpSettings.get_boolean('secondarymenu-contains-appmenu')) { + if(Me.settings.get_boolean('secondarymenu-contains-appmenu')) { let appMenu = this._source.app.menu; if(appMenu) { let remoteMenu = new imports.ui.remoteMenu.RemoteMenu(this._source.actor, this._source.app.menu, this._source.app.action_group); @@ -1393,7 +1388,7 @@ var taskbarSecondaryMenu = Utils.defineClass({ // quit menu let app = this._source.app; let window = this._source.window; - let count = window ? 1 : getInterestingWindows(app, this._dtpSettings).length; + let count = window ? 1 : getInterestingWindows(app).length; if ( count > 0) { this._appendSeparator(); let quitFromTaskbarMenuText = ""; @@ -1493,8 +1488,7 @@ function ItemShowLabel() { var ShowAppsIconWrapper = Utils.defineClass({ Name: 'DashToPanel.ShowAppsIconWrapper', - _init: function(settings) { - this._dtpSettings = settings; + _init: function() { this.realShowAppsIcon = new Dash.ShowAppsIcon(); Utils.wrapActor(this.realShowAppsIcon); @@ -1532,7 +1526,7 @@ var ShowAppsIconWrapper = Utils.defineClass({ Taskbar.extendDashItemContainer(this.realShowAppsIcon); - let customIconPath = this._dtpSettings.get_string('show-apps-icon-file'); + let customIconPath = Me.settings.get_string('show-apps-icon-file'); this.realShowAppsIcon.icon.createIcon = function(size) { this._iconActor = new St.Icon({ icon_name: 'view' + (Config.PACKAGE_VERSION < '3.20' ? '' : '-app') + '-grid-symbolic', @@ -1547,20 +1541,20 @@ var ShowAppsIconWrapper = Utils.defineClass({ return this._iconActor; }; - this._changedShowAppsIconId = this._dtpSettings.connect('changed::show-apps-icon-file', () => { - customIconPath = this._dtpSettings.get_string('show-apps-icon-file'); + this._changedShowAppsIconId = Me.settings.connect('changed::show-apps-icon-file', () => { + customIconPath = Me.settings.get_string('show-apps-icon-file'); this.realShowAppsIcon.icon._createIconTexture(this.realShowAppsIcon.icon.iconSize); }); - this._changedAppIconPaddingId = this._dtpSettings.connect('changed::appicon-padding', () => this.setShowAppsPadding()); - this._changedAppIconSidePaddingId = this._dtpSettings.connect('changed::show-apps-icon-side-padding', () => this.setShowAppsPadding()); + this._changedAppIconPaddingId = Me.settings.connect('changed::appicon-padding', () => this.setShowAppsPadding()); + this._changedAppIconSidePaddingId = Me.settings.connect('changed::show-apps-icon-side-padding', () => this.setShowAppsPadding()); this.setShowAppsPadding(); }, setShowAppsPadding: function() { - let padding = getIconPadding(this._dtpSettings); - let sidePadding = this._dtpSettings.get_int('show-apps-icon-side-padding') + let padding = getIconPadding(Me.settings); + let sidePadding = Me.settings.get_int('show-apps-icon-side-padding') this.actor.set_style('padding:' + padding + 'px ' + (padding + sidePadding) + 'px;'); }, @@ -1570,7 +1564,7 @@ var ShowAppsIconWrapper = Utils.defineClass({ this.actor.fake_release(); if (!this._menu) { - this._menu = new MyShowAppsIconMenu(this, this._dtpSettings); + this._menu = new MyShowAppsIconMenu(this, Me.settings); this._menu.connect('open-state-changed', Lang.bind(this, function(menu, isPoppedUp) { if (!isPoppedUp) this._onMenuPoppedDown(); @@ -1595,14 +1589,14 @@ var ShowAppsIconWrapper = Utils.defineClass({ }, shouldShowTooltip: function() { - return this._dtpSettings.get_boolean('show-tooltip') && + return Me.settings.get_boolean('show-tooltip') && (this.actor.hover && (!this._menu || !this._menu.isOpen)); }, destroy: function() { - this._dtpSettings.disconnect(this._changedShowAppsIconId); - this._dtpSettings.disconnect(this._changedAppIconSidePaddingId); - this._dtpSettings.disconnect(this._changedAppIconPaddingId); + Me.settings.disconnect(this._changedShowAppsIconId); + Me.settings.disconnect(this._changedAppIconSidePaddingId); + Me.settings.disconnect(this._changedAppIconPaddingId); } }); Signals.addSignalMethods(ShowAppsIconWrapper.prototype); @@ -1667,9 +1661,9 @@ var MyShowAppsIconMenu = Utils.defineClass({ this._appendSeparator(); - let lockTaskbarMenuItem = this._appendMenuItem(this._dtpSettings.get_boolean('taskbar-locked') ? _('Unlock taskbar') : _('Lock taskbar')); + let lockTaskbarMenuItem = this._appendMenuItem(Me.settings.get_boolean('taskbar-locked') ? _('Unlock taskbar') : _('Lock taskbar')); lockTaskbarMenuItem.connect('activate', () => { - this._dtpSettings.set_boolean('taskbar-locked', !this._dtpSettings.get_boolean('taskbar-locked')); + Me.settings.set_boolean('taskbar-locked', !Me.settings.get_boolean('taskbar-locked')); }); let settingsMenuItem = this._appendMenuItem(_('Dash to Panel Settings')); diff --git a/extension.js b/extension.js index ddabe0a..3719225 100644 --- a/extension.js +++ b/extension.js @@ -38,7 +38,6 @@ const Utils = Me.imports.utils; const UBUNTU_DOCK_UUID = 'ubuntu-dock@ubuntu.com'; let panelManager; -let settings; let oldDash; let extensionChangedHandler; let disabledUbuntuDock; @@ -86,8 +85,8 @@ function _enable() { if (panelManager) return; //already initialized - settings = Convenience.getSettings('org.gnome.shell.extensions.dash-to-panel'); - panelManager = new PanelManager.dtpPanelManager(settings); + Me.settings = Convenience.getSettings('org.gnome.shell.extensions.dash-to-panel'); + panelManager = new PanelManager.dtpPanelManager(); panelManager.enable(); Utils.removeKeybinding('open-application-menu'); @@ -112,9 +111,9 @@ function _enable() { function disable(reset) { panelManager.disable(); Main.overview._dash = oldDash; - settings.run_dispose(); + Me.settings.run_dispose(); - settings = null; + delete Me.settings; oldDash = null; panelManager = null; diff --git a/intellihide.js b/intellihide.js index 5d2b933..aef4d38 100644 --- a/intellihide.js +++ b/intellihide.js @@ -54,7 +54,6 @@ var Intellihide = Utils.defineClass({ _init: function(dtpPanel) { this._dtpPanel = dtpPanel; - this._dtpSettings = dtpPanel._dtpSettings; this._panelBox = dtpPanel.panelBox; this._panelManager = dtpPanel.panelManager; this._proximityManager = this._panelManager.proximityManager; @@ -63,8 +62,8 @@ var Intellihide = Utils.defineClass({ this._signalsHandler = new Utils.GlobalSignalsHandler(); this._timeoutsHandler = new Utils.TimeoutsHandler(); - this._intellihideChangedId = this._dtpSettings.connect('changed::intellihide', () => this._changeEnabledStatus()); - this._intellihideOnlySecondaryChangedId = this._dtpSettings.connect('changed::intellihide-only-secondary', () => this._changeEnabledStatus()); + this._intellihideChangedId = Me.settings.connect('changed::intellihide', () => this._changeEnabledStatus()); + this._intellihideOnlySecondaryChangedId = Me.settings.connect('changed::intellihide-only-secondary', () => this._changeEnabledStatus()); this.enabled = false; this._changeEnabledStatus(); @@ -77,7 +76,7 @@ var Intellihide = Utils.defineClass({ this._pendingUpdate = false; this._hoveredOut = false; this._windowOverlap = false; - this._panelAtTop = this._dtpSettings.get_string('panel-position') === 'TOP'; + this._panelAtTop = Me.settings.get_string('panel-position') === 'TOP'; if (this._panelAtTop && this._panelBox.translation_y > 0 || !this._panelAtTop && this._panelBox.translation_y < 0) { @@ -88,10 +87,10 @@ var Intellihide = Utils.defineClass({ this._setTrackPanel(reset, true); this._bindGeneralSignals(); - if (this._dtpSettings.get_boolean('intellihide-hide-from-windows')) { + if (Me.settings.get_boolean('intellihide-hide-from-windows')) { this._proximityWatchId = this._proximityManager.createWatch( this._clipContainer, - Proximity.Mode[this._dtpSettings.get_string('intellihide-behaviour')], + Proximity.Mode[Me.settings.get_string('intellihide-behaviour')], 0, 0, overlap => { this._windowOverlap = overlap; @@ -122,8 +121,8 @@ var Intellihide = Utils.defineClass({ }, destroy: function() { - this._dtpSettings.disconnect(this._intellihideChangedId); - this._dtpSettings.disconnect(this._intellihideOnlySecondaryChangedId); + Me.settings.disconnect(this._intellihideChangedId); + Me.settings.disconnect(this._intellihideOnlySecondaryChangedId); if (this.enabled) { this.disable(); @@ -156,8 +155,8 @@ var Intellihide = Utils.defineClass({ }, _changeEnabledStatus: function() { - let intellihide = this._dtpSettings.get_boolean('intellihide'); - let onlySecondary = this._dtpSettings.get_boolean('intellihide-only-secondary'); + let intellihide = Me.settings.get_boolean('intellihide'); + let onlySecondary = Me.settings.get_boolean('intellihide-only-secondary'); let enabled = intellihide && (this._dtpPanel.isSecondary || !onlySecondary); if (this.enabled !== enabled) { @@ -173,7 +172,7 @@ var Intellihide = Utils.defineClass({ () => this._panelBox.sync_hover() ], [ - this._dtpSettings, + Me.settings, [ 'changed::panel-position', 'changed::panel-size', @@ -244,11 +243,11 @@ var Intellihide = Utils.defineClass({ }, _setRevealMechanism: function() { - if (global.display.supports_extended_barriers() && this._dtpSettings.get_boolean('intellihide-use-pressure')) { + if (global.display.supports_extended_barriers() && Me.settings.get_boolean('intellihide-use-pressure')) { this._edgeBarrier = this._createBarrier(); this._pressureBarrier = new Layout.PressureBarrier( - this._dtpSettings.get_int('intellihide-pressure-threshold'), - this._dtpSettings.get_int('intellihide-pressure-time'), + Me.settings.get_int('intellihide-pressure-threshold'), + Me.settings.get_int('intellihide-pressure-time'), Shell.ActionMode.NORMAL ); this._pressureBarrier.addBarrier(this._edgeBarrier); @@ -331,13 +330,13 @@ var Intellihide = Utils.defineClass({ //the user is trying to reveal the panel if (this._monitor.inFullscreen && !mouseBtnIsPressed) { - return this._dtpSettings.get_boolean('intellihide-show-in-fullscreen'); + return Me.settings.get_boolean('intellihide-show-in-fullscreen'); } return !mouseBtnIsPressed; } - if (!this._dtpSettings.get_boolean('intellihide-hide-from-windows')) { + if (!Me.settings.get_boolean('intellihide-hide-from-windows')) { return this._panelBox.hover; } @@ -384,9 +383,9 @@ var Intellihide = Utils.defineClass({ //when entering/leaving the overview, use its animation time instead of the one from the settings time: Main.overview.visible ? OverviewControls.SIDE_CONTROLS_ANIMATION_TIME : - this._dtpSettings.get_int('intellihide-animation-time') * 0.001, + Me.settings.get_int('intellihide-animation-time') * 0.001, //only delay the animation when hiding the panel after the user hovered out - delay: destination != 0 && this._hoveredOut ? this._dtpSettings.get_int('intellihide-close-delay') * 0.001 : 0, + delay: destination != 0 && this._hoveredOut ? Me.settings.get_int('intellihide-close-delay') * 0.001 : 0, transition: 'easeOutQuad', onComplete: () => { this._invokeIfExists(onComplete); diff --git a/overview.js b/overview.js index 03862f7..0c0cec9 100644 --- a/overview.js +++ b/overview.js @@ -40,10 +40,9 @@ const GS_HOTKEYS_KEY = 'switch-to-application-'; var dtpOverview = Utils.defineClass({ Name: 'DashToPanel.Overview', - _init: function(settings) { + _init: function() { this._numHotkeys = 10; this._currentHotkeyFocusIndex = -1; - this._dtpSettings = settings; }, enable : function(panel) { @@ -59,7 +58,7 @@ var dtpOverview = Utils.defineClass({ this._toggleDash(); this._signalsHandler.add([ - this._dtpSettings, + Me.settings, 'changed::stockgs-keep-dash', () => this._toggleDash() ]); @@ -88,7 +87,7 @@ var dtpOverview = Utils.defineClass({ // 1 static workspace only) if (visible === undefined) { - visible = this._dtpSettings.get_boolean('stockgs-keep-dash'); + visible = Me.settings.get_boolean('stockgs-keep-dash'); } let visibilityFunc = visible ? 'show' : 'hide'; @@ -108,19 +107,19 @@ var dtpOverview = Utils.defineClass({ let label = 'optionalWorkspaceIsolation'; this._signalsHandler.add([ - this._dtpSettings, + Me.settings, 'changed::isolate-workspaces', Lang.bind(this, function() { this._panel.panelManager.allPanels.forEach(p => p.taskbar.resetAppIcons()); - if (this._dtpSettings.get_boolean('isolate-workspaces')) + if (Me.settings.get_boolean('isolate-workspaces')) Lang.bind(this, enable)(); else Lang.bind(this, disable)(); }) ]); - if (this._dtpSettings.get_boolean('isolate-workspaces')) + if (Me.settings.get_boolean('isolate-workspaces')) Lang.bind(this, enable)(); function enable() { @@ -181,7 +180,7 @@ var dtpOverview = Utils.defineClass({ let seenAppCount = seenApps[appIcon.app]; let windowCount = appIcon.window || appIcon._hotkeysCycle ? seenAppCount : appIcon._nWindows; - if (this._dtpSettings.get_boolean('shortcut-previews') && windowCount > 1) { + if (Me.settings.get_boolean('shortcut-previews') && windowCount > 1) { if (this._currentHotkeyFocusIndex < 0) { let currentWindow = appIcon.window; let keyFocusOutId = appIcon.actor.connect('key-focus-out', () => appIcon.actor.grab_key_focus()); @@ -216,14 +215,14 @@ var dtpOverview = Utils.defineClass({ _optionalHotKeys: function() { this._hotKeysEnabled = false; - if (this._dtpSettings.get_boolean('hot-keys')) + if (Me.settings.get_boolean('hot-keys')) this._enableHotKeys(); this._signalsHandler.add([ - this._dtpSettings, + Me.settings, 'changed::hot-keys', Lang.bind(this, function() { - if (this._dtpSettings.get_boolean('hot-keys')) + if (Me.settings.get_boolean('hot-keys')) Lang.bind(this, this._enableHotKeys)(); else Lang.bind(this, this._disableHotKeys)(); @@ -249,13 +248,13 @@ var dtpOverview = Utils.defineClass({ for (let i = 0; i < this._numHotkeys; i++) { let appNum = i; - Utils.addKeybinding(key + (i + 1), this._dtpSettings, () => this._activateApp(appNum)); + Utils.addKeybinding(key + (i + 1), Me.settings, () => this._activateApp(appNum)); } }, this); this._hotKeysEnabled = true; - if (this._dtpSettings.get_string('hotkeys-overlay-combo') === 'ALWAYS') + if (Me.settings.get_string('hotkeys-overlay-combo') === 'ALWAYS') this.taskbar.toggleNumberOverlay(true); }, @@ -286,18 +285,18 @@ var dtpOverview = Utils.defineClass({ _optionalNumberOverlay: function() { // Enable extra shortcut - if (this._dtpSettings.get_boolean('hot-keys')) + if (Me.settings.get_boolean('hot-keys')) this._enableExtraShortcut(); this._signalsHandler.add([ - this._dtpSettings, + Me.settings, 'changed::hot-keys', Lang.bind(this, this._checkHotkeysOptions) ], [ - this._dtpSettings, + Me.settings, 'changed::hotkeys-overlay-combo', Lang.bind(this, function() { - if (this._dtpSettings.get_boolean('hot-keys') && this._dtpSettings.get_string('hotkeys-overlay-combo') === 'ALWAYS') + if (Me.settings.get_boolean('hot-keys') && Me.settings.get_string('hotkeys-overlay-combo') === 'ALWAYS') this.taskbar.toggleNumberOverlay(true); else this.taskbar.toggleNumberOverlay(false); @@ -306,14 +305,14 @@ var dtpOverview = Utils.defineClass({ }, _checkHotkeysOptions: function() { - if (this._dtpSettings.get_boolean('hot-keys')) + if (Me.settings.get_boolean('hot-keys')) this._enableExtraShortcut(); else this._disableExtraShortcut(); }, _enableExtraShortcut: function() { - Utils.addKeybinding('shortcut', this._dtpSettings, () => this._showOverlay(true)); + Utils.addKeybinding('shortcut', Me.settings, () => this._showOverlay(true)); }, _disableExtraShortcut: function() { @@ -332,7 +331,7 @@ var dtpOverview = Utils.defineClass({ this._numberOverlayTimeoutId = 0; } - let hotkey_option = this._dtpSettings.get_string('hotkeys-overlay-combo'); + let hotkey_option = Me.settings.get_string('hotkeys-overlay-combo'); if (hotkey_option === 'NEVER') return; @@ -342,10 +341,10 @@ var dtpOverview = Utils.defineClass({ this._panel.intellihide.revealAndHold(Intellihide.Hold.TEMPORARY); - let timeout = this._dtpSettings.get_int('overlay-timeout'); + let timeout = Me.settings.get_int('overlay-timeout'); if (overlayFromShortcut) { - timeout = this._dtpSettings.get_int('shortcut-timeout'); + timeout = Me.settings.get_int('shortcut-timeout'); } // Hide the overlay/dock after the timeout diff --git a/panel.js b/panel.js index e1bfbd5..74f7cf0 100644 --- a/panel.js +++ b/panel.js @@ -63,8 +63,7 @@ var dtpPanelWrapper = Utils.defineClass({ _init: function(panelManager, monitor, panel, panelBox, isSecondary) { this.panelManager = panelManager; - this._dtpSettings = panelManager._dtpSettings; - this.panelStyle = new PanelStyle.dtpPanelStyle(panelManager._dtpSettings); + this.panelStyle = new PanelStyle.dtpPanelStyle(); this.monitor = monitor; this.panel = panel; @@ -76,7 +75,7 @@ var dtpPanelWrapper = Utils.defineClass({ }, enable : function() { - let taskbarPosition = this._dtpSettings.get_string('taskbar-position'); + let taskbarPosition = Me.settings.get_string('taskbar-position'); if (taskbarPosition == 'CENTEREDCONTENT' || taskbarPosition == 'CENTEREDMONITOR') { this.container = this.panel._centerBox; } else { @@ -155,7 +154,7 @@ var dtpPanelWrapper = Utils.defineClass({ this.panel.menuManager._oldChangeMenu = this.panel.menuManager._changeMenu; this.panel.menuManager._changeMenu = (menu) => { - if (!this._dtpSettings.get_boolean('stockgs-panelbtn-click-only')) { + if (!Me.settings.get_boolean('stockgs-panelbtn-click-only')) { this.panel.menuManager._oldChangeMenu(menu); } }; @@ -174,10 +173,10 @@ var dtpPanelWrapper = Utils.defineClass({ this.container.insert_child_above(this.taskbar.actor, null); - this._setActivitiesButtonVisible(this._dtpSettings.get_boolean('show-activities-button')); - this._setAppmenuVisible(this._dtpSettings.get_boolean('show-appmenu')); - this._setClockLocation(this._dtpSettings.get_string('location-clock')); - this._displayShowDesktopButton(this._dtpSettings.get_boolean('show-showdesktop-button')); + this._setActivitiesButtonVisible(Me.settings.get_boolean('show-activities-button')); + this._setAppmenuVisible(Me.settings.get_boolean('show-appmenu')); + this._setClockLocation(Me.settings.get_string('location-clock')); + this._displayShowDesktopButton(Me.settings.get_boolean('show-showdesktop-button')); this.panel.actor.add_style_class_name('dashtopanelMainPanel'); @@ -234,13 +233,13 @@ var dtpPanelWrapper = Utils.defineClass({ this.panel._rightBox, 'actor-added', Lang.bind(this, function() { - this._setClockLocation(this._dtpSettings.get_string('location-clock')); + this._setClockLocation(Me.settings.get_string('location-clock')); }) ], [ this.panel._centerBox, 'actor-added', - () => this._setClockLocation(this._dtpSettings.get_string('location-clock')) + () => this._setClockLocation(Me.settings.get_string('location-clock')) ], [ this.panel.actor, @@ -323,7 +322,7 @@ var dtpPanelWrapper = Utils.defineClass({ } for (let i = 0; i < this._dtpSettingsSignalIds.length; ++i) { - this._dtpSettings.disconnect(this._dtpSettingsSignalIds[i]); + Me.settings.disconnect(this._dtpSettingsSignalIds[i]); } this._removeTopLimit(); @@ -392,36 +391,36 @@ var dtpPanelWrapper = Utils.defineClass({ _bindSettingsChanges: function() { this._dtpSettingsSignalIds = [ - this._dtpSettings.connect('changed::panel-size', Lang.bind(this, function() { + Me.settings.connect('changed::panel-size', Lang.bind(this, function() { this._setPanelPosition(); this.taskbar.resetAppIcons(); })), - this._dtpSettings.connect('changed::appicon-margin', Lang.bind(this, function() { + Me.settings.connect('changed::appicon-margin', Lang.bind(this, function() { this.taskbar.resetAppIcons(); })), - this._dtpSettings.connect('changed::appicon-padding', Lang.bind(this, function() { + Me.settings.connect('changed::appicon-padding', Lang.bind(this, function() { this.taskbar.resetAppIcons(); })), - this._dtpSettings.connect('changed::show-activities-button', Lang.bind(this, function() { - this._setActivitiesButtonVisible(this._dtpSettings.get_boolean('show-activities-button')); + Me.settings.connect('changed::show-activities-button', Lang.bind(this, function() { + this._setActivitiesButtonVisible(Me.settings.get_boolean('show-activities-button')); })), - this._dtpSettings.connect('changed::show-appmenu', Lang.bind(this, function() { - this._setAppmenuVisible(this._dtpSettings.get_boolean('show-appmenu')); + Me.settings.connect('changed::show-appmenu', Lang.bind(this, function() { + this._setAppmenuVisible(Me.settings.get_boolean('show-appmenu')); })), - this._dtpSettings.connect('changed::location-clock', Lang.bind(this, function() { - this._setClockLocation(this._dtpSettings.get_string('location-clock')); + Me.settings.connect('changed::location-clock', Lang.bind(this, function() { + this._setClockLocation(Me.settings.get_string('location-clock')); })), - this._dtpSettings.connect('changed::show-showdesktop-button', Lang.bind(this, function() { - this._displayShowDesktopButton(this._dtpSettings.get_boolean('show-showdesktop-button')); + Me.settings.connect('changed::show-showdesktop-button', Lang.bind(this, function() { + this._displayShowDesktopButton(Me.settings.get_boolean('show-showdesktop-button')); })), - this._dtpSettings.connect('changed::showdesktop-button-width', () => this._setShowDesktopButtonWidth()) + Me.settings.connect('changed::showdesktop-button-width', () => this._setShowDesktopButtonWidth()) ]; }, @@ -446,7 +445,7 @@ var dtpPanelWrapper = Utils.defineClass({ let [centerMinWidth, centerNaturalWidth] = this.panel._centerBox.get_preferred_width(-1); let [rightMinWidth, rightNaturalWidth] = this.panel._rightBox.get_preferred_width(-1); - let taskbarPosition = this._dtpSettings.get_string('taskbar-position'); + let taskbarPosition = Me.settings.get_string('taskbar-position'); // The _rightBox is always allocated the same, regardless of taskbar position setting let rightAllocWidth = rightNaturalWidth; @@ -534,7 +533,7 @@ var dtpPanelWrapper = Utils.defineClass({ _setPanelPosition: function() { let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor; - let size = this._dtpSettings.get_int('panel-size'); + let size = Me.settings.get_int('panel-size'); let container = this.intellihide && this.intellihide.enabled ? this.panelBox.get_parent() : this.panelBox; if(scaleFactor) @@ -602,7 +601,7 @@ var dtpPanelWrapper = Utils.defineClass({ } if (isVisible && this.appMenu) { - let taskbarPosition = this._dtpSettings.get_string('taskbar-position'); + let taskbarPosition = Me.settings.get_string('taskbar-position'); if (taskbarPosition == 'CENTEREDCONTENT' || taskbarPosition == 'CENTEREDMONITOR') { this.panel._leftBox.insert_child_above(this.appMenu.container, null); } else { @@ -661,8 +660,8 @@ var dtpPanelWrapper = Utils.defineClass({ this._showDesktopButton.connect('enter-event', Lang.bind(this, function(){ this._showDesktopButton.add_style_class_name('showdesktop-button-hovered'); - if (this._dtpSettings.get_boolean('show-showdesktop-hover')) { - this._showDesktopTimeoutId = Mainloop.timeout_add(this._dtpSettings.get_int('show-showdesktop-delay'), () => { + if (Me.settings.get_boolean('show-showdesktop-hover')) { + this._showDesktopTimeoutId = Mainloop.timeout_add(Me.settings.get_int('show-showdesktop-delay'), () => { this._hiddenDesktopWorkspace = Utils.DisplayWrapper.getWorkspaceManager().get_active_workspace(); this._toggleWorkspaceWindows(true, this._hiddenDesktopWorkspace); this._showDesktopTimeoutId = 0; @@ -673,7 +672,7 @@ var dtpPanelWrapper = Utils.defineClass({ this._showDesktopButton.connect('leave-event', Lang.bind(this, function(){ this._showDesktopButton.remove_style_class_name('showdesktop-button-hovered'); - if (this._dtpSettings.get_boolean('show-showdesktop-hover')) { + if (Me.settings.get_boolean('show-showdesktop-hover')) { if (this._showDesktopTimeoutId) { Mainloop.source_remove(this._showDesktopTimeoutId); this._showDesktopTimeoutId = 0; @@ -696,7 +695,7 @@ var dtpPanelWrapper = Utils.defineClass({ _setShowDesktopButtonWidth: function() { if (this._showDesktopButton) { - this._showDesktopButton.set_style('width: ' + this._dtpSettings.get_int('showdesktop-button-width') + 'px;'); + this._showDesktopButton.set_style('width: ' + Me.settings.get_int('showdesktop-button-width') + 'px;'); } }, @@ -704,7 +703,7 @@ var dtpPanelWrapper = Utils.defineClass({ workspace.list_windows().forEach(w => Tweener.addTween(w.get_compositor_private(), { opacity: hide ? 0 : 255, - time: this._dtpSettings.get_int('show-showdesktop-time') * .001, + time: Me.settings.get_int('show-showdesktop-time') * .001, transition: 'easeOutQuad' }) ); @@ -753,11 +752,11 @@ var dtpPanelWrapper = Utils.defineClass({ }, _onPanelMouseScroll: function(actor, event) { - let scrollAction = this._dtpSettings.get_string('scroll-panel-action'); + let scrollAction = Me.settings.get_string('scroll-panel-action'); let direction = Utils.getMouseScrollDirection(event); if (!event.get_source()._dtpIgnoreScroll && direction && !this._scrollPanelDelayTimeoutId) { - this._scrollPanelDelayTimeoutId = Mainloop.timeout_add(this._dtpSettings.get_int('scroll-panel-delay'), () => { + this._scrollPanelDelayTimeoutId = Mainloop.timeout_add(Me.settings.get_int('scroll-panel-delay'), () => { this._scrollPanelDelayTimeoutId = 0; }); @@ -784,7 +783,7 @@ var dtpSecondaryPanel = Utils.defineClass({ _init: function(settings, monitor) { this.callParent('_init', { name: 'panel', reactive: true }); - this._dtpSettings = settings; + Me.settings = settings; this.actor = this; this._sessionStyle = null; @@ -844,11 +843,11 @@ var dtpSecondaryPanel = Utils.defineClass({ _setPanelMenu: function(settingName, propName, constr, container, isInit) { if (isInit) { - this._panelMenuSignalIds.push(this._dtpSettings.connect( + this._panelMenuSignalIds.push(Me.settings.connect( 'changed::' + settingName, () => this._setPanelMenu(settingName, propName, constr, container))); } - if (!this._dtpSettings.get_boolean(settingName)) { + if (!Me.settings.get_boolean(settingName)) { this._removePanelMenu(propName); } else if (!this.statusArea[propName]) { this.statusArea[propName] = new constr(); @@ -874,7 +873,7 @@ var dtpSecondaryPanel = Utils.defineClass({ _onDestroy: function() { Main.ctrlAltTabManager.removeGroup(this); - this._panelMenuSignalIds.forEach(id => this._dtpSettings.disconnect(id)); + this._panelMenuSignalIds.forEach(id => Me.settings.disconnect(id)); this._removePanelMenu('dateMenu'); this._removePanelMenu('aggregateMenu'); diff --git a/panelManager.js b/panelManager.js index 66948d1..a80a273 100755 --- a/panelManager.js +++ b/panelManager.js @@ -52,16 +52,14 @@ const WorkspacesView = imports.ui.workspacesView; var dtpPanelManager = Utils.defineClass({ Name: 'DashToPanel.PanelManager', - _init: function(settings) { - this._dtpSettings = settings; - Taskbar.dtpSettings = settings; - this.overview = new Overview.dtpOverview(settings); + _init: function() { + this.overview = new Overview.dtpOverview(); Main.overview.viewSelector.appDisplay._views.forEach(v => Utils.wrapActor(v.view._grid)); }, enable: function(reset) { - let dtpPrimaryIndex = this._dtpSettings.get_int('primary-monitor'); + let dtpPrimaryIndex = Me.settings.get_int('primary-monitor'); if(dtpPrimaryIndex < 0 || dtpPrimaryIndex >= Main.layoutManager.monitors.length) dtpPrimaryIndex = Main.layoutManager.primaryIndex; @@ -75,7 +73,7 @@ var dtpPanelManager = Utils.defineClass({ this.overview.enable(this.primaryPanel); - if (this._dtpSettings.get_boolean('multi-monitors')) { + if (Me.settings.get_boolean('multi-monitors')) { Main.layoutManager.monitors.forEach(monitor => { if (monitor == dtpPrimaryMonitor) return; @@ -83,7 +81,7 @@ var dtpPanelManager = Utils.defineClass({ let panelBox = new St.BoxLayout({ name: 'panelBox', vertical: true }); Main.layoutManager.addChrome(panelBox, { affectsStruts: true, trackFullscreen: true }); - let panel = new Panel.dtpSecondaryPanel(this._dtpSettings, monitor); + let panel = new Panel.dtpSecondaryPanel(Me.settings, monitor); panelBox.add(panel.actor); let panelWrapper = new Panel.dtpPanelWrapper(this, monitor, panel, panelBox, true); @@ -135,7 +133,7 @@ var dtpPanelManager = Utils.defineClass({ Main.layoutManager._updatePanelBarrier = (panel) => { let panelUpdates = panel ? [panel] : this.allPanels; - panelUpdates.forEach(p => newUpdatePanelBarrier.call(Main.layoutManager, p, this._dtpSettings)); + panelUpdates.forEach(p => newUpdatePanelBarrier.call(Main.layoutManager, p, Me.settings)); }; Main.layoutManager._updatePanelBarrier(); @@ -168,7 +166,7 @@ var dtpPanelManager = Utils.defineClass({ this._signalsHandler.add( [ - this._dtpSettings, + Me.settings, [ 'changed::primary-monitor', 'changed::multi-monitors', @@ -179,7 +177,7 @@ var dtpPanelManager = Utils.defineClass({ () => this._reset() ], [ - this._dtpSettings, + Me.settings, 'changed::intellihide-key-toggle-text', () => this._setKeyBindings(true) ], @@ -295,9 +293,9 @@ var dtpPanelManager = Utils.defineClass({ }, _getBoxPointerPreferredHeight: function(boxPointer, alloc, monitor) { - if (boxPointer._dtpInPanel && boxPointer.sourceActor && this._dtpSettings.get_boolean('intellihide')) { + if (boxPointer._dtpInPanel && boxPointer.sourceActor && Me.settings.get_boolean('intellihide')) { monitor = monitor || Main.layoutManager.findMonitorForActor(boxPointer.sourceActor); - let excess = alloc.natural_size + this._dtpSettings.get_int('panel-size') + 10 - monitor.height; // 10 is arbitrary + let excess = alloc.natural_size + Me.settings.get_int('panel-size') + 10 - monitor.height; // 10 is arbitrary if (excess > 0) { alloc.natural_size -= excess; @@ -347,7 +345,7 @@ var dtpPanelManager = Utils.defineClass({ Utils.removeKeybinding(k); if (enable) { - Utils.addKeybinding(k, this._dtpSettings, keys[k], Shell.ActionMode.NORMAL); + Utils.addKeybinding(k, Me.settings, keys[k], Shell.ActionMode.NORMAL); } }); }, @@ -441,7 +439,7 @@ function newViewSelectorAnimateIn(oldPage) { if (vs._activePage == vs._appsPage && oldPage == vs._workspacesPage) { // Restore opacity, in case we animated via _fadePageOut vs._activePage.opacity = 255; - let animate = this._dtpSettings.get_boolean('animate-show-apps'); + let animate = Me.settings.get_boolean('animate-show-apps'); if(animate) vs.appDisplay.animate(IconGrid.AnimationDirection.IN); } else { @@ -457,7 +455,7 @@ function newViewSelectorAnimateOut(page) { if (page == vs._appsPage && vs._activePage == vs._workspacesPage && !Main.overview.animationInProgress) { - let animate = this._dtpSettings.get_boolean('animate-show-apps'); + let animate = Me.settings.get_boolean('animate-show-apps'); if(animate) vs.appDisplay.animate(IconGrid.AnimationDirection.OUT, Lang.bind(this, function() { diff --git a/panelStyle.js b/panelStyle.js index 0c15fdd..ce67e9d 100644 --- a/panelStyle.js +++ b/panelStyle.js @@ -35,8 +35,8 @@ const Utils = Me.imports.utils; var dtpPanelStyle = Utils.defineClass({ Name: 'DashToPanel.PanelStyle', - _init: function(settings) { - this._dtpSettings = settings; + _init: function() { + }, enable : function(panel) { @@ -49,7 +49,7 @@ var dtpPanelStyle = Utils.defineClass({ disable: function () { for (let i = 0; i < this._dtpSettingsSignalIds.length; ++i) { - this._dtpSettings.disconnect(this._dtpSettingsSignalIds[i]); + Me.settings.disconnect(this._dtpSettingsSignalIds[i]); } this._removeStyles(); @@ -67,7 +67,7 @@ var dtpPanelStyle = Utils.defineClass({ this._dtpSettingsSignalIds = []; for(let i in configKeys) { - this._dtpSettingsSignalIds.push(this._dtpSettings.connect('changed::' + configKeys[i], Lang.bind(this, function () { + this._dtpSettingsSignalIds.push(Me.settings.connect('changed::' + configKeys[i], Lang.bind(this, function () { this._removeStyles(); this._applyStyles(); }))); @@ -77,7 +77,7 @@ var dtpPanelStyle = Utils.defineClass({ _applyStyles: function() { this._rightBoxOperations = []; - let trayPadding = this._dtpSettings.get_int('tray-padding'); + let trayPadding = Me.settings.get_int('tray-padding'); if(trayPadding >= 0) { let trayPaddingStyleLine = '-natural-hpadding: %dpx'.format(trayPadding); if (trayPadding < 6) { @@ -93,7 +93,7 @@ var dtpPanelStyle = Utils.defineClass({ this._rightBoxOperations.push(operation); } - let statusIconPadding = this._dtpSettings.get_int('status-icon-padding'); + let statusIconPadding = Me.settings.get_int('status-icon-padding'); if(statusIconPadding >= 0) { let statusIconPaddingStyleLine = 'padding-left: %dpx; padding-right: %dpx'.format(statusIconPadding, statusIconPadding) let operation = {}; @@ -106,7 +106,7 @@ var dtpPanelStyle = Utils.defineClass({ this._rightBoxOperations.push(operation); } - let trayContentSize = this._dtpSettings.get_int('tray-size'); + let trayContentSize = Me.settings.get_int('tray-size'); if(trayContentSize > 0) { let trayIconSizeStyleLine = 'icon-size: %dpx'.format(trayContentSize) let operation = {}; @@ -137,7 +137,7 @@ var dtpPanelStyle = Utils.defineClass({ this._leftBoxOperations = []; - let leftboxPadding = this._dtpSettings.get_int('leftbox-padding'); + let leftboxPadding = Me.settings.get_int('leftbox-padding'); if(leftboxPadding >= 0) { let leftboxPaddingStyleLine = '-natural-hpadding: %dpx'.format(leftboxPadding); if (leftboxPadding < 6) { @@ -153,7 +153,7 @@ var dtpPanelStyle = Utils.defineClass({ this._leftBoxOperations.push(operation); } - let leftboxContentSize = this._dtpSettings.get_int('leftbox-size'); + let leftboxContentSize = Me.settings.get_int('leftbox-size'); if(leftboxContentSize > 0) { let leftboxIconSizeStyleLine = 'icon-size: %dpx'.format(leftboxContentSize) let operation = {}; diff --git a/taskbar.js b/taskbar.js index 9a4ecae..5deffb0 100644 --- a/taskbar.js +++ b/taskbar.js @@ -51,10 +51,9 @@ const AppIcons = Me.imports.appIcons; var DASH_ANIMATION_TIME = Dash.DASH_ANIMATION_TIME / (Dash.DASH_ANIMATION_TIME > 1 ? 1000 : 1); var DASH_ITEM_HOVER_TIMEOUT = Dash.DASH_ITEM_HOVER_TIMEOUT; var MIN_ICON_SIZE = 4; -var dtpSettings; function getPosition() { - let position = dtpSettings.get_string('panel-position'); + let position = Me.settings.get_string('panel-position'); if (position == 'TOP') { return St.Side.TOP; @@ -194,7 +193,7 @@ var taskbar = Utils.defineClass({ this._scrollView.add_actor(this._box); // Create a wrapper around the real showAppsIcon in order to add a popupMenu. - this._showAppsIconWrapper = new AppIcons.ShowAppsIconWrapper(dtpSettings); + this._showAppsIconWrapper = new AppIcons.ShowAppsIconWrapper(); this._showAppsIconWrapper.connect('menu-state-changed', Lang.bind(this, function(showAppsIconWrapper, opened) { this._itemMenuStateChanged(showAppsIconWrapper, opened); })); @@ -224,10 +223,10 @@ var taskbar = Utils.defineClass({ coordinate: Clutter.BindCoordinate.HEIGHT })); - this.previewMenu = new WindowPreview.PreviewMenu(dtpSettings, panelWrapper); + this.previewMenu = new WindowPreview.PreviewMenu(panelWrapper); this.previewMenu.enable(); - if (!dtpSettings.get_boolean('show-show-apps-button')) + if (!Me.settings.get_boolean('show-show-apps-button')) this.hideShowAppsButton(); let rtl = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL; @@ -288,7 +287,7 @@ var taskbar = Utils.defineClass({ 'window-left-monitor' ], () => { - if (dtpSettings.get_boolean('isolate-monitors')) { + if (Me.settings.get_boolean('isolate-monitors')) { this._queueRedisplay(); } } @@ -315,17 +314,17 @@ var taskbar = Utils.defineClass({ Lang.bind(this, this._syncShowAppsButtonToggled) ], [ - dtpSettings, + Me.settings, 'changed::show-show-apps-button', Lang.bind(this, function() { - if (dtpSettings.get_boolean('show-show-apps-button')) + if (Me.settings.get_boolean('show-show-apps-button')) this.showShowAppsButton(); else this.hideShowAppsButton(); }) ], [ - dtpSettings, + Me.settings, [ 'changed::dot-size', 'changed::show-favorites', @@ -335,16 +334,16 @@ var taskbar = Utils.defineClass({ Lang.bind(this, this._redisplay) ], [ - dtpSettings, + Me.settings, 'changed::group-apps', Lang.bind(this, function() { - this.isGroupApps = dtpSettings.get_boolean('group-apps'); + this.isGroupApps = Me.settings.get_boolean('group-apps'); this._connectWorkspaceSignals(); this.resetAppIcons(); }) ], [ - dtpSettings, + Me.settings, [ 'changed::group-apps-use-launchers', 'changed::taskbar-locked' @@ -353,7 +352,7 @@ var taskbar = Utils.defineClass({ ] ); - this.isGroupApps = dtpSettings.get_boolean('group-apps'); + this.isGroupApps = Me.settings.get_boolean('group-apps'); this._connectWorkspaceSignals(); }, @@ -527,7 +526,6 @@ var taskbar = Utils.defineClass({ _createAppItem: function(app, window, isLauncher) { let appIcon = new AppIcons.taskbarAppIcon( - dtpSettings, { app: app, window: window, @@ -537,7 +535,7 @@ var taskbar = Utils.defineClass({ { setSizeManually: true, showLabel: false, - isDraggable: !dtpSettings.get_boolean('taskbar-locked'), + isDraggable: !Me.settings.get_boolean('taskbar-locked'), }, this.previewMenu ); @@ -689,8 +687,8 @@ var taskbar = Utils.defineClass({ }, _adjustIconSize: function() { - let panelSize = dtpSettings.get_int('panel-size'); - let availSize = panelSize - dtpSettings.get_int('appicon-padding') * 2; + let panelSize = Me.settings.get_int('panel-size'); + let availSize = panelSize - Me.settings.get_int('appicon-padding') * 2; let minIconSize = MIN_ICON_SIZE + panelSize % 2; if (availSize == this.iconSize) @@ -739,8 +737,8 @@ var taskbar = Utils.defineClass({ }, sortAppsCompareFunction: function(appA, appB) { - return getAppStableSequence(appA, dtpSettings, this.panelWrapper.monitor) - - getAppStableSequence(appB, dtpSettings, this.panelWrapper.monitor); + return getAppStableSequence(appA, this.panelWrapper.monitor) - + getAppStableSequence(appB, this.panelWrapper.monitor); }, getAppInfos: function() { @@ -752,7 +750,7 @@ var taskbar = Utils.defineClass({ // the current workspace (this check is done in AppIcons.getInterestingWindows) let runningApps = this._checkIfShowingRunningApps() ? this._getRunningApps().sort(this.sortAppsCompareFunction.bind(this)) : []; - if (!this.isGroupApps && dtpSettings.get_boolean('group-apps-use-launchers')) { + if (!this.isGroupApps && Me.settings.get_boolean('group-apps-use-launchers')) { return this._createAppInfos(favoriteApps, [], true) .concat(this._createAppInfos(runningApps) .filter(appInfo => appInfo.windows.length)); @@ -836,12 +834,12 @@ var taskbar = Utils.defineClass({ }, _checkIfShowingRunningApps: function() { - return dtpSettings.get_boolean('show-running-apps'); + return Me.settings.get_boolean('show-running-apps'); }, _checkIfShowingFavorites: function() { - return dtpSettings.get_boolean('show-favorites') && - (!this.panelWrapper.isSecondary || dtpSettings.get_boolean('show-favorites-all-monitors')); + return Me.settings.get_boolean('show-favorites') && + (!this.panelWrapper.isSecondary || Me.settings.get_boolean('show-favorites-all-monitors')); }, _getRunningApps: function() { @@ -864,7 +862,7 @@ var taskbar = Utils.defineClass({ return apps.map(app => ({ app: app, isLauncher: defaultIsLauncher || false, - windows: defaultWindows || AppIcons.getInterestingWindows(app, dtpSettings, this.panelWrapper.monitor) + windows: defaultWindows || AppIcons.getInterestingWindows(app, this.panelWrapper.monitor) .sort(sortWindowsCompareFunction) })); }, @@ -904,8 +902,8 @@ var taskbar = Utils.defineClass({ icon.updateNumberOverlay(); }); - if (dtpSettings.get_boolean('hot-keys') && - dtpSettings.get_string('hotkeys-overlay-combo') === 'ALWAYS') + if (Me.settings.get_boolean('hot-keys') && + Me.settings.get_string('hotkeys-overlay-combo') === 'ALWAYS') this.toggleNumberOverlay(true); }, @@ -986,7 +984,7 @@ var taskbar = Utils.defineClass({ let appIcons = this._getAppIcons(); let sourceIndex = appIcons.indexOf(source); - let usingLaunchers = !this.isGroupApps && dtpSettings.get_boolean('group-apps-use-launchers'); + let usingLaunchers = !this.isGroupApps && Me.settings.get_boolean('group-apps-use-launchers'); // dragging the icon to its original position if (this._dragInfo[0] === sourceIndex) { @@ -1005,7 +1003,7 @@ var taskbar = Utils.defineClass({ let interestingWindows = {}; let getAppWindows = app => { if (!interestingWindows[app]) { - interestingWindows[app] = AppIcons.getInterestingWindows(app, dtpSettings, this.panelWrapper.monitor); + interestingWindows[app] = AppIcons.getInterestingWindows(app, this.panelWrapper.monitor); } let appWindows = interestingWindows[app]; //prevents "reference to undefined property Symbol.toPrimitive" warning @@ -1057,7 +1055,7 @@ var taskbar = Utils.defineClass({ // status (due to the _syncShowAppsButtonToggled function below) and it // has already performed the desired action. - let animate = dtpSettings.get_boolean('animate-show-apps'); + let animate = Me.settings.get_boolean('animate-show-apps'); let selector = Main.overview.viewSelector; if (selector._showAppsButton.checked !== this.showAppsButton.checked) { @@ -1211,8 +1209,8 @@ var DragPlaceholderItem = Utils.defineClass({ }, }); -function getAppStableSequence(app, dtpSettings, monitor) { - let windows = AppIcons.getInterestingWindows(app, dtpSettings, monitor); +function getAppStableSequence(app, monitor) { + let windows = AppIcons.getInterestingWindows(app, monitor); return windows.reduce((prevWindow, window) => { return Math.min(prevWindow, getWindowStableSequence(window)); diff --git a/transparency.js b/transparency.js index 84a7d4c..536d234 100644 --- a/transparency.js +++ b/transparency.js @@ -31,7 +31,6 @@ var DynamicTransparency = Utils.defineClass({ _init: function(dtpPanel) { this._dtpPanel = dtpPanel; - this._dtpSettings = dtpPanel._dtpSettings; this._proximityManager = dtpPanel.panelManager.proximityManager; this._proximityWatchId = 0; this._windowOverlap = false; @@ -73,7 +72,7 @@ var DynamicTransparency = Utils.defineClass({ () => this._updateAlphaAndSet() ], [ - this._dtpSettings, + Me.settings, [ 'changed::trans-use-custom-bg', 'changed::trans-bg-color' @@ -81,7 +80,7 @@ var DynamicTransparency = Utils.defineClass({ () => this._updateColorAndSet() ], [ - this._dtpSettings, + Me.settings, [ 'changed::trans-use-custom-opacity', 'changed::trans-panel-opacity', @@ -92,7 +91,7 @@ var DynamicTransparency = Utils.defineClass({ () => this._updateAlphaAndSet() ], [ - this._dtpSettings, + Me.settings, [ 'changed::trans-use-custom-gradient', 'changed::trans-gradient-top-color', @@ -103,7 +102,7 @@ var DynamicTransparency = Utils.defineClass({ () => this._updateGradientAndSet() ], [ - this._dtpSettings, + Me.settings, [ 'changed::trans-dynamic-behavior', 'changed::trans-use-dynamic-opacity', @@ -112,7 +111,7 @@ var DynamicTransparency = Utils.defineClass({ () => this._updateProximityWatch() ], [ - this._dtpSettings, + Me.settings, 'changed::trans-dynamic-anim-time', () => this._updateAnimationDuration() ] @@ -122,11 +121,11 @@ var DynamicTransparency = Utils.defineClass({ _updateProximityWatch: function() { this._proximityManager.removeWatch(this._proximityWatchId); - if (this._dtpSettings.get_boolean('trans-use-dynamic-opacity')) { + if (Me.settings.get_boolean('trans-use-dynamic-opacity')) { this._proximityWatchId = this._proximityManager.createWatch( this._dtpPanel.panelBox, - Proximity.Mode[this._dtpSettings.get_string('trans-dynamic-behavior')], - 0, this._dtpSettings.get_int('trans-dynamic-distance'), + Proximity.Mode[Me.settings.get_string('trans-dynamic-behavior')], + 0, Me.settings.get_int('trans-dynamic-distance'), overlap => { this._windowOverlap = overlap; this._updateAlphaAndSet(); @@ -136,7 +135,7 @@ var DynamicTransparency = Utils.defineClass({ }, _updateAnimationDuration: function() { - this.animationDuration = (this._dtpSettings.get_int('trans-dynamic-anim-time') * 0.001) + 's;'; + this.animationDuration = (Me.settings.get_int('trans-dynamic-anim-time') * 0.001) + 's;'; }, _updateAllAndSet: function() { @@ -172,17 +171,17 @@ var DynamicTransparency = Utils.defineClass({ }, _updateColor: function(themeBackground) { - this.backgroundColorRgb = this._dtpSettings.get_boolean('trans-use-custom-bg') ? - this._dtpSettings.get_string('trans-bg-color') : + this.backgroundColorRgb = Me.settings.get_boolean('trans-use-custom-bg') ? + Me.settings.get_string('trans-bg-color') : (themeBackground || this._getThemeBackground()); }, _updateAlpha: function(themeBackground) { - if (this._windowOverlap && !Main.overview.visibleTarget && this._dtpSettings.get_boolean('trans-use-dynamic-opacity')) { - this.alpha = this._dtpSettings.get_double('trans-dynamic-anim-target'); + 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 { - this.alpha = this._dtpSettings.get_boolean('trans-use-custom-opacity') ? - this._dtpSettings.get_double('trans-panel-opacity') : + this.alpha = Me.settings.get_boolean('trans-use-custom-opacity') ? + Me.settings.get_double('trans-panel-opacity') : (themeBackground || this._getThemeBackground()).alpha * 0.003921569; // 1 / 255 = 0.003921569 } }, @@ -190,12 +189,12 @@ var DynamicTransparency = Utils.defineClass({ _updateGradient: function() { this._gradientStyle = ''; - if (this._dtpSettings.get_boolean('trans-use-custom-gradient')) { + if (Me.settings.get_boolean('trans-use-custom-gradient')) { this._gradientStyle += 'background-gradient-direction: vertical; ' + - 'background-gradient-start: ' + Utils.getrgbaColor(this._dtpSettings.get_string('trans-gradient-top-color'), - this._dtpSettings.get_double('trans-gradient-top-opacity')) + - 'background-gradient-end: ' + Utils.getrgbaColor(this._dtpSettings.get_string('trans-gradient-bottom-color'), - this._dtpSettings.get_double('trans-gradient-bottom-opacity')); + 'background-gradient-start: ' + Utils.getrgbaColor(Me.settings.get_string('trans-gradient-top-color'), + Me.settings.get_double('trans-gradient-top-opacity')) + + 'background-gradient-end: ' + Utils.getrgbaColor(Me.settings.get_string('trans-gradient-bottom-color'), + Me.settings.get_double('trans-gradient-bottom-opacity')); } }, diff --git a/windowPreview.js b/windowPreview.js index 5d4c204..826be3c 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -64,10 +64,9 @@ var PreviewMenu = Utils.defineClass({ Extends: St.Widget, Signals: { 'open-state-changed': {} }, - _init: function(dtpSettings, panelWrapper) { + _init: function(panelWrapper) { this.callParent('_init', { layout_manager: new Clutter.BinLayout() }); - this._dtpSettings = dtpSettings; this._panelWrapper = panelWrapper; this.currentAppIcon = null; this._focusedPreview = null; @@ -78,7 +77,7 @@ var PreviewMenu = Utils.defineClass({ this.isLeftOrRight = this._position == St.Side.LEFT || this._position == St.Side.RIGHT; this._translationProp = 'translation_' + (this.isLeftOrRight ? 'x' : 'y'); this._translationDirection = (this._position == St.Side.TOP || this._position == St.Side.LEFT ? -1 : 1); - this._translationOffset = Math.min(this._dtpSettings.get_int('panel-size'), MAX_TRANSLATION) * this._translationDirection; + this._translationOffset = Math.min(Me.settings.get_int('panel-size'), MAX_TRANSLATION) * this._translationDirection; this.menu = new St.Widget({ name: 'preview-menu', @@ -132,7 +131,7 @@ var PreviewMenu = Utils.defineClass({ () => this._updateClip() ], [ - this._dtpSettings, + Me.settings, [ 'changed::panel-size', 'changed::window-preview-size', @@ -159,7 +158,7 @@ var PreviewMenu = Utils.defineClass({ requestOpen: function(appIcon) { this._endOpenCloseTimeouts(); - this._timeoutsHandler.add([T1, this._dtpSettings.get_int('show-window-previews-timeout'), () => this.open(appIcon)]); + this._timeoutsHandler.add([T1, Me.settings.get_int('show-window-previews-timeout'), () => this.open(appIcon)]); }, requestClose: function() { @@ -242,9 +241,9 @@ var PreviewMenu = Utils.defineClass({ requestPeek: function(window) { this._timeoutsHandler.remove(T3); - if (this._dtpSettings.get_boolean('peek-mode')) { + if (Me.settings.get_boolean('peek-mode')) { if (this.peekInitialWorkspaceIndex < 0) { - this._timeoutsHandler.add([T3, this._dtpSettings.get_int('enter-peek-mode-timeout'), () => this._peek(window)]); + this._timeoutsHandler.add([T3, Me.settings.get_int('enter-peek-mode-timeout'), () => this._peek(window)]); } else { this._peek(window); } @@ -339,7 +338,7 @@ var PreviewMenu = Utils.defineClass({ }, _addCloseTimeout: function() { - this._timeoutsHandler.add([T2, this._dtpSettings.get_int('leave-timeout'), () => this.close()]); + this._timeoutsHandler.add([T2, Me.settings.get_int('leave-timeout'), () => this.close()]); }, _onHoverChanged: function() { @@ -384,22 +383,22 @@ var PreviewMenu = Utils.defineClass({ _refreshGlobals: function() { isLeftButtons = Meta.prefs_get_button_layout().left_buttons.indexOf(Meta.ButtonFunction.CLOSE) >= 0; - isTopHeader = this._dtpSettings.get_string('window-preview-title-position') == 'TOP'; + isTopHeader = Me.settings.get_string('window-preview-title-position') == 'TOP'; scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor; - headerHeight = this._dtpSettings.get_boolean('window-preview-show-title') ? HEADER_HEIGHT * scaleFactor : 0; - animationTime = this._dtpSettings.get_int('window-preview-animation-time') * .001; + headerHeight = Me.settings.get_boolean('window-preview-show-title') ? HEADER_HEIGHT * scaleFactor : 0; + animationTime = Me.settings.get_int('window-preview-animation-time') * .001; aspectRatio.x = { - size: this._dtpSettings.get_int('window-preview-aspect-ratio-x'), - fixed: this._dtpSettings.get_boolean('window-preview-fixed-x') + size: Me.settings.get_int('window-preview-aspect-ratio-x'), + fixed: Me.settings.get_boolean('window-preview-fixed-x') }; aspectRatio.y = { - size: this._dtpSettings.get_int('window-preview-aspect-ratio-y'), - fixed: this._dtpSettings.get_boolean('window-preview-fixed-y') + size: Me.settings.get_int('window-preview-aspect-ratio-y'), + fixed: Me.settings.get_boolean('window-preview-fixed-y') }; if (this._panelWrapper.dynamicTransparency) { - alphaBg = this._dtpSettings.get_boolean('preview-use-custom-opacity') ? - this._dtpSettings.get_int('preview-custom-opacity') * .01 : + alphaBg = Me.settings.get_boolean('preview-use-custom-opacity') ? + Me.settings.get_int('preview-custom-opacity') * .01 : this._panelWrapper.dynamicTransparency.alpha; } }, @@ -415,9 +414,9 @@ var PreviewMenu = Utils.defineClass({ _updateClip: function() { let x, y, w, h; let panelBoxTheme = this._panelWrapper.panelBox.get_theme_node(); - let panelSize = this._dtpSettings.get_int('panel-size') * scaleFactor; - let previewSize = (this._dtpSettings.get_int('window-preview-size') + - this._dtpSettings.get_int('window-preview-padding') * 2) * scaleFactor; + let panelSize = Me.settings.get_int('panel-size') * scaleFactor; + let previewSize = (Me.settings.get_int('window-preview-size') + + Me.settings.get_int('window-preview-padding') * 2) * scaleFactor; if (this.isLeftOrRight) { w = previewSize; @@ -447,7 +446,7 @@ var PreviewMenu = Utils.defineClass({ let sourceContentBox = sourceNode.get_content_box(this.currentAppIcon.actor.get_allocation_box()); let sourceAllocation = Shell.util_get_transformed_allocation(this.currentAppIcon.actor); let [previewsWidth, previewsHeight] = this._getPreviewsSize(); - let appIconMargin = this._dtpSettings.get_int('appicon-margin') / scaleFactor; + let appIconMargin = Me.settings.get_int('appicon-margin') / scaleFactor; let x = 0, y = 0; previewsWidth = Math.min(previewsWidth, this._panelWrapper.monitor.width); @@ -574,7 +573,7 @@ var PreviewMenu = Utils.defineClass({ _peek: function(window) { let currentWorkspace = Utils.getCurrentWorkspace(); let windowWorkspace = window.get_workspace(); - let focusWindow = () => this._focusMetaWindow(this._dtpSettings.get_int('peek-mode-opacity'), window); + let focusWindow = () => this._focusMetaWindow(Me.settings.get_int('peek-mode-opacity'), window); this._restorePeekedWindowStack(); this._peekedWindow = window; @@ -678,7 +677,7 @@ var Preview = Utils.defineClass({ this.cloneWidth = this.cloneHeight = 0; this._panelWrapper = previewMenu._panelWrapper; this._previewMenu = previewMenu; - this._padding = previewMenu._dtpSettings.get_int('window-preview-padding') * scaleFactor; + this._padding = Me.settings.get_int('window-preview-padding') * scaleFactor; this._previewDimensions = this._getPreviewDimensions(); this.animatingOut = false; @@ -849,7 +848,7 @@ var Preview = Utils.defineClass({ this._hideOrShowCloseButton(true); this.reactive = false; - if (!this._previewMenu._dtpSettings.get_boolean('group-apps')) { + if (!Me.settings.get_boolean('group-apps')) { this._previewMenu.close(); } }, @@ -860,7 +859,7 @@ var Preview = Utils.defineClass({ this.activate(); break; case 2: // Middle click - if (this._previewMenu._dtpSettings.get_boolean('preview-middle-click-close')) { + if (Me.settings.get_boolean('preview-middle-click-close')) { this._onCloseBtnClick(); } break; @@ -913,14 +912,14 @@ var Preview = Utils.defineClass({ let icon = this._previewMenu.getCurrentAppIcon().app.create_icon_texture(iconTextureSize); let workspaceIndex = ''; let workspaceStyle = null; - let commonTitleStyles = 'color: ' + this._previewMenu._dtpSettings.get_string('window-preview-title-font-color') + ';' + - 'font-size: ' + this._previewMenu._dtpSettings.get_int('window-preview-title-font-size') + 'px;' + - 'font-weight: ' + this._previewMenu._dtpSettings.get_string('window-preview-title-font-weight') + ';'; + let commonTitleStyles = 'color: ' + Me.settings.get_string('window-preview-title-font-color') + ';' + + 'font-size: ' + Me.settings.get_int('window-preview-title-font-size') + 'px;' + + 'font-weight: ' + Me.settings.get_string('window-preview-title-font-weight') + ';'; this._iconBin.destroy_all_children(); this._iconBin.add_child(icon); - if (!this._previewMenu._dtpSettings.get_boolean('isolate-workspaces')) { + if (!Me.settings.get_boolean('isolate-workspaces')) { workspaceIndex = (this.window.get_workspace().index() + 1).toString(); workspaceStyle = 'margin: 0 4px 0 ' + (isLeftButtons ? Math.round((headerHeight - icon.width) * .5) + 'px' : '0') + '; padding: 0 4px;' + 'border: 2px solid ' + this._getRgbaColor(FOCUSED_COLOR_OFFSET, .8) + 'border-radius: 2px;' + commonTitleStyles; @@ -1045,7 +1044,7 @@ var Preview = Utils.defineClass({ }, _getPreviewDimensions: function() { - let size = this._previewMenu._dtpSettings.get_int('window-preview-size') * scaleFactor; + let size = Me.settings.get_int('window-preview-size') * scaleFactor; let w, h; if (this._previewMenu.isLeftOrRight) {