From 610b72d43ae9eb6b29460c97fd90f9cb4723761c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 19 Aug 2023 18:31:24 +0200 Subject: [PATCH] dash: Move getAppFromSource() into static method This is a small helper function that is used by the DND handling in the dash and its items. It turns out that some extensions used to override it, which is no longer possible: We don't export it, and if we did, it would be read-only. To make the function available again, expose it as static method on the dash itself. Part-of: --- js/ui/dash.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/js/ui/dash.js b/js/ui/dash.js index 7f09e65e1..0841b6c04 100644 --- a/js/ui/dash.js +++ b/js/ui/dash.js @@ -20,16 +20,6 @@ const DASH_ITEM_LABEL_SHOW_TIME = 150; const DASH_ITEM_LABEL_HIDE_TIME = 100; const DASH_ITEM_HOVER_TIMEOUT = 300; -/** - * @param {AppDisplay.AppIcon} source - */ -function getAppFromSource(source) { - if (source instanceof AppDisplay.AppIcon) - return source.app; - else - return null; -} - export const DashIcon = GObject.registerClass( class DashIcon extends AppDisplay.AppIcon { _init(app) { @@ -263,14 +253,14 @@ class ShowAppsIcon extends DashItemContainer { } handleDragOver(source, _actor, _x, _y, _time) { - if (!this._canRemoveApp(getAppFromSource(source))) + if (!this._canRemoveApp(Dash.getAppFromSource(source))) return DND.DragMotionResult.NO_DROP; return DND.DragMotionResult.MOVE_DROP; } acceptDrop(source, _actor, _x, _y, _time) { - let app = getAppFromSource(source); + const app = Dash.getAppFromSource(source); if (!this._canRemoveApp(app)) return false; @@ -321,6 +311,16 @@ const baseIconSizes = [16, 22, 24, 32, 48, 64]; export const Dash = GObject.registerClass({ Signals: {'icon-size-changed': {}}, }, class Dash extends St.Widget { + /** + * @param {object} source + */ + static getAppFromSource(source) { + if (source instanceof AppDisplay.AppIcon) + return source.app; + else + return null; + } + _init() { this._maxWidth = -1; this._maxHeight = -1; @@ -444,7 +444,7 @@ export const Dash = GObject.registerClass({ } _onItemDragMotion(dragEvent) { - let app = getAppFromSource(dragEvent.source); + const app = Dash.getAppFromSource(dragEvent.source); if (app == null) return DND.DragMotionResult.CONTINUE; @@ -860,7 +860,7 @@ export const Dash = GObject.registerClass({ } handleDragOver(source, actor, x, _y, _time) { - let app = getAppFromSource(source); + const app = Dash.getAppFromSource(source); // Don't allow favoriting of transient apps if (app == null || app.is_window_backed()) @@ -947,7 +947,7 @@ export const Dash = GObject.registerClass({ // Draggable target interface acceptDrop(source, _actor, _x, _y, _time) { - let app = getAppFromSource(source); + const app = Dash.getAppFromSource(source); // Don't allow favoriting of transient apps if (app == null || app.is_window_backed())