raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=71f578dc0b84b92db3a7aaf381717c496727ed14

commit 71f578dc0b84b92db3a7aaf381717c496727ed14
Author: Jee-Yong Um <jc9...@samsung.com>
Date:   Thu Dec 24 15:55:17 2015 +0900

    edje: add text_classes syntax to EDC
    
    Summary:
    text_class can be defined in text_classes block.
    
    T2900
    
    @feature
    
    Reviewers: jpeg, raster
    
    Subscribers: raster, cedric, Jaehyun_Cho, CHAN, kimcinoo
    
    Differential Revision: https://phab.enlightenment.org/D3435
---
 src/bin/edje/edje_cc_handlers.c  | 164 ++++++++++++++++++++++++++++++
 src/bin/edje/edje_convert.c      |   1 +
 src/bin/edje/edje_convert.h      |   1 +
 src/bin/edje/edje_data_convert.c |   1 +
 src/lib/edje/Edje_Common.h       |  23 +++++
 src/lib/edje/Edje_Legacy.h       |  17 ++++
 src/lib/edje/edje_cache.c        |   6 ++
 src/lib/edje/edje_convert.c      |   1 +
 src/lib/edje/edje_convert.h      |   1 +
 src/lib/edje/edje_data.c         |  10 ++
 src/lib/edje/edje_load.c         |  12 +++
 src/lib/edje/edje_main.c         |   8 +-
 src/lib/edje/edje_private.h      |   5 +-
 src/lib/edje/edje_smart.c        |  11 ++
 src/lib/edje/edje_util.c         | 212 +++++++++++++++++++++++++++++++++++++--
 15 files changed, 457 insertions(+), 16 deletions(-)

diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index c7fc246..a5178c4 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -223,6 +223,11 @@ static void st_color_class_color2(void);
 static void st_color_class_color3(void);
 static void st_color_class_desc(void);
 
+static void ob_text_class(void);
+static void st_text_class_name(void);
+static void st_text_class_font(void);
+static void st_text_class_size(void);
+
 static void ob_size_class(void);
 static void st_size_class_name(void);
 static void st_size_class_min(void);
@@ -550,6 +555,11 @@ static void st_collections_group_nobroadcast(void);
      {PREFIX"color_classes.color_class.description", st_color_class_desc}, /* 
dup */ \
      {PREFIX"color_classes.color_class.desc", st_color_class_desc}, /* dup */
 
+#define TEXT_CLASS_STATEMENTS(PREFIX) \
+     {PREFIX"text_classes.text_class.name", st_text_class_name}, /* dup */ \
+     {PREFIX"text_classes.text_class.font", st_text_class_font}, /* dup */ \
+     {PREFIX"text_classes.text_class.size", st_text_class_size}, /* dup */
+
 #define SIZE_CLASS_STATEMENTS(PREFIX) \
      {PREFIX"size_classes.size_class.name", st_size_class_name}, /* dup */ \
      {PREFIX"size_classes.size_class.min", st_size_class_min}, /* dup */ \
@@ -657,6 +667,7 @@ New_Statement_Handler statement_handlers[] =
      {"externals.external", st_externals_external},
      IMAGE_STATEMENTS("")
      FONT_STYLE_CC_STATEMENTS("")
+     TEXT_CLASS_STATEMENTS("")
      SIZE_CLASS_STATEMENTS("")
      {"data.item", st_data_item},
      {"data.file", st_data_file},
@@ -666,6 +677,7 @@ New_Statement_Handler statement_handlers[] =
      IMAGE_SET_STATEMENTS("collections")
      {"collections.font", st_fonts_font}, /* dup */
      FONT_STYLE_CC_STATEMENTS("collections.")
+     TEXT_CLASS_STATEMENTS("collections.")
      SIZE_CLASS_STATEMENTS("collections.")
      {"collections.base_scale", st_collections_base_scale},
      {"collections.translation.file.locale", 
st_collections_group_translation_file_locale},
@@ -710,12 +722,14 @@ New_Statement_Handler statement_handlers[] =
      {"collections.group.models.model", st_models_model},
      {"collections.group.font", st_fonts_font}, /* dup */
      FONT_STYLE_CC_STATEMENTS("collections.group.")
+     TEXT_CLASS_STATEMENTS("collections.group.")
      SIZE_CLASS_STATEMENTS("collections.group.")
      {"collections.group.parts.alias", st_collections_group_parts_alias },
      IMAGE_SET_STATEMENTS("collections.group.parts")
      IMAGE_STATEMENTS("collections.group.parts.")
      {"collections.group.parts.font", st_fonts_font}, /* dup */
      FONT_STYLE_CC_STATEMENTS("collections.group.parts.")
