Edje: now we can refer to the content of a external type

SVN revision: 50730
This commit is contained in:
Jonathan Atton 2010-08-01 17:27:31 +00:00
parent 1c05469785
commit 6e1ada9850
4 changed files with 49 additions and 1 deletions

View File

@ -384,6 +384,7 @@ struct _Edje_External_Type
void (*signal_emit) (void *data, Evas_Object *obj, const char *emission, const char *source); /**< Feed a signal emitted with emission originally set as part_name:signal to this object (without the "part_name:" prefix) */
Eina_Bool (*param_set) (void *data, Evas_Object *obj, const Edje_External_Param *param); /**< dynamically change a parameter of this external, called by scripts and user code. Returns @c EINA_TRUE on success */
Eina_Bool (*param_get) (void *data, const Evas_Object *obj, Edje_External_Param *param); /**< dynamically fetch a parameter of this external, called by scripts and user code. Returns @c EINA_TRUE on success. (Must check parameter name and type!) */
Evas_Object *(*content_get) (void *data, const Evas_Object *obj, const char *content); /**< dynamically fetch a sub object of this external, called by scripts and user code. Returns @c Evas_Object * on success. (Must check parameter name and type!) */
void *(*params_parse) (void *data, Evas_Object *obj, const Eina_List *params); /**< parses the list of parameters, converting into a friendly representation. Used with state_set() */
void (*params_free) (void *params); /**< free parameters parsed with params_parse() */
@ -555,6 +556,7 @@ typedef void (*Edje_Message_Handler_Cb) (void *data, Evas_Object *obj, Edje_Mess
EAPI Evas_Object *edje_object_part_external_object_get (const Evas_Object *obj, const char *part);
EAPI Eina_Bool edje_object_part_external_param_set (Evas_Object *obj, const char *part, const Edje_External_Param *param);
EAPI Eina_Bool edje_object_part_external_param_get (const Evas_Object *obj, const char *part, Edje_External_Param *param);
EAPI Evas_Object *edje_object_part_external_content_get (const Evas_Object *obj, const char *part, const char *content);
EAPI Edje_External_Param_Type edje_object_part_external_param_type_get (const Evas_Object *obj, const char *part, const char *param);
EAPI Eina_Bool edje_object_part_box_append (Evas_Object *obj, const char *part, Evas_Object *child);

View File

@ -181,6 +181,29 @@ edje_object_part_external_param_get(const Evas_Object *obj, const char *part, Ed
return _edje_external_param_get(rp->swallowed_object, param);
}
EAPI Evas_Object*
edje_object_part_external_content_get(const Evas_Object *obj, const char *part, const char *content)
{
Edje *ed;
Edje_Real_Part *rp;
if (!content) return EINA_FALSE;
ed = _edje_fetch(obj);
if ((!ed) || (!part)) return EINA_FALSE;
rp = _edje_real_part_recursive_get(ed, (char *)part);
if (!rp)
{
ERR("no part '%s'", part);
return EINA_FALSE;
}
return _edje_external_content_get(rp->swallowed_object, content);
}
/**
* Facility to query the type of the given parameter of the given part.
*
@ -594,13 +617,31 @@ _edje_external_param_get(const Evas_Object *obj, Edje_External_Param *param)
}
if (!type->param_get)
{
ERR("external type '%s' from module '%s' does not provide param_set()",
ERR("external type '%s' from module '%s' does not provide param_get()",
type->module_name, type->module);
return EINA_FALSE;
}
return type->param_get(type->data, obj, param);
}
Evas_Object*
_edje_external_content_get(const Evas_Object *obj, const char *content)
{
Edje_External_Type *type = evas_object_data_get(obj, "Edje_External_Type");
if (!type)
{
ERR("no external type for object %p", obj);
return EINA_FALSE;
}
if (!type->content_get)
{
ERR("external type '%s' from module '%s' does not provide content_get()",
type->module_name, type->module);
return EINA_FALSE;
}
return type->content_get(type->data, obj, content);
}
void
_edje_external_params_free(Eina_List *external_params, Eina_Bool free_strings)
{

View File

@ -1683,6 +1683,7 @@ Evas_Object *_edje_external_type_add(const char *type_name, Evas *evas, Evas_Obj
void _edje_external_signal_emit(Evas_Object *obj, const char *emission, const char *source);
Eina_Bool _edje_external_param_set(Evas_Object *obj, const Edje_External_Param *param) EINA_ARG_NONNULL(1, 2);
Eina_Bool _edje_external_param_get(const Evas_Object *obj, Edje_External_Param *param) EINA_ARG_NONNULL(1, 2);
Evas_Object *_edje_external_content_get(const Evas_Object *obj, const char *content) EINA_ARG_NONNULL(1, 2);
void _edje_external_params_free(Eina_List *params, Eina_Bool free_strings);
void _edje_external_recalc_apply(Edje *ed, Edje_Real_Part *ep,
Edje_Calc_Params *params,

View File

@ -4252,6 +4252,9 @@ _edje_children_get(Edje_Real_Part *rp, const char *partid)
else
if (rp->part->type == EDJE_PART_TYPE_TABLE)
l = evas_object_table_children_get(rp->object);
else
if (rp->part->type == EDJE_PART_TYPE_EXTERNAL)
return _edje_external_content_get(rp->swallowed_object, partid);
else
return NULL;
@ -4320,6 +4323,7 @@ _edje_real_part_recursive_get_helper(Edje *ed, char **path)
return _edje_real_part_recursive_get_helper(ed, path);
case EDJE_PART_TYPE_BOX:
case EDJE_PART_TYPE_TABLE:
case EDJE_PART_TYPE_EXTERNAL:
if (!idx) return rp;
path++;