Two patches from Peter van de Werken
- Hide eina_list internals by using eina macros - Cleanup some duplicate code Patches slightly modified for formatting & whitespace removal. Use eina_list internal macros in some places that were missed. SVN revision: 41518
This commit is contained in:
parent
f16d0a13ef
commit
619fc7a98a
|
@ -30,6 +30,8 @@ static void _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission
|
|||
static void _e_wid_cb_scrollframe_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _e_wid_cb_key_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
|
||||
static void _item_show(Item *it);
|
||||
static void _item_select(Item *it);
|
||||
static void _item_unselect(Item *it);
|
||||
|
||||
/* local subsystem functions */
|
||||
|
||||
|
@ -40,18 +42,18 @@ e_widget_toolbar_add(Evas *evas, int icon_w, int icon_h)
|
|||
Evas_Object *obj, *o;
|
||||
E_Widget_Data *wd;
|
||||
Evas_Coord mw = 0, mh = 0;
|
||||
|
||||
|
||||
obj = e_widget_add(evas);
|
||||
|
||||
|
||||
e_widget_del_hook_set(obj, _e_wid_del_hook);
|
||||
e_widget_focus_hook_set(obj, _e_wid_focus_hook);
|
||||
e_widget_disable_hook_set(obj, _e_wid_disable_hook);
|
||||
wd = calloc(1, sizeof(E_Widget_Data));
|
||||
wd = E_NEW(E_Widget_Data, 1);
|
||||
e_widget_data_set(obj, wd);
|
||||
wd->icon_w = icon_w;
|
||||
wd->icon_h = icon_h;
|
||||
wd->focus_steal = EINA_TRUE;
|
||||
|
||||
|
||||
o = e_scrollframe_add(evas);
|
||||
wd->o_base = o;
|
||||
o = e_box_add(evas);
|
||||
|
@ -79,11 +81,11 @@ e_widget_toolbar_add(Evas *evas, int icon_w, int icon_h)
|
|||
e_scrollframe_child_set(wd->o_base, o);
|
||||
e_widget_sub_object_add(obj, o);
|
||||
evas_object_show(o);
|
||||
|
||||
|
||||
edje_object_size_min_calc
|
||||
(e_scrollframe_edje_object_get(wd->o_base), &mw, &mh);
|
||||
e_widget_min_size_set(obj, mw, mh);
|
||||
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -94,7 +96,7 @@ e_widget_toolbar_item_append(Evas_Object *obj, Evas_Object *icon, const char *la
|
|||
Evas_Object *o;
|
||||
Item *it;
|
||||
Evas_Coord mw = 0, mh = 0, vw = 0, vh = 0;
|
||||
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
o = edje_object_add(evas_object_evas_get(obj));
|
||||
e_theme_edje_object_set(o, "base/theme/widgets",
|
||||
|
@ -155,43 +157,31 @@ e_widget_toolbar_item_remove(Evas_Object *obj, int num)
|
|||
EAPI void
|
||||
e_widget_toolbar_item_select(Evas_Object *obj, int num)
|
||||
{
|
||||
E_Widget_Data *wd;
|
||||
Eina_List *l;
|
||||
Item *it;
|
||||
int i;
|
||||
E_Widget_Data *wd = NULL;
|
||||
Eina_List *l = NULL;
|
||||
Item *it = NULL;
|
||||
int i = 0;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
for (i = 0, l = wd->items; l; l = l->next, i++)
|
||||
EINA_LIST_FOREACH(wd->items, l, it)
|
||||
{
|
||||
it = l->data;
|
||||
if (i == num)
|
||||
{
|
||||
if (!it->selected)
|
||||
{
|
||||
it->selected = EINA_TRUE;
|
||||
edje_object_signal_emit(it->o_base, "e,state,selected", "e");
|
||||
edje_object_signal_emit(it->o_icon, "e,state,selected", "e");
|
||||
_item_show(it);
|
||||
if (it->func) it->func(it->data1, it->data2);
|
||||
}
|
||||
if (!it->selected) _item_select(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (it->selected)
|
||||
{
|
||||
it->selected = EINA_FALSE;
|
||||
edje_object_signal_emit(it->o_base, "e,state,unselected", "e");
|
||||
edje_object_signal_emit(it->o_icon, "e,state,unselected", "e");
|
||||
}
|
||||
if (it->selected) _item_unselect(it);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_widget_toolbar_item_label_set(Evas_Object *obj, int num, const char *label)
|
||||
{
|
||||
E_Widget_Data *wd;
|
||||
Item *it;
|
||||
E_Widget_Data *wd = NULL;
|
||||
Item *it = NULL;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
it = eina_list_nth(wd->items, num);
|
||||
|
@ -216,7 +206,7 @@ e_widget_toolbar_scrollable_set(Evas_Object *obj, Eina_Bool scrollable)
|
|||
{
|
||||
E_Widget_Data *wd;
|
||||
Evas_Coord mw = 0, mh = 0, vw = 0, vh = 0;
|
||||
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
wd->scrollable = scrollable;
|
||||
e_box_min_size_get(wd->o_box, &mw, &mh);
|
||||
|
@ -255,18 +245,15 @@ e_widget_toolbar_focus_steal_set(Evas_Object *obj, Eina_Bool steal)
|
|||
EAPI void
|
||||
e_widget_toolbar_clear(Evas_Object *obj)
|
||||
{
|
||||
E_Widget_Data *wd;
|
||||
E_Widget_Data *wd = NULL;
|
||||
Item *it = NULL;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
while (wd->items)
|
||||
EINA_LIST_FREE(wd->items, it)
|
||||
{
|
||||
Item *it = NULL;
|
||||
|
||||
if (!(it = wd->items->data)) continue;
|
||||
evas_object_del(it->o_base);
|
||||
evas_object_del(it->o_icon);
|
||||
wd->items = eina_list_remove(wd->items, it);
|
||||
E_FREE(it);
|
||||
evas_object_del(it->o_base);
|
||||
evas_object_del(it->o_icon);
|
||||
E_FREE(it);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,15 +262,14 @@ e_widget_toolbar_item_selected_get(Evas_Object *obj)
|
|||
{
|
||||
E_Widget_Data *wd = NULL;
|
||||
Eina_List *l = NULL;
|
||||
Item *it = NULL;
|
||||
int i = 0;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
for (i = 0, l = wd->items; l; l = l->next, i++)
|
||||
EINA_LIST_FOREACH(wd->items, l, it)
|
||||
{
|
||||
Item *it = NULL;
|
||||
|
||||
if (!(it = l->data)) continue;;
|
||||
if (it->selected) return i;
|
||||
i++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -293,16 +279,13 @@ static void
|
|||
_e_wid_del_hook(Evas_Object *obj)
|
||||
{
|
||||
E_Widget_Data *wd;
|
||||
|
||||
Item *it;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
while (wd->items)
|
||||
EINA_LIST_FREE(wd->items, it)
|
||||
{
|
||||
Item *it;
|
||||
|
||||
it = wd->items->data;
|
||||
evas_object_del(it->o_base);
|
||||
evas_object_del(it->o_icon);
|
||||
wd->items = eina_list_remove_list(wd->items, wd->items);
|
||||
E_FREE(it);
|
||||
}
|
||||
E_FREE(wd);
|
||||
|
@ -312,7 +295,7 @@ static void
|
|||
_e_wid_disable_hook(Evas_Object *obj)
|
||||
{
|
||||
E_Widget_Data *wd;
|
||||
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
if (e_widget_disabled_get(obj))
|
||||
edje_object_signal_emit
|
||||
|
@ -328,26 +311,19 @@ _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char
|
|||
Item *it, *it2;
|
||||
E_Widget_Data *wd;
|
||||
Eina_List *l;
|
||||
|
||||
it = data;
|
||||
|
||||
if (!(it = data)) return;
|
||||
if (it->selected) return;
|
||||
wd = e_widget_data_get(it->o_toolbar);
|
||||
for (l = wd->items; l; l = l->next)
|
||||
EINA_LIST_FOREACH(wd->items, l, it2)
|
||||
{
|
||||
it2 = l->data;
|
||||
if (it2->selected)
|
||||
{
|
||||
it2->selected = EINA_FALSE;
|
||||
edje_object_signal_emit(it2->o_base, "e,state,unselected", "e");
|
||||
edje_object_signal_emit(it2->o_icon, "e,state,unselected", "e");
|
||||
_item_unselect(it2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
it->selected = EINA_TRUE;
|
||||
edje_object_signal_emit(it->o_base, "e,state,selected", "e");
|
||||
edje_object_signal_emit(it->o_icon, "e,state,selected", "e");
|
||||
_item_show(it);
|
||||
if (it->func) it->func(it->data1, it->data2);
|
||||
_item_select(it);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -357,7 +333,7 @@ _e_wid_cb_scrollframe_resize(void *data, Evas *e, Evas_Object *obj, void *event_
|
|||
Evas_Coord mw, mh, vw, vh, w, h;
|
||||
Eina_List *l;
|
||||
Item *it;
|
||||
|
||||
|
||||
wd = e_widget_data_get(data);
|
||||
|
||||
if (wd->o_base == NULL || wd->o_box == NULL) return ;
|
||||
|
@ -369,9 +345,8 @@ _e_wid_cb_scrollframe_resize(void *data, Evas *e, Evas_Object *obj, void *event_
|
|||
{
|
||||
if (w != vw) evas_object_resize(wd->o_box, 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);
|
||||
|
@ -385,74 +360,67 @@ _e_wid_cb_key_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
|||
{
|
||||
Evas_Event_Key_Down *ev;
|
||||
E_Widget_Data *wd;
|
||||
Eina_List *l;
|
||||
Eina_List *l, *l2;
|
||||
Item *it = NULL, *it2 = NULL;
|
||||
|
||||
|
||||
ev = event_info;
|
||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||
wd = e_widget_data_get(data);
|
||||
if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")) ||
|
||||
(!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left"))
|
||||
)
|
||||
(!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
|
||||
{
|
||||
for (l = wd->items; l; l = l->next)
|
||||
EINA_LIST_FOREACH(wd->items, l, it)
|
||||
{
|
||||
it = l->data;
|
||||
if (it->selected)
|
||||
{
|
||||
if (l->prev) it2 = l->prev->data;
|
||||
l2 = eina_list_prev(l);
|
||||
if (l2) it2 = eina_list_data_get(l2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")) ||
|
||||
(!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right"))
|
||||
)
|
||||
else if ((!strcmp(ev->keyname, "Down")) ||
|
||||
(!strcmp(ev->keyname, "KP_Down")) ||
|
||||
(!strcmp(ev->keyname, "Right")) ||
|
||||
(!strcmp(ev->keyname, "KP_Right")))
|
||||
{
|
||||
for (l = wd->items; l; l = l->next)
|
||||
EINA_LIST_FOREACH(wd->items, l, it)
|
||||
{
|
||||
it = l->data;
|
||||
if (it->selected)
|
||||
{
|
||||
if (l->next) it2 = l->next->data;
|
||||
l2 = eina_list_next(l);
|
||||
if (l2) it2 = eina_list_data_get(l2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
|
||||
else if ((!strcmp(ev->keyname, "Home")) ||
|
||||
(!strcmp(ev->keyname, "KP_Home")))
|
||||
{
|
||||
for (l = wd->items; l; l = l->next)
|
||||
EINA_LIST_FOREACH(wd->items, l, it)
|
||||
{
|
||||
it = l->data;
|
||||
if (it->selected)
|
||||
{
|
||||
it2 = wd->items->data;
|
||||
it2 = eina_list_data_get(wd->items);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
|
||||
{
|
||||
for (l = wd->items; l; l = l->next)
|
||||
{
|
||||
it = l->data;
|
||||
EINA_LIST_FOREACH(wd->items, l, it)
|
||||
{
|
||||
if (it->selected)
|
||||
{
|
||||
it2 = eina_list_last(wd->items)->data;
|
||||
it2 = eina_list_data_get(eina_list_last(wd->items));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((it) && (it2) && (it != it2))
|
||||
{
|
||||
it->selected = EINA_FALSE;
|
||||
edje_object_signal_emit(it->o_base, "e,state,unselected", "e");
|
||||
edje_object_signal_emit(it->o_icon, "e,state,unselected", "e");
|
||||
it2->selected = EINA_TRUE;
|
||||
edje_object_signal_emit(it2->o_base, "e,state,selected", "e");
|
||||
edje_object_signal_emit(it2->o_icon, "e,state,selected", "e");
|
||||
_item_show(it2);
|
||||
if (it2->func) it->func(it2->data1, it2->data2);
|
||||
_item_unselect(it);
|
||||
_item_select(it2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -460,17 +428,17 @@ static void
|
|||
_e_wid_focus_hook(Evas_Object *obj)
|
||||
{
|
||||
E_Widget_Data *wd;
|
||||
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
if (e_widget_focus_get(obj))
|
||||
{
|
||||
edje_object_signal_emit(wd->o_base, "e,state,focused", "e");
|
||||
evas_object_focus_set(obj, 1);
|
||||
evas_object_focus_set(obj, EINA_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
edje_object_signal_emit(wd->o_base, "e,state,unfocused", "e");
|
||||
evas_object_focus_set(obj, 0);
|
||||
evas_object_focus_set(obj, EINA_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,10 +453,27 @@ _item_show(Item *it)
|
|||
{
|
||||
E_Widget_Data *wd;
|
||||
Evas_Coord x, y, w, h, bx, by;
|
||||
|
||||
|
||||
wd = e_widget_data_get(it->o_toolbar);
|
||||
evas_object_geometry_get(wd->o_box, &bx, &by, NULL, NULL);
|
||||
evas_object_geometry_get(it->o_base, &x, &y, &w, &h);
|
||||
e_scrollframe_child_region_show(wd->o_base, x - bx, y - by, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_select(Item *it)
|
||||
{
|
||||
it->selected = EINA_TRUE;
|
||||
edje_object_signal_emit(it->o_base, "e,state,selected", "e");
|
||||
edje_object_signal_emit(it->o_icon, "e,state,selected", "e");
|
||||
_item_show(it);
|
||||
if (it->func) it->func(it->data1, it->data2);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_unselect(Item *it)
|
||||
{
|
||||
it->selected = EINA_FALSE;
|
||||
edje_object_signal_emit(it->o_base, "e,state,unselected", "e");
|
||||
edje_object_signal_emit(it->o_icon, "e,state,unselected", "e");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue