cedric pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=3410e632fd718a99523a709bf01c4a2f5aaa061a

commit 3410e632fd718a99523a709bf01c4a2f5aaa061a
Author: Jee-Yong Um <jc9...@samsung.com>
Date:   Fri Mar 4 15:32:22 2016 -0800

    fileselector: add backspace key binding to move to previous path.
    
    Summary: Add backspace key to move to previous path.
    
    Test Plan:
    remove /home/username/.elementary (to apply new elementary config file)
    elementary_test -to fileselector
    
    Reviewers: cedric, jpeg
    
    Subscribers: bu5hm4n
    
    Differential Revision: https://phab.enlightenment.org/D3685
---
 config/default/base.src.in        |  6 ++++++
 config/mobile/base.src.in         |  6 ++++++
 config/standard/base.src.in       |  6 ++++++
 src/lib/elc_fileselector.c        | 23 +++++++++++++++++++++++
 src/lib/elm_widget_fileselector.h |  1 +
 5 files changed, 42 insertions(+)

diff --git a/config/default/base.src.in b/config/default/base.src.in
index f48f4a4..891a7b7 100644
--- a/config/default/base.src.in
+++ b/config/default/base.src.in
@@ -360,6 +360,12 @@ group "Elm_Config" struct {
               value "action" string: "escape";
               value "params" string: "";
            }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "BackSpace";
+              value "action" string: "backspace";
+              value "params" string: "";
+           }
         }
      }
      group "Elm_Config_Bindings_Widget" struct {
diff --git a/config/mobile/base.src.in b/config/mobile/base.src.in
index 8eca4b8..b950c80 100644
--- a/config/mobile/base.src.in
+++ b/config/mobile/base.src.in
@@ -364,6 +364,12 @@ group "Elm_Config" struct {
               value "action" string: "escape";
               value "params" string: "";
            }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "BackSpace";
+              value "action" string: "backspace";
+              value "params" string: "";
+           }
         }
      }
      group "Elm_Config_Bindings_Widget" struct {
diff --git a/config/standard/base.src.in b/config/standard/base.src.in
index 37c2cda..02344b0 100644
--- a/config/standard/base.src.in
+++ b/config/standard/base.src.in
@@ -361,6 +361,12 @@ group "Elm_Config" struct {
               value "action" string: "escape";
               value "params" string: "";
            }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "BackSpace";
+              value "action" string: "backspace";
+              value "params" string: "";
+           }
         }
      }
      group "Elm_Config_Bindings_Widget" struct {
diff --git a/src/lib/elc_fileselector.c b/src/lib/elc_fileselector.c
index 3ead816..7fef607 100644
--- a/src/lib/elc_fileselector.c
+++ b/src/lib/elc_fileselector.c
@@ -47,21 +47,26 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = 
{
 
 static Eina_Bool _key_action_select(Evas_Object *obj, const char *params);
 static Eina_Bool _key_action_escape(Evas_Object *obj, const char *params);
+static Eina_Bool _key_action_backspace(Evas_Object *obj, const char *params);
 
 static const Elm_Action key_actions[] = {
    {"select", _key_action_select},
    {"escape", _key_action_escape},
+   {"backspace", _key_action_backspace},
    {NULL, NULL}
 };
 
 static Eina_Bool _ok(void *data, const Eo_Event *event);
 static Eina_Bool _canc(void *data, const Eo_Event *event);
+static Eina_Bool _on_dir_up(void *data, const Eo_Event *event);
+static void _populate(Evas_Object *obj, const char *path, Elm_Object_Item 
*parent_it, const char *selected);
 
 /* final routine on deletion */
 static void
 _elm_fileselector_smart_del_do(Elm_Fileselector_Data *sd)
 {
    eina_stringshare_del(sd->path);
+   eina_stringshare_del(sd->prev_path);
    eina_stringshare_del(sd->selection);
    free(ecore_idler_del(sd->populate_idler));
    ecore_idler_del(sd->path_entry_idler);
@@ -167,6 +172,21 @@ _key_action_escape(Evas_Object *obj, const char *params 
EINA_UNUSED)
    return EINA_TRUE;
 }
 
+static Eina_Bool
+_key_action_backspace(Evas_Object *obj, const char *params EINA_UNUSED)
+{
+   ELM_FILESELECTOR_DATA_GET(obj, sd);
+   if (sd->prev_path)
+     _populate(obj, sd->prev_path, NULL, NULL);
+   else
+     _on_dir_up(obj, NULL);
+
+   eina_stringshare_del(sd->prev_path);
+   sd->prev_path = NULL;
+
+   return EINA_TRUE;
+}
+
 EOLIAN static Eina_Bool
 _elm_fileselector_elm_widget_event(Eo *obj, Elm_Fileselector_Data *sd 
EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info)
 {
@@ -1076,6 +1096,8 @@ _on_text_activated(void *data, const Eo_Event *event)
 
    if (ecore_file_is_dir(path))
      {
+        // keep previous path for backspace key action
+        eina_stringshare_replace(&sd->prev_path, sd->path);
         // keep a ref to path 'couse it will be destroyed by _populate
         p = eina_stringshare_add(path);
         _populate(fs, p, NULL, NULL);
@@ -2501,6 +2523,7 @@ 
_elm_fileselector_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA
    static Elm_Atspi_Action atspi_actions[] = {
           { "select", "select", NULL, _key_action_select },
           { "escape", "escape", NULL, _key_action_escape},
+          { "backspace", "backspace", NULL, _key_action_backspace},
           { NULL, NULL, NULL, NULL}
    };
    return &atspi_actions[0];
diff --git a/src/lib/elm_widget_fileselector.h 
b/src/lib/elm_widget_fileselector.h
index e9b0f03..e3f7c76 100644
--- a/src/lib/elm_widget_fileselector.h
+++ b/src/lib/elm_widget_fileselector.h
@@ -49,6 +49,7 @@ struct _Elm_Fileselector_Data
    Eina_List               *paths;
 
    const char              *path;
+   const char              *prev_path;
    const char              *selection;
    Ecore_Idler             *populate_idler;
    Ecore_Idler             *path_entry_idler;

-- 


Reply via email to