[blam] Catch exception if notifications can't be used



commit cc0d14c8c3add5fc36033e80b5a9ea9adeb239fc
Author: Carlos MartÃn Nieto <carlos cmartin tk>
Date:   Tue Aug 23 20:09:25 2011 +0200

    Catch exception if notifications can't be used
    
    Signed-off-by: Carlos MartÃn Nieto <carlos cmartin tk>

 src/UnreadNotification.cs |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/src/UnreadNotification.cs b/src/UnreadNotification.cs
index 84b6fb8..4400395 100644
--- a/src/UnreadNotification.cs
+++ b/src/UnreadNotification.cs
@@ -9,13 +9,18 @@ namespace Imendio.Blam
 
         static Notification note = new Notification();
 
-        public UnreadNotification()
-        {
-            note = new Notification();
-        }
-
         public static void NotifyUnreadPosts(int unread, int new_items)
         {
+            if(note == null){
+                try {
+                    note = new Notification();
+                    note.IconName = "blam";
+                    note.Summary = Catalog.GetString("Feeds refreshed");
+                    note.Urgency = Urgency.Normal;
+                } catch(Exception e){
+                    return;
+                }
+            }
             /* Same as for the tray icon tooltip */
             /* Total number of unread items */
             string str = string.Format (Catalog.GetPluralString ("{0} unread item", "{0} unread items", unread),
@@ -24,10 +29,7 @@ namespace Imendio.Blam
             /* Number of new (not-skipped-over) entries. Gets appended to previous string */
             str += string.Format(Catalog.GetPluralString("({0} new)", "({0} new)", new_items), new_items);
 
-            note.IconName = "blam";
-            note.Summary = Catalog.GetString("Feeds refreshed");
             note.Body = str;
-            note.Urgency = Urgency.Normal;
             note.Show();
         }
     }



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