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 326693 - PangoLayouts should be query-able about their effective properties (width / wrapped / ellipsized / etc)
PangoLayouts should be query-able about their effective properties (width / w...
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
unspecified
Other All
: Normal enhancement
: Medium API
Assigned To: pango-maint
pango-maint
: 328456 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-01-12 06:12 UTC by Milosz Derezynski
Modified: 2007-01-16 19:45 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
get effective width (2.06 KB, patch)
2006-02-09 09:49 UTC, LingNing Zhang
none Details | Review
get effective properties (width / wrap / ellipsize) (3.93 KB, patch)
2006-02-10 05:58 UTC, LingNing Zhang
rejected Details | Review

Description Milosz Derezynski 2006-01-12 06:12:11 UTC
The feature request simply consists of a request to add a method/function for
PangoLayout:

gboolean pango_layout_get_ellipsized (PangoLayout *layout);

NOTE that this is not to be confused with get_ellipsize(). The proposal is meant
for to be able to tell whether the layout had to actually ellipsize or not. The
use case for this would be e.g. to determine whether a tooltip should be shown
or not (if the text was ellipsized, it's appropriate to show a tooltip,
otherwise it might be not neccesary)
Comment 1 Matthias Clasen 2006-01-12 18:25:17 UTC
sounds like a useful feature to have.
Comment 2 Milosz Derezynski 2006-01-12 22:57:32 UTC
Actually this would be *required* for "Tooltips in GtkTreeView", no? I mean, aside of the issue of revamping the Tooltips API as owen proposed, since even then you'd need to know whether the text had to be ellipsized or not..

This PangoLayout API addition could be "propagated" into GtkCellRendererText (as a R/O property), and yeah, this would then probably only really work out in TreeView with the new/proposed API for Tooltips, but it might be already (now, that is) useful in other widgets (Labels, etc).
Comment 3 Behdad Esfahbod 2006-01-29 01:41:09 UTC
I would call it pango_layout_get_effective_ellipsize, like my proposal for pango_layout_get_effective_width in bug #328456.  We need a whole array of pango_layout_get_effective_* methods it seems.

In fact I'm going to broaden this bug to refer to all of them.  From what I can see, we need these:

pango_layout_get_effective_ellipsize: described above
pango_layout_get_effective_width: described in bug #328456
pango_layout_get_effective_wrap: whether text was wrapped


Thinking about it now, get_ellipsized and get_wrapped sound better, but also a bit confusing.

Another feature that people are interested in getting the effective value is the resolved direction, but we cannot provide that easily, since each paragraph may resolve to a different direction.  Return the dirrection of the first paragraph?
Comment 4 Behdad Esfahbod 2006-01-29 01:41:36 UTC
*** Bug 328456 has been marked as a duplicate of this bug. ***
Comment 5 Behdad Esfahbod 2006-01-29 01:56:58 UTC
Humm, this may not be a good idea to dup bugs for different features to this, but I really want to see a consistent naming and behavior designed for all of these.

pango_layout_get_effective_direction is described in but #135843.  It takes an index or something into the text and returns the resolved direction of the paragraph at that position.

There is another one, in bug #328585, asking for whether the layout had any unknown glyphs, ie. characters that for which no glyph was found.
Comment 6 Behdad Esfahbod 2006-01-29 01:57:24 UTC
*** Bug 135843 has been marked as a duplicate of this bug. ***
Comment 7 Behdad Esfahbod 2006-01-29 01:57:34 UTC
*** Bug 328585 has been marked as a duplicate of this bug. ***
Comment 8 Behdad Esfahbod 2006-02-02 00:54:42 UTC
Related bug: Bug 329545 – pango_layout_get_size is buggy
Comment 9 Milosz Derezynski 2006-02-03 03:15:43 UTC
WRG to the namings, i'd distinguish between methods/functions that return a boolean value and others that return an int value. With this in mind, i'd propose:


pango_layout_is_ellipsized ()
pango_layout_is_wrapped ()

for panyo_layout_get_effective_width (), i have no better idea right now given the current names (set_width (), get_width ()), however, i'm not sure what is described in bug #328456 is so good, because it makes things opaque (you don't really know which value it has returned), so well, i think this should be a macro (?), but not a real function call, to emphasize that it's a conveninece thing; in other cases usage of this might be "dangerous" in the sense that people might use it unknowing of the fact that the function doesn't always return the 'same thing', but does an evaluation of it's own, yet 'pretends' to be returning a unique value


Comment 10 Behdad Esfahbod 2006-02-03 03:56:34 UTC
About get_effective_width, please see bug 329545 too.  It's in fact just returning logical_rect->x + logical_rect->width.
Comment 11 LingNing Zhang 2006-02-09 09:49:34 UTC
Created attachment 58987 [details] [review]
get effective width

