Christian, Mike and I have been having productive discussions on changes I have felt were needed in the notification protocol and library. To that effect I have been working on revamping both and I am happy to say I have got the library compiling and sending messages over the bus. It is not ready to be checked in yet but that should come relatively soon.

The major changes were simplifying the protocol so it fit more into the mold the newer D-Bus protocol and better designing the input interactions. Desktop Notifications were started way back when D-Bus was still passing nul’s over the bus and didn’t have a recursive type system. On the library side I made it more gtk centric - using gobject, being able to be attached to widgets for x, y location and also utilizing the glib D-Bus bindings for better readability in the code. Actions will also attach to callbacks and such once I get to that part.

Sorry, no pretty screenshots. That is next week when I move on to revamping the server. Once I can get the server showing notifications and I can test thing more thoroughly I will be asking for permission to branch the old stuff and check this code in. I was hoping to do this all sooner but D-Bus releases and debugging along with other stuff kept popping up.

Protocol Changes:

org.freedsektop.Notifications.Notify has a much more terse signature:
* s, app name
* i, notification id #
* s, icon name(the name of a system icon or URI)
* s, summary
* s, message
* as, actions (this will be an action id/action label pair. we could have used an aas signature but why complicate things)
* a{sv}, dictionary of hints
* i, timeout (-1 = use server default, 0 = never, > 0 = time in milliseconds)

There is also an int32 returned as the message id

Library Changes

Using the library looks something like this:

notify  = notify_notification_new (summary, body, icon_str, NULL);
notify_notification_set_category (notify, type);
notify_notification_set_urgency (notify, urgency);
notify_notification_set_timeout (notify, expire_timeout);
notify_notification_set_hint_string ("author", "J5");

notify_notification_send (notify, error);

For all the sets there are sane defaults so you don’t even have to set urgency or timeout if the defaults work for you. Also there will be an easy way to update the contents so all you have to do is update the contents and call send again to get the notification to update. Also as I said before sending in a widget instead of NULL to the constructor will have the library automagicly extract the x, y attributes and add them to the hints when you send your notification. A small but nice little convenience.

When the library will really kick into high gear is when I get to implementing actions. The library will take care of setting up filter functions and what ever else to handle the D-Bus messages which will be routed directly to the owner of the notification instead of broadcast as a signal. All a programmer will have to do is integrate D-Bus with their mainloop and then use this method to setup the action and callback:

gboolean notify_notification_add_action (NotifyNotification *notification,
                                    const char *action,
                                    const char *label,
                                    NotifyActionCallback callback);

The callback will passed in the notification and the action. The ability to attach userdata to the notification gives even more flexibility.

[read this post in: ar de es fr it ja ko pt ru zh-CN ]