|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Detecting whether a widget is displayed. Hi list,
I have what's probably a simple GTK+ problem, and I was wondering if anyone could give me a tip. I'm trying to write a custom widget (in GTK--) that would benefit from knowing whether it's currently visible or not. It seems pretty easy to detect when a widget becomes visible for the first time by hooking into the "expose" signal, but I can't for the life of me find any way of detecting when a widget becomes invisible. (for instance, when the user switches away from its tab in a notebook or scrolls past it in a TextView) The most promising thing I found was the "visibility notify event", but it never seems to get delivered to my widget. I've also tried to use is_viewable() and get_visible_region() on the GDK window, but even if these work (they don't seem to so far, but I could be doing it wrong) I need a signal or event so that I know when to test them. Any suggestions? Thanks, Daniel _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@... http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list |
|
|
Re: Detecting whether a widget is displayed.On Thu, 2009-11-05 at 06:28 -0800, Daniel Burrows wrote:
> I'm trying to write a custom widget (in GTK--) that would benefit > from knowing whether it's currently visible or not. Do the map-event and unmap-event signals on GtkWidget do what you need? _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@... http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list |
|
|
Re: Detecting whether a widget is displayed.On Thu, Nov 05, 2009 at 04:31:27PM +0200, Lars Wirzenius <liw@...> was heard to say:
> On Thu, 2009-11-05 at 06:28 -0800, Daniel Burrows wrote: > > I'm trying to write a custom widget (in GTK--) that would benefit > > from knowing whether it's currently visible or not. > > Do the map-event and unmap-event signals on GtkWidget do what you need? I tried them earlier -- it didn't seem like my object was ever receiving the map or unmap events, though. I can take another look; maybe my test was wrong. One other thing that occurred to me since I wrote that first mail is that maybe I need to wrap an event box around the image. Do map/unmap/visibility-notify events work on images at all? Daniel _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@... http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list |
|
|
Re: Detecting whether a widget is displayed.On Thu, 2009-11-05 at 07:58 -0800, Daniel Burrows wrote:
> On Thu, Nov 05, 2009 at 04:31:27PM +0200, Lars Wirzenius <liw@...> was heard to say: > > On Thu, 2009-11-05 at 06:28 -0800, Daniel Burrows wrote: > > > I'm trying to write a custom widget (in GTK--) that would benefit > > > from knowing whether it's currently visible or not. > > > > Do the map-event and unmap-event signals on GtkWidget do what you need? > > I tried them earlier -- it didn't seem like my object was ever > receiving the map or unmap events, though. I can take another look; > maybe my test was wrong. Did you connect to map or map-event? Both signals seem to exist. I think the latter is the one you'd want. (Ditto for unmap and unmap-event.) _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@... http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list |
|
|
Re: Detecting whether a widget is displayed.On Thu, 5 Nov 2009 06:28:36 -0800
Daniel Burrows <dburrows@...> wrote: > > I have what's probably a simple GTK+ problem, and I was wondering if > anyone could give me a tip. > > I'm trying to write a custom widget (in GTK--) that would benefit > from knowing whether it's currently visible or not. It seems pretty > easy to detect when a widget becomes visible for the first time by > hooking into the "expose" signal, but I can't for the life of me find > any way of detecting when a widget becomes invisible. (for instance, > when the user switches away from its tab in a notebook or scrolls past > it in a TextView) > > The most promising thing I found was the "visibility notify event", > but it never seems to get delivered to my widget. I've also tried to > use is_viewable() and get_visible_region() on the GDK window, but even > if these work (they don't seem to so far, but I could be doing it > wrong) I need a signal or event so that I know when to test them. You need to add the GDK_VISIBILITY_NOTIFY_MASK for the widget with gtk_widget_add_events() in order to get visibility notify events on it. Also test GTK_WIDGET_VISIBLE() if you might call hide() on the widget (eg when in the system tray), because hiding a widget for some reason does not count as a change of visibility status. Depending on what you are after, you may also want to track window state events for cases where a window is iconified (minimised). In other words, a lot depends on what you mean by "visible". Your meaning many not be the same as GDK's meaning. If you test for all of the conditions I have mentioned it will probably do what you want. Chris _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@... http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list |
| Free embeddable forum powered by Nabble | Forum Help |