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 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)
Ability to query whether a PangoLayout is effectively ellipsized (as opposed ...
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
1.15.x
Other All
: Normal enhancement
: ---
Assigned To: Behdad Esfahbod
pango-maint
Depends on:
Blocks:
 
 
Reported: 2006-10-19 21:48 UTC by Milosz Derezynski
Modified: 2007-01-16 10:37 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Patch that adds the described functionality (6.59 KB, patch)
2006-10-19 21:50 UTC, Milosz Derezynski
none Details | Review
Rerolled patch conforming with Owen's recommendation. (4.53 KB, patch)
2006-10-19 23:50 UTC, Milosz Derezynski
none Details | Review
Again, removing the noise i've introduced with the linebreak at the 'break' statement. (4.34 KB, patch)
2006-10-19 23:57 UTC, Milosz Derezynski
committed Details | Review

Description Milosz Derezynski 2006-10-19 21:48:52 UTC
It's currently not possible to query whether a layout was effectively ellipsized. This is useful in a lot of cases, e.g. when you have a layout of fixed width, yet ellipsized, so you can decide on showing a tooltip or not.

One other major case that comes into mind is tooltips (with the new API then) for TreeView, for showing tooltips for text cells with ellipsized text.

The attached patch adds a method pango_layout_is_ellipsized(), which makes it possible to query the layout whether it is actually/effectively ellipsized.
Comment 1 Milosz Derezynski 2006-10-19 21:50:54 UTC
Created attachment 75039 [details] [review]
Patch that adds the described functionality
Comment 2 Behdad Esfahbod 2006-10-19 22:39:23 UTC
Please don't abuse return value of arbitrary functions to return is_ellipsized.  And in cases that you do, it should return gboolean, not int.  Also, don't change coding style: break on the same line that 'if' is is wrong.  Finally, documentation block is missing.
Comment 3 Behdad Esfahbod 2006-10-19 22:41:40 UTC

*** This bug has been marked as a duplicate of 326693 ***
Comment 4 Owen Taylor 2006-10-19 22:49:00 UTC
I agree that process_line/pango_layout_line_postprocess shouldn't get the return
value; I think it's right for _pango_layout_line_ellipsize(). (Not sure
which functions Behdad was referring to.)

You can make pango_layout_line_postprocess simply modify the layout flag
directly.

 if (_pango_layout_line_ellipsize(..))
    layout->ellipsized = TRUE;
Comment 5 Milosz Derezynski 2006-10-19 23:22:23 UTC
Owen: That would be no problem, except that in this function, the Layout object is not available:

static int
pango_layout_line_postprocess (PangoLayoutLine *line,
             ParaBreakState  *state);

Comment 6 Milosz Derezynski 2006-10-19 23:23:35 UTC
Allright, it's available in the LayoutLine struct, sorry.
Comment 7 Milosz Derezynski 2006-10-19 23:45:28 UTC
Quote Behdad: "Please don't abuse return value of arbitrary functions to return is_ellipsized.  And in cases that you do, it should return gboolean, not int.  Also, don't change coding style: break on the same line that 'if' is is wrong.  Finally, documentation block is missing."

The rationale here was, just FWIW, since it's processing multiple lines, i can use  operator |= to accumulate the state of ellipsizing for each processed line, and since gboolean is a typedef which even though it is publicly defined, is still not the proper data type to use with |= (i know the behaviour of int with |=, but i "don't know" the behaviour of |= with gboolean)

Clearly this all isn't neccessary anymore now that i've changed the patch to how Owen recommended it. The removal of the linebreak at the "break" was probably some intuitive code restructuring, and finally, i've added the documentation block.
Comment 8 Milosz Derezynski 2006-10-19 23:50:32 UTC
Created attachment 75046 [details] [review]
Rerolled patch conforming with Owen's recommendation.

I'm attaching it here despite the bug being RESOLVED DUPLICATE, since we've already started resolving the is_ellipsized issue here, and otherwise i'd have to move the first patch to the other bug (just for completeness, etc).
Comment 9 Milosz Derezynski 2006-10-19 23:57:58 UTC
Created attachment 75047 [details] [review]
Again, removing the noise i've introduced with the linebreak at the 'break' statement.
Comment 10 Behdad Esfahbod 2007-01-16 00:33:33 UTC
+ */
+gboolean
+pango_layout_is_ellipsized (PangoLayout *layout)
+{
+  return layout->is_ellipsized;
+}

It needs to do check_lines first.  I'll fix and commit.
Comment 11 Behdad Esfahbod 2007-01-16 10:37:53 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.