diff options
author | Chow Loong Jin <hyperair@debian.org> | 2013-11-04 02:04:25 +0800 |
---|---|---|
committer | Chow Loong Jin <hyperair@debian.org> | 2013-11-04 02:05:05 +0800 |
commit | f11f03f1dc38b7ef3a14400f593f9ba271971e7f (patch) | |
tree | f066984148a510bf230782d54f9ec9fb0bbce292 /src/Notification.cs | |
parent | fd94e72e5df31cf8a5bca52d6a86049a657d38ed (diff) | |
parent | 0d04227fa0319e717cb9dde6d8bfa060c93441ba (diff) |
Merge tag 'upstream/3.0.0'
Upstream version 3.0.0
Diffstat (limited to 'src/Notification.cs')
-rw-r--r-- | src/Notification.cs | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/Notification.cs b/src/Notification.cs index 09ef83e..8dfb6c0 100644 --- a/src/Notification.cs +++ b/src/Notification.cs @@ -24,11 +24,10 @@ using System; using System.Reflection; using System.Collections.Generic; -using GLib; using Gdk; using Gtk; -using NDesk.DBus; +using DBus; using org.freedesktop; using org.freedesktop.DBus; @@ -112,7 +111,12 @@ namespace Notifications { nf.NotificationClosed += OnClosed; nf.ActionInvoked += OnActionInvoked; - this.app_name = Assembly.GetCallingAssembly().GetName().Name; + Assembly app_asm = Assembly.GetEntryAssembly(); + + if (app_asm == null) + app_asm = Assembly.GetCallingAssembly(); + + this.app_name = app_asm.GetName().Name; } public Notification (string summary, string body) : this () { @@ -256,7 +260,7 @@ namespace Notifications { public void AttachToWidget (Gtk.Widget widget) { int x, y; - widget.GdkWindow.GetOrigin (out x, out y); + widget.Window.GetOrigin (out x, out y); if (widget.GetType() != typeof (Gtk.Window) || ! widget.GetType().IsSubclassOf(typeof (Gtk.Window))) { x += widget.Allocation.X; @@ -301,9 +305,15 @@ namespace Notifications { if (shown && !updates_pending) { updates_pending = true; GLib.Timeout.Add (100, delegate { - if (updates_pending) { - Show (); - updates_pending = false; + try { + if (updates_pending) { + Show (); + updates_pending = false; + } + } catch (Exception ex) { + // do not throw an exception in a GTK+ callback as + // this will _crash_ the application + Console.WriteLine("Ignoring exception: {0}", ex); } return false; }); @@ -341,13 +351,10 @@ namespace Notifications { } public void AddAction (string action, string label, ActionHandler handler) { - if (Notifications.Global.Capabilities != null && - Array.IndexOf (Notifications.Global.Capabilities, "actions") > -1) { - lock (action_map) { - action_map[action] = new ActionTuple (label, handler); - } - Update (); + lock (action_map) { + action_map[action] = new ActionTuple (label, handler); } + Update (); } public void RemoveAction (string action) { |