gnome bubbles: Call notifications from the main thread. #1362

This commit is contained in:
Hylke Bons 2013-10-11 21:57:41 +02:00
parent f874c1c70b
commit 34e4afa806
2 changed files with 9 additions and 17 deletions

View file

@ -34,24 +34,14 @@ namespace SparkleShare {
if (!Program.Controller.NotificationsEnabled) if (!Program.Controller.NotificationsEnabled)
return; return;
try { Application.Invoke (delegate {
// Debug information for https://github.com/hbons/SparkleShare/issues/1362
if (title.Length > 255) {
SparkleLogger.LogInfo ("Notification", "Long string detected, truncating 'title'");
title = title.Substring (0, 255) + "...";
} else if (subtext.Length > 255) {
SparkleLogger.LogInfo ("Notification", "Long string detected, truncating 'subtext'");
title = title.Substring (0, 255) + "...";
}
Notification notification = new Notification () { Notification notification = new Notification () {
Summary = title, Summary = title,
Body = subtext, Body = subtext,
Timeout = 5 * 1000, Timeout = 5 * 1000,
Urgency = Urgency.Low Urgency = Urgency.Low
}; };
if (image_path != null) if (image_path != null)
notification.Icon = new Gdk.Pixbuf (image_path); notification.Icon = new Gdk.Pixbuf (image_path);
else else
@ -62,11 +52,13 @@ namespace SparkleShare {
Controller.BubbleClicked (); Controller.BubbleClicked ();
}; };
notification.Show (); try {
notification.Show ();
} catch (Exception e) { } catch (Exception e) {
SparkleLogger.LogInfo ("Notification", "Error showing notification: ", e); SparkleLogger.LogInfo ("Notification", "Error showing notification: ", e);
} }
});
}; };
} }
} }

View file

@ -79,7 +79,7 @@ namespace SparkleShare {
this.indicator.Status = Status.Attention; this.indicator.Status = Status.Attention;
this.indicator.Status = Status.Active; this.indicator.Status = Status.Active;
#else #else
this.status_icon.IconName = icon_name this.status_icon.IconName = icon_name;
#endif #endif
}); });
}; };