GNOME Bugzilla – Bug 530255
GtkAboutDialog cuts off comments label
Last modified: 2014-12-23 11:39:25 UTC
See the attached test case which simply calls gtk_show_about_dialog() with a long comments property. As you can see this string is cut off, but probably should not. Pango 1.20.0 Gtk+ 2.12.8
Created attachment 110006 [details] Test case
Created attachment 110007 [details] Screen shot, showing the label
*** Bug 526090 has been marked as a duplicate of this bug. ***
This is a bug in GtkLabel. The width of the PangoLayout does not equals the logical width of the extents of the PangoLayout (so with justify != JUSTIFY_LEFT => logical.x > 0). Fix: a) make sure logical.x is always 0 or b) subtract logical.x in get_layout_location
Created attachment 110286 [details] [review] Subtract logical.x in get_layout_location
Behdad, does this look right ?
It does. Except that there's a pango_layout_get_pixel_extents() that can be reused. No big deal though as Pango caches extents already.
2008-05-25 Jan Arne Petersen <jpetersen@jpetersen.org> * gtk/gtklabel.c: (get_layout_location): Subtract logical.x from x to fix the wrong position for right and center justified labels with logical.x > 0 (#530255).
The patch breaks some things for unrealized widgets that used to work. label = gtk.Label('<b>Hi</b>') assert label.get_layout_offsets() == (-1, -1) with the patch I get: PangoWarning: pango_layout_get_pixel_extents: assertion `PANGO_IS_LAYOUT (layout)' failed and the values in the returned 2-tuple are undefined. Does pango_layout_get_pixel_extents() really have to be used here?
label = gtk.Label('<b>Hi</b>') label.set_ellipsize (True) assert label.get_layout_offsets() == (-1, -1) with the old version will fail, too. So this bug is not really new. There are two options to fix the bug: 1.) get_layout_offsets() returns (-1, -1) if label->layout == NULL 2.) get_layout_offsets() calls gtk_label_ensure_layout. I would got with the second option.
*** Bug 536218 has been marked as a duplicate of this bug. ***
Created attachment 112075 [details] [review] add gtk_label_ensure_layout call to gtk_label_get_layout_offsets
Testend and looks good to me! As an aside, why isn't the layout created at initiation time and cleared all over the code? Seems like that could remove a lot of redundant gtk_label_ensure_layout calls...
Can you commit this patch?
*** Bug 540748 has been marked as a duplicate of this bug. ***
This can pretty safely be committed, and as the duplicates are stacking up it should go in soon.
2008-06-29 Behdad Esfahbod <behdad@gnome.org> Bug 530255 – GtkAboutDialog cuts off comments label Followup patch from Jan Arne Petersen * gtk/gtklabel.c (gtk_label_get_layout_offsets): Ensure layout.
*** Bug 438752 has been marked as a duplicate of this bug. ***
Created attachment 121012 [details] test showing regression caused by fix for bug #530255 in LXDE launcher, big buttons with centered wrapped text (in gtklabel) are no longer center correctly because of the fix for this bug. I'm attaching a testcase showing the issue.
reopening, because of the regression
*** Bug 555821 has been marked as a duplicate of this bug. ***
this bug affects Eclipse, see https://bugs.eclipse.org/279339 The patch in comment 5 seems wrong, it visually hides the justification done by the PangoLayout by moving the layout to the left. It affects all wrap label that call gtk_widget_size_request and gtk_label_set_justify with RIGHT or CENTER. In right-to-left is even worse, cause the default justify is RIGHT. So basically it breaks all labels in BIDI locales.
Apparently this bug is not very active at the moment. I'd suggest to remove the fix from comment 5 from HEAD since it causes a regression problem which is affecting more than one product. When time allows better fix for the original problem can be found, but please for the meantime remove the current fix.
I don't think this is relevant anymore. label size allocation has been redone in the meantime.