raster pushed a commit to branch master.

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

commit afa54eb810848f93ce352516de6b05f0f2bd3bfa
Author: Jaeun Choi <jaeun12.c...@samsung.com>
Date:   Tue Apr 15 16:07:52 2014 +0900

    toolbar: apply key binding
    
    Summary: This patch applies key binding to elm_toolbar.
    
    Test Plan: None
    
    Reviewers: Hermet, raster
    
    Differential Revision: https://phab.enlightenment.org/D737
---
 config/default/base.src  |  71 ++++++++++++++++++++++++++++++++
 config/mobile/base.src   |  71 ++++++++++++++++++++++++++++++++
 config/standard/base.src |  71 ++++++++++++++++++++++++++++++++
 src/lib/elm_toolbar.c    | 103 ++++++++++++++++++++++++-----------------------
 4 files changed, 266 insertions(+), 50 deletions(-)

diff --git a/config/default/base.src b/config/default/base.src
index 2726563..b5ef141 100644
--- a/config/default/base.src
+++ b/config/default/base.src
@@ -1364,5 +1364,76 @@ group "Elm_Config" struct {
            }
         }
      }
+     group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elm_Toolbar";
+        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: "space";
+              value "action" string: "select";
+              value "params" string: "";
+           }
+           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";
+           }
+        }
+     }
   }
 }
diff --git a/config/mobile/base.src b/config/mobile/base.src
index 79c4433..622e2d6 100644
--- a/config/mobile/base.src
+++ b/config/mobile/base.src
@@ -1368,5 +1368,76 @@ group "Elm_Config" struct {
            }
         }
      }
+     group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elm_Toolbar";
+        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: "space";
+              value "action" string: "select";
+              value "params" string: "";
+           }
+           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";
+           }
+        }
+     }
   }
 }
diff --git a/config/standard/base.src b/config/standard/base.src
index 10e1240..0bafe71 100644
--- a/config/standard/base.src
+++ b/config/standard/base.src
@@ -1365,5 +1365,76 @@ group "Elm_Config" struct {
            }
         }
      }
+     group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elm_Toolbar";
+        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: "space";
+              value "action" string: "select";
+              value "params" string: "";
+           }
+           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";
+           }
+        }
+     }
   }
 }
diff --git a/src/lib/elm_toolbar.c b/src/lib/elm_toolbar.c
index 6fe7f48..d17aaef 100644
--- a/src/lib/elm_toolbar.c
+++ b/src/lib/elm_toolbar.c
@@ -44,6 +44,15 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
    {NULL, NULL}
 };
 
+static Eina_Bool _key_action_select(Evas_Object *obj, const char *params);
+static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
+
+static const Elm_Action key_actions[] = {
+   {"select", _key_action_select},
+   {"move", _key_action_move},
+   {NULL, NULL}
+};
+
 static void _item_select(Elm_Toolbar_Item *it);
 
 static int
@@ -832,69 +841,63 @@ _item_focused_next( Evas_Object *obj,
    return EINA_FALSE;
 }
 
-EOLIAN static Eina_Bool
-_elm_toolbar_elm_widget_event(Eo *obj, Elm_Toolbar_Data *sd, Evas_Object *src, 
Evas_Callback_Type type, void *event_info)
+static Eina_Bool
+_key_action_select(Evas_Object *obj, const char *params EINA_UNUSED)
 {
-   (void) src;
-   (void) type;
-   Evas_Event_Key_Down *ev = event_info;
+   ELM_TOOLBAR_DATA_GET(obj, sd);
 
-   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 (!sd->items) return EINA_FALSE;
+   if (sd->focused_item)
+     _item_select(sd->focused_item);
 
-   if ((!strcmp(ev->key, "Return")) ||
-       (!strcmp(ev->key, "KP_Enter")) ||
-       (!strcmp(ev->key, "space")))
-     {
-         if (sd->focused_item)
-           _item_select(sd->focused_item);
+   return EINA_TRUE;
+}
 
-        goto success;
-     }
-   else 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"))
      {
-        if (_item_focused_next(obj, EINA_TRUE, ELM_FOCUS_LEFT))
-          {
-             goto success;
-          }
-        else
-           return EINA_FALSE;
+        if (!_item_focused_next(obj, EINA_TRUE, ELM_FOCUS_LEFT))
+          return EINA_FALSE;
      }
-   else if ((!strcmp(ev->key, "Right")) ||
-            ((!strcmp(ev->key, "KP_Right")) && !ev->string))
+   else if (!strcmp(dir, "right"))
      {
-        if (_item_focused_next(obj, EINA_FALSE, ELM_FOCUS_RIGHT))
-          {
-             goto success;
-          }
-        else
-           return EINA_FALSE;
+        if (!_item_focused_next(obj, EINA_FALSE, ELM_FOCUS_RIGHT))
+          return EINA_FALSE;
      }
-   else if ((!strcmp(ev->key, "Up")) ||
-            ((!strcmp(ev->key, "KP_Up")) && !ev->string))
+   else if (!strcmp(dir, "up"))
      {
-        if (_item_focused_next(obj, EINA_TRUE, ELM_FOCUS_UP))
-          {
-             goto success;
-          }
-        else
-           return EINA_FALSE;
+        if (!_item_focused_next(obj, EINA_TRUE, ELM_FOCUS_UP))
+          return EINA_FALSE;
      }
-   else if ((!strcmp(ev->key, "Down")) ||
-            ((!strcmp(ev->key, "KP_Down")) && !ev->string))
+   else if (!strcmp(dir, "down"))
      {
-        if (_item_focused_next(obj, EINA_FALSE, ELM_FOCUS_DOWN))
-          {
-             goto success;
-          }
-        else
-           return EINA_FALSE;
+        if (!_item_focused_next(obj, EINA_FALSE, ELM_FOCUS_DOWN))
+          return EINA_FALSE;
      }
+   else return EINA_FALSE;
+
+   return EINA_TRUE;
+
+}
+
+EOLIAN static Eina_Bool
+_elm_toolbar_elm_widget_event(Eo *obj, Elm_Toolbar_Data *sd, Evas_Object *src, 
Evas_Callback_Type type, void *event_info)
+{
+   (void) src;
+   (void) type;
+   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 (!sd->items) return EINA_FALSE;
+
+   if (!_elm_config_key_binding_call(obj, ev, key_actions))
+     return EINA_FALSE;
 
-success:
    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
    return EINA_TRUE;
 }

-- 


Reply via email to