+     TEXT_CLASS_STATEMENTS("collections.group.parts.")
      SIZE_CLASS_STATEMENTS("collections.group.parts.")
      {"collections.group.parts.target_group", 
st_collections_group_target_group}, /* dup */
      {"collections.group.parts.part.name", 
st_collections_group_parts_part_name},
@@ -760,6 +774,7 @@ New_Statement_Handler statement_handlers[] =
      IMAGE_STATEMENTS("collections.group.parts.part.")
      {"collections.group.parts.part.font", st_fonts_font}, /* dup */
      FONT_STYLE_CC_STATEMENTS("collections.group.parts.part.")
+     TEXT_CLASS_STATEMENTS("collections.group.parts.part.")
      SIZE_CLASS_STATEMENTS("collections.group.parts.part.")
      {"collections.group.parts.part.box.items.item.type", 
st_collections_group_parts_part_box_items_item_type},
      {"collections.group.parts.part.box.items.item.name", 
st_collections_group_parts_part_box_items_item_name},
@@ -940,6 +955,7 @@ New_Statement_Handler statement_handlers[] =
      IMAGE_STATEMENTS("collections.group.parts.part.description.")
      {"collections.group.parts.part.description.font", st_fonts_font}, /* dup 
*/
      FONT_STYLE_CC_STATEMENTS("collections.group.parts.part.description.")
+     TEXT_CLASS_STATEMENTS("collections.group.parts.part.description.")
      SIZE_CLASS_STATEMENTS("collections.group.parts.part.description.")
 #ifdef HAVE_EPHYSICS
      {"collections.group.physics.world.gravity", 
st_collections_group_physics_world_gravity},
@@ -1151,6 +1167,8 @@ New_Object_Handler object_handlers[] =
      {"styles.style", ob_styles_style},
      {"color_classes", NULL},
      {"color_classes.color_class", ob_color_class},
+     {"text_classes", NULL},
+     {"text_classes.text_class", ob_text_class},
      {"size_classes", NULL},
      {"size_classes.size_class", ob_size_class},
      {"spectra", NULL},
@@ -1169,6 +1187,8 @@ New_Object_Handler object_handlers[] =
      {"collections.styles.style", ob_styles_style}, /* dup */
      {"collections.color_classes", NULL}, /* dup */
      {"collections.color_classes.color_class", ob_color_class}, /* dup */
+     {"collections.text_classes", NULL},
+     {"collections.text_classes.text_class", ob_text_class}, /* dup */
      {"collections.size_classes", NULL}, /* dup */
      {"collections.size_classes.size_class", ob_size_class}, /* dup */
      {"collections.sounds", NULL},
@@ -1203,6 +1223,8 @@ New_Object_Handler object_handlers[] =
      {"collections.group.styles.style", ob_styles_style}, /* dup */
      {"collections.group.color_classes", NULL}, /* dup */
      {"collections.group.color_classes.color_class", ob_color_class}, /* dup */
+     {"collections.group.text_classes", NULL},
+     {"collections.group.text_classes.text_class", ob_text_class}, /* dup */
      {"collections.group.size_classes", NULL}, /* dup */
      {"collections.group.size_classes.size_class", ob_size_class}, /* dup */
      {"collections.group.filters", NULL},
@@ -1219,6 +1241,8 @@ New_Object_Handler object_handlers[] =
      {"collections.group.parts.styles.style", ob_styles_style}, /* dup */
      {"collections.group.parts.color_classes", NULL}, /* dup */
      {"collections.group.parts.color_classes.color_class", ob_color_class}, /* 
dup */
+     {"collections.group.parts.text_classes", NULL},
+     {"collections.group.parts.text_classes.text_class", ob_text_class}, /* 
dup */
      {"collections.group.parts.size_classes", NULL}, /* dup */
      {"collections.group.parts.size_classes.size_class", ob_size_class}, /* 
dup */
      {"collections.group.parts.part", ob_collections_group_parts_part},
@@ -1233,6 +1257,8 @@ New_Object_Handler object_handlers[] =
      {"collections.group.parts.part.styles.style", ob_styles_style}, /* dup */
      {"collections.group.parts.part.color_classes", NULL}, /* dup */
      {"collections.group.parts.part.color_classes.color_class", 
ob_color_class}, /* dup */
+     {"collections.group.parts.part.text_classes", NULL},
+     {"collections.group.parts.part.text_classes.text_class", ob_text_class}, 
/* dup */
      {"collections.group.parts.part.size_classes", NULL}, /* dup */
      {"collections.group.parts.part.size_classes.size_class", ob_size_class}, 
/* dup */
      {"collections.group.parts.part.box", NULL},
@@ -1283,6 +1309,8 @@ New_Object_Handler object_handlers[] =
      {"collections.group.parts.part.description.params", NULL},
      {"collections.group.parts.part.description.color_classes", NULL}, /* dup 
*/
      {"collections.group.parts.part.description.color_classes.color_class", 
ob_color_class}, /* dup */
+     {"collections.group.parts.part.description.text_classes", NULL}, /* dup */
+     {"collections.group.parts.part.description.text_classes.text_class", 
ob_text_class}, /* dup */
      {"collections.group.parts.part.description.size_classes", NULL}, /* dup */
      {"collections.group.parts.part.description.size_classes.size_class", 
ob_size_class}, /* dup */
 #ifdef HAVE_EPHYSICS
@@ -2753,6 +2781,135 @@ st_styles_style_tag(void)
    stl->tags = eina_list_append(stl->tags, tag);
 }
 
+/** @edcsubsection{toplevel_text_classes,
+ *                 Text Classes} */
+
+/**
+    @page edcref
+    @block
+        text_classes
+    @context
+        text_classes {
+           text_class {
+              name: "text_class name";
+              font: "font name";
+              size: SIZE";
+           }
+            ..
+        }
+    @description
+        The "text_classes" block contains a list of one or more "text_class"
+        blocks. Each "text_class" allows the designer to name an arbitrary
+        group of font and size to be used in the theme, the application can
+        use that name to alter the font and its size at runtime.
+    @endblock
+*/
+static void
+ob_text_class(void)
+{
+   Edje_Text_Class *tc;
+
+   tc = mem_alloc(SZ(Edje_Text_Class));
+   edje_file->text_classes = eina_list_append(edje_file->text_classes, tc);
+
+   tc->font = "";
+   tc->size = 0;
+}
+
+static void
+_text_class_name(char *name)
+{
+   Edje_Text_Class *tc, *ttc;
+   Eina_List *l;
+
+   tc = eina_list_data_get(eina_list_last(edje_file->text_classes));
+   tc->name = name;
+   EINA_LIST_FOREACH(edje_file->text_classes, l, ttc)
+     {
+        if ((tc != ttc) && (!strcmp(tc->name, ttc->name)))
+          {
+             ERR("parse error %s:%i. There is already a text class named 
\"%s\"",
+                 file_in, line - 1, tc->name);
+             exit(-1);
+          }
+     }
+}
+
+/**
+    @page edcref
+
+    @property
+        name
+    @parameters
+        [text class name]
+    @effect
+        Sets the name for the text class, used as reference by both the theme
+        and the application.
+    @endproperty
+*/
+static void
+st_text_class_name(void)
+{
+   Edje_Text_Class *tc, *ttc;
+   Eina_List *l;
+
+   tc = eina_list_data_get(eina_list_last(edje_file->text_classes));
+   tc->name = parse_str(0);
+   EINA_LIST_FOREACH(edje_file->text_classes, l, ttc)
+     {
+        if ((tc != ttc) && (!strcmp(tc->name, ttc->name)))
+          {
+             ERR("parse error %s:%i. There is already a text class named 
\"%s\"",
+                 file_in, line - 1, tc->name);
+             exit(-1);
+          }
+     }
+}
+
+/**
+    @page edcref
+
+    @property
+        font
+    @parameters
+        [font name]
+    @effect
+        Sets the font family for the text class.
+    @endproperty
+*/
+static void
+st_text_class_font(void)
+{
+   Edje_Text_Class *tc;
+
+   check_arg_count(1);
+
+   tc = eina_list_data_get(eina_list_last(edje_file->text_classes));
+   tc->font = parse_str(0);
+}
+
+/**
+    @page edcref
+
+    @property
+        size
+    @parameters
+        [font size in points (pt)]
+    @effect
+        Sets the font size for the text class.
+    @endproperty
+*/
+static void
+st_text_class_size(void)
+{
+   Edje_Text_Class *tc;
+
+   check_arg_count(1);
+
+   tc = eina_list_data_get(eina_list_last(edje_file->text_classes));
+   tc->size = parse_int_range(0, 0, 255);
+}
+
 /** @edcsubsection{toplevel_size_classes,
  *                 Size Classes} */
 
@@ -14219,6 +14376,13 @@ edje_cc_handlers_wildcard(void)
          stack_pop_quick(EINA_FALSE, EINA_FALSE);
          return EINA_TRUE;
      }
