2009-09-23 04:15:55 -07:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
|
|
|
|
2009-11-25 13:06:23 -08:00
|
|
|
|
2009-09-23 04:15:55 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Notify notify
|
|
|
|
*
|
|
|
|
* Display a window in a particular region of the application (top, bottom ...).
|
|
|
|
* A timeout can be set to automatically close the window.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct _Widget_Data Widget_Data;
|
|
|
|
|
|
|
|
struct _Widget_Data
|
|
|
|
{
|
2009-10-22 15:10:23 -07:00
|
|
|
Evas_Object *notify, *content, *parent;
|
2009-09-23 04:15:55 -07:00
|
|
|
|
|
|
|
Elm_Notify_Orient orient;
|
2009-10-22 15:10:23 -07:00
|
|
|
Eina_Bool repeat_events;
|
|
|
|
Evas_Object *block_events;
|
2009-09-23 04:15:55 -07:00
|
|
|
|
|
|
|
int timeout;
|
|
|
|
Ecore_Timer *timer;
|
|
|
|
};
|
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
static const char *widtype = NULL;
|
2009-09-23 04:15:55 -07:00
|
|
|
static void _del_hook(Evas_Object *obj);
|
|
|
|
static void _theme_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);
|
|
|
|
static void _sub_del(void *data, Evas_Object *obj, void *event_info);
|
2010-02-22 01:48:21 -08:00
|
|
|
static void _signal_block_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
|
2009-09-23 06:05:00 -07:00
|
|
|
static void _calc(Evas_Object *obj);
|
|
|
|
static void _content_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
2009-10-15 13:48:00 -07:00
|
|
|
static void _show(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
|
|
static void _hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
|
|
static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
|
|
|
2009-10-18 09:31:53 -07:00
|
|
|
static void
|
2009-10-15 13:48:00 -07:00
|
|
|
_del_pre_hook(Evas_Object *obj)
|
|
|
|
{
|
2009-10-22 15:10:23 -07:00
|
|
|
evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
|
|
|
|
evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE, _resize, obj);
|
|
|
|
evas_object_event_callback_del_full(obj, EVAS_CALLBACK_SHOW, _show, obj);
|
|
|
|
evas_object_event_callback_del_full(obj, EVAS_CALLBACK_HIDE, _hide, obj);
|
2009-10-15 13:48:00 -07:00
|
|
|
}
|
|
|
|
|
2009-09-27 20:23:54 -07:00
|
|
|
static void
|
2009-09-23 04:15:55 -07:00
|
|
|
_del_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2009-10-22 15:10:23 -07:00
|
|
|
elm_notify_parent_set(obj, NULL);
|
|
|
|
elm_notify_repeat_events_set(obj, EINA_TRUE);
|
|
|
|
if (wd->timer)
|
|
|
|
{
|
|
|
|
ecore_timer_del(wd->timer);
|
|
|
|
wd->timer = NULL;
|
|
|
|
}
|
2009-09-23 04:15:55 -07:00
|
|
|
free(wd);
|
|
|
|
}
|
|
|
|
|
2009-09-27 20:23:54 -07:00
|
|
|
static void
|
2009-09-23 04:15:55 -07:00
|
|
|
_theme_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-27 20:23:54 -07:00
|
|
|
if (!wd) return;
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->notify, "notify", "base", "default");
|
2009-11-14 17:52:53 -08:00
|
|
|
if (wd->block_events)
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->block_events, "notify", "block_events", "default");
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_scale_set(wd->notify, elm_widget_scale_get(obj) *
|
2009-09-27 20:23:54 -07:00
|
|
|
_elm_config->scale);
|
2009-09-23 04:15:55 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
2009-09-27 20:23:54 -07:00
|
|
|
static void
|
2009-09-23 04:15:55 -07:00
|
|
|
_sizing_eval(Evas_Object *obj)
|
|
|
|
{
|
2009-10-22 15:10:23 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Coord x,y,w,h;
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2009-11-09 04:50:16 -08:00
|
|
|
if (!wd->parent) return;
|
2009-10-22 15:10:23 -07:00
|
|
|
evas_object_geometry_get(wd->parent, &x, &y, &w, &h);
|
|
|
|
evas_object_move(obj, x, y);
|
2009-11-14 17:52:53 -08:00
|
|
|
evas_object_resize(obj, w, h);
|
2009-09-23 04:15:55 -07:00
|
|
|
}
|
|
|
|
|
2009-09-27 20:23:54 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2009-09-23 04:15:55 -07:00
|
|
|
{
|
2010-06-23 10:58:08 -07:00
|
|
|
_calc(data);
|
2009-09-23 04:15:55 -07:00
|
|
|
}
|
|
|
|
|
2009-09-27 20:23:54 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
|
2009-09-23 04:15:55 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-06-16 13:58:09 -07:00
|
|
|
Evas_Object *sub = event_info;
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2010-06-23 10:58:08 -07:00
|
|
|
|
2010-06-16 13:58:09 -07:00
|
|
|
if (sub == wd->content)
|
|
|
|
{
|
|
|
|
evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
|
|
|
evas_object_event_callback_del_full(sub, EVAS_CALLBACK_RESIZE,
|
|
|
|
_content_resize, obj);
|
|
|
|
wd->content = NULL;
|
|
|
|
}
|
2009-09-23 04:15:55 -07:00
|
|
|
}
|
|
|
|
|
2010-02-22 01:48:21 -08:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_block_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2010-02-22 01:48:21 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
if (!wd) return;
|
|
|
|
evas_object_smart_callback_call(data, "block,clicked", NULL);
|
|
|
|
}
|
|
|
|
|
2009-09-27 20:23:54 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_resize(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
|
2009-09-23 06:05:00 -07:00
|
|
|
{
|
|
|
|
_calc(obj);
|
|
|
|
}
|
|
|
|
|
2009-10-04 16:05:50 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_content_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2009-10-04 16:05:50 -07:00
|
|
|
{
|
|
|
|
_calc(data);
|
|
|
|
}
|
|
|
|
|
2009-10-22 15:10:23 -07:00
|
|
|
static void
|
2009-09-27 20:23:54 -07:00
|
|
|
_calc(Evas_Object *obj)
|
2009-09-23 04:15:55 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-10-20 14:35:57 -07:00
|
|
|
Evas_Coord minw = -1, minh = -1;
|
2009-09-27 20:23:54 -07:00
|
|
|
Evas_Coord x, y, w, h;
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2009-09-23 04:15:55 -07:00
|
|
|
evas_object_geometry_get(obj, &x, &y, &w, &h);
|
|
|
|
edje_object_size_min_calc(wd->notify, &minw, &minh);
|
2009-10-22 15:10:23 -07:00
|
|
|
|
2009-09-27 20:23:54 -07:00
|
|
|
if (wd->content)
|
2009-09-23 04:15:55 -07:00
|
|
|
{
|
2009-09-27 20:23:54 -07:00
|
|
|
int offx = (w - minw) / 2;
|
|
|
|
int offy = (h - minh) / 2;
|
2009-09-23 04:15:55 -07:00
|
|
|
|
2009-09-27 20:23:54 -07:00
|
|
|
switch (wd->orient)
|
2009-09-23 04:15:55 -07:00
|
|
|
{
|
|
|
|
case ELM_NOTIFY_ORIENT_TOP:
|
2009-10-04 16:05:50 -07:00
|
|
|
evas_object_move(wd->notify, x + offx, y);
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2010-01-18 22:57:25 -08:00
|
|
|
case ELM_NOTIFY_ORIENT_CENTER:
|
|
|
|
evas_object_move(wd->notify, x + offx, y + offy);
|
|
|
|
break;
|
2009-09-23 04:15:55 -07:00
|
|
|
case ELM_NOTIFY_ORIENT_BOTTOM:
|
2009-10-04 16:05:50 -07:00
|
|
|
evas_object_move(wd->notify, x + offx, y + h - minh);
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2009-09-23 04:15:55 -07:00
|
|
|
case ELM_NOTIFY_ORIENT_LEFT:
|
2009-10-04 16:05:50 -07:00
|
|
|
evas_object_move(wd->notify, x, y + offy);
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2009-09-23 06:05:00 -07:00
|
|
|
case ELM_NOTIFY_ORIENT_RIGHT:
|
2009-10-04 16:05:50 -07:00
|
|
|
evas_object_move(wd->notify, x + w - minw, y + offy);
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2009-09-23 04:15:55 -07:00
|
|
|
case ELM_NOTIFY_ORIENT_TOP_LEFT:
|
2009-10-04 16:05:50 -07:00
|
|
|
evas_object_move(wd->notify, x, y);
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2009-09-23 06:05:00 -07:00
|
|
|
case ELM_NOTIFY_ORIENT_TOP_RIGHT:
|
2009-10-04 16:05:50 -07:00
|
|
|
evas_object_move(wd->notify, x + w - minw, y);
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2009-09-23 06:05:00 -07:00
|
|
|
case ELM_NOTIFY_ORIENT_BOTTOM_LEFT:
|
2009-10-04 16:05:50 -07:00
|
|
|
evas_object_move(wd->notify, x, y + h - minh);
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2009-09-23 06:05:00 -07:00
|
|
|
case ELM_NOTIFY_ORIENT_BOTTOM_RIGHT:
|
2009-10-04 16:05:50 -07:00
|
|
|
evas_object_move(wd->notify, x + w - minw, y + h - minh);
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2009-09-23 04:15:55 -07:00
|
|
|
}
|
2009-09-27 20:23:54 -07:00
|
|
|
evas_object_resize(wd->notify, minw, minh);
|
2009-09-23 04:15:55 -07:00
|
|
|
}
|
2010-02-17 14:49:27 -08:00
|
|
|
_sizing_eval(obj);
|
2009-09-23 04:15:55 -07:00
|
|
|
}
|
|
|
|
|
2010-06-25 02:58:14 -07:00
|
|
|
static Eina_Bool
|
2009-09-23 04:15:55 -07:00
|
|
|
_timer_cb(void *data)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-06-25 02:58:14 -07:00
|
|
|
if (!wd) return ECORE_CALLBACK_CANCEL;
|
2009-09-23 04:15:55 -07:00
|
|
|
wd->timer = NULL;
|
|
|
|
evas_object_hide(obj);
|
2010-06-25 02:58:14 -07:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2009-09-23 04:15:55 -07:00
|
|
|
}
|
|
|
|
|
2009-09-27 20:23:54 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
|
2009-09-23 04:15:55 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2009-09-27 20:23:54 -07:00
|
|
|
evas_object_show(wd->notify);
|
2010-02-22 01:48:21 -08:00
|
|
|
if (!wd->repeat_events)
|
2009-10-22 15:10:23 -07:00
|
|
|
evas_object_show(wd->block_events);
|
2009-09-27 20:23:54 -07:00
|
|
|
if (wd->timer)
|
2009-09-23 04:15:55 -07:00
|
|
|
{
|
|
|
|
ecore_timer_del(wd->timer);
|
|
|
|
wd->timer = NULL;
|
|
|
|
}
|
2009-10-15 13:34:11 -07:00
|
|
|
if (wd->timeout > 0)
|
2009-09-23 04:15:55 -07:00
|
|
|
wd->timer = ecore_timer_add(wd->timeout, _timer_cb, obj);
|
|
|
|
}
|
|
|
|
|
2009-09-27 20:23:54 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_hide(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
|
2009-09-23 04:15:55 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2009-09-23 04:15:55 -07:00
|
|
|
evas_object_hide(wd->notify);
|
2010-02-22 01:48:21 -08:00
|
|
|
if (!wd->repeat_events)
|
2009-10-22 15:10:23 -07:00
|
|
|
evas_object_hide(wd->block_events);
|
2009-09-27 20:23:54 -07:00
|
|
|
if (wd->timer)
|
2009-09-23 04:15:55 -07:00
|
|
|
{
|
|
|
|
ecore_timer_del(wd->timer);
|
|
|
|
wd->timer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-22 15:10:23 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_parent_del(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
|
2009-10-22 15:10:23 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2009-10-22 15:10:23 -07:00
|
|
|
wd->parent = NULL;
|
|
|
|
evas_object_hide(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_parent_hide(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
|
2009-10-22 15:10:23 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2009-10-22 15:10:23 -07:00
|
|
|
wd->parent = NULL;
|
|
|
|
evas_object_hide(obj);
|
|
|
|
}
|
|
|
|
|
2009-09-23 04:15:55 -07:00
|
|
|
/**
|
|
|
|
* Add a new notify to the parent
|
|
|
|
*
|
|
|
|
* @param parent The parent object
|
|
|
|
* @return The new object or NULL if it cannot be created
|
|
|
|
*
|
|
|
|
* @ingroup Notify
|
|
|
|
*/
|
2009-09-27 20:23:54 -07:00
|
|
|
EAPI Evas_Object *
|
2009-09-23 04:15:55 -07:00
|
|
|
elm_notify_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
Evas *e;
|
|
|
|
Widget_Data *wd;
|
|
|
|
|
|
|
|
wd = ELM_NEW(Widget_Data);
|
|
|
|
e = evas_object_evas_get(parent);
|
|
|
|
obj = elm_widget_add(e);
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_SET_WIDTYPE(widtype, "notify");
|
2009-09-23 04:15:55 -07:00
|
|
|
elm_widget_type_set(obj, "notify");
|
|
|
|
elm_widget_sub_object_add(parent, obj);
|
|
|
|
elm_widget_data_set(obj, wd);
|
2009-10-15 13:48:00 -07:00
|
|
|
elm_widget_del_pre_hook_set(obj, _del_pre_hook);
|
2009-09-23 04:15:55 -07:00
|
|
|
elm_widget_del_hook_set(obj, _del_hook);
|
|
|
|
elm_widget_theme_hook_set(obj, _theme_hook);
|
|
|
|
|
2009-10-22 15:10:23 -07:00
|
|
|
wd->repeat_events = EINA_TRUE;
|
|
|
|
|
2009-09-23 04:15:55 -07:00
|
|
|
wd->notify = edje_object_add(e);
|
|
|
|
elm_notify_orient_set(obj, ELM_NOTIFY_ORIENT_TOP);
|
|
|
|
|
2009-11-01 11:05:00 -08:00
|
|
|
elm_notify_parent_set(obj, parent);
|
|
|
|
|
2009-09-23 04:15:55 -07:00
|
|
|
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
|
2009-10-04 16:05:50 -07:00
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _resize, obj);
|
2009-09-23 04:15:55 -07:00
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _show, obj);
|
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _hide, obj);
|
|
|
|
|
|
|
|
_sizing_eval(obj);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-06-16 13:58:09 -07:00
|
|
|
* Set the content of the notify widget
|
|
|
|
*
|
|
|
|
* Once the content object is set, a previously set one will be deleted.
|
|
|
|
* If you want to keep that old content object, use the
|
|
|
|
* elm_notify_content_unset() function.
|
2009-09-23 04:15:55 -07:00
|
|
|
*
|
|
|
|
* @param obj The notify object
|
|
|
|
* @param content The content will be filled in this notify object
|
|
|
|
*
|
|
|
|
* @ingroup Notify
|
|
|
|
*/
|
2009-09-27 20:23:54 -07:00
|
|
|
EAPI void
|
2009-09-23 04:15:55 -07:00
|
|
|
elm_notify_content_set(Evas_Object *obj, Evas_Object *content)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-09-23 04:15:55 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2010-06-16 13:58:09 -07:00
|
|
|
if (wd->content == content) return;
|
|
|
|
if (wd->content) evas_object_del(wd->content);
|
|
|
|
wd->content = content;
|
2010-06-23 10:58:08 -07:00
|
|
|
|
2009-09-23 04:15:55 -07:00
|
|
|
if (content)
|
|
|
|
{
|
2009-11-01 11:05:00 -08:00
|
|
|
elm_widget_sub_object_add(obj, content);
|
2010-06-16 13:58:09 -07:00
|
|
|
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
2009-11-09 04:50:16 -08:00
|
|
|
evas_object_event_callback_add(content, EVAS_CALLBACK_RESIZE,
|
2010-06-16 13:58:09 -07:00
|
|
|
_content_resize, obj);
|
2009-12-07 06:19:20 -08:00
|
|
|
edje_object_part_swallow(wd->notify, "elm.swallow.content", content);
|
2009-10-22 15:10:23 -07:00
|
|
|
}
|
2010-06-16 13:58:09 -07:00
|
|
|
_sizing_eval(obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
_calc(obj);
|
|
|
|
}
|
|
|
|
|
2010-06-16 13:58:09 -07:00
|
|
|
/**
|
|
|
|
* Unset the content of the notify widget
|
|
|
|
*
|
|
|
|
* Unparent and return the content object which was set for this widget
|
|
|
|
*
|
|
|
|
* @param obj The notify object
|
|
|
|
* @return The content that was being used
|
|
|
|
*
|
|
|
|
* @ingroup Notify
|
|
|
|
*/
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_notify_content_unset(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Object *content;
|
|
|
|
if (!wd) return NULL;
|
|
|
|
if (!wd->content) return NULL;
|
|
|
|
content = wd->content;
|
|
|
|
elm_widget_sub_object_del(obj, wd->content);
|
|
|
|
edje_object_part_unswallow(wd->notify, wd->content);
|
|
|
|
wd->content = NULL;
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
|
2009-10-22 15:10:23 -07:00
|
|
|
/**
|
2009-11-25 13:06:23 -08:00
|
|
|
* Set the notify parent
|
2009-10-22 15:10:23 -07:00
|
|
|
*
|
|
|
|
* @param obj The notify object
|
|
|
|
* @param content The new parent
|
|
|
|
*
|
|
|
|
* @ingroup Notify
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
elm_notify_parent_set(Evas_Object *obj, Evas_Object *parent)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-10-22 15:10:23 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
|
|
|
if (wd->parent)
|
2009-10-22 15:10:23 -07:00
|
|
|
{
|
|
|
|
evas_object_event_callback_del_full(wd->parent,
|
2009-11-09 04:50:16 -08:00
|
|
|
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
|
|
|
evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_RESIZE,
|
|
|
|
_changed_size_hints, obj);
|
|
|
|
evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_MOVE,
|
|
|
|
_changed_size_hints, obj);
|
|
|
|
evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_DEL,
|
|
|
|
_parent_del, obj);
|
|
|
|
evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_HIDE,
|
|
|
|
_parent_hide, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
wd->parent = NULL;
|
|
|
|
}
|
2010-03-09 16:31:54 -08:00
|
|
|
|
2009-10-22 15:10:23 -07:00
|
|
|
if (parent)
|
|
|
|
{
|
2009-11-01 11:05:00 -08:00
|
|
|
wd->parent = parent;
|
2009-10-22 15:10:23 -07:00
|
|
|
evas_object_event_callback_add(parent,
|
|
|
|
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
2009-11-09 04:50:16 -08:00
|
|
|
evas_object_event_callback_add(parent, EVAS_CALLBACK_RESIZE,
|
2009-10-22 15:10:23 -07:00
|
|
|
_changed_size_hints, obj);
|
2009-11-09 04:50:16 -08:00
|
|
|
evas_object_event_callback_add(parent, EVAS_CALLBACK_MOVE,
|
2009-10-22 15:10:23 -07:00
|
|
|
_changed_size_hints, obj);
|
2009-11-09 04:50:16 -08:00
|
|
|
evas_object_event_callback_add(parent, EVAS_CALLBACK_DEL,
|
2009-10-22 15:10:23 -07:00
|
|
|
_parent_del, obj);
|
2009-11-25 13:06:23 -08:00
|
|
|
evas_object_event_callback_add(parent, EVAS_CALLBACK_HIDE,
|
2009-10-22 15:10:23 -07:00
|
|
|
_parent_hide, obj);
|
2009-12-07 06:19:20 -08:00
|
|
|
edje_object_part_swallow(wd->notify, "elm.swallow.parent", parent);
|
2009-09-23 04:15:55 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
2009-09-23 06:05:00 -07:00
|
|
|
_calc(obj);
|
2009-09-23 04:15:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the orientation
|
|
|
|
*
|
|
|
|
* @param obj The notify object
|
|
|
|
* @param orient The new orientation
|
|
|
|
*/
|
2009-09-27 20:23:54 -07:00
|
|
|
EAPI void
|
2009-09-23 04:15:55 -07:00
|
|
|
elm_notify_orient_set(Evas_Object *obj, Elm_Notify_Orient orient)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-09-23 04:15:55 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2009-09-23 04:15:55 -07:00
|
|
|
wd->orient = orient;
|
2009-09-27 20:23:54 -07:00
|
|
|
switch (orient)
|
2009-09-23 04:15:55 -07:00
|
|
|
{
|
2010-03-09 16:31:54 -08:00
|
|
|
case ELM_NOTIFY_ORIENT_TOP:
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->notify, "notify", "base", "default");
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2010-03-09 16:31:54 -08:00
|
|
|
case ELM_NOTIFY_ORIENT_CENTER:
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->notify, "notify", "base", "center");
|
2010-02-17 14:49:27 -08:00
|
|
|
break;
|
2010-03-09 16:31:54 -08:00
|
|
|
case ELM_NOTIFY_ORIENT_BOTTOM:
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->notify, "notify", "base", "bottom");
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2010-03-09 16:31:54 -08:00
|
|
|
case ELM_NOTIFY_ORIENT_LEFT:
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->notify, "notify", "base", "left");
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2010-03-09 16:31:54 -08:00
|
|
|
case ELM_NOTIFY_ORIENT_RIGHT:
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->notify, "notify", "base", "right");
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2010-03-09 16:31:54 -08:00
|
|
|
case ELM_NOTIFY_ORIENT_TOP_LEFT:
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->notify, "notify", "base", "top_left");
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2010-03-09 16:31:54 -08:00
|
|
|
case ELM_NOTIFY_ORIENT_TOP_RIGHT:
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->notify, "notify", "base", "top_right");
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2010-03-09 16:31:54 -08:00
|
|
|
case ELM_NOTIFY_ORIENT_BOTTOM_LEFT:
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->notify, "notify", "base", "bottom_left");
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2010-03-09 16:31:54 -08:00
|
|
|
case ELM_NOTIFY_ORIENT_BOTTOM_RIGHT:
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->notify, "notify", "base", "bottom_right");
|
2009-09-27 20:23:54 -07:00
|
|
|
break;
|
2009-09-23 04:15:55 -07:00
|
|
|
}
|
|
|
|
_resize(obj, NULL, obj, NULL);
|
|
|
|
}
|
|
|
|
|
2010-07-11 14:19:27 -07:00
|
|
|
/**
|
|
|
|
* Return the orientation
|
|
|
|
* @param obj the notify objects
|
|
|
|
*/
|
|
|
|
EAPI Elm_Notify_Orient
|
|
|
|
elm_notify_orient_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
return wd->orient;
|
|
|
|
}
|
|
|
|
|
2009-09-23 04:15:55 -07:00
|
|
|
/**
|
|
|
|
* Set the time before the notify window is hidden. <br>
|
|
|
|
* Set a value < 0 to disable the timer
|
|
|
|
*
|
|
|
|
* @param obj The notify object
|
|
|
|
* @param time the new timeout
|
|
|
|
*/
|
2009-09-27 20:23:54 -07:00
|
|
|
EAPI void
|
2009-09-23 04:15:55 -07:00
|
|
|
elm_notify_timeout_set(Evas_Object *obj, int timeout)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-09-23 04:15:55 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2009-09-23 04:15:55 -07:00
|
|
|
wd->timeout = timeout;
|
2009-09-23 15:39:02 -07:00
|
|
|
elm_notify_timer_init(obj);
|
2009-09-23 04:15:55 -07:00
|
|
|
}
|
|
|
|
|
2010-07-11 14:19:27 -07:00
|
|
|
/**
|
|
|
|
* Return the timeout value (in seconds)
|
|
|
|
* @param obj the notify object
|
|
|
|
*/
|
|
|
|
EAPI int
|
|
|
|
elm_notify_timeout_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
return wd->timeout;
|
|
|
|
}
|
|
|
|
|
2009-09-23 06:05:00 -07:00
|
|
|
/**
|
|
|
|
* Re-init the timer
|
|
|
|
* @param obj The notify object
|
|
|
|
*/
|
2009-09-27 20:23:54 -07:00
|
|
|
EAPI void
|
2009-09-23 06:05:00 -07:00
|
|
|
elm_notify_timer_init(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-09-23 06:05:00 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2009-09-27 20:23:54 -07:00
|
|
|
if (wd->timer) ecore_timer_del(wd->timer);
|
2009-09-23 15:39:02 -07:00
|
|
|
wd->timer = NULL;
|
2009-10-15 13:34:11 -07:00
|
|
|
if (wd->timeout > 0)
|
2009-09-23 06:05:00 -07:00
|
|
|
wd->timer = ecore_timer_add(wd->timeout, _timer_cb, obj);
|
|
|
|
}
|
2009-10-04 16:05:50 -07:00
|
|
|
|
2009-10-22 15:10:23 -07:00
|
|
|
/**
|
2009-11-25 13:06:23 -08:00
|
|
|
* When true if the user clicks outside the window the events will be
|
2009-10-22 15:10:23 -07:00
|
|
|
* catch by the others widgets, else the events are block and the signal
|
|
|
|
* dismiss will be sent when the user click outside the window.
|
|
|
|
*
|
|
|
|
* @note The default value is EINA_TRUE.
|
|
|
|
*
|
|
|
|
* @param obj The notify object
|
2009-11-25 13:06:23 -08:00
|
|
|
* @param repeats EINA_TRUE Events are repeats, else no
|
2009-10-22 15:10:23 -07:00
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
elm_notify_repeat_events_set(Evas_Object *obj, Eina_Bool repeat)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-10-22 15:10:23 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2009-11-14 17:52:53 -08:00
|
|
|
if (repeat == wd->repeat_events) return;
|
2009-10-22 15:10:23 -07:00
|
|
|
wd->repeat_events = repeat;
|
2010-02-22 01:48:21 -08:00
|
|
|
if (!repeat)
|
2009-10-22 15:10:23 -07:00
|
|
|
{
|
|
|
|
wd->block_events = edje_object_add(evas_object_evas_get(obj));
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->block_events, "notify", "block_events", "default");
|
2009-11-25 13:06:23 -08:00
|
|
|
elm_widget_resize_object_set(obj, wd->block_events);
|
2010-02-22 01:48:21 -08:00
|
|
|
edje_object_signal_callback_add(wd->block_events, "elm,action,clicked", "elm", _signal_block_clicked, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
}
|
|
|
|
else
|
2009-11-09 04:50:16 -08:00
|
|
|
evas_object_del(wd->block_events);
|
2009-10-22 15:10:23 -07:00
|
|
|
}
|
|
|
|
|
2010-07-11 14:19:27 -07:00
|
|
|
/**
|
|
|
|
* Return true if events are repeat below the notify object
|
|
|
|
* @param obj the notify object
|
|
|
|
*/
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_notify_repeat_events_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
return wd->repeat_events;
|
|
|
|
}
|
|
|
|
|