[patch] Re: mcs-manager dialog too wide

Benedikt Meurer benedikt.meurer at unix-ag.uni-siegen.de
Tue Apr 4 13:10:46 CEST 2006


Adriano Winter Bess wrote:
>>You should first add the label to the box before calculating the size
>>requesition.
> 
> Sorry, but I don't understand why, specially because I just need to know the
> width it would naturally request whithout being inside a container, i.e. the
> size indeed occupied by the label's text. The whole point is the following: if
> the label's natural width (which is probably very close to the button's width)
> is bigger than the label's height plus the image's height (which is close to the
> button's height) times a factor (in this case, 2), than we constrain the label's
> width in such a way that it is forced to wrap line.

You're missing the point: To determine the width of the label, you need
to know the font that should be used, and the font is a per screen
setting, so you need to know the screen for the widget. But until a
widget is part of a window, it doesn't know the screen and so it will
just measure using the default screen, and the measured width will be
inappropriate for the real screen. This is a bug present in many Gtk
apps, because its too easy to b0rk it, esp. with the existing code
samples google finds for Gtk. It's not much of an issue as long as the
application uses only a single screen, since there's only the default
screen then. I just checked xfce4-session and xfce-mcs-manager is run
once per screen, so this would work for xfce-mcs-manager (now!), but
once you start to introduce these kinds of bugs, you'll have a hard time
later tracing the problem when xfce-mcs-manager is changed to support
multiple screens (just an example).

>>Also, this solution is rather hacky, can't we use
>>gtk_label_set_max_width_chars() instead?
> 
> Unfortunatelly I'm afraid not, it doesn't interact well with GtkLabel's line
> wrapping (the width is constrained but the line isn't wrapped at all, so parts
> of the label are not shown, which is even worse). IMHO, this whole GtkLabel line
> wrapping stuff looks like a hack, starting by the (undocumented) default 65
> latin characteres limit.

Ok, then we should use a custom label class that handles the wrapping
and the alignment properly, but don't try to replace a hack with a hack.

> Regards,
> Adriano

Benedikt



More information about the Xfce4-dev mailing list