I have written a patch about adding a new function of pango_layout_get_effective_width( ) and modifying pango_layout_get_size( ) and pango_layout_get_pixel_size( ) as Behdad's idea.
Comment 12 LingNing Zhang 2006-02-09 09:54:15 UTC
About Bug 328456 and Bug 329545.
Comment 13 LingNing Zhang 2006-02-10 05:58:56 UTC
Created attachment 59052 [details] [review]
get effective properties (width / wrap / ellipsize)

adding 3 new function:
pango_layout_get_effective_width( ), 
pango_layout_get_effective_ellipsize( ), 
pango_layout_get_effective_wrap( ).

modifying 2 functions:
pango_layout_get_size( ),
pango_layout_get_pixel_size( ).
Comment 14 LingNing Zhang 2006-02-10 06:03:50 UTC
the patch that its' id is 58987 is obsolete.
Comment 15 Behdad Esfahbod 2006-02-10 06:58:28 UTC
Thanks LingNing, but that's not really what is meant by this request.  The requests are whether any text was actually wrapped in the layout, and whether any text was actually ellipsised.

About effective_width, we do not want to modify current functions.
Comment 16 LingNing Zhang 2006-02-10 08:07:57 UTC
Behdad, pango_layout_get_effective_ellipsize( ) and pango_layout_get_effective_wrap( ) can judge whether any text is actually ellipsized or wrapped in the layout.

pango_layout_get_effective_ellipsize( ):
If there is only one line in the layout, then the text is not ellipsized. And if there are some lines in the layout, then if the return value of pango_layout_get_ellipsize( ) is PANGO_ELLIPSIZE_NONE, it shows that the text is not ellipsized. And if the return value of pango_layout_get_ellipsize( ) is not PANGO_ELLIPSIZE_NONE, it shows that the text is ellipsized.

pango_layout_get_effective_wrap( ):
If there is only one line in the layout, then the text is not wrapped. And if there are some lines in the layout, then if the return value of pango_layout_get_ellipsize( ) is PANGO_ELLIPSIZE_NONE, it shows that the text is wrapped. And if the return value of pango_layout_get_ellipsize( ) is not PANGO_ELLIPSIZE_NONE, it shows that the text is not wrapped.

Do I understand error?
:)
Comment 17 Behdad Esfahbod 2006-02-10 08:15:01 UTC
No, both ellipsize and wrap only work if a width is set on the layout.  And then if you don't have enough text to fill one line, no epplisizing or wrapping happens at all.

It's not just about one line, you may have multiple paragraph, none of them long enough to fill a line.
Comment 18 LingNing Zhang 2006-02-10 08:28:21 UTC
I see, so I call pango_layout_get_width( ) to get the width of the layout. And if the width is -1, then the text is not ellipsized and wrapped.
And I think that if the text is ellipsized, then it must be not wrapped, is it right?
Comment 19 Behdad Esfahbod 2006-02-10 09:56:41 UTC
But if the width is not -1, it's really hard to figure out whether ellipsization/wrapping has happened.  It's not 5 lines of wrapper code really.
Comment 20 Behdad Esfahbod 2006-10-19 22:41:40 UTC
*** Bug 363510 has been marked as a duplicate of this bug. ***
Comment 21 Behdad Esfahbod 2006-10-19 23:21:34 UTC
Bug 363510 has a patch for is_ellipsized.
Comment 22 Behdad Esfahbod 2007-01-16 10:38:28 UTC
2007-01-16  Behdad Esfahbod  <behdad@gnome.org>

        Bug 363510 – Ability to query whether a PangoLayout is effectively
        ellipsized (as opposed to the set_ellpisize()/get_ellipsize() methods
        which only set a request, or return the set request respectively)
        Patch from Milosz Derezynski

        * pango/pango-layout.h:
        * pango/ellipsize.c (_pango_layout_line_ellipsize):
        * pango/pango-layout-private.h:
        * pango/pango-layout.c (pango_layout_init), (pango_layout_copy),
        (pango_layout_is_ellipsized), (pango_layout_clear_lines),
        (pango_layout_line_postprocess):
        New public function:

                pango_layout_is_ellipsized()

        * pango/pango.def:
        * docs/tmpl/layout.sgml:
        * docs/pango-sections.txt:
        Update.

Comment 23 Behdad Esfahbod 2007-01-16 19:44:26 UTC
2007-01-16  Behdad Esfahbod  <behdad@gnome.org>

        Part of Bug 326693 – PangoLayouts should be query-able about their
        effective properties (width / wrapped / ellipsized / etc)

        * pango/pango-layout-private.h:
        * pango/pango-layout.c (pango_layout_init), (pango_layout_copy),
        (pango_layout_is_wrapped), (pango_layout_clear_lines),
        (process_line):
        * pango/pango-layout.h:
        New public function:

                pango_layout_is_wrapped()

        * pango/pango.def:
        * docs/tmpl/layout.sgml:
        * docs/pango-sections.txt:
        Update.

Comment 24 Behdad Esfahbod 2007-01-16 19:45:53 UTC
Closing as it doesn't make sense for width, and unknown glyphs is tracked in bug 328585.