rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=69984d8a5115640a474d45ee10f0790c46028a85
commit 69984d8a5115640a474d45ee10f0790c46028a85 Author: Vyacheslav Reutskiy <v.reuts...@samsung.com> Date: Wed Oct 7 12:16:28 2015 +0300 popup: extend the fileselector helper API's Change the behavior of popup with fileselector. Now popup is not set the new value to entry, it's *must* do use, in callback on dismiss event. Change-Id: I97516eade30812248cf299a0bc17084943ebb5fa --- src/bin/ui/main_window.h | 9 ++++--- src/bin/ui/popup.c | 52 +++++++++++++++++++++++++++++----------- src/bin/ui/tab_home_common.c | 11 +++++++++ src/bin/ui/tab_home_import_edc.c | 8 +++++-- src/bin/ui/tab_home_import_edj.c | 7 ++++-- src/bin/ui/tab_home_new.c | 3 ++- src/bin/ui/tabs_private.h | 4 ++++ 7 files changed, 72 insertions(+), 22 deletions(-) diff --git a/src/bin/ui/main_window.h b/src/bin/ui/main_window.h index 4bc9892..ab40eb3 100644 --- a/src/bin/ui/main_window.h +++ b/src/bin/ui/main_window.h @@ -415,13 +415,16 @@ void popup_buttons_disabled_set(Popup_Button p_btns, Eina_Bool disabled); void -popup_fileselector_folder_helper(Evas_Object *follow_up, const char *path); +popup_fileselector_folder_helper(Evas_Object *follow_up, const char *path, + Evas_Smart_Cb func, void *data); void -popup_fileselector_edj_helper(const char *title, Evas_Object *follow_up, const char *path); +popup_fileselector_edj_helper(const char *title, Evas_Object *follow_up, const char *path, + Evas_Smart_Cb func, void *data); void -popup_fileselector_edc_helper(Evas_Object *follow_up, const char *path); +popup_fileselector_edc_helper(Evas_Object *follow_up, const char *path, + Evas_Smart_Cb func, void *data); void popup_log_message_helper(const char *msg); diff --git a/src/bin/ui/popup.c b/src/bin/ui/popup.c index b518eb9..76ab48b 100644 --- a/src/bin/ui/popup.c +++ b/src/bin/ui/popup.c @@ -21,6 +21,9 @@ static Popup_Button btn_pressed; static Evas_Object *popup; +static Evas_Object *fs; +static Evas_Smart_Cb dismiss_func; +static void* func_data; static const Popup_Button _btn_ok = BTN_OK; static const Popup_Button _btn_save = BTN_SAVE; @@ -130,13 +133,28 @@ _popup_dismiss(void *data __UNUSED__, } static void -_open(void *data, - Evas_Object *obj, +_done(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - Evas_Object *entry = (Evas_Object *)data; - elm_entry_entry_set(entry, elm_fileselector_selected_get(obj)); - _popup_dismiss(NULL, NULL, NULL, NULL); + Eina_List *selected_paths = NULL; + Eina_Stringshare *selected; + + if (dismiss_func) + { + if (elm_fileselector_multi_select_get(fs)) + selected_paths = (Eina_List *)elm_fileselector_selected_paths_get(fs); + else + { + selected = elm_fileselector_selected_get(fs); + selected_paths = eina_list_append(selected_paths, selected); + } + ((Evas_Smart_Cb)dismiss_func)(func_data, NULL, selected_paths); + } + eina_list_free(selected_paths); + dismiss_func = NULL; + func_data = NULL; + _popup_dismiss(NULL, NULL, data, NULL); } #define FS_W 430 @@ -175,9 +193,12 @@ static void _fileselector_helper(const char *title, Evas_Object *follow_up, const char *path, + Evas_Smart_Cb func, + void *data, Elm_Fileselector_Filter_Func filter_cb) { - Evas_Object *fs; + dismiss_func = func; + func_data = data; popup = elm_layout_add(ap.win); elm_layout_theme_set(popup, "layout", "popup", title ? "hint_title" : "hint"); @@ -193,8 +214,8 @@ _fileselector_helper(const char *title, else elm_fileselector_folder_only_set(fs, true); elm_fileselector_path_set(fs, path ? path : getenv("HOME")); - evas_object_smart_callback_add(fs, "done", _open, follow_up); - evas_object_smart_callback_add(fs, "activated", _open, follow_up); + evas_object_smart_callback_add(fs, "done", _done, NULL); + evas_object_smart_callback_add(fs, "activated", _done, NULL); /* small hack, hide not necessary button */ evas_object_hide(elm_layout_content_unset(fs, "elm.swallow.cancel")); /* one more hack, set text our text to button 'ok' */ @@ -219,9 +240,10 @@ _fileselector_helper(const char *title, } void -popup_fileselector_folder_helper(Evas_Object *follow_up, const char *path) +popup_fileselector_folder_helper(Evas_Object *follow_up, const char *path, + Evas_Smart_Cb func, void *data) { - _fileselector_helper(NULL, follow_up, path, NULL); + _fileselector_helper(NULL, follow_up, path, func, data, NULL); } static Eina_Bool @@ -237,9 +259,10 @@ _edj_filter(const char *path, } void -popup_fileselector_edj_helper(const char *title, Evas_Object *follow_up, const char *path) +popup_fileselector_edj_helper(const char *title, Evas_Object *follow_up, const char *path, + Evas_Smart_Cb func, void *data) { - _fileselector_helper(title, follow_up, path, _edj_filter); + _fileselector_helper(title, follow_up, path, func, data, _edj_filter); } static Eina_Bool @@ -255,9 +278,10 @@ _edc_filter(const char *path, } void -popup_fileselector_edc_helper(Evas_Object *follow_up, const char *path) +popup_fileselector_edc_helper(Evas_Object *follow_up, const char *path, + Evas_Smart_Cb func, void *data) { - _fileselector_helper(NULL, follow_up, path, _edc_filter); + _fileselector_helper(NULL, follow_up, path, func, data, _edc_filter); } void diff --git a/src/bin/ui/tab_home_common.c b/src/bin/ui/tab_home_common.c index e9dc1ee..f45c008 100644 --- a/src/bin/ui/tab_home_common.c +++ b/src/bin/ui/tab_home_common.c @@ -161,3 +161,14 @@ exist_permission_check(const char *path, const char *name, const char *title) eina_strbuf_free(buf_msg); eina_strbuf_free(buf); } + +void +entry_path_set(void *data, + Evas_Object *obj __UNUSED__, + void *event_info) +{ + Evas_Object *entry = (Evas_Object *)data; + Eina_List *selected = (Eina_List *)event_info; + + elm_entry_entry_set(entry, eina_list_data_get(selected)); +} diff --git a/src/bin/ui/tab_home_import_edc.c b/src/bin/ui/tab_home_import_edc.c index 1f152e3..5fe592f 100644 --- a/src/bin/ui/tab_home_import_edc.c +++ b/src/bin/ui/tab_home_import_edc.c @@ -106,7 +106,9 @@ _elipsis(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - popup_fileselector_folder_helper((Evas_Object *)data, elm_entry_entry_get(tab_edc.path)); + popup_fileselector_folder_helper((Evas_Object *)data, + elm_entry_entry_get(tab_edc.path), + entry_path_set, (Evas_Object *)data); } static void @@ -114,7 +116,9 @@ _elipsis_edc(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - popup_fileselector_edc_helper(tab_edc.edc, NULL); + popup_fileselector_edc_helper(tab_edc.edc, + NULL, + entry_path_set, tab_edc.edc); } static void diff --git a/src/bin/ui/tab_home_import_edj.c b/src/bin/ui/tab_home_import_edj.c index 5a9d4e2..896fc7a 100644 --- a/src/bin/ui/tab_home_import_edj.c +++ b/src/bin/ui/tab_home_import_edj.c @@ -122,7 +122,9 @@ _elipsis(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - popup_fileselector_folder_helper(tab_edj.path, elm_entry_entry_get(tab_edj.path)); + popup_fileselector_folder_helper(tab_edj.path, + elm_entry_entry_get(tab_edj.path), + entry_path_set, tab_edj.path); } static void @@ -130,7 +132,8 @@ _elipsis_edj(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - popup_fileselector_edj_helper(NULL, tab_edj.edj, NULL); + popup_fileselector_edj_helper(NULL, tab_edj.edj, NULL, + entry_path_set, tab_edj.edj); } Evas_Object * diff --git a/src/bin/ui/tab_home_new.c b/src/bin/ui/tab_home_new.c index 10d77fa..fb39b72 100644 --- a/src/bin/ui/tab_home_new.c +++ b/src/bin/ui/tab_home_new.c @@ -536,7 +536,8 @@ _elipsis(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - popup_fileselector_folder_helper(tab_new.path, elm_entry_entry_get(tab_new.path)); + popup_fileselector_folder_helper(tab_new.path, elm_entry_entry_get(tab_new.path), + entry_path_set, tab_new.path); } Evas_Object * diff --git a/src/bin/ui/tabs_private.h b/src/bin/ui/tabs_private.h index ab6ae43..d9df544 100644 --- a/src/bin/ui/tabs_private.h +++ b/src/bin/ui/tabs_private.h @@ -69,4 +69,8 @@ elipsis_btn_add(Evas_Object *entry, Evas_Smart_Cb cb_func, void *data); void exist_permission_check(const char *path, const char *name, const char *title); +void +entry_path_set(void *data, Evas_Object *obj, void *event_info); + + #endif /* TABS_PRIVATE */ --