Fix more nasty formatting.

Reduce repeated code.


SVN revision: 42753
This commit is contained in:
Christopher Michael 2009-09-28 03:23:54 +00:00
parent 9a25a4bb87
commit 803e07e83b
1 changed files with 82 additions and 81 deletions

View File

@ -13,12 +13,11 @@
*/
typedef struct _Widget_Data Widget_Data;
typedef struct _Subinfo Subinfo;
typedef struct _Subinfo Subinfo;
struct _Widget_Data
{
Evas_Object *notify;
Evas_Object *content;
Evas_Object *notify, *content;
Elm_Notify_Orient orient;
@ -34,24 +33,27 @@ static void _sub_del(void *data, Evas_Object *obj, void *event_info);
static void _calc(Evas_Object *obj);
static void _content_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void
static void
_del_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
free(wd);
}
static void
static void
_theme_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if(!wd) return;
if (!wd) return;
_elm_theme_set(wd->notify, "notify", "base", "default");
edje_object_scale_set(wd->notify, elm_widget_scale_get(obj) * _elm_config->scale);
edje_object_scale_set(wd->notify, elm_widget_scale_get(obj) *
_elm_config->scale);
_sizing_eval(obj);
}
static void
static void
_sizing_eval(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
@ -61,89 +63,85 @@ _sizing_eval(Evas_Object *obj)
//evas_object_size_hint_min_set(obj, minw, minh);
}
static void
static void
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
edje_object_part_swallow(wd->notify, "elm.swallow.content", obj);
_sizing_eval(data);
}
static void
static void
_sub_del(void *data, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *sub = event_info;
evas_object_event_callback_del
(wd->content, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints);
evas_object_event_callback_del(wd->content,
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints);
evas_object_del(wd->content);
if(wd->timer)
if (wd->timer)
{
ecore_timer_del(wd->timer);
wd->timer = NULL;
}
}
static void
static void
_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
_calc(obj);
}
static void _calc(Evas_Object *obj)
static void
_calc(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
Evas_Coord x,y,w,h;
Evas_Coord x, y, w, h;
evas_object_geometry_get(obj, &x, &y, &w, &h);
edje_object_size_min_calc(wd->notify, &minw, &minh);
if(wd->content)
if (wd->content)
{
int offx = (w - minw)/2;
int offy = (h - minh)/2;
int offx = (w - minw) / 2;
int offy = (h - minh) / 2;
switch(wd->orient)
switch (wd->orient)
{
case ELM_NOTIFY_ORIENT_TOP:
evas_object_move(wd->notify, x + offx, 0);
evas_object_resize(wd->notify, minw, minh);
break;
evas_object_move(wd->notify, x + offx, 0);
break;
case ELM_NOTIFY_ORIENT_BOTTOM:
evas_object_move(wd->notify, x + offx, h - minh);
evas_object_resize(wd->notify, minw, minh);
break;
evas_object_move(wd->notify, x + offx, h - minh);
break;
case ELM_NOTIFY_ORIENT_LEFT:
evas_object_move(wd->notify, 0, y+offy);
evas_object_resize(wd->notify, minw, minh);
break;
evas_object_move(wd->notify, 0, y + offy);
break;
case ELM_NOTIFY_ORIENT_RIGHT:
evas_object_move(wd->notify, w - minw, y+offy);
evas_object_resize(wd->notify, minw, minh);
break;
evas_object_move(wd->notify, w - minw, y + offy);
break;
case ELM_NOTIFY_ORIENT_TOP_LEFT:
evas_object_move(wd->notify, 0, 0);
evas_object_resize(wd->notify, minw, minh);
break;
evas_object_move(wd->notify, 0, 0);
break;
case ELM_NOTIFY_ORIENT_TOP_RIGHT:
evas_object_move(wd->notify, w-minw, 0);
evas_object_resize(wd->notify, minw, minh);
break;
evas_object_move(wd->notify, w - minw, 0);
break;
case ELM_NOTIFY_ORIENT_BOTTOM_LEFT:
evas_object_move(wd->notify, 0, h - minh);
evas_object_resize(wd->notify, minw, minh);
break;
evas_object_move(wd->notify, 0, h - minh);
break;
case ELM_NOTIFY_ORIENT_BOTTOM_RIGHT:
evas_object_move(wd->notify, w-minw, h-minh);
evas_object_resize(wd->notify, minw, minh);
break;
evas_object_move(wd->notify, w - minw, h - minh);
break;
}
evas_object_resize(wd->notify, minw, minh);
}
}
static int
static int
_timer_cb(void *data)
{
Evas_Object *obj = data;
@ -151,32 +149,32 @@ _timer_cb(void *data)
wd->timer = NULL;
evas_object_hide(obj);
return 0;
}
static void
static void
_show(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(obj);
evas_object_show(wd->notify);
if(wd->timer)
evas_object_show(wd->notify);
if (wd->timer)
{
ecore_timer_del(wd->timer);
wd->timer = NULL;
}
if(wd->timeout>0)
if (wd->timeout>0)
wd->timer = ecore_timer_add(wd->timeout, _timer_cb, obj);
}
static void
static void
_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(obj);
evas_object_hide(wd->notify);
if(wd->timer)
if (wd->timer)
{
ecore_timer_del(wd->timer);
wd->timer = NULL;
@ -191,7 +189,7 @@ _hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
*
* @ingroup Notify
*/
EAPI Evas_Object *
EAPI Evas_Object *
elm_notify_add(Evas_Object *parent)
{
Evas_Object *obj;
@ -227,21 +225,22 @@ elm_notify_add(Evas_Object *parent)
*
* @ingroup Notify
*/
EAPI void
EAPI void
elm_notify_content_set(Evas_Object *obj, Evas_Object *content)
{
Widget_Data *wd = elm_widget_data_get(obj);
Subinfo *si;
if(wd->content)
if (wd->content)
elm_widget_sub_object_del(obj, wd->content);
if (content)
{
elm_widget_sub_object_add(obj, content);
edje_object_part_swallow(wd->notify, "elm.swallow.content", content);
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
evas_object_event_callback_add(content,
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
wd->content = content;
_sizing_eval(obj);
}
@ -254,37 +253,38 @@ elm_notify_content_set(Evas_Object *obj, Evas_Object *content)
* @param obj The notify object
* @param orient The new orientation
*/
EAPI void
EAPI void
elm_notify_orient_set(Evas_Object *obj, Elm_Notify_Orient orient)
{
Widget_Data *wd = elm_widget_data_get(obj);
wd->orient = orient;
switch(orient)
switch (orient)
{
case ELM_NOTIFY_ORIENT_TOP:
_elm_theme_set(wd->notify, "notify", "base", "default");
break;
_elm_theme_set(wd->notify, "notify", "base", "default");
break;
case ELM_NOTIFY_ORIENT_BOTTOM:
_elm_theme_set(wd->notify, "notify", "base", "bottom");
break;
_elm_theme_set(wd->notify, "notify", "base", "bottom");
break;
case ELM_NOTIFY_ORIENT_LEFT:
_elm_theme_set(wd->notify, "notify", "base", "left");
break;
_elm_theme_set(wd->notify, "notify", "base", "left");
break;
case ELM_NOTIFY_ORIENT_RIGHT:
_elm_theme_set(wd->notify, "notify", "base", "right");
break;
_elm_theme_set(wd->notify, "notify", "base", "right");
break;
case ELM_NOTIFY_ORIENT_TOP_LEFT:
_elm_theme_set(wd->notify, "notify", "base", "top_left");
break;
_elm_theme_set(wd->notify, "notify", "base", "top_left");
break;
case ELM_NOTIFY_ORIENT_TOP_RIGHT:
_elm_theme_set(wd->notify, "notify", "base", "top_right");
break;
_elm_theme_set(wd->notify, "notify", "base", "top_right");
break;
case ELM_NOTIFY_ORIENT_BOTTOM_LEFT:
_elm_theme_set(wd->notify, "notify", "base", "bottom_left");
break;
_elm_theme_set(wd->notify, "notify", "base", "bottom_left");
break;
case ELM_NOTIFY_ORIENT_BOTTOM_RIGHT:
_elm_theme_set(wd->notify, "notify", "base", "bottom_right");
break;
_elm_theme_set(wd->notify, "notify", "base", "bottom_right");
break;
}
_resize(obj, NULL, obj, NULL);
@ -297,10 +297,11 @@ elm_notify_orient_set(Evas_Object *obj, Elm_Notify_Orient orient)
* @param obj The notify object
* @param time the new timeout
*/
EAPI void
EAPI void
elm_notify_timeout_set(Evas_Object *obj, int timeout)
{
Widget_Data *wd = elm_widget_data_get(obj);
wd->timeout = timeout;
elm_notify_timer_init(obj);
}
@ -309,13 +310,13 @@ elm_notify_timeout_set(Evas_Object *obj, int timeout)
* Re-init the timer
* @param obj The notify object
*/
EAPI void
EAPI void
elm_notify_timer_init(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if(wd->timer)
ecore_timer_del(wd->timer);
if (wd->timer) ecore_timer_del(wd->timer);
wd->timer = NULL;
if(wd->timeout>0)
if (wd->timeout>0)
wd->timer = ecore_timer_add(wd->timeout, _timer_cb, obj);
}