forked from enlightenment/efl
slideshow: apply key binding
Summary: This patch applies key binding to elm_slideshow. Test Plan: None Reviewers: Hermet, raster Differential Revision: https://phab.enlightenment.org/D736
This commit is contained in:
parent
10fb0a3f30
commit
840e1fa07f
|
@ -1317,5 +1317,52 @@ group "Elm_Config" struct {
|
|||
}
|
||||
}
|
||||
}
|
||||
group "Elm_Config_Bindings_Widget" struct {
|
||||
value "name" string: "Elm_Slideshow";
|
||||
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: "Return";
|
||||
value "action" string: "pause";
|
||||
value "params" string: "";
|
||||
}
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "KP_Enter";
|
||||
value "action" string: "pause";
|
||||
value "params" string: "";
|
||||
}
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "space";
|
||||
value "action" string: "pause";
|
||||
value "params" string: "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1321,5 +1321,52 @@ group "Elm_Config" struct {
|
|||
}
|
||||
}
|
||||
}
|
||||
group "Elm_Config_Bindings_Widget" struct {
|
||||
value "name" string: "Elm_Slideshow";
|
||||
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: "Return";
|
||||
value "action" string: "pause";
|
||||
value "params" string: "";
|
||||
}
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "KP_Enter";
|
||||
value "action" string: "pause";
|
||||
value "params" string: "";
|
||||
}
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "space";
|
||||
value "action" string: "pause";
|
||||
value "params" string: "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1318,5 +1318,52 @@ group "Elm_Config" struct {
|
|||
}
|
||||
}
|
||||
}
|
||||
group "Elm_Config_Bindings_Widget" struct {
|
||||
value "name" string: "Elm_Slideshow";
|
||||
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: "Return";
|
||||
value "action" string: "pause";
|
||||
value "params" string: "";
|
||||
}
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "KP_Enter";
|
||||
value "action" string: "pause";
|
||||
value "params" string: "";
|
||||
}
|
||||
group "Elm_Config_Binding_Key" struct {
|
||||
value "context" int: 0;
|
||||
value "key" string: "space";
|
||||
value "action" string: "pause";
|
||||
value "params" string: "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,50 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
|||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
|
||||
static Eina_Bool _key_action_pause(Evas_Object *obj, const char *params);
|
||||
|
||||
static const Elm_Action key_actions[] = {
|
||||
{"move", _key_action_move},
|
||||
{"pause", _key_action_pause},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static Eina_Bool
|
||||
_key_action_move(Evas_Object *obj, const char *params)
|
||||
{
|
||||
const char *dir = params;
|
||||
|
||||
if (!strcmp(dir, "left"))
|
||||
{
|
||||
elm_slideshow_previous(obj);
|
||||
}
|
||||
else if (!strcmp(dir, "right"))
|
||||
{
|
||||
elm_slideshow_next(obj);
|
||||
}
|
||||
else return EINA_FALSE;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_key_action_pause(Evas_Object *obj, const char *params EINA_UNUSED)
|
||||
{
|
||||
ELM_SLIDESHOW_DATA_GET(obj, sd);
|
||||
|
||||
if (sd->timeout)
|
||||
{
|
||||
if (sd->timer)
|
||||
ELM_SAFE_FREE(sd->timer, ecore_timer_del);
|
||||
else
|
||||
elm_slideshow_timeout_set(obj, sd->timeout);
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_elm_slideshow_elm_widget_event(Eo *obj, Elm_Slideshow_Data *sd, Evas_Object *src, Evas_Callback_Type type, void *event_info)
|
||||
_elm_slideshow_elm_widget_event(Eo *obj, Elm_Slideshow_Data *sd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info)
|
||||
{
|
||||
Evas_Event_Key_Down *ev = event_info;
|
||||
(void) src;
|
||||
|
@ -35,35 +77,9 @@ _elm_slideshow_elm_widget_event(Eo *obj, Elm_Slideshow_Data *sd, Evas_Object *sr
|
|||
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, "Left")) ||
|
||||
((!strcmp(ev->key, "KP_Left")) && (!ev->string)))
|
||||
{
|
||||
elm_slideshow_previous(obj);
|
||||
goto success;
|
||||
}
|
||||
else if ((!strcmp(ev->key, "Right")) ||
|
||||
((!strcmp(ev->key, "KP_Right")) && (!ev->string)))
|
||||
{
|
||||
elm_slideshow_next(obj);
|
||||
goto success;
|
||||
}
|
||||
else if ((!strcmp(ev->key, "Return")) ||
|
||||
(!strcmp(ev->key, "KP_Enter")) ||
|
||||
(!strcmp(ev->key, "space")))
|
||||
{
|
||||
if (sd->timeout)
|
||||
{
|
||||
if (sd->timer)
|
||||
ELM_SAFE_FREE(sd->timer, ecore_timer_del);
|
||||
else
|
||||
elm_slideshow_timeout_set(obj, sd->timeout);
|
||||
}
|
||||
goto success;
|
||||
}
|
||||
if (!_elm_config_key_binding_call(obj, ev, key_actions))
|
||||
return EINA_FALSE;
|
||||
|
||||
return EINA_FALSE;
|
||||
|
||||
success:
|
||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue