[gnome-shell/wip/fmuellner/notification-redux: 40/93] calendar: Show notifications



commit ddd2984f26f5dbba4ed63378d3aab00783ed77ff
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Feb 11 23:19:34 2015 +0100

    calendar: Show notifications

 js/ui/calendar.js |   39 +++++++++++++++++++++++++++++++++++++++
 js/ui/main.js     |    2 +-
 2 files changed, 40 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index cbc6287..cc3117c 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -1165,6 +1165,12 @@ const NotificationSection = new Lang.Class({
 
         this._notificationQueue = [];
 
+        this._sources = new Map();
+        Main.messageTray.connect('source-added', Lang.bind(this, this._sourceAdded));
+        Main.messageTray.getSources().forEach(Lang.bind(this, function(source) {
+            this._sourceAdded(Main.messageTray, source);
+        }));
+
         this._bannerBox = new St.Widget({ layout_manager: new Clutter.BinLayout(),
                                           clip_to_allocation: true });
         this._bannerBox.add_constraint(new Layout.MonitorConstraint({ primary: true, work_area: true }));
@@ -1176,6 +1182,39 @@ const NotificationSection = new Lang.Class({
         this._sessionUpdated();
     },
 
+    _sourceAdded: function(tray, source) {
+        let obj = {
+            sourceTitleChangedId: 0,
+            sourceDestroyId: 0,
+            sourceNotificationAdded: 0,
+        };
+
+/*
+        obj.sourceTitleChangedId = source.connect('title-changed', Lang.bind(this, function(source) {
+            this._titleChanged(source, obj);
+        }));
+        obj.sourceDestroyId = source.connect('destroy', Lang.bind(this, function(source) {
+            this._onSourceDestroy(source, obj);
+        }));
+        */
+        obj.sourceNotificationAdded = source.connect('notification-added',
+                                                     Lang.bind(this, this._onNotificationAdded));
+
+        this._sources.set(source, obj);
+    },
+
+    _onNotificationAdded: function(source, notification) {
+        let gicon = notification._icon ? notification._icon.gicon : source.getIcon();
+        let body = '';
+        if (notification.bannerBodyText) {
+            body = notification.bannerBodyMarkup ? notification.bannerBodyText
+                                                 : GLib.markup_escape_text(notification.bannerBodyText, -1);
+        }
+        let listEntry = new MessageListEntry(notification.title, body, { gicon: gicon, time: new Date() });
+        // TODO: Keep URGENT notifications on top
+        this._list.insert_child_below(listEntry.actor, null);
+    },
+
     addNotification: function(notification) {
         let listEntry = new NotificationListEntry(notification);
         // TODO: Keep URGENT notifications on top
diff --git a/js/ui/main.js b/js/ui/main.js
index 385a73d..92ba0f1 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -159,8 +159,8 @@ function _initializeUI() {
     if (LoginManager.canLock())
         screenShield = new ScreenShield.ScreenShield();
 
-    panel = new Panel.Panel();
     messageTray = new MessageTray.MessageTray();
+    panel = new Panel.Panel();
     keyboard = new Keyboard.Keyboard();
     notificationDaemon = new NotificationDaemon.NotificationDaemon();
     windowAttentionHandler = new WindowAttentionHandler.WindowAttentionHandler();


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