Move eina list iterations to EINA_LIST_FOREACH variants.

By using these macros we can avoid errors and if we need to change
things, we do just in the macro definitions.



SVN revision: 39216
This commit is contained in:
Gustavo Sverzut Barbieri 2009-02-25 19:50:45 +00:00
parent 47c6288efc
commit d1d91b99df
15 changed files with 316 additions and 309 deletions

View File

@ -2,7 +2,6 @@
#include "elm_priv.h"
typedef struct _Widget_Data Widget_Data;
typedef struct _Item Item;
struct _Widget_Data
{
@ -11,7 +10,7 @@ struct _Widget_Data
Eina_List *items;
};
struct _Item
struct _Elm_Hoversel_Item
{
Evas_Object *obj;
const char *label;
@ -71,7 +70,7 @@ _hover_clicked(void *data, Evas_Object *obj, void *event_info)
static void
_item_clicked(void *data, Evas_Object *obj, void *event_info)
{
Item *it = data;
Elm_Hoversel_Item *it = data;
Evas_Object *obj2 = it->obj;
elm_hoversel_hover_end(obj2);
if (it->func) it->func(it->data, obj2, it);
@ -84,7 +83,9 @@ _button_clicked(void *data, Evas_Object *obj, void *event_info)
Widget_Data *wd = elm_widget_data_get(data);
if (!wd) return;
Evas_Object *bt, *bx, *ic;
Eina_List *l;
const Eina_List *l;
const Elm_Hoversel_Item *it;
wd->hover = elm_hover_add(data);
elm_hover_style_set(wd->hover, "hoversel_vertical");
evas_object_smart_callback_add(wd->hover, "clicked", _hover_clicked, data);
@ -93,10 +94,9 @@ _button_clicked(void *data, Evas_Object *obj, void *event_info)
bx = elm_box_add(wd->hover);
elm_box_homogenous_set(bx, 1);
for (l = wd->items; l; l = l->next)
EINA_LIST_FOREACH(wd->items, l, it)
{
Item *it = l->data;
bt = elm_button_add(wd->hover);
elm_button_style_set(bt, "hoversel_vertical_entry");
elm_button_label_set(bt, it->label);
@ -203,7 +203,7 @@ elm_hoversel_item_add(Evas_Object *obj, const char *label, const char *icon_file
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
Item *it = calloc(1, sizeof(Item));
Elm_Hoversel_Item *it = calloc(1, sizeof(Elm_Hoversel_Item));
if (!it) return NULL;
wd->items = eina_list_append(wd->items, it);
it->obj = obj;
@ -212,13 +212,12 @@ elm_hoversel_item_add(Evas_Object *obj, const char *label, const char *icon_file
it->icon_type = icon_type;
it->func = func;
it->data = (void *)data;
return (Elm_Hoversel_Item *)it;
return it;
}
EAPI void
elm_hoversel_item_del(Elm_Hoversel_Item *item)
elm_hoversel_item_del(Elm_Hoversel_Item *it)
{
Item *it = (Item *)item;
Widget_Data *wd = elm_widget_data_get(it->obj);
if (!wd) return;
elm_hoversel_hover_end(it->obj);

View File

@ -44,11 +44,10 @@ _item_select(Elm_Carousel_Item *it)
Elm_Carousel_Item *it2;
Widget_Data *wd = elm_widget_data_get(it->obj);
Evas_Object *obj2;
Eina_List *l;
const Eina_List *l;
if (it->selected) return;
for (l = wd->items; l; l = l->next)
EINA_LIST_FOREACH(wd->items, l, it2)
{
it2 = l->data;
if (it2->selected)
{
it2->selected = 0;
@ -75,12 +74,11 @@ static void
_theme_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Eina_List *l;
Elm_Carousel_Item *it;
const Eina_List *l;
const Elm_Carousel_Item *it;
Evas_Coord mw, mh;
for (l = wd->items; l; l = l->next)
EINA_LIST_FOREACH(wd->items, l, it)
{
it = l->data;
if (it->selected)
edje_object_signal_emit(it->base, "elm,state,selected", "elm");
_elm_theme_set(it->base, "carousel", "item", "default");
@ -123,7 +121,7 @@ _resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
Evas_Coord mw, mh, vw, vh, w, h;
Eina_List *l;
const Eina_List *l;
Elm_Carousel_Item *it;
elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
@ -133,9 +131,8 @@ _resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
if (w != vw) evas_object_resize(wd->bx, vw, h);
}
for (l = wd->items; l; l = l->next)
EINA_LIST_FOREACH(wd->items, l, it)
{
it = l->data;
if (it->selected)
{
_item_show(it);

View File

@ -356,10 +356,11 @@ static void
_signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Widget_Data *wd = elm_widget_data_get(data);
Eina_List *l;
for (l = entries; l; l = l->next)
const Eina_List *l;
Evas_Object *entry;
EINA_LIST_FOREACH(entries, l, entry)
{
if (l->data != data) elm_entry_select_none(l->data);
if (entry != data) elm_entry_select_none(entry);
}
wd->have_selection = 1;
evas_object_smart_callback_call(data, "selection,start", NULL);
@ -712,10 +713,11 @@ elm_entry_entry_set(Evas_Object *obj, const char *entry)
// debug
#if 0
{
Eina_List *l, *an;
const Eina_List *l, *an;
const char *anchor;
an = edje_object_part_text_anchor_list_get(wd->ent, "elm.text");
for (l = an; l; l = l->next)
printf("ANCHOR: %s\n", l->data);
EINA_LIST_FOREACH(an, l, anchor)
printf("ANCHOR: %s\n", anchor);
}
#endif
wd->changed = 1;

View File

@ -279,13 +279,20 @@ _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
}
else
{
for (l = it->wd->selected; l;)
{
Elm_Genlist_Item *it2 = l->data;
l = l->next;
if ((it2 != it) && (it2->selected)) _item_unselect(it2);
if (!it->selected)
{
Widget_Data *wd = it->wd;
while (wd->selected)
_item_unselect(wd->selected->data);
_item_select(it);
}
else
{
const Eina_List *l, *l_next;
Elm_Genlist_Item *it2;
EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
if (it2 != it) _item_unselect(it2);
}
if (!it->selected) _item_select(it);
}
}
@ -326,12 +333,12 @@ _item_realize(Elm_Genlist_Item *it, int in, int calc)
if (it->itc->func.label_get)
{
Eina_List *l;
const Eina_List *l;
const char *key;
it->labels = _stringlist_get(edje_object_data_get(it->base, "labels"));
for (l = it->labels; l; l = l->next)
EINA_LIST_FOREACH(it->labels, l, key)
{
const char *key = l->data;
char *s = it->itc->func.label_get(it->data, it->wd->obj, l->data);
if (s)
{
@ -342,12 +349,12 @@ _item_realize(Elm_Genlist_Item *it, int in, int calc)
}
if (it->itc->func.icon_get)
{
Eina_List *l;
const Eina_List *l;
const char *key;
it->icons = _stringlist_get(edje_object_data_get(it->base, "icons"));
for (l = it->icons; l; l = l->next)
EINA_LIST_FOREACH(it->icons, l, key)
{
const char *key = l->data;
Evas_Object *ic = it->itc->func.icon_get(it->data, it->wd->obj, l->data);
if (ic)
{
@ -360,12 +367,12 @@ _item_realize(Elm_Genlist_Item *it, int in, int calc)
}
if (it->itc->func.state_get)
{
Eina_List *l;
const Eina_List *l;
const char *key;
it->states = _stringlist_get(edje_object_data_get(it->base, "states"));
for (l = it->states; l; l = l->next)
EINA_LIST_FOREACH(it->states, l, key)
{
const char *key = l->data;
Evas_Bool on = it->itc->func.state_get(it->data, it->wd->obj, l->data);
if (on)
{
@ -411,14 +418,14 @@ _item_unrealize(Elm_Genlist_Item *it)
static int
_item_block_recalc(Item_Block *itb, int in)
{
Eina_List *l;
const Eina_List *l;
Elm_Genlist_Item *it;
Evas_Coord minw = 0, minh = 0;
int showme = 0;
Evas_Coord y = 0;
for (l = itb->items; l; l = l->next)
EINA_LIST_FOREACH(itb->items, l, it)
{
Elm_Genlist_Item *it = l->data;
if (it->delete_me) continue;
showme |= it->showme;
if (!itb->realized)
@ -446,11 +453,11 @@ _item_block_recalc(Item_Block *itb, int in)
static void
_item_block_realize(Item_Block *itb, int in)
{
Eina_List *l;
const Eina_List *l;
Elm_Genlist_Item *it;
if (itb->realized) return;
for (l = itb->items; l; l = l->next)
EINA_LIST_FOREACH(itb->items, l, it)
{
Elm_Genlist_Item *it = l->data;
if (it->delete_me) continue;
_item_realize(it, in, 0);
in++;
@ -461,12 +468,12 @@ _item_block_realize(Item_Block *itb, int in)
static void
_item_block_unrealize(Item_Block *itb)
{
Eina_List *l;
const Eina_List *l;
Elm_Genlist_Item *it;
if (!itb->realized) return;
for (l = itb->items; l; l = l->next)
EINA_LIST_FOREACH(itb->items, l, it)
{
Elm_Genlist_Item *it = l->data;
_item_unrealize(it);
}
itb->realized = 0;
@ -475,14 +482,13 @@ _item_block_unrealize(Item_Block *itb)
static void
_item_block_position(Item_Block *itb)
{
Eina_List *l;
const Eina_List *l;
Elm_Genlist_Item *it;
Evas_Coord y = 0, ox, oy;
evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, NULL, NULL);
for (l = itb->items; l; l = l->next)
EINA_LIST_FOREACH(itb->items, l, it)
{
Elm_Genlist_Item *it = l->data;
if (it->delete_me) continue;
it->x = 0;
it->y = y;

View File

@ -96,22 +96,20 @@ static void
_reval_content(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Eina_List *l;
for (l = wd->subs; l; l = l->next)
{
Subinfo *si = l->data;
edje_object_part_swallow(wd->cov, si->swallow, si->obj);
}
const Eina_List *l;
const Subinfo *si;
EINA_LIST_FOREACH(wd->subs, l, si)
edje_object_part_swallow(wd->cov, si->swallow, si->obj);
}
static void
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
Eina_List *l;
for (l = wd->subs; l; l = l->next)
const Eina_List *l;
const Subinfo *si;
EINA_LIST_FOREACH(wd->subs, l, si)
{
Subinfo *si = l->data;
if (si->obj == obj)
{
edje_object_part_swallow(wd->cov, si->swallow, si->obj);
@ -126,10 +124,9 @@ _sub_del(void *data, Evas_Object *obj, void *event_info)
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *sub = event_info;
Eina_List *l;
for (l = wd->subs; l; l = l->next)
Subinfo *si;
EINA_LIST_FOREACH(wd->subs, l, si)
{
Subinfo *si = l->data;
if (si->obj == sub)
{
evas_object_event_callback_del
@ -146,15 +143,15 @@ static void
_hov_show_do(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Eina_List *l;
const Eina_List *l;
const Subinfo *si;
if (wd->cov)
{
evas_object_show(wd->cov);
edje_object_signal_emit(wd->cov, "elm,action,show", "elm");
}
for (l = wd->subs; l; l = l->next)
EINA_LIST_FOREACH(wd->subs, l, si)
{
Subinfo *si = l->data;
char buf[1024];
if (!strncmp(si->swallow, "elm.swallow.slot.", 17))
{
@ -187,15 +184,15 @@ static void
_hov_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
Eina_List *l;
const Eina_List *l;
const Subinfo *si;
if (wd->cov)
{
edje_object_signal_emit(wd->cov, "elm,action,hide", "elm");
evas_object_hide(wd->cov);
}
for (l = wd->subs; l; l = l->next)
EINA_LIST_FOREACH(wd->subs, l, si)
{
Subinfo *si = l->data;
char buf[1024];
if (!strncmp(si->swallow, "elm.swallow.slot.", 17))
{
@ -349,13 +346,12 @@ elm_hover_content_set(Evas_Object *obj, const char *swallow, Evas_Object *conten
{
Widget_Data *wd = elm_widget_data_get(obj);
Subinfo *si;
Eina_List *l;
const Eina_List *l;
char buf[1024];
snprintf(buf, sizeof(buf), "elm.swallow.slot.%s", swallow);
for (l = wd->subs; l; l = l->next)
EINA_LIST_FOREACH(wd->subs, l, si)
{
si = l->data;
if (!strcmp(buf, si->swallow))
{
if (content == si->obj) return;

View File

@ -59,10 +59,10 @@ static void
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
Eina_List *l;
for (l = wd->subs; l; l = l->next)
const Eina_List *l;
const Subinfo *si;
EINA_LIST_FOREACH(wd->subs, l, si)
{
Subinfo *si = l->data;
if (si->obj == obj)
{
edje_object_part_swallow(wd->lay, si->swallow, obj);
@ -78,10 +78,9 @@ _sub_del(void *data, Evas_Object *obj, void *event_info)
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *sub = event_info;
Eina_List *l;
for (l = wd->subs; l; l = l->next)
Subinfo *si;
EINA_LIST_FOREACH(wd->subs, l, si)
{
Subinfo *si = l->data;
if (si->obj == sub)
{
evas_object_event_callback_del
@ -130,11 +129,10 @@ elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *conte
{
Widget_Data *wd = elm_widget_data_get(obj);
Subinfo *si;
Eina_List *l;
for (l = wd->subs; l; l = l->next)
const Eina_List *l;
EINA_LIST_FOREACH(wd->subs, l, si)
{
si = l->data;
if (!strcmp(swallow, si->swallow))
{
if (content == si->obj) return;

View File

@ -92,12 +92,11 @@ _sub_del(void *data, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *sub = event_info;
Eina_List *l;
for (l = wd->items; l; l = l->next)
const Eina_List *l;
Elm_List_Item *it;
EINA_LIST_FOREACH(wd->items, l, it)
{
Elm_List_Item *it = l->data;
if ((sub == it->icon) || (sub == it->end))
{
if (it->icon == sub) it->icon = NULL;
@ -164,7 +163,6 @@ _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
Elm_List_Item *it = data;
Widget_Data *wd = elm_widget_data_get(it->obj);
Evas_Event_Mouse_Up *ev = event_info;
Eina_List *l;
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = 1;
else wd->on_hold = 0;
if (wd->on_hold)
@ -179,13 +177,19 @@ _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
}
else
{
for (l = wd->selected; l;)
{
Elm_List_Item *it2 = l->data;
l = l->next;
if ((it2 != it) && (it2->selected)) _item_unselect(it2);
if (!it->selected)
{
while (wd->selected)
_item_unselect(wd->selected->data);
_item_select(it);
}
if (!it->selected) _item_select(it);
else
{
const Eina_List *l, *l_next;
Elm_List_Item *it2;
EINA_LIST_FOREACH_SAFE(wd->selected, l, l_next, it2)
if (it2 != it) _item_unselect(it2);
}
}
}
@ -228,15 +232,15 @@ static void
_fix_items(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Eina_List *l;
const Eina_List *l;
Elm_List_Item *it;
Evas_Coord minw[2] = { 0, 0 }, minh[2] = { 0, 0 };
Evas_Coord mw, mh;
int i, redo = 0;
for (l = wd->items; l; l = l->next)
EINA_LIST_FOREACH(wd->items, l, it)
{
Evas_Coord mw, mh;
Elm_List_Item *it = l->data;
if (it->icon)
{
evas_object_size_hint_min_get(it->icon, &mw, &mh);
@ -259,9 +263,9 @@ _fix_items(Evas_Object *obj)
wd->minh[1] = minh[1];
redo = 1;
}
for (i = 0, l = wd->items; l; l = l->next, i++)
i = 0;
EINA_LIST_FOREACH(wd->items, l, it)
{
Elm_List_Item *it = l->data;
it->even = i & 0x1;
if ((it->even != it->is_even) || (!it->fixed) || (redo))
{
@ -327,6 +331,7 @@ _fix_items(Evas_Object *obj)
it->fixed = 1;
it->is_even = it->even;
}
i++;
}
mw = 0; mh = 0;
evas_object_size_hint_min_get(wd->box, &mw, &mh);

View File

@ -534,7 +534,8 @@ elm_quicklaunch_exe_path_get(const char *exe)
{
static char *path = NULL;
static Eina_List *pathlist = NULL;
Eina_List *l;
const char *pathitr;
const Eina_List *l;
char buf[PATH_MAX];
if (exe[0] == '/') return strdup(exe);
if ((exe[0] == '.') && (exe[1] == '/')) return strdup(exe);
@ -568,9 +569,9 @@ elm_quicklaunch_exe_path_get(const char *exe)
}
}
}
for (l = pathlist; l; l = l->next)
EINA_LIST_FOREACH(pathlist, l, pathitr)
{
snprintf(buf, sizeof(buf), "%s/%s", (char *)l->data, exe);
snprintf(buf, sizeof(buf), "%s/%s", pathitr, exe);
if (access(buf, R_OK | X_OK) == 0) return strdup(buf);
}
return NULL;

View File

@ -116,20 +116,28 @@ _state_set(Evas_Object *obj, Evas_Bool state)
}
}
static void
_state_set_all(Widget_Data *wd)
{
const Eina_List *l;
Evas_Object *child;
EINA_LIST_FOREACH(wd->group->radios, l, child)
{
Widget_Data *wd2 = elm_widget_data_get(child);
if (wd2->value == wd->group->value) _state_set(child, 1);
else _state_set(child, 0);
}
}
static void
_signal_radio_on(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Widget_Data *wd = elm_widget_data_get(data);
Eina_List *l;
if (wd->group->value == wd->value) return;
wd->group->value = wd->value;
if (wd->group->valuep) *(wd->group->valuep) = wd->group->value;
for (l = wd->group->radios; l; l = l->next)
{
Widget_Data *wd2 = elm_widget_data_get(l->data);
if (wd2->value == wd->group->value) _state_set(l->data, 1);
else _state_set(l->data, 0);
}
_state_set_all(wd);
evas_object_smart_callback_call(data, "changed", NULL);
}
@ -233,16 +241,12 @@ EAPI void
elm_radio_value_set(Evas_Object *obj, int value)
{
Widget_Data *wd = elm_widget_data_get(obj);
Eina_List *l;
const Eina_List *l;
Evas_Object *child;
if (value == wd->group->value) return;
wd->group->value = value;
if (wd->group->valuep) *(wd->group->valuep) = wd->group->value;
for (l = wd->group->radios; l; l = l->next)
{
Widget_Data *wd2 = elm_widget_data_get(l->data);
if (wd2->value == wd->group->value) _state_set(l->data, 1);
else _state_set(l->data, 0);
}
_state_set_all(wd);
}
EAPI int
@ -262,15 +266,11 @@ elm_radio_value_pointer_set(Evas_Object *obj, int *valuep)
wd->group->valuep = valuep;
if (*(wd->group->valuep) != wd->group->value)
{
Eina_List *l;
const Eina_List *l;
Evas_Object *child;
wd->group->value = *(wd->group->valuep);
for (l = wd->group->radios; l; l = l->next)
{
Widget_Data *wd2 = elm_widget_data_get(l->data);
if (wd2->value == wd->group->value) _state_set(l->data, 1);
else _state_set(l->data, 0);
}
_state_set_all(wd);
}
}
else

View File

@ -49,7 +49,8 @@ _elm_theme_theme_element_try(const char *home, const char *f, const char *group)
static const char *
_elm_theme_group_file_find(const char *group)
{
Eina_List *l;
const Eina_List *l;
const char *f;
char *p;
static const char *home = NULL;
const char *file = eina_hash_find(cache, group);
@ -59,19 +60,19 @@ _elm_theme_group_file_find(const char *group)
home = getenv("HOME");
if (!home) home = "";
}
for (l = overlay; l; l = l->next)
EINA_LIST_FOREACH(overlay, l, f)
{
file = _elm_theme_theme_element_try(home, l->data, group);
file = _elm_theme_theme_element_try(home, f, group);
if (file) return file;
}
for (l = themes; l; l = l->next)
EINA_LIST_FOREACH(themes, l, f)
{
file = _elm_theme_theme_element_try(home, l->data, group);
file = _elm_theme_theme_element_try(home, f, group);
if (file) return file;
}
for (l = extension; l; l = l->next)
EINA_LIST_FOREACH(extension, l, f)
{
file = _elm_theme_theme_element_try(home, l->data, group);
file = _elm_theme_theme_element_try(home, f, group);
if (file) return file;
}
return NULL;

View File

@ -43,11 +43,10 @@ _item_select(Elm_Toolbar_Item *it)
Elm_Toolbar_Item *it2;
Widget_Data *wd = elm_widget_data_get(it->obj);
Evas_Object *obj2;
Eina_List *l;
const Eina_List *l;
if (it->selected) return;
for (l = wd->items; l; l = l->next)
EINA_LIST_FOREACH(wd->items, l, it2)
{
it2 = l->data;
if (it2->selected)
{
it2->selected = 0;
@ -83,12 +82,11 @@ static void
_theme_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Eina_List *l;
const Eina_List *l;
Elm_Toolbar_Item *it;
Evas_Coord mw, mh;
for (l = wd->items; l; l = l->next)
EINA_LIST_FOREACH(wd->items, l, it)
{
it = l->data;
if (it->selected)
edje_object_signal_emit(it->base, "elm,state,selected", "elm");
_elm_theme_set(it->base, "toolbar", "item", "default");
@ -141,7 +139,7 @@ _resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
Evas_Coord mw, mh, vw, vh, w, h;
Eina_List *l;
const Eina_List *l;
Elm_Toolbar_Item *it;
elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
@ -151,9 +149,8 @@ _resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
if (w != vw) evas_object_resize(wd->bx, vw, h);
}
for (l = wd->items; l; l = l->next)
EINA_LIST_FOREACH(wd->items, l, it)
{
it = l->data;
if (it->selected)
{
_item_show(it);

View File

@ -137,10 +137,12 @@ elm_widget_theme_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
EAPI void
elm_widget_theme(Evas_Object *obj)
{
Eina_List *l;
const Eina_List *l;
Evas_Object *child;
API_ENTRY return;
for (l = sd->subobjs; l; l = l->next) elm_widget_theme(l->data);
EINA_LIST_FOREACH(sd->subobjs, l, child)
elm_widget_theme(child);
if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
if (sd->theme_func) sd->theme_func(obj);
@ -339,7 +341,6 @@ elm_widget_focus_jump(Evas_Object *obj, int forward)
/* its some container */
else
{
Eina_List *l;
int focus_next;
int noloop = 0;
@ -378,24 +379,26 @@ elm_widget_focus_jump(Evas_Object *obj, int forward)
}
if (!noloop)
{
for (l = sd->subobjs; l; l = l->next)
const Eina_List *l;
Evas_Object *child;
EINA_LIST_FOREACH(sd->subobjs, l, child)
{
if (elm_widget_can_focus_get(l->data))
if (elm_widget_can_focus_get(child))
{
if ((focus_next) &&
(!elm_widget_disabled_get(l->data)))
(!elm_widget_disabled_get(child)))
{
/* the previous focused item was unfocused - so focus
* the next one (that can be focused) */
if (elm_widget_focus_jump(l->data, forward)) return 1;
if (elm_widget_focus_jump(child, forward)) return 1;
else break;
}
else
{
if (elm_widget_focus_get(l->data))
if (elm_widget_focus_get(child))
{
/* jump to the next focused item or focus this item */
if (elm_widget_focus_jump(l->data, forward)) return 1;
if (elm_widget_focus_jump(child, forward)) return 1;
/* it returned 0 - it got to the last item and is past it */
focus_next = 1;
}
@ -406,24 +409,27 @@ elm_widget_focus_jump(Evas_Object *obj, int forward)
}
else
{
for (l = eina_list_last(sd->subobjs); l; l = l->prev)
const Eina_List *l;
Evas_Object *child;
EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
{
if (elm_widget_can_focus_get(l->data))
if (elm_widget_can_focus_get(child))
{
if ((focus_next) &&
(!elm_widget_disabled_get(l->data)))
(!elm_widget_disabled_get(child)))
{
/* the previous focused item was unfocused - so focus
* the next one (that can be focused) */
if (elm_widget_focus_jump(l->data, forward)) return 1;
if (elm_widget_focus_jump(child, forward)) return 1;
else break;
}
else
{
if (elm_widget_focus_get(l->data))
if (elm_widget_focus_get(child))
{
/* jump to the next focused item or focus this item */
if (elm_widget_focus_jump(l->data, forward)) return 1;
if (elm_widget_focus_jump(child, forward)) return 1;
/* it returned 0 - it got to the last item and is past it */
focus_next = 1;
}
@ -481,8 +487,6 @@ elm_widget_focus_set(Evas_Object *obj, int first)
}
else
{
Eina_List *l;
if (first)
{
if ((elm_widget_can_focus_get(sd->resize_obj)) &&
@ -492,12 +496,14 @@ elm_widget_focus_set(Evas_Object *obj, int first)
}
else
{
for (l = sd->subobjs; l; l = l->next)
const Eina_List *l;
Evas_Object *child;
EINA_LIST_FOREACH(sd->subobjs, l, child)
{
if ((elm_widget_can_focus_get(l->data)) &&
(!elm_widget_disabled_get(l->data)))
if ((elm_widget_can_focus_get(child)) &&
(!elm_widget_disabled_get(child)))
{
elm_widget_focus_set(l->data, first);
elm_widget_focus_set(child, first);
break;
}
}
@ -505,12 +511,14 @@ elm_widget_focus_set(Evas_Object *obj, int first)
}
else
{
for (l = eina_list_last(sd->subobjs); l; l = l->prev)
const Eina_List *l;
Evas_Object *child;
EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
{
if ((elm_widget_can_focus_get(l->data)) &&
(!elm_widget_disabled_get(l->data)))
if ((elm_widget_can_focus_get(child)) &&
(!elm_widget_disabled_get(child)))
{
elm_widget_focus_set(l->data, first);
elm_widget_focus_set(child, first);
break;
}
}
@ -536,7 +544,6 @@ elm_widget_parent_get(const Evas_Object *obj)
EAPI void
elm_widget_focused_object_clear(Evas_Object *obj)
{
Eina_List *l;
API_ENTRY return;
if (!sd->focused) return;
if (elm_widget_focus_get(sd->resize_obj))
@ -545,11 +552,13 @@ elm_widget_focused_object_clear(Evas_Object *obj)
}
else
{
for (l = sd->subobjs; l; l = l->next)
{
if (elm_widget_focus_get(l->data))
const Eina_List *l;
Evas_Object *child;
EINA_LIST_FOREACH(sd->subobjs, l, child)
{
if (elm_widget_focus_get(child))
{
elm_widget_focused_object_clear(l->data);
elm_widget_focused_object_clear(child);
break;
}
}
@ -591,18 +600,19 @@ elm_widget_focus_steal(Evas_Object *obj)
elm_widget_focused_object_clear(parent);
else
{
Eina_List *l;
parent = elm_widget_parent_get(parent);
sd = evas_object_smart_data_get(parent);
if (elm_widget_focus_get(sd->resize_obj))
elm_widget_focused_object_clear(sd->resize_obj);
else
{
for (l = sd->subobjs; l; l = l->next)
const Eina_List *l;
Evas_Object *child;
EINA_LIST_FOREACH(sd->subobjs, l, child)
{
if (elm_widget_focus_get(l->data))
if (elm_widget_focus_get(child))
{
elm_widget_focused_object_clear(l->data);
elm_widget_focused_object_clear(child);
break;
}
}

View File

@ -94,16 +94,17 @@ static void
_elm_win_resize_job(void *data)
{
Elm_Win *win = data;
Eina_List *l;
const Eina_List *l;
Evas_Object *obj;
int w, h;
win->deferred_resize_job = NULL;
ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
evas_object_resize(win->win_obj, w, h);
for (l = win->subobjs; l; l = l->next)
EINA_LIST_FOREACH(win->subobjs, l, obj)
{
evas_object_move(l->data, 0, 0);
evas_object_resize(l->data, w, h);
evas_object_move(obj, 0, 0);
evas_object_resize(obj, w, h);
}
}
@ -178,25 +179,26 @@ _elm_win_xwin_update(Elm_Win *win)
static void
_elm_win_eval_subobjs(Evas_Object *obj)
{
Eina_List *l;
const Eina_List *l;
const Evas_Object *child;
Elm_Win *win = elm_widget_data_get(obj);
Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
int xx = 1, xy = 1;
double wx, wy;
for (l = win->subobjs; l; l = l->next)
EINA_LIST_FOREACH(win->subobjs, l, child)
{
evas_object_size_hint_weight_get(l->data, &wx, &wy);
evas_object_size_hint_weight_get(child, &wx, &wy);
if (wx == 0.0) xx = 0;
if (wy == 0.0) xy = 0;
evas_object_size_hint_min_get(l->data, &w, &h);
evas_object_size_hint_min_get(child, &w, &h);
if (w < 1) w = -1;
if (h < 1) h = -1;
if (w > minw) minw = w;
if (h > minh) minh = h;
evas_object_size_hint_max_get(l->data, &w, &h);
evas_object_size_hint_max_get(child, &w, &h);
if (w < 1) w = -1;
if (h < 1) h = -1;
if (maxw == -1) maxw = w;
@ -241,16 +243,18 @@ _elm_win_shutdown(void)
void
_elm_win_rescale(void)
{
Eina_List *l;
for (l = _elm_win_list; l; l = l->next) elm_widget_theme(l->data);
const Eina_List *l;
Evas_Object *obj;
EINA_LIST_FOREACH(_elm_win_list, l, obj)
elm_widget_theme(obj);
}
EAPI Evas_Object *
elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
{
Elm_Win *win;
Eina_List *l;
const Eina_List *l;
const char *fontpath;
win = ELM_NEW(Elm_Win);
switch (_elm_config->engine)
@ -316,8 +320,8 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
evas_image_cache_set(win->evas, _elm_config->image_cache * 1024);
evas_font_cache_set(win->evas, _elm_config->font_cache * 1024);
for (l = _elm_config->font_dirs; l; l = l->next)
evas_font_path_append(win->evas, l->data);
EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
evas_font_path_append(win->evas, fontpath);
if (_elm_config->font_hinting == 0)
evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
else if (_elm_config->font_hinting == 1)

View File

@ -108,44 +108,48 @@ _els_smart_box_pack_end(Evas_Object *obj, Evas_Object *child)
return eina_list_count(sd->items) - 1;
}
static int
_els_smart_box_find(const Smart_Data *sd, const Evas_Object *child)
{
int i = 0;
const Eina_List *l;
const Evas_Object *oitr;
EINA_LIST_FOREACH(sd->items, l, oitr)
{
if (oitr == child)
return i;
i++;
}
return -1;
}
int
_els_smart_box_pack_before(Evas_Object *obj, Evas_Object *child, Evas_Object *before)
{
Smart_Data *sd;
int i = 0;
Eina_List *l;
if (!child) return 0;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
_smart_adopt(sd, child);
sd->items = eina_list_prepend_relative(sd->items, child, before);
for (i = 0, l = sd->items; l; l = l->next, i++)
{
if (l->data == child) break;
}
_smart_reconfigure(sd);
return i;
return _els_smart_box_find(sd, child);
}
int
_els_smart_box_pack_after(Evas_Object *obj, Evas_Object *child, Evas_Object *after)
{
Smart_Data *sd;
int i = 0;
Eina_List *l;
if (!child) return 0;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
_smart_adopt(sd, child);
sd->items = eina_list_append_relative(sd->items, child, after);
for (i = 0, l = sd->items; l; l = l->next, i++)
{
if (l->data == child) break;
}
_smart_reconfigure(sd);
return i;
return _els_smart_box_find(sd, child);
}
void
@ -215,7 +219,8 @@ static void
_smart_reconfigure(Smart_Data *sd)
{
Evas_Coord x, y, w, h, xx, yy;
Eina_List *l;
const Eina_List *l;
Evas_Object *obj;
Evas_Coord minw, minh, wdif, hdif, mnw, mnh, mxw, mxh;
int count, expand, fw, fh, xw, xh;
double ax, ay, wx, wy;
@ -241,9 +246,9 @@ _smart_reconfigure(Smart_Data *sd)
y = y + ((h - minh) * (1.0 - ay));
h = minh;
}
for (l = sd->items; l; l = l->next)
EINA_LIST_FOREACH(sd->items, l, obj)
{
evas_object_size_hint_weight_get(l->data, &wx, &wy);
evas_object_size_hint_weight_get(obj, &wx, &wy);
if (sd->horizontal)
{
if (wx > 0.0) expand++;
@ -271,15 +276,12 @@ _smart_reconfigure(Smart_Data *sd)
hdif = h - minh;
xx = x;
yy = y;
for (l = sd->items; l; l = l->next)
EINA_LIST_FOREACH(sd->items, l, obj)
{
Evas_Object *obj;
obj = l->data;
evas_object_size_hint_align_get(l->data, &ax, &ay);
evas_object_size_hint_weight_get(l->data, &wx, &wy);
evas_object_size_hint_min_get(l->data, &mnw, &mnh);
evas_object_size_hint_max_get(l->data, &mxw, &mxh);
evas_object_size_hint_align_get(obj, &ax, &ay);
evas_object_size_hint_weight_get(obj, &wx, &wy);
evas_object_size_hint_min_get(obj, &mnw, &mnh);
evas_object_size_hint_max_get(obj, &mxw, &mxh);
fw = fh = 0;
xw = xh = 0;
if (ax == -1.0) {fw = 1; ax = 0.5;}
@ -386,7 +388,6 @@ _smart_reconfigure(Smart_Data *sd)
static void
_smart_extents_calculate(Smart_Data *sd)
{
Eina_List *l;
Evas_Coord minw, minh, maxw, maxh, mnw, mnh;
/* FIXME: need to calc max */
@ -396,9 +397,11 @@ _smart_extents_calculate(Smart_Data *sd)
maxh = -1;
if (sd->homogenous)
{
for (l = sd->items; l; l = l->next)
const Eina_List *l;
const Evas_Object *obj;
EINA_LIST_FOREACH(sd->items, l, obj)
{
evas_object_size_hint_min_get(l->data, &mnw, &mnh);
evas_object_size_hint_min_get(obj, &mnw, &mnh);
if (minh < mnh) minh = mnh;
if (minw < mnw) minw = mnw;
}
@ -409,9 +412,11 @@ _smart_extents_calculate(Smart_Data *sd)
}
else
{
for (l = sd->items; l; l = l->next)
const Eina_List *l;
const Evas_Object *obj;
EINA_LIST_FOREACH(sd->items, l, obj)
{
evas_object_size_hint_min_get(l->data, &mnw, &mnh);
evas_object_size_hint_min_get(obj, &mnw, &mnh);
if (sd->horizontal)
{
if (minh < mnh) minh = mnh;
@ -494,7 +499,8 @@ static void
_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
{
Smart_Data *sd;
Eina_List *l;
const Eina_List *l;
Evas_Object *child;
Evas_Coord dx, dy;
sd = evas_object_smart_data_get(obj);
@ -503,12 +509,12 @@ _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
dy = y - sd->y;
sd->x = x;
sd->y = y;
for (l = sd->items; l; l = l->next)
EINA_LIST_FOREACH(sd->items, l, child)
{
Evas_Coord ox, oy;
evas_object_geometry_get(l->data, &ox, &oy, NULL, NULL);
evas_object_move(l->data, ox + dx, oy + dy);
evas_object_geometry_get(child, &ox, &oy, NULL, NULL);
evas_object_move(child, ox + dx, oy + dy);
}
}

View File

@ -181,7 +181,8 @@ static void
_smart_reconfigure(Smart_Data *sd)
{
Evas_Coord x, y, w, h, xx, yy;
Eina_List *l;
const Eina_List *l;
Evas_Object *obj;
Evas_Coord minw, minh;
int expandw, expandh;
double ax, ay;
@ -207,16 +208,14 @@ _smart_reconfigure(Smart_Data *sd)
y = y + ((h - minh) * (1.0 - ay));
h = minh;
}
for (l = sd->items; l; l = l->next)
EINA_LIST_FOREACH(sd->items, l, obj)
{
Table_Item *ti;
Evas_Object *obj;
int xw, xh;
double wx, wy;
obj = l->data;
ti = evas_object_data_get(obj, "e_table_data");
evas_object_size_hint_weight_get(l->data, &wx, &wy);
evas_object_size_hint_weight_get(obj, &wx, &wy);
xw = 0;
xh = 0;
if (wx > 0.0) xw = 1;
@ -238,26 +237,24 @@ _smart_reconfigure(Smart_Data *sd)
y = sd->y;
if (sd->homogenous)
{
for (l = sd->items; l; l = l->next)
EINA_LIST_FOREACH(sd->items, l, obj)
{
Table_Item *ti;
Evas_Object *obj;
Evas_Coord ww, hh, ow, oh;
Evas_Coord mxw, mxh;
int xw, xh;
double wx, wy;
obj = l->data;
ti = evas_object_data_get(obj, "e_table_data");
xx = x + ((ti->col) * (w / (Evas_Coord)sd->size.cols));
yy = y + ((ti->row) * (h / (Evas_Coord)sd->size.rows));
ww = ((w / (Evas_Coord)sd->size.cols) * (ti->colspan));
hh = ((h / (Evas_Coord)sd->size.rows) * (ti->rowspan));
evas_object_size_hint_min_get(l->data, &ow, &oh);
evas_object_size_hint_max_get(l->data, &mxw, &mxh);
evas_object_size_hint_weight_get(l->data, &wx, &wy);
evas_object_size_hint_align_get(l->data, &ax, &ay);
evas_object_size_hint_min_get(obj, &ow, &oh);
evas_object_size_hint_max_get(obj, &mxw, &mxh);
evas_object_size_hint_weight_get(obj, &wx, &wy);
evas_object_size_hint_align_get(obj, &ax, &ay);
xw = 0;
xh = 0;
if (wx > 0.0) xw = 1;
@ -275,12 +272,10 @@ _smart_reconfigure(Smart_Data *sd)
else
{
int i, ex, tot, need, num, dif, left, nx;
for (l = sd->items; l; l = l->next)
EINA_LIST_FOREACH(sd->items, l, obj)
{
Table_Item *ti;
Evas_Object *obj;
obj = l->data;
ti = evas_object_data_get(obj, "e_table_data");
if (sd->size.cols < (ti->col + ti->colspan))
sd->size.cols = ti->col + ti->colspan;
@ -295,17 +290,15 @@ _smart_reconfigure(Smart_Data *sd)
rows = calloc(sd->size.rows, sizeof(int));
colsx = calloc(sd->size.cols, sizeof(int));
rowsx = calloc(sd->size.rows, sizeof(int));
for (l = sd->items; l; l = l->next)
EINA_LIST_FOREACH(sd->items, l, obj)
{
Table_Item *ti;
Evas_Object *obj;
int xw, xh;
double wx, wy;
obj = l->data;
ti = evas_object_data_get(obj, "e_table_data");
evas_object_size_hint_weight_get(l->data, &wx, &wy);
evas_object_size_hint_weight_get(obj, &wx, &wy);
xw = 0;
xh = 0;
if (wx > 0.0) xw = 1;
@ -315,22 +308,20 @@ _smart_reconfigure(Smart_Data *sd)
for (i = ti->row; i < (ti->row + ti->rowspan); i++)
rowsx[i] |= xh;
}
for (l = sd->items; l; l = l->next)
EINA_LIST_FOREACH(sd->items, l, obj)
{
Table_Item *ti;
Evas_Object *obj;
Evas_Coord mnw, mnh, mxw, mxh;
int xw, xh;
double wx, wy;
obj = l->data;
ti = evas_object_data_get(obj, "e_table_data");
evas_object_size_hint_min_get(l->data, &mnw, &mnh);
evas_object_size_hint_max_get(l->data, &mxw, &mxh);
evas_object_size_hint_weight_get(l->data, &wx, &wy);
evas_object_size_hint_align_get(l->data, &ax, &ay);
evas_object_size_hint_min_get(obj, &mnw, &mnh);
evas_object_size_hint_max_get(obj, &mxw, &mxh);
evas_object_size_hint_weight_get(obj, &wx, &wy);
evas_object_size_hint_align_get(obj, &ax, &ay);
xw = 0;
xh = 0;
if (wx > 0.0) xw = 1;
@ -508,20 +499,18 @@ _smart_reconfigure(Smart_Data *sd)
}
}
}
for (l = sd->items; l; l = l->next)
EINA_LIST_FOREACH(sd->items, l, obj)
{
Table_Item *ti;
Evas_Object *obj;
Evas_Coord ww, hh, ow, oh, i;
Evas_Coord mxw, mxh;
obj = l->data;
ti = evas_object_data_get(obj, "e_table_data");
evas_object_size_hint_min_get(l->data, &ow, &oh);
evas_object_size_hint_max_get(l->data, &mxw, &mxh);
evas_object_size_hint_align_get(l->data, &ax, &ay);
evas_object_size_hint_min_get(obj, &ow, &oh);
evas_object_size_hint_max_get(obj, &mxw, &mxh);
evas_object_size_hint_align_get(obj, &ax, &ay);
xx = x;
for (i = 0; i < ti->col; i++) xx += cols[i];
ww = 0;
@ -551,7 +540,6 @@ _smart_reconfigure(Smart_Data *sd)
static void
_smart_extents_calcuate(Smart_Data *sd)
{
Eina_List *l;
Evas_Coord minw, minh, maxw, maxh;
minw = 0;
@ -562,20 +550,20 @@ _smart_extents_calcuate(Smart_Data *sd)
sd->size.rows = 0;
if (sd->homogenous)
{
for (l = sd->items; l; l = l->next)
const Eina_List *l;
const Evas_Object *obj;
EINA_LIST_FOREACH(sd->items, l, obj)
{
Table_Item *ti;
Evas_Object *obj;
int mw, mh;
Evas_Coord w, h;
obj = l->data;
ti = evas_object_data_get(obj, "e_table_data");
if (sd->size.cols < (ti->col + ti->colspan))
sd->size.cols = ti->col + ti->colspan;
if (sd->size.rows < (ti->row + ti->rowspan))
sd->size.rows = ti->row + ti->rowspan;
evas_object_size_hint_min_get(l->data, &w, &h);
evas_object_size_hint_min_get(obj, &w, &h);
mw = (w + (ti->colspan - 1)) / ti->colspan;
mh = (h + (ti->rowspan - 1)) / ti->rowspan;
if (minw < mw) minw = mw;
@ -586,14 +574,14 @@ _smart_extents_calcuate(Smart_Data *sd)
}
else
{
const Eina_List *l;
const Evas_Object *obj;
int i, ex, tot, need, num, dif, left, nx;
for (l = sd->items; l; l = l->next)
EINA_LIST_FOREACH(sd->items, l, obj)
{
Table_Item *ti;
Evas_Object *obj;
obj = l->data;
ti = evas_object_data_get(obj, "e_table_data");
ti = evas_object_data_get(obj, "e_table_data");
if (sd->size.cols < (ti->col + ti->colspan))
sd->size.cols = ti->col + ti->colspan;
if (sd->size.rows < (ti->row + ti->rowspan))
@ -607,17 +595,15 @@ _smart_extents_calcuate(Smart_Data *sd)
rows = calloc(sd->size.rows, sizeof(int));
colsx = calloc(sd->size.cols, sizeof(int));
rowsx = calloc(sd->size.rows, sizeof(int));
for (l = sd->items; l; l = l->next)
EINA_LIST_FOREACH(sd->items, l, obj)
{
Table_Item *ti;
Evas_Object *obj;
int xw, xh;
double wx, wy;
obj = l->data;
ti = evas_object_data_get(obj, "e_table_data");
evas_object_size_hint_weight_get(l->data, &wx, &wy);
evas_object_size_hint_weight_get(obj, &wx, &wy);
xw = 0;
xh = 0;
if (wx > 0.0) xw = 1;
@ -627,17 +613,15 @@ _smart_extents_calcuate(Smart_Data *sd)
for (i = ti->row; i < (ti->row + ti->rowspan); i++)
rowsx[i] |= xh;
}
for (l = sd->items; l; l = l->next)
EINA_LIST_FOREACH(sd->items, l, obj)
{
Table_Item *ti;
Evas_Object *obj;
Evas_Coord w, h;
obj = l->data;
ti = evas_object_data_get(obj, "e_table_data");
evas_object_size_hint_min_get(l->data, &w, &h);
evas_object_size_hint_min_get(obj, &w, &h);
/* handle horizontal */
ex = 0;
tot = 0;
@ -830,19 +814,20 @@ static void
_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
{
Smart_Data *sd;
Eina_List *l;
const Eina_List *l;
Evas_Object *child;
Evas_Coord dx, dy;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
dx = x - sd->x;
dy = y - sd->y;
for (l = sd->items; l; l = l->next)
EINA_LIST_FOREACH(sd->items, l, child)
{
Evas_Coord ox, oy;
evas_object_geometry_get(l->data, &ox, &oy, NULL, NULL);
evas_object_move(l->data, ox + dx, oy + dy);
evas_object_geometry_get(child, &ox, &oy, NULL, NULL);
evas_object_move(child, ox + dx, oy + dy);
}
sd->x = x;
sd->y = y;