diff options
author | Daniel Hirt <hirt.danny@gmail.com> | 2017-06-11 17:26:52 +0300 |
---|---|---|
committer | Daniel Hirt <hirt.danny@gmail.com> | 2017-06-11 17:26:52 +0300 |
commit | 4bdff7dfc929f6cea1bc026ebcb26dc15b5e96b6 (patch) | |
tree | 85690a25c13c6dec1bd4f3a8f4eb81ab8e4cbb0f | |
parent | e3412a4152935e7892a15fd4289a1f9edb70af7f (diff) | |
download | efl-devs/herdsman/edje_part_cursor.tar.gz |
Edje part text: remove 'text/markup_filter' and 'user_insert'devs/herdsman/edje_part_cursor
-rw-r--r-- | src/lib/edje/Edje_Legacy.h | 162 | ||||
-rw-r--r-- | src/lib/edje/edje_legacy.c | 158 | ||||
-rw-r--r-- | src/lib/edje/edje_object.eo | 144 | ||||
-rw-r--r-- | src/lib/edje/edje_util.c | 134 |
4 files changed, 319 insertions, 279 deletions
diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h index c06053c7b3..f6d54e712f 100644 --- a/src/lib/edje/Edje_Legacy.h +++ b/src/lib/edje/Edje_Legacy.h @@ -1693,6 +1693,168 @@ EAPI Eina_Bool edje_object_part_text_item_geometry_get(const Edje_Object *obj, c EAPI const Eina_List *edje_object_part_text_item_list_get(const Edje_Object *obj, const char * part); /** + * @brief Adds a filter function for newly inserted text. + * + * Whenever text is inserted (not the same as set) into the given part, the + * list of filter functions will be called to decide if and how the new text + * will be accepted. There are three types of filters, EDJE_TEXT_FILTER_TEXT, + * EDJE_TEXT_FILTER_FORMAT and EDJE_TEXT_FILTER_MARKUP. The text parameter in + * the func filter can be modified by the user and it's up to him to free the + * one passed if he's to change the pointer. If doing so, the newly set text + * should be malloc'ed, as once all the filters are called Edje will free it. + * If the text is to be rejected, freeing it and setting the pointer to @c null + * will make Edje break out of the filter cycle and reject the inserted text. + * + * @warning This function will be deprecated because of difficulty in use. The + * type(format, text, or markup) of text should be always checked in the filter + * function for correct filtering. Please use + * edje_object_text_markup_filter_callback_add() instead. There is no need to + * check the type of text in the filter function because the text is always + * markup. Warning: If you use this function with + * edje_object_text_markup_filter_callback_add() together, all + * Edje_Text_Filter_Cb functions and Edje_Markup_Filter_Cb functions will be + * executed, and then filtered text will be inserted. + * + * See also @ref edje_object_text_insert_filter_callback_del, + * @ref edje_object_text_insert_filter_callback_del_full and + * @ref edje_object_text_markup_filter_callback_add + * + * @param[in] part The part name + * @param[in] func The callback function that will act as filter + * @param[in] data User provided data to pass to the filter function + * + * @ingroup Edje_Object + */ +EAPI void edje_object_text_insert_filter_callback_add(Edje_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data); + +/** + * @brief Deletes a function from the filter list. + * + * Delete the given func filter from the list in part. Returns the user data + * pointer given when added. + * + * See also @ref edje_object_text_insert_filter_callback_add and + * @ref edje_object_text_insert_filter_callback_del_full + * + * @param[in] part The part name + * @param[in] func The function callback to remove + * + * @return The user data pointer if successful, or @c null otherwise + * + * @ingroup Edje_Object + */ +EAPI void *edje_object_text_insert_filter_callback_del(Edje_Object *obj, const char *part, Edje_Text_Filter_Cb func); + +/** + * @brief Deletes a function and matching user data from the filter list. + * + * Delete the given func filter and data user data from the list in part. + * Returns the user data pointer given when added. + * + * See also @ref edje_object_text_insert_filter_callback_add and + * @ref edje_object_text_insert_filter_callback_del + * + * @param[in] part The part name + * @param[in] func The function callback to remove + * @param[in] data The data passed to the callback function + * + * @return The same data pointer if successful, or @c null otherwise + * + * @ingroup Edje_Object + */ +EAPI void *edje_object_text_insert_filter_callback_del_full(Edje_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data); + +/** + * @brief Adds a markup filter function for newly inserted text. + * + * Whenever text is inserted (not the same as set) into the given part, the + * list of markup filter functions will be called to decide if and how the new + * text will be accepted. The text parameter in the func filter is always + * markup. It can be modified by the user and it's up to him to free the one + * passed if he's to change the pointer. If doing so, the newly set text should + * be malloc'ed, as once all the filters are called Edje will free it. If the + * text is to be rejected, freeing it and setting the pointer to @c null will + * make Edje break out of the filter cycle and reject the inserted text. This + * function is different from edje_object_text_insert_filter_callback_add() in + * that the text parameter in the fucn filter is always markup. + * + * @warning If you use this function with + * edje_object_text_insert_filter_callback_add() togehter, all + * Edje_Text_Filter_Cb functions and Edje_Markup_Filter_Cb functions will be + * executed, and then filtered text will be inserted. + * + * See also @ref edje_object_text_markup_filter_callback_del, + * @ref edje_object_text_markup_filter_callback_del_full and + * @ref edje_object_text_insert_filter_callback_add + * + * @param[in] part The part name + * @param[in] func The callback function that will act as markup filter + * @param[in] data User provided data to pass to the filter function + * + * @since 1.2.0 + * + * @ingroup Edje_Object + */ +EAPI void edje_object_text_markup_filter_callback_add(Edje_Object *obj, const char *part, Edje_Markup_Filter_Cb func, void *data); + +/** + * @brief Deletes a function from the markup filter list. + * + * Delete the given func filter from the list in part. Returns the user data + * pointer given when added. + * + * See also @ref edje_object_text_markup_filter_callback_add and + * @ref edje_object_text_markup_filter_callback_del_full + * + * @param[in] part The part name + * @param[in] func The function callback to remove + * + * @return The user data pointer if successful, or @c null otherwise + * + * @since 1.2.0 + * + * @ingroup Edje_Object + */ +EAPI void *edje_object_text_markup_filter_callback_del(Edje_Object *obj, const char *part, Edje_Markup_Filter_Cb func); + +/** + * @brief Deletes a function and matching user data from the markup filter + * list. + * + * Delete the given func filter and data user data from the list in part. + * Returns the user data pointer given when added. + * + * See also @ref edje_object_text_markup_filter_callback_add and + * @ref edje_object_text_markup_filter_callback_del + * + * @param[in] part The part name + * @param[in] func The function callback to remove + * @param[in] data The data passed to the callback function + * + * @return The same data pointer if successful, or @c null otherwise + * + * @since 1.2.0 + * + * @ingroup Edje_Object + */ +EAPI void *edje_object_text_markup_filter_callback_del_full(Edje_Object *obj, const char *part, Edje_Markup_Filter_Cb func, void *data); + +/** + * @brief This function inserts text as if the user has inserted it. + * + * This means it actually registers as a change and emits signals, triggers + * callbacks as appropriate. + * + * @param[in] part The part name + * @param[in] text The text string + * + * @since 1.2.0 + * + * @ingroup Edje_Object + */ +EAPI void edje_object_part_text_user_insert(const Edje_Object *obj, const char *part, const char *text); + +/** * @} */ #include "edje_object.eo.legacy.h" diff --git a/src/lib/edje/edje_legacy.c b/src/lib/edje/edje_legacy.c index 5b11f5dc49..f26ec2b584 100644 --- a/src/lib/edje/edje_legacy.c +++ b/src/lib/edje/edje_legacy.c @@ -495,7 +495,7 @@ edje_object_part_text_item_list_get(const Eo *obj EINA_UNUSED, const char *part) return NULL; } -EOLIAN Eina_Bool +EAPI Eina_Bool edje_object_part_text_item_geometry_get(const Eo *obj EINA_UNUSED, const char *part, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch) { Edje_Real_Part *rp; @@ -513,3 +513,159 @@ edje_object_part_text_item_geometry_get(const Eo *obj EINA_UNUSED, const char *p return EINA_FALSE; } + +EAPI void +edje_object_text_insert_filter_callback_add(Eo *obj EINA_UNUSED, const char *part, Edje_Text_Filter_Cb func, void *data) +{ + Edje_Text_Insert_Filter_Callback *cb; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return; + cb = calloc(1, sizeof(Edje_Text_Insert_Filter_Callback)); + cb->part = eina_stringshare_add(part); + cb->func = func; + cb->data = (void *)data; + ed->text_insert_filter_callbacks = + eina_list_append(ed->text_insert_filter_callbacks, cb); +} + +EAPI void * +edje_object_text_insert_filter_callback_del(Eo *obj EINA_UNUSED, const char *part, Edje_Text_Filter_Cb func) +{ + Edje_Text_Insert_Filter_Callback *cb; + Eina_List *l; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return NULL; + EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb) + { + if ((!strcmp(cb->part, part)) && (cb->func == func)) + { + void *data = cb->data; + ed->text_insert_filter_callbacks = + eina_list_remove_list(ed->text_insert_filter_callbacks, l); + eina_stringshare_del(cb->part); + free(cb); + return data; + } + } + + return NULL; +} + +EAPI void * +edje_object_text_insert_filter_callback_del_full(Eo *obj EINA_UNUSED, const char *part, Edje_Text_Filter_Cb func, void *data) +{ + Edje_Text_Insert_Filter_Callback *cb; + Eina_List *l; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return NULL; + EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb) + { + if ((!strcmp(cb->part, part)) && (cb->func == func) && + (cb->data == data)) + { + void *tmp = cb->data; + ed->text_insert_filter_callbacks = + eina_list_remove_list(ed->text_insert_filter_callbacks, l); + eina_stringshare_del(cb->part); + free(cb); + return tmp; + } + } + + return NULL; +} + +EAPI void +edje_object_text_markup_filter_callback_add(Eo *obj EINA_UNUSED, const char *part, Edje_Markup_Filter_Cb func, void *data) +{ + Edje_Markup_Filter_Callback *cb; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return; + cb = calloc(1, sizeof(Edje_Markup_Filter_Callback)); + cb->part = eina_stringshare_add(part); + cb->func = func; + cb->data = (void *)data; + ed->markup_filter_callbacks = + eina_list_append(ed->markup_filter_callbacks, cb); +} + +EAPI void * +edje_object_text_markup_filter_callback_del(Eo *obj EINA_UNUSED, const char *part, Edje_Markup_Filter_Cb func) +{ + Edje_Markup_Filter_Callback *cb; + Eina_List *l; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return NULL; + EINA_LIST_FOREACH(ed->markup_filter_callbacks, l, cb) + { + if ((!strcmp(cb->part, part)) && (cb->func == func)) + { + void *data = cb->data; + ed->markup_filter_callbacks = + eina_list_remove_list(ed->markup_filter_callbacks, l); + eina_stringshare_del(cb->part); + free(cb); + return data; + } + } + + return NULL; +} + +EAPI void * +edje_object_text_markup_filter_callback_del_full(Eo *obj EINA_UNUSED, const char *part, Edje_Markup_Filter_Cb func, void *data) +{ + Edje_Markup_Filter_Callback *cb; + Eina_List *l; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return NULL; + EINA_LIST_FOREACH(ed->markup_filter_callbacks, l, cb) + { + if ((!strcmp(cb->part, part)) && (cb->func == func) && + (cb->data == data)) + { + void *tmp = cb->data; + ed->markup_filter_callbacks = + eina_list_remove_list(ed->markup_filter_callbacks, l); + eina_stringshare_del(cb->part); + free(cb); + return tmp; + } + } + + return NULL; +} + +EAPI void +edje_object_part_text_user_insert(const Eo *obj, const char *part, const char *text) +{ + Edje_Real_Part *rp; + Edje *ed; + + ed = efl_data_scope_get(obj, EDJE_OBJECT_CLASS); + + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(&ed, part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + _edje_entry_user_insert(rp, text); +} + diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo index 1e0d120314..d455c02d3c 100644 --- a/src/lib/edje/edje_object.eo +++ b/src/lib/edje/edje_object.eo @@ -850,18 +850,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part, @in text: string; [[The text string]] } } - part_text_user_insert @const { - [[This function inserts text as if the user has inserted it. - - This means it actually registers as a change and emits signals, triggers - callbacks as appropriate. - - @since 1.2.0]] - params { - @in part: string; [[The part name]] - @in text: string; [[The text string]] - } - } @property part_text_autocapital_type { set { [[Sets the autocapitalization type on the immodule. @@ -1217,138 +1205,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part, ondemand: bool; [[If $true, the input panel will be shown in case of only Mouse up event. (Focus event will be ignored.)]] } } - text_insert_filter_callback_add { - [[Adds a filter function for newly inserted text. - - Whenever text is inserted (not the same as set) into the given part, - the list of filter functions will be called to decide if and how the new - text will be accepted. - There are three types of filters, EDJE_TEXT_FILTER_TEXT, - EDJE_TEXT_FILTER_FORMAT and EDJE_TEXT_FILTER_MARKUP. - The text parameter in the func filter can be modified by the user and - it's up to him to free the one passed if he's to change the pointer. If - doing so, the newly set text should be malloc'ed, as once all the filters - are called Edje will free it. - If the text is to be rejected, freeing it and setting the pointer to $null - will make Edje break out of the filter cycle and reject the inserted - text. - - Warning: This function will be deprecated because of difficulty in use. - The type(format, text, or markup) of text should be always - checked in the filter function for correct filtering. - Please use edje_object_text_markup_filter_callback_add() instead. There - is no need to check the type of text in the filter function - because the text is always markup. - Warning: If you use this function with - edje_object_text_markup_filter_callback_add() together, all - Edje_Text_Filter_Cb functions and Edje_Markup_Filter_Cb functions - will be executed, and then filtered text will be inserted. - - See also @.text_insert_filter_callback_del, @.text_insert_filter_callback_del_full - and @.text_markup_filter_callback_add]] - - params { - @in part: string; [[The part name]] - @in func: Edje.Text.Filter_Cb; [[The callback function that will act as filter]] - @in data: void_ptr; [[User provided data to pass to the filter function]] - } - } - text_insert_filter_callback_del { - [[Deletes a function from the filter list. - - Delete the given func filter from the list in part. Returns - the user data pointer given when added. - - See also @.text_insert_filter_callback_add and @.text_insert_filter_callback_del_full]] - - return: void_ptr; [[The user data pointer if successful, or $null otherwise]] - params { - @in part: string; [[The part name]] - @in func: Edje.Text.Filter_Cb; [[The function callback to remove]] - } - } - text_insert_filter_callback_del_full { - [[Deletes a function and matching user data from the filter list. - - Delete the given func filter and data user data from the list - in part. - Returns the user data pointer given when added. - - See also @.text_insert_filter_callback_add and @.text_insert_filter_callback_del]] - - return: void_ptr; [[The same data pointer if successful, or $null otherwise]] - params { - @in part: string; [[The part name]] - @in func: Edje.Text.Filter_Cb; [[The function callback to remove]] - @in data: void_ptr; [[The data passed to the callback function]] - } - } - text_markup_filter_callback_add { - [[Adds a markup filter function for newly inserted text. - - Whenever text is inserted (not the same as set) into the given part, - the list of markup filter functions will be called to decide if and how - the new text will be accepted. - The text parameter in the func filter is always markup. It can be - modified by the user and it's up to him to free the one passed if he's to - change the pointer. If doing so, the newly set text should be malloc'ed, - as once all the filters are called Edje will free it. - If the text is to be rejected, freeing it and setting the pointer to $null - will make Edje break out of the filter cycle and reject the inserted - text. - This function is different from edje_object_text_insert_filter_callback_add() - in that the text parameter in the fucn filter is always markup. - - Warning: If you use this function with - edje_object_text_insert_filter_callback_add() togehter, all - Edje_Text_Filter_Cb functions and Edje_Markup_Filter_Cb functions - will be executed, and then filtered text will be inserted. - - See also @.text_markup_filter_callback_del, @.text_markup_filter_callback_del_full - and @.text_insert_filter_callback_add - - @since 1.2.0]] - - params { - @in part: string; [[The part name]] - @in func: Edje.Markup_Filter_Cb; [[The callback function that will act as markup filter]] - @in data: void_ptr; [[User provided data to pass to the filter function]] - } - } - text_markup_filter_callback_del { - [[Deletes a function from the markup filter list. - - Delete the given func filter from the list in part. Returns - the user data pointer given when added. - - See also @.text_markup_filter_callback_add and @.text_markup_filter_callback_del_full - - @since 1.2.0]] - - return: void_ptr; [[The user data pointer if successful, or $null otherwise]] - params { - @in part: string; [[The part name]] - @in func: Edje.Markup_Filter_Cb; [[The function callback to remove]] - } - } - text_markup_filter_callback_del_full { - [[Deletes a function and matching user data from the markup filter list. - - Delete the given func filter and data user data from the list - in part. - Returns the user data pointer given when added. - - See also @.text_markup_filter_callback_add and @.text_markup_filter_callback_del - - @since 1.2.0]] - - return: void_ptr; [[The same data pointer if successful, or $null otherwise]] - params { - @in part: string; [[The part name]] - @in func: Edje.Markup_Filter_Cb; [[The function callback to remove]] - @in data: void_ptr; [[The data passed to the callback function]] - } - } /* TEXT PART APIS END ------------------------------------------------ */ @property seat { diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c index 6556ec6bfb..5860a669b2 100644 --- a/src/lib/edje/edje_util.c +++ b/src/lib/edje/edje_util.c @@ -2355,18 +2355,6 @@ _edje_object_part_text_cursor_geometry_get(Eo *obj EINA_UNUSED, Edje *ed, const } } -EOLIAN void -_edje_object_part_text_user_insert(Eo *obj EINA_UNUSED, Edje *ed, const char *part, const char *text) -{ - Edje_Real_Part *rp; - - if ((!ed) || (!part)) return; - rp = _edje_real_part_recursive_get(&ed, part); - if (!rp) return; - if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) - _edje_entry_user_insert(rp, text); -} - EAPI void edje_object_part_text_select_allow_set(const Evas_Object *obj, const char *part, Eina_Bool allow) { @@ -3003,128 +2991,6 @@ _edje_object_part_text_input_panel_show_on_demand_get(Eo *obj EINA_UNUSED, Edje return ret; } -EOLIAN void -_edje_object_text_insert_filter_callback_add(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Text_Filter_Cb func, void *data) -{ - Edje_Text_Insert_Filter_Callback *cb; - - if ((!ed) || (!part)) return; - cb = calloc(1, sizeof(Edje_Text_Insert_Filter_Callback)); - cb->part = eina_stringshare_add(part); - cb->func = func; - cb->data = (void *)data; - ed->text_insert_filter_callbacks = - eina_list_append(ed->text_insert_filter_callbacks, cb); -} - -EOLIAN void * -_edje_object_text_insert_filter_callback_del(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Text_Filter_Cb func) -{ - Edje_Text_Insert_Filter_Callback *cb; - Eina_List *l; - - if ((!ed) || (!part)) return NULL; - EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb) - { - if ((!strcmp(cb->part, part)) && (cb->func == func)) - { - void *data = cb->data; - ed->text_insert_filter_callbacks = - eina_list_remove_list(ed->text_insert_filter_callbacks, l); - eina_stringshare_del(cb->part); - free(cb); - return data; - } - } - - return NULL; -} - -EOLIAN void * -_edje_object_text_insert_filter_callback_del_full(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Text_Filter_Cb func, void *data) -{ - Edje_Text_Insert_Filter_Callback *cb; - Eina_List *l; - - if ((!ed) || (!part)) return NULL; - EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb) - { - if ((!strcmp(cb->part, part)) && (cb->func == func) && - (cb->data == data)) - { - void *tmp = cb->data; - ed->text_insert_filter_callbacks = - eina_list_remove_list(ed->text_insert_filter_callbacks, l); - eina_stringshare_del(cb->part); - free(cb); - return tmp; - } - } - - return NULL; -} - -EOLIAN void -_edje_object_text_markup_filter_callback_add(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Markup_Filter_Cb func, void *data) -{ - Edje_Markup_Filter_Callback *cb; - - if ((!ed) || (!part)) return; - cb = calloc(1, sizeof(Edje_Markup_Filter_Callback)); - cb->part = eina_stringshare_add(part); - cb->func = func; - cb->data = (void *)data; - ed->markup_filter_callbacks = - eina_list_append(ed->markup_filter_callbacks, cb); -} - -EOLIAN void * -_edje_object_text_markup_filter_callback_del(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Markup_Filter_Cb func) -{ - Edje_Markup_Filter_Callback *cb; - Eina_List *l; - - if ((!ed) || (!part)) return NULL; - EINA_LIST_FOREACH(ed->markup_filter_callbacks, l, cb) - { - if ((!strcmp(cb->part, part)) && (cb->func == func)) - { - void *data = cb->data; - ed->markup_filter_callbacks = - eina_list_remove_list(ed->markup_filter_callbacks, l); - eina_stringshare_del(cb->part); - free(cb); - return data; - } - } - - return NULL; -} - -EOLIAN void * -_edje_object_text_markup_filter_callback_del_full(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Edje_Markup_Filter_Cb func, void *data) -{ - Edje_Markup_Filter_Callback *cb; - Eina_List *l; - - if ((!ed) || (!part)) return NULL; - EINA_LIST_FOREACH(ed->markup_filter_callbacks, l, cb) - { - if ((!strcmp(cb->part, part)) && (cb->func == func) && - (cb->data == data)) - { - void *tmp = cb->data; - ed->markup_filter_callbacks = - eina_list_remove_list(ed->markup_filter_callbacks, l); - eina_stringshare_del(cb->part); - free(cb); - return tmp; - } - } - - return NULL; -} - Eina_Bool _edje_efl_container_content_set(Edje *ed, const char *part, Efl_Gfx *obj_swallow) { |