Skip to content

Commit a9a76ac

Browse files
committed
appIconsDecorator: Support decorating app icons with emblems everywhere
If unity indicators are enabled we should show them allover the places, but we didn't so far, so let's add support for patching all the kinds of icons so that we can define the behavior when this happens
1 parent 136de6b commit a9a76ac

6 files changed

Lines changed: 106 additions & 8 deletions

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ EXTRA_MODULES = \
1212
dash.js \
1313
docking.js \
1414
appIcons.js \
15+
appIconsDecorator.js \
1516
appIconIndicators.js \
1617
fileManager1API.js \
1718
imports.js \
@@ -38,6 +39,7 @@ EXTRA_MEDIA = logo.svg \
3839
TOLOCALIZE = prefs.js \
3940
docking.js \
4041
appIcons.js \
42+
appIconsDecorator.js \
4143
locations.js \
4244
$(NULL)
4345

_stylesheet.scss

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,9 @@ $dock_style_modes: [null, shrink, extended, extended-shrink];
364364
background: $dash_background_color;
365365
}
366366

367-
#dashtodockContainer.dashtodock .progress-bar {
367+
#dashtodockContainer.dashtodock .progress-bar,
368+
.overview-tile .progress-bar,
369+
.icon-grid .progress-bar {
368370
/* Customization of the progress bar style. The possible elements
369371
* are:
370372
*
@@ -442,13 +444,17 @@ $dock_style_modes: [null, shrink, extended, extended-shrink];
442444
transition-duration: 500ms;
443445
}
444446

445-
#dashtodockContainer .number-overlay {
447+
#dashtodockContainer .number-overlay,
448+
.overview-tile .number-overlay,
449+
.icon-grid .number-overlay {
446450
color: rgba(255, 255, 255, 1);
447451
background-color: rgba(0, 0, 0, 0.8);
448452
text-align: center;
449453
}
450454

451-
#dashtodockContainer .notification-badge {
455+
#dashtodockContainer .notification-badge,
456+
.overview-tile .notification-badge,
457+
.icon-grid .notification-badge {
452458
color: rgba(255, 255, 255, 1);
453459
background-color: rgba(255, 0, 0, 1);
454460
padding: 0.2em 0.5em;

appIconIndicators.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ class RunningIndicatorBinary extends RunningIndicatorDots {
676676
/*
677677
* Unity like notification and progress indicators
678678
*/
679-
class UnityIndicator extends IndicatorBase {
679+
export class UnityIndicator extends IndicatorBase {
680680
static defaultProgressBar = {
681681
// default values for the progress bar itself
682682
background: {

appIconsDecorator.js

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
2+
3+
4+
import {
5+
Docking,
6+
AppIconIndicators,
7+
Utils,
8+
} from './imports.js';
9+
10+
import {
11+
AppDisplay,
12+
} from './dependencies/shell/ui.js';
13+
14+
export class AppIconsDecorator {
15+
constructor() {
16+
this._signals = new Utils.GlobalSignalsHandler();
17+
this._iconSignals = new Utils.GlobalSignalsHandler();
18+
this._methodInjections = new Utils.InjectionsHandler();
19+
this._indicators = new Set();
20+
21+
this._patchAppIcons();
22+
this._decorateIcons();
23+
}
24+
25+
destroy() {
26+
this._signals?.destroy();
27+
delete this._signals;
28+
this._iconSignals?.destroy();
29+
delete this._iconSignals;
30+
this._methodInjections?.destroy();
31+
delete this._methodInjections;
32+
this._indicators?.clear();
33+
delete this._indicators;
34+
}
35+
36+
_decorateIcon(parentIcon) {
37+
const indicator = new AppIconIndicators.UnityIndicator(parentIcon);
38+
this._indicators.add(indicator);
39+
this._signals.add(parentIcon, 'destroy', () => {
40+
this._indicators.delete(indicator);
41+
indicator.destroy();
42+
});
43+
return indicator;
44+
}
45+
46+
_decorateIcons() {
47+
const {appDisplay} = Docking.DockManager.getDefault().overviewControls;
48+
49+
const decorateAppIcons = () => {
50+
this._indicators.clear();
51+
this._iconSignals.clear();
52+
53+
const decorateViewIcons = view => {
54+
const items = view.getAllItems();
55+
items.forEach(i => {
56+
if (i instanceof AppDisplay.AppIcon) {
57+
this._decorateIcon(i);
58+
} else if (i instanceof AppDisplay.FolderIcon) {
59+
decorateViewIcons(i.view);
60+
this._iconSignals.add(i.view, 'view-loaded', () =>
61+
decorateAppIcons());
62+
}
63+
});
64+
};
65+
decorateViewIcons(appDisplay);
66+
};
67+
68+
this._signals.add(appDisplay, 'view-loaded', () => decorateAppIcons());
69+
decorateAppIcons();
70+
}
71+
72+
_patchAppIcons() {
73+
const self = this;
74+
75+
this._methodInjections.add(AppDisplay.AppSearchProvider.prototype,
76+
'createResultObject', function (originalFunction, ...args) {
77+
/* eslint-disable no-invalid-this */
78+
const result = originalFunction.call(this, ...args);
79+
if (result instanceof AppDisplay.AppIcon)
80+
self._decorateIcon(result);
81+
return result;
82+
/* eslint-enable no-invalid-this */
83+
});
84+
}
85+
}

docking.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
} from './dependencies/shell/misc.js';
2929

3030
import {
31+
AppIconsDecorator,
3132
AppSpread,
3233
DockDash,
3334
DesktopIconsIntegration,
@@ -1687,17 +1688,19 @@ export class DockManager {
16871688

16881689
const needsRemoteModel = () =>
16891690
!this._notificationsMonitor.dndMode && this._settings.showIconsEmblems;
1690-
if (needsRemoteModel)
1691-
this._remoteModel = new LauncherAPI.LauncherEntryRemoteModel();
16921691

16931692
const ensureRemoteModel = () => {
16941693
if (needsRemoteModel && !this._remoteModel) {
16951694
this._remoteModel = new LauncherAPI.LauncherEntryRemoteModel();
1696-
} else if (!needsRemoteModel && this._remoteModel) {
1697-
this._remoteModel.destroy();
1695+
this._appIconsDecorator = new AppIconsDecorator.AppIconsDecorator();
1696+
} else if (!needsRemoteModel) {
1697+
this._remoteModel?.destroy();
16981698
delete this._remoteModel;
1699+
this._appIconsDecorator?.destroy();
1700+
delete this._appIconsDecorator;
16991701
}
17001702
};
1703+
ensureRemoteModel();
17011704

17021705
this._notificationsMonitor.connect('changed', ensureRemoteModel);
17031706
this._settings.connect('changed::show-icons-emblems', ensureRemoteModel);
@@ -2565,6 +2568,7 @@ export class DockManager {
25652568
this._removables = null;
25662569
this._iconTheme = null;
25672570
this._remoteModel?.destroy();
2571+
this._appIconsDecorator?.destroy();
25682572
this._settings = null;
25692573
this._appSwitcherSettings = null;
25702574
this._oldDash = null;

imports.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * as AppIconIndicators from './appIconIndicators.js';
22
export * as AppIcons from './appIcons.js';
3+
export * as AppIconsDecorator from './appIconsDecorator.js';
34
export * as AppSpread from './appSpread.js';
45
export * as DockDash from './dash.js';
56
export * as DBusMenuUtils from './dbusmenuUtils.js';

0 commit comments

Comments
 (0)