From f17e9732b8a89250aa336ffc825917faa5f7e569 Mon Sep 17 00:00:00 2001 From: Tiago Rezende Campos Falcao Date: Wed, 22 Sep 2010 17:45:43 +0000 Subject: [PATCH] Complete some widgets with activate_hook widgets: * button * check * file selector button * hoversel * radio Author: Helen Fornazier SVN revision: 52598 --- src/lib/elc_fileselector_button.c | 23 +++++++++++++++++++---- src/lib/elc_hoversel.c | 9 +++++++++ src/lib/elm_button.c | 23 +++++++++++++++++++---- src/lib/elm_check.c | 21 +++++++++++++++++++-- src/lib/elm_radio.c | 23 ++++++++++++++++++++--- 5 files changed, 86 insertions(+), 13 deletions(-) diff --git a/src/lib/elc_fileselector_button.c b/src/lib/elc_fileselector_button.c index e96fb2d01..12cce33be 100644 --- a/src/lib/elc_fileselector_button.c +++ b/src/lib/elc_fileselector_button.c @@ -41,6 +41,8 @@ static void _signal_pressed(void *data, Evas_Object *obj, const char *emission, static void _signal_unpressed(void *data, Evas_Object *obj, const char *emission, const char *source); static void _on_focus_hook(void *data, Evas_Object *obj); static void _selection_done(void *data, Evas_Object *obj, void *event_info); +static void _activate(Evas_Object *obj); +static void _activate_hook(Evas_Object *obj); static const char SIG_CLICKED[] = "clicked"; static const char SIG_UNPRESSED[] = "unpressed"; @@ -166,15 +168,27 @@ _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info) } static void -_signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source) +_activate(Evas_Object *obj) { - Widget_Data *wd = elm_widget_data_get(data); + Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; - evas_object_smart_callback_call(data, SIG_CLICKED, NULL); + evas_object_smart_callback_call(obj, SIG_CLICKED, NULL); /* safe guard when the theme does not emit the 'unpress' signal */ - _signal_unpressed(data, obj, emission, source); + _signal_unpressed(obj, wd->btn, NULL, NULL); +} + +static void +_activate_hook(Evas_Object *obj) +{ + _activate(obj); +} + +static void +_signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + _activate(data); } static Evas_Object * @@ -343,6 +357,7 @@ elm_fileselector_button_add(Evas_Object *parent) elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_disable_hook_set(obj, _disable_hook); elm_widget_can_focus_set(obj, 1); + elm_widget_activate_hook_set(obj, _activate_hook); wd->btn = edje_object_add(e); _elm_theme_object_set(obj, wd->btn, "button", "base", "default"); diff --git a/src/lib/elc_hoversel.c b/src/lib/elc_hoversel.c index b9dddcc0f..0bb961551 100644 --- a/src/lib/elc_hoversel.c +++ b/src/lib/elc_hoversel.c @@ -42,6 +42,8 @@ struct _Elm_Hoversel_Item static const char *widtype = NULL; static void _del_pre_hook(Evas_Object *obj); static void _del_hook(Evas_Object *obj); +static void _activate(Evas_Object *obj); +static void _activate_hook(Evas_Object *obj); static void _disable_hook(Evas_Object *obj); static void _sizing_eval(Evas_Object *obj); static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info); @@ -206,6 +208,12 @@ _activate(Evas_Object *obj) // if (wd->horizontal) evas_object_hide(wd->btn); } +static void +_activate_hook(Evas_Object *obj) +{ + _activate(obj); +} + static void _button_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { @@ -247,6 +255,7 @@ elm_hoversel_add(Evas_Object *parent) elm_widget_del_hook_set(obj, _del_hook); elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_disable_hook_set(obj, _disable_hook); + elm_widget_activate_hook_set(obj, _activate_hook); wd->btn = elm_button_add(parent); if (wd->horizontal) diff --git a/src/lib/elm_button.c b/src/lib/elm_button.c index 3299008cb..8117b1855 100644 --- a/src/lib/elm_button.c +++ b/src/lib/elm_button.c @@ -32,6 +32,8 @@ static void _signal_clicked(void *data, Evas_Object *obj, const char *emission, static void _signal_pressed(void *data, Evas_Object *obj, const char *emission, const char *source); static void _signal_unpressed(void *data, Evas_Object *obj, const char *emission, const char *source); static void _on_focus_hook(void *data, Evas_Object *obj); +static void _activate(Evas_Object *obj); +static void _activate_hook(Evas_Object *obj); static const char SIG_CLICKED[] = "clicked"; static const char SIG_REPEATED[] = "repeated"; @@ -143,9 +145,9 @@ _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info) } static void -_signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source) +_activate(Evas_Object *obj) { - Widget_Data *wd = elm_widget_data_get(data); + Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; if (wd->timer) { @@ -153,8 +155,20 @@ _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char * wd->timer = NULL; } wd->repeating = EINA_FALSE; - evas_object_smart_callback_call(data, SIG_CLICKED, NULL); - _signal_unpressed(data, obj, emission, source); /* safe guard when the theme does not emit the 'unpress' signal */ + evas_object_smart_callback_call(obj, SIG_CLICKED, NULL); + _signal_unpressed(obj, wd->btn, NULL, NULL); /* safe guard when the theme does not emit the 'unpress' signal */ +} + +static void +_activate_hook(Evas_Object *obj) +{ + _activate(obj); +} + +static void +_signal_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) +{ + _activate(data); } static Eina_Bool @@ -243,6 +257,7 @@ elm_button_add(Evas_Object *parent) elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_disable_hook_set(obj, _disable_hook); elm_widget_can_focus_set(obj, 1); + elm_widget_activate_hook_set(obj, _activate_hook); wd->btn = edje_object_add(e); _elm_theme_object_set(obj, wd->btn, "button", "base", "default"); diff --git a/src/lib/elm_check.c b/src/lib/elm_check.c index 188ed3f0a..509a02926 100644 --- a/src/lib/elm_check.c +++ b/src/lib/elm_check.c @@ -39,6 +39,9 @@ static void _sub_del(void *data, Evas_Object *obj, void *event_info); static void _signal_check_off(void *data, Evas_Object *obj, const char *emission, const char *source); static void _signal_check_on(void *data, Evas_Object *obj, const char *emission, const char *source); static void _signal_check_toggle(void *data, Evas_Object *obj, const char *emission, const char *source); +static void _on_focus_hook(void *data, Evas_Object *obj); +static void _activate_hook(Evas_Object *obj); +static void _activate(Evas_Object *obj); static const char SIG_CHANGED[] = "changed"; static const Evas_Smart_Cb_Description _signals[] = { @@ -156,7 +159,19 @@ _signal_check_on(void *data, Evas_Object *obj __UNUSED__, const char *emission _ static void _signal_check_toggle(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) { - Widget_Data *wd = elm_widget_data_get(data); + _activate(data); +} + +static void +_activate_hook(Evas_Object *obj) +{ + _activate(obj); +} + +static void +_activate(Evas_Object *obj) +{ + Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; wd->state = !wd->state; if (wd->statep) *wd->statep = wd->state; @@ -164,7 +179,7 @@ _signal_check_toggle(void *data, Evas_Object *obj __UNUSED__, const char *emissi edje_object_signal_emit(wd->chk, "elm,state,check,on", "elm"); else edje_object_signal_emit(wd->chk, "elm,state,check,off", "elm"); - evas_object_smart_callback_call(data, SIG_CHANGED, NULL); + evas_object_smart_callback_call(obj, SIG_CHANGED, NULL); } /** @@ -192,6 +207,8 @@ elm_check_add(Evas_Object *parent) elm_widget_del_hook_set(obj, _del_hook); elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_disable_hook_set(obj, _disable_hook); + elm_widget_can_focus_set(obj, 1); + elm_widget_activate_hook_set(obj, _activate_hook); wd->chk = edje_object_add(e); _elm_theme_object_set(obj, wd->chk, "check", "base", "default"); diff --git a/src/lib/elm_radio.c b/src/lib/elm_radio.c index c5c878ca7..cfdf4fb0a 100644 --- a/src/lib/elm_radio.c +++ b/src/lib/elm_radio.c @@ -59,6 +59,9 @@ static void _sizing_eval(Evas_Object *obj); static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _sub_del(void *data, Evas_Object *obj, void *event_info); static void _signal_radio_on(void *data, Evas_Object *obj, const char *emission, const char *source); +static void _on_focus_hook(void *data, Evas_Object *obj); +static void _activate(Evas_Object *obj); +static void _activate_hook(Evas_Object *obj); static const char SIG_CHANGED[] = "changed"; static const Evas_Smart_Cb_Description _signals[] = { @@ -190,15 +193,27 @@ _state_set_all(Widget_Data *wd) } static void -_signal_radio_on(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) +_activate(Evas_Object *obj) { - Widget_Data *wd = elm_widget_data_get(data); + Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; if (wd->group->value == wd->value) return; wd->group->value = wd->value; if (wd->group->valuep) *(wd->group->valuep) = wd->group->value; _state_set_all(wd); - evas_object_smart_callback_call(data, SIG_CHANGED, NULL); + evas_object_smart_callback_call(obj, SIG_CHANGED, NULL); +} + +static void +_activate_hook(Evas_Object *obj) +{ + _activate(obj); +} + +static void +_signal_radio_on(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) +{ + _activate(data); } /** @@ -226,6 +241,8 @@ elm_radio_add(Evas_Object *parent) elm_widget_del_hook_set(obj, _del_hook); elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_disable_hook_set(obj, _disable_hook); + elm_widget_can_focus_set(obj, 1); + elm_widget_activate_hook_set(obj, _activate_hook); wd->radio = edje_object_add(e); _elm_theme_object_set(obj, wd->radio, "radio", "base", "default"); -- 2.34.1