On Thu, 5 Nov 2009 06:28:36 -0800
Daniel Burrows <dburr...@algebraicthunk.net> 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@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to