[gnome-shell/wip/fmuellner/notification-redux+sass: 122/207] notificationDaemon: Playing around with notifiations



commit 0e46d70218b33a3b7bba552e8984d00818518e15
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Feb 11 23:04:02 2015 +0100

    notificationDaemon: Playing around with notifiations

 js/ui/notificationDaemon.js |   68 ++++++++----------------------------------
 1 files changed, 13 insertions(+), 55 deletions(-)
---
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index 1891572..f850cc8 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -10,6 +10,7 @@ const Shell = imports.gi.Shell;
 const Mainloop = imports.mainloop;
 const St = imports.gi.St;
 
+const Calendar = imports.ui.calendar;
 const Config = imports.misc.config;
 const Main = imports.ui.main;
 const MessageTray = imports.ui.messageTray;
@@ -195,7 +196,6 @@ const FdoNotificationDaemon = new Lang.Class({
                 this._sources.splice(index, 1);
         }));
 
-        Main.messageTray.add(source);
         return source;
     },
 
@@ -311,26 +311,13 @@ const FdoNotificationDaemon = new Lang.Class({
         return invocation.return_value(GLib.Variant.new('(u)', [id]));
     },
 
-    _makeButton: function(id, label, useActionIcons) {
-        let button = new St.Button({ can_focus: true });
-        let iconName = id.endsWith('-symbolic') ? id : id + '-symbolic';
-        if (useActionIcons && Gtk.IconTheme.get_default().has_icon(iconName)) {
-            button.add_style_class_name('notification-icon-button button');
-            button.child = new St.Icon({ icon_name: iconName });
-        } else {
-            button.add_style_class_name('notification-button button');
-            button.label = label;
-        }
-        return button;
-    },
-
     _notifyForSource: function(source, ndata) {
         let [id, icon, summary, body, actions, hints, notification] =
             [ndata.id, ndata.icon, ndata.summary, ndata.body,
              ndata.actions, ndata.hints, ndata.notification];
 
         if (notification == null) {
-            notification = new MessageTray.Notification(source);
+            notification = new Calendar.Notification(source);
             ndata.notification = notification;
             notification.connect('destroy', Lang.bind(this,
                 function(n, reason) {
@@ -368,47 +355,35 @@ const FdoNotificationDaemon = new Lang.Class({
             gicon = this._fallbackIconForNotificationData(hints);
 
         notification.update(summary, body, { gicon: gicon,
-                                             bannerMarkup: true,
-                                             clear: true,
                                              soundFile: hints['sound-file'],
                                              soundName: hints['sound-name'] });
 
         let hasDefaultAction = false;
 
         if (actions.length) {
-            let useActionIcons = (hints['action-icons'] == true);
-
             for (let i = 0; i < actions.length - 1; i += 2) {
                 let [actionId, label] = [actions[i], actions[i+1]];
                 if (actionId == 'default') {
-                    hasDefaultAction = true;
+                    notification.setDefaultAction(Lang.bind(this, function() {
+                        this._emitActionInvoked(ndata.id, 'default');
+                    }));
                 } else {
-                    notification.addButton(this._makeButton(actionId, label, useActionIcons), 
Lang.bind(this, function() {
+                    notification.addButton(label, Lang.bind(this, function() {
                         this._emitActionInvoked(ndata.id, actionId);
                     }));
                 }
             }
         }
 
-        if (hasDefaultAction) {
-            notification.connect('clicked', Lang.bind(this, function() {
-                this._emitActionInvoked(ndata.id, 'default');
-            }));
-        } else {
-            notification.connect('clicked', Lang.bind(this, function() {
-                source.open();
-            }));
-        }
-
         switch (hints.urgency) {
             case Urgency.LOW:
-                notification.setUrgency(MessageTray.Urgency.LOW);
+                notification.setPriority(Gio.NotificationPriority.LOW);
                 break;
             case Urgency.NORMAL:
-                notification.setUrgency(MessageTray.Urgency.NORMAL);
+                notification.setPriority(Gio.NotificationPriority.NORMAL);
                 break;
             case Urgency.CRITICAL:
-                notification.setUrgency(MessageTray.Urgency.CRITICAL);
+                notification.setPriority(Gio.NotificationPriority.URGENT);
                 break;
         }
         notification.setResident(hints.resident == true);
@@ -416,8 +391,7 @@ const FdoNotificationDaemon = new Lang.Class({
         // of the 'transient' hint with hints['transient'] rather than hints.transient
         notification.setTransient(hints['transient'] == true);
 
-        let sourceGIcon = source.useNotificationIcon ? gicon : null;
-        source.processNotification(notification, sourceGIcon);
+        Main.panel.statusArea.dateMenu._messageList._notificationSection.addNotification(notification);
     },
 
     CloseNotification: function(id) {
@@ -432,7 +406,7 @@ const FdoNotificationDaemon = new Lang.Class({
     GetCapabilities: function() {
         return [
             'actions',
-            'action-icons',
+            // 'action-icons',
             'body',
             // 'body-hyperlinks',
             // 'body-images',
@@ -494,7 +468,7 @@ const FdoNotificationDaemon = new Lang.Class({
 
 const FdoNotificationDaemonSource = new Lang.Class({
     Name: 'FdoNotificationDaemonSource',
-    Extends: MessageTray.Source,
+    Extends: Calendar.Source,
 
     _init: function(title, pid, sender, appId) {
         // Need to set the app before chaining up, so
@@ -539,18 +513,6 @@ const FdoNotificationDaemonSource = new Lang.Class({
             this.destroy();
     },
 
-    processNotification: function(notification, gicon) {
-        if (gicon)
-            this._gicon = gicon;
-        this.iconUpdated();
-
-        let tracker = Shell.WindowTracker.get_default();
-        if (notification.resident && this.app && tracker.focus_app == this.app)
-            this.pushNotification(notification);
-        else
-            this.notify(notification);
-    },
-
     _getApp: function(appId) {
         let app;
 
@@ -579,11 +541,7 @@ const FdoNotificationDaemonSource = new Lang.Class({
 
     open: function() {
         this.openApp();
-        this.destroyNonResidentNotifications();
-    },
-
-    _lastNotificationRemoved: function() {
-        this.destroy();
+        //this.destroyNonResidentNotifications();
     },
 
     openApp: function() {


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