sucky - but have to add this api to fix bug in elm.
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 20 Apr 2012 12:37:42 +0000 (12:37 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 20 Apr 2012 12:37:42 +0000 (12:37 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@70360 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
NEWS
src/lib/Edje.h
src/lib/edje_util.c

index 664df41..ebe8a18 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
         * 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 (file)
--- 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.
index fc76657..a12c168 100644 (file)
@@ -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 "&amp;" and "&copy;" 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
index d9b73bd..0dba28f 100644 (file)
@@ -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)
 {