Re: decent way to access "private" data of widgets



xander <xvw@warande0147.warande.uu.nl> writes:
> hi again,
> 
> sorry for flooding this mailing list with stupid questions, but you all
> have been very helpful to me (THANKS).
> 
> my question: what's the right way to access for instance the width of a
> widget? I can use gdk* functions or look deeper into the widget
> struct. Can this value be retrieved more elegantly using
> gtk_object_get_data?
> 

Usually you don't want to get the size of a widget; widgets can change
size at any time.

What you want to do is _keep track of_ the size of the widget, and
update whatever data structures you're concerned about when it
changes. The way to do that is to connect to the size_allocate signal.

The last allocated size is in widget->allocation, so the current size
of a widget is widget->allocation.width by widget->allocation.height, 
but this can change whenever it feels like it, and also won't be what
you expect just after you create a widget.

Havoc




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