jackdanielz pushed a commit to branch master. http://git.enlightenment.org/tools/erigo.git/commit/?id=6c70b9e994a16dddd2b5be1cf8e2f2756f307a5a
commit 6c70b9e994a16dddd2b5be1cf8e2f2756f307a5a Author: Daniel Zaoui <daniel.za...@samsung.com> Date: Mon Nov 9 13:11:59 2015 +0200 Updater: add widget forcing infrastructures This is needed when e.g, an edje file has to be updated in a layout widget. Mementos mechanism cannot help for this kind of scenario, as no memento is created. --- src/lib/updater.c | 211 ++++++++++++++++++++++++++++++++---------------------- src/lib/updater.h | 8 +++ 2 files changed, 134 insertions(+), 85 deletions(-) diff --git a/src/lib/updater.c b/src/lib/updater.c index 69c917d..7a78a81 100644 --- a/src/lib/updater.c +++ b/src/lib/updater.c @@ -11,6 +11,13 @@ static Ecore_Idler *_idler = NULL; static Eina_List *_ctxs_to_update = NULL; #define SESSIONS_DATA_KEY "__updater_sessions" +#define CONTEXT_FORCE_WDGS_KEY "__updater_forced_widgets" + +typedef struct _force_info +{ + Eid *eid; + Updater_Force_Type type; +} Force_Info; void updater_session_add(Gui_Context *ctx, const Gui_Session *session) @@ -26,6 +33,21 @@ updater_wake(const Gui_Context *ctx) _ctxs_to_update = eina_list_append(_ctxs_to_update, ctx); } +void +updater_force(Eid *eid, Updater_Force_Type type) +{ + Gui_Widget *wdg = wdg_get(eid); + if (!wdg) return; + Gui_Context *ctx = (Gui_Context *)wdg_context_get(wdg); + Force_Info *info = calloc(1, sizeof(*info)); + info->eid = eid; + info->type = type; + Eina_List *infos = gui_context_data_get(ctx, CONTEXT_FORCE_WDGS_KEY); + infos = eina_list_append(infos, info); + gui_context_data_set(ctx, CONTEXT_FORCE_WDGS_KEY, infos); + updater_wake(ctx); +} + static void _eo_add_apply(const Eina_List *sessions, Eid *eid) { @@ -83,110 +105,129 @@ _update_check(void *data EINA_UNUSED) if (!_ctxs_to_update) return EINA_TRUE; EINA_LIST_FREE(_ctxs_to_update, ctx) { + Eina_List *sessions = gui_context_data_get(ctx, SESSIONS_DATA_KEY); Eina_Bool mem_dir = EINA_TRUE; Eina_List *mementos = context_memento_not_updated_list_steal(ctx, &mem_dir); - Eina_List *sessions = gui_context_data_get(ctx, SESSIONS_DATA_KEY); - Memento *mem; - EINA_LIST_FREE(mementos, mem) + if (mementos) { - const Eina_List *itr, *commands; - Memento_Command *cmd; - - commands = memento_commands_get(mem); - itr = mem_dir ? commands : eina_list_last(commands); - - /* According to direction we must iterate forward/backward through commands. - * Following for loop is opened EINA_LIST_FOREACH and EINA_LIST_REVERSE_FOREACH */ - for (cmd = eina_list_data_get(itr); - itr; - itr = (mem_dir ? eina_list_next(itr) : eina_list_prev(itr)), - cmd = eina_list_data_get(itr)) + Memento *mem; + EINA_LIST_FREE(mementos, mem) { - Eid *eid = memento_command_wdg_get(cmd); - Gui_Widget *wdg = wdg_get(eid); - Memento_Type type = memento_command_type_get(cmd); - void *from, *to; - if (mem_dir) - { - from = memento_command_old_pointer_get(cmd); - to = memento_command_new_pointer_get(cmd); - } - else - { - from = memento_command_new_pointer_get(cmd); - to = memento_command_old_pointer_get(cmd); - } - switch(type) + const Eina_List *itr, *commands; + Memento_Command *cmd; + + commands = memento_commands_get(mem); + itr = mem_dir ? commands : eina_list_last(commands); + + /* According to direction we must iterate forward/backward through commands. + * Following for loop is opened EINA_LIST_FOREACH and EINA_LIST_REVERSE_FOREACH */ + for (cmd = eina_list_data_get(itr); + itr; + itr = (mem_dir ? eina_list_next(itr) : eina_list_prev(itr)), + cmd = eina_list_data_get(itr)) { - case MEMENTO_WIDGET: - { - if (from) + Eid *eid = memento_command_wdg_get(cmd); + Gui_Widget *wdg = wdg_get(eid); + Memento_Type type = memento_command_type_get(cmd); + void *from, *to; + if (mem_dir) + { + from = memento_command_old_pointer_get(cmd); + to = memento_command_new_pointer_get(cmd); + } + else + { + from = memento_command_new_pointer_get(cmd); + to = memento_command_old_pointer_get(cmd); + } + switch(type) + { + case MEMENTO_WIDGET: { - eid_active_set(eid, EINA_TRUE); - _eo_del_apply(sessions, eid); - eid_active_set(eid, EINA_FALSE); + if (from) + { + eid_active_set(eid, EINA_TRUE); + _eo_del_apply(sessions, eid); + eid_active_set(eid, EINA_FALSE); + } + else + { + _eo_add_apply(sessions, eid); + Eid *parent_container_id = wdg_parent_container_eid_get(wdg); + if (parent_container_id) _obj_container_update(sessions, parent_container_id); + } + break; } - else + case MEMENTO_PROPERTY: { - _eo_add_apply(sessions, eid); - Eid *parent_container_id = wdg_parent_container_eid_get(wdg); - if (parent_container_id) _obj_container_update(sessions, parent_container_id); + if (to) _eo_prop_apply(sessions, eid, to); + else + { + _eo_del_apply(sessions, eid); + _eo_add_apply(sessions, eid); + /* Here separate algorithm for each kind of container can be implemented. */ + Eid *parent_container_id = wdg_parent_container_eid_get(wdg); + if (parent_container_id) _obj_container_update(sessions, parent_container_id); + } + break; } - break; - } - case MEMENTO_PROPERTY: - { - if (to) _eo_prop_apply(sessions, eid, to); - else + case MEMENTO_OBJ_CONTAINER: { - _eo_del_apply(sessions, eid); - _eo_add_apply(sessions, eid); - /* Here separate algorithm for each kind of container can be implemented. */ - Eid *parent_container_id = wdg_parent_container_eid_get(wdg); - if (parent_container_id) _obj_container_update(sessions, parent_container_id); + _obj_container_update(sessions, eid); + break; } - break; - } - case MEMENTO_OBJ_CONTAINER: - { - _obj_container_update(sessions, eid); - break; - } - case MEMENTO_WIDGET_PARENT: - { - _eo_del_apply(sessions, eid); - _eo_add_apply(sessions, eid); - break; - } - case MEMENTO_ITEM_CONTAINER_ITEM: - { - if (strstr(wdg_name_get(wdg), "main_menu")) - { - Eid *parent_eid = wdg_parent_id_get(wdg); - _eo_del_apply(sessions, parent_eid); - _eo_add_apply(sessions, parent_eid); - } - else + case MEMENTO_WIDGET_PARENT: { _eo_del_apply(sessions, eid); _eo_add_apply(sessions, eid); - /* Here separate algorithm for each kind of container can be implemented. */ - Eid *parent_container_id = wdg_parent_container_eid_get(wdg); - if (parent_container_id) _obj_container_update(sessions, parent_container_id); + break; } + case MEMENTO_ITEM_CONTAINER_ITEM: + { + if (strstr(wdg_name_get(wdg), "main_menu")) + { + Eid *parent_eid = wdg_parent_id_get(wdg); + _eo_del_apply(sessions, parent_eid); + _eo_add_apply(sessions, parent_eid); + } + else + { + _eo_del_apply(sessions, eid); + _eo_add_apply(sessions, eid); + /* Here separate algorithm for each kind of container can be implemented. */ + Eid *parent_container_id = wdg_parent_container_eid_get(wdg); + if (parent_container_id) _obj_container_update(sessions, parent_container_id); + } + break; + } + case MEMENTO_ACTION: + case MEMENTO_CALLBACK: + case MEMENTO_CALLBACK_ADD_DEL: + case MEMENTO_WIDGET_NAME: + case MEMENTO_WIDGET_PUBLIC: + default: + printf("%s - Apply %d\n", __FUNCTION__, type); break; - } - case MEMENTO_ACTION: - case MEMENTO_CALLBACK: - case MEMENTO_CALLBACK_ADD_DEL: - case MEMENTO_WIDGET_NAME: - case MEMENTO_WIDGET_PUBLIC: - default: - printf("%s - Apply %d\n", __FUNCTION__, type); - break; + } } } } + Eina_List *forced_wdgs_infos = gui_context_data_get(ctx, CONTEXT_FORCE_WDGS_KEY); + Force_Info *info; + EINA_LIST_FREE(forced_wdgs_infos, info) + { + switch(info->type) + { + case UPDATER_PROPERTIES_FORCE: + { + _obj_container_update(sessions, info->eid); + break; + } + default: break; + } + free(info); + } + gui_context_data_set(ctx, CONTEXT_FORCE_WDGS_KEY, NULL); } return EINA_TRUE; } diff --git a/src/lib/updater.h b/src/lib/updater.h index a60f9ea..6ae572c 100644 --- a/src/lib/updater.h +++ b/src/lib/updater.h @@ -1,6 +1,11 @@ #ifndef UPDATER_H #define UPDATER_H +typedef enum +{ + UPDATER_PROPERTIES_FORCE +} Updater_Force_Type; + Eina_Bool updater_init(); @@ -13,4 +18,7 @@ updater_session_add(Gui_Context *ctx, const Gui_Session *session); void updater_wake(const Gui_Context *ctx); +void +updater_force(Eid *eid, Updater_Force_Type type); + #endif --