aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-03-31 23:23:32 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-03-31 23:23:32 +0200
commitb72df468f25a0361ca8e3f6ee69ce0be8e641f83 (patch)
treeca19158615c8e39ae0dcf2bcee0ab04014006c93
parentedje: fix build break. (diff)
downloadefl-b72df468f25a0361ca8e3f6ee69ce0be8e641f83.tar.gz
edje: add edje_file_iterator_new().
This list the actually opened Edje file by the current process.
-rw-r--r--src/lib/edje/Edje_Common.h7
-rw-r--r--src/lib/edje/edje_cache.c3
-rw-r--r--src/lib/edje/edje_load.c56
-rw-r--r--src/lib/edje/edje_private.h2
4 files changed, 67 insertions, 1 deletions
diff --git a/src/lib/edje/Edje_Common.h b/src/lib/edje/Edje_Common.h
index 19fc6772ed..be0f4386fb 100644
--- a/src/lib/edje/Edje_Common.h
+++ b/src/lib/edje/Edje_Common.h
@@ -1773,6 +1773,13 @@ EAPI void edje_mmap_collection_list_free(Eina_List *lst);
EAPI Eina_Bool edje_mmap_group_exists(Eina_File *f, const char *glob);
/**
+ * @brief Iterate over all the opened Edje file.
+ *
+ * @return an iterator of Eina_File currently opened Edje file.
+ */
+EAPI Eina_Iterator *edje_file_iterator_new(void);
+
+/**
* Get a list of groups in an edje file
* @param file The path to the edje file
*
diff --git a/src/lib/edje/edje_cache.c b/src/lib/edje/edje_cache.c
index eea4ac7e66..4477ac80c2 100644
--- a/src/lib/edje/edje_cache.c
+++ b/src/lib/edje/edje_cache.c
@@ -1,6 +1,7 @@
#include "edje_private.h"
-static Eina_Hash *_edje_file_hash = NULL;
+Eina_Hash *_edje_file_hash = NULL;
+
static int _edje_file_cache_size = 16;
static Eina_List *_edje_file_cache = NULL;
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index 61b1de1aa3..1ce67a66d2 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -234,6 +234,62 @@ edje_mmap_group_exists(Eina_File *f, const char *glob)
return succeed;
}
+typedef struct _Edje_File_Iterator Edje_File_Iterator;
+struct _Edje_File_Iterator
+{
+ Eina_Iterator iterator;
+
+ Eina_Iterator *it;
+};
+
+static Eina_Bool
+_edje_file_iterator_next(Eina_Iterator *it, void **data)
+{
+ Edje_File_Iterator *et = (void*) it;
+ Edje_File *edf = NULL;
+
+ if (!eina_iterator_next(et->it, (void**) &edf))
+ return EINA_FALSE;
+
+ *data = edf->f;
+ return EINA_TRUE;
+}
+
+static void *
+_edje_file_iterator_container(Eina_Iterator *it EINA_UNUSED)
+{
+ return NULL;
+}
+
+static void
+_edje_file_iterator_free(Eina_Iterator *it)
+{
+ Edje_File_Iterator *et = (void*) it;
+
+ EINA_MAGIC_SET(&et->iterator, 0);
+ eina_iterator_free(et->it);
+ free(et);
+}
+
+EAPI Eina_Iterator *
+edje_file_iterator_new(void)
+{
+ Edje_File_Iterator *it;
+
+ it = calloc(1, sizeof (Edje_File_Iterator));
+ if (!it) return NULL;
+
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+ it->it = eina_hash_iterator_data_new(_edje_file_hash);
+
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next = _edje_file_iterator_next;
+ it->iterator.get_container = _edje_file_iterator_container;
+ it->iterator.free = _edje_file_iterator_free;
+
+ return &it->iterator;
+}
+
EAPI Eina_Bool
edje_file_group_exists(const char *file, const char *glob)
{
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 0128c3fc75..4abc5eb93e 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -2129,6 +2129,8 @@ extern Eina_Mempool *_edje_real_part_state_mp;
extern Eina_Cow *_edje_calc_params_map_cow;
extern Eina_Cow *_edje_calc_params_physics_cow;
+extern Eina_Hash *_edje_file_hash;
+
EAPI extern Eina_Mempool *_emp_RECTANGLE;
EAPI extern Eina_Mempool *_emp_TEXT;
EAPI extern Eina_Mempool *_emp_IMAGE;