[elm] Account for elm_object_orient_set() deprecation

along elm files.

Spankies to Hermet for not doing it/delegating it before :)



SVN revision: 78948
This commit is contained in:
Gustavo Lima Chaves 2012-11-06 19:54:16 +00:00
parent 98e76632a7
commit 914d525282
9 changed files with 338 additions and 160 deletions

View File

@ -139,7 +139,7 @@ test_slideshow(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i
evas_object_smart_callback_add(slideshow, "transition,end", _slide_transition, slide_last_it);
notify = elm_notify_add(win);
elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);
elm_notify_align_set(notify, 0.5, 1.0);
evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, notify);
elm_notify_timeout_set(notify, 3.0);

View File

@ -59,7 +59,7 @@ test_video(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
evas_object_show(video);
notify = elm_notify_add(win);
elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);
elm_notify_align_set(notify, 0.5, 1.0);
elm_notify_timeout_set(notify, 3.0);
player = elm_player_add(win);

View File

@ -125,7 +125,7 @@ _alert_hook(void *data __UNUSED__, Evas_Object *obj, const char *message)
Evas_Object *popup, *label;
popup = elm_notify_add(obj);
elm_notify_orient_set(popup, ELM_NOTIFY_ORIENT_CENTER);
elm_notify_align_set(popup, 0.5, 0.5);
// Using the timeout doesn't seem to go well with the second main loop
//elm_notify_timeout_set(popup, 2.0);
elm_notify_allow_events_set(popup, EINA_FALSE);
@ -167,7 +167,7 @@ _confirm_hook(void *data __UNUSED__, Evas_Object *obj, const char *message, Eina
Evas_Object *popup, *box, *box2, *label, *btn_ok, *btn_cancel;
popup = elm_notify_add(obj);
elm_notify_orient_set(popup, ELM_NOTIFY_ORIENT_CENTER);
elm_notify_align_set(popup, 0.5, 0.5);
elm_notify_allow_events_set(popup, EINA_FALSE);
evas_object_show(popup);

View File

@ -1,40 +1,125 @@
#include "private.h"
#include <assert.h>
typedef struct _Elm_Params_Notify Elm_Params_Notify;
struct _Elm_Params_Notify {
Elm_Params base;
Evas_Object *content; /* part name whose obj is to be set as content */
Eina_Bool allow_events_exists;
Eina_Bool allow_events;
Eina_Bool timeout_exists;
double timeout;
struct _Elm_Params_Notify
{
Elm_Params base;
Evas_Object *content; /* part name whose obj is to be set as content */
Eina_Bool allow_events_exists;
Eina_Bool allow_events;
Eina_Bool timeout_exists;
double timeout;
const char *orient;
const char *orient;
};
static const char *orients[] = {
"top",
"center",
"bottom",
"left",
"right",
"top_left",
"top_right",
"bottom_left",
"bottom_right",
NULL
"top",
"center",
"bottom",
"left",
"right",
"top_left",
"top_right",
"bottom_left",
"bottom_right",
NULL
};
static Elm_Notify_Orient _orient_get(const char *orient)
/* keeping old externals orient api for notify, but taking away the
* introduced deprecation warning by copying the deprecated code
* here */
static Elm_Notify_Orient
_elm_notify_orient_get(const Evas_Object *obj)
{
Elm_Notify_Orient orient;
double horizontal, vertical;
elm_notify_align_get(obj, &horizontal, &vertical);
if ((horizontal == 0.5) && (vertical == 0.0))
orient = ELM_NOTIFY_ORIENT_TOP;
else if ((horizontal == 0.5) && (vertical == 0.5))
orient = ELM_NOTIFY_ORIENT_CENTER;
else if ((horizontal == 0.5) && (vertical == 1.0))
orient = ELM_NOTIFY_ORIENT_BOTTOM;
else if ((horizontal == 0.0) && (vertical == 0.5))
orient = ELM_NOTIFY_ORIENT_LEFT;
else if ((horizontal == 1.0) && (vertical == 0.5))
orient = ELM_NOTIFY_ORIENT_RIGHT;
else if ((horizontal == 0.0) && (vertical == 0.0))
orient = ELM_NOTIFY_ORIENT_TOP_LEFT;
else if ((horizontal == 1.0) && (vertical == 0.0))
orient = ELM_NOTIFY_ORIENT_TOP_RIGHT;
else if ((horizontal == 0.0) && (vertical == 1.0))
orient = ELM_NOTIFY_ORIENT_BOTTOM_LEFT;
else if ((horizontal == 1.0) && (vertical == 1.0))
orient = ELM_NOTIFY_ORIENT_BOTTOM_RIGHT;
else
orient = ELM_NOTIFY_ORIENT_TOP;
return orient;
}
static void
_elm_notify_orient_set(Evas_Object *obj,
Elm_Notify_Orient orient)
{
double horizontal = 0, vertical = 0;
switch (orient)
{
case ELM_NOTIFY_ORIENT_TOP:
horizontal = 0.5; vertical = 0.0;
break;
case ELM_NOTIFY_ORIENT_CENTER:
horizontal = 0.5; vertical = 0.5;
break;
case ELM_NOTIFY_ORIENT_BOTTOM:
horizontal = 0.5; vertical = 1.0;
break;
case ELM_NOTIFY_ORIENT_LEFT:
horizontal = 0.0; vertical = 0.5;
break;
case ELM_NOTIFY_ORIENT_RIGHT:
horizontal = 1.0; vertical = 0.5;
break;
case ELM_NOTIFY_ORIENT_TOP_LEFT:
horizontal = 0.0; vertical = 0.0;
break;
case ELM_NOTIFY_ORIENT_TOP_RIGHT:
horizontal = 1.0; vertical = 0.0;
break;
case ELM_NOTIFY_ORIENT_BOTTOM_LEFT:
horizontal = 0.0; vertical = 1.0;
break;
case ELM_NOTIFY_ORIENT_BOTTOM_RIGHT:
horizontal = 1.0; vertical = 1.0;
break;
case ELM_NOTIFY_ORIENT_LAST:
break;
}
elm_notify_align_set(obj, horizontal, vertical);
}
static Elm_Notify_Orient
_orient_get(const char *orient)
{
unsigned int i;
assert(sizeof(orients)/sizeof(orients[0]) ==
ELM_NOTIFY_ORIENT_LAST + 1);
assert(sizeof(orients) / sizeof(orients[0]) ==
ELM_NOTIFY_ORIENT_LAST + 1);
for (i = 0; i < ELM_NOTIFY_ORIENT_LAST; i++)
if (!strcmp(orient, orients[i])) return i;
@ -42,158 +127,166 @@ static Elm_Notify_Orient _orient_get(const char *orient)
return ELM_NOTIFY_ORIENT_LAST;
}
static void external_notify_state_set(void *data __UNUSED__,
Evas_Object *obj, const void *from_params,
const void *to_params, float pos __UNUSED__)
static void
external_notify_state_set(void *data __UNUSED__,
Evas_Object *obj, const void *from_params,
const void *to_params, float pos __UNUSED__)
{
const Elm_Params_Notify *p;
const Elm_Params_Notify *p;
if (to_params) p = to_params;
else if (from_params) p = from_params;
else return;
if (to_params) p = to_params;
else if (from_params)
p = from_params;
else return;
if (p->content) {
elm_object_content_set(obj, p->content);
}
if (p->allow_events_exists)
elm_notify_allow_events_set(obj, p->allow_events);
if (p->timeout_exists)
elm_notify_timeout_set(obj, p->timeout);
if (p->orient)
{
Elm_Notify_Orient set = _orient_get(p->orient);
if (set == ELM_NOTIFY_ORIENT_LAST) return;
elm_notify_orient_set(obj, set);
}
if (p->content)
{
elm_object_content_set(obj, p->content);
}
if (p->allow_events_exists)
elm_notify_allow_events_set(obj, p->allow_events);
if (p->timeout_exists)
elm_notify_timeout_set(obj, p->timeout);
if (p->orient)
{
Elm_Notify_Orient set = _orient_get(p->orient);
if (set == ELM_NOTIFY_ORIENT_LAST) return;
_elm_notify_orient_set(obj, set);
}
}
static Eina_Bool external_notify_param_set(void *data __UNUSED__,
Evas_Object *obj, const Edje_External_Param *param)
static Eina_Bool
external_notify_param_set(void *data __UNUSED__,
Evas_Object *obj, const Edje_External_Param *param)
{
if ((!strcmp(param->name, "content"))
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING))
{
Evas_Object *content = external_common_param_edje_object_get(obj, param);
if ((strcmp(param->s, "")) && (!content))
return EINA_FALSE;
elm_object_content_set(obj, content);
return EINA_TRUE;
}
else if ((!strcmp(param->name, "allow_events"))
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
{
elm_notify_allow_events_set(obj, param->i);
return EINA_TRUE;
}
else if ((!strcmp(param->name, "timeout"))
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE))
{
elm_notify_timeout_set(obj, param->d);
return EINA_TRUE;
}
else if ((!strcmp(param->name, "orient"))
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE))
{
Elm_Notify_Orient set = _orient_get(param->s);
if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE;
elm_notify_orient_set(obj, set);
return EINA_TRUE;
}
if ((!strcmp(param->name, "content"))
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING))
{
Evas_Object *content =
external_common_param_edje_object_get(obj, param);
if ((strcmp(param->s, "")) && (!content))
return EINA_FALSE;
elm_object_content_set(obj, content);
return EINA_TRUE;
}
else if ((!strcmp(param->name, "allow_events"))
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
{
elm_notify_allow_events_set(obj, param->i);
return EINA_TRUE;
}
else if ((!strcmp(param->name, "timeout"))
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE))
{
elm_notify_timeout_set(obj, param->d);
return EINA_TRUE;
}
else if ((!strcmp(param->name, "orient"))
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE))
{
Elm_Notify_Orient set = _orient_get(param->s);
if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE;
_elm_notify_orient_set(obj, set);
return EINA_TRUE;
}
ERR("unknown parameter '%s' of type '%s'",
param->name, edje_external_param_type_str(param->type));
ERR("unknown parameter '%s' of type '%s'",
param->name, edje_external_param_type_str(param->type));
return EINA_FALSE;
return EINA_FALSE;
}
static Eina_Bool external_notify_param_get(void *data __UNUSED__,
const Evas_Object *obj, Edje_External_Param *param)
static Eina_Bool
external_notify_param_get(void *data __UNUSED__,
const Evas_Object *obj, Edje_External_Param *param)
{
if (!strcmp(param->name, "content"))
{
/* not easy to get content name back from live object */
return EINA_FALSE;
}
else if ((!strcmp(param->name, "allow_events"))
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
{
param->i = elm_notify_allow_events_get(obj);
return EINA_TRUE;
}
else if ((!strcmp(param->name, "timeout"))
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE))
{
param->d = elm_notify_timeout_get(obj);
return EINA_TRUE;
}
else if ((!strcmp(param->name, "orient"))
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE))
{
Elm_Notify_Orient set = elm_notify_orient_get(obj);
if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE;
param->s = orients[set];
return EINA_TRUE;
}
if (!strcmp(param->name, "content"))
{
/* not easy to get content name back from live object */
return EINA_FALSE;
}
else if ((!strcmp(param->name, "allow_events"))
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
{
param->i = elm_notify_allow_events_get(obj);
return EINA_TRUE;
}
else if ((!strcmp(param->name, "timeout"))
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE))
{
param->d = elm_notify_timeout_get(obj);
return EINA_TRUE;
}
else if ((!strcmp(param->name, "orient"))
&& (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE))
{
Elm_Notify_Orient set = _elm_notify_orient_get(obj);
if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE;
param->s = orients[set];
return EINA_TRUE;
}
ERR("unknown parameter '%s' of type '%s'",
param->name, edje_external_param_type_str(param->type));
ERR("unknown parameter '%s' of type '%s'",
param->name, edje_external_param_type_str(param->type));
return EINA_FALSE;
return EINA_FALSE;
}
static void * external_notify_params_parse(void *data __UNUSED__, Evas_Object *obj,
const Eina_List *params) {
Elm_Params_Notify *mem;
Edje_External_Param *param;
const Eina_List *l;
static void *
external_notify_params_parse(void *data __UNUSED__, Evas_Object *obj,
const Eina_List *params) {
Elm_Params_Notify *mem;
Edje_External_Param *param;
const Eina_List *l;
mem = calloc(1, sizeof(Elm_Params_Notify));
if (!mem)
return NULL;
mem = calloc(1, sizeof(Elm_Params_Notify));
if (!mem)
return NULL;
EINA_LIST_FOREACH(params, l, param)
{
if (!strcmp(param->name, "content"))
mem->content = external_common_param_edje_object_get(obj, param);
else if (!strcmp(param->name, "timeout"))
{
mem->timeout = param->d;
mem->timeout_exists = EINA_TRUE;
}
else if (!strcmp(param->name, "allow_events"))
{
mem->allow_events = param->i;
mem->allow_events_exists = EINA_TRUE;
}
else if (!strcmp(param->name, "orient"))
mem->orient = eina_stringshare_add(param->s);
}
EINA_LIST_FOREACH(params, l, param)
{
if (!strcmp(param->name, "content"))
mem->content = external_common_param_edje_object_get(obj, param);
else if (!strcmp(param->name, "timeout"))
{
mem->timeout = param->d;
mem->timeout_exists = EINA_TRUE;
}
else if (!strcmp(param->name, "allow_events"))
{
mem->allow_events = param->i;
mem->allow_events_exists = EINA_TRUE;
}
else if (!strcmp(param->name, "orient"))
mem->orient = eina_stringshare_add(param->s);
}
return mem;
return mem;
}
static Evas_Object *external_notify_content_get(void *data __UNUSED__,
const Evas_Object *obj, const char *content)
static Evas_Object *
external_notify_content_get(void *data __UNUSED__,
const Evas_Object *obj, const char *content)
{
if (!strcmp(content, "content"))
return elm_object_content_get(obj);
if (!strcmp(content, "content"))
return elm_object_content_get(obj);
ERR("unknown content '%s'", content);
return NULL;
ERR("unknown content '%s'", content);
return NULL;
}
static void external_notify_params_free(void *params) {
free(params);
static void
external_notify_params_free(void *params) {
free(params);
}
static Edje_External_Param_Info external_notify_params[] = {
DEFINE_EXTERNAL_COMMON_PARAMS,
EDJE_EXTERNAL_PARAM_INFO_STRING("content"),
EDJE_EXTERNAL_PARAM_INFO_BOOL("allow_events"),
EDJE_EXTERNAL_PARAM_INFO_DOUBLE("timeout"),
EDJE_EXTERNAL_PARAM_INFO_SENTINEL
DEFINE_EXTERNAL_COMMON_PARAMS,
EDJE_EXTERNAL_PARAM_INFO_STRING("content"),
EDJE_EXTERNAL_PARAM_INFO_BOOL("allow_events"),
EDJE_EXTERNAL_PARAM_INFO_DOUBLE("timeout"),
EDJE_EXTERNAL_PARAM_INFO_SENTINEL
};
DEFINE_EXTERNAL_ICON_ADD(notify, "notify");
DEFINE_EXTERNAL_TYPE_SIMPLE(notify, "Notify")
;
DEFINE_EXTERNAL_TYPE_SIMPLE(notify, "Notify");

View File

@ -38,7 +38,7 @@ elm_main(int argc, char **argv)
evas_object_show(content);
notify = elm_notify_add(win);
elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);
elm_notify_align_set(notify, 0.5, 1.0);
elm_object_content_set(notify, content);
evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(notify);
@ -49,7 +49,7 @@ elm_main(int argc, char **argv)
evas_object_show(content);
notify = elm_notify_add(win);
elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_CENTER);
elm_notify_align_set(notify, 0.5, 0,5);
elm_object_content_set(notify, content);
evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(notify);