+   if (edje_file->text_classes && (!strcmp(last, "text_class")))
+     {
+        if (!had_quote) return EINA_FALSE;
+        _text_class_name(token);
+        stack_pop_quick(EINA_FALSE, EINA_FALSE);
+        return EINA_TRUE;
+     }
    if (edje_file->size_classes && (!strcmp(last, "size_class")))
      {
         if (!had_quote) return EINA_FALSE;
diff --git a/src/bin/edje/edje_convert.c b/src/bin/edje/edje_convert.c
index 1352b43..e9712c1 100644
--- a/src/bin/edje/edje_convert.c
+++ b/src/bin/edje/edje_convert.c
@@ -158,6 +158,7 @@ _edje_file_convert(Eet_File *ef, Old_Edje_File *oedf)
 
    edf->styles = oedf->styles;
    edf->color_classes = oedf->color_classes;
+   edf->text_classes = oedf->text_classes;
    edf->size_classes = oedf->size_classes;
    edf->version = EDJE_FILE_VERSION;
    edf->feature_ver = oedf->feature_ver;
diff --git a/src/bin/edje/edje_convert.h b/src/bin/edje/edje_convert.h
index 8c11333..eb70163 100644
--- a/src/bin/edje/edje_convert.h
+++ b/src/bin/edje/edje_convert.h
@@ -49,6 +49,7 @@ struct _Old_Edje_File
    Eina_List                      *data;
    Eina_List                      *styles;
    Eina_List                      *color_classes;
+   Eina_List                      *text_classes;
    Eina_List                      *size_classes;
 
    const char                     *compiler;
diff --git a/src/bin/edje/edje_data_convert.c b/src/bin/edje/edje_data_convert.c
index 86ff7f5..f417c6a 100644
--- a/src/bin/edje/edje_data_convert.c
+++ b/src/bin/edje/edje_data_convert.c
@@ -194,6 +194,7 @@ _edje_edd_old_init(void)
    EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_file, Old_Edje_File, 
"data", data, _edje_edd_old_edje_data);
    EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_file, Old_Edje_File, 
"styles", styles, _edje_edd_old_edje_style);
    EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_file, Old_Edje_File, 
"color_classes", color_classes, _edje_edd_old_edje_color_class);
+   EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_file, Old_Edje_File, 
"text_classes", text_classes, _edje_edd_old_edje_text_class);
    EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_file, Old_Edje_File, 
"size_classes", size_classes, _edje_edd_old_edje_size_class);
 
    /* parts & programs - loaded induvidually */
diff --git a/src/lib/edje/Edje_Common.h b/src/lib/edje/Edje_Common.h
index def2b8f..71e9f39 100644
--- a/src/lib/edje/Edje_Common.h
+++ b/src/lib/edje/Edje_Common.h
@@ -1586,6 +1586,29 @@ EAPI void         edje_text_class_del             (const 
char *text_class);
 EAPI Eina_List   *edje_text_class_list            (void);
 
 /**
+ * @brief Iterate over all active classes of an application.
+ *
+ * @return an iterator of Edje_Text_Class of the currently active text class
+ *
+ * This function only iterates over the Edje_Text_Class in use by
+ * an application.
+ *
+ * @since 1.17
+ *
+ */
+EAPI Eina_Iterator *edje_text_class_active_iterator_new(void);
+
+/**
+ * @brief Iterate over all text classes provided by an Edje file.
+ *
+ * @return an iterator of Edje_Text_Class provided by the Edje file.
+ *
+ * @since 1.17
+ *
+ */
+EAPI Eina_Iterator *edje_mmap_text_class_iterator_new(Eina_File *f);
+
+/**
  * @}
  */
 
diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h
index c99bbcc..b7c78ab 100644
--- a/src/lib/edje/Edje_Legacy.h
+++ b/src/lib/edje/Edje_Legacy.h
@@ -115,6 +115,23 @@ EAPI void        
*edje_object_signal_callback_del_full(Evas_Object *obj, const c
  EAPI void         edje_object_color_class_del         (Evas_Object *obj, 
const char *color_class);
 
 /**
+ * @brief Delete the object text class.
+ *
+ * @param obj The edje object's reference.
+ * @param text_class The text class to be deleted.
+ *
+ * This function deletes any values at the object level for the
+ * specified object and text class.
+ * @note Deleting the text class will revert it to the values
+ *       defined by edje_text_class_set() or the text class
+ *       defined in the theme file.
+ *
+ * @since 1.17
+ *
+ */
+EAPI void         edje_object_text_class_del         (Evas_Object *obj, const 
char *text_class);
+
+/**
  * @brief Delete the object size class.
  *
  * @param obj The edje object's reference.
diff --git a/src/lib/edje/edje_cache.c b/src/lib/edje/edje_cache.c
index b873383..ab8a9b4 100644
--- a/src/lib/edje/edje_cache.c
+++ b/src/lib/edje/edje_cache.c
@@ -262,6 +262,7 @@ static Edje_File *
 _edje_file_open(const Eina_File *f, int *error_ret, time_t mtime)
 {
    Edje_Color_Class *cc;
+   Edje_Text_Class *tc;
    Edje_Size_Class *sc;
    Edje_File *edf;
    Eina_List *l;
@@ -319,6 +320,11 @@ _edje_file_open(const Eina_File *f, int *error_ret, time_t 
mtime)
      if (cc->name)
        eina_hash_direct_add(edf->color_hash, cc->name, cc);
 
+   edf->text_hash = eina_hash_string_small_new(NULL);
+   EINA_LIST_FOREACH(edf->text_classes, l, tc)
+      if (tc->name)
+         eina_hash_direct_add(edf->text_hash, tc->name, tc);
+
    edf->size_hash = eina_hash_string_small_new(NULL);
    EINA_LIST_FOREACH(edf->size_classes, l, sc)
      if (sc->name)
diff --git a/src/lib/edje/edje_convert.c b/src/lib/edje/edje_convert.c
index 7c4e378..a6a8439 100644
--- a/src/lib/edje/edje_convert.c
+++ b/src/lib/edje/edje_convert.c
@@ -212,6 +212,7 @@ _edje_file_convert(Eet_File *file, Old_Edje_File *oedf)
    edf->oef = oedf;
    edf->styles = oedf->styles;
    edf->color_classes = oedf->color_classes;
+   edf->text_classes = oedf->text_classes;
    edf->size_classes = oedf->size_classes;
    edf->version = oedf->version;
    edf->feature_ver = oedf->feature_ver;
diff --git a/src/lib/edje/edje_convert.h b/src/lib/edje/edje_convert.h
index da1b782..7848efb 100644
--- a/src/lib/edje/edje_convert.h
+++ b/src/lib/edje/edje_convert.h
@@ -67,6 +67,7 @@ struct _Old_Edje_File
    Eina_List                      *data; /**< list of Edje_Data */
    Eina_List                      *styles; /**< list of Edje_Style */
    Eina_List                      *color_classes; /**< list of 
Edje_Color_Class */
+   Eina_List                      *text_classes; /**< list of Edje_Text_Class 
*/
    Eina_List                      *size_classes; /**< list of Edje_Size_Class 
*/
 
    const char                     *compiler; /**< compiler name */
diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c
index 9c8f571..905831d 100644
--- a/src/lib/edje/edje_data.c
+++ b/src/lib/edje/edje_data.c
@@ -7,6 +7,7 @@ Eet_Data_Descriptor *_edje_edd_edje_string = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_style = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_style_tag = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_color_class = NULL;
+Eet_Data_Descriptor *_edje_edd_edje_text_class = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_size_class = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_external_directory = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_external_directory_entry = NULL;
@@ -229,6 +230,7 @@ _edje_edd_shutdown(void)
    FREED(_edje_edd_edje_style);
    FREED(_edje_edd_edje_style_tag);
    FREED(_edje_edd_edje_color_class);
+   FREED(_edje_edd_edje_text_class);
    FREED(_edje_edd_edje_size_class);
    FREED(_edje_edd_edje_external_directory);
    FREED(_edje_edd_edje_external_directory_entry);
@@ -537,6 +539,13 @@ _edje_edd_init(void)
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, 
"a3", a3, EET_T_UCHAR);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, 
"desc", desc, EET_T_STRING);
 
+   EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Text_Class);
+   _edje_edd_edje_text_class =
+      eet_data_descriptor_file_new(&eddc);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_text_class, Edje_Text_Class, 
"name", name, EET_T_STRING);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_text_class, Edje_Text_Class, 
"font", font, EET_T_STRING);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_text_class, Edje_Text_Class, 
"size", size, EET_T_INT);
+
    EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Size_Class);
    _edje_edd_edje_size_class =
       eet_data_descriptor_file_new(&eddc);
@@ -571,6 +580,7 @@ _edje_edd_init(void)
    EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, 
"vibration_dir", vibration_dir, _edje_edd_edje_vibration_directory);
    EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_file, Edje_File, "styles", 
styles, _edje_edd_edje_style);
    EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_file, Edje_File, 
"color_classes", color_classes, _edje_edd_edje_color_class);
+   EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_file, Edje_File, 
"text_classes", text_classes, _edje_edd_edje_text_class);
    EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_file, Edje_File, 
"size_classes", size_classes, _edje_edd_edje_size_class);
    EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "data", data, 
_edje_edd_edje_string);
    EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "fonts", 
