dbus-sharp icon indicating copy to clipboard operation
dbus-sharp copied to clipboard

How to catch signals?

Open dicktracy87 opened this issue 9 years ago • 0 comments

I'm playing with the Notifications example, I would like to print something on the console output when a notification is closed. So I added the event to the interface

    [Interface ("org.freedesktop.Notifications")]
    public interface Notifications : Introspectable, Properties
    {
        ServerInformation GetServerInformation ();
        string[] GetCapabilities ();
        void CloseNotification (uint id);
        uint Notify (string app_name, uint id, string icon, string summary, string body, string[] actions, IDictionary<string,object> hints, int timeout);
        event NotificationClosedHandler NotificationClosed;
        event ActionInvokedHandler ActionInvoked;
    }
    public delegate void NotificationClosedHandler (uint id, uint reason);
    public delegate void ActionInvokedHandler (uint id, string action);

And the delegate in the main:

    nf.NotificationClosed += delegate(uint id, uint reason) {
        Console.WriteLine("Notification Closed");
    };

The code compiles without errors but I nothing is printed when a notifications is closed.

dicktracy87 avatar May 20 '16 09:05 dicktracy87