dateMenu: Indicate when do-not-disturb is on
When do-not-disturb is enabled, non-critical notifications will not be shown as banners. It therefore makes sense to indicate that state to the user, so they don't accidentally miss notifications. https://gitlab.gnome.org/GNOME/gnome-shell/issues/239
This commit is contained in:
parent
b4cf07d05f
commit
9e9f3ff6b4
@ -432,7 +432,6 @@ var MessagesIndicator = GObject.registerClass(
|
|||||||
class MessagesIndicator extends St.Icon {
|
class MessagesIndicator extends St.Icon {
|
||||||
_init() {
|
_init() {
|
||||||
super._init({
|
super._init({
|
||||||
icon_name: 'message-indicator-symbolic',
|
|
||||||
icon_size: 16,
|
icon_size: 16,
|
||||||
visible: false,
|
visible: false,
|
||||||
y_expand: true,
|
y_expand: true,
|
||||||
@ -440,6 +439,13 @@ class MessagesIndicator extends St.Icon {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this._sources = [];
|
this._sources = [];
|
||||||
|
this._count = 0;
|
||||||
|
this._doNotDisturb = false;
|
||||||
|
|
||||||
|
this._settings = new Gio.Settings({
|
||||||
|
schema_id: 'org.gnome.desktop.notifications',
|
||||||
|
});
|
||||||
|
this._settings.connect('changed::show-banners', this._sync.bind(this));
|
||||||
|
|
||||||
Main.messageTray.connect('source-added', this._onSourceAdded.bind(this));
|
Main.messageTray.connect('source-added', this._onSourceAdded.bind(this));
|
||||||
Main.messageTray.connect('source-removed', this._onSourceRemoved.bind(this));
|
Main.messageTray.connect('source-removed', this._onSourceRemoved.bind(this));
|
||||||
@ -447,6 +453,11 @@ class MessagesIndicator extends St.Icon {
|
|||||||
|
|
||||||
let sources = Main.messageTray.getSources();
|
let sources = Main.messageTray.getSources();
|
||||||
sources.forEach(source => this._onSourceAdded(null, source));
|
sources.forEach(source => this._onSourceAdded(null, source));
|
||||||
|
|
||||||
|
this.connect('destroy', () => {
|
||||||
|
this._settings.run_dispose();
|
||||||
|
this._settings = null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_onSourceAdded(tray, source) {
|
_onSourceAdded(tray, source) {
|
||||||
@ -463,9 +474,17 @@ class MessagesIndicator extends St.Icon {
|
|||||||
_updateCount() {
|
_updateCount() {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
this._sources.forEach(source => (count += source.unseenCount));
|
this._sources.forEach(source => (count += source.unseenCount));
|
||||||
count -= Main.messageTray.queueCount;
|
this._count = count - Main.messageTray.queueCount;
|
||||||
|
|
||||||
this.visible = count > 0;
|
this._sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
_sync() {
|
||||||
|
let doNotDisturb = !this._settings.get_boolean('show-banners');
|
||||||
|
this.icon_name = doNotDisturb
|
||||||
|
? 'notifications-disabled-symbolic'
|
||||||
|
: 'message-indicator-symbolic';
|
||||||
|
this.visible = doNotDisturb || this._count > 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user