[gnome-shell/wip/fmuellner/dont-disturb] dateMenu: Indicate when do-not-disturb is on



commit e517b3209399535ab29147d416b0d3e321458ad2
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jan 17 17:26:08 2020 +0100

    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

 js/ui/dateMenu.js | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 5542d8f7ce..44ce17e6cd 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -8,6 +8,7 @@ const Util = imports.misc.util;
 const Main = imports.ui.main;
 const PanelMenu = imports.ui.panelMenu;
 const Calendar = imports.ui.calendar;
+const GnomeSession = imports.misc.gnomeSession;
 const Weather = imports.misc.weather;
 const System = imports.system;
 
@@ -432,7 +433,6 @@ var MessagesIndicator = GObject.registerClass(
 class MessagesIndicator extends St.Icon {
     _init() {
         super._init({
-            icon_name: 'message-indicator-symbolic',
             icon_size: 16,
             visible: false,
             y_expand: true,
@@ -440,6 +440,13 @@ class MessagesIndicator extends St.Icon {
         });
 
         this._sources = [];
+        this._count = 0;
+        this._doNotDisturb = false;
+
+        this._presence = new GnomeSession.Presence(
+            proxy => this._onStatusChanged(proxy.status));
+        this._presence.connectSignal('StatusChanged',
+            (proxy, sender, [status]) => this._onStatusChanged(status));
 
         Main.messageTray.connect('source-added', this._onSourceAdded.bind(this));
         Main.messageTray.connect('source-removed', this._onSourceRemoved.bind(this));
@@ -463,9 +470,21 @@ class MessagesIndicator extends St.Icon {
     _updateCount() {
         let count = 0;
         this._sources.forEach(source => (count += source.unseenCount));
-        count -= Main.messageTray.queueCount;
+        this._count = count - Main.messageTray.queueCount;
+
+        this._sync();
+    }
 
-        this.visible = count > 0;
+    _onStatusChanged(status) {
+        this._doNotDisturb = status === GnomeSession.PresenceStatus.BUSY;
+        this._sync();
+    }
+
+    _sync() {
+        this.icon_name = this._doNotDisturb
+            ? 'notifications-disabled-symbolic'
+            : 'message-indicator-symbolic';
+        this.visible = this._doNotDisturb || this._count > 0;
     }
 });
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]