libnotify notifications management



Hi all,

I have a couple of questions about the usage of libnotify.
My application needs to send notifications and then don't care about them anymore (Eg. just display a notification then ask the gnome subsystem to automatically get rid of that). I use the following code (please don't care about the fact I'm using a void* instead of NotifyNotification* ... at the end of the day those are C pointers):

notify_init("application_name");
...
void *notification = notify_notification_new("title", "message", 0, 0);
if (notification) {
   notify_notification_set_timeout(notification, -1);
   notify_notification_show(notification, 0);
   g_object_unref(notification);
}
...
notify_uninit();

Is the above code correct to implement such behavior?
I mean, with this code (that is working fine - eg. notifications are shown), am I sure that the g_object_unref(notification); will then force the underlying gnome/notification daemon to take care and dispose the notification properly once the timeout (default value -1) has expired? Will it get rid of the memory allocated in the current process to (locally) create the notification? Do I have to use other functions to implement the set-display-n-forget notifications? Please note that these are the only GTK++ functions that I use; if I have to use some other to properly perform the operation, feel free to tell me. I'm asking this because I want to be sure this is the proper way to avoid memory leaks.

Thanks in advance,
Cheers,

Emanuele Oriani


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]