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 530255 - GtkAboutDialog cuts off comments label
GtkAboutDialog cuts off comments label
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.12.x
Other Linux
: Normal minor
: ---
Assigned To: Jan Arne Petersen
gtk-bugs
: 438752 526090 536218 540748 555821 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-04-27 21:58 UTC by Andreas Köhler
Modified: 2014-12-23 11:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (353 bytes, text/plain)
2008-04-27 21:59 UTC, Andreas Köhler
  Details
Screen shot, showing the label (9.57 KB, image/png)
2008-04-27 22:01 UTC, Andreas Köhler
  Details
Subtract logical.x in get_layout_location (1.15 KB, patch)
2008-05-02 20:17 UTC, Jan Arne Petersen
committed Details | Review
add gtk_label_ensure_layout call to gtk_label_get_layout_offsets (364 bytes, patch)
2008-06-03 19:42 UTC, Jan Arne Petersen
committed Details | Review
test showing regression caused by fix for bug #530255 (746 bytes, text/plain)
2008-10-21 13:37 UTC, Frederic Crozat
  Details

Description Andreas Köhler 2008-04-27 21:58:21 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
Comment 1 Andreas Köhler 2008-04-27 21:59:05 UTC
Created attachment 110006 [details]
Test case
Comment 2 Andreas Köhler 2008-04-27 22:01:00 UTC
Created attachment 110007 [details]
Screen shot, showing the label
Comment 3 Andreas Köhler 2008-04-27 22:02:17 UTC
*** Bug 526090 has been marked as a duplicate of this bug. ***
Comment 4 Jan Arne Petersen 2008-05-02 20:15:51 UTC
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
Comment 5 Jan Arne Petersen 2008-05-02 20:17:11 UTC
Created attachment 110286 [details] [review]
Subtract logical.x in get_layout_location
Comment 6 Matthias Clasen 2008-05-25 04:41:05 UTC
Behdad, does this look right ?
Comment 7 Behdad Esfahbod 2008-05-25 05:10:56 UTC
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.
Comment 8 Jan Arne Petersen 2008-05-25 12:29:37 UTC
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).
Comment 9 Björn Lindqvist 2008-06-02 00:51:22 UTC
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?
Comment 10 Jan Arne Petersen 2008-06-02 17:35:21 UTC
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.
Comment 11 Jan Arne Petersen 2008-06-02 21:52:48 UTC
*** Bug 536218 has been marked as a duplicate of this bug. ***
Comment 12 Jan Arne Petersen 2008-06-03 19:42:47 UTC
Created attachment 112075 [details] [review]
add gtk_label_ensure_layout call to gtk_label_get_layout_offsets
Comment 13 Björn Lindqvist 2008-06-03 21:14:02 UTC
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...
Comment 14 Björn Lindqvist 2008-06-21 02:16:33 UTC
Can you commit this patch?
Comment 15 Björn Lindqvist 2008-06-29 12:57:13 UTC
*** Bug 540748 has been marked as a duplicate of this bug. ***
Comment 16 Johan (not receiving bugmail) Dahlin 2008-06-29 14:28:48 UTC
This can pretty safely be committed, and as the duplicates are stacking up it should go in soon.
Comment 17 Behdad Esfahbod 2008-06-29 17:17:20 UTC
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.

Comment 18 Christian Persch 2008-07-23 09:58:29 UTC
*** Bug 438752 has been marked as a duplicate of this bug. ***
Comment 19 Frederic Crozat 2008-10-21 13:37:20 UTC
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.
Comment 20 Frederic Crozat 2008-10-21 13:39:58 UTC
reopening, because of the regression
Comment 21 Christian Persch 2009-04-03 00:22:02 UTC
*** Bug 555821 has been marked as a duplicate of this bug. ***
Comment 22 Felipe Heidrich 2009-06-17 20:31:23 UTC
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.
Comment 23 Felipe Heidrich 2009-06-24 15:16:26 UTC
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.
Comment 24 Matthias Clasen 2014-12-23 11:39:25 UTC
I don't think this is relevant anymore. label size allocation has been redone in the meantime.