[banshee] [NotificationArea] Fix notifications regression



commit 1efe2dbcba78e23fd53d42dff0498a6c37e59afb
Author: Aaron Bockover <abockover novell com>
Date:   Sun Oct 11 12:41:58 2009 -0400

    [NotificationArea] Fix notifications regression
    
    Recently, probing the name of the notification daemon became
    necessary for knowing what to do with artwork, however this
    probe was added outside of the try/catch block for displaying
    notifications. This is a crashing regression in the case where
    no notification daemon is running at all.

 .../NotificationAreaService.cs                     |   30 ++++++++++----------
 1 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
index aefdd2d..60be5d5 100644
--- a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
+++ b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
@@ -399,13 +399,6 @@ namespace Banshee.NotificationArea
             }
         }
 
-        private bool IsNotificationDaemon {
-            get {
-                var name = Notifications.Global.ServerInformation.Name;
-                return name == "notification-daemon" || name == "Notification Daemon";
-            }
-        }
-        
         private void ShowTrackNotification ()
         {
             // This has to happen before the next if, otherwise the last_* members aren't set correctly.
@@ -416,11 +409,20 @@ namespace Banshee.NotificationArea
             
             notify_last_title = current_track.DisplayTrackTitle;
             notify_last_artist = current_track.DisplayArtistName;
-
+            
             if (!show_notifications || elements_service.PrimaryWindow.HasToplevelFocus) {
                 return;
             }
             
+            bool is_notification_daemon = false;
+            try {
+                var name = Notifications.Global.ServerInformation.Name;
+                is_notification_daemon = name == "notification-daemon" || name == "Notification Daemon";
+            } catch {
+                // This will be reached if no notification daemon is running
+                return;
+            }
+            
             string message = String.Format ("{0}\n<i>{1}</i>", 
                 GLib.Markup.EscapeText (current_track.DisplayTrackTitle),
                 GLib.Markup.EscapeText (current_track.DisplayArtistName));
@@ -432,11 +434,9 @@ namespace Banshee.NotificationArea
             Gdk.Pixbuf image = null;
             
             if (artwork_manager_service != null) {
-                if (IsNotificationDaemon) {
-                    image = artwork_manager_service.LookupScalePixbuf (current_track.ArtworkId, 42);
-                } else {
-                    image = artwork_manager_service.LookupPixbuf (current_track.ArtworkId);
-                }
+                image = is_notification_daemon
+                    ? artwork_manager_service.LookupScalePixbuf (current_track.ArtworkId, 42)
+                    : artwork_manager_service.LookupPixbuf (current_track.ArtworkId);
             }
             
             if (image == null) {
@@ -447,10 +447,10 @@ namespace Banshee.NotificationArea
             }
             
             try {
-                if (current_nf == null)
+                if (current_nf == null) {
                     current_nf = new Notification (Catalog.GetString ("Now Playing"), 
                         message, image, notif_area.Widget);
-                else {
+                } else {
                     current_nf.Body = message;
                     current_nf.Icon = image;
                     current_nf.AttachToWidget (notif_area.Widget);



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