libwnck should signal last use of GdkPixbuf
Submitted by Stephane Chauveau
libwnck provides icons as GdkPixbuf.
A program using libwnck do not have any simple ways to know when such a GdkPixbuf is not anymore in use by libwnck.
I think that libwnck should send a signal to the GdkPixbuf just before releasing its last reference.
For example, consider the windows menu in the panel-menu. This program transforms each GdkPixbuf into a GdkImage which is used to create a menu entry icon.
With the current libwnck, a different GdkImage has to be created for each window (potentially using the same GdkPixbuf) each time the menu is created. A better approach could be to create a single GdkImage for each GdkPixbuf and to reuse it until the GdkPixbuf is destroyed.
A simple but wrong approach is to attach the GdkImage to the GdkPixbuf using g_object_set_qdata_full. The callback function would free GdkImage when the GdkPixbuf is finalized.
This method does not work because the GdkImage creates a reference to the GdkPixbuf so the GdkPixbuf is never finalized and the callback is never called (there is a circular dependancy).
The panel needs an explicit signal from libwnck to free the GdkImage.