hermet pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=820f3dc907250c0c08ed8431b50567e58d6dab5c

commit 820f3dc907250c0c08ed8431b50567e58d6dab5c
Author: Jaeun Choi <jaeun12.c...@samsung.com>
Date:   Tue Apr 15 13:58:01 2014 +0900

    fileselector: apply key binding
    
    Summary: This patch applies key binding to elm_fileselector.
    
    Test Plan: elementary_test > fileselector > check key events
    
    Reviewers: Hermet, raster
    
    Differential Revision: https://phab.enlightenment.org/D728
---
 config/default/base.src    | 23 +++++++++++++++++++++++
 config/mobile/base.src     | 23 +++++++++++++++++++++++
 config/standard/base.src   | 23 +++++++++++++++++++++++
 src/lib/elc_fileselector.c | 30 ++++++++++++++++++++++++------
 4 files changed, 93 insertions(+), 6 deletions(-)

diff --git a/config/default/base.src b/config/default/base.src
index a417035..2ec3527 100644
--- a/config/default/base.src
+++ b/config/default/base.src
@@ -249,6 +249,29 @@ group "Elm_Config" struct {
   }
   group "bindings" list {
      group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elc_Fileselector";
+        group "key_bindings" list {
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Return";
+              value "action" string: "select";
+              value "params" string: "";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Enter";
+              value "action" string: "select";
+              value "params" string: "";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Escape";
+              value "action" string: "escape";
+              value "params" string: "";
+           }
+        }
+     }
+     group "Elm_Config_Bindings_Widget" struct {
         value "name" string: "Elm_Button";
         group "key_bindings" list {
            group "Elm_Config_Binding_Key" struct {
diff --git a/config/mobile/base.src b/config/mobile/base.src
index 6efe584..5e6d1b8 100644
--- a/config/mobile/base.src
+++ b/config/mobile/base.src
@@ -253,6 +253,29 @@ group "Elm_Config" struct {
   }
   group "bindings" list {
      group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elc_Fileselector";
+        group "key_bindings" list {
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Return";
+              value "action" string: "select";
+              value "params" string: "";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Enter";
+              value "action" string: "select";
+              value "params" string: "";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Escape";
+              value "action" string: "escape";
+              value "params" string: "";
+           }
+        }
+     }
+     group "Elm_Config_Bindings_Widget" struct {
         value "name" string: "Elm_Button";
         group "key_bindings" list {
            group "Elm_Config_Binding_Key" struct {
diff --git a/config/standard/base.src b/config/standard/base.src
index c65abfa..f044de9 100644
--- a/config/standard/base.src
+++ b/config/standard/base.src
@@ -250,6 +250,29 @@ group "Elm_Config" struct {
   }
   group "bindings" list {
      group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elc_Fileselector";
+        group "key_bindings" list {
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Return";
+              value "action" string: "select";
+              value "params" string: "";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Enter";
+              value "action" string: "select";
+              value "params" string: "";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Escape";
+              value "action" string: "escape";
+              value "params" string: "";
+           }
+        }
+     }
+     group "Elm_Config_Bindings_Widget" struct {
         value "name" string: "Elm_Button";
         group "key_bindings" list {
            group "Elm_Config_Binding_Key" struct {
diff --git a/src/lib/elc_fileselector.c b/src/lib/elc_fileselector.c
index 9450a05..986b7f6 100644
--- a/src/lib/elc_fileselector.c
+++ b/src/lib/elc_fileselector.c
@@ -42,6 +42,15 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
 };
 #undef ELM_PRIV_FILESELECTOR_SIGNALS
 
+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 const Elm_Action key_actions[] = {
+   {"select", _key_action_select},
+   {"escape", _key_action_escape},
+   {NULL, NULL}
+};
+
 static void _ok(void *data, Evas_Object *obj, void *event_info);
 static void _canc(void *data, Evas_Object *obj, void *event_info);
 
@@ -137,6 +146,20 @@ _elc_fileselector_elm_widget_theme_apply(Eo *obj, 
Elc_Fileselector_Data *sd)
    return EINA_TRUE;
 }
 
+static Eina_Bool
+_key_action_select(Evas_Object *obj, const char *params EINA_UNUSED)
+{
+   _ok(obj, NULL, NULL);
+   return EINA_TRUE;
+}
+
+static Eina_Bool
+_key_action_escape(Evas_Object *obj, const char *params EINA_UNUSED)
+{
+   _canc(obj, NULL, NULL);
+   return EINA_TRUE;
+}
+
 EOLIAN static Eina_Bool
 _elc_fileselector_elm_widget_event(Eo *obj, Elc_Fileselector_Data *sd 
EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info)
 {
@@ -147,12 +170,7 @@ _elc_fileselector_elm_widget_event(Eo *obj, 
Elc_Fileselector_Data *sd EINA_UNUSE
    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
 
-   if ((!strcmp(ev->key, "Return")) ||
-       (!strcmp(ev->key, "KP_Enter")))
-     _ok(obj, NULL, NULL);
-   else if (!strcmp(ev->key, "Escape"))
-     _canc(obj, NULL, NULL);
-   else
+   if (!_elm_config_key_binding_call(obj, ev, key_actions))
      return EINA_FALSE;
 
    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;

-- 


Reply via email to