GNOME Bugzilla – Bug 645222
The Notify GI can't work because of constructor
Last modified: 2011-03-21 03:55:12 UTC
In Notify, if I construct the Notification with summary, body, icon_name and id, "body" and "icon_name" will fail. But there's no problem if I set them explicitly. The command: $ python -c "from gi.repository import Notify;Notify.init('test');n=Notify.Notification(summary='summary',body='body',icon_name='gedit',id=1);print n.get_property('summary'),n.get_property('body'),n.get_property('icon_name'),n.get_property('id')" The output (the body and icon_name failed): (process:30826): libnotify-CRITICAL **: notify_notification_update: assertion `summary != NULL && *summary != '\0'' failed (process:30826): libnotify-CRITICAL **: notify_notification_update: assertion `summary != NULL && *summary != '\0'' failed summary None None 1 This command which set properties explicitly works. $ python -c "from gi.repository import Notify;Notify.init('test');n=Notify.Notification(summary='summary',id=1);n.set_property('body','body');n.set_property('icon_name','gedit');print n.get_property('summary'),n.get_property('body'),n.get_property('icon_name'),n.get_property('id')" The output: summary body gedit 1 Here's another problem: The "summary" is a required parameter, but I can still construct the like this: n=Notify.Notification() Please fix this problem. Thanks.
And it works if you call the Notification constructor: $ python -c "from gi.repository import Notify;Notify.init('test');n=Notify.Notification.new('summary', 'body', 'gedit');print n.get_property('summary'),n.get_property('body'),n.get_property('icon_name'),n.get_property('id')" summary body gedit 0
(In reply to comment #0) > > Here's another problem: > > The "summary" is a required parameter, but I can still construct the like this: > n=Notify.Notification() This can only be fixed with an override right now as we use g_object_new to create objects and don't call constructors directly. There is currently no way to tell if a property has to be set. In the case of the g_warning it really should be a GError that is returned, not an assert. I'm not quite sure why the properties aren't being set. I'll take a look but I am guessing this is a bug in the library, not pygobject.
Ok, yes it is a bug in libnotify which requires the summary be set before any other property is set. Since we don't order how properties are set, it just so happens that some of the other properties get set before summary is. In my opinion the library should be fixed to return a GError when the notification is sent over the wire if the summary is not set. It shouldn't error out until after it first requests the notification daemon to display it. Reassigning.
Created attachment 183850 [details] [review] don't assert if summary is not set, return gerror instead * FIXME: this is just an example of how to fix this issue.
Pushed a slightly different fix