image: apply key binding
authorJaeun Choi <jaeun12.choi@samsung.com>
Tue, 15 Apr 2014 05:49:35 +0000 (14:49 +0900)
committerChunEon Park <hermet@hermet.pe.kr>
Tue, 15 Apr 2014 05:49:35 +0000 (14:49 +0900)
Summary: This patch applies key binding to elm_image.

Test Plan: None

Reviewers: Hermet, raster

Reviewed By: Hermet

Differential Revision: https://phab.enlightenment.org/D732

config/default/base.src
config/mobile/base.src
config/standard/base.src
src/lib/elm_image.c

index f3729f457d17af9a817d38c968f6605d4a6bc067..0de169c689baeb30043a01fdebea5695845df6c4 100644 (file)
@@ -654,6 +654,29 @@ group "Elm_Config" struct {
            }
         }
      }
+     group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elm_Image";
+        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_List";
         group "key_bindings" list {
index b3c7c624fb70c4b1c79d2953a2d2a20a99bcdae4..a308a28067bc827f950fb1a65a1f1f980d576a04 100644 (file)
@@ -658,6 +658,29 @@ group "Elm_Config" struct {
            }
         }
      }
+     group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elm_Image";
+        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_List";
         group "key_bindings" list {
index 0c7d55e2ec2bd9b054f67651aee3cf38632c3855..d44ebf407bdccf21ba0b9eb0fcd8d9aa6daebf83 100644 (file)
@@ -655,6 +655,29 @@ group "Elm_Config" struct {
            }
         }
      }
+     group "Elm_Config_Bindings_Widget" struct {
+        value "name" string: "Elm_Image";
+        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_List";
         group "key_bindings" list {
index e6bf02175aa87f4368aac5d0c49cba9a4614d6f5..5681f493aeba934b39aef8aa401306aed1eca394 100644 (file)
@@ -29,11 +29,12 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
    {NULL, NULL}
 };
 
-static void
-_activate(Evas_Object *obj)
-{
-   evas_object_smart_callback_call(obj, SIG_CLICKED, 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
 _on_image_preloaded(void *data,
@@ -560,6 +561,13 @@ _elm_image_elm_widget_theme_apply(Eo *obj, Elm_Image_Data *sd EINA_UNUSED)
    return EINA_TRUE;
 }
 
+static Eina_Bool
+_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
+{
+   evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
+   return EINA_TRUE;
+}
+
 EOLIAN static Eina_Bool
 _elm_image_elm_widget_event(Eo *obj, Elm_Image_Data *_pd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info)
 {
@@ -570,13 +578,9 @@ _elm_image_elm_widget_event(Eo *obj, Elm_Image_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;
 }