hermet pushed a commit to branch master.

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

commit bc4153058d122f78f78d6efd65d9201e5a6bf6e5
Author: Jaeun Choi <jaeun12.c...@samsung.com>
Date:   Tue Apr 15 14:40:38 2014 +0900

    hoversel: apply key binding
    
    Summary: This patch applied key bindiing to elc_hoversel.
    
    Test Plan: None
    
    Reviewers: Hermet, raster
    
    Reviewed By: Hermet
    
    Differential Revision: https://phab.enlightenment.org/D729
---
 config/default/base.src  | 53 ++++++++++++++++++++++++++++++++++
 config/mobile/base.src   | 53 ++++++++++++++++++++++++++++++++++
 config/standard/base.src | 53 ++++++++++++++++++++++++++++++++++
 src/lib/elc_hoversel.c   | 75 +++++++++++++++++++++++++++---------------------
 4 files changed, 201 insertions(+), 33 deletions(-)

diff --git a/config/default/base.src b/config/default/base.src
index 2ec3527..10866d3 100644
--- a/config/default/base.src
+++ b/config/default/base.src
@@ -272,6 +272,59 @@ group "Elm_Config" struct {
         }
      }
      group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elc_Hoversel";
+        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: "Up";
+              value "action" string: "move";
+              value "params" string: "up";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Up";
+              value "action" string: "move";
+              value "params" string: "up";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Down";
+              value "action" string: "move";
+              value "params" string: "down";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Down";
+              value "action" string: "move";
+              value "params" string: "down";
+           }
+        }
+     }
+     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 5e6d1b8..50bd082 100644
--- a/config/mobile/base.src
+++ b/config/mobile/base.src
@@ -276,6 +276,59 @@ group "Elm_Config" struct {
         }
      }
      group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elc_Hoversel";
+        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: "Up";
+              value "action" string: "move";
+              value "params" string: "up";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Up";
+              value "action" string: "move";
+              value "params" string: "up";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Down";
+              value "action" string: "move";
+              value "params" string: "down";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Down";
+              value "action" string: "move";
+              value "params" string: "down";
+           }
+        }
+     }
+     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 f044de9..bd7a162 100644
--- a/config/standard/base.src
+++ b/config/standard/base.src
@@ -273,6 +273,59 @@ group "Elm_Config" struct {
         }
      }
      group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elc_Hoversel";
+        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: "Up";
+              value "action" string: "move";
+              value "params" string: "up";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Up";
+              value "action" string: "move";
+              value "params" string: "up";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "Down";
+              value "action" string: "move";
+              value "params" string: "down";
+           }
+           group "Elm_Config_Binding_Key" struct {
+              value "context" int: 0;
+              value "key" string: "KP_Down";
+              value "action" string: "move";
+              value "params" string: "down";
+           }
+        }
+     }
+     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_hoversel.c b/src/lib/elc_hoversel.c
index 414f127..c77d342 100644
--- a/src/lib/elc_hoversel.c
+++ b/src/lib/elc_hoversel.c
@@ -29,6 +29,13 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
    {NULL, NULL}
 };
 
+static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
+
+static const Elm_Action key_actions[] = {
+   {"move", _key_action_move},
+   {NULL, NULL}
+};
+
 EOLIAN static Eina_Bool
 _elc_hoversel_elm_widget_translate(Eo *obj EINA_UNUSED, Elc_Hoversel_Data *sd)
 {
@@ -494,76 +501,78 @@ item_focused_get(Elc_Hoversel_Data *sd)
    return NULL;
 }
 
-EOLIAN static Eina_Bool
-_elc_hoversel_elm_widget_event(Eo *obj, Elc_Hoversel_Data *sd, Evas_Object 
*src, Evas_Callback_Type type, void *event_info)
+static Eina_Bool
+_key_action_move(Evas_Object *obj, const char *params)
 {
-   (void) src;
-   Eina_Bool int_ret = EINA_FALSE;
-   Evas_Event_Key_Down *ev = event_info;
+   ELM_HOVERSEL_DATA_GET(obj, sd);
+   const char *dir = params;
 
    Elm_Hoversel_Item  *litem, *fitem;
-
-   eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_event(src, type, 
event_info));
-   if (int_ret) return EINA_FALSE;
-
-   if (!sd || !sd->hover) return EINA_FALSE;
-   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;
-
    litem = eina_list_last_data_get(sd->items);
    fitem = eina_list_data_get(sd->items);
 
-   if ((!strcmp(ev->key, "Down")) ||
-      ((!strcmp(ev->key, "KP_Down")) && (!ev->string)))
+   if (!strcmp(dir, "down"))
      {
         if (item_focused_get(sd) == litem)
           {
             elm_object_focus_set(VIEW(fitem), EINA_TRUE);
-            goto success;
+            return EINA_TRUE;
           }
         elm_widget_focus_cycle(sd->hover, ELM_FOCUS_DOWN);
-        goto success;
+        return EINA_TRUE;
      }
-   else if ((!strcmp(ev->key, "Up")) ||
-           ((!strcmp(ev->key, "KP_Up")) && (!ev->string)))
+   else if (!strcmp(dir, "up"))
      {
         if (item_focused_get(sd) == fitem)
           {
             elm_object_focus_set(VIEW(litem), EINA_TRUE);
-            goto success;
+            return EINA_TRUE;
           }
         elm_widget_focus_cycle(sd->hover, ELM_FOCUS_UP);
-        goto success;
+        return EINA_TRUE;
      }
-   else if ((!strcmp(ev->key, "Left")) ||
-           ((!strcmp(ev->key, "KP_Left")) && (!ev->string)))
+   else if (!strcmp(dir, "left"))
      {
         if (item_focused_get(sd) == fitem)
           {
             elm_object_focus_set(VIEW(litem), EINA_TRUE);
-            goto success;
+            return EINA_TRUE;
           }
         elm_widget_focus_cycle(sd->hover, ELM_FOCUS_LEFT);
-        goto success;
+        return EINA_TRUE;
      }
-   else if ((!strcmp(ev->key, "Right")) ||
-           ((!strcmp(ev->key, "KP_Right")) && (!ev->string)))
+   else if (!strcmp(dir, "right"))
      {
         if (item_focused_get(sd) == litem)
           {
             elm_object_focus_set(VIEW(fitem), EINA_TRUE);
-            goto success;
+            return EINA_TRUE;
           }
         elm_widget_focus_cycle(sd->hover, ELM_FOCUS_RIGHT);
-        goto success;
+        return EINA_TRUE;
      }
+   else return EINA_FALSE;
+}
 
-   return EINA_FALSE;
+EOLIAN static Eina_Bool
+_elc_hoversel_elm_widget_event(Eo *obj, Elc_Hoversel_Data *sd, Evas_Object 
*src, Evas_Callback_Type type, void *event_info)
+{
+   (void) src;
+   Eina_Bool int_ret = EINA_FALSE;
+   Evas_Event_Key_Down *ev = event_info;
 
-   success:
-   ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+   eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_event(src, type, 
event_info));
+   if (int_ret) return EINA_FALSE;
 
+   if (!sd || !sd->hover) return EINA_FALSE;
+   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))
+     return EINA_FALSE;
+
+   ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
    return EINA_TRUE;
 }
 

-- 


Reply via email to