GNOME Bugzilla – Bug 387215
GtkStatusIcon doesn't signal when it is embedded
Last modified: 2007-02-16 20:33:35 UTC
The issue here is that you can't rely on the _is_embedded() call straight after the icon is created. Since it is not instant, it would be better for applications developers to have a signal to watch out for instead of having to add their own timeouts.
Patch to follow.
Created attachment 78578 [details] [review]
Fix for this bug
Is this good enough as is, or would it be better to have some sort of timeout for attempting to embed the status icon and signal if not possible?
I have also updated the documentation to mention that the _is_embedded() signal is not something you can rely on straight after calling _new().
I don't think we should be polling every 500ms whether the icon is embedded...
The backend tray (gtktrayicon-x11) knows when it's embedded, can't it signal and status icon just forward the signal?
I thought so and looked into it a bit some time ago, but AFAIR it wasn't entirely trivial.
chpe: are you talking about the ::embedded signal for the GtkPlug? I agree having a 500ms timeout isn't great, which is why I asked about having a timeout for the polling to accept that it is not ever going to be embedded - or perhaps update the backend so we signal when we know either way.
I am not entirely sure which is the best way forward on this. From an application writer's point of view, I would rather have some sort of callback which returns the state (embedded or not) and times out after a period of 10 seconds. I wrote the patch with the thinking that the status icon could be embedded or not at any point and it was some state that could change often. If it is simply embedded once then a callback or property is better than a signal by far.
Created attachment 78600 [details] [review]
my proposed patch
No, I wasn't talking about ::embedded on the GtkPlug (that signal is completely useless :).
But the GtkPlug knows when its embedding changes, so it should notify on this. This patch adds a "embedded" property on GtkPlug and makes the status icon listen to notify::embedded on its tray icon and forward the notification.
Playing with testtray and teststatusicon, this seems to work fine.
Seems to work nicely, thanks chpe.
2006-12-22 Matthias Clasen <email@example.com>
Make it possible to track the embeddedness of
statusicon (#387215, Martyn Russell, patch by Christian
* gtk/gtkstatusicon.c: Add orientation and embedded properties.
* gtk/gtkplug-x11.c: Add an embedded property.
* tests/teststatusicon.c: Test the new properties.
This patch breaks build on Windows and Mac OS X ports (and all other platforms that doesn't have a GtkTrayIcon.
Thread on gtk-devel-list: http://mail.gnome.org/archives/gtk-devel-list/2006-December/msg00112.html
Noticed that Tor already commited this to CVS to closing again. Sorry for the noise.