fonts, _edje_edd_edje_font_directory_entry);
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index 67e35f9..8c6b6c1 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -1681,6 +1681,7 @@ void
 _edje_file_free(Edje_File *edf)
 {
    Edje_Color_Class *ecc;
+   Edje_Text_Class *etc;
    Edje_Size_Class *esc;
 
 #define HASH_FREE(Hash)            \
@@ -1782,6 +1783,17 @@ _edje_file_free(Edje_File *edf)
         free(ecc);
      }
 
+   eina_hash_free(edf->text_hash);
+   EINA_LIST_FREE(edf->text_classes, etc)
+     {
+        if (edf->free_strings)
+          {
+             if (etc->name) eina_stringshare_del(etc->name);
+             if (etc->font) eina_stringshare_del(etc->font);
+          }
+        free(etc);
+     }
+
    eina_hash_free(edf->size_hash);
    EINA_LIST_FREE(edf->size_classes, esc)
      {
diff --git a/src/lib/edje/edje_main.c b/src/lib/edje/edje_main.c
index cb1b0ea..8803320 100644
--- a/src/lib/edje/edje_main.c
+++ b/src/lib/edje/edje_main.c
@@ -250,7 +250,6 @@ _edje_del(Edje *ed)
 {
    Edje_Running_Program *runp;
    Edje_Pending_Program *pp;
-   Edje_Text_Class *tc;
    Edje_Text_Insert_Filter_Callback *cb;
 
    if (ed->processing_messages)
@@ -275,12 +274,7 @@ _edje_del(Edje *ed)
    EINA_LIST_FREE(ed->pending_actions, pp)
      free(pp);
    eina_hash_free(ed->color_classes);
-   EINA_LIST_FREE(ed->text_classes, tc)
-     {
-        if (tc->name) eina_stringshare_del(tc->name);
-        if (tc->font) eina_stringshare_del(tc->font);
-        free(tc);
-     }
+   eina_hash_free(ed->text_classes);
    eina_hash_free(ed->size_classes);
    EINA_LIST_FREE(ed->text_insert_filter_callbacks, cb)
      {
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 402cfdd..5f1d6d4 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -544,6 +544,9 @@ struct _Edje_File
    Eina_List                      *color_classes;
    Eina_Hash                      *color_hash;
 
+   Eina_List                      *text_classes;
+   Eina_Hash                      *text_hash;
+
    Eina_List                      *size_classes;
    Eina_Hash                      *size_hash;
 
@@ -1591,7 +1594,7 @@ struct _Edje
    Eina_List            *actions; /* currently running actions */
    Eina_List            *pending_actions;
    Eina_Hash            *color_classes;
-   Eina_List            *text_classes;
+   Eina_Hash            *text_classes;
    Eina_Hash            *size_classes;
    /* variable pool for Edje Embryo scripts */
    Edje_Var_Pool        *var_pool;
diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c
index 142cbd2..500ef3c 100644
--- a/src/lib/edje/edje_smart.c
+++ b/src/lib/edje/edje_smart.c
@@ -74,6 +74,16 @@ _edje_color_class_free(void *data)
 }
 
 static void
+_edje_text_class_free(void *data)
+{
+   Edje_Text_Class *tc = data;
+
+   if (tc->name) eina_stringshare_del(tc->name);
+   if (tc->font) eina_stringshare_del(tc->font);
+   free(tc);
+}
+
+static void
 _edje_size_class_free(void *data)
 {
    Edje_Size_Class *sc = data;
@@ -97,6 +107,7 @@ _edje_object_evas_object_smart_add(Eo *obj, Edje *ed)
    ed->references = 1;
    ed->user_defined = NULL;
    ed->color_classes = eina_hash_string_small_new(_edje_color_class_free);
+   ed->text_classes = eina_hash_string_small_new(_edje_text_class_free);
    ed->size_classes = eina_hash_string_small_new(_edje_size_class_free);
 
    evas_object_geometry_get(obj, &(ed->x), &(ed->y), &(ed->w), &(ed->h));
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index 5bbc42d..fc0c5b8 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -1225,6 +1225,83 @@ edje_text_class_list(void)
    return fdata.list;
 }
 
+typedef struct _Edje_Active_Text_Class_Iterator 
Edje_Active_Text_Class_Iterator;
+struct _Edje_Active_Text_Class_Iterator
+{
+   Eina_Iterator    iterator;
+   Edje_Text_Class  tc;
+   Eina_Iterator   *classes;
+};
+
+static Eina_Bool
+_edje_text_class_active_iterator_next(Eina_Iterator *it, void **data)
+{
+   Edje_Active_Text_Class_Iterator *et = (void *)it;
+   Eina_Hash_Tuple *tuple = NULL;
+   Edje_Refcount *er = NULL;
+   Eina_Iterator *ith;
+   Edje_Text_Class *tc;
+   Eina_Bool r = EINA_FALSE;
+
+   if (!eina_iterator_next(et->classes, (void **)&tuple)) return EINA_FALSE;
+   if (!tuple) return EINA_FALSE;
+
+   ith = eina_hash_iterator_data_new(tuple->data);
+   if (!eina_iterator_next(ith, (void **)&er)) goto on_error;
+
+   /*
+      We actually need to ask on an object to get the correct value.
+      It is being assumed that the size key are the same for all object here.
+      This can some times not be the case, but for now we should be fine.
+    */
+   tc = _edje_text_class_find(er->ed, tuple->key);
+   if (!tc) goto on_error;
+   et->tc = *tc;
+
+   *data = &et->tc;
+   r = EINA_TRUE;
+
+ on_error:
+   eina_iterator_free(ith);
+   return r;
+}
+
+static void *
+_edje_text_class_active_iterator_container(Eina_Iterator *it EINA_UNUSED)
+{
+   return NULL;
+}
+
+static void
+_edje_text_class_active_iterator_free(Eina_Iterator *it)
+{
+   Edje_Active_Text_Class_Iterator *et = (void *)it;
+
+   eina_iterator_free(et->classes);
+   EINA_MAGIC_SET(&et->iterator, 0);
+   free(et);
+}
+
+EAPI Eina_Iterator *
+edje_text_class_active_iterator_new(void)
+{
+   Edje_Active_Text_Class_Iterator *it;
+
+   if (!_edje_text_class_member_hash) return NULL;
+   it = calloc(1, sizeof (Edje_Active_Text_Class_Iterator));
+   if (!it) return NULL;
+
+   EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+   it->classes = eina_hash_iterator_tuple_new(_edje_text_class_member_hash);
+
+   it->iterator.version = EINA_ITERATOR_VERSION;
+   it->iterator.next = _edje_text_class_active_iterator_next;
+   it->iterator.get_container = _edje_text_class_active_iterator_container;
+   it->iterator.free = _edje_text_class_active_iterator_free;
+
+   return &it->iterator;
+}
+
 static Eina_Bool
 _edje_text_class_list_foreach(const Eina_Hash *hash EINA_UNUSED, const void 
*key, void *data EINA_UNUSED, void *fdata)
 {
@@ -1238,14 +1315,15 @@ _edje_text_class_list_foreach(const Eina_Hash *hash 
EINA_UNUSED, const void *key
 EOLIAN Eina_Bool
 _edje_object_text_class_set(Eo *obj EINA_UNUSED, Edje *ed, const char 
*text_class, const char *font, Evas_Font_Size size)
 {
-   Eina_List *l;
    Edje_Text_Class *tc = NULL;
    unsigned int i;
 
    if ((!ed) || (!text_class)) return EINA_FALSE;
 
+   tc = eina_hash_find(ed->text_classes, text_class);
+
    /* for each text_class in the edje */
-   EINA_LIST_FOREACH(ed->text_classes, l, tc)
+   if (tc)
      {
         if ((tc->name) && (!strcmp(tc->name, text_class)))
           {
@@ -1260,7 +1338,6 @@ _edje_object_text_class_set(Eo *obj EINA_UNUSED, Edje 
*ed, const char *text_clas
              /* Update new text class properties */
              eina_stringshare_replace(&tc->font, font);
              tc->size = size;
-             break;
           }
      }
 
@@ -1278,7 +1355,7 @@ _edje_object_text_class_set(Eo *obj EINA_UNUSED, Edje 
*ed, const char *text_clas
         tc->font = eina_stringshare_add(font);
         tc->size = size;
         /* Add to edje's text class list */
-        ed->text_classes = eina_list_append(ed->text_classes, tc);
+        eina_hash_direct_add(ed->text_classes, tc->name, tc);
      }
 
    for (i = 0; i < ed->table_parts_size; i++)
@@ -1326,6 +1403,115 @@ _edje_object_text_class_get(Eo *obj EINA_UNUSED, Edje 
*ed, const char *text_clas
    return EINA_TRUE;
 }
 
+EAPI void
+edje_object_text_class_del(Evas_Object *obj, const char *text_class)
+{
+   Edje *ed;
+   Edje_Text_Class *tc = NULL;
+   unsigned int i;
+
+   ed = _edje_fetch(obj);
+
+   if ((!ed) || (!text_class)) return;
+
+   eina_hash_del(ed->text_classes, text_class, tc);
+
+   for (i = 0; i < ed->table_parts_size; i++)
+     {
+        Edje_Real_Part *rp;
+
+        rp = ed->table_parts[i];
+        if ((rp->part->type == EDJE_PART_TYPE_GROUP) &&
+            ((rp->type == EDJE_RP_TYPE_SWALLOW) &&
+             (rp->typedata.swallow)) &&
+            (rp->typedata.swallow->swallowed_object))
+          edje_object_text_class_del(rp->typedata.swallow->swallowed_object, 
text_class);
+     }
+
+   ed->dirty = EINA_TRUE;
+   ed->recalc_call = EINA_TRUE;
+#ifdef EDJE_CALC_CACHE
+   ed->text_part_change = EINA_TRUE;
+#endif
+   _edje_textblock_styles_cache_free(ed, text_class);
+   _edje_textblock_style_all_update(ed);
+   _edje_recalc(ed);
+}
+
+typedef struct _Edje_File_Text_Class_Iterator Edje_File_Text_Class_Iterator;
+struct _Edje_File_Text_Class_Iterator
+{
+   Edje_Active_Text_Class_Iterator it;
+
+   Edje_File                       *edf;
+};
+
+static Eina_Bool
+_edje_mmap_text_class_iterator_next(Eina_Iterator *it, void **data)
+{
+   Edje_File_Text_Class_Iterator *et = (void *)it;
+   Eina_Hash_Tuple *tuple = NULL;
+   Edje_Text_Class *tc = NULL;
+
+   if (!eina_iterator_next(et->it.classes, (void **)&tuple)) return EINA_FALSE;
+   if (!tuple) return EINA_FALSE;
+
+   tc = tuple->data;
+
+   et->it.tc = *tc;
+
+   *data = &et->it.tc;
+   return EINA_TRUE;
+}
+
+static void *
+_edje_mmap_text_class_iterator_container(Eina_Iterator *it)
+{
+   Edje_File_Text_Class_Iterator *et = (void *)it;
+
+   return et->edf->f;
+}
+
+static void
+_edje_mmap_text_class_iterator_free(Eina_Iterator *it)
+{
+   Edje_File_Text_Class_Iterator *et = (void *)it;
+
+   eina_iterator_free(et->it.classes);
+   _edje_cache_file_unref(et->edf);
+   EINA_MAGIC_SET(&et->it.iterator, 0);
+   free(et);
+}
+
+EAPI Eina_Iterator *
+edje_mmap_text_class_iterator_new(Eina_File *f)
+{
+   Edje_File_Text_Class_Iterator *it;
+   Edje_File *edf;
+   int error_ret;
+
+   edf = _edje_cache_file_coll_open(f, NULL, &error_ret, NULL, NULL);
+   if (!edf) return NULL;
+
+   it = calloc(1, sizeof (Edje_File_Text_Class_Iterator));
+   if (!it) goto on_error;
+
+   EINA_MAGIC_SET(&it->it.iterator, EINA_MAGIC_ITERATOR);
+   it->edf = edf;
+   it->it.classes = eina_hash_iterator_tuple_new(edf->text_hash);
+
+   it->it.iterator.version = EINA_ITERATOR_VERSION;
+   it->it.iterator.next = _edje_mmap_text_class_iterator_next;
+   it->it.iterator.get_container = _edje_mmap_text_class_iterator_container;
+   it->it.iterator.free = _edje_mmap_text_class_iterator_free;
+
+   return &it->it.iterator;
+
+on_error:
+   _edje_cache_file_unref(edf);
+   return NULL;
+}
+
 EAPI Eina_Bool
 edje_size_class_set(const char *size_class, Evas_Coord minw, Evas_Coord minh, 
Evas_Coord maxw, Evas_Coord maxh)
 {
@@ -5591,13 +5777,23 @@ _edje_color_class_on_del(Edje *ed, Edje_Part *ep)
 Edje_Text_Class *
 _edje_text_class_find(Edje *ed, const char *text_class)
 {
-   Eina_List *l;
    Edje_Text_Class *tc;
 
    if ((!ed) || (!text_class)) return NULL;
-   EINA_LIST_FOREACH(ed->text_classes, l, tc)
-     if ((tc->name) && (!strcmp(text_class, tc->name))) return tc;
-   return eina_hash_find(_edje_text_class_hash, text_class);
+
+   /* first look through the object scope */
+   tc = eina_hash_find(ed->text_classes, text_class);
+   if (tc) return tc;
+
+   /* next look through the global scope */
+   tc = eina_hash_find(_edje_text_class_hash, text_class);
+   if (tc) return tc;
+
+   /* finally, look through the file scope */
+   tc = eina_hash_find(ed->file->text_hash, text_class);
+   if (tc) return tc;
+
+   return NULL;
 }
 
 void

-- 


Reply via email to