Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable notification badges #1803

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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