[patch] Re: mcs-manager dialog too wide

Adriano Winter Bess awbess at gmail.com
Tue Apr 4 12:27:47 CEST 2006


On Tue, Apr 04, 2006 at 09:49:57AM +0200, Benedikt Meurer 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.

One could argue why just not asking the whole button for its size request. I've
tried this, but GTK+ didn't seem to like it very much. Besides this, I tried
first adding the label to the box and then asking for its requisition -- just as
you suggested, and indeed the same problem happened. It's really hard to explain
as I don't actually understand completelly what's going on, but a screenhot may
help:

http://www.das.ufsc.br/~adrianob/mcs-manager-dialog/problem/sshot1.png
http://www.das.ufsc.br/~adrianob/mcs-manager-dialog/problem/sshot2.png

Both screenshots were taken from the dialog with my patch applied modified to ask
for the label's requisition after it's added to the box (in fact, only a two
line swap).

The first screenshot shows how the dialog appears after calling
`xfce-setting-show'. If you look close (that should be hard, I hope you trust
me) you will see that all labels that take only one line are misaligned, a
little bit more to the right than they should be (this is evident looking to UI
plugin, where a character is missing -- there's a hidden 'o' at the end of the
label).

The second screenshot is exactly the same window (didn't even close it!) after
doing something such as changing the GTK theme or the icon theme; you will
notice now that all labels are perfectly aligned. I don't know why this happens,
but if you keep looking to the dialog while changing the GTK theme you will
notice imediatelly how labels are realigned as expected.

My humblest opinion about this is that there's something I'm missing. My not so
humble opinion is that it is a GTK bug. Even more weird is that sometimes
(rarely, but still possible) the effect observed in the first screenshot is not
reproducible, I mean, calling `xfce-setting-show' displays the dialog correctly
(as in the second screenshot), which makes me think about some sort of race
condition.
 
> 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.

Regards,
Adriano
-- 
Adriano Winter Bess

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://mail.xfce.org/pipermail/xfce4-dev/attachments/20060404/b6bf593e/attachment.pgp>


More information about the Xfce4-dev mailing list