Skip to content

Commit

Permalink
appIconsDecorator: Hide all menu items except unpinning ones on updating
Browse files Browse the repository at this point in the history
Do not allow performing any action on updating apps
  • Loading branch information
3v1n0 committed Aug 24, 2024
1 parent 4d1515c commit 7862abb
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions appIconsDecorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import {
} from './dependencies/gi.js';

import {
AppMenu,
AppDisplay,
Main,
PopupMenu,
} from './dependencies/shell/ui.js';

export class AppIconsDecorator {
Expand Down Expand Up @@ -127,5 +129,34 @@ export class AppIconsDecorator {
/* eslint-enable no-invalid-this */
},
}));

this._methodInjections.add(AppMenu.AppMenu.prototype,
'open', function (originalFunction, ...args) {
/* eslint-disable no-invalid-this */
if (!this.sourceActor.updating) {
originalFunction.call(this, ...args);
return;
}

if (this.isOpen)
return;

if (this.isEmpty())
return;

// Temporarily hide all the menu items a part the Pinning one
// while we're updating.
const items = this._getMenuItems().filter(
i => i !== this._toggleFavoriteItem).map(i =>
i instanceof PopupMenu.PopupMenuBase ? i.actor : i);
const itemsVisibility = items.map(i => i.visible);
items.forEach(i => (i.visible = false));
const menuClosedId = this.connect('menu-closed', () => {
this.disconnect(menuClosedId);
items.forEach((i, idx) => (i.visible = itemsVisibility[idx]));
});
originalFunction.call(this, ...args);
/* eslint-enable no-invalid-this */
});
}
}

0 comments on commit 7862abb

Please sign in to comment.