From 5a6f5b770ba34826808144d2f5bd758e0a7e8177 Mon Sep 17 00:00:00 2001 From: Ryuan Choi Date: Thu, 12 Sep 2013 22:17:07 +0900 Subject: [PATCH] fileselector: Added "selected,invalid" signal for wrong path on the path_entry. If user typed wrong path on the path entry, "selected,invalid" will be emitted with "selected" for legacy. In addition, send "selected" signal when folder is changed in only folder mode. It's regression of 74f308df9. See more information from http://sourceforge.net/mailarchive/message.php?msg_id=31394571 --- legacy/elementary/ChangeLog | 4 +++ legacy/elementary/NEWS | 1 + legacy/elementary/src/bin/test_fileselector.c | 33 +++++++++++++++++++ legacy/elementary/src/lib/elc_fileselector.c | 22 ++++++++++--- legacy/elementary/src/lib/elc_fileselector.h | 2 ++ 5 files changed, 58 insertions(+), 4 deletions(-) diff --git a/legacy/elementary/ChangeLog b/legacy/elementary/ChangeLog index ff18f8c8c1..973c714c9f 100644 --- a/legacy/elementary/ChangeLog +++ b/legacy/elementary/ChangeLog @@ -1607,3 +1607,7 @@ 2013-09-11 Daniel Juyung Seo (SeoZ) * flip : Added support for focus direction. + +2013-09-12 Ryuan Choi (ryuan) + + * elc_fileselector : Added "selected,invalid" smart callbacks. diff --git a/legacy/elementary/NEWS b/legacy/elementary/NEWS index 3d536c07dd..029433f872 100644 --- a/legacy/elementary/NEWS +++ b/legacy/elementary/NEWS @@ -88,6 +88,7 @@ Additions: * Add support for more than one progress status in a progressbar. * Add elm_table_child_get(). * Add support for flip focus direction. + * Add "selected,invalid" smart callback for fileselector. Improvements: diff --git a/legacy/elementary/src/bin/test_fileselector.c b/legacy/elementary/src/bin/test_fileselector.c index f0f7665ac4..049a6a6cde 100644 --- a/legacy/elementary/src/bin/test_fileselector.c +++ b/legacy/elementary/src/bin/test_fileselector.c @@ -43,6 +43,37 @@ my_fileselector_selected(void *data EINA_UNUSED, printf("or: %s\n", elm_fileselector_selected_get(obj)); } +static void +_popup_close_cb(void *data, Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + evas_object_del(data); +} + +static void +my_fileselector_invalid(void *data EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, + void *event_info) +{ + Evas_Object *popup; + Evas_Object *btn; + char error_msg[256]; + + snprintf(error_msg, 256, "No such file or directory: %s", (char *)event_info); + + popup = elm_popup_add(data); + elm_popup_content_text_wrap_type_set(popup, ELM_WRAP_CHAR); + elm_object_part_text_set(popup, "title,text", "Error"); + elm_object_text_set(popup, error_msg); + + btn = elm_button_add(popup); + elm_object_text_set(btn, "OK"); + elm_object_part_content_set(popup, "button1", btn); + evas_object_smart_callback_add(btn, "clicked", _popup_close_cb, popup); + + evas_object_show(popup); +} + static void _is_save_clicked(void *data, Evas_Object *obj EINA_UNUSED, @@ -172,6 +203,8 @@ test_fileselector(void *data EINA_UNUSED, /* the 'selected' cb is called when the user click on a file/dir */ evas_object_smart_callback_add(fs, "selected", my_fileselector_selected, win); + evas_object_smart_callback_add(fs, "selected,invalid", + my_fileselector_invalid, win); /* test buttons */ sep = elm_separator_add(win); diff --git a/legacy/elementary/src/lib/elc_fileselector.c b/legacy/elementary/src/lib/elc_fileselector.c index 0d134129f2..c2d1f649db 100644 --- a/legacy/elementary/src/lib/elc_fileselector.c +++ b/legacy/elementary/src/lib/elc_fileselector.c @@ -33,7 +33,8 @@ static Elm_Gengrid_Item_Class *grid_itc[ELM_FILE_LAST]; #define ELM_PRIV_FILESELECTOR_SIGNALS(cmd) \ cmd(SIG_DIRECTORY_OPEN, "directory,open", "s") \ cmd(SIG_DONE, "done", "s") \ - cmd(SIG_SELECTED, "selected", "s") + cmd(SIG_SELECTED, "selected", "s") \ + cmd(SIG_SELECTED_INVALID, "selected,invalid", "s") ELM_PRIV_FILESELECTOR_SIGNALS(ELM_PRIV_STATIC_VARIABLE_DECLARE); @@ -813,8 +814,12 @@ _on_text_activated(void *data, path = elm_object_text_get(obj); - // FIXME: Needs some feedback to user like alert. - if (!ecore_file_exists(path)) goto end; + if (!ecore_file_exists(path)) + { + evas_object_smart_callback_call(fs, SIG_SELECTED, (void *)path); + evas_object_smart_callback_call(fs, SIG_SELECTED_INVALID, (void *)path); + goto end; + } if (ecore_file_is_dir(path)) { @@ -822,6 +827,10 @@ _on_text_activated(void *data, p = eina_stringshare_add(path); _populate(fs, p, NULL, NULL); eina_stringshare_del(p); + + if (sd->only_folder) + evas_object_smart_callback_call(fs, SIG_SELECTED, (void *)path); + goto end; } @@ -829,7 +838,12 @@ _on_text_activated(void *data, if (!dir) goto end; if (strcmp(dir, sd->path)) - _populate(fs, dir, NULL, path); + { + _populate(fs, dir, NULL, path); + + if (sd->only_folder) + evas_object_smart_callback_call(fs, SIG_SELECTED, (void *)path); + } else { if (sd->mode == ELM_FILESELECTOR_LIST) diff --git a/legacy/elementary/src/lib/elc_fileselector.h b/legacy/elementary/src/lib/elc_fileselector.h index 77e6a392e0..6d465c21f3 100644 --- a/legacy/elementary/src/lib/elc_fileselector.h +++ b/legacy/elementary/src/lib/elc_fileselector.h @@ -41,6 +41,8 @@ * @ref Layout: * - @c "selected" - the user has clicked on a file (when not in * folders-only mode) or directory (when in folders-only mode) + * - @c "selected,invalid" - the user has tried to access wrong path + * which does not exist. * - @c "directory,open" - the list has been populated with new * content (@c event_info is a pointer to the directory's * path, a @b stringshared string)