From 38dd2e23d9e4d0c4e4ccae2e1f261dd19861c331 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 8 Apr 2024 18:02:51 +0200 Subject: Moving current extensions to subdirectory for GNOME 44 as GNOME Shell 45 is backwards incompatible (see Debian #1052112). Signed-off-by: Daniel Baumann --- .../44/vertical-workspaces/lib/appFavorites.js | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 extensions/44/vertical-workspaces/lib/appFavorites.js (limited to 'extensions/44/vertical-workspaces/lib/appFavorites.js') diff --git a/extensions/44/vertical-workspaces/lib/appFavorites.js b/extensions/44/vertical-workspaces/lib/appFavorites.js new file mode 100644 index 0000000..50ebce9 --- /dev/null +++ b/extensions/44/vertical-workspaces/lib/appFavorites.js @@ -0,0 +1,61 @@ +/** + * V-Shell (Vertical Workspaces) + * appFavorites.js + * + * @author GdH + * @copyright 2022 - 2023 + * @license GPL-3.0 + * + */ + +'use strict'; + +const { Shell } = imports.gi; +const AppFavorites = imports.ui.appFavorites; +const Main = imports.ui.main; + +const Me = imports.misc.extensionUtils.getCurrentExtension(); +const _Util = Me.imports.lib.util; + +let opt; +let _overrides; +let _firstRun = true; + +function update(reset = false) { + opt = Me.imports.lib.settings.opt; + const moduleEnabled = opt.get('appFavoritesModule', true); + reset = reset || !moduleEnabled; + + // don't even touch this module if disabled + if (_firstRun && reset) + return; + + _firstRun = false; + + if (_overrides) + _overrides.removeAll(); + + + // if notifications are enabled no override is needed + if (reset || opt.SHOW_FAV_NOTIFICATION) { + _overrides = null; + opt = null; + return; + } + + _overrides = new _Util.Overrides(); + + // AppFavorites.AppFavorites is const, first access returns undefined + const dummy = AppFavorites.AppFavorites; + _overrides.addOverride('AppFavorites', AppFavorites.AppFavorites.prototype, AppFavoritesCommon); +} + +const AppFavoritesCommon = { + addFavoriteAtPos(appId, pos) { + this._addFavorite(appId, pos); + }, + + removeFavorite(appId) { + this._removeFavorite(appId); + }, +}; -- cgit v1.2.3