raster pushed a commit to branch master. http://git.enlightenment.org/core/elementary.git/commit/?id=96d2f454cc85c5b4dd1b534a694694e2d35ddc2c
commit 96d2f454cc85c5b4dd1b534a694694e2d35ddc2c Author: Jaeun Choi <jaeun12.c...@samsung.com> Date: Tue Apr 15 16:09:12 2014 +0900 video: apply key binding Summary: This patch applies key binding to elm_video. Test Plan: None Reviewers: Hermet, raster Differential Revision: https://phab.enlightenment.org/D738 --- config/default/base.src | 35 ++++++++++++++++++++++++ config/mobile/base.src | 35 ++++++++++++++++++++++++ config/standard/base.src | 35 ++++++++++++++++++++++++ src/lib/elm_video.c | 70 +++++++++++++++++++++++++++++------------------- 4 files changed, 148 insertions(+), 27 deletions(-) diff --git a/config/default/base.src b/config/default/base.src index b5ef141..b92d99e 100644 --- a/config/default/base.src +++ b/config/default/base.src @@ -1435,5 +1435,40 @@ group "Elm_Config" struct { } } } + group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elm_Video"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "space"; + value "action" string: "play"; + value "params" string: ""; + } + } + } } } diff --git a/config/mobile/base.src b/config/mobile/base.src index 622e2d6..19c5bcb 100644 --- a/config/mobile/base.src +++ b/config/mobile/base.src @@ -1439,5 +1439,40 @@ group "Elm_Config" struct { } } } + group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elm_Video"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "space"; + value "action" string: "play"; + value "params" string: ""; + } + } + } } } diff --git a/config/standard/base.src b/config/standard/base.src index 0bafe71..f60f263 100644 --- a/config/standard/base.src +++ b/config/standard/base.src @@ -1436,5 +1436,40 @@ group "Elm_Config" struct { } } } + group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elm_Video"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "space"; + value "action" string: "play"; + value "params" string: ""; + } + } + } } } diff --git a/src/lib/elm_video.c b/src/lib/elm_video.c index 0305e0a..9cbb002 100644 --- a/src/lib/elm_video.c +++ b/src/lib/elm_video.c @@ -24,18 +24,21 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = { {NULL, NULL} }; -EOLIAN static Eina_Bool -_elm_video_elm_widget_event(Eo *obj, Elm_Video_Data *_pd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info) -{ - (void) src; - Evas_Event_Key_Down *ev = event_info; +static Eina_Bool _key_action_move(Evas_Object *obj, const char *params); +static Eina_Bool _key_action_play(Evas_Object *obj, const char *params); - if (elm_widget_disabled_get(obj)) return EINA_FALSE; - if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE; - if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE; +static const Elm_Action key_actions[] = { + {"move", _key_action_move}, + {"play", _key_action_play}, + {NULL, NULL} +}; - if ((!strcmp(ev->key, "Left")) || - ((!strcmp(ev->key, "KP_Left")) && (!ev->string))) +static Eina_Bool +_key_action_move(Evas_Object *obj, const char *params) +{ + const char *dir = params; + + if (!strcmp(dir, "left")) { double current, last; @@ -47,11 +50,8 @@ _elm_video_elm_widget_event(Eo *obj, Elm_Video_Data *_pd EINA_UNUSED, Evas_Objec current += last / 100; elm_video_play_position_set(obj, current); } - - goto success; } - else if ((!strcmp(ev->key, "Right")) || - ((!strcmp(ev->key, "KP_Right")) && (!ev->string))) + else if (!strcmp(dir, "right")) { double current, last; @@ -64,23 +64,39 @@ _elm_video_elm_widget_event(Eo *obj, Elm_Video_Data *_pd EINA_UNUSED, Evas_Objec if (current < 0) current = 0; elm_video_play_position_set(obj, current); } - - goto success; } - else if (!strcmp(ev->key, "space")) - { - if (elm_video_is_playing_get(obj)) - elm_video_pause(obj); - else - elm_video_play(obj); + else return EINA_FALSE; - goto success; - } + return EINA_TRUE; +} - INF("keyname: '%s' not handled", ev->key); - return EINA_FALSE; +static Eina_Bool +_key_action_play(Evas_Object *obj, const char *params EINA_UNUSED) +{ + if (elm_video_is_playing_get(obj)) + elm_video_pause(obj); + else + elm_video_play(obj); + + return EINA_TRUE; +} + +EOLIAN static Eina_Bool +_elm_video_elm_widget_event(Eo *obj, Elm_Video_Data *_pd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info) +{ + (void) src; + Evas_Event_Key_Down *ev = event_info; + + if (elm_widget_disabled_get(obj)) return EINA_FALSE; + if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE; + if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE; + + if (!_elm_config_key_binding_call(obj, ev, key_actions)) + { + INF("keyname: '%s' not handled", ev->key); + return EINA_FALSE; + } -success: ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; return EINA_TRUE; } --