forked from enlightenment/efl
colorclass: add util function for listing color classes out of an open edje file
This commit is contained in:
parent
84b68085c3
commit
2b03eb5a09
|
@ -9,6 +9,25 @@ tl_cb(char *str)
|
|||
return str;
|
||||
}
|
||||
|
||||
static Eina_List *
|
||||
name_cb(void)
|
||||
{
|
||||
Eina_List *l, *ret = NULL;
|
||||
Eina_Iterator *it;
|
||||
Eina_File *f;
|
||||
|
||||
it = edje_file_iterator_new();
|
||||
if (!it) return NULL;
|
||||
EINA_ITERATOR_FOREACH(it, f)
|
||||
{
|
||||
l = elm_color_class_util_edje_file_list(f);
|
||||
if (l)
|
||||
ret = eina_list_merge(ret, l);
|
||||
}
|
||||
eina_iterator_free(it);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
test_colorclass()
|
||||
{
|
||||
|
@ -18,6 +37,7 @@ test_colorclass()
|
|||
elm_win_autodel_set(win, EINA_TRUE);
|
||||
|
||||
elm_color_class_translate_cb_set(tl_cb);
|
||||
elm_color_class_list_cb_set(name_cb);
|
||||
cc = elm_color_class_editor_add(win, 0);
|
||||
elm_win_resize_object_add(win, cc);
|
||||
evas_object_size_hint_weight_set(cc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
|
|
@ -703,3 +703,29 @@ elm_color_class_list_cb_set(Elm_Color_Class_List_Cb cb)
|
|||
{
|
||||
list_cb = cb;
|
||||
}
|
||||
|
||||
EAPI Eina_List *
|
||||
elm_color_class_util_edje_file_list(Eina_File *f)
|
||||
{
|
||||
Edje_Color_Class *ecc, *ecc2;
|
||||
Eina_Iterator *it;
|
||||
Eina_List *ret = NULL;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(f, NULL);
|
||||
|
||||
it = edje_mmap_color_class_iterator_new(f);
|
||||
if (!it) return NULL;
|
||||
EINA_ITERATOR_FOREACH(it, ecc)
|
||||
{
|
||||
ecc2 = malloc(sizeof(Edje_Color_Class));
|
||||
memcpy(ecc2, ecc, sizeof(Edje_Color_Class));
|
||||
ecc2->name = eina_stringshare_add(ecc->name);
|
||||
if (tl_cb)
|
||||
ecc2->desc = eina_stringshare_add(tl_cb((char*)ecc->desc));
|
||||
else
|
||||
ecc2->desc = eina_stringshare_add(ecc->desc);
|
||||
ret = eina_list_append(ret, ecc2);
|
||||
}
|
||||
eina_iterator_free(it);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -68,6 +68,18 @@ EAPI void elm_color_class_translate_cb_set(Elm_Color_Class_Name_Cb cb);
|
|||
**/
|
||||
EAPI void elm_color_class_list_cb_set(Elm_Color_Class_List_Cb cb);
|
||||
|
||||
/**
|
||||
* @brief Create an allocated list of allocated Edje_Color_Class structs from an open edje file
|
||||
* @param f The file to list color classes from
|
||||
* @return The list of color classes present in the file
|
||||
*
|
||||
* This is a helper function to create a list for use with #Elm_Color_Class_List_Cb callbacks.
|
||||
*
|
||||
* @see Elm_Color_Class_List_Cb
|
||||
*
|
||||
* @since 1.14
|
||||
**/
|
||||
EAPI Eina_List *elm_color_class_util_edje_file_list(Eina_File *f);
|
||||
/** }@ */
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue