[gnome-shell/wip/fmuellner/notification-redux+sass: 54/61] messageTray: Adjust to Notification/NotificationBanner split



commit 6a66414d4549fba8bd8635d0d05f8fe437c08f4f
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Feb 17 03:13:56 2015 +0100

    messageTray: Adjust to Notification/NotificationBanner split

 js/ui/messageTray.js |   60 +++++++++++++++++++++++--------------------------
 1 files changed, 28 insertions(+), 32 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index abe8832..8ed5a0a 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -879,7 +879,8 @@ const MessageTray = new Lang.Class({
         this._notificationFocusGrabber = new FocusGrabber(this.actor);
         this._notificationQueue = [];
         this._notification = null;
-        this._notificationClickedId = 0;
+        this._banner = null;
+        this._bannerClickedId = 0;
 
         this._userActiveWhileNotificationShown = false;
 
@@ -900,7 +901,6 @@ const MessageTray = new Lang.Class({
 
         this._notificationState = State.HIDDEN;
         this._notificationTimeoutId = 0;
-        this._notificationExpandedId = 0;
         this._notificationRemoved = false;
 
         this.clearableCount = 0;
@@ -1191,17 +1191,17 @@ const MessageTray = new Lang.Class({
             let expired = (this._userActiveWhileNotificationShown &&
                            this._notificationTimeoutId == 0 &&
                            this._notification.urgency != Urgency.CRITICAL &&
-                           !this._notification.focused &&
+                           !this._banner.focused &&
                            !this._pointerInNotification) || this._notificationExpired;
             let mustClose = (this._notificationRemoved || !hasNotifications || expired);
 
             if (mustClose) {
                 let animate = hasNotifications && !this._notificationRemoved;
                 this._hideNotification(animate);
-            } else if (this._pointerInNotification && !this._notification.expanded) {
-                this._expandNotification(false);
+            } else if (this._pointerInNotification && !this._banner.expanded) {
+                this._expandBanner(false);
             } else if (this._pointerInNotification) {
-                this._ensureNotificationFocused();
+                this._ensureBannerFocused();
             }
         }
 
@@ -1252,14 +1252,14 @@ const MessageTray = new Lang.Class({
             this.idleMonitor.add_user_active_watch(Lang.bind(this, this._onIdleMonitorBecameActive));
         }
 
-        this._notificationClickedId = this._notification.connect('done-displaying',
-                                                                 Lang.bind(this, this._escapeTray));
-        this._notificationUnfocusedId = this._notification.connect('unfocused', Lang.bind(this, function() {
+        this._banner = new NotificationBanner(this._notification);
+        this._bannerClickedId = this._banner.connect('done-displaying',
+                                                     Lang.bind(this, this._escapeTray));
+        this._bannerUnfocusedId = this._banner.connect('unfocused', Lang.bind(this, function() {
             this._updateState();
         }));
-        this._notificationBin.child = this._notification.actor;
-
-        this._notificationBin.y = -this._notification.actor.height;
+        this._notificationBin.child = this._banner.actor;
+        this._notificationBin.y = -this._banner.actor.height;
 
         this._updateShowingNotification();
 
@@ -1288,7 +1288,7 @@ const MessageTray = new Lang.Class({
         // is on in the control center.
         if (this._notification.urgency == Urgency.CRITICAL ||
             this._notification.source.policy.forceExpanded)
-            this._expandNotification(true);
+            this._expandBanner(true);
 
         // We tween all notifications to full opacity. This ensures that both new notifications and
         // notifications that might have been in the process of hiding get full opacity.
@@ -1361,17 +1361,13 @@ const MessageTray = new Lang.Class({
     _hideNotification: function(animate) {
         this._notificationFocusGrabber.ungrabFocus();
 
-        if (this._notificationExpandedId) {
-            this._notification.disconnect(this._notificationExpandedId);
-            this._notificationExpandedId = 0;
-        }
-        if (this._notificationClickedId) {
-            this._notification.disconnect(this._notificationClickedId);
-            this._notificationClickedId = 0;
+        if (this._bannerClickedId) {
+            this._banner.disconnect(this._bannerClickedId);
+            this._bannerClickedId = 0;
         }
-        if (this._notificationUnfocusedId) {
-            this._notification.disconnect(this._notificationUnfocusedId);
-            this._notificationUnfocusedId = 0;
+        if (this._bannerUnfocusedId) {
+            this._banner.disconnect(this._bannerUnfocusedId);
+            this._bannerUnfocusedId = 0;
         }
 
         this._resetNotificationLeftTimeout();
@@ -1397,8 +1393,6 @@ const MessageTray = new Lang.Class({
     },
 
     _hideNotificationCompleted: function() {
-        this._notification.collapseCompleted();
-
         let notification = this._notification;
         this._notification = null;
         if (notification.isTransient)
@@ -1406,26 +1400,28 @@ const MessageTray = new Lang.Class({
 
         this._pointerInNotification = false;
         this._notificationRemoved = false;
-        this._notificationBin.child = null;
+
+        this._banner.actor.destroy();
+        this._banner = null;
     },
 
     _expandActiveNotification: function() {
-        if (!this._notification)
+        if (!this._banner)
             return;
 
-        this._expandNotification(false);
+        this._expandBanner(false);
     },
 
-    _expandNotification: function(autoExpanding) {
+    _expandBanner: function(autoExpanding) {
         // Don't animate changes in notifications that are auto-expanding.
-        this._notification.expand(!autoExpanding);
+        this._banner.expand(!autoExpanding);
 
         // Don't focus notifications that are auto-expanding.
         if (!autoExpanding)
-            this._ensureNotificationFocused();
+            this._ensureBannerFocused();
     },
 
-    _ensureNotificationFocused: function() {
+    _ensureBannerFocused: function() {
         this._notificationFocusGrabber.grabFocus();
     }
 });


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