From 84159f5df9aead75828fb61d8fcb51369105920c Mon Sep 17 00:00:00 2001 From: Philipp Unger Date: Sun, 13 Aug 2023 22:58:15 +0200 Subject: [PATCH] use exported settings --- appIcons.js | 193 ++++++++++++++++++++++++----------------------- intellihide.js | 33 ++++---- overview.js | 53 ++++++------- panel.js | 67 ++++++++-------- panelManager.js | 37 ++++----- panelStyle.js | 15 ++-- progress.js | 5 +- taskbar.js | 41 +++++----- transparency.js | 41 +++++----- windowPreview.js | 61 +++++++-------- 10 files changed, 278 insertions(+), 268 deletions(-) diff --git a/appIcons.js b/appIcons.js index adbdc9c..b0193cd 100644 --- a/appIcons.js +++ b/appIcons.js @@ -49,6 +49,7 @@ import * as Utils from './utils.js'; import * as PanelSettings from './panelSettings.js'; import * as Taskbar from './taskbar.js'; import * as Progress from './progress.js'; +import {SETTINGS, DESKTOPSETTINGS} from './extension.js'; import {gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; const Mainloop = imports.mainloop; @@ -146,7 +147,7 @@ var TaskbarAppIcon = GObject.registerClass({ this._dot.set_width(0); - this._isGroupApps = Me.settings.get_boolean('group-apps'); + this._isGroupApps = 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() }); @@ -203,7 +204,7 @@ var TaskbarAppIcon = GObject.registerClass({ this._stateChangedId = this.app.connect('windows-changed', this.onWindowsChanged.bind(this)); if (!this.window) { - if (Me.settings.get_boolean('isolate-monitors')) { + if (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)); } @@ -229,33 +230,33 @@ var TaskbarAppIcon = GObject.registerClass({ this._hoverChangeId = this.connect('notify::hover', () => this._onAppIconHoverChanged()); this._dtpSettingsSignalIds = [ - Me.settings.connect('changed::animate-appicon-hover', this._onAnimateAppiconHoverChanged.bind(this)), - Me.settings.connect('changed::dot-position', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::dot-size', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::dot-style-focused', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::dot-style-unfocused', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::dot-color-dominant', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::dot-color-override', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::dot-color-1', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::dot-color-2', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::dot-color-3', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::dot-color-4', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::dot-color-unfocused-different', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::dot-color-unfocused-1', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::dot-color-unfocused-2', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::dot-color-unfocused-3', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::dot-color-unfocused-4', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::focus-highlight', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::focus-highlight-dominant', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::focus-highlight-color', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::focus-highlight-opacity', this._settingsChangeRefresh.bind(this)), - Me.settings.connect('changed::group-apps-label-font-size', this._updateWindowTitleStyle.bind(this)), - Me.settings.connect('changed::group-apps-label-font-weight', this._updateWindowTitleStyle.bind(this)), - Me.settings.connect('changed::group-apps-label-font-color', this._updateWindowTitleStyle.bind(this)), - Me.settings.connect('changed::group-apps-label-font-color-minimized', this._updateWindowTitleStyle.bind(this)), - Me.settings.connect('changed::group-apps-label-max-width', this._updateWindowTitleStyle.bind(this)), - Me.settings.connect('changed::group-apps-use-fixed-width', this._updateWindowTitleStyle.bind(this)), - Me.settings.connect('changed::group-apps-underline-unfocused', this._settingsChangeRefresh.bind(this)) + SETTINGS.connect('changed::animate-appicon-hover', this._onAnimateAppiconHoverChanged.bind(this)), + SETTINGS.connect('changed::dot-position', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::dot-size', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::dot-style-focused', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::dot-style-unfocused', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::dot-color-dominant', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::dot-color-override', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::dot-color-1', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::dot-color-2', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::dot-color-3', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::dot-color-4', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::dot-color-unfocused-different', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::dot-color-unfocused-1', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::dot-color-unfocused-2', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::dot-color-unfocused-3', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::dot-color-unfocused-4', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::focus-highlight', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::focus-highlight-dominant', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::focus-highlight-color', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::focus-highlight-opacity', this._settingsChangeRefresh.bind(this)), + SETTINGS.connect('changed::group-apps-label-font-size', this._updateWindowTitleStyle.bind(this)), + SETTINGS.connect('changed::group-apps-label-font-weight', this._updateWindowTitleStyle.bind(this)), + SETTINGS.connect('changed::group-apps-label-font-color', this._updateWindowTitleStyle.bind(this)), + SETTINGS.connect('changed::group-apps-label-font-color-minimized', this._updateWindowTitleStyle.bind(this)), + SETTINGS.connect('changed::group-apps-label-max-width', this._updateWindowTitleStyle.bind(this)), + SETTINGS.connect('changed::group-apps-use-fixed-width', this._updateWindowTitleStyle.bind(this)), + SETTINGS.connect('changed::group-apps-underline-unfocused', this._settingsChangeRefresh.bind(this)) ] this._progressIndicator = new Progress.ProgressIndicator(this, panel.progressManager); @@ -293,8 +294,8 @@ var TaskbarAppIcon = GObject.registerClass({ } shouldShowTooltip() { - if (!Me.settings.get_boolean('show-tooltip') || - (!this.isLauncher && Me.settings.get_boolean("show-window-previews") && + if (!SETTINGS.get_boolean('show-tooltip') || + (!this.isLauncher && SETTINGS.get_boolean("show-window-previews") && this.getAppIconInterestingWindows().length > 0)) { return false; } else { @@ -305,7 +306,7 @@ var TaskbarAppIcon = GObject.registerClass({ } _onAppIconHoverChanged() { - if (!Me.settings.get_boolean('show-window-previews') || + if (!SETTINGS.get_boolean('show-window-previews') || (!this.window && !this._nWindows)) { return; } @@ -362,7 +363,7 @@ var TaskbarAppIcon = GObject.registerClass({ } for (let i = 0; i < this._dtpSettingsSignalIds.length; ++i) { - Me.settings.disconnect(this._dtpSettingsSignalIds[i]); + SETTINGS.disconnect(this._dtpSettingsSignalIds[i]); } } @@ -407,7 +408,7 @@ var TaskbarAppIcon = GObject.registerClass({ } _onAnimateAppiconHoverChanged() { - if (Me.settings.get_boolean('animate-appicon-hover')) { + if (SETTINGS.get_boolean('animate-appicon-hover')) { this._container.add_style_class_name('animate-appicon-hover'); // Workaround to prevent scaled icon from being ugly when it is animated on hover. @@ -439,7 +440,7 @@ var TaskbarAppIcon = GObject.registerClass({ } _onMouseScroll(actor, event) { - let scrollAction = Me.settings.get_string('scroll-icon-action'); + let scrollAction = SETTINGS.get_string('scroll-icon-action'); if (scrollAction === 'PASS_THROUGH') { return this.dtpPanel._onPanelMouseScroll(actor, event); @@ -450,7 +451,7 @@ var TaskbarAppIcon = GObject.registerClass({ let direction = Utils.getMouseScrollDirection(event); if (direction && !this._timeoutsHandler.getId(T2)) { - this._timeoutsHandler.add([T2, Me.settings.get_int('scroll-icon-delay'), () => {}]); + this._timeoutsHandler.add([T2, SETTINGS.get_int('scroll-icon-delay'), () => {}]); let windows = this.getAppIconInterestingWindows(); @@ -485,12 +486,12 @@ var TaskbarAppIcon = GObject.registerClass({ if (!this._dashItemContainer.animatingOut) // don't draw and trigger more animations if the icon is in the middle of // being removed from the panel - this._drawRunningIndicator(this._focusedDots, Me.settings.get_string('dot-style-focused'), true); + this._drawRunningIndicator(this._focusedDots, SETTINGS.get_string('dot-style-focused'), true); }); this._unfocusedDots.connect('repaint', () => { if (!this._dashItemContainer.animatingOut) - this._drawRunningIndicator(this._unfocusedDots, Me.settings.get_string('dot-style-unfocused'), false); + this._drawRunningIndicator(this._unfocusedDots, SETTINGS.get_string('dot-style-unfocused'), false); }); this._dotsContainer.add_child(this._unfocusedDots); @@ -507,11 +508,11 @@ var TaskbarAppIcon = GObject.registerClass({ } _resetDots() { - let position = Me.settings.get_string('dot-position'); + let position = SETTINGS.get_string('dot-position'); let isHorizontalDots = position == DOT_POSITION.TOP || position == DOT_POSITION.BOTTOM; let sizeProp = isHorizontalDots ? 'width' : 'height'; - let focusedDotStyle = Me.settings.get_string('dot-style-focused'); - let unfocusedDotStyle = Me.settings.get_string('dot-style-unfocused'); + let focusedDotStyle = SETTINGS.get_string('dot-style-focused'); + let unfocusedDotStyle = SETTINGS.get_string('dot-style-unfocused'); this._focusedIsWide = this._isWideDotStyle(focusedDotStyle); this._unfocusedIsWide = this._isWideDotStyle(unfocusedDotStyle); @@ -540,14 +541,14 @@ var TaskbarAppIcon = GObject.registerClass({ _updateWindowTitleStyle() { if (this._windowTitle) { - let useFixedWidth = Me.settings.get_boolean('group-apps-use-fixed-width'); - let fontWeight = Me.settings.get_string('group-apps-label-font-weight'); - let fontScale = Me.desktopSettings.get_double('text-scaling-factor'); + let useFixedWidth = SETTINGS.get_boolean('group-apps-use-fixed-width'); + let fontWeight = SETTINGS.get_string('group-apps-label-font-weight'); + let fontScale = DESKTOPSETTINGS.get_double('text-scaling-factor'); let fontColor = this.window.minimized ? - Me.settings.get_string('group-apps-label-font-color-minimized') : - Me.settings.get_string('group-apps-label-font-color'); + SETTINGS.get_string('group-apps-label-font-color-minimized') : + SETTINGS.get_string('group-apps-label-font-color'); let scaleFactor = Utils.getScaleFactor(); - let maxLabelWidth = Me.settings.get_int('group-apps-label-max-width') * scaleFactor; + let maxLabelWidth = SETTINGS.get_int('group-apps-label-max-width') * scaleFactor; let variableWidth = !useFixedWidth || this.dtpPanel.checkIfVertical() || this.dtpPanel.taskbar.fullScrollView; this._windowTitle[(maxLabelWidth > 0 ? 'show' : 'hide')](); @@ -556,7 +557,7 @@ var TaskbarAppIcon = GObject.registerClass({ this._windowTitle.clutter_text.natural_width = useFixedWidth ? maxLabelWidth : 0; this._windowTitle.clutter_text.natural_width_set = useFixedWidth; - this._windowTitle.set_style('font-size: ' + Me.settings.get_int('group-apps-label-font-size') * fontScale + 'px;' + + this._windowTitle.set_style('font-size: ' + SETTINGS.get_int('group-apps-label-font-size') * fontScale + 'px;' + 'font-weight: ' + fontWeight + ';' + (useFixedWidth ? '' : 'max-width: ' + maxLabelWidth + 'px;') + 'color: ' + fontColor); @@ -576,12 +577,12 @@ var TaskbarAppIcon = GObject.registerClass({ _setIconStyle(isFocused) { let inlineStyle = 'margin: 0;'; - if(Me.settings.get_boolean('focus-highlight') && + if(SETTINGS.get_boolean('focus-highlight') && this._checkIfFocusedApp() && !this.isLauncher && (!this.window || isFocused) && !this._isThemeProvidingIndicator() && this._checkIfMonitorHasFocus()) { - let focusedDotStyle = Me.settings.get_string('dot-style-focused'); - let pos = Me.settings.get_string('dot-position'); - let highlightMargin = this._focusedIsWide ? Me.settings.get_int('dot-size') : 0; + let focusedDotStyle = SETTINGS.get_string('dot-style-focused'); + let pos = SETTINGS.get_string('dot-position'); + let highlightMargin = this._focusedIsWide ? SETTINGS.get_int('dot-size') : 0; if(!this.window) { let containerWidth = this._dtpIconContainer.get_width() / Utils.getScaleFactor();; @@ -605,7 +606,7 @@ var TaskbarAppIcon = GObject.registerClass({ } let highlightColor = this._getFocusHighlightColor(); - inlineStyle += "background-color: " + cssHexTocssRgba(highlightColor, Me.settings.get_int('focus-highlight-opacity') * 0.01); + inlineStyle += "background-color: " + cssHexTocssRgba(highlightColor, SETTINGS.get_int('focus-highlight-opacity') * 0.01); } if(this._dotsContainer.get_style() != inlineStyle) { @@ -619,14 +620,14 @@ var TaskbarAppIcon = GObject.registerClass({ _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') || + (!SETTINGS.get_boolean('multi-monitors') || // only check same monitor index if multi window is enabled. + !SETTINGS.get_boolean('isolate-monitors') || global.display.focus_window.get_monitor() === this.dtpPanel.monitor.index); } _setAppIconPadding() { let padding = getIconPadding(this.dtpPanel.monitor.index); - let margin = Me.settings.get_int('appicon-margin'); + let margin = SETTINGS.get_int('appicon-margin'); this.set_style('padding:' + (this.dtpPanel.checkIfVertical() ? margin + 'px 0' : '0 ' + margin + 'px;')); this._iconContainer.set_style('padding: ' + padding + 'px;'); @@ -676,7 +677,7 @@ var TaskbarAppIcon = GObject.registerClass({ _onOverviewWindowDragEnd(windowTracker) { this._timeoutsHandler.add([T4, 0, () => { - if (Me.settings.get_boolean('isolate-workspaces')) + if (SETTINGS.get_boolean('isolate-workspaces')) this._updateWindows() this._displayProperIndicator() @@ -693,13 +694,13 @@ var TaskbarAppIcon = GObject.registerClass({ _displayProperIndicator() { let isFocused = this._isFocusedWindow(); - let position = Me.settings.get_string('dot-position'); + let position = SETTINGS.get_string('dot-position'); let isHorizontalDots = position == DOT_POSITION.TOP || position == DOT_POSITION.BOTTOM; this._setIconStyle(isFocused); if(!this._isGroupApps) { - if (this.window && (Me.settings.get_boolean('group-apps-underline-unfocused') || isFocused)) { + if (this.window && (SETTINGS.get_boolean('group-apps-underline-unfocused') || isFocused)) { let align = Clutter.ActorAlign[position == DOT_POSITION.TOP || position == DOT_POSITION.LEFT ? 'START' : 'END']; this._focusedDots.set_size(0, 0); @@ -748,7 +749,7 @@ var TaskbarAppIcon = GObject.registerClass({ // 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) - let animate = Me.settings.get_boolean('animate-app-switch') && + let animate = SETTINGS.get_boolean('animate-app-switch') && ((this._focusedIsWide != this._unfocusedIsWide) || (this._focusedDots[sizeProp] != newUnfocusedDotsSize || this._unfocusedDots[sizeProp] != newFocusedDotsSize)) let duration = animate ? Taskbar.DASH_ANIMATION_TIME : 0.001; @@ -830,9 +831,9 @@ var TaskbarAppIcon = GObject.registerClass({ if (button && button == 2 ) { if (modifiers & Clutter.ModifierType.SHIFT_MASK) - buttonAction = Me.settings.get_string('shift-middle-click-action'); + buttonAction = SETTINGS.get_string('shift-middle-click-action'); else - buttonAction = Me.settings.get_string('middle-click-action'); + buttonAction = SETTINGS.get_string('middle-click-action'); } else if (button && button == 1) { let now = global.get_current_time() @@ -841,12 +842,12 @@ var TaskbarAppIcon = GObject.registerClass({ this.lastClick = now if (modifiers & Clutter.ModifierType.SHIFT_MASK) - buttonAction = Me.settings.get_string('shift-click-action'); + buttonAction = SETTINGS.get_string('shift-click-action'); else - buttonAction = Me.settings.get_string('click-action'); + buttonAction = SETTINGS.get_string('click-action'); } - let closePreview = () => this._previewMenu.close(Me.settings.get_boolean('window-preview-hide-immediate-click')); + let closePreview = () => this._previewMenu.close(SETTINGS.get_boolean('window-preview-hide-immediate-click')); let appCount = this.getAppIconInterestingWindows().length; let previewedAppIcon = this._previewMenu.getCurrentAppIcon(); @@ -989,7 +990,7 @@ var TaskbarAppIcon = GObject.registerClass({ } _launchNewInstance(ctrlPressed) { - let maybeAnimate = () => Me.settings.get_boolean('animate-window-launch') && this.animateLaunch() + let maybeAnimate = () => SETTINGS.get_boolean('animate-window-launch') && this.animateLaunch() if ((ctrlPressed || this.app.state == Shell.AppState.RUNNING) && this.app.can_open_new_window()) { @@ -1032,14 +1033,14 @@ var TaskbarAppIcon = GObject.registerClass({ } _getRunningIndicatorSize() { - return Me.settings.get_int('dot-size') * Utils.getScaleFactor(); + return SETTINGS.get_int('dot-size') * Utils.getScaleFactor(); } _getRunningIndicatorColor(isFocused) { let color; const fallbackColor = new Clutter.Color({ red: 82, green: 148, blue: 226, alpha: 255 }); - if (Me.settings.get_boolean('dot-color-dominant')) { + if (SETTINGS.get_boolean('dot-color-dominant')) { let dce = new Utils.DominantColorExtractor(this.app); let palette = dce._getColorPalette(); if (palette) { @@ -1051,13 +1052,13 @@ var TaskbarAppIcon = GObject.registerClass({ // theme didn't provide one, use a default if(color.alpha == 0) color = fallbackColor; } - } else if(Me.settings.get_boolean('dot-color-override')) { + } else if(SETTINGS.get_boolean('dot-color-override')) { let dotColorSettingPrefix = 'dot-color-'; - if(!isFocused && Me.settings.get_boolean('dot-color-unfocused-different')) + if(!isFocused && SETTINGS.get_boolean('dot-color-unfocused-different')) dotColorSettingPrefix = 'dot-color-unfocused-'; - color = Clutter.color_from_string(Me.settings.get_string(dotColorSettingPrefix + (this._getRunningIndicatorCount() || 1) ))[1]; + color = Clutter.color_from_string(SETTINGS.get_string(dotColorSettingPrefix + (this._getRunningIndicatorCount() || 1) ))[1]; } else { // Re-use the style - background color, and border width and color - // of the default dot @@ -1072,12 +1073,12 @@ var TaskbarAppIcon = GObject.registerClass({ } _getFocusHighlightColor() { - if (Me.settings.get_boolean('focus-highlight-dominant')) { + if (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'); + return SETTINGS.get_string('focus-highlight-color'); } _drawRunningIndicator(area, type, isFocused) { @@ -1087,7 +1088,7 @@ var TaskbarAppIcon = GObject.registerClass({ return; } - let position = Me.settings.get_string('dot-position'); + let position = SETTINGS.get_string('dot-position'); let isHorizontalDots = position == DOT_POSITION.TOP || position == DOT_POSITION.BOTTOM; let bodyColor = this._getRunningIndicatorColor(isFocused); let [areaWidth, areaHeight] = area.get_surface_size(); @@ -1401,13 +1402,13 @@ function getInterestingWindows(app, monitor, isolateMonitors) { // 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 (Me.settings.get_boolean('isolate-workspaces')) + if (SETTINGS.get_boolean('isolate-workspaces')) windows = windows.filter(function(w) { return w.get_workspace() && w.get_workspace() == Utils.getCurrentWorkspace(); }); - if (monitor && Me.settings.get_boolean('multi-monitors') && (isolateMonitors || Me.settings.get_boolean('isolate-monitors'))) { + if (monitor && SETTINGS.get_boolean('multi-monitors') && (isolateMonitors || SETTINGS.get_boolean('isolate-monitors'))) { windows = windows.filter(function(w) { return w.get_monitor() == monitor.index; }); @@ -1426,8 +1427,8 @@ function cssHexTocssRgba(cssHex, opacity) { } function getIconPadding(monitorIndex) { - let panelSize = PanelSettings.getPanelSize(Me.settings, monitorIndex); - let padding = Me.settings.get_int('appicon-padding'); + let panelSize = PanelSettings.getPanelSize(SETTINGS, monitorIndex); + let padding = SETTINGS.get_int('appicon-padding'); let availSize = panelSize - Taskbar.MIN_ICON_SIZE - panelSize % 2; if (padding * 2 > availSize) { @@ -1455,7 +1456,7 @@ function getIconPadding(monitorIndex) { this._showSingleWindows = true; // Remove "Show Details" menu item - if(!Me.settings.get_boolean('secondarymenu-contains-showdetails')) { + if(!SETTINGS.get_boolean('secondarymenu-contains-showdetails')) { let existingMenuItems = this._getMenuItems(); for (let i = 0; i < existingMenuItems.length; i++) { let item = existingMenuItems[i]; @@ -1617,7 +1618,7 @@ function ItemShowLabel() { this.realShowAppsIcon._dtpPanel = dtpPanel; Taskbar.extendDashItemContainer(this.realShowAppsIcon); - let customIconPath = Me.settings.get_string('show-apps-icon-file'); + let customIconPath = SETTINGS.get_string('show-apps-icon-file'); this.realShowAppsIcon.icon.createIcon = function(size) { this._iconActor = new St.Icon({ icon_name: 'view-app-grid-symbolic', @@ -1632,13 +1633,13 @@ function ItemShowLabel() { return this._iconActor; }; - this._changedShowAppsIconId = Me.settings.connect('changed::show-apps-icon-file', () => { - customIconPath = Me.settings.get_string('show-apps-icon-file'); + this._changedShowAppsIconId = SETTINGS.connect('changed::show-apps-icon-file', () => { + customIconPath = SETTINGS.get_string('show-apps-icon-file'); this.realShowAppsIcon.icon._createIconTexture(this.realShowAppsIcon.icon.iconSize); }); - this._changedAppIconPaddingId = Me.settings.connect('changed::appicon-padding', () => this.setShowAppsPadding()); - this._changedAppIconSidePaddingId = Me.settings.connect('changed::show-apps-icon-side-padding', () => this.setShowAppsPadding()); + this._changedAppIconPaddingId = SETTINGS.connect('changed::appicon-padding', () => this.setShowAppsPadding()); + this._changedAppIconSidePaddingId = SETTINGS.connect('changed::show-apps-icon-side-padding', () => this.setShowAppsPadding()); this.setShowAppsPadding(); } @@ -1674,7 +1675,7 @@ function ItemShowLabel() { setShowAppsPadding() { let padding = getIconPadding(this.realShowAppsIcon._dtpPanel.monitor.index); - let sidePadding = Me.settings.get_int('show-apps-icon-side-padding'); + let sidePadding = 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;'); @@ -1718,14 +1719,14 @@ function ItemShowLabel() { } shouldShowTooltip() { - return Me.settings.get_boolean('show-tooltip') && + return SETTINGS.get_boolean('show-tooltip') && (this.actor.hover && (!this._menu || !this._menu.isOpen)); } destroy() { - Me.settings.disconnect(this._changedShowAppsIconId); - Me.settings.disconnect(this._changedAppIconSidePaddingId); - Me.settings.disconnect(this._changedAppIconPaddingId); + SETTINGS.disconnect(this._changedShowAppsIconId); + SETTINGS.disconnect(this._changedAppIconSidePaddingId); + SETTINGS.disconnect(this._changedAppIconPaddingId); this.realShowAppsIcon.destroy(); } @@ -1777,8 +1778,8 @@ var MyShowAppsIconMenu = class extends PopupMenu.PopupMenu { }); this._appendList( - Me.settings.get_strv('show-apps-button-context-menu-commands'), - Me.settings.get_strv('show-apps-button-context-menu-titles') + SETTINGS.get_strv('show-apps-button-context-menu-commands'), + SETTINGS.get_strv('show-apps-button-context-menu-titles') ) this._appendSeparator(); @@ -1810,15 +1811,15 @@ var MyShowAppsIconMenu = class extends PopupMenu.PopupMenu { }); this._appendList( - Me.settings.get_strv('panel-context-menu-commands'), - Me.settings.get_strv('panel-context-menu-titles') + SETTINGS.get_strv('panel-context-menu-commands'), + SETTINGS.get_strv('panel-context-menu-titles') ) this._appendSeparator(); - let lockTaskbarMenuItem = this._appendMenuItem(Me.settings.get_boolean('taskbar-locked') ? _('Unlock taskbar') : _('Lock taskbar')); + let lockTaskbarMenuItem = this._appendMenuItem(SETTINGS.get_boolean('taskbar-locked') ? _('Unlock taskbar') : _('Lock taskbar')); lockTaskbarMenuItem.connect('activate', () => { - Me.settings.set_boolean('taskbar-locked', !Me.settings.get_boolean('taskbar-locked')); + SETTINGS.set_boolean('taskbar-locked', !SETTINGS.get_boolean('taskbar-locked')); }); let settingsMenuItem = this._appendMenuItem(_('Dash to Panel Settings')); @@ -1877,7 +1878,7 @@ var MyShowAppsIconMenu = class extends PopupMenu.PopupMenu { var getIconContainerStyle = function(isVertical) { let style = 'padding: '; - if (Me.settings.get_boolean('group-apps')) { + if (SETTINGS.get_boolean('group-apps')) { style += (isVertical ? '0;' : '0 ' + DEFAULT_PADDING_SIZE + 'px;'); } else { style += (isVertical ? '' : '0 ') + DEFAULT_PADDING_SIZE + 'px;'; diff --git a/intellihide.js b/intellihide.js index d2ba8b3..6979ffe 100644 --- a/intellihide.js +++ b/intellihide.js @@ -29,6 +29,7 @@ import * as PointerWatcher from 'resource:///org/gnome/shell/ui/pointerWatcher.j import * as Panel from './panel.js'; import * as Proximity from './proximity.js'; import * as Utils from './utils.js'; +import {SETTINGS} from './extension.js'; //timeout intervals const CHECK_POINTER_MS = 200; @@ -62,8 +63,8 @@ var Intellihide = class { this._signalsHandler = new Utils.GlobalSignalsHandler(); this._timeoutsHandler = new Utils.TimeoutsHandler(); - this._intellihideChangedId = Me.settings.connect('changed::intellihide', () => this._changeEnabledStatus()); - this._intellihideOnlySecondaryChangedId = Me.settings.connect('changed::intellihide-only-secondary', () => this._changeEnabledStatus()); + this._intellihideChangedId = SETTINGS.connect('changed::intellihide', () => this._changeEnabledStatus()); + this._intellihideOnlySecondaryChangedId = SETTINGS.connect('changed::intellihide-only-secondary', () => this._changeEnabledStatus()); this.enabled = false; this._changeEnabledStatus(); @@ -84,11 +85,11 @@ var Intellihide = class { this._setTrackPanel(true); this._bindGeneralSignals(); - if (Me.settings.get_boolean('intellihide-hide-from-windows')) { + if (SETTINGS.get_boolean('intellihide-hide-from-windows')) { this._proximityWatchId = this._proximityManager.createWatch( this._panelBox.get_parent(), this._dtpPanel.monitor.index, - Proximity.Mode[Me.settings.get_string('intellihide-behaviour')], + Proximity.Mode[SETTINGS.get_string('intellihide-behaviour')], 0, 0, overlap => { this._windowOverlap = overlap; @@ -119,8 +120,8 @@ var Intellihide = class { } destroy() { - Me.settings.disconnect(this._intellihideChangedId); - Me.settings.disconnect(this._intellihideOnlySecondaryChangedId); + SETTINGS.disconnect(this._intellihideChangedId); + SETTINGS.disconnect(this._intellihideOnlySecondaryChangedId); if (this.enabled) { this.disable(); @@ -153,8 +154,8 @@ var Intellihide = class { } _changeEnabledStatus() { - let intellihide = Me.settings.get_boolean('intellihide'); - let onlySecondary = Me.settings.get_boolean('intellihide-only-secondary'); + let intellihide = SETTINGS.get_boolean('intellihide'); + let onlySecondary = SETTINGS.get_boolean('intellihide-only-secondary'); let enabled = intellihide && !(this._dtpPanel.isPrimary && onlySecondary); if (this.enabled !== enabled) { @@ -173,7 +174,7 @@ var Intellihide = class { } ], [ - Me.settings, + SETTINGS, [ 'changed::intellihide-use-pressure', 'changed::intellihide-hide-from-windows', @@ -231,11 +232,11 @@ var Intellihide = class { } _setRevealMechanism() { - if (global.display.supports_extended_barriers() && Me.settings.get_boolean('intellihide-use-pressure')) { + if (global.display.supports_extended_barriers() && SETTINGS.get_boolean('intellihide-use-pressure')) { this._edgeBarrier = this._createBarrier(); this._pressureBarrier = new Layout.PressureBarrier( - Me.settings.get_int('intellihide-pressure-threshold'), - Me.settings.get_int('intellihide-pressure-time'), + SETTINGS.get_int('intellihide-pressure-threshold'), + SETTINGS.get_int('intellihide-pressure-time'), Shell.ActionMode.NORMAL ); this._pressureBarrier.addBarrier(this._edgeBarrier); @@ -331,13 +332,13 @@ var Intellihide = class { //the user is trying to reveal the panel if (this._monitor.inFullscreen && !mouseBtnIsPressed) { - return Me.settings.get_boolean('intellihide-show-in-fullscreen'); + return SETTINGS.get_boolean('intellihide-show-in-fullscreen'); } return !mouseBtnIsPressed; } - if (!Me.settings.get_boolean('intellihide-hide-from-windows')) { + if (!SETTINGS.get_boolean('intellihide-hide-from-windows')) { return this._panelBox.hover; } @@ -405,9 +406,9 @@ var Intellihide = class { //when entering/leaving the overview, use its animation time instead of the one from the settings time: Main.overview.visible ? SIDE_CONTROLS_ANIMATION_TIME : - Me.settings.get_int('intellihide-animation-time') * 0.001, + 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 ? Me.settings.get_int('intellihide-close-delay') * 0.001 : 0, + delay: destination != 0 && this._hoveredOut ? SETTINGS.get_int('intellihide-close-delay') * 0.001 : 0, transition: 'easeOutQuad', onComplete: () => { this._panelBox.visible = !destination; diff --git a/overview.js b/overview.js index 59664f4..d38dc89 100644 --- a/overview.js +++ b/overview.js @@ -30,6 +30,7 @@ import St from 'gi://St'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import * as Workspace from 'resource:///org/gnome/shell/ui/workspace.js'; import { WindowPreview } from 'resource:///org/gnome/shell/ui/windowPreview.js'; +import {SETTINGS} from './extension.js'; import Meta from 'gi://Meta'; @@ -67,7 +68,7 @@ var Overview = class { this._adaptAlloc(true); this._signalsHandler.add([ - Me.settings, + SETTINGS, [ 'changed::stockgs-keep-dash', 'changed::panel-sizes' @@ -92,7 +93,7 @@ var Overview = class { _toggleDash(visible) { if (visible === undefined) { - visible = Me.settings.get_boolean('stockgs-keep-dash'); + visible = SETTINGS.get_boolean('stockgs-keep-dash'); } let visibilityFunc = visible ? 'show' : 'hide'; @@ -183,19 +184,19 @@ var Overview = class { } this._signalsHandler.add([ - Me.settings, + SETTINGS, 'changed::isolate-workspaces', () => { this._panel.panelManager.allPanels.forEach(p => p.taskbar.resetAppIcons()); - if (Me.settings.get_boolean('isolate-workspaces')) + if (SETTINGS.get_boolean('isolate-workspaces')) enable(); else disable(); } ]); - if (Me.settings.get_boolean('isolate-workspaces')) + if (SETTINGS.get_boolean('isolate-workspaces')) enable(); } @@ -219,7 +220,7 @@ var Overview = class { let seenAppCount = seenApps[appIcon.app]; let windowCount = appIcon.window || appIcon._hotkeysCycle ? seenAppCount : appIcon._nWindows; - if (Me.settings.get_boolean('shortcut-previews') && windowCount > 1 && + if (SETTINGS.get_boolean('shortcut-previews') && windowCount > 1 && !(modifiers & ~(Clutter.ModifierType.MOD1_MASK | Clutter.ModifierType.SUPER_MASK))) { //ignore the alt (MOD1_MASK) and super key (SUPER_MASK) if (this._hotkeyPreviewCycleInfo && this._hotkeyPreviewCycleInfo.appIcon != appIcon) { this._endHotkeyPreviewCycle(); @@ -273,14 +274,14 @@ var Overview = class { _optionalHotKeys() { this._hotKeysEnabled = false; - if (Me.settings.get_boolean('hot-keys')) + if (SETTINGS.get_boolean('hot-keys')) this._enableHotKeys(); this._signalsHandler.add([ - Me.settings, + SETTINGS, 'changed::hot-keys', () => { - if (Me.settings.get_boolean('hot-keys')) + if (SETTINGS.get_boolean('hot-keys')) this._enableHotKeys(); else this._disableHotKeys(); @@ -305,12 +306,12 @@ var Overview = class { } // Setup keyboard bindings for taskbar elements - let shortcutNumKeys = Me.settings.get_string('shortcut-num-keys'); + let shortcutNumKeys = SETTINGS.get_string('shortcut-num-keys'); let bothNumKeys = shortcutNumKeys == 'BOTH'; let keys = []; let prefixModifiers = Clutter.ModifierType.SUPER_MASK - if (Me.settings.get_string('hotkey-prefix-text') == 'SuperAlt') + if (SETTINGS.get_string('hotkey-prefix-text') == 'SuperAlt') prefixModifiers |= Clutter.ModifierType.MOD1_MASK if (bothNumKeys || shortcutNumKeys == 'NUM_ROW') { @@ -332,13 +333,13 @@ var Overview = class { for (let i = 0; i < this._numHotkeys; i++) { let appNum = i; - Utils.addKeybinding(key + (i + 1), Me.settings, () => this._activateApp(appNum, modifiers)); + Utils.addKeybinding(key + (i + 1), SETTINGS, () => this._activateApp(appNum, modifiers)); } }, this); this._hotKeysEnabled = true; - if (Me.settings.get_string('hotkeys-overlay-combo') === 'ALWAYS') + if (SETTINGS.get_string('hotkeys-overlay-combo') === 'ALWAYS') this.taskbar.toggleNumberOverlay(true); } @@ -369,38 +370,38 @@ var Overview = class { _optionalNumberOverlay() { // Enable extra shortcut - if (Me.settings.get_boolean('hot-keys')) + if (SETTINGS.get_boolean('hot-keys')) this._enableExtraShortcut(); this._signalsHandler.add([ - Me.settings, + SETTINGS, 'changed::hot-keys', this._checkHotkeysOptions.bind(this) ], [ - Me.settings, + SETTINGS, 'changed::hotkeys-overlay-combo', () => { - if (Me.settings.get_boolean('hot-keys') && Me.settings.get_string('hotkeys-overlay-combo') === 'ALWAYS') + if (SETTINGS.get_boolean('hot-keys') && SETTINGS.get_string('hotkeys-overlay-combo') === 'ALWAYS') this.taskbar.toggleNumberOverlay(true); else this.taskbar.toggleNumberOverlay(false); } ], [ - Me.settings, + SETTINGS, 'changed::shortcut-num-keys', () => this._resetHotkeys() ]); } _checkHotkeysOptions() { - if (Me.settings.get_boolean('hot-keys')) + if (SETTINGS.get_boolean('hot-keys')) this._enableExtraShortcut(); else this._disableExtraShortcut(); } _enableExtraShortcut() { - Utils.addKeybinding('shortcut', Me.settings, () => this._showOverlay(true)); + Utils.addKeybinding('shortcut', SETTINGS, () => this._showOverlay(true)); } _disableExtraShortcut() { @@ -414,7 +415,7 @@ var Overview = class { } // Restart the counting if the shortcut is pressed again - let hotkey_option = Me.settings.get_string('hotkeys-overlay-combo'); + let hotkey_option = SETTINGS.get_string('hotkeys-overlay-combo'); if (hotkey_option === 'NEVER') return; @@ -424,10 +425,10 @@ var Overview = class { this._panel.intellihide.revealAndHold(Intellihide.Hold.TEMPORARY); - let timeout = Me.settings.get_int('overlay-timeout'); + let timeout = SETTINGS.get_int('overlay-timeout'); if (overlayFromShortcut) { - timeout = Me.settings.get_int('shortcut-timeout'); + timeout = SETTINGS.get_int('shortcut-timeout'); } // Hide the overlay/dock after the timeout @@ -442,14 +443,14 @@ var Overview = class { _optionalClickToExit() { this._clickToExitEnabled = false; - if (Me.settings.get_boolean('overview-click-to-exit')) + if (SETTINGS.get_boolean('overview-click-to-exit')) this._enableClickToExit(); this._signalsHandler.add([ - Me.settings, + SETTINGS, 'changed::overview-click-to-exit', () => { - if (Me.settings.get_boolean('overview-click-to-exit')) + if (SETTINGS.get_boolean('overview-click-to-exit')) this._enableClickToExit(); else this._disableClickToExit(); diff --git a/panel.js b/panel.js index b59f190..d1be58b 100644 --- a/panel.js +++ b/panel.js @@ -57,6 +57,7 @@ import * as Progress from './progress.js'; import * as Intellihide from './intellihide.js'; import * as Transparency from './transparency.js'; +import {SETTINGS, DESKTOPSETTINGS} from './extension.js'; import {gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; const Mainloop = imports.mainloop; @@ -91,7 +92,7 @@ var Panel = GObject.registerClass({ // so in this case use isPrimary to get the panel on the primary dtp monitor, which // might be different from the system's primary monitor. this.isStandalone = isStandalone; - this.isPrimary = !isStandalone || (Me.settings.get_boolean('stockgs-keep-top-panel') && + this.isPrimary = !isStandalone || (SETTINGS.get_boolean('stockgs-keep-top-panel') && monitor == panelManager.dtpPrimaryMonitor); this._sessionStyle = null; @@ -206,7 +207,7 @@ var Panel = GObject.registerClass({ this.menuManager._oldChangeMenu = this.menuManager._changeMenu; this.menuManager._changeMenu = (menu) => { - if (!Me.settings.get_boolean('stockgs-panelbtn-click-only')) { + if (!SETTINGS.get_boolean('stockgs-panelbtn-click-only')) { this.menuManager._oldChangeMenu(menu); } }; @@ -217,14 +218,14 @@ var Panel = GObject.registerClass({ this.panel.add_child(this.taskbar.actor); - this._setAppmenuVisible(Me.settings.get_boolean('show-appmenu')); + this._setAppmenuVisible(SETTINGS.get_boolean('show-appmenu')); this._setShowDesktopButton(true); this._setAllocationMap(); this.panel.add_style_class_name('dashtopanelMainPanel ' + this.getOrientation()); - this._timeoutsHandler.add([T2, Me.settings.get_int('intellihide-enable-start-delay'), () => this.intellihide = new Intellihide.Intellihide(this)]); + this._timeoutsHandler.add([T2, SETTINGS.get_int('intellihide-enable-start-delay'), () => this.intellihide = new Intellihide.Intellihide(this)]); this._signalsHandler.add( // this is to catch changes to the theme or window scale factor @@ -412,7 +413,7 @@ var Panel = GObject.registerClass({ } getPosition() { - let position = PanelSettings.getPanelPosition(Me.settings, this.monitor.index); + let position = PanelSettings.getPanelPosition(SETTINGS, this.monitor.index); if (position == Pos.TOP) { return St.Side.TOP; @@ -499,7 +500,7 @@ var Panel = GObject.registerClass({ this._signalsHandler.add( [ - Me.settings, + SETTINGS, [ 'changed::panel-sizes', 'changed::group-apps' @@ -507,7 +508,7 @@ var Panel = GObject.registerClass({ () => this._resetGeometry() ], [ - Me.settings, + SETTINGS, [ 'changed::appicon-margin', 'changed::appicon-padding' @@ -515,12 +516,12 @@ var Panel = GObject.registerClass({ () => this.taskbar.resetAppIcons() ], [ - Me.settings, + SETTINGS, 'changed::show-appmenu', - () => this._setAppmenuVisible(Me.settings.get_boolean('show-appmenu')) + () => this._setAppmenuVisible(SETTINGS.get_boolean('show-appmenu')) ], [ - Me.settings, + SETTINGS, [ 'changed::showdesktop-button-width', 'changed::trans-use-custom-bg', @@ -531,7 +532,7 @@ var Panel = GObject.registerClass({ () => this._setShowDesktopButtonStyle() ], [ - Me.desktopSettings, + DESKTOPSETTINGS, 'changed::clock-format', () => { this._clockFormat = null; @@ -542,19 +543,19 @@ var Panel = GObject.registerClass({ } ], [ - Me.settings, + SETTINGS, 'changed::progress-show-bar', () => this._initProgressManager() ], [ - Me.settings, + SETTINGS, 'changed::progress-show-count', () => this._initProgressManager() ] ); if (isVertical) { - this._signalsHandler.add([Me.settings, 'changed::group-apps-label-max-width', () => this._resetGeometry()]); + this._signalsHandler.add([SETTINGS, 'changed::group-apps-label-max-width', () => this._resetGeometry()]); } } @@ -633,24 +634,24 @@ var Panel = GObject.registerClass({ let topPadding = panelBoxTheme.get_padding(St.Side.TOP); let tbPadding = topPadding + panelBoxTheme.get_padding(St.Side.BOTTOM); let position = this.getPosition(); - let length = PanelSettings.getPanelLength(Me.settings, this.monitor.index) / 100; - let anchor = PanelSettings.getPanelAnchor(Me.settings, this.monitor.index); + let length = PanelSettings.getPanelLength(SETTINGS, this.monitor.index) / 100; + let anchor = PanelSettings.getPanelAnchor(SETTINGS, this.monitor.index); let anchorPlaceOnMonitor = 0; let gsTopPanelOffset = 0; let x = 0, y = 0; let w = 0, h = 0; - const panelSize = PanelSettings.getPanelSize(Me.settings, this.monitor.index); + const panelSize = PanelSettings.getPanelSize(SETTINGS, this.monitor.index); this.dtpSize = panelSize * scaleFactor; - if (Me.settings.get_boolean('stockgs-keep-top-panel') && Main.layoutManager.primaryMonitor == this.monitor) { + if (SETTINGS.get_boolean('stockgs-keep-top-panel') && Main.layoutManager.primaryMonitor == this.monitor) { gsTopPanelOffset = Main.layoutManager.panelBox.height - topPadding; } if (this.checkIfVertical()) { - if (!Me.settings.get_boolean('group-apps')) { + if (!SETTINGS.get_boolean('group-apps')) { // add window title width and side padding of _dtpIconContainer when vertical - this.dtpSize += Me.settings.get_int('group-apps-label-max-width') + AppIcons.DEFAULT_PADDING_SIZE * 2 / scaleFactor; + this.dtpSize += SETTINGS.get_int('group-apps-label-max-width') + AppIcons.DEFAULT_PADDING_SIZE * 2 / scaleFactor; } this.sizeFunc = 'get_preferred_height', @@ -1065,7 +1066,7 @@ var Panel = GObject.registerClass({ let timeParts = time.split('∶'); if (!this._clockFormat) { - this._clockFormat = Me.desktopSettings.get_string('clock-format'); + this._clockFormat = DESKTOPSETTINGS.get_string('clock-format'); } if (this._clockFormat == '12h') { @@ -1096,8 +1097,8 @@ var Panel = GObject.registerClass({ this._showDesktopButton.add_style_class_name(this._getBackgroundBrightness() ? 'showdesktop-button-light-hovered' : 'showdesktop-button-dark-hovered'); - if (Me.settings.get_boolean('show-showdesktop-hover')) { - this._timeoutsHandler.add([T4, Me.settings.get_int('show-showdesktop-delay'), () => { + if (SETTINGS.get_boolean('show-showdesktop-hover')) { + this._timeoutsHandler.add([T4, SETTINGS.get_int('show-showdesktop-delay'), () => { this._hiddenDesktopWorkspace = Utils.DisplayWrapper.getWorkspaceManager().get_active_workspace(); this._toggleWorkspaceWindows(true, this._hiddenDesktopWorkspace); }]); @@ -1108,7 +1109,7 @@ var Panel = GObject.registerClass({ this._showDesktopButton.remove_style_class_name(this._getBackgroundBrightness() ? 'showdesktop-button-light-hovered' : 'showdesktop-button-dark-hovered'); - if (Me.settings.get_boolean('show-showdesktop-hover')) { + if (SETTINGS.get_boolean('show-showdesktop-hover')) { if (this._timeoutsHandler.getId(T4)) { this._timeoutsHandler.remove(T4); } else if (this._hiddenDesktopWorkspace) { @@ -1131,11 +1132,11 @@ var Panel = GObject.registerClass({ _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'); - rgb = isLineCustom ? Me.settings.get_string('desktop-line-custom-color') : rgb; + let isLineCustom = SETTINGS.get_boolean('desktop-line-use-custom-color'); + rgb = isLineCustom ? SETTINGS.get_string('desktop-line-custom-color') : rgb; if (this._showDesktopButton) { - let buttonSize = Me.settings.get_int('showdesktop-button-width') + 'px;'; + let buttonSize = SETTINGS.get_int('showdesktop-button-width') + 'px;'; let isVertical = this.checkIfVertical(); let sytle = "border: 0 solid " + rgb + ";"; @@ -1152,7 +1153,7 @@ var Panel = GObject.registerClass({ } _toggleWorkspaceWindows(hide, workspace) { - let time = Me.settings.get_int('show-showdesktop-time') * .001; + let time = SETTINGS.get_int('show-showdesktop-time') * .001; workspace.list_windows().forEach(w => { if (!w.minimized && !w.customJS_ding) { @@ -1210,7 +1211,7 @@ var Panel = GObject.registerClass({ } _onPanelMouseScroll(actor, event) { - let scrollAction = Me.settings.get_string('scroll-panel-action'); + let scrollAction = SETTINGS.get_string('scroll-panel-action'); let direction = Utils.getMouseScrollDirection(event); if (!this._checkIfIgnoredScrollSource(event.get_source()) && !this._timeoutsHandler.getId(T6)) { @@ -1225,7 +1226,7 @@ var Panel = GObject.registerClass({ //gnome-shell < 3.30 needs an additional "screen" param global.screen ? args.push(global.screen) : 0; - let showWsPopup = Me.settings.get_boolean('scroll-panel-show-ws-popup'); + let showWsPopup = SETTINGS.get_boolean('scroll-panel-show-ws-popup'); showWsPopup ? 0 : Main.wm._workspaceSwitcherPopup = { display: () => {} }; Main.wm._showWorkspaceSwitcher.apply(Main.wm, args.concat([0, { get_name: () => 'switch---' + direction }])); showWsPopup ? 0 : Main.wm._workspaceSwitcherPopup = null; @@ -1247,7 +1248,7 @@ var Panel = GObject.registerClass({ return; } - var scrollDelay = Me.settings.get_int('scroll-panel-delay'); + var scrollDelay = SETTINGS.get_int('scroll-panel-delay'); if (scrollDelay) { this._timeoutsHandler.add([T6, scrollDelay, () => {}]); @@ -1262,8 +1263,8 @@ var Panel = GObject.registerClass({ } _initProgressManager() { - const progressVisible = Me.settings.get_boolean('progress-show-bar'); - const countVisible = Me.settings.get_boolean('progress-show-count'); + const progressVisible = SETTINGS.get_boolean('progress-show-bar'); + const countVisible = SETTINGS.get_boolean('progress-show-count'); const pm = this.progressManager; if(!pm && (progressVisible || countVisible)) diff --git a/panelManager.js b/panelManager.js index db65750..b996e9c 100755 --- a/panelManager.js +++ b/panelManager.js @@ -52,6 +52,7 @@ import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js'; import * as Layout from 'resource:///org/gnome/shell/ui/layout.js'; import * as WM from 'resource:///org/gnome/shell/ui/windowManager.js'; +import {SETTINGS} from './extension.js'; import { SecondaryMonitorDisplay, WorkspacesView } from 'resource:///org/gnome/shell/ui/workspacesView.js'; const Gi = imports._gi; @@ -66,21 +67,21 @@ var PanelManager = class { } enable(reset) { - let dtpPrimaryIndex = Me.settings.get_int('primary-monitor'); + let dtpPrimaryIndex = SETTINGS.get_int('primary-monitor'); this.allPanels = []; this.dtpPrimaryMonitor = Main.layoutManager.monitors[dtpPrimaryIndex] || Main.layoutManager.primaryMonitor; this.proximityManager = new Proximity.ProximityManager(); if (this.dtpPrimaryMonitor) { - this.primaryPanel = this._createPanel(this.dtpPrimaryMonitor, Me.settings.get_boolean('stockgs-keep-top-panel')); + this.primaryPanel = this._createPanel(this.dtpPrimaryMonitor, SETTINGS.get_boolean('stockgs-keep-top-panel')); this.allPanels.push(this.primaryPanel); this.overview.enable(this.primaryPanel); this.setFocusedMonitor(this.dtpPrimaryMonitor); } - if (Me.settings.get_boolean('multi-monitors')) { + if (SETTINGS.get_boolean('multi-monitors')) { Main.layoutManager.monitors.filter(m => m != this.dtpPrimaryMonitor).forEach(m => { this.allPanels.push(this._createPanel(m, true)); }); @@ -135,7 +136,7 @@ var PanelManager = class { Main.layoutManager._updateHotCorners = newUpdateHotCorners.bind(Main.layoutManager); Main.layoutManager._updateHotCorners(); - this._forceHotCornerId = Me.settings.connect('changed::stockgs-force-hotcorner', () => Main.layoutManager._updateHotCorners()); + this._forceHotCornerId = SETTINGS.connect('changed::stockgs-force-hotcorner', () => Main.layoutManager._updateHotCorners()); if (Main.layoutManager._interfaceSettings) { this._enableHotCornersId = Main.layoutManager._interfaceSettings.connect('changed::enable-hot-corners', () => Main.layoutManager._updateHotCorners()); @@ -158,7 +159,7 @@ var PanelManager = class { //listen settings this._signalsHandler.add( [ - Me.settings, + SETTINGS, [ 'changed::primary-monitor', 'changed::multi-monitors', @@ -171,17 +172,17 @@ var PanelManager = class { () => this._reset() ], [ - Me.settings, + SETTINGS, 'changed::panel-element-positions', () => this._updatePanelElementPositions() ], [ - Me.settings, + SETTINGS, 'changed::intellihide-key-toggle-text', () => this._setKeyBindings(true) ], [ - Me.settings, + SETTINGS, 'changed::panel-sizes', () => { GLib.idle_add(GLib.PRIORITY_LOW, () => { @@ -215,7 +216,7 @@ var PanelManager = class { this._setKeyBindings(true); // keep GS overview.js from blowing away custom panel styles - if(!Me.settings.get_boolean('stockgs-keep-top-panel')) + if(!SETTINGS.get_boolean('stockgs-keep-top-panel')) Object.defineProperty(Main.panel, "style", {configurable: true, set(v) {}}); } @@ -277,7 +278,7 @@ var PanelManager = class { Main.layoutManager._updateHotCorners = this._oldUpdateHotCorners; Main.layoutManager._updateHotCorners(); - Me.settings.disconnect(this._forceHotCornerId); + SETTINGS.disconnect(this._forceHotCornerId); if (this._enableHotCornersId) { Main.layoutManager._interfaceSettings.disconnect(this._enableHotCornersId); @@ -385,8 +386,8 @@ var PanelManager = class { let keyPrimary = 'primary-monitor'; let primaryIndex = Main.layoutManager.primaryIndex; let newMonitors = [primaryIndex]; - let savedMonitors = Me.settings.get_value(keyMonitors).deep_unpack(); - let dtpPrimaryIndex = Me.settings.get_int(keyPrimary); + let savedMonitors = SETTINGS.get_value(keyMonitors).deep_unpack(); + let dtpPrimaryIndex = SETTINGS.get_int(keyPrimary); let newDtpPrimaryIndex = primaryIndex; Main.layoutManager.monitors.filter(m => m.index != primaryIndex).forEach(m => newMonitors.push(m.index)); @@ -400,8 +401,8 @@ var PanelManager = class { newDtpPrimaryIndex = newDtpPrimaryIndex == null ? primaryIndex : newDtpPrimaryIndex; } - Me.settings.set_int(keyPrimary, newDtpPrimaryIndex); - Me.settings.set_value(keyMonitors, new GLib.Variant('ai', newMonitors)); + SETTINGS.set_int(keyPrimary, newDtpPrimaryIndex); + SETTINGS.set_value(keyMonitors, new GLib.Variant('ai', newMonitors)); } checkIfFocusedMonitor(monitor) { @@ -446,7 +447,7 @@ var PanelManager = class { } _updatePanelElementPositions() { - this.panelsElementPositions = PanelSettings.getSettingsJson(Me.settings, 'panel-element-positions'); + this.panelsElementPositions = PanelSettings.getSettingsJson(SETTINGS, 'panel-element-positions'); this.allPanels.forEach(p => p.updateElementPositions()); } @@ -466,7 +467,7 @@ var PanelManager = class { } _getBoxPointerPreferredHeight(boxPointer, alloc, monitor) { - if (boxPointer._dtpInPanel && boxPointer.sourceActor && Me.settings.get_boolean('intellihide')) { + if (boxPointer._dtpInPanel && boxPointer.sourceActor && SETTINGS.get_boolean('intellihide')) { monitor = monitor || Main.layoutManager.findMonitorForActor(boxPointer.sourceActor); let panel = Utils.find(global.dashToPanel.panels, p => p.monitor == monitor); let excess = alloc.natural_size + panel.dtpSize + 10 - monitor.height; // 10 is arbitrary @@ -520,7 +521,7 @@ var PanelManager = class { Utils.removeKeybinding(k); if (enable) { - Utils.addKeybinding(k, Me.settings, keys[k], Shell.ActionMode.NORMAL); + Utils.addKeybinding(k, SETTINGS, keys[k], Shell.ActionMode.NORMAL); } }); } @@ -640,7 +641,7 @@ function newUpdateHotCorners() { // hot corner unless it is actually a top left panel. Otherwise, it stops the mouse // as you are dragging across. In the future, maybe we will automatically move the // hotcorner to the bottom when the panel is positioned at the bottom - if (i != this.primaryIndex || (!panelTopLeft && !Me.settings.get_boolean('stockgs-force-hotcorner'))) { + if (i != this.primaryIndex || (!panelTopLeft && !SETTINGS.get_boolean('stockgs-force-hotcorner'))) { // Check if we have a top left (right for RTL) corner. // I.e. if there is no monitor directly above or to the left(right) let besideX = this._rtl ? monitor.x + 1 : cornerX - 1; diff --git a/panelStyle.js b/panelStyle.js index d0a28d7..6ef6c10 100644 --- a/panelStyle.js +++ b/panelStyle.js @@ -29,6 +29,7 @@ import Shell from 'gi://Shell'; import * as Panel from './panel.js'; import * as Taskbar from './taskbar.js'; import * as Utils from './utils.js'; +import {SETTINGS} from './extension.js'; const Mainloop = imports.mainloop; @@ -44,7 +45,7 @@ var PanelStyle = class { disable() { for (let i = 0; i < this._dtpSettingsSignalIds.length; ++i) { - Me.settings.disconnect(this._dtpSettingsSignalIds[i]); + SETTINGS.disconnect(this._dtpSettingsSignalIds[i]); } this._removeStyles(); @@ -62,7 +63,7 @@ var PanelStyle = class { this._dtpSettingsSignalIds = []; for(let i in configKeys) { - this._dtpSettingsSignalIds.push(Me.settings.connect('changed::' + configKeys[i], () => { + this._dtpSettingsSignalIds.push(SETTINGS.connect('changed::' + configKeys[i], () => { this._removeStyles(); this._applyStyles(); })); @@ -72,7 +73,7 @@ var PanelStyle = class { _applyStyles() { this._rightBoxOperations = []; - let trayPadding = Me.settings.get_int('tray-padding'); + let trayPadding = SETTINGS.get_int('tray-padding'); let isVertical = this.panel.checkIfVertical(); let paddingStyle = 'padding: ' + (isVertical ? '%dpx 0' : '0 %dpx'); @@ -105,7 +106,7 @@ var PanelStyle = class { this._rightBoxOperations.push(operation); } - let statusIconPadding = Me.settings.get_int('status-icon-padding'); + let statusIconPadding = SETTINGS.get_int('status-icon-padding'); if(statusIconPadding >= 0) { let statusIconPaddingStyleLine = paddingStyle.format(statusIconPadding) let operation = {}; @@ -118,7 +119,7 @@ var PanelStyle = class { this._rightBoxOperations.push(operation); } - let trayContentSize = Me.settings.get_int('tray-size'); + let trayContentSize = SETTINGS.get_int('tray-size'); if(trayContentSize > 0) { let trayIconSizeStyleLine = 'icon-size: %dpx'.format(trayContentSize) let operation = {}; @@ -149,7 +150,7 @@ var PanelStyle = class { this._leftBoxOperations = []; - let leftboxPadding = Me.settings.get_int('leftbox-padding'); + let leftboxPadding = SETTINGS.get_int('leftbox-padding'); if(leftboxPadding >= 0) { let leftboxPaddingStyleLine = paddingStyle.format(leftboxPadding); let operation = {}; @@ -163,7 +164,7 @@ var PanelStyle = class { this._leftBoxOperations.push(operation); } - let leftboxContentSize = Me.settings.get_int('leftbox-size'); + let leftboxContentSize = SETTINGS.get_int('leftbox-size'); if(leftboxContentSize > 0) { let leftboxIconSizeStyleLine = 'icon-size: %dpx'.format(leftboxContentSize) let operation = {}; diff --git a/progress.js b/progress.js index 4c2f062..03ab49f 100644 --- a/progress.js +++ b/progress.js @@ -24,6 +24,7 @@ import Clutter from 'gi://Clutter'; import Pango from 'gi://Pango'; import St from 'gi://St'; import * as Utils from './utils.js'; +import {SETTINGS} from './extension.js'; const Cairo = imports.cairo; const Signals = imports.signals; @@ -262,11 +263,11 @@ class AppProgress { if (property == 'count') { this.setCount(other[property].get_int64()); } else if (property == 'count-visible') { - this.setCountVisible(Me.settings.get_boolean('progress-show-count') && other[property].get_boolean()); + this.setCountVisible(SETTINGS.get_boolean('progress-show-count') && other[property].get_boolean()); } else if (property == 'progress') { this.setProgress(other[property].get_double()); } else if (property == 'progress-visible') { - this.setProgressVisible(Me.settings.get_boolean('progress-show-bar') && other[property].get_boolean()); + this.setProgressVisible(SETTINGS.get_boolean('progress-show-bar') && other[property].get_boolean()); } else if (property == 'urgent') { this.setUrgent(other[property].get_boolean()); } else { diff --git a/taskbar.js b/taskbar.js index e288193..2ba6922 100644 --- a/taskbar.js +++ b/taskbar.js @@ -46,6 +46,7 @@ import * as PanelSettings from './panelSettings.js'; import * as Pos from './panelPositions.js'; import * as Utils from './utils.js'; import * as WindowPreview from './windowPreview.js'; +import {SETTINGS} from './extension.js'; const Mainloop = imports.mainloop; const Signals = imports.signals; @@ -76,15 +77,15 @@ function extendDashItemContainer(dashItemContainer) { const iconAnimationSettings = { _getDictValue(key) { - let type = Me.settings.get_string('animate-appicon-hover-animation-type'); - return Me.settings.get_value(key).deep_unpack()[type] || 0; + let type = SETTINGS.get_string('animate-appicon-hover-animation-type'); + return SETTINGS.get_value(key).deep_unpack()[type] || 0; }, get type() { - if (!Me.settings.get_boolean('animate-appicon-hover')) + if (!SETTINGS.get_boolean('animate-appicon-hover')) return ""; - return Me.settings.get_string('animate-appicon-hover-animation-type'); + return SETTINGS.get_string('animate-appicon-hover-animation-type'); }, get convexity() { @@ -330,7 +331,7 @@ var Taskbar = class { 'window-left-monitor' ], () => { - if (Me.settings.get_boolean('isolate-monitors')) { + if (SETTINGS.get_boolean('isolate-monitors')) { this._queueRedisplay(); } } @@ -357,7 +358,7 @@ var Taskbar = class { this._syncShowAppsButtonToggled.bind(this) ], [ - Me.settings, + SETTINGS, [ 'changed::dot-size', 'changed::show-favorites', @@ -370,7 +371,7 @@ var Taskbar = class { } ], [ - Me.settings, + SETTINGS, 'changed::group-apps', () => { setAttributes() @@ -378,7 +379,7 @@ var Taskbar = class { } ], [ - Me.settings, + SETTINGS, [ 'changed::group-apps-use-launchers', 'changed::taskbar-locked' @@ -399,11 +400,11 @@ var Taskbar = class { ); let setAttributes = () => { - this.isGroupApps = Me.settings.get_boolean('group-apps'); - this.usingLaunchers = !this.isGroupApps && Me.settings.get_boolean('group-apps-use-launchers'); - this.showFavorites = Me.settings.get_boolean('show-favorites') && - (this.dtpPanel.isPrimary || Me.settings.get_boolean('show-favorites-all-monitors')) - this.showRunningApps = Me.settings.get_boolean('show-running-apps') + this.isGroupApps = SETTINGS.get_boolean('group-apps'); + this.usingLaunchers = !this.isGroupApps && SETTINGS.get_boolean('group-apps-use-launchers'); + this.showFavorites = SETTINGS.get_boolean('show-favorites') && + (this.dtpPanel.isPrimary || SETTINGS.get_boolean('show-favorites-all-monitors')) + this.showRunningApps = SETTINGS.get_boolean('show-running-apps') this.allowSplitApps = this.usingLaunchers || (!this.isGroupApps && !this.showFavorites) } @@ -693,7 +694,7 @@ var Taskbar = class { { setSizeManually: true, showLabel: false, - isDraggable: !Me.settings.get_boolean('taskbar-locked'), + isDraggable: !SETTINGS.get_boolean('taskbar-locked'), }, this.previewMenu, this.iconAnimator @@ -852,8 +853,8 @@ var Taskbar = class { _adjustIconSize() { const thisMonitorIndex = this.dtpPanel.monitor.index; - let panelSize = PanelSettings.getPanelSize(Me.settings, thisMonitorIndex); - let availSize = panelSize - Me.settings.get_int('appicon-padding') * 2; + let panelSize = PanelSettings.getPanelSize(SETTINGS, thisMonitorIndex); + let availSize = panelSize - SETTINGS.get_int('appicon-padding') * 2; let minIconSize = MIN_ICON_SIZE + panelSize % 2; if (availSize == this.iconSize) @@ -1084,8 +1085,8 @@ var Taskbar = class { icon.updateHotkeyNumberOverlay(); }); - if (Me.settings.get_boolean('hot-keys') && - Me.settings.get_string('hotkeys-overlay-combo') === 'ALWAYS') + if (SETTINGS.get_boolean('hot-keys') && + SETTINGS.get_string('hotkeys-overlay-combo') === 'ALWAYS') this.toggleNumberOverlay(true); } @@ -1249,7 +1250,7 @@ var Taskbar = class { // find visible view if (this.showAppsButton.checked) { - if (Me.settings.get_boolean('show-apps-override-escape')) { + if (SETTINGS.get_boolean('show-apps-override-escape')) { //override escape key to return to the desktop when entering the overview using the showapps button SearchController._onStageKeyPress = function(actor, event) { if (Main.modalCount == 1 && event.get_key_symbol() === Clutter.KEY_Escape) { @@ -1385,7 +1386,7 @@ var TaskbarItemContainer = GObject.registerClass({ // For ItemShowLabel _getIconAnimationOffset() { - if (!Me.settings.get_boolean('animate-appicon-hover')) + if (!SETTINGS.get_boolean('animate-appicon-hover')) return 0; let travel = iconAnimationSettings.travel; diff --git a/transparency.js b/transparency.js index 83497c4..e48ffc9 100644 --- a/transparency.js +++ b/transparency.js @@ -25,6 +25,7 @@ import * as Config from 'resource:///org/gnome/shell/misc/config.js'; import * as Panel from './panel.js'; import * as Proximity from './proximity.js'; import * as Utils from './utils.js'; +import {SETTINGS} from './extension.js'; var DynamicTransparency = class { @@ -72,7 +73,7 @@ var DynamicTransparency = class { () => this._updateAlphaAndSet() ], [ - Me.settings, + SETTINGS, [ 'changed::trans-use-custom-bg', 'changed::trans-bg-color' @@ -80,7 +81,7 @@ var DynamicTransparency = class { () => this._updateColorAndSet() ], [ - Me.settings, + SETTINGS, [ 'changed::trans-use-custom-opacity', 'changed::trans-panel-opacity', @@ -91,7 +92,7 @@ var DynamicTransparency = class { () => this._updateAlphaAndSet() ], [ - Me.settings, + SETTINGS, [ 'changed::trans-use-custom-gradient', 'changed::trans-gradient-top-color', @@ -102,7 +103,7 @@ var DynamicTransparency = class { () => this._updateGradientAndSet() ], [ - Me.settings, + SETTINGS, [ 'changed::trans-dynamic-behavior', 'changed::trans-use-dynamic-opacity', @@ -111,7 +112,7 @@ var DynamicTransparency = class { () => this._updateProximityWatch() ], [ - Me.settings, + SETTINGS, 'changed::trans-dynamic-anim-time', () => this._updateAnimationDuration() ] @@ -121,9 +122,9 @@ var DynamicTransparency = class { _updateProximityWatch() { this._proximityManager.removeWatch(this._proximityWatchId); - if (Me.settings.get_boolean('trans-use-dynamic-opacity')) { + if (SETTINGS.get_boolean('trans-use-dynamic-opacity')) { let isVertical = this._dtpPanel.checkIfVertical(); - let threshold = Me.settings.get_int('trans-dynamic-distance'); + let threshold = SETTINGS.get_int('trans-dynamic-distance'); this._windowOverlap = false; this._updateAlphaAndSet() @@ -131,7 +132,7 @@ var DynamicTransparency = class { this._proximityWatchId = this._proximityManager.createWatch( this._dtpPanel.panelBox.get_parent(), this._dtpPanel.monitor.index, - Proximity.Mode[Me.settings.get_string('trans-dynamic-behavior')], + Proximity.Mode[SETTINGS.get_string('trans-dynamic-behavior')], isVertical ? threshold : 0, isVertical ? 0 : threshold, overlap => { @@ -143,7 +144,7 @@ var DynamicTransparency = class { } _updateAnimationDuration() { - this.animationDuration = (Me.settings.get_int('trans-dynamic-anim-time') * 0.001) + 's;'; + this.animationDuration = (SETTINGS.get_int('trans-dynamic-anim-time') * 0.001) + 's;'; } _updateAllAndSet() { @@ -179,17 +180,17 @@ var DynamicTransparency = class { } _updateColor(themeBackground) { - this.backgroundColorRgb = Me.settings.get_boolean('trans-use-custom-bg') ? - Me.settings.get_string('trans-bg-color') : + this.backgroundColorRgb = SETTINGS.get_boolean('trans-use-custom-bg') ? + SETTINGS.get_string('trans-bg-color') : (themeBackground || this._getThemeBackground()); } _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'); + if (this._windowOverlap && !Main.overview.visibleTarget && SETTINGS.get_boolean('trans-use-dynamic-opacity')) { + this.alpha = SETTINGS.get_double('trans-dynamic-anim-target'); } else { - this.alpha = Me.settings.get_boolean('trans-use-custom-opacity') ? - Me.settings.get_double('trans-panel-opacity') : + this.alpha = SETTINGS.get_boolean('trans-use-custom-opacity') ? + SETTINGS.get_double('trans-panel-opacity') : (themeBackground || this._getThemeBackground()).alpha * 0.003921569; // 1 / 255 = 0.003921569 } } @@ -197,12 +198,12 @@ var DynamicTransparency = class { _updateGradient() { this._gradientStyle = ''; - if (Me.settings.get_boolean('trans-use-custom-gradient')) { + if (SETTINGS.get_boolean('trans-use-custom-gradient')) { this._gradientStyle += 'background-gradient-direction: ' + (this._dtpPanel.checkIfVertical() ? 'horizontal;' : 'vertical;') + - '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')); + 'background-gradient-start: ' + Utils.getrgbaColor(SETTINGS.get_string('trans-gradient-top-color'), + SETTINGS.get_double('trans-gradient-top-opacity')) + + 'background-gradient-end: ' + Utils.getrgbaColor(SETTINGS.get_string('trans-gradient-bottom-color'), + SETTINGS.get_double('trans-gradient-bottom-opacity')); } } diff --git a/windowPreview.js b/windowPreview.js index 4efae2f..55a8af9 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -30,6 +30,7 @@ import * as Workspace from 'resource:///org/gnome/shell/ui/workspace.js'; import * as Panel from './panel.js'; import * as Taskbar from './taskbar.js'; import * as Utils from './utils.js'; +import {SETTINGS, DESKTOPSETTINGS} from './extension.js'; const Mainloop = imports.mainloop; const Signals = imports.signals; @@ -143,7 +144,7 @@ var PreviewMenu = GObject.registerClass({ } ], [ - Me.settings, + SETTINGS, [ 'changed::panel-sizes', 'changed::window-preview-size', @@ -169,7 +170,7 @@ var PreviewMenu = GObject.registerClass({ } requestOpen(appIcon) { - let timeout = Me.settings.get_int('show-window-previews-timeout'); + let timeout = SETTINGS.get_int('show-window-previews-timeout'); if (this.opened) { timeout = Math.min(100, timeout); @@ -263,9 +264,9 @@ var PreviewMenu = GObject.registerClass({ requestPeek(window) { this._timeoutsHandler.remove(T3); - if (Me.settings.get_boolean('peek-mode')) { + if (SETTINGS.get_boolean('peek-mode')) { if (this.peekInitialWorkspaceIndex < 0) { - this._timeoutsHandler.add([T3, Me.settings.get_int('enter-peek-mode-timeout'), () => this._peek(window)]); + this._timeoutsHandler.add([T3, SETTINGS.get_int('enter-peek-mode-timeout'), () => this._peek(window)]); } else { this._peek(window); } @@ -368,7 +369,7 @@ var PreviewMenu = GObject.registerClass({ } _addCloseTimeout() { - this._timeoutsHandler.add([T2, Me.settings.get_int('leave-timeout'), () => this.close()]); + this._timeoutsHandler.add([T2, SETTINGS.get_int('leave-timeout'), () => this.close()]); } _onHoverChanged() { @@ -413,22 +414,22 @@ var PreviewMenu = GObject.registerClass({ _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'); + isTopHeader = SETTINGS.get_string('window-preview-title-position') == 'TOP'; + isManualStyling = SETTINGS.get_boolean('window-preview-manual-styling'); scaleFactor = Utils.getScaleFactor(); - headerHeight = Me.settings.get_boolean('window-preview-show-title') ? HEADER_HEIGHT * scaleFactor : 0; - animationTime = Me.settings.get_int('window-preview-animation-time') * .001; + headerHeight = SETTINGS.get_boolean('window-preview-show-title') ? HEADER_HEIGHT * scaleFactor : 0; + animationTime = SETTINGS.get_int('window-preview-animation-time') * .001; aspectRatio.x = { - size: Me.settings.get_int('window-preview-aspect-ratio-x'), - fixed: Me.settings.get_boolean('window-preview-fixed-x') + size: SETTINGS.get_int('window-preview-aspect-ratio-x'), + fixed: SETTINGS.get_boolean('window-preview-fixed-x') }; aspectRatio.y = { - size: Me.settings.get_int('window-preview-aspect-ratio-y'), - fixed: Me.settings.get_boolean('window-preview-fixed-y') + size: SETTINGS.get_int('window-preview-aspect-ratio-y'), + fixed: SETTINGS.get_boolean('window-preview-fixed-y') }; - alphaBg = Me.settings.get_boolean('preview-use-custom-opacity') ? - Me.settings.get_int('preview-custom-opacity') * .01 : + alphaBg = SETTINGS.get_boolean('preview-use-custom-opacity') ? + SETTINGS.get_int('preview-custom-opacity') * .01 : this.panel.dynamicTransparency.alpha; } @@ -436,8 +437,8 @@ var PreviewMenu = GObject.registerClass({ let x, y, w; let geom = this.panel.getGeometry(); let panelBoxTheme = this.panel.panelBox.get_theme_node(); - let previewSize = (Me.settings.get_int('window-preview-size') + - Me.settings.get_int('window-preview-padding') * 2) * scaleFactor; + let previewSize = (SETTINGS.get_int('window-preview-size') + + SETTINGS.get_int('window-preview-padding') * 2) * scaleFactor; if (this.isVertical) { w = previewSize; @@ -467,7 +468,7 @@ var PreviewMenu = GObject.registerClass({ let sourceContentBox = sourceNode.get_content_box(this.currentAppIcon.get_allocation_box()); let sourceAllocation = Utils.getTransformedAllocation(this.currentAppIcon); let [previewsWidth, previewsHeight] = this._getPreviewsSize(); - let appIconMargin = Me.settings.get_int('appicon-margin') / scaleFactor; + let appIconMargin = SETTINGS.get_int('appicon-margin') / scaleFactor; let x = 0, y = 0; previewsWidth = Math.min(previewsWidth, this.panel.monitor.width); @@ -589,7 +590,7 @@ var PreviewMenu = GObject.registerClass({ _peek(window) { let currentWorkspace = Utils.getCurrentWorkspace(); let windowWorkspace = window.get_workspace(); - let focusWindow = () => this._focusMetaWindow(Me.settings.get_int('peek-mode-opacity'), window); + let focusWindow = () => this._focusMetaWindow(SETTINGS.get_int('peek-mode-opacity'), window); this._restorePeekedWindowStack(); @@ -709,7 +710,7 @@ var Preview = GObject.registerClass({ this._needsCloseButton = true; this.cloneWidth = this.cloneHeight = 0; this._previewMenu = previewMenu; - this._padding = Me.settings.get_int('window-preview-padding') * scaleFactor; + this._padding = SETTINGS.get_int('window-preview-padding') * scaleFactor; this._previewDimensions = this._getPreviewDimensions(); this.animatingOut = false; @@ -883,7 +884,7 @@ var Preview = GObject.registerClass({ this._hideOrShowCloseButton(true); this.reactive = false; - if (!Me.settings.get_boolean('group-apps')) { + if (!SETTINGS.get_boolean('group-apps')) { this._previewMenu.close(); } else { this._previewMenu.endPeekHere(); @@ -898,7 +899,7 @@ var Preview = GObject.registerClass({ this.activate(); break; case 2: // Middle click - if (Me.settings.get_boolean('preview-middle-click-close')) { + if (SETTINGS.get_boolean('preview-middle-click-close')) { this._onCloseBtnClick(); } break; @@ -957,21 +958,21 @@ var Preview = GObject.registerClass({ _updateHeader() { if (headerHeight) { - let iconTextureSize = Me.settings.get_boolean('window-preview-use-custom-icon-size') ? - Me.settings.get_int('window-preview-custom-icon-size') : + let iconTextureSize = SETTINGS.get_boolean('window-preview-use-custom-icon-size') ? + SETTINGS.get_int('window-preview-custom-icon-size') : headerHeight / scaleFactor * .6; let icon = this._previewMenu.getCurrentAppIcon().app.create_icon_texture(iconTextureSize); let workspaceIndex = ''; let workspaceStyle = null; - let fontScale = Me.desktopSettings.get_double('text-scaling-factor'); - let commonTitleStyles = 'color: ' + Me.settings.get_string('window-preview-title-font-color') + ';' + - 'font-size: ' + Me.settings.get_int('window-preview-title-font-size') * fontScale + 'px;' + - 'font-weight: ' + Me.settings.get_string('window-preview-title-font-weight') + ';'; + let fontScale = DESKTOPSETTINGS.get_double('text-scaling-factor'); + let commonTitleStyles = 'color: ' + SETTINGS.get_string('window-preview-title-font-color') + ';' + + 'font-size: ' + SETTINGS.get_int('window-preview-title-font-size') * fontScale + 'px;' + + 'font-weight: ' + SETTINGS.get_string('window-preview-title-font-weight') + ';'; this._iconBin.destroy_all_children(); this._iconBin.add_child(icon); - if (!Me.settings.get_boolean('isolate-workspaces')) { + if (!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; @@ -1096,7 +1097,7 @@ var Preview = GObject.registerClass({ } _getPreviewDimensions() { - let size = Me.settings.get_int('window-preview-size') * scaleFactor; + let size = SETTINGS.get_int('window-preview-size') * scaleFactor; let w, h; if (this._previewMenu.isVertical) {