View File

@ -227,7 +227,7 @@ elm_main(int argc,
(const char *)elm_object_item_data_get(slide_it));
notify = elm_notify_add(win);
elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);
elm_notify_align_set(notify, 0.5, 1.0);
evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, notify);
elm_notify_timeout_set(notify, 3.0);

View File

@ -108,7 +108,7 @@ _main_win_del_cb(void *data, Evas_Object *obj, void *event)
Evas_Object *msg, *box, *box2, *btn, *lbl, *sep;
msg = elm_notify_add(obj);
elm_notify_orient_set(msg, ELM_NOTIFY_ORIENT_CENTER);
elm_notify_align_set(msg, 0.5, 0.5);
elm_notify_allow_events_set(msg, EINA_FALSE);
evas_object_show(msg);

View File

@ -1236,7 +1236,7 @@ _elm_popup_smart_add(Evas_Object *obj)
(ELM_WIDGET_DATA(priv)->resize_obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
priv->notify = elm_notify_add(obj);
elm_notify_orient_set(priv->notify, ELM_NOTIFY_ORIENT_CENTER);
elm_notify_align_set(priv->notify, 0.5, 0.5);
elm_notify_allow_events_set(priv->notify, EINA_FALSE);
evas_object_size_hint_weight_set
(priv->notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@ -1374,6 +1374,91 @@ elm_popup_content_text_wrap_type_get(const Evas_Object *obj)
return sd->content_text_wrap_type;
}
/* keeping old externals orient api for notify, but taking away the
* introduced deprecation warning by copying the deprecated code
* here */
static Elm_Notify_Orient
_elm_notify_orient_get(const Evas_Object *obj)
{
Elm_Notify_Orient orient;
double horizontal, vertical;
elm_notify_align_get(obj, &horizontal, &vertical);
if ((horizontal == 0.5) && (vertical == 0.0))
orient = ELM_NOTIFY_ORIENT_TOP;
else if ((horizontal == 0.5) && (vertical == 0.5))
orient = ELM_NOTIFY_ORIENT_CENTER;
else if ((horizontal == 0.5) && (vertical == 1.0))
orient = ELM_NOTIFY_ORIENT_BOTTOM;
else if ((horizontal == 0.0) && (vertical == 0.5))
orient = ELM_NOTIFY_ORIENT_LEFT;
else if ((horizontal == 1.0) && (vertical == 0.5))
orient = ELM_NOTIFY_ORIENT_RIGHT;
else if ((horizontal == 0.0) && (vertical == 0.0))
orient = ELM_NOTIFY_ORIENT_TOP_LEFT;
else if ((horizontal == 1.0) && (vertical == 0.0))
orient = ELM_NOTIFY_ORIENT_TOP_RIGHT;
else if ((horizontal == 0.0) && (vertical == 1.0))
orient = ELM_NOTIFY_ORIENT_BOTTOM_LEFT;
else if ((horizontal == 1.0) && (vertical == 1.0))
orient = ELM_NOTIFY_ORIENT_BOTTOM_RIGHT;
else
orient = ELM_NOTIFY_ORIENT_TOP;
return orient;
}
static void
_elm_notify_orient_set(Evas_Object *obj,
Elm_Notify_Orient orient)
{
double horizontal = 0, vertical = 0;
switch (orient)
{
case ELM_NOTIFY_ORIENT_TOP:
horizontal = 0.5; vertical = 0.0;
break;
case ELM_NOTIFY_ORIENT_CENTER:
horizontal = 0.5; vertical = 0.5;
break;
case ELM_NOTIFY_ORIENT_BOTTOM:
horizontal = 0.5; vertical = 1.0;
break;
case ELM_NOTIFY_ORIENT_LEFT:
horizontal = 0.0; vertical = 0.5;
break;
case ELM_NOTIFY_ORIENT_RIGHT:
horizontal = 1.0; vertical = 0.5;
break;
case ELM_NOTIFY_ORIENT_TOP_LEFT:
horizontal = 0.0; vertical = 0.0;
break;
case ELM_NOTIFY_ORIENT_TOP_RIGHT:
horizontal = 1.0; vertical = 0.0;
break;
case ELM_NOTIFY_ORIENT_BOTTOM_LEFT:
horizontal = 0.0; vertical = 1.0;
break;
case ELM_NOTIFY_ORIENT_BOTTOM_RIGHT:
horizontal = 1.0; vertical = 1.0;
break;
case ELM_NOTIFY_ORIENT_LAST:
break;
}
elm_notify_align_set(obj, horizontal, vertical);
}
EAPI void
elm_popup_orient_set(Evas_Object *obj,
Elm_Popup_Orient orient)
@ -1382,7 +1467,7 @@ elm_popup_orient_set(Evas_Object *obj,
ELM_POPUP_DATA_GET(obj, sd);
if (orient >= ELM_POPUP_ORIENT_LAST) return;
elm_notify_orient_set(sd->notify, (Elm_Notify_Orient)orient);
_elm_notify_orient_set(sd->notify, (Elm_Notify_Orient)orient);
}
EAPI Elm_Popup_Orient
@ -1391,7 +1476,7 @@ elm_popup_orient_get(const Evas_Object *obj)
ELM_POPUP_CHECK(obj) - 1;
ELM_POPUP_DATA_GET(obj, sd);
return (Elm_Popup_Orient)elm_notify_orient_get(sd->notify);
return (Elm_Popup_Orient)_elm_notify_orient_get(sd->notify);
}
EAPI void

View File

@ -973,7 +973,7 @@ _ewk_view_popup_create_cb(void *data,
notify = elm_notify_add(obj);
elm_notify_allow_events_set(notify, EINA_FALSE);
elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);
elm_notify_align_set(notify, 0.5, 1.0);
list = elm_list_add(obj);
elm_list_select_mode_set(data, ELM_OBJECT_SELECT_MODE_ALWAYS);