aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-03-31 04:24:48 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-03-31 04:26:06 +0200
commit5906569f7f85954e6fade62ebc1a7c234b126c76 (patch)
treeb1f0e0fd11ae685aae1490aa44f551bc17988fda
parentedje: make Edje_Color_Class a public structure. (diff)
downloadefl-5906569f7f85954e6fade62ebc1a7c234b126c76.tar.gz
edje: add edje_color_class_active_iterator_new()
This function make it possible to get a list of active Edje_Color_Class in an application. Think about Enlightenment color class configuration, but can now be done on any application dynamically. @feature
-rw-r--r--src/lib/edje/Edje_Common.h10
-rw-r--r--src/lib/edje/edje_util.c98
2 files changed, 108 insertions, 0 deletions
diff --git a/src/lib/edje/Edje_Common.h b/src/lib/edje/Edje_Common.h
index 3b1b8dd315..850a9f8a1d 100644
--- a/src/lib/edje/Edje_Common.h
+++ b/src/lib/edje/Edje_Common.h
@@ -1261,6 +1261,16 @@ EAPI void edje_color_class_del (const char *color_class);
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
+ *
+ * This function only iterate over the Edje_Color_Class in use by
+ * an application.
+ */
+EAPI Eina_Iterator *edje_color_class_active_iterator_new(void);
+
+/**
* @}
*/
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index e1818a04be..2745970a40 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -653,6 +653,104 @@ edje_color_class_list(void)
return fdata.list;
}
+typedef struct _Edje_Active_Color_Class_Iterator Edje_Active_Color_Class_Iterator;
+struct _Edje_Active_Color_Class_Iterator
+{
+ Eina_Iterator iterator;
+
+ Edje_Color_Class cc;
+
+ Eina_Iterator *classes;
+};
+
+static Eina_Bool
+_edje_color_class_active_iterator_next(Eina_Iterator *it, void **data)
+{
+ Edje_Active_Color_Class_Iterator *et = (void*) it;
+ Eina_Hash_Tuple *tuple = NULL;
+ Edje_Refcount *er = NULL;
+ Eina_Iterator *ith;
+ Edje_Color_Class *cc;
+ int r, g, b, a;
+ int r2, g2, b2, a2;
+ int r3, g3, b3, a3;
+
+ if (!eina_iterator_next(et->classes, (void**) &tuple)) return EINA_FALSE;
+ if (!tuple) return EINA_FALSE;
+
+ if (!edje_color_class_get(tuple->key,
+ &r, &g, &b, &a,
+ &r2, &g2, &b2, &a2,
+ &r3, &g3, &b3, &a3))
+ return EINA_FALSE;
+
+ /*
+ Any of the Edje object referenced should have a file with a valid
+ description for this color class. Let's bet on that for now.
+ */
+ ith = eina_hash_iterator_data_new(tuple->data);
+ if (!eina_iterator_next(ith, (void**) &er)) return EINA_FALSE;
+ cc = eina_hash_find(er->ed->file->color_hash, tuple->key);
+ if (!cc) return EINA_FALSE;
+
+ /*
+ Now set the value of a fake color class with current value as set
+ and description from edc.
+ */
+ et->cc.name = tuple->key;
+ et->cc.desc = cc->desc;
+ et->cc.r = r;
+ et->cc.g = g;
+ et->cc.b = b;
+ et->cc.a = a;
+ et->cc.r2 = r2;
+ et->cc.g2 = g2;
+ et->cc.b2 = b2;
+ et->cc.a2 = a2;
+ et->cc.r3 = r3;
+ et->cc.g3 = g3;
+ et->cc.b3 = b3;
+ et->cc.a3 = a3;
+
+ *data = &et->cc;
+ return EINA_TRUE;
+}
+
+static void *
+_edje_color_class_active_iterator_container(Eina_Iterator *it EINA_UNUSED)
+{
+ return NULL;
+}
+
+static void
+_edje_color_class_active_iterator_free(Eina_Iterator *it)
+{
+ Edje_Active_Color_Class_Iterator *et = (void*) it;
+
+ eina_iterator_free(et->classes);
+ EINA_MAGIC_SET(&et->iterator, 0);
+ free(et);
+}
+
+EAPI Eina_Iterator *
+edje_color_class_active_iterator_new(void)
+{
+ Edje_Active_Color_Class_Iterator *it;
+
+ it = calloc(1, sizeof (Edje_Active_Color_Class_Iterator));
+ if (!it) return NULL;
+
+ EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+ it->classes = eina_hash_iterator_tuple_new(_edje_color_class_member_hash);
+
+ it->iterator.version = EINA_ITERATOR_VERSION;
+ it->iterator.next = _edje_color_class_active_iterator_next;
+ it->iterator.get_container = _edje_color_class_active_iterator_container;
+ it->iterator.free = _edje_color_class_active_iterator_free;
+
+ return &it->iterator;
+}
+
static Eina_Bool
_edje_color_class_list_foreach(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data EINA_UNUSED, void *fdata)
{