From: raster Date: Fri, 20 Apr 2012 12:37:42 +0000 (+0000) Subject: sucky - but have to add this api to fix bug in elm. X-Git-Tag: submit/2.0alpha-wayland/20121127.221958~310 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e2c70fa1673e262983d15459f45d495e5ee1622d;p=profile%2Fivi%2Fedje.git sucky - but have to add this api to fix bug in elm. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@70360 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/ChangeLog b/ChangeLog index 664df41..ebe8a18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -406,3 +406,9 @@ * Add EDJE_VERSION_12 define so edc files can #ifdef compile right. +2012-04-20 Carsten Haitzler (The Rasterman) + + * To work through a bug in Elementary, add + edje_object_part_text_escaped_set() that converts escapes to + plain UTF8 if the part is TEXT. + diff --git a/NEWS b/NEWS index c0bea7c..441230a 100644 --- a/NEWS +++ b/NEWS @@ -35,6 +35,7 @@ Additions: * edje_object_part_text_user_insert() * double click in entry selects word, triple selects line. * EDJE_VERSION_12 define in edc for #ifdefs handling edje 1.2 (or older) + * edje_object_part_text_escaped_set() Improvements: * speedup load time of Edje file. diff --git a/src/lib/Edje.h b/src/lib/Edje.h index fc76657..a12c168 100644 --- a/src/lib/Edje.h +++ b/src/lib/Edje.h @@ -2299,6 +2299,19 @@ EAPI void edje_object_text_change_cb_set (Evas_Object *obj, Edje_Te EAPI Eina_Bool edje_object_part_text_set (Evas_Object *obj, const char *part, const char *text); /** + * @brief Sets the text for an object part, but converts HTML escapes to UTF8 + * + * This converts the given string @p text to UTF8 assuming it contains HTML + * style escapes like "&" and "©" etc. IF the part is of type TEXT, + * as opposed to TEXTBLOCK. + * + * @param obj A valid Evas Object handle + * @param part The part name + * @param text The text string + */ +EAPI Eina_Bool edje_object_part_text_escaped_set (Evas_Object *obj, const char *part, const char *text); + +/** * @brief Return the text of the object part. * * @param obj A valid Evas_Object handle diff --git a/src/lib/edje_util.c b/src/lib/edje_util.c index d9b73bd..0dba28f 100644 --- a/src/lib/edje_util.c +++ b/src/lib/edje_util.c @@ -1157,6 +1157,75 @@ edje_object_part_text_get(const Evas_Object *obj, const char *part) return NULL; } +EAPI Eina_Bool +edje_object_part_text_escaped_set(Evas_Object *obj, const char *part, const char *text) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return EINA_FALSE; + if ((rp->part->type == EDJE_PART_TYPE_TEXT) && (text)) + { + Eina_Strbuf *sbuf; + char *esc_start = NULL, *esc_end = NULL; + char *s, *p; + Eina_Bool ret; + + sbuf = eina_strbuf_new(); + p = (char *)text; + s = p; + for (;;) + { + if ((*p == 0) || (esc_end) || (esc_start)) + { + if (esc_end) + { + const char *escape; + + escape = evas_textblock_escape_string_range_get + (esc_start, esc_end + 1); + if (escape) eina_strbuf_append(sbuf, escape); + esc_start = esc_end = NULL; + } + else if (*p == 0) + { + eina_strbuf_append_length(sbuf, s, p - s); + s = NULL; + } + if (*p == 0) + break; + } + + if (*p == '&') + { + esc_start = p; + esc_end = NULL; + eina_strbuf_append_length(sbuf, s, p - s); + s = NULL; + } + else if (*p == ';') + { + if (esc_start) + { + esc_end = p; + s = p + 1; + } + } + p++; + } + ret = _edje_object_part_text_raw_set + (obj, rp, part, eina_strbuf_string_get(sbuf)); + eina_strbuf_free(sbuf); + return ret; + } + if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return EINA_FALSE; + return _edje_object_part_text_raw_set(obj, rp, part, text); +} + + char * _edje_text_escape(const char *text) {