|
From: Ryuan C. - E. G. <no-...@en...> - 2013-09-12 13:38:25
|
ryuan pushed a commit to branch master.
commit 747e772ac1d8a55383824f5302bdfa0fc4e466ac
Author: Ryuan Choi <ryu...@gm...>
Date: Thu Sep 12 22:17:07 2013 +0900
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
---
ChangeLog | 4 ++++
NEWS | 1 +
src/bin/test_fileselector.c | 33 +++++++++++++++++++++++++++++++++
src/lib/elc_fileselector.c | 22 ++++++++++++++++++----
src/lib/elc_fileselector.h | 2 ++
5 files changed, 58 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ff18f8c..973c714 100644
--- a/ChangeLog
+++ b/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/NEWS b/NEWS
index 3d536c0..029433f 100644
--- a/NEWS
+++ b/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/src/bin/test_fileselector.c b/src/bin/test_fileselector.c
index f0f7665..049a6a6 100644
--- a/src/bin/test_fileselector.c
+++ b/src/bin/test_fileselector.c
@@ -44,6 +44,37 @@ my_fileselector_selected(void *data EINA_UNUSED,
}
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,
void *event_info 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/src/lib/elc_fileselector.c b/src/lib/elc_fileselector.c
index 0d13412..c2d1f64 100644
--- a/src/lib/elc_fileselector.c
+++ b/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/src/lib/elc_fileselector.h b/src/lib/elc_fileselector.h
index 77e6a39..6d465c2 100644
--- a/src/lib/elc_fileselector.h
+++ b/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)
--
|