diff options
author | Cedric BAIL <cedric@osg.samsung.com> | 2015-03-31 21:57:23 +0200 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2015-03-31 21:57:23 +0200 |
commit | 11a4e1ae83e74b55aef0fe42e93d7d0651085dfd (patch) | |
tree | c150af5a92970ca6c2fdc00992e059c92f3134e4 | |
parent | 70df9f48bae3a55ab9bd0e9ca555f6cfb8b2da4c (diff) | |
download | efl-11a4e1ae83e74b55aef0fe42e93d7d0651085dfd.tar.gz |
edje: add edje_mmap_color_class_iterator_new().
This function make it possible to list the Color class of a specific Edje file.
-rw-r--r-- | src/lib/edje/Edje_Common.h | 10 | ||||
-rw-r--r-- | src/lib/edje/edje_util.c | 56 |
2 files changed, 65 insertions, 1 deletions
diff --git a/src/lib/edje/Edje_Common.h b/src/lib/edje/Edje_Common.h index 850a9f8a1d..db91730161 100644 --- a/src/lib/edje/Edje_Common.h +++ b/src/lib/edje/Edje_Common.h @@ -1263,7 +1263,7 @@ EAPI Eina_List *edje_color_class_list (void); /** * @brief Iterate over all the active class of an application. * - * @return Return an iterator of Edje_Color_Class of the currently active color class + * @return an iterator of Edje_Color_Class of the currently active color class * * This function only iterate over the Edje_Color_Class in use by * an application. @@ -1271,6 +1271,14 @@ EAPI Eina_List *edje_color_class_list (void); EAPI Eina_Iterator *edje_color_class_active_iterator_new(void); /** + * @brief Iterate over all the color class provided by an Edje file. + * + * @return an iterator of Edje_Color_Class provided by the Edje file. + */ +EAPI Eina_Iterator *edje_mmap_color_class_iterator_new(Eina_File *f) + + +/** * @} */ diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c index a76f922000..9410a0a04b 100644 --- a/src/lib/edje/edje_util.c +++ b/src/lib/edje/edje_util.c @@ -897,6 +897,62 @@ edje_object_color_class_del(Evas_Object *obj, const char *color_class) _edje_emit(ed, "color_class,del", color_class); } +typedef struct _Edje_File_Color_Class_Iterator Edje_File_Color_Class_Iterator; +struct _Edje_File_Color_Class_Iterator +{ + Edje_Active_Color_Class_Iterator it; + + Edje_File *edf; +}; + +static void * +_edje_mmap_color_class_iterator_container(Eina_Iterator *it) +{ + Edje_File_Color_Class_Iterator *et = (void*) it; + + return et->edf->f; +} + +static void +_edje_mmap_color_class_iterator_free(Eina_Iterator *it) +{ + Edje_File_Color_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_color_class_iterator_new(Eina_File *f) +{ + Edje_File_Color_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_Color_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->color_hash); + + it->it.iterator.version = EINA_ITERATOR_VERSION; + it->it.iterator.next = _edje_color_class_active_iterator_next; + it->it.iterator.get_container = _edje_mmap_color_class_iterator_container; + it->it.iterator.free = _edje_mmap_color_class_iterator_free; + + return &it->it.iterator; + + on_error: + _edje_cache_file_unref(edf); + return NULL; +} + EAPI Eina_Bool edje_text_class_set(const char *text_class, const char *font, Evas_Font_Size size) { |