After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 318276 - GtkLabels not recalculating the text layout correctly.
GtkLabels not recalculating the text layout correctly.
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkLabel
2.6.x
Other All
: Normal minor
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2005-10-08 11:18 UTC by Cole
Modified: 2018-02-10 03:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
wrong.png (421 bytes, image/png)
2005-10-08 11:19 UTC, Cole
Details
correct.png (379 bytes, image/png)
2005-10-08 11:20 UTC, Cole
Details

Description Cole 2005-10-08 11:18:48 UTC
Please describe the problem:
Gtk 2.6.8 win32

I have a GtkContainer derived class that uses gtk_widget_size_allocate to place
and size a GtkLabel.
The GtkLabels do not always appear to recalculate the text layout correctly (see
wrong.png).

If directly after the gtk_widget_size_allocate I do a gtk_widget_size_request
then the layout is correct (see correct.png).

In both instances the bounding for the GtkLabel is {0, 0, 67, 22}.

Looking at the sources I think it could be that gtk_label_ensure_layout is
called in gtk_label_size_request.
Could the same call be placed in gtk_label_size_allocate, along the lines of...

if ((allocation->width != widget->allocation.width) || 
    (allocation->height != widget->allocation.height)
{
    gtk_label_ensure_layout (label);
}


I have not been able to test this with modified GtkLabel sources though.

Kind Regards

Steps to reproduce:



Actual results:


Expected results:


Does this happen every time?
Yes

Other information:
Comment 1 Cole 2005-10-08 11:19:55 UTC
Created attachment 53223 [details]
wrong.png
Comment 2 Cole 2005-10-08 11:20:27 UTC
Created attachment 53224 [details]
correct.png
Comment 3 Thierry Vignaud 2006-05-18 21:29:09 UTC
is this bug still valid?
Comment 4 Cole 2006-05-22 19:39:48 UTC
In the latest 2.8.14-rc1 from http://gladewin32.sourceforge.net it still is.
Comment 5 Cody Russell 2007-12-01 20:01:28 UTC
I've never reproduced this.  Is it still valid?  If so, can you provide a simple demo program that can exploit the bug?
Comment 6 Cole 2007-12-02 19:38:16 UTC
Yes, it is still valid.  You also sometimes see this with a GtkLabel in a GtkButton not repostioning correctly after the button is resized (I've seen this recently).  The project I have been working on intermittently over the years is a library called curlyankles which does some weird and complicated stuff.  I think you may find refences to this bug number in the code.  You'll forgive me but over 2 years after this bug was raised I can't remember the exact nature of why it happens.  I did research this at the time and remember trying out the initial posts fix which seemed to resolve the problem.
You say you have not reproduced this, what have you tried?  Thanks
Comment 7 Cole 2007-12-02 19:52:51 UTC
Back to the intial post.  Is the GtkLabel really reliant on its layout being calculated via its size_request rather than its size_allocate?  I would have thought that the layout would be calculated in a new allocation rather than a request.  I think this is where the error is.  My gtkcontainer derivative is more like a GtkFixed which I don't think does a size request along the lines of a usual GtkContainers?
Comment 8 Cody Russell 2007-12-02 20:00:25 UTC
Is this -only- happening on Win32?
Comment 9 awilliam 2011-02-23 15:50:55 UTC
I believe I see this bug on LINUX (openSUSE) via use of PyGTK.

See the mail list thread at http://www.daa.com.au/pipermail/pygtk/2011-February/019434.html

Binding a method of -

def label_size_allocate_hack(widget, allocation):
    "Callback which re-allocates the size of a label."
    layout = widget.get_layout()
    lw_old, lh_old = layout.get_size()
    # fixed width labels
    if lw_old / pango.SCALE == allocation.width:
        return
    # set wrap width to the pango.Layout of the labels
    layout.set_width(allocation.width * pango.SCALE)

to the size-allocate event works around the issue and text displays correctly wrapped.

label.connect_after("size-allocate", label_size_allocate_hack)

This is shamelessly stolen from the StackOverflow thread at

http://stackoverflow.com/questions/1893748/pygtk-dynamic-label-wrapping/1911179#1911179
Comment 10 Matthias Clasen 2018-02-10 03:45:13 UTC
We're moving to gitlab! As part of this move, we are closing bugs that haven't seen activity in more than 5 years. If this issue is still imporant to you and
still relevant with GTK+ 3.22 or master, please consider creating a gitlab issue
for it.