Re: How to get the widget's current width and height?

John K Luebs wrote:
On Tue, Nov 18, 2003 at 09:29:50AM -0500, Tom Liu wrote:

gdk_drawable_get_size(w->window,&wid,&hi); may work for the widget which
has a xwindow such as eventbox. For vbox, label, button etc. It will not work.
Can't believe there is no function to retrive size of widget?!

There is a good reason for this. The size of a widget (it's allocation) is dynamic (can be changed by the user, WM, etc.), so having a function
to query the current size would just facilitate writing fundamentally
broken code. There's no point in getting a value that could become
invalid the moment you return to the mainloop.

As another poster has told you, you should connect to size-allocate.
This way you know that you always have the correct size, and can react

You should also take a moment to think about why you need the size.
Are you sure this is not something you can do in a more
straightforward manner using the packing mechanisms?


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