Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > e73bedbb114357090e4e8b92530aa6fa > files > 5

cinnamon-1.4.0-8.UP1.fc16.src.rpm

--- a/data/org.cinnamon.gschema.xml.in	2012-05-13 23:30:06.000000000 +0100
+++ b/data/org.cinnamon.gschema.xml.in	2012-05-28 16:37:33.136089480 +0100
@@ -175,6 +175,11 @@
       </_description>
     </key>
     
+    <key type="i" name="notification-style">
+      <default>2</default>
+      <_summary>Notification style</_summary>
+    </key>
+    
     <key name="date-format" type="s">
       <default>"YYYY-MM-DD"</default>
       <_summary>Auto-hide panel</_summary>
--- a/js/ui/windowAttentionHandler.js	2012-05-13 23:30:06.000000000 +0100
+++ b/js/ui/windowAttentionHandler.js	2012-05-28 16:36:22.797043548 +0100
@@ -12,10 +12,21 @@ function WindowAttentionHandler() {
 
 WindowAttentionHandler.prototype = {
     _init : function() {
+        this.notification_style = global.settings.get_int("notification-style");
+        global.settings.connect("changed::notification-style", Lang.bind(this, function() {
+            this.notification_style = global.settings.get_int("notification-style");
+        })); 
+        
         this._tracker = Cinnamon.WindowTracker.get_default();
         global.display.connect('window-demands-attention', Lang.bind(this, this._onWindowDemandsAttention));
     },
 
+    _getTitleAndBanner: function(app, window) {
+        let title = app.get_name();
+        let banner = _("'%s' is ready").format(window.get_title());
+        return [title, banner]
+    },
+
     _onWindowDemandsAttention : function(display, window) {
         // We don't want to show the notification when the window is already focused,
         // because this is rather pointless.
@@ -28,9 +39,41 @@ WindowAttentionHandler.prototype = {
         if (!window || window.has_focus() || window.is_skip_taskbar())
             return;
 
-        if (this._tracker.is_window_interesting(window)) {
-            window.activate(global.get_current_time());
+        switch (this.notification_style) {
+            case 0:
+                //nop
+                break;
+            case 1:
+                this.bringToFront(window);
+                break;
+            case 2:
+                this.showBanner(window);
+                break;
+            default:
+                global.log('Unknown notification style: ' + this.notification_style);
         }
+    },
+
+    bringToFront : function(window) {
+         if (this._tracker.is_window_interesting(window)) {
+            window.activate(global.get_current_time());
+        }       
+    },
+
+    showBanner : function(window) {
+        let app = this._tracker.get_window_app(window);
+        let source = new Source(app, window);
+        if (Main.messageTray) Main.messageTray.add(source);
+
+        let [title, banner] = this._getTitleAndBanner(app, window);
+
+        let notification = new MessageTray.Notification(source, title, banner);
+        source.notify(notification);
+
+        source.signalIDs.push(window.connect('notify::title', Lang.bind(this, function() {
+            let [title, banner] = this._getTitleAndBanner(app, window);
+            notification.update(title, banner);
+        })));
     }
 };