Skip to content

Commit

Permalink
Enable notification badges
Browse files Browse the repository at this point in the history
Closes #1695
  • Loading branch information
ibauersachs committed Aug 5, 2023
1 parent be8214d commit f68b2af
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
5 changes: 5 additions & 0 deletions appIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ var TaskbarAppIcon = GObject.registerClass({
});
}

updateBadge(count, enable) {
this._progressIndicator.setNotificationBadge(count);
this._progressIndicator.toggleNotificationBadge(enable);
}

_onAnimateAppiconHoverChanged() {
if (Me.settings.get_boolean('animate-appicon-hover')) {
this._container.add_style_class_name('animate-appicon-hover');
Expand Down
39 changes: 39 additions & 0 deletions taskbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ var Taskbar = class {

this.iconAnimator = new PanelManager.IconAnimator(this.dtpPanel.panel);

this._messageTray = Main.messageTray;

this._signalsHandler.add(
[
this.dtpPanel.panel,
Expand Down Expand Up @@ -394,6 +396,21 @@ var Taskbar = class {
'notify::pageSize'
],
() => this._onScrollSizeChange(adjustment)
],
[
this._messageTray,
'source-added',
this._onMessageTraySource.bind(this)
],
[
this._messageTray,
'source-removed',
this._onMessageTraySource.bind(this)
],
[
this._messageTray,
'queue-changed',
this._onMessageTrayQueueChanged.bind(this)
]
);

Expand Down Expand Up @@ -798,6 +815,28 @@ var Taskbar = class {
});
}

_onMessageTraySource(source) {
// The source from signals does not contain the policy, and
// source-removed does not even contain any id. Ignore and
// always handle changes as if there was any other queue change.
this._onMessageTrayQueueChanged();
}

_onMessageTrayQueueChanged() {
this._getAppIcons().filter(icon => icon.constructor === AppIcons.TaskbarAppIcon).forEach(icon => {
let count = 0;
let enable = false;
for (let source of this._messageTray.getSources()) {
if (icon.app.id === `${source.policy.id}.desktop`) {
count = source.count;
enable = source.policy.enable;
}
}

icon.updateBadge(count, enable);
});
}

_itemMenuStateChanged(item, opened) {
// When the menu closes, it calls sync_hover, which means
// that the notify::hover handler does everything we need to.
Expand Down

0 comments on commit f68b2af

Please sign in to comment.