hermet pushed a commit to branch master.

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

commit fe6bb1d6b86933d50114b73da7302ec705633555
Author: Jaeun Choi <jaeun12.c...@samsung.com>
Date:   Tue Apr 15 14:54:58 2014 +0900

    radio: apply key binding
    
    Summary: This patch applies key binding to elm_radio.
    
    Test Plan: None
    
    Reviewers: Hermet, raster
    
    Differential Revision: https://phab.enlightenment.org/D734
---
 config/default/base.src  | 23 +++++++++++++++++++++++
 config/mobile/base.src   | 23 +++++++++++++++++++++++
 config/standard/base.src | 23 +++++++++++++++++++++++
 src/lib/elm_radio.c      | 20 +++++++++++++++-----
 4 files changed, 84 insertions(+), 5 deletions(-)

diff --git a/config/default/base.src b/config/default/base.src
index 1de5664..ef1b85b 100644
--- a/config/default/base.src
+++ b/config/default/base.src
@@ -1105,6 +1105,29 @@ group "Elm_Config" struct {
         }
      }
      group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elm_Radio";
+        group "key_bindings" list {
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Return";
+              value "action" string: "activate";
+              value "params" string: "";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Enter";
+              value "action" string: "activate";
+              value "params" string: "";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "space";
+              value "action" string: "activate";
+              value "params" string: "";
+           }
+        }
+     }
+     group "Elm_Config_Bindings_Widget" struct {
         value "name" string: "Elm_Scroller";
         group "key_bindings" list {
            group "Elm_Config_Binding_Key" struct {
diff --git a/config/mobile/base.src b/config/mobile/base.src
index a98745f..5060e3b 100644
--- a/config/mobile/base.src
+++ b/config/mobile/base.src
@@ -1109,6 +1109,29 @@ group "Elm_Config" struct {
         }
      }
      group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elm_Radio";
+        group "key_bindings" list {
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Return";
+              value "action" string: "activate";
+              value "params" string: "";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Enter";
+              value "action" string: "activate";
+              value "params" string: "";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "space";
+              value "action" string: "activate";
+              value "params" string: "";
+           }
+        }
+     }
+     group "Elm_Config_Bindings_Widget" struct {
         value "name" string: "Elm_Scroller";
         group "key_bindings" list {
            group "Elm_Config_Binding_Key" struct {
diff --git a/config/standard/base.src b/config/standard/base.src
index bdcdd97..5ad7169 100644
--- a/config/standard/base.src
+++ b/config/standard/base.src
@@ -1106,6 +1106,29 @@ group "Elm_Config" struct {
         }
      }
      group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elm_Radio";
+        group "key_bindings" list {
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Return";
+              value "action" string: "activate";
+              value "params" string: "";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Enter";
+              value "action" string: "activate";
+              value "params" string: "";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "space";
+              value "action" string: "activate";
+              value "params" string: "";
+           }
+        }
+     }
+     group "Elm_Config_Bindings_Widget" struct {
         value "name" string: "Elm_Scroller";
         group "key_bindings" list {
            group "Elm_Config_Binding_Key" struct {
diff --git a/src/lib/elm_radio.c b/src/lib/elm_radio.c
index 22cecb3..cbeb153 100644
--- a/src/lib/elm_radio.c
+++ b/src/lib/elm_radio.c
@@ -35,6 +35,13 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
    {NULL, NULL}
 };
 
+static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params);
+
+static const Elm_Action key_actions[] = {
+   {"activate", _key_action_activate},
+   {NULL, NULL}
+};
+
 static void
 _state_set(Evas_Object *obj, Eina_Bool state)
 {
@@ -144,6 +151,13 @@ _elm_radio_elm_container_content_set(Eo *obj, 
Elm_Radio_Data *_pd EINA_UNUSED, c
    return EINA_TRUE;
 }
 
+static Eina_Bool
+_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
+{
+   _activate(obj);
+   return EINA_TRUE;
+}
+
 EOLIAN static Eina_Bool
 _elm_radio_elm_widget_event(Eo *obj, Elm_Radio_Data *_pd EINA_UNUSED, 
Evas_Object *src, Evas_Callback_Type type, void *event_info)
 {
@@ -154,13 +168,9 @@ _elm_radio_elm_widget_event(Eo *obj, Elm_Radio_Data *_pd 
EINA_UNUSED, Evas_Objec
    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")) &&
-       (strcmp(ev->key, "space")))
+   if (!_elm_config_key_binding_call(obj, ev, key_actions))
      return EINA_FALSE;
 
-   _activate(obj);
-
    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
    return EINA_TRUE;
 }

-- 


Reply via email to