From: Jaeun Choi Date: Tue, 15 Apr 2014 04:58:01 +0000 (+0900) Subject: fileselector: apply key binding X-Git-Tag: v1.10.0-alpha1~113 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=820f3dc907250c0c08ed8431b50567e58d6dab5c;p=platform%2Fupstream%2Felementary.git 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 --- 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;