diff options
Diffstat (limited to 'src/lib/efl/interfaces/efl_model_common.c')
-rw-r--r-- | src/lib/efl/interfaces/efl_model_common.c | 88 |
1 files changed, 24 insertions, 64 deletions
diff --git a/src/lib/efl/interfaces/efl_model_common.c b/src/lib/efl/interfaces/efl_model_common.c index 6bf825819f..ecbbb59ecb 100644 --- a/src/lib/efl/interfaces/efl_model_common.c +++ b/src/lib/efl/interfaces/efl_model_common.c @@ -23,87 +23,47 @@ static const char EFL_MODEL_ERROR_PERMISSION_DENIED_STR[] = "Permission denied"; static const char EFL_MODEL_ERROR_INCORRECT_VALUE_STR[] = "Incorrect value"; static const char EFL_MODEL_ERROR_INVALID_OBJECT_STR[] = "Object is invalid"; +#define _ERROR(Name) EFL_MODEL_ERROR_##Name = eina_error_msg_static_register(EFL_MODEL_ERROR_##Name##_STR); EAPI int efl_model_init(void) { - EFL_MODEL_ERROR_INCORRECT_VALUE = eina_error_msg_static_register( - EFL_MODEL_ERROR_INCORRECT_VALUE_STR); - - EFL_MODEL_ERROR_UNKNOWN = eina_error_msg_static_register( - EFL_MODEL_ERROR_UNKNOWN_STR); - - EFL_MODEL_ERROR_NOT_SUPPORTED = eina_error_msg_static_register( - EFL_MODEL_ERROR_NOT_SUPPORTED_STR); - - EFL_MODEL_ERROR_NOT_FOUND = eina_error_msg_static_register( - EFL_MODEL_ERROR_NOT_FOUND_STR); - - EFL_MODEL_ERROR_READ_ONLY = eina_error_msg_static_register( - EFL_MODEL_ERROR_READ_ONLY_STR); - - EFL_MODEL_ERROR_INIT_FAILED = eina_error_msg_static_register( - EFL_MODEL_ERROR_INIT_FAILED_STR); - - EFL_MODEL_ERROR_PERMISSION_DENIED = eina_error_msg_static_register( - EFL_MODEL_ERROR_PERMISSION_DENIED_STR); - - EFL_MODEL_ERROR_INVALID_OBJECT = eina_error_msg_static_register( - EFL_MODEL_ERROR_INVALID_OBJECT_STR); + _ERROR(INCORRECT_VALUE); + _ERROR(UNKNOWN); + _ERROR(NOT_SUPPORTED); + _ERROR(NOT_FOUND); + _ERROR(READ_ONLY); + _ERROR(INIT_FAILED); + _ERROR(PERMISSION_DENIED); + _ERROR(INVALID_OBJECT); return EINA_TRUE; } -EAPI Eina_Accessor* -efl_model_list_slice(Eina_List *list, unsigned start, unsigned count) -{ - if (!list) return NULL; +#undef _ERROR - if ((start == 0) && (count == 0)) /* this is full data */ - { - /* - * children_accessor will be set to NULL by - * eina_list_accessor_new if the later fails. - */ - return eina_list_accessor_new(list); - } +EAPI void +_efl_model_properties_changed_internal(const Efl_Model *model, ...) +{ + Efl_Model_Property_Event ev = { 0 }; + Eina_Array *properties = eina_array_new(1); + const char *property; + va_list args; - Eo *child; - Eina_List *l, *ln, *lr = NULL; - ln = eina_list_nth_list(list, (start)); - if (!ln) - { - return NULL; - } + va_start(args, model); - EINA_LIST_FOREACH(ln, l, child) + while ((property = (const char*) va_arg(args, const char*))) { - efl_ref(child); - lr = eina_list_append(lr, child); - if (eina_list_count(lr) == count) - break; + eina_array_push(properties, property); } - if (!lr) return NULL; + va_end(args); - // This may leak the children Eina_List. - return eina_list_accessor_new(lr); -} + ev.changed_properties = properties; -EAPI void -efl_model_property_changed_notify(Efl_Model *model, const char *property) -{ - Eina_Array *changed_properties = eina_array_new(1); - EINA_SAFETY_ON_NULL_RETURN(changed_properties); + efl_event_callback_call((Efl_Model *) model, EFL_MODEL_EVENT_PROPERTIES_CHANGED, &ev); - Eina_Bool ret = eina_array_push(changed_properties, property); - EINA_SAFETY_ON_FALSE_GOTO(ret, on_error); - - Efl_Model_Property_Event evt = {.changed_properties = changed_properties}; - efl_event_callback_call(model, EFL_MODEL_EVENT_PROPERTIES_CHANGED, &evt); - -on_error: - eina_array_free(changed_properties); + eina_array_free(properties); } EAPI void |