diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2007-01-16 10:36:42 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2007-01-16 10:36:42 +0000 |
commit | 9354b7f487b706ddb693a32fe01cdaf729f0b66b (patch) | |
tree | 99da184a9a6fdccd1ed480b5c4e65a9ee25d04a5 /pango/pango-layout.c | |
parent | 375cb212021277fd31142080a4ebb3fcf9b27a43 (diff) | |
download | pango-9354b7f487b706ddb693a32fe01cdaf729f0b66b.tar.gz |
Bug 363510 – Ability to query whether a PangoLayout is effectively
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.
svn path=/trunk/; revision=2150
Diffstat (limited to 'pango/pango-layout.c')
-rw-r--r-- | pango/pango-layout.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 52b9dccf..e708d555 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -200,6 +200,7 @@ pango_layout_init (PangoLayout *layout) layout->wrap = PANGO_WRAP_WORD; layout->ellipsize = PANGO_ELLIPSIZE_NONE; + layout->is_ellipsized = FALSE; } static void @@ -306,7 +307,7 @@ pango_layout_copy (PangoLayout *src) layout->wrap = src->wrap; layout->ellipsize = src->ellipsize; - /* log_attrs, lines fields are updated by check_lines */ + /* is_ellipsized, log_attrs, lines fields are updated by check_lines */ return layout; } @@ -845,6 +846,32 @@ pango_layout_get_ellipsize (PangoLayout *layout) } /** + * pango_layout_is_ellipsized: + * @layout: a #PangoLayout + * + * Queries whether the layout had to ellipsize any paragraphs. + * + * This can only return %TRUE if the ellipsization mode for @layout + * is not %PANGO_ELLIPSIZE_NONE, a positive width is set on @layout, + * and there were paragraphs exceeding that width that had to be + * ellipsized. + * + * Return value: %TRUE if any paragraphs had to be ellipsized, %FALSE + * otherwise. + * + * Since: 1.16 + */ +gboolean +pango_layout_is_ellipsized (PangoLayout *layout) +{ + g_return_if_fail (layout != NULL); + + pango_layout_check_lines (layout); + + return layout->is_ellipsized; +} + +/** * pango_layout_set_text: * @layout: a #PangoLayout * @text: a valid UTF-8 string @@ -2456,6 +2483,8 @@ pango_layout_get_pixel_size (PangoLayout *layout, static void pango_layout_clear_lines (PangoLayout *layout) { + layout->is_ellipsized = FALSE; + if (layout->lines) { GSList *tmp_list = layout->lines; @@ -4571,7 +4600,8 @@ pango_layout_line_postprocess (PangoLayoutLine *line, /* Ellipsize the line if necessary */ - _pango_layout_line_ellipsize (line, state->attrs); + if (_pango_layout_line_ellipsize (line, state->attrs)) + line->layout->is_ellipsized = TRUE; /* Now convert logical to visual order */ |