Elm Notify timeout are double.

And only start timer when visible.
The previous code don't start the timer if timer was changed from
disabled to one valid value.

SVN revision: 52817
This commit is contained in:
Tiago Rezende Campos Falcao 2010-09-27 21:13:45 +00:00
parent 59e7d34f2c
commit d5b17baf0f
3 changed files with 34 additions and 26 deletions

View File

@ -20,6 +20,13 @@ _bt_close(void *data, Evas_Object *obj, void *event_info)
evas_object_hide(notify);
}
static void
_bt_timer_close(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *notify = data;
elm_notify_timeout_set(notify, 2.0);
}
static void
_notify_timeout(void *data, Evas_Object *obj, void *event_info)
{
@ -80,7 +87,7 @@ test_notify(void *data, Evas_Object *obj, void *event_info)
elm_notify_repeat_events_set(notify, EINA_FALSE);
evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);
elm_notify_timeout_set(notify, 5);
elm_notify_timeout_set(notify, 5.0);
evas_object_smart_callback_add(notify, "timeout", _notify_timeout, NULL);
evas_object_smart_callback_add(notify, "block,clicked", _notify_block, NULL);
@ -110,7 +117,7 @@ test_notify(void *data, Evas_Object *obj, void *event_info)
notify = elm_notify_add(win);
evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_LEFT);
elm_notify_timeout_set(notify, 10);
elm_notify_timeout_set(notify, 10.0);
evas_object_smart_callback_add(notify, "timeout", _notify_timeout, NULL);
bx = elm_box_add(win);
@ -139,6 +146,7 @@ test_notify(void *data, Evas_Object *obj, void *event_info)
evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_CENTER);
elm_notify_timeout_set(notify, 10);
elm_notify_timeout_set(notify, 10.0);
evas_object_smart_callback_add(notify, "timeout", _notify_timeout, NULL);
bx = elm_box_add(win);
@ -282,8 +290,8 @@ test_notify(void *data, Evas_Object *obj, void *event_info)
evas_object_show(lb);
bt = elm_button_add(win);
elm_button_label_set(bt, "Close");
evas_object_smart_callback_add(bt, "clicked", _bt_close, notify);
elm_button_label_set(bt, "Close in 2s");
evas_object_smart_callback_add(bt, "clicked", _bt_timer_close, notify);
elm_box_pack_end(bx, bt);
evas_object_show(bt);

View File

@ -761,8 +761,8 @@ extern "C" {
EAPI void elm_notify_parent_set(Evas_Object *obj, Evas_Object *parent);
EAPI void elm_notify_orient_set(Evas_Object *obj, Elm_Notify_Orient orient);
EAPI Elm_Notify_Orient elm_notify_orient_get(const Evas_Object *obj);
EAPI void elm_notify_timeout_set(Evas_Object *obj, int timeout);
EAPI int elm_notify_timeout_get(const Evas_Object *obj);
EAPI void elm_notify_timeout_set(Evas_Object *obj, double timeout);
EAPI double elm_notify_timeout_get(const Evas_Object *obj);
EAPI void elm_notify_timer_init(Evas_Object *obj);
EAPI void elm_notify_repeat_events_set(Evas_Object *obj, Eina_Bool repeat);
EAPI Eina_Bool elm_notify_repeat_events_get(const Evas_Object *obj);

View File

@ -20,7 +20,7 @@ struct _Widget_Data
Eina_Bool repeat_events;
Evas_Object *block_events;
int timeout;
double timeout;
Ecore_Timer *timer;
};
@ -250,6 +250,18 @@ _timer_cb(void *data)
return ECORE_CALLBACK_CANCEL;
}
static void
_timer_init(Evas_Object *obj, Widget_Data *wd)
{
if (wd->timer)
{
ecore_timer_del(wd->timer);
wd->timer = NULL;
}
if (evas_object_visible_get(obj) && (wd->timeout > 0.0))
wd->timer = ecore_timer_add(wd->timeout, _timer_cb, obj);
}
static void
_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
@ -258,13 +270,7 @@ _show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_i
evas_object_show(wd->notify);
if (!wd->repeat_events)
evas_object_show(wd->block_events);
if (wd->timer)
{
ecore_timer_del(wd->timer);
wd->timer = NULL;
}
if (wd->timeout > 0)
wd->timer = ecore_timer_add(wd->timeout, _timer_cb, obj);
_timer_init(obj, wd);
}
static void
@ -517,29 +523,26 @@ elm_notify_orient_get(const Evas_Object *obj)
*
*/
EAPI void
elm_notify_timeout_set(Evas_Object *obj, int timeout)
elm_notify_timeout_set(Evas_Object *obj, double timeout)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
wd->timeout = timeout;
_timer_init(obj, wd);
if (!wd->timer)
return;
elm_notify_timer_init(obj);
}
/**
* Return the timeout value (in seconds)
* @param obj the notify object
*/
EAPI int
EAPI double
elm_notify_timeout_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) -1;
ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return -1;
if (!wd) return 0.0;
return wd->timeout;
}
@ -553,10 +556,7 @@ elm_notify_timer_init(Evas_Object *obj)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (wd->timer) ecore_timer_del(wd->timer);
wd->timer = NULL;
if (wd->timeout > 0)
wd->timer = ecore_timer_add(wd->timeout, _timer_cb, obj);
_timer_init(obj, wd);
}
/**