From fd8022b49b1d85d41ec1d8753ff296922a84fafa Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:24 -0700 Subject: [PATCH 01/18] refactor: replace `export var` with `export const` --- appIcons.js | 10 ++--- desktopIconsIntegration.js | 2 +- extension.js | 12 +++--- intellihide.js | 6 +-- overview.js | 4 +- panel.js | 8 ++-- panelManager.js | 4 +- panelPositions.js | 46 +++++++++++------------ panelStyle.js | 2 +- progress.js | 4 +- proximity.js | 6 +-- taskbar.js | 10 ++--- transparency.js | 2 +- utils.js | 76 +++++++++++++++++++------------------- windowPreview.js | 6 +-- 15 files changed, 99 insertions(+), 99 deletions(-) diff --git a/appIcons.js b/appIcons.js index 2f5e647..2df9d6e 100644 --- a/appIcons.js +++ b/appIcons.js @@ -68,7 +68,7 @@ const DOUBLE_CLICK_DELAY_MS = 450; let LABEL_GAP = 5; let MAX_INDICATORS = 4; -export var DEFAULT_PADDING_SIZE = 4; +export const DEFAULT_PADDING_SIZE = 4; let DOT_STYLE = { DOTS: "DOTS", @@ -108,7 +108,7 @@ let tracker = Shell.WindowTracker.get_default(); * */ -export var TaskbarAppIcon = GObject.registerClass({ +export const TaskbarAppIcon = GObject.registerClass({ }, class TaskbarAppIcon extends AppDisplay.AppIcon { _init(appInfo, panel, iconParams, previewMenu, iconAnimator) { @@ -1587,7 +1587,7 @@ export function ItemShowLabel() { * use of this class in place of the original showAppsButton. * */ -export var ShowAppsIconWrapper = class { +export const ShowAppsIconWrapper = class { constructor(dtpPanel) { this.realShowAppsIcon = new Dash.ShowAppsIcon(); @@ -1736,7 +1736,7 @@ Signals.addSignalMethods(ShowAppsIconWrapper.prototype); /** * A menu for the showAppsIcon */ -export var MyShowAppsIconMenu = class extends PopupMenu.PopupMenu { +export const MyShowAppsIconMenu = class extends PopupMenu.PopupMenu { constructor(actor, dtpPanel) { super(actor, 0, dtpPanel.getPosition()); @@ -1875,7 +1875,7 @@ export var MyShowAppsIconMenu = class extends PopupMenu.PopupMenu { }; -export var getIconContainerStyle = function(isVertical) { +export const getIconContainerStyle = function(isVertical) { let style = 'padding: '; if (SETTINGS.get_boolean('group-apps')) { diff --git a/desktopIconsIntegration.js b/desktopIconsIntegration.js index c308b2c..9a93d07 100644 --- a/desktopIconsIntegration.js +++ b/desktopIconsIntegration.js @@ -64,7 +64,7 @@ import * as ExtensionUtils from 'resource:///org/gnome/shell/misc/extensionUtils const IDENTIFIER_UUID = "130cbc66-235c-4bd6-8571-98d2d8bba5e2"; -export var DesktopIconsUsableAreaClass = class { +export const DesktopIconsUsableAreaClass = class { constructor() { this._extensionManager = Main.extensionManager; this._timedMarginsID = 0; diff --git a/extension.js b/extension.js index b270333..d933e64 100644 --- a/extension.js +++ b/extension.js @@ -43,12 +43,12 @@ let extensionChangedHandler; let disabledUbuntuDock; let extensionSystem = Main.extensionManager; -export var DTP_EXTENSION = null; -export var SETTINGS = null; -export var DESKTOPSETTINGS = null; -export var PERSISTENTSTORAGE = null; -export var EXTENSION_UUID = null; -export var EXTENSION_PATH = null; +export let DTP_EXTENSION = null; +export let SETTINGS = null; +export let DESKTOPSETTINGS = null; +export let PERSISTENTSTORAGE = null; +export let EXTENSION_UUID = null; +export let EXTENSION_PATH = null; export default class DashToPanelExtension extends Extension { constructor(metadata) { diff --git a/intellihide.js b/intellihide.js index d35ade4..808016a 100644 --- a/intellihide.js +++ b/intellihide.js @@ -45,13 +45,13 @@ const T4 = 'panelBoxClipTimeout'; var SIDE_CONTROLS_ANIMATION_TIME = OverviewControls.SIDE_CONTROLS_ANIMATION_TIME / (OverviewControls.SIDE_CONTROLS_ANIMATION_TIME > 1 ? 1000 : 1); -export var Hold = { +export const Hold = { NONE: 0, TEMPORARY: 1, PERMANENT: 2 }; -export var Intellihide = class { +export const Intellihide = class { constructor(dtpPanel) { this._dtpPanel = dtpPanel; @@ -424,4 +424,4 @@ export var Intellihide = class { this._hoveredOut = false; } -} \ No newline at end of file +} diff --git a/overview.js b/overview.js index 22626e0..d39f115 100644 --- a/overview.js +++ b/overview.js @@ -46,7 +46,7 @@ const LABEL_MARGIN = 60; const T1 = 'swipeEndTimeout'; const T2 = 'numberOverlayTimeout'; -export var Overview = class { +export const Overview = class { constructor() { this._numHotkeys = 10; @@ -518,4 +518,4 @@ export var Overview = class { return true; } -} \ No newline at end of file +} diff --git a/panel.js b/panel.js index 35a36ba..041d60d 100644 --- a/panel.js +++ b/panel.js @@ -63,7 +63,7 @@ const Mainloop = imports.mainloop; const Gi = imports._gi; let tracker = Shell.WindowTracker.get_default(); -export var panelBoxes = ['_leftBox', '_centerBox', '_rightBox']; +export const panelBoxes = ['_leftBox', '_centerBox', '_rightBox']; //timeout names const T2 = 'startIntellihideTimeout'; @@ -72,7 +72,7 @@ const T5 = 'trackerFocusAppTimeout'; const T6 = 'scrollPanelDelayTimeout'; const T7 = 'waitPanelBoxAllocation'; -export var Panel = GObject.registerClass({ +export const Panel = GObject.registerClass({ }, class Panel extends St.Widget { _init(panelManager, monitor, panelBox, isStandalone) { @@ -1256,7 +1256,7 @@ export var Panel = GObject.registerClass({ } }); -export var SecondaryPanel = GObject.registerClass({ +export const SecondaryPanel = GObject.registerClass({ }, class SecondaryPanel extends St.Widget { _init(params) { @@ -1266,4 +1266,4 @@ export var SecondaryPanel = GObject.registerClass({ vfunc_allocate(box) { this.set_allocation(box); } -}); \ No newline at end of file +}); diff --git a/panelManager.js b/panelManager.js index 1dd45e1..f74be84 100755 --- a/panelManager.js +++ b/panelManager.js @@ -56,7 +56,7 @@ import {SecondaryMonitorDisplay, WorkspacesView} from 'resource:///org/gnome/she const Gi = imports._gi; -export var PanelManager = class { +export const PanelManager = class { constructor() { this.overview = new Overview.Overview(); @@ -529,7 +529,7 @@ export var PanelManager = class { // This class drives long-running icon animations, to keep them running in sync // with each other. -export var IconAnimator = class { +export const IconAnimator = class { constructor(actor) { this._count = 0; diff --git a/panelPositions.js b/panelPositions.js index 37bffc2..a970bdd 100644 --- a/panelPositions.js +++ b/panelPositions.js @@ -15,31 +15,31 @@ * along with this program. If not, see . */ -export var SHOW_APPS_BTN = 'showAppsButton'; -export var ACTIVITIES_BTN = 'activitiesButton'; -export var TASKBAR = 'taskbar'; -export var DATE_MENU = 'dateMenu'; -export var SYSTEM_MENU = 'systemMenu'; -export var LEFT_BOX = 'leftBox'; -export var CENTER_BOX = 'centerBox'; -export var RIGHT_BOX = 'rightBox'; -export var DESKTOP_BTN = 'desktopButton'; +export const SHOW_APPS_BTN = 'showAppsButton'; +export const ACTIVITIES_BTN = 'activitiesButton'; +export const TASKBAR = 'taskbar'; +export const DATE_MENU = 'dateMenu'; +export const SYSTEM_MENU = 'systemMenu'; +export const LEFT_BOX = 'leftBox'; +export const CENTER_BOX = 'centerBox'; +export const RIGHT_BOX = 'rightBox'; +export const DESKTOP_BTN = 'desktopButton'; -export var STACKED_TL = 'stackedTL'; -export var STACKED_BR = 'stackedBR'; -export var CENTERED = 'centered'; -export var CENTERED_MONITOR = 'centerMonitor'; +export const STACKED_TL = 'stackedTL'; +export const STACKED_BR = 'stackedBR'; +export const CENTERED = 'centered'; +export const CENTERED_MONITOR = 'centerMonitor'; -export var TOP = 'TOP'; -export var BOTTOM = 'BOTTOM'; -export var LEFT = 'LEFT'; -export var RIGHT = 'RIGHT'; +export const TOP = 'TOP'; +export const BOTTOM = 'BOTTOM'; +export const LEFT = 'LEFT'; +export const RIGHT = 'RIGHT'; -export var START = 'START'; -export var MIDDLE = 'MIDDLE'; -export var END = 'END'; +export const START = 'START'; +export const MIDDLE = 'MIDDLE'; +export const END = 'END'; -export var defaults = [ +export const defaults = [ { element: SHOW_APPS_BTN, visible: true, position: STACKED_TL }, { element: ACTIVITIES_BTN, visible: false, position: STACKED_TL }, { element: LEFT_BOX, visible: true, position: STACKED_TL }, @@ -51,11 +51,11 @@ export var defaults = [ { element: DESKTOP_BTN, visible: true, position: STACKED_BR }, ]; -export var optionDialogFunctions = {}; +export const optionDialogFunctions = {}; optionDialogFunctions[SHOW_APPS_BTN] = '_showShowAppsButtonOptions'; optionDialogFunctions[DESKTOP_BTN] = '_showDesktopButtonOptions'; export function checkIfCentered(position) { return position == CENTERED || position == CENTERED_MONITOR; -} \ No newline at end of file +} diff --git a/panelStyle.js b/panelStyle.js index c1d4452..291683f 100644 --- a/panelStyle.js +++ b/panelStyle.js @@ -33,7 +33,7 @@ import {SETTINGS} from './extension.js'; const Mainloop = imports.mainloop; -export var PanelStyle = class { +export const PanelStyle = class { enable(panel) { this.panel = panel; diff --git a/progress.js b/progress.js index d22b492..40c21b4 100644 --- a/progress.js +++ b/progress.js @@ -30,7 +30,7 @@ const Cairo = imports.cairo; const {signals: Signals} = imports; -export var ProgressManager = class { +export const ProgressManager = class { constructor() { this._entriesByDBusName = {}; @@ -281,7 +281,7 @@ export class AppProgress { Signals.addSignalMethods(AppProgress.prototype); -export var ProgressIndicator = class { +export const ProgressIndicator = class { constructor(source, progressManager) { this._source = source; diff --git a/proximity.js b/proximity.js index 9dcff42..2221833 100644 --- a/proximity.js +++ b/proximity.js @@ -29,7 +29,7 @@ const MIN_UPDATE_MS = 200; //timeout names const T1 = 'limitUpdateTimeout'; -export var Mode = { +export const Mode = { ALL_WINDOWS: 0, FOCUSED_WINDOWS: 1, MAXIMIZED_WINDOWS: 2 @@ -66,7 +66,7 @@ export class ProximityWatch { } }; -export var ProximityManager = class { +export const ProximityManager = class { constructor() { this._counter = 1; @@ -254,4 +254,4 @@ export var ProximityManager = class { metaWindow.get_monitor() == watch.monitorIndex || windowRect.overlap(global.display.get_monitor_geometry(watch.monitorIndex))); } -}; \ No newline at end of file +}; diff --git a/taskbar.js b/taskbar.js index 7565aa8..8b7bb42 100644 --- a/taskbar.js +++ b/taskbar.js @@ -53,9 +53,9 @@ const Mainloop = imports.mainloop; const {signals: Signals} = imports; const SearchController = Main.overview.searchController; -export var DASH_ANIMATION_TIME = Dash.DASH_ANIMATION_TIME / (Dash.DASH_ANIMATION_TIME > 1 ? 1000 : 1); +export const DASH_ANIMATION_TIME = Dash.DASH_ANIMATION_TIME / (Dash.DASH_ANIMATION_TIME > 1 ? 1000 : 1); var DASH_ITEM_HOVER_TIMEOUT = Dash.DASH_ITEM_HOVER_TIMEOUT; -export var MIN_ICON_SIZE = 4; +export const MIN_ICON_SIZE = 4; const T1 = 'ensureAppIconVisibilityTimeout' const T2 = 'showLabelTimeout' @@ -119,7 +119,7 @@ const iconAnimationSettings = { * - modified chldBox calculations for when 'show-apps-at-top' option is checked * - handle horizontal dash */ -export var TaskbarActor = GObject.registerClass({ +export const TaskbarActor = GObject.registerClass({ }, class TaskbarActor extends St.Widget { _init(delegate) { this._delegate = delegate; @@ -200,7 +200,7 @@ export var TaskbarActor = GObject.registerClass({ * - Sync minimization application target position. */ -export var Taskbar = class { +export const Taskbar = class { constructor(panel) { this.dtpPanel = panel; @@ -1344,7 +1344,7 @@ const CloneContainerConstraint = GObject.registerClass({ } }); -export var TaskbarItemContainer = GObject.registerClass({ +export const TaskbarItemContainer = GObject.registerClass({ }, class TaskbarItemContainer extends Dash.DashItemContainer { diff --git a/transparency.js b/transparency.js index 2561f03..e9691a5 100644 --- a/transparency.js +++ b/transparency.js @@ -27,7 +27,7 @@ import * as Proximity from './proximity.js'; import * as Utils from './utils.js'; import {SETTINGS} from './extension.js'; -export var DynamicTransparency = class { +export const DynamicTransparency = class { constructor(dtpPanel) { this._dtpPanel = dtpPanel; diff --git a/utils.js b/utils.js index 8da0def..0bb9474 100644 --- a/utils.js +++ b/utils.js @@ -42,7 +42,7 @@ var SCROLL_TIME = Util.SCROLL_TIME / (Util.SCROLL_TIME > 1 ? 1000 : 1); // simplify global signals and function injections handling // abstract class -export var BasicHandler = class { +export const BasicHandler = class { constructor() { this._storage = new Object(); @@ -102,7 +102,7 @@ export var BasicHandler = class { } // Manage global signals -export var GlobalSignalsHandler = class extends BasicHandler { +export const GlobalSignalsHandler = class extends BasicHandler { _create(item) { let handlers = []; @@ -135,7 +135,7 @@ export var GlobalSignalsHandler = class extends BasicHandler { * Manage function injection: both instances and prototype can be overridden * and restored */ -export var InjectionsHandler = class extends BasicHandler { +export const InjectionsHandler = class extends BasicHandler { _create(item) { let object = item[0]; @@ -158,7 +158,7 @@ export var InjectionsHandler = class extends BasicHandler { /** * Manage timeouts: the added timeouts have their id reset on completion */ -export var TimeoutsHandler = class extends BasicHandler { +export const TimeoutsHandler = class extends BasicHandler { _create(item) { let name = item[0]; @@ -195,7 +195,7 @@ export var TimeoutsHandler = class extends BasicHandler { // This is wrapper to maintain compatibility with GNOME-Shell 3.30+ as well as // previous versions. -export var DisplayWrapper = { +export const DisplayWrapper = { getScreen() { return global.screen || global.display; }, @@ -210,7 +210,7 @@ export var DisplayWrapper = { }; let unredirectEnabled = true -export var setDisplayUnredirect = (enable) => { +export const setDisplayUnredirect = (enable) => { if (enable && !unredirectEnabled) Meta.enable_unredirect_for_display(global.display); else if (!enable && unredirectEnabled) @@ -219,34 +219,34 @@ export var setDisplayUnredirect = (enable) => { unredirectEnabled = enable; }; -export var getSystemMenuInfo = function() { +export const getSystemMenuInfo = function() { return { name: 'quickSettings', constructor: Main.panel.statusArea.quickSettings.constructor }; } -export var getCurrentWorkspace = function() { +export const getCurrentWorkspace = function() { return DisplayWrapper.getWorkspaceManager().get_active_workspace(); }; -export var getWorkspaceByIndex = function(index) { +export const getWorkspaceByIndex = function(index) { return DisplayWrapper.getWorkspaceManager().get_workspace_by_index(index); }; -export var getWorkspaceCount = function() { +export const getWorkspaceCount = function() { return DisplayWrapper.getWorkspaceManager().n_workspaces; }; -export var getStageTheme = function() { +export const getStageTheme = function() { return St.ThemeContext.get_for_stage(global.stage); }; -export var getScaleFactor = function() { +export const getScaleFactor = function() { return getStageTheme().scale_factor || 1; }; -export var findIndex = function(array, predicate) { +export const findIndex = function(array, predicate) { if (array) { if (Array.prototype.findIndex) { return array.findIndex(predicate); @@ -262,7 +262,7 @@ export var findIndex = function(array, predicate) { return -1; }; -export var find = function(array, predicate) { +export const find = function(array, predicate) { let index = findIndex(array, predicate); if (index > -1) { @@ -270,7 +270,7 @@ export var find = function(array, predicate) { } }; -export var mergeObjects = function(main, bck) { +export const mergeObjects = function(main, bck) { for (var prop in bck) { if (!main.hasOwnProperty(prop) && bck.hasOwnProperty(prop)) { main[prop] = bck[prop]; @@ -280,7 +280,7 @@ export var mergeObjects = function(main, bck) { return main; }; -export var hookVfunc = function(proto, symbol, func) { +export const hookVfunc = function(proto, symbol, func) { if (!func) return if (Gi.gobject_prototype_symbol && proto[Gi.gobject_prototype_symbol]) { @@ -290,14 +290,14 @@ export var hookVfunc = function(proto, symbol, func) { } }; -export var getTrackedActorData = (actor) => { +export const getTrackedActorData = (actor) => { let trackedIndex = Main.layoutManager._findActor(actor); if (trackedIndex >= 0) return Main.layoutManager._trackedActors[trackedIndex] } -export var getTransformedAllocation = function(actor) { +export const getTransformedAllocation = function(actor) { let extents = actor.get_transformed_extents(); let topLeft = extents.get_top_left(); let bottomRight = extents.get_bottom_right(); @@ -305,13 +305,13 @@ export var getTransformedAllocation = function(actor) { return { x1: topLeft.x, x2: bottomRight.x, y1: topLeft.y, y2: bottomRight.y }; }; -export var setClip = function(actor, x, y, width, height) { +export const setClip = function(actor, x, y, width, height) { actor.set_clip(0, 0, width, height); actor.set_position(x, y); actor.set_size(width, height); }; -export var addKeybinding = function(key, settings, handler, modes) { +export const addKeybinding = function(key, settings, handler, modes) { if (!Main.wm._allowedKeybindings[key]) { Main.wm.addKeybinding( key, @@ -323,19 +323,19 @@ export var addKeybinding = function(key, settings, handler, modes) { } }; -export var removeKeybinding = function(key) { +export const removeKeybinding = function(key) { if (Main.wm._allowedKeybindings[key]) { Main.wm.removeKeybinding(key); } }; -export var getrgbColor = function(color) { +export const getrgbColor = function(color) { color = typeof color === 'string' ? Clutter.color_from_string(color)[1] : color; return { red: color.red, green: color.green, blue: color.blue }; }; -export var getrgbaColor = function(color, alpha, offset) { +export const getrgbaColor = function(color, alpha, offset) { if (alpha <= 0) { return 'transparent; '; } @@ -355,14 +355,14 @@ export var getrgbaColor = function(color, alpha, offset) { return 'rgba(' + rgb.red + ',' + rgb.green + ',' + rgb.blue + ',' + (Math.floor(alpha * 100) * 0.01) + '); ' ; }; -export var checkIfColorIsBright = function(color) { +export const checkIfColorIsBright = function(color) { let rgb = getrgbColor(color); let brightness = 0.2126 * rgb.red + 0.7152 * rgb.green + 0.0722 * rgb.blue; return brightness > 128; }; -export var getMouseScrollDirection = function(event) { +export const getMouseScrollDirection = function(event) { let direction; switch (event.get_scroll_direction()) { @@ -379,7 +379,7 @@ export var getMouseScrollDirection = function(event) { return direction; }; -export var checkIfWindowHasTransient = function(window) { +export const checkIfWindowHasTransient = function(window) { let hasTransient; window.foreach_transient(t => !(hasTransient = true)); @@ -387,7 +387,7 @@ export var checkIfWindowHasTransient = function(window) { return hasTransient; }; -export var activateSiblingWindow = function(windows, direction, startWindow) { +export const activateSiblingWindow = function(windows, direction, startWindow) { let windowIndex = windows.indexOf(global.display.focus_window); let nextWindowIndex = windowIndex < 0 ? startWindow ? windows.indexOf(startWindow) : 0 : @@ -404,7 +404,7 @@ export var activateSiblingWindow = function(windows, direction, startWindow) { } }; -export var animateWindowOpacity = function(window, tweenOpts) { +export const animateWindowOpacity = function(window, tweenOpts) { //there currently is a mutter bug with the windowactor opacity, starting with 3.34 //https://gitlab.gnome.org/GNOME/mutter/issues/836 @@ -433,7 +433,7 @@ export var animateWindowOpacity = function(window, tweenOpts) { animate(window, tweenOpts); }; -export var animate = function(actor, options) { +export const animate = function(actor, options) { //the original animations used Tweener instead of Clutter animations, so we //use "time" and "delay" properties defined in seconds, as opposed to Clutter //animations "duration" and "delay" which are defined in milliseconds @@ -466,15 +466,15 @@ export var animate = function(actor, options) { actor.ease.apply(actor, params); } -export var isAnimating = function(actor, prop) { +export const isAnimating = function(actor, prop) { return !!actor.get_transition(prop); } -export var stopAnimations = function(actor) { +export const stopAnimations = function(actor) { actor.remove_all_transitions(); } -export var getIndicators = function(delegate) { +export const getIndicators = function(delegate) { if (delegate instanceof St.BoxLayout) { return delegate; } @@ -482,11 +482,11 @@ export var getIndicators = function(delegate) { return delegate.indicators; } -export var getPoint = function(coords) { +export const getPoint = function(coords) { return new Graphene.Point(coords); } -export var notify = function(text, iconName, action, isTransient) { +export const notify = function(text, iconName, action, isTransient) { let source = new MessageTray.SystemNotificationSource(); let notification = new MessageTray.Notification(source, 'Dash to Panel', text); let notifyFunc = source.showNotification || source.notify; @@ -517,7 +517,7 @@ export var notify = function(text, iconName, action, isTransient) { * it would be clamp to the current one in any case. * Return the amount of shift applied */ -export var ensureActorVisibleInScrollView = function(scrollView, actor, fadeSize, onComplete) { +export const ensureActorVisibleInScrollView = function(scrollView, actor, fadeSize, onComplete) { let vadjustment = scrollView.vscroll.adjustment; let hadjustment = scrollView.hscroll.adjustment; let [vvalue, vlower, vupper, vstepIncrement, vpageIncrement, vpageSize] = vadjustment.get_values(); @@ -574,7 +574,7 @@ export var ensureActorVisibleInScrollView = function(scrollView, actor, fadeSize /** * ColorUtils is adapted from https://github.com/micheleg/dash-to-dock */ -export var ColorUtils = { +export const ColorUtils = { colorLuminance(r, g, b, dlum) { // Darken or brighten color by a fraction dlum // Each rgb value is modified by the same fraction. @@ -685,7 +685,7 @@ const MAX_CACHED_ITEMS = 1000; const BATCH_SIZE_TO_DELETE = 50; const DOMINANT_COLOR_ICON_SIZE = 64; -export var DominantColorExtractor = class { +export const DominantColorExtractor = class { constructor(app){ this._app = app; @@ -875,7 +875,7 @@ export var DominantColorExtractor = class { }; -export var drawRoundedLine = function(cr, x, y, width, height, isRoundLeft, isRoundRight, stroke, fill) { +export const drawRoundedLine = function(cr, x, y, width, height, isRoundLeft, isRoundRight, stroke, fill) { if (height > width) { y += Math.floor((height - width) / 2.0); height = width; diff --git a/windowPreview.js b/windowPreview.js index 1f78a1f..e82c75e 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -62,7 +62,7 @@ let scaleFactor = 1; let animationTime = 0; let aspectRatio = {}; -export var PreviewMenu = GObject.registerClass({ +export const PreviewMenu = GObject.registerClass({ Signals: { 'open-state-changed': {} } }, class PreviewMenu extends St.Widget { @@ -694,7 +694,7 @@ export var PreviewMenu = GObject.registerClass({ } }); -export var Preview = GObject.registerClass({ +export const Preview = GObject.registerClass({ }, class Preview extends St.Widget { _init(previewMenu) { @@ -1112,7 +1112,7 @@ export var Preview = GObject.registerClass({ } }); -export var WindowCloneLayout = GObject.registerClass({ +export const WindowCloneLayout = GObject.registerClass({ }, class WindowCloneLayout extends Clutter.BinLayout { _init(frameRect, bufferRect) { From 285c3862b1275aabcf4124f4872c4019d2ce5196 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:25 -0700 Subject: [PATCH 02/18] fix: remove unused Gtk import --- appIcons.js | 1 - 1 file changed, 1 deletion(-) diff --git a/appIcons.js b/appIcons.js index 2df9d6e..62b7ab7 100644 --- a/appIcons.js +++ b/appIcons.js @@ -26,7 +26,6 @@ import Clutter from 'gi://Clutter'; import Gio from 'gi://Gio'; import GLib from 'gi://GLib'; import Graphene from 'gi://Graphene'; -import Gtk from 'gi://Gtk'; import GObject from 'gi://GObject'; import Mtk from 'gi://Mtk'; import Shell from 'gi://Shell'; From 93f1777878ae2b6bf74fafaa56557fc1ab52901a Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:25 -0700 Subject: [PATCH 03/18] fix: use `St.PolicyType` in the shell process --- taskbar.js | 5 ++--- windowPreview.js | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/taskbar.js b/taskbar.js index 8b7bb42..1b8f270 100644 --- a/taskbar.js +++ b/taskbar.js @@ -27,7 +27,6 @@ import Gio from 'gi://Gio'; import GLib from 'gi://GLib'; import GObject from 'gi://GObject'; import Graphene from 'gi://Graphene'; -import Gtk from 'gi://Gtk'; import Meta from 'gi://Meta'; import Shell from 'gi://Shell'; import St from 'gi://St'; @@ -225,8 +224,8 @@ export const Taskbar = class { this._container = new TaskbarActor(this); this._scrollView = new St.ScrollView({ name: 'dashtopanelScrollview', - hscrollbar_policy: Gtk.PolicyType.NEVER, - vscrollbar_policy: Gtk.PolicyType.NEVER, + hscrollbar_policy: St.PolicyType.NEVER, + vscrollbar_policy: St.PolicyType.NEVER, enable_mouse_scrolling: true }); this._scrollView.connect('leave-event', this._onLeaveEvent.bind(this)); diff --git a/windowPreview.js b/windowPreview.js index e82c75e..a556c5b 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -19,7 +19,6 @@ import GObject from 'gi://GObject'; import Clutter from 'gi://Clutter'; import GLib from 'gi://GLib'; import Graphene from 'gi://Graphene'; -import Gtk from 'gi://Gtk'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import Meta from 'gi://Meta'; import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; @@ -95,8 +94,8 @@ export const PreviewMenu = GObject.registerClass({ this._box = new St.BoxLayout({ vertical: this.isVertical }); this._scrollView = new St.ScrollView({ name: 'dashtopanelPreviewScrollview', - hscrollbar_policy: Gtk.PolicyType.NEVER, - vscrollbar_policy: Gtk.PolicyType.NEVER, + hscrollbar_policy: St.PolicyType.NEVER, + vscrollbar_policy: St.PolicyType.NEVER, enable_mouse_scrolling: true, y_expand: !this.isVertical }); From 70da5672e243e773ef2fe0f480ea08df8408dbae Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:26 -0700 Subject: [PATCH 04/18] fix: use `St.IconTheme` in the shell process --- utils.js | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/utils.js b/utils.js index 0bb9474..9fd74af 100644 --- a/utils.js +++ b/utils.js @@ -26,7 +26,6 @@ import GdkPixbuf from 'gi://GdkPixbuf'; import Gio from 'gi://Gio'; import GLib from 'gi://GLib'; import Graphene from 'gi://Graphene'; -import Gtk from 'gi://Gtk'; import Meta from 'gi://Meta'; import Shell from 'gi://Shell'; import St from 'gi://St'; @@ -696,14 +695,9 @@ export const DominantColorExtractor = class { */ _getIconPixBuf() { let iconTexture = this._app.create_icon_texture(16); - let isGtk3 = !!Gtk.IconTheme.prototype.set_custom_theme; if (themeLoader === null) { - let ifaceSettings = new Gio.Settings({ schema: "org.gnome.desktop.interface" }); - let themeFunc = isGtk3 ? 'set_custom_theme' : 'set_theme_name'; - - themeLoader = new Gtk.IconTheme(), - themeLoader[themeFunc](ifaceSettings.get_string('icon-theme')); // Make sure the correct theme is loaded + themeLoader = new St.IconTheme(); } // Unable to load the icon texture, use fallback @@ -725,19 +719,11 @@ export const DominantColorExtractor = class { // Get the pixel buffer from the icon theme if (iconTexture instanceof Gio.ThemedIcon) { - let params = [iconTexture.get_names()[0], DOMINANT_COLOR_ICON_SIZE, 0]; - - if (!isGtk3) { - params.splice(1, 0, null); - params.splice(3, 1, 1, 1, 1); - } - - let icon_info = themeLoader.lookup_icon.apply(themeLoader, params); + let icon_info = themeLoader.lookup_icon(iconTexture.get_names()[0], + DOMINANT_COLOR_ICON_SIZE, 0); if (icon_info !== null) { - if (isGtk3) return icon_info.load_icon(); - - return GdkPixbuf.Pixbuf.new_from_file(icon_info.get_file().get_path()); + return icon_info.load_icon(); } } From 7bf1de003768b3cf1439bf9328ec1974ea011dad Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:26 -0700 Subject: [PATCH 05/18] refactor: drop backwards-compatibility check Checking for `Main.extensionManager` isn't necessary, since this release of the extension can only support >= GNOME 45. --- extension.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/extension.js b/extension.js index d933e64..9c888a7 100644 --- a/extension.js +++ b/extension.js @@ -106,9 +106,7 @@ export default class DashToPanelExtension extends Extension { } function _enable(extension) { - let ubuntuDock = Main.extensionManager ? - Main.extensionManager.lookup(UBUNTU_DOCK_UUID) : //gnome-shell >= 3.33.4 - ExtensionUtils.extensions[UBUNTU_DOCK_UUID]; + let ubuntuDock = Main.extensionManager.lookup(UBUNTU_DOCK_UUID); if (ubuntuDock && ubuntuDock.stateObj && ubuntuDock.stateObj.dockManager) { // Disable Ubuntu Dock From 05281ab7a0118284073cd4102950a93d0cc70f25 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:27 -0700 Subject: [PATCH 06/18] cleanup: drop unnecessary call to `initTranslations()` --- extension.js | 2 -- prefs.js | 1 - 2 files changed, 3 deletions(-) diff --git a/extension.js b/extension.js index 9c888a7..c5b6945 100644 --- a/extension.js +++ b/extension.js @@ -56,8 +56,6 @@ export default class DashToPanelExtension extends Extension { console.log(`Initiating ${this.uuid}`); this._realHasOverview = Main.sessionMode.hasOverview; - - this.initTranslations(); //create an object that persists until gnome-shell is restarted, even if the extension is disabled PERSISTENTSTORAGE = {}; diff --git a/prefs.js b/prefs.js index 2e78629..7069bca 100644 --- a/prefs.js +++ b/prefs.js @@ -2332,7 +2332,6 @@ const BuilderScope = GObject.registerClass({ export default class DashToPanelPreferences extends ExtensionPreferences { fillPreferencesWindow(window) { window._settings = this.getSettings('org.gnome.shell.extensions.dash-to-panel'); - this.initTranslations(); // use default width or window window.set_default_size(0, 740); From 20b692ab40ab462e9c09ce90229ca1779fe246df Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:27 -0700 Subject: [PATCH 07/18] fix: use GSettings constructor for desktop settings --- extension.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension.js b/extension.js index c5b6945..80a0776 100644 --- a/extension.js +++ b/extension.js @@ -125,7 +125,7 @@ function _enable(extension) { if (panelManager) return; //already initialized SETTINGS = extension.getSettings('org.gnome.shell.extensions.dash-to-panel'); - DESKTOPSETTINGS = extension.getSettings('org.gnome.desktop.interface'); + DESKTOPSETTINGS = new Gio.Settings({schema_id: 'org.gnome.desktop.interface'}); EXTENSION_UUID = extension.uuid EXTENSION_PATH = extension.path From 5ced13a32461a576c051b8b7a013055ee9ab5cfd Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:28 -0700 Subject: [PATCH 08/18] fix: null DESKTOPSETTINGS on disable --- extension.js | 1 + 1 file changed, 1 insertion(+) diff --git a/extension.js b/extension.js index 80a0776..c1fac4e 100644 --- a/extension.js +++ b/extension.js @@ -85,6 +85,7 @@ export default class DashToPanelExtension extends Extension { DTP_EXTENSION = null; SETTINGS = null; + DESKTOPSETTINGS = null; panelManager = null; if (!reset) { From f68e860d43e58b1d1c97fe345147045aec097615 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:28 -0700 Subject: [PATCH 09/18] refactor: remove unused imports --- appIcons.js | 5 ----- extension.js | 7 ------- intellihide.js | 1 - overview.js | 3 --- panel.js | 7 ------- panelManager.js | 6 ------ panelStyle.js | 8 -------- prefs.js | 3 --- proximity.js | 1 - taskbar.js | 5 ----- transparency.js | 4 ---- utils.js | 1 - windowPreview.js | 4 ---- 13 files changed, 55 deletions(-) diff --git a/appIcons.js b/appIcons.js index 62b7ab7..ba9b3ca 100644 --- a/appIcons.js +++ b/appIcons.js @@ -24,24 +24,19 @@ import Clutter from 'gi://Clutter'; import Gio from 'gi://Gio'; -import GLib from 'gi://GLib'; import Graphene from 'gi://Graphene'; import GObject from 'gi://GObject'; import Mtk from 'gi://Mtk'; import Shell from 'gi://Shell'; import St from 'gi://St'; -import * as Config from 'resource:///org/gnome/shell/misc/config.js'; import * as AppDisplay from 'resource:///org/gnome/shell/ui/appDisplay.js'; import * as AppMenu from 'resource:///org/gnome/shell/ui/appMenu.js'; -import * as AppFavorites from 'resource:///org/gnome/shell/ui/appFavorites.js'; import * as Dash from 'resource:///org/gnome/shell/ui/dash.js'; import * as DND from 'resource:///org/gnome/shell/ui/dnd.js'; -import * as IconGrid from 'resource:///org/gnome/shell/ui/iconGrid.js'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; import * as Util from 'resource:///org/gnome/shell/misc/util.js'; -import * as Workspace from 'resource:///org/gnome/shell/ui/workspace.js'; import * as BoxPointer from 'resource:///org/gnome/shell/ui/boxpointer.js'; import * as Utils from './utils.js'; diff --git a/extension.js b/extension.js index c1fac4e..7e344a0 100644 --- a/extension.js +++ b/extension.js @@ -19,13 +19,7 @@ import * as Main from 'resource:///org/gnome/shell/ui/main.js'; -import Meta from 'gi://Meta'; import Gio from 'gi://Gio'; -import GLib from 'gi://GLib'; -import Shell from 'gi://Shell'; -import St from 'gi://St'; -import * as WindowManager from 'resource:///org/gnome/shell/ui/windowManager.js'; -import * as ExtensionUtils from 'resource:///org/gnome/shell/misc/extensionUtils.js';; import * as PanelManager from './panelManager.js'; import * as Utils from './utils.js'; @@ -33,7 +27,6 @@ import * as AppIcons from './appIcons.js'; import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; -const Mainloop = imports.mainloop; const {signals: Signals} = imports; const UBUNTU_DOCK_UUID = 'ubuntu-dock@ubuntu.com'; diff --git a/intellihide.js b/intellihide.js index 808016a..ea5873c 100644 --- a/intellihide.js +++ b/intellihide.js @@ -26,7 +26,6 @@ import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import * as OverviewControls from 'resource:///org/gnome/shell/ui/overviewControls.js'; import * as PointerWatcher from 'resource:///org/gnome/shell/ui/pointerWatcher.js'; -import * as Panel from './panel.js'; import * as Proximity from './proximity.js'; import * as Utils from './utils.js'; import {SETTINGS} from './extension.js'; diff --git a/overview.js b/overview.js index d39f115..9ce980f 100644 --- a/overview.js +++ b/overview.js @@ -28,13 +28,10 @@ import Gio from 'gi://Gio'; import Shell from 'gi://Shell'; 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 * as WindowManager from 'resource:///org/gnome/shell/ui/windowManager.js'; import {WindowPreview} from 'resource:///org/gnome/shell/ui/windowPreview.js'; import {SETTINGS} from './extension.js'; -import Meta from 'gi://Meta'; - const GS_HOTKEYS_KEY = 'switch-to-application-'; // When the dash is shown, workspace window preview bottom labels go over it (default diff --git a/panel.js b/panel.js index 041d60d..62cd29d 100644 --- a/panel.js +++ b/panel.js @@ -28,8 +28,6 @@ */ import Clutter from 'gi://Clutter'; -import * as Config from 'resource:///org/gnome/shell/misc/config.js'; -import Gtk from 'gi://Gtk'; import GObject from 'gi://GObject'; import * as AppIcons from './appIcons.js'; import * as Utils from './utils.js'; @@ -43,13 +41,11 @@ import * as Dash from 'resource:///org/gnome/shell/ui/dash.js'; import * as CtrlAltTab from 'resource:///org/gnome/shell/ui/ctrlAltTab.js'; import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js'; import St from 'gi://St'; -import GLib from 'gi://GLib'; import Meta from 'gi://Meta'; import Pango from 'gi://Pango'; import * as DND from 'resource:///org/gnome/shell/ui/dnd.js'; import Shell from 'gi://Shell'; import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; -import * as IconGrid from 'resource:///org/gnome/shell/ui/iconGrid.js'; import * as DateMenu from 'resource:///org/gnome/shell/ui/dateMenu.js'; import * as Volume from 'resource:///org/gnome/shell/ui/status/volume.js'; import * as Progress from './progress.js'; @@ -59,9 +55,6 @@ import * as Transparency from './transparency.js'; import {SETTINGS, DESKTOPSETTINGS, PERSISTENTSTORAGE} from './extension.js'; import {gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; -const Mainloop = imports.mainloop; -const Gi = imports._gi; - let tracker = Shell.WindowTracker.get_default(); export const panelBoxes = ['_leftBox', '_centerBox', '_rightBox']; diff --git a/panelManager.js b/panelManager.js index f74be84..48578e2 100755 --- a/panelManager.js +++ b/panelManager.js @@ -31,7 +31,6 @@ import * as Overview from './overview.js'; import * as Panel from './panel.js'; import * as PanelSettings from './panelSettings.js'; import * as Proximity from './proximity.js'; -import * as Taskbar from './taskbar.js'; import * as Utils from './utils.js'; import * as DesktopIconsIntegration from './desktopIconsIntegration.js'; @@ -42,19 +41,14 @@ import Meta from 'gi://Meta'; import Shell from 'gi://Shell'; import St from 'gi://St'; -import * as AppDisplay from 'resource:///org/gnome/shell/ui/appDisplay.js'; import * as BoxPointer from 'resource:///org/gnome/shell/ui/boxpointer.js'; -import * as Dash from 'resource:///org/gnome/shell/ui/dash.js'; -import * as IconGrid from 'resource:///org/gnome/shell/ui/iconGrid.js'; import * as LookingGlass from 'resource:///org/gnome/shell/ui/lookingGlass.js'; 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; export const PanelManager = class { diff --git a/panelStyle.js b/panelStyle.js index 291683f..e4b1f8e 100644 --- a/panelStyle.js +++ b/panelStyle.js @@ -21,17 +21,9 @@ * mathematical.coffee@gmail.com */ -import * as ExtensionUtils from 'resource:///org/gnome/shell/misc/extensionUtils.js';; -import * as Main from 'resource:///org/gnome/shell/ui/main.js'; -import St from 'gi://St'; -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; export const PanelStyle = class { diff --git a/prefs.js b/prefs.js index 7069bca..ace8553 100644 --- a/prefs.js +++ b/prefs.js @@ -25,7 +25,6 @@ import Gio from 'gi://Gio'; import GLib from 'gi://GLib'; import GObject from 'gi://GObject'; import Gtk from 'gi://Gtk'; -import Adw from 'gi://Adw'; import Gdk from 'gi://Gdk'; import * as PanelSettings from './panelSettings.js'; @@ -35,8 +34,6 @@ import {ExtensionPreferences, gettext as _, ngettext} from 'resource:///org/gnom const Mainloop = imports.mainloop; -const N_ = function(e) { return e }; - const SCALE_UPDATE_TIMEOUT = 500; const DEFAULT_PANEL_SIZES = [ 128, 96, 64, 48, 32, 24, 16 ]; const DEFAULT_FONT_SIZES = [ 96, 64, 48, 32, 24, 16, 0 ]; diff --git a/proximity.js b/proximity.js index 2221833..eff1548 100644 --- a/proximity.js +++ b/proximity.js @@ -18,7 +18,6 @@ import Meta from 'gi://Meta'; import Mtk from 'gi://Mtk'; -import * as Layout from 'resource:///org/gnome/shell/ui/layout.js'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import * as Utils from './utils.js'; diff --git a/taskbar.js b/taskbar.js index 1b8f270..b3055f6 100644 --- a/taskbar.js +++ b/taskbar.js @@ -27,20 +27,15 @@ import Gio from 'gi://Gio'; import GLib from 'gi://GLib'; import GObject from 'gi://GObject'; import Graphene from 'gi://Graphene'; -import Meta from 'gi://Meta'; import Shell from 'gi://Shell'; import St from 'gi://St'; import * as AppFavorites from 'resource:///org/gnome/shell/ui/appFavorites.js'; import * as Dash from 'resource:///org/gnome/shell/ui/dash.js'; import * as DND from 'resource:///org/gnome/shell/ui/dnd.js'; -import * as IconGrid from 'resource:///org/gnome/shell/ui/iconGrid.js'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; -import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; -import * as Workspace from 'resource:///org/gnome/shell/ui/workspace.js'; import * as AppIcons from './appIcons.js'; -import * as Panel from './panel.js'; import * as PanelManager from './panelManager.js'; import * as PanelSettings from './panelSettings.js'; import * as Pos from './panelPositions.js'; diff --git a/transparency.js b/transparency.js index e9691a5..25ff00f 100644 --- a/transparency.js +++ b/transparency.js @@ -15,14 +15,10 @@ * along with this program. If not, see . */ -import Clutter from 'gi://Clutter'; import GdkPixbuf from 'gi://GdkPixbuf'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; -import Meta from 'gi://Meta'; import St from 'gi://St'; -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'; diff --git a/utils.js b/utils.js index 9fd74af..26c125d 100644 --- a/utils.js +++ b/utils.js @@ -29,7 +29,6 @@ import Graphene from 'gi://Graphene'; import Meta from 'gi://Meta'; import Shell from 'gi://Shell'; import St from 'gi://St'; -import * as Config from 'resource:///org/gnome/shell/misc/config.js'; import * as Util from 'resource:///org/gnome/shell/misc/util.js'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js'; diff --git a/windowPreview.js b/windowPreview.js index a556c5b..dce7af6 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -23,16 +23,12 @@ import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import Meta from 'gi://Meta'; import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; import St from 'gi://St'; -import * as WindowManager from 'resource:///org/gnome/shell/ui/windowManager.js'; -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: Signals} = imports; //timeout intervals const ENSURE_VISIBLE_MS = 200; From 66a387eaf7078234c3f40c9ec4ce7ec05c59c342 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:29 -0700 Subject: [PATCH 10/18] fix: add missing gettext import --- windowPreview.js | 1 + 1 file changed, 1 insertion(+) diff --git a/windowPreview.js b/windowPreview.js index dce7af6..88b10c9 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -27,6 +27,7 @@ import St from 'gi://St'; import * as Taskbar from './taskbar.js'; import * as Utils from './utils.js'; import {SETTINGS, DESKTOPSETTINGS} from './extension.js'; +import {gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; const Mainloop = imports.mainloop; From 351d86e10ad8d574f64e8c18eeff38dc9a7c3af9 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:29 -0700 Subject: [PATCH 11/18] fix: use ESModule for Cairo --- progress.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progress.js b/progress.js index 40c21b4..c7cd944 100644 --- a/progress.js +++ b/progress.js @@ -19,6 +19,7 @@ * This file is based on code from the Dash to Dock extension by micheleg */ +import Cairo from 'cairo'; import Gio from 'gi://Gio'; import Clutter from 'gi://Clutter'; import Pango from 'gi://Pango'; @@ -26,7 +27,6 @@ import St from 'gi://St'; import * as Utils from './utils.js'; import {SETTINGS} from './extension.js'; -const Cairo = imports.cairo; const {signals: Signals} = imports; From c565aa514a257221718c880efd6121422dcc1cb1 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:30 -0700 Subject: [PATCH 12/18] refactor: derive from EventEmitter Instead of using the legacy import and adding signal methods, just derive from EventEmitter. --- appIcons.js | 7 ++++--- extension.js | 11 +++++------ progress.js | 12 +++++++----- taskbar.js | 8 ++++---- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/appIcons.js b/appIcons.js index ba9b3ca..2ca2b16 100644 --- a/appIcons.js +++ b/appIcons.js @@ -38,6 +38,7 @@ import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; import * as Util from 'resource:///org/gnome/shell/misc/util.js'; import * as BoxPointer from 'resource:///org/gnome/shell/ui/boxpointer.js'; +import {EventEmitter} from 'resource:///org/gnome/shell/misc/signals.js'; import * as Utils from './utils.js'; import * as PanelSettings from './panelSettings.js'; @@ -47,7 +48,6 @@ import {DTP_EXTENSION, SETTINGS, DESKTOPSETTINGS, EXTENSION_PATH} from './extens import {gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; const Mainloop = imports.mainloop; -const {signals: Signals} = imports; //timeout names const T2 = 'mouseScrollTimeout'; @@ -1581,9 +1581,11 @@ export function ItemShowLabel() { * use of this class in place of the original showAppsButton. * */ -export const ShowAppsIconWrapper = class { +export const ShowAppsIconWrapper = class extends EventEmitter { constructor(dtpPanel) { + super(); + this.realShowAppsIcon = new Dash.ShowAppsIcon(); /* the variable equivalent to toggleButton has a different name in the appIcon class @@ -1725,7 +1727,6 @@ export const ShowAppsIconWrapper = class { this.realShowAppsIcon.destroy(); } }; -Signals.addSignalMethods(ShowAppsIconWrapper.prototype); /** * A menu for the showAppsIcon diff --git a/extension.js b/extension.js index 7e344a0..4dc3162 100644 --- a/extension.js +++ b/extension.js @@ -18,16 +18,16 @@ */ -import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import Gio from 'gi://Gio'; +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +import {EventEmitter} from 'resource:///org/gnome/shell/misc/signals.js'; +import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; + import * as PanelManager from './panelManager.js'; import * as Utils from './utils.js'; import * as AppIcons from './appIcons.js'; -import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; - -const {signals: Signals} = imports; const UBUNTU_DOCK_UUID = 'ubuntu-dock@ubuntu.com'; @@ -67,8 +67,7 @@ export default class DashToPanelExtension extends Extension { }); //create a global object that can emit signals and conveniently expose functionalities to other extensions - global.dashToPanel = {}; - Signals.addSignalMethods(global.dashToPanel); + global.dashToPanel = new EventEmitter(); _enable(this); } diff --git a/progress.js b/progress.js index c7cd944..f12e820 100644 --- a/progress.js +++ b/progress.js @@ -27,12 +27,14 @@ import St from 'gi://St'; import * as Utils from './utils.js'; import {SETTINGS} from './extension.js'; -const {signals: Signals} = imports; +import {EventEmitter} from 'resource:///org/gnome/shell/misc/signals.js'; -export const ProgressManager = class { +export const ProgressManager = class extends EventEmitter { constructor() { + super(); + this._entriesByDBusName = {}; this._launcher_entry_dbus_signal_id = @@ -163,11 +165,12 @@ export const ProgressManager = class { } } }; -Signals.addSignalMethods(ProgressManager.prototype); -export class AppProgress { +export class AppProgress extends EventEmitter { constructor(dbusName, appId, properties) { + super(); + this._dbusName = dbusName; this._appId = appId; this._count = 0; @@ -278,7 +281,6 @@ export class AppProgress { } } }; -Signals.addSignalMethods(AppProgress.prototype); export const ProgressIndicator = class { diff --git a/taskbar.js b/taskbar.js index b3055f6..0399855 100644 --- a/taskbar.js +++ b/taskbar.js @@ -34,6 +34,7 @@ import * as AppFavorites from 'resource:///org/gnome/shell/ui/appFavorites.js'; import * as Dash from 'resource:///org/gnome/shell/ui/dash.js'; import * as DND from 'resource:///org/gnome/shell/ui/dnd.js'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +import {EventEmitter} from 'resource:///org/gnome/shell/misc/signals.js'; import * as AppIcons from './appIcons.js'; import * as PanelManager from './panelManager.js'; @@ -44,7 +45,6 @@ import * as WindowPreview from './windowPreview.js'; import {SETTINGS} from './extension.js'; const Mainloop = imports.mainloop; -const {signals: Signals} = imports; const SearchController = Main.overview.searchController; export const DASH_ANIMATION_TIME = Dash.DASH_ANIMATION_TIME / (Dash.DASH_ANIMATION_TIME > 1 ? 1000 : 1); @@ -194,9 +194,11 @@ export const TaskbarActor = GObject.registerClass({ * - Sync minimization application target position. */ -export const Taskbar = class { +export const Taskbar = class extends EventEmitter { constructor(panel) { + super(); + this.dtpPanel = panel; // start at smallest size due to running indicator drawing area expanding but not shrinking @@ -1321,8 +1323,6 @@ export const Taskbar = class { } }; -Signals.addSignalMethods(Taskbar.prototype); - const CloneContainerConstraint = GObject.registerClass({ }, class CloneContainerConstraint extends Clutter.BindConstraint { From b0114216a2e7ab0defa9eaca85c672c59913299f Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:30 -0700 Subject: [PATCH 13/18] cleanup: remove extraneous semi-colons and tabs --- appIcons.js | 6 +++--- prefs.js | 2 +- progress.js | 2 +- taskbar.js | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/appIcons.js b/appIcons.js index 2ca2b16..c513aae 100644 --- a/appIcons.js +++ b/appIcons.js @@ -579,7 +579,7 @@ export const TaskbarAppIcon = GObject.registerClass({ let highlightMargin = this._focusedIsWide ? SETTINGS.get_int('dot-size') : 0; if(!this.window) { - let containerWidth = this._dtpIconContainer.get_width() / Utils.getScaleFactor();; + let containerWidth = this._dtpIconContainer.get_width() / Utils.getScaleFactor(); let backgroundSize = containerWidth + "px " + (containerWidth - (pos == DOT_POSITION.BOTTOM ? highlightMargin : 0)) + "px;"; @@ -1495,7 +1495,7 @@ export class TaskbarSecondaryMenu extends AppMenu.AppMenu { Mainloop.idle_add(() => windows.forEach((w) => !!w.get_compositor_private() && w.delete(time++))) } -}; +} /** * This function is used for extendDashItemContainer @@ -1567,7 +1567,7 @@ export function ItemShowLabel() { time: duration, transition: 'easeOutQuad', }); -}; +} /** * A wrapper class around the ShowAppsIcon class. diff --git a/prefs.js b/prefs.js index ace8553..e258b3c 100644 --- a/prefs.js +++ b/prefs.js @@ -151,7 +151,7 @@ function mergeObjects(main, bck) { } return main; -}; +} const Preferences = class { diff --git a/progress.js b/progress.js index f12e820..473b19d 100644 --- a/progress.js +++ b/progress.js @@ -280,7 +280,7 @@ export class AppProgress extends EventEmitter { } } } -}; +} export const ProgressIndicator = class { diff --git a/taskbar.js b/taskbar.js index 0399855..81e9e9f 100644 --- a/taskbar.js +++ b/taskbar.js @@ -67,7 +67,7 @@ const T3 = 'resetHoverTimeout' export function extendDashItemContainer(dashItemContainer) { dashItemContainer.showLabel = AppIcons.ItemShowLabel; -}; +} const iconAnimationSettings = { _getDictValue(key) { @@ -308,9 +308,9 @@ export const Taskbar = class extends EventEmitter { } ], [ - this._appSystem, - 'app-state-changed', - this._queueRedisplay.bind(this) + this._appSystem, + 'app-state-changed', + this._queueRedisplay.bind(this) ], [ AppFavorites.getAppFavorites(), From 08bd792ae7cb543330caf6a3bc39a4ab776ca1df Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:31 -0700 Subject: [PATCH 14/18] refactor: port away from Mainloop --- appIcons.js | 17 ++++++++++------- prefs.js | 36 +++++++++++++++++------------------- taskbar.js | 12 ++++++++---- utils.js | 7 ++++--- windowPreview.js | 6 +++--- 5 files changed, 42 insertions(+), 36 deletions(-) diff --git a/appIcons.js b/appIcons.js index c513aae..2d80a09 100644 --- a/appIcons.js +++ b/appIcons.js @@ -23,6 +23,7 @@ import Clutter from 'gi://Clutter'; +import Gio from 'gi://GLib'; import Gio from 'gi://Gio'; import Graphene from 'gi://Graphene'; import GObject from 'gi://GObject'; @@ -47,8 +48,6 @@ import * as Progress from './progress.js'; import {DTP_EXTENSION, SETTINGS, DESKTOPSETTINGS, EXTENSION_PATH} from './extension.js'; import {gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; -const Mainloop = imports.mainloop; - //timeout names const T2 = 'mouseScrollTimeout'; const T3 = 'showDotsTimeout'; @@ -1336,9 +1335,10 @@ export function cycleThroughWindows(app, reversed, shouldMinimize, monitor) { app_windows.push("MINIMIZE"); if (recentlyClickedAppLoopId > 0) - Mainloop.source_remove(recentlyClickedAppLoopId); + GLib.Source.remove(recentlyClickedAppLoopId); - recentlyClickedAppLoopId = Mainloop.timeout_add(MEMORY_TIME, resetRecentlyClickedApp); + recentlyClickedAppLoopId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, + MEMORY_TIME, resetRecentlyClickedApp); // If there isn't already a list of windows for the current app, // or the stored list is outdated, use the current windows list. @@ -1368,7 +1368,7 @@ export function cycleThroughWindows(app, reversed, shouldMinimize, monitor) { export function resetRecentlyClickedApp() { if (recentlyClickedAppLoopId > 0) - Mainloop.source_remove(recentlyClickedAppLoopId); + GLib.Source.remove(recentlyClickedAppLoopId); recentlyClickedAppLoopId=0; recentlyClickedApp =null; @@ -1491,9 +1491,12 @@ export class TaskbarSecondaryMenu extends AppMenu.AppMenu { if (windows.length == this._app.get_windows().length) this._app.request_quit() + + GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => { + windows.forEach((w) => !!w.get_compositor_private() && w.delete(time++)); - Mainloop.idle_add(() => - windows.forEach((w) => !!w.get_compositor_private() && w.delete(time++))) + return GLib.SOURCE_REMOVE; + }); } } diff --git a/prefs.js b/prefs.js index e258b3c..bc16ad5 100644 --- a/prefs.js +++ b/prefs.js @@ -32,8 +32,6 @@ import * as Pos from './panelPositions.js'; import {ExtensionPreferences, gettext as _, ngettext} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; -const Mainloop = imports.mainloop; - const SCALE_UPDATE_TIMEOUT = 500; const DEFAULT_PANEL_SIZES = [ 128, 96, 64, 48, 32, 24, 16 ]; const DEFAULT_FONT_SIZES = [ 96, 64, 48, 32, 24, 16, 0 ]; @@ -2225,9 +2223,9 @@ const BuilderScope = GObject.registerClass({ panel_size_scale_value_changed_cb(scale) { // Avoid settings the size continuously if (this._preferences._panel_size_timeout > 0) - Mainloop.source_remove(this._preferences._panel_size_timeout); + GLib.Source.remove(this._preferences._panel_size_timeout); - this._preferences._panel_size_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, (() => { + this._preferences._panel_size_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => { const value = scale.get_value(); const monitorSync = this._preferences._settings.get_boolean('panel-element-positions-monitors-sync'); const monitorsToSetFor = monitorSync ? this._preferences.monitors : [this._preferences._currentMonitorIndex]; @@ -2237,15 +2235,15 @@ const BuilderScope = GObject.registerClass({ this._preferences._panel_size_timeout = 0; return GLib.SOURCE_REMOVE; - })); + }); } tray_size_scale_value_changed_cb(scale) { // Avoid settings the size consinuosly if (this._preferences._tray_size_timeout > 0) - Mainloop.source_remove(this._preferences._tray_size_timeout); + GLib.Source.remove(this._preferences._tray_size_timeout); - this._preferences._tray_size_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => { + this._preferences._tray_size_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => {) this._preferences._settings.set_int('tray-size', scale.get_value()); this._preferences._tray_size_timeout = 0; return GLib.SOURCE_REMOVE; @@ -2255,9 +2253,9 @@ const BuilderScope = GObject.registerClass({ leftbox_size_scale_value_changed_cb(scale) { // Avoid settings the size consinuosly if (this._preferences._leftbox_size_timeout > 0) - Mainloop.source_remove(this._preferences._leftbox_size_timeout); + GLib.Source.remove(this._preferences._leftbox_size_timeout); - this._preferences._leftbox_size_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => { + this._preferences._leftbox_size_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => { this._preferences._settings.set_int('leftbox-size', scale.get_value()); this._preferences._leftbox_size_timeout = 0; return GLib.SOURCE_REMOVE; @@ -2267,9 +2265,9 @@ const BuilderScope = GObject.registerClass({ appicon_margin_scale_value_changed_cb(scale) { // Avoid settings the size consinuosly if (this._preferences._appicon_margin_timeout > 0) - Mainloop.source_remove(this._preferences._appicon_margin_timeout); + GLib.Source.remove(this._preferences._appicon_margin_timeout); - this._preferences._appicon_margin_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => { + this._preferences._appicon_margin_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => { this._preferences._settings.set_int('appicon-margin', scale.get_value()); this._preferences._appicon_margin_timeout = 0; return GLib.SOURCE_REMOVE; @@ -2279,9 +2277,9 @@ const BuilderScope = GObject.registerClass({ appicon_padding_scale_value_changed_cb(scale) { // Avoid settings the size consinuosly if (this._preferences._appicon_padding_timeout > 0) - Mainloop.source_remove(this._preferences._appicon_padding_timeout); + GLib.Source.remove(this._preferences._appicon_padding_timeout); - this._preferences._appicon_padding_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => { + this._preferences._appicon_padding_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => { this._preferences._settings.set_int('appicon-padding', scale.get_value()); this._preferences._appicon_padding_timeout = 0; return GLib.SOURCE_REMOVE; @@ -2291,9 +2289,9 @@ const BuilderScope = GObject.registerClass({ tray_padding_scale_value_changed_cb(scale) { // Avoid settings the size consinuosly if (this._preferences._tray_padding_timeout > 0) - Mainloop.source_remove(this._preferences._tray_padding_timeout); + GLib.Source.remove(this._preferences._tray_padding_timeout); - this._preferences._tray_padding_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => { + this._preferences._tray_padding_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => { this._preferences._settings.set_int('tray-padding', scale.get_value()); this._preferences._tray_padding_timeout = 0; return GLib.SOURCE_REMOVE; @@ -2303,9 +2301,9 @@ const BuilderScope = GObject.registerClass({ statusicon_padding_scale_value_changed_cb(scale) { // Avoid settings the size consinuosly if (this._preferences._statusicon_padding_timeout > 0) - Mainloop.source_remove(this._preferences._statusicon_padding_timeout); + GLib.Source.remove(this._preferences._statusicon_padding_timeout); - this._preferences._statusicon_padding_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => { + this._preferences._statusicon_padding_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => { this._preferences._settings.set_int('status-icon-padding', scale.get_value()); this._preferences._statusicon_padding_timeout = 0; return GLib.SOURCE_REMOVE; @@ -2315,9 +2313,9 @@ const BuilderScope = GObject.registerClass({ leftbox_padding_scale_value_changed_cb(scale) { // Avoid settings the size consinuosly if (this._preferences._leftbox_padding_timeout > 0) - Mainloop.source_remove(this._preferences._leftbox_padding_timeout); + GLib.Source.remove(this._preferences._leftbox_padding_timeout); - this._preferences._leftbox_padding_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => { + this._preferences._leftbox_padding_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => { this._preferences._settings.set_int('leftbox-padding', scale.get_value()); this._preferences._leftbox_padding_timeout = 0; return GLib.SOURCE_REMOVE; diff --git a/taskbar.js b/taskbar.js index 81e9e9f..b738544 100644 --- a/taskbar.js +++ b/taskbar.js @@ -44,7 +44,6 @@ import * as Utils from './utils.js'; import * as WindowPreview from './windowPreview.js'; import {SETTINGS} from './extension.js'; -const Mainloop = imports.mainloop; const SearchController = Main.overview.searchController; export const DASH_ANIMATION_TIME = Dash.DASH_ANIMATION_TIME / (Dash.DASH_ANIMATION_TIME > 1 ? 1000 : 1); @@ -560,9 +559,11 @@ export const Taskbar = class extends EventEmitter { } if (initial != this.fullScrollView && !this._waitIdleId) { - this._waitIdleId = Mainloop.idle_add(() => { + this._waitIdleId = GLib.idle_add(() => { this._getAppIcons().forEach(a => a.updateTitleStyle()) - this._waitIdleId = 0 + this._waitIdleId = 0; + + return GLib.SOURCE_REMOVE; }); } } @@ -1433,7 +1434,10 @@ export const TaskbarItemContainer = GObject.registerClass({ this._raisedClone.connect('destroy', () => { adjustment.disconnect(adjustmentChangedId); taskbarBox.disconnect(taskbarBoxAllocationChangedId); - Mainloop.idle_add(() => cloneContainer.destroy()); + GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => { + cloneContainer.destroy(); + return GLib.SOURCE_REMOVE; + }); delete this._raisedClone; }); diff --git a/utils.js b/utils.js index 26c125d..7a2fe2e 100644 --- a/utils.js +++ b/utils.js @@ -34,7 +34,6 @@ import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js'; const Gi = imports._gi; -const Mainloop = imports.mainloop; var SCROLL_TIME = Util.SCROLL_TIME / (Util.SCROLL_TIME > 1 ? 1000 : 1); @@ -165,9 +164,11 @@ export const TimeoutsHandler = class extends BasicHandler { this._remove(item); - this[name] = Mainloop.timeout_add(delay, () => { + this[name] = GLib.timeout_add(GLib.PRIORITY_DEFAULT, delay, () => { this[name] = 0; timeoutHandler(); + + return GLib.SOURCE_REMOVE; }); return [[name]]; @@ -181,7 +182,7 @@ export const TimeoutsHandler = class extends BasicHandler { let name = item[0]; if (this[name]) { - Mainloop.source_remove(this[name]); + GLib.Source.remove(this[name]); this[name] = 0; } } diff --git a/windowPreview.js b/windowPreview.js index 88b10c9..d9c1d67 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -29,8 +29,6 @@ import * as Utils from './utils.js'; import {SETTINGS, DESKTOPSETTINGS} from './extension.js'; import {gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; -const Mainloop = imports.mainloop; - //timeout intervals const ENSURE_VISIBLE_MS = 200; @@ -807,12 +805,14 @@ export const Preview = GObject.registerClass({ this._addClone(cloneBin, animateSize); this._previewMenu.updatePosition(); } else if (!this._waitWindowId) { - this._waitWindowId = Mainloop.idle_add(() => { + this._waitWindowId = GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => { this._waitWindowId = 0; if (this._previewMenu.opened) { _assignWindowClone(); } + + return GLib.SOURCE_REMOVE; }); } }; From f588ab7218c9a9c059e8da43bdf189f441e38580 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 19:22:32 -0700 Subject: [PATCH 15/18] fix: correct call to `disable()` --- extension.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension.js b/extension.js index 4dc3162..aec4c8d 100644 --- a/extension.js +++ b/extension.js @@ -111,7 +111,7 @@ function _enable(extension) { //reset to prevent conflicts with the ubuntu-dock if (panelManager) { - disable(true); + extension.disable(true); } } From f3257803faff04201a8ea3b7862cebb747b837c3 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 22:34:50 -0700 Subject: [PATCH 16/18] fix: disconnect handlers in disable() --- extension.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/extension.js b/extension.js index aec4c8d..f732d3a 100644 --- a/extension.js +++ b/extension.js @@ -33,6 +33,7 @@ const UBUNTU_DOCK_UUID = 'ubuntu-dock@ubuntu.com'; let panelManager; let extensionChangedHandler; +let startupCompleteHandler; let disabledUbuntuDock; let extensionSystem = Main.extensionManager; @@ -92,6 +93,11 @@ export default class DashToPanelExtension extends Extension { AppIcons.resetRecentlyClickedApp(); } + if (startupCompleteHandler) { + Main.layoutManager.disconnect(startupCompleteHandler); + startupCompleteHandler = null; + } + Main.sessionMode.hasOverview = this._realHasOverview; } } @@ -126,7 +132,7 @@ function _enable(extension) { if (SETTINGS.get_boolean('hide-overview-on-startup') && Main.layoutManager._startingUp) { Main.sessionMode.hasOverview = false; - Main.layoutManager.connect('startup-complete', () => { + startupCompleteHandler = Main.layoutManager.connect('startup-complete', () => { Main.sessionMode.hasOverview = extension._realHasOverview }); } From 3c7eac5f2399f9aeb27f4bfee6f3a1c1df2e9534 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 22:55:42 -0700 Subject: [PATCH 17/18] refactor: use GLib.find_program_in_path() Use the more efficient built-in for checking if a program is in the PATH. --- appIcons.js | 2 +- utils.js | 25 ------------------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/appIcons.js b/appIcons.js index 2d80a09..fedf226 100644 --- a/appIcons.js +++ b/appIcons.js @@ -1833,7 +1833,7 @@ export const MyShowAppsIconMenu = class extends PopupMenu.PopupMenu { // Only add menu entries for commands that exist in path _appendItem(info) { - if (Utils.checkIfCommandExists(info.cmd[0])) { + if (GLib.find_program_in_path(info.cmd[0])) { let item = this._appendMenuItem(_(info.title)); item.connect('activate', function() { diff --git a/utils.js b/utils.js index 7a2fe2e..8e5348d 100644 --- a/utils.js +++ b/utils.js @@ -893,28 +893,3 @@ export const drawRoundedLine = function(cr, x, y, width, height, isRoundLeft, is cr.setSource(stroke); cr.stroke(); } - -/** - * Check if an app exists in the system. - */ -var checkedCommandsMap = new Map(); - -export function checkIfCommandExists(app) { - let answer = checkedCommandsMap.get(app); - if (answer === undefined) { - // Command is a shell built in, use shell to call it. - // Quotes around app value are important. They let command operate - // on the whole value, instead of having shell interpret it. - let cmd = "sh -c 'command -v \"" + app + "\"'"; - try { - let out = GLib.spawn_command_line_sync(cmd); - // out contains 1: stdout, 2: stderr, 3: exit code - answer = out[3] == 0; - } catch (ex) { - answer = false; - } - - checkedCommandsMap.set(app, answer); - } - return answer; -} From 0d779c6032ea5fbf0ef8c61515f5e95ef547dd38 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 Sep 2023 23:10:07 -0700 Subject: [PATCH 18/18] refactor: avoid using `var` --- appIcons.js | 10 +++++----- intellihide.js | 2 +- panel.js | 2 +- prefs.js | 4 ++-- taskbar.js | 4 ++-- utils.js | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/appIcons.js b/appIcons.js index fedf226..01be947 100644 --- a/appIcons.js +++ b/appIcons.js @@ -1412,10 +1412,10 @@ export function getInterestingWindows(app, monitor, isolateMonitors) { } export function cssHexTocssRgba(cssHex, opacity) { - var bigint = parseInt(cssHex.slice(1), 16); - var r = (bigint >> 16) & 255; - var g = (bigint >> 8) & 255; - var b = bigint & 255; + let bigint = parseInt(cssHex.slice(1), 16); + let r = (bigint >> 16) & 255; + let g = (bigint >> 8) & 255; + let b = bigint & 255; return 'rgba(' + [r, g, b].join(',') + ',' + opacity + ')'; } @@ -1851,7 +1851,7 @@ export const MyShowAppsIconMenu = class extends PopupMenu.PopupMenu { return; } - for (var entry = 0; entry < commandList.length; entry++) { + for (let entry = 0; entry < commandList.length; entry++) { _appendItem({ title: titleList[entry], cmd: commandList[entry].split(' ') diff --git a/intellihide.js b/intellihide.js index ea5873c..e47171f 100644 --- a/intellihide.js +++ b/intellihide.js @@ -42,7 +42,7 @@ const T2 = 'limitUpdateTimeout'; const T3 = 'postAnimateTimeout'; const T4 = 'panelBoxClipTimeout'; -var SIDE_CONTROLS_ANIMATION_TIME = OverviewControls.SIDE_CONTROLS_ANIMATION_TIME / (OverviewControls.SIDE_CONTROLS_ANIMATION_TIME > 1 ? 1000 : 1); +const SIDE_CONTROLS_ANIMATION_TIME = OverviewControls.SIDE_CONTROLS_ANIMATION_TIME / (OverviewControls.SIDE_CONTROLS_ANIMATION_TIME > 1 ? 1000 : 1); export const Hold = { NONE: 0, diff --git a/panel.js b/panel.js index 62cd29d..cb88701 100644 --- a/panel.js +++ b/panel.js @@ -1223,7 +1223,7 @@ export const Panel = GObject.registerClass({ return; } - var scrollDelay = SETTINGS.get_int('scroll-panel-delay'); + const scrollDelay = SETTINGS.get_int('scroll-panel-delay'); if (scrollDelay) { this._timeoutsHandler.add([T6, scrollDelay, () => {}]); diff --git a/prefs.js b/prefs.js index bc16ad5..6da427e 100644 --- a/prefs.js +++ b/prefs.js @@ -142,7 +142,7 @@ function checkHotkeyPrefix(settings) { } function mergeObjects(main, bck) { - for (var prop in bck) { + for (const prop in bck) { if (!main.hasOwnProperty(prop) && bck.hasOwnProperty(prop)) { main[prop] = bck[prop]; } @@ -1933,7 +1933,7 @@ const Preferences = class { {objectName: 'panel_length_scale', valueName: '', range: LENGTH_MARKS } ]; - for(var idx in sizeScales) { + for(const idx in sizeScales) { let size_scale = this._builder.get_object(sizeScales[idx].objectName); let range = sizeScales[idx].range; size_scale.set_range(range[range.length - 1], range[0]); diff --git a/taskbar.js b/taskbar.js index b738544..f3018f3 100644 --- a/taskbar.js +++ b/taskbar.js @@ -47,7 +47,7 @@ import {SETTINGS} from './extension.js'; const SearchController = Main.overview.searchController; export const DASH_ANIMATION_TIME = Dash.DASH_ANIMATION_TIME / (Dash.DASH_ANIMATION_TIME > 1 ? 1000 : 1); -var DASH_ITEM_HOVER_TIMEOUT = Dash.DASH_ITEM_HOVER_TIMEOUT; +const DASH_ITEM_HOVER_TIMEOUT = Dash.DASH_ITEM_HOVER_TIMEOUT; export const MIN_ICON_SIZE = 4; const T1 = 'ensureAppIconVisibilityTimeout' @@ -1530,7 +1530,7 @@ export const TaskbarItemContainer = GObject.registerClass({ } }); -var DragPlaceholderItem = GObject.registerClass({ +const DragPlaceholderItem = GObject.registerClass({ }, class DragPlaceholderItem extends St.Widget { _init(appIcon, iconSize, isVertical) { diff --git a/utils.js b/utils.js index 8e5348d..b1fd40c 100644 --- a/utils.js +++ b/utils.js @@ -35,7 +35,7 @@ import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js'; const Gi = imports._gi; -var SCROLL_TIME = Util.SCROLL_TIME / (Util.SCROLL_TIME > 1 ? 1000 : 1); +const SCROLL_TIME = Util.SCROLL_TIME / (Util.SCROLL_TIME > 1 ? 1000 : 1); // simplify global signals and function injections handling // abstract class @@ -270,7 +270,7 @@ export const find = function(array, predicate) { }; export const mergeObjects = function(main, bck) { - for (var prop in bck) { + for (const prop in bck) { if (!main.hasOwnProperty(prop) && bck.hasOwnProperty(prop)) { main[prop] = bck[prop]; } @@ -869,8 +869,8 @@ export const drawRoundedLine = function(cr, x, y, width, height, isRoundLeft, is height = 2.0 * Math.floor(height / 2.0); - var leftRadius = isRoundLeft ? height / 2.0 : 0.0; - var rightRadius = isRoundRight ? height / 2.0 : 0.0; + const leftRadius = isRoundLeft ? height / 2.0 : 0.0; + const rightRadius = isRoundRight ? height / 2.0 : 0.0; cr.moveTo(x + width - rightRadius, y); cr.lineTo(x + leftRadius, y);