GNOME Bugzilla – Bug 326693
PangoLayouts should be query-able about their effective properties (width / wrapped / ellipsized / etc)
Last modified: 2007-01-16 19:45:53 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)
sounds like a useful feature to have.
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).
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?
*** Bug 328456 has been marked as a duplicate of this bug. ***
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.
*** Bug 135843 has been marked as a duplicate of this bug. ***
*** Bug 328585 has been marked as a duplicate of this bug. ***
Related bug: Bug 329545 – pango_layout_get_size is buggy
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
About get_effective_width, please see bug 329545 too. It's in fact just returning logical_rect->x + logical_rect->width.
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.
About Bug 328456 and Bug 329545.
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( ).
the patch that its' id is 58987 is obsolete.
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.
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? :)
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.
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?
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.
*** Bug 363510 has been marked as a duplicate of this bug. ***
Bug 363510 has a patch for is_ellipsized.
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.
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.
Closing as it doesn't make sense for width, and unknown glyphs is tracked in bug 328585.