2007-06-06 20:49:09 -07:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
2005-11-05 04:12:17 -08:00
|
|
|
#include "e.h"
|
|
|
|
|
|
|
|
#define SMART_NAME "e_ilist"
|
|
|
|
#define API_ENTRY E_Smart_Data *sd; sd = evas_object_smart_data_get(obj); if ((!obj) || (!sd) || (evas_object_type_get(obj) && strcmp(evas_object_type_get(obj), SMART_NAME)))
|
|
|
|
#define INTERNAL_ENTRY E_Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return;
|
2007-01-08 11:23:21 -08:00
|
|
|
|
2005-11-05 04:12:17 -08:00
|
|
|
typedef struct _E_Smart_Data E_Smart_Data;
|
2007-01-08 11:23:21 -08:00
|
|
|
struct _E_Smart_Data
|
|
|
|
{
|
|
|
|
Evas_Coord x, y, w, h, iw, ih;
|
2008-04-17 23:23:21 -07:00
|
|
|
Evas_Object *o_smart, *o_box;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *items;
|
2007-01-08 11:23:21 -08:00
|
|
|
int selected;
|
|
|
|
unsigned char selector : 1;
|
|
|
|
unsigned char multi_select : 1;
|
2008-01-23 01:04:56 -08:00
|
|
|
unsigned char on_hold : 1;
|
2008-09-22 06:29:34 -07:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
unsigned int size;
|
|
|
|
Ecore_Timer *timer;
|
|
|
|
}
|
|
|
|
typebuf;
|
2006-01-23 10:47:10 -08:00
|
|
|
};
|
2005-11-05 04:12:17 -08:00
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
static void _e_smart_init (void);
|
|
|
|
static void _e_smart_add (Evas_Object *obj);
|
|
|
|
static void _e_smart_del (Evas_Object *obj);
|
|
|
|
static void _e_smart_show (Evas_Object *obj);
|
|
|
|
static void _e_smart_hide (Evas_Object *obj);
|
|
|
|
static void _e_smart_move (Evas_Object *obj, Evas_Coord x, Evas_Coord y);
|
|
|
|
static void _e_smart_resize (Evas_Object *obj, Evas_Coord w, Evas_Coord h);
|
|
|
|
static void _e_smart_color_set (Evas_Object *obj, int r, int g, int b, int a);
|
|
|
|
static void _e_smart_clip_set (Evas_Object *obj, Evas_Object *clip);
|
|
|
|
static void _e_smart_clip_unset (Evas_Object *obj);
|
|
|
|
static void _e_smart_reconfigure (E_Smart_Data *sd);
|
|
|
|
static void _e_smart_event_mouse_down (void *data, Evas *evas, Evas_Object *obj, void *event_info);
|
|
|
|
static void _e_smart_event_mouse_up (void *data, Evas *evas, Evas_Object *obj, void *event_info);
|
|
|
|
static void _e_smart_event_key_down (void *data, Evas *evas, Evas_Object *obj, void *event_info);
|
2005-11-05 04:12:17 -08:00
|
|
|
|
2008-09-22 06:29:34 -07:00
|
|
|
static void _e_typebuf_add (Evas_Object *obj, const char *s);
|
|
|
|
static void _e_typebuf_match (Evas_Object *obj);
|
|
|
|
static int _e_typebuf_timer_cb (void *data);
|
|
|
|
static void _e_typebuf_timer_update (Evas_Object *obj);
|
|
|
|
static void _e_typebuf_timer_delete (Evas_Object *obj);
|
|
|
|
static void _e_typebuf_clean (Evas_Object *obj);
|
|
|
|
|
2005-11-05 04:12:17 -08:00
|
|
|
static Evas_Smart *_e_smart = NULL;
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI Evas_Object *
|
2007-01-08 11:23:21 -08:00
|
|
|
e_ilist_add(Evas *evas)
|
2005-11-05 04:12:17 -08:00
|
|
|
{
|
|
|
|
_e_smart_init();
|
|
|
|
return evas_object_smart_add(evas, _e_smart);
|
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI void
|
2008-01-23 01:04:56 -08:00
|
|
|
e_ilist_append(Evas_Object *obj, Evas_Object *icon, const char *label, int header, void (*func) (void *data, void *data2), void (*func_hilight) (void *data, void *data2), void *data, void *data2)
|
2005-11-05 04:12:17 -08:00
|
|
|
{
|
2007-01-08 11:23:21 -08:00
|
|
|
E_Ilist_Item *si;
|
2005-11-05 04:12:17 -08:00
|
|
|
Evas_Coord mw = 0, mh = 0;
|
2008-08-18 02:39:20 -07:00
|
|
|
int isodd;
|
2008-08-18 05:57:15 -07:00
|
|
|
const char *stacking;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2005-11-05 04:12:17 -08:00
|
|
|
API_ENTRY return;
|
2007-01-08 11:23:21 -08:00
|
|
|
si = E_NEW(E_Ilist_Item, 1);
|
2005-11-05 04:12:17 -08:00
|
|
|
si->sd = sd;
|
2007-01-08 11:23:21 -08:00
|
|
|
si->o_base = edje_object_add(evas_object_evas_get(sd->o_smart));
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
isodd = eina_list_count(sd->items) & 0x1;
|
2007-01-08 11:23:21 -08:00
|
|
|
if (header)
|
2008-08-18 05:57:15 -07:00
|
|
|
{
|
|
|
|
if (isodd)
|
|
|
|
{
|
|
|
|
if (!e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist_header_odd"))
|
|
|
|
e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist_header");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist_header");
|
|
|
|
}
|
2005-11-05 05:45:08 -08:00
|
|
|
else
|
2008-08-18 05:57:15 -07:00
|
|
|
{
|
|
|
|
if (isodd)
|
|
|
|
e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist_odd");
|
|
|
|
else
|
|
|
|
e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist");
|
|
|
|
}
|
2007-01-08 11:23:21 -08:00
|
|
|
if (label)
|
|
|
|
edje_object_part_text_set(si->o_base, "e.text.label", label);
|
|
|
|
si->o_icon = icon;
|
|
|
|
if (si->o_icon)
|
2005-11-05 04:12:17 -08:00
|
|
|
{
|
2007-01-08 11:23:21 -08:00
|
|
|
edje_extern_object_min_size_set(si->o_icon, sd->iw, sd->ih);
|
|
|
|
edje_object_part_swallow(si->o_base, "e.swallow.icon", si->o_icon);
|
|
|
|
evas_object_show(si->o_icon);
|
2005-11-05 04:12:17 -08:00
|
|
|
}
|
2007-01-08 11:23:21 -08:00
|
|
|
si->func = func;
|
2006-01-21 02:06:13 -08:00
|
|
|
si->func_hilight = func_hilight;
|
2005-11-05 04:12:17 -08:00
|
|
|
si->data = data;
|
2005-11-05 05:54:43 -08:00
|
|
|
si->data2 = data2;
|
2006-03-27 06:46:26 -08:00
|
|
|
si->header = header;
|
2008-10-22 04:49:33 -07:00
|
|
|
sd->items = eina_list_append(sd->items, si);
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
edje_object_size_min_calc(si->o_base, &mw, &mh);
|
|
|
|
e_box_freeze(sd->o_box);
|
|
|
|
e_box_pack_end(sd->o_box, si->o_base);
|
|
|
|
e_box_pack_options_set(si->o_base, 1, 1, 1, 1, 0.5, 0.5,
|
|
|
|
mw, mh, 99999, 99999);
|
2008-08-18 05:57:15 -07:00
|
|
|
stacking = edje_object_data_get(si->o_base, "stacking");
|
|
|
|
if (stacking)
|
|
|
|
{
|
|
|
|
if (!strcmp(stacking, "below")) evas_object_lower(si->o_base);
|
|
|
|
else if (!strcmp(stacking, "above")) evas_object_raise(si->o_base);
|
|
|
|
}
|
2007-01-08 11:23:21 -08:00
|
|
|
e_box_thaw(sd->o_box);
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
evas_object_lower(sd->o_box);
|
|
|
|
evas_object_event_callback_add(si->o_base, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_e_smart_event_mouse_down, si);
|
|
|
|
evas_object_event_callback_add(si->o_base, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_e_smart_event_mouse_up, si);
|
|
|
|
evas_object_show(si->o_base);
|
|
|
|
}
|
|
|
|
|
2007-07-10 04:15:34 -07:00
|
|
|
EAPI void
|
|
|
|
e_ilist_append_relative(Evas_Object *obj, Evas_Object *icon, const char *label, int header, void (*func) (void *data, void *data2), void (*func_hilight) (void *data, void *data2), void *data, void *data2, int relative)
|
|
|
|
{
|
|
|
|
E_Ilist_Item *si, *ri;
|
|
|
|
Evas_Coord mw = 0, mh = 0;
|
2008-08-18 02:39:20 -07:00
|
|
|
int isodd;
|
2008-08-18 05:57:15 -07:00
|
|
|
const char *stacking;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-07-10 04:15:34 -07:00
|
|
|
API_ENTRY return;
|
|
|
|
si = E_NEW(E_Ilist_Item, 1);
|
|
|
|
si->sd = sd;
|
|
|
|
si->o_base = edje_object_add(evas_object_evas_get(sd->o_smart));
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
isodd = eina_list_count(sd->items) & 0x1;
|
2007-07-10 04:15:34 -07:00
|
|
|
if (header)
|
2008-08-18 05:57:15 -07:00
|
|
|
{
|
|
|
|
if (isodd)
|
|
|
|
{
|
|
|
|
if (!e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist_header_odd"))
|
|
|
|
e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist_header");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist_header");
|
|
|
|
}
|
2007-07-10 04:15:34 -07:00
|
|
|
else
|
2008-08-18 05:57:15 -07:00
|
|
|
{
|
|
|
|
if (isodd)
|
|
|
|
e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist_odd");
|
|
|
|
else
|
|
|
|
e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist");
|
|
|
|
}
|
2007-07-10 04:15:34 -07:00
|
|
|
if (label)
|
|
|
|
edje_object_part_text_set(si->o_base, "e.text.label", label);
|
|
|
|
si->o_icon = icon;
|
|
|
|
if (si->o_icon)
|
|
|
|
{
|
|
|
|
edje_extern_object_min_size_set(si->o_icon, sd->iw, sd->ih);
|
|
|
|
edje_object_part_swallow(si->o_base, "e.swallow.icon", si->o_icon);
|
|
|
|
evas_object_show(si->o_icon);
|
|
|
|
}
|
|
|
|
si->func = func;
|
|
|
|
si->func_hilight = func_hilight;
|
|
|
|
si->data = data;
|
|
|
|
si->data2 = data2;
|
|
|
|
si->header = header;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
ri = eina_list_nth(sd->items, relative);
|
2007-07-10 04:15:34 -07:00
|
|
|
if (ri)
|
2008-10-22 04:49:33 -07:00
|
|
|
sd->items = eina_list_append_relative(sd->items, si, ri);
|
2007-07-10 04:15:34 -07:00
|
|
|
else
|
2008-10-22 04:49:33 -07:00
|
|
|
sd->items = eina_list_append(sd->items, si);
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-07-10 04:15:34 -07:00
|
|
|
edje_object_size_min_calc(si->o_base, &mw, &mh);
|
|
|
|
e_box_freeze(sd->o_box);
|
|
|
|
if (ri)
|
|
|
|
e_box_pack_after(sd->o_box, si->o_base, ri->o_base);
|
|
|
|
else
|
|
|
|
e_box_pack_end(sd->o_box, si->o_base);
|
|
|
|
e_box_pack_options_set(si->o_base, 1, 1, 1, 1, 0.5, 0.5,
|
|
|
|
mw, mh, 99999, 99999);
|
2008-08-18 05:57:15 -07:00
|
|
|
stacking = edje_object_data_get(si->o_base, "stacking");
|
|
|
|
if (stacking)
|
|
|
|
{
|
|
|
|
if (!strcmp(stacking, "below")) evas_object_lower(si->o_base);
|
|
|
|
else if (!strcmp(stacking, "above")) evas_object_raise(si->o_base);
|
|
|
|
}
|
2007-07-10 04:15:34 -07:00
|
|
|
e_box_thaw(sd->o_box);
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-07-10 04:15:34 -07:00
|
|
|
evas_object_lower(sd->o_box);
|
|
|
|
evas_object_event_callback_add(si->o_base, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_e_smart_event_mouse_down, si);
|
|
|
|
evas_object_event_callback_add(si->o_base, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_e_smart_event_mouse_up, si);
|
|
|
|
evas_object_show(si->o_base);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_ilist_prepend(Evas_Object *obj, Evas_Object *icon, const char *label, int header, void (*func) (void *data, void *data2), void (*func_hilight) (void *data, void *data2), void *data, void *data2)
|
|
|
|
{
|
|
|
|
E_Ilist_Item *si;
|
|
|
|
Evas_Coord mw = 0, mh = 0;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-07-10 04:15:34 -07:00
|
|
|
API_ENTRY return;
|
|
|
|
si = E_NEW(E_Ilist_Item, 1);
|
|
|
|
si->sd = sd;
|
|
|
|
si->o_base = edje_object_add(evas_object_evas_get(sd->o_smart));
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-07-10 04:15:34 -07:00
|
|
|
if (header)
|
|
|
|
e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist_header");
|
2008-10-22 04:49:33 -07:00
|
|
|
else if (eina_list_count(sd->items) & 0x1)
|
2007-07-10 04:15:34 -07:00
|
|
|
e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist_odd");
|
|
|
|
else
|
|
|
|
e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist");
|
|
|
|
if (label)
|
|
|
|
edje_object_part_text_set(si->o_base, "e.text.label", label);
|
|
|
|
si->o_icon = icon;
|
|
|
|
if (si->o_icon)
|
|
|
|
{
|
|
|
|
edje_extern_object_min_size_set(si->o_icon, sd->iw, sd->ih);
|
|
|
|
edje_object_part_swallow(si->o_base, "e.swallow.icon", si->o_icon);
|
|
|
|
evas_object_show(si->o_icon);
|
|
|
|
}
|
|
|
|
si->func = func;
|
|
|
|
si->func_hilight = func_hilight;
|
|
|
|
si->data = data;
|
|
|
|
si->data2 = data2;
|
|
|
|
si->header = header;
|
2008-10-22 04:49:33 -07:00
|
|
|
sd->items = eina_list_prepend(sd->items, si);
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-07-10 04:15:34 -07:00
|
|
|
edje_object_size_min_calc(si->o_base, &mw, &mh);
|
|
|
|
e_box_freeze(sd->o_box);
|
|
|
|
e_box_pack_start(sd->o_box, si->o_base);
|
|
|
|
e_box_pack_options_set(si->o_base, 1, 1, 1, 1, 0.5, 0.5,
|
|
|
|
mw, mh, 99999, 99999);
|
|
|
|
e_box_thaw(sd->o_box);
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-07-10 04:15:34 -07:00
|
|
|
evas_object_lower(sd->o_box);
|
|
|
|
evas_object_event_callback_add(si->o_base, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_e_smart_event_mouse_down, si);
|
|
|
|
evas_object_event_callback_add(si->o_base, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_e_smart_event_mouse_up, si);
|
|
|
|
evas_object_show(si->o_base);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_ilist_prepend_relative(Evas_Object *obj, Evas_Object *icon, const char *label, int header, void (*func) (void *data, void *data2), void (*func_hilight) (void *data, void *data2), void *data, void *data2, int relative)
|
|
|
|
{
|
|
|
|
E_Ilist_Item *si, *ri;
|
|
|
|
Evas_Coord mw = 0, mh = 0;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-07-10 04:15:34 -07:00
|
|
|
API_ENTRY return;
|
|
|
|
si = E_NEW(E_Ilist_Item, 1);
|
|
|
|
si->sd = sd;
|
|
|
|
si->o_base = edje_object_add(evas_object_evas_get(sd->o_smart));
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-07-10 04:15:34 -07:00
|
|
|
if (header)
|
|
|
|
e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist_header");
|
2008-10-22 04:49:33 -07:00
|
|
|
else if (eina_list_count(sd->items) & 0x1)
|
2007-07-10 04:15:34 -07:00
|
|
|
e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist_odd");
|
|
|
|
else
|
|
|
|
e_theme_edje_object_set(si->o_base, "base/theme/widgets",
|
|
|
|
"e/widgets/ilist");
|
|
|
|
if (label)
|
|
|
|
edje_object_part_text_set(si->o_base, "e.text.label", label);
|
|
|
|
si->o_icon = icon;
|
|
|
|
if (si->o_icon)
|
|
|
|
{
|
|
|
|
edje_extern_object_min_size_set(si->o_icon, sd->iw, sd->ih);
|
|
|
|
edje_object_part_swallow(si->o_base, "e.swallow.icon", si->o_icon);
|
|
|
|
evas_object_show(si->o_icon);
|
|
|
|
}
|
|
|
|
si->func = func;
|
|
|
|
si->func_hilight = func_hilight;
|
|
|
|
si->data = data;
|
|
|
|
si->data2 = data2;
|
|
|
|
si->header = header;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
ri = eina_list_nth(sd->items, relative);
|
2007-07-10 04:15:34 -07:00
|
|
|
if (ri)
|
2008-10-22 04:49:33 -07:00
|
|
|
sd->items = eina_list_prepend_relative(sd->items, si, ri);
|
2007-07-10 04:15:34 -07:00
|
|
|
else
|
2008-10-22 04:49:33 -07:00
|
|
|
sd->items = eina_list_prepend(sd->items, si);
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-07-10 04:15:34 -07:00
|
|
|
edje_object_size_min_calc(si->o_base, &mw, &mh);
|
|
|
|
e_box_freeze(sd->o_box);
|
|
|
|
if (ri)
|
|
|
|
e_box_pack_before(sd->o_box, si->o_base, ri->o_base);
|
|
|
|
else
|
|
|
|
e_box_pack_end(sd->o_box, si->o_base);
|
|
|
|
e_box_pack_options_set(si->o_base, 1, 1, 1, 1, 0.5, 0.5,
|
|
|
|
mw, mh, 99999, 99999);
|
|
|
|
e_box_thaw(sd->o_box);
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-07-10 04:15:34 -07:00
|
|
|
evas_object_lower(sd->o_box);
|
|
|
|
evas_object_event_callback_add(si->o_base, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_e_smart_event_mouse_down, si);
|
|
|
|
evas_object_event_callback_add(si->o_base, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_e_smart_event_mouse_up, si);
|
|
|
|
evas_object_show(si->o_base);
|
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI void
|
|
|
|
e_ilist_clear(Evas_Object *obj)
|
|
|
|
{
|
2005-11-05 04:12:17 -08:00
|
|
|
API_ENTRY return;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-05-09 05:54:57 -07:00
|
|
|
e_ilist_freeze(obj);
|
2007-01-08 11:23:21 -08:00
|
|
|
while (sd->items)
|
2005-11-05 04:12:17 -08:00
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
|
|
|
if (!(si = sd->items->data)) continue;
|
2008-10-22 04:49:33 -07:00
|
|
|
sd->items = eina_list_remove_list(sd->items, sd->items);
|
2007-01-08 11:23:21 -08:00
|
|
|
if (si->o_icon) evas_object_del(si->o_icon);
|
|
|
|
evas_object_del(si->o_base);
|
|
|
|
E_FREE(si);
|
2005-11-05 04:12:17 -08:00
|
|
|
}
|
2007-05-09 05:54:57 -07:00
|
|
|
e_ilist_thaw(obj);
|
2007-01-08 11:23:21 -08:00
|
|
|
sd->selected = -1;
|
2005-11-05 04:12:17 -08:00
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI void
|
|
|
|
e_ilist_freeze(Evas_Object *obj)
|
2005-11-05 04:12:17 -08:00
|
|
|
{
|
2007-01-08 11:23:21 -08:00
|
|
|
API_ENTRY return;
|
|
|
|
e_box_freeze(sd->o_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_ilist_thaw(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
API_ENTRY return;
|
|
|
|
e_box_thaw(sd->o_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
e_ilist_count(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
API_ENTRY return 0;
|
2008-10-22 04:49:33 -07:00
|
|
|
return eina_list_count(sd->items);
|
2007-01-08 11:23:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
e_ilist_selector_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
API_ENTRY return 0;
|
|
|
|
return sd->selector;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_ilist_selector_set(Evas_Object *obj, int selector)
|
|
|
|
{
|
|
|
|
API_ENTRY return;
|
|
|
|
sd->selector = selector;
|
2005-11-05 04:12:17 -08:00
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI int
|
|
|
|
e_ilist_multi_select_get(Evas_Object *obj)
|
2006-09-03 01:51:32 -07:00
|
|
|
{
|
2007-01-08 11:23:21 -08:00
|
|
|
API_ENTRY return 0;
|
|
|
|
return sd->multi_select;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_ilist_multi_select_set(Evas_Object *obj, int multi)
|
|
|
|
{
|
|
|
|
API_ENTRY return;
|
|
|
|
sd->multi_select = multi;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_ilist_min_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
|
|
|
|
{
|
|
|
|
API_ENTRY return;
|
|
|
|
e_box_min_size_get(sd->o_box, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_ilist_unselect(Evas_Object *obj)
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l = NULL;
|
2008-08-18 05:57:15 -07:00
|
|
|
const char *stacking, *selectraise;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2006-09-03 01:51:32 -07:00
|
|
|
API_ENTRY return;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2006-09-03 01:51:32 -07:00
|
|
|
if (!sd->items) return;
|
2007-01-08 11:23:21 -08:00
|
|
|
if (sd->selected < 0) return;
|
|
|
|
for (l = sd->items; l; l = l->next)
|
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
|
|
|
if (!(si = l->data)) continue;
|
2007-01-08 11:23:21 -08:00
|
|
|
if (!si->selected) continue;
|
|
|
|
edje_object_signal_emit(si->o_base, "e,state,unselected", "e");
|
2007-08-15 04:31:36 -07:00
|
|
|
si->selected = 0;
|
2008-08-18 05:57:15 -07:00
|
|
|
stacking = edje_object_data_get(si->o_base, "stacking");
|
|
|
|
selectraise = edje_object_data_get(si->o_base, "selectraise");
|
|
|
|
if ((selectraise) && (!strcmp(selectraise, "on")))
|
|
|
|
{
|
|
|
|
if ((stacking) && (!strcmp(stacking, "below")))
|
|
|
|
evas_object_lower(si->o_base);
|
|
|
|
}
|
2007-01-08 11:23:21 -08:00
|
|
|
}
|
2006-09-03 01:51:32 -07:00
|
|
|
sd->selected = -1;
|
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI void
|
|
|
|
e_ilist_selected_set(Evas_Object *obj, int n)
|
2005-12-22 13:08:34 -08:00
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l = NULL;
|
2007-01-08 11:23:21 -08:00
|
|
|
int i;
|
2008-08-18 05:57:15 -07:00
|
|
|
const char *stacking, *selectraise;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
API_ENTRY return;
|
|
|
|
if (!sd->items) return;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
i = eina_list_count(sd->items);
|
2007-01-08 11:23:21 -08:00
|
|
|
if (n >= i) n = i - 1;
|
|
|
|
else if (n < 0) n = 0;
|
|
|
|
|
|
|
|
for (l = sd->items; l; l = l->next)
|
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
if (!(si = l->data)) continue;
|
|
|
|
if ((!si->selected) || (si->header)) continue;
|
2007-01-08 11:23:21 -08:00
|
|
|
edje_object_signal_emit(si->o_base, "e,state,unselected", "e");
|
|
|
|
si->selected = 0;
|
2008-08-18 05:57:15 -07:00
|
|
|
stacking = edje_object_data_get(si->o_base, "stacking");
|
|
|
|
selectraise = edje_object_data_get(si->o_base, "selectraise");
|
|
|
|
if ((selectraise) && (!strcmp(selectraise, "on")))
|
|
|
|
{
|
|
|
|
if ((stacking) && (!strcmp(stacking, "below")))
|
|
|
|
evas_object_lower(si->o_base);
|
|
|
|
}
|
2007-01-08 11:23:21 -08:00
|
|
|
}
|
|
|
|
sd->selected = -1;
|
2008-10-22 04:49:33 -07:00
|
|
|
if (!(si = eina_list_nth(sd->items, n))) return;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
|
|
|
/* NB: Remove this if headers ever become selectable */
|
2008-10-19 06:34:47 -07:00
|
|
|
while (si->header && ((++ n) < i))
|
2008-10-22 04:49:33 -07:00
|
|
|
if (!(si = eina_list_nth(sd->items, n))) return;
|
2008-10-19 06:34:47 -07:00
|
|
|
while (si->header && ((-- n) >= 0))
|
2008-10-22 04:49:33 -07:00
|
|
|
if (!(si = eina_list_nth(sd->items, n))) return;
|
2008-04-17 23:23:21 -07:00
|
|
|
if (si->header) return;
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
si->selected = 1;
|
2008-08-18 05:57:15 -07:00
|
|
|
selectraise = edje_object_data_get(si->o_base, "selectraise");
|
|
|
|
if ((selectraise) && (!strcmp(selectraise, "on")))
|
|
|
|
evas_object_raise(si->o_base);
|
2007-01-08 11:23:21 -08:00
|
|
|
edje_object_signal_emit(si->o_base, "e,state,selected", "e");
|
2008-08-18 05:57:15 -07:00
|
|
|
sd->selected = n;
|
2007-01-08 11:23:21 -08:00
|
|
|
if (si->func_hilight) si->func_hilight(si->data, si->data2);
|
|
|
|
if (sd->selector) return;
|
2008-01-23 01:04:56 -08:00
|
|
|
if (!sd->on_hold)
|
|
|
|
{
|
|
|
|
if (si->func) si->func(si->data, si->data2);
|
|
|
|
}
|
2005-12-22 13:08:34 -08:00
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI int
|
|
|
|
e_ilist_selected_get(Evas_Object *obj)
|
2006-04-12 17:01:15 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l = NULL;
|
2007-01-08 18:29:51 -08:00
|
|
|
int i, j;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
API_ENTRY return -1;
|
|
|
|
if (!sd->items) return -1;
|
2007-01-08 18:29:51 -08:00
|
|
|
if (!sd->multi_select)
|
|
|
|
return sd->selected;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
j = -1;
|
|
|
|
for (i = 0, l = sd->items; l; l = l->next, i++)
|
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *li = NULL;
|
|
|
|
|
|
|
|
if (!(li = l->data)) continue;
|
2007-01-08 18:29:51 -08:00
|
|
|
if (li->selected) j = i;
|
|
|
|
}
|
|
|
|
return j;
|
|
|
|
}
|
2007-01-08 11:23:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const char *
|
|
|
|
e_ilist_selected_label_get(Evas_Object *obj)
|
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
2006-04-12 17:01:15 -07:00
|
|
|
API_ENTRY return NULL;
|
|
|
|
if (!sd->items) return NULL;
|
2007-01-08 11:23:21 -08:00
|
|
|
if (sd->multi_select) return NULL;
|
|
|
|
if (sd->selected < 0) return NULL;
|
2008-10-22 04:49:33 -07:00
|
|
|
si = eina_list_nth(sd->items, sd->selected);
|
2007-01-08 11:23:21 -08:00
|
|
|
if (si) return edje_object_part_text_get(si->o_base, "e.text.label");
|
2006-04-12 17:01:15 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void *
|
2007-01-08 11:23:21 -08:00
|
|
|
e_ilist_selected_data_get(Evas_Object *obj)
|
2005-11-05 04:12:17 -08:00
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
2005-11-05 04:12:17 -08:00
|
|
|
API_ENTRY return NULL;
|
|
|
|
if (!sd->items) return NULL;
|
2007-01-08 11:23:21 -08:00
|
|
|
if (sd->multi_select) return NULL;
|
|
|
|
if (sd->selected < 0) return NULL;
|
2008-10-22 04:49:33 -07:00
|
|
|
si = eina_list_nth(sd->items, sd->selected);
|
2005-11-05 04:12:17 -08:00
|
|
|
if (si) return si->data;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void *
|
2007-01-08 11:23:21 -08:00
|
|
|
e_ilist_selected_data2_get(Evas_Object *obj)
|
2005-11-05 05:54:43 -08:00
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
2005-11-05 05:54:43 -08:00
|
|
|
API_ENTRY return NULL;
|
|
|
|
if (!sd->items) return NULL;
|
2007-01-08 11:23:21 -08:00
|
|
|
if (sd->multi_select) return NULL;
|
|
|
|
if (sd->selected < 0) return NULL;
|
2008-10-22 04:49:33 -07:00
|
|
|
si = eina_list_nth(sd->items, sd->selected);
|
2005-11-05 05:54:43 -08:00
|
|
|
if (si) return si->data2;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI Evas_Object *
|
|
|
|
e_ilist_selected_icon_get(Evas_Object *obj)
|
2005-11-05 04:12:17 -08:00
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
API_ENTRY return NULL;
|
|
|
|
if (!sd->items) return NULL;
|
|
|
|
if (sd->multi_select) return NULL;
|
|
|
|
if (sd->selected < 0) return NULL;
|
2008-10-22 04:49:33 -07:00
|
|
|
si = eina_list_nth(sd->items, sd->selected);
|
2007-01-08 11:23:21 -08:00
|
|
|
if (si) return si->o_icon;
|
|
|
|
return NULL;
|
2005-11-05 04:12:17 -08:00
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI void
|
|
|
|
e_ilist_selected_geometry_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
|
2005-11-11 21:27:58 -08:00
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
2005-11-11 21:27:58 -08:00
|
|
|
API_ENTRY return;
|
2007-01-08 11:23:21 -08:00
|
|
|
if (!sd->items) return;
|
|
|
|
if (sd->selected < 0) return;
|
2008-10-22 04:49:33 -07:00
|
|
|
if (!(si = eina_list_nth(sd->items, sd->selected))) return;
|
2007-01-08 11:23:21 -08:00
|
|
|
evas_object_geometry_get(si->o_base, x, y, w, h);
|
|
|
|
*x -= sd->x;
|
|
|
|
*y -= sd->y;
|
2005-11-11 21:27:58 -08:00
|
|
|
}
|
|
|
|
|
2007-07-15 16:39:28 -07:00
|
|
|
EAPI int
|
|
|
|
e_ilist_selected_count_get(Evas_Object *obj)
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l = NULL;
|
2007-07-15 16:39:28 -07:00
|
|
|
int count = 0;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-07-15 16:39:28 -07:00
|
|
|
API_ENTRY return 0;
|
|
|
|
if (!sd->items) return 0;
|
|
|
|
for (l = sd->items; l; l = l->next)
|
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
|
|
|
if (!(si = l->data)) continue;
|
2007-07-15 16:39:28 -07:00
|
|
|
if (si->selected) count++;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI void
|
|
|
|
e_ilist_remove_num(Evas_Object *obj, int n)
|
2005-12-22 13:08:34 -08:00
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
2005-12-22 13:08:34 -08:00
|
|
|
API_ENTRY return;
|
|
|
|
if (!sd->items) return;
|
2008-10-22 04:49:33 -07:00
|
|
|
if (!(si = eina_list_nth(sd->items, n))) return;
|
|
|
|
sd->items = eina_list_remove(sd->items, si);
|
2007-01-08 11:23:21 -08:00
|
|
|
if (sd->selected == n) sd->selected = -1;
|
|
|
|
if (si->o_icon) evas_object_del(si->o_icon);
|
|
|
|
evas_object_del(si->o_base);
|
|
|
|
E_FREE(si);
|
2005-12-22 13:08:34 -08:00
|
|
|
}
|
|
|
|
|
2006-04-04 07:00:19 -07:00
|
|
|
EAPI const char *
|
2007-01-08 11:23:21 -08:00
|
|
|
e_ilist_nth_label_get(Evas_Object *obj, int n)
|
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
2006-04-04 07:00:19 -07:00
|
|
|
API_ENTRY return NULL;
|
|
|
|
if (!sd->items) return NULL;
|
2008-10-22 04:49:33 -07:00
|
|
|
si = eina_list_nth(sd->items, n);
|
2007-01-08 11:23:21 -08:00
|
|
|
if (si) return edje_object_part_text_get(si->o_base, "e.text.label");
|
2006-04-04 07:00:19 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI void
|
|
|
|
e_ilist_nth_label_set(Evas_Object *obj, int n, const char *label)
|
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
|
|
|
/* check for a NULL label first...simplier, faster check then doing
|
|
|
|
* API_ENTRY check first */
|
|
|
|
if (!label) return;
|
2006-04-04 07:00:19 -07:00
|
|
|
API_ENTRY return;
|
|
|
|
if (!sd->items) return;
|
2008-10-22 04:49:33 -07:00
|
|
|
si = eina_list_nth(sd->items, n);
|
2007-01-08 11:23:21 -08:00
|
|
|
if (si) edje_object_part_text_set(si->o_base, "e.text.label", label);
|
2006-04-04 07:00:19 -07:00
|
|
|
}
|
|
|
|
|
2006-04-12 17:01:15 -07:00
|
|
|
EAPI Evas_Object *
|
2007-01-08 11:23:21 -08:00
|
|
|
e_ilist_nth_icon_get(Evas_Object *obj, int n)
|
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
2006-04-12 17:01:15 -07:00
|
|
|
API_ENTRY return NULL;
|
|
|
|
if (!sd->items) return NULL;
|
2008-10-22 04:49:33 -07:00
|
|
|
si = eina_list_nth(sd->items, n);
|
2007-01-08 11:23:21 -08:00
|
|
|
if (si) return si->o_icon;
|
2006-04-12 17:01:15 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI void
|
|
|
|
e_ilist_nth_icon_set(Evas_Object *obj, int n, Evas_Object *icon)
|
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
2006-04-12 17:01:15 -07:00
|
|
|
API_ENTRY return;
|
|
|
|
if (!sd->items) return;
|
2008-10-22 04:49:33 -07:00
|
|
|
if (!(si = eina_list_nth(sd->items, n))) return;
|
2007-01-08 11:23:21 -08:00
|
|
|
if (si->o_icon)
|
|
|
|
{
|
|
|
|
edje_object_part_unswallow(si->o_base, si->o_icon);
|
|
|
|
evas_object_del(si->o_icon);
|
|
|
|
}
|
|
|
|
si->o_icon = icon;
|
|
|
|
if (si->o_icon)
|
|
|
|
{
|
|
|
|
edje_extern_object_min_size_set(si->o_icon, sd->iw, sd->ih);
|
|
|
|
edje_object_part_swallow(si->o_base, "e.swallow.icon", si->o_icon);
|
|
|
|
evas_object_show(si->o_icon);
|
2006-04-12 17:01:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI int
|
|
|
|
e_ilist_nth_is_header(Evas_Object *obj, int n)
|
2006-01-23 10:47:10 -08:00
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
2006-01-23 10:47:10 -08:00
|
|
|
API_ENTRY return 0;
|
2007-01-08 11:23:21 -08:00
|
|
|
if (!sd->items) return 0;
|
2008-10-22 04:49:33 -07:00
|
|
|
si = eina_list_nth(sd->items, n);
|
2007-01-08 11:23:21 -08:00
|
|
|
if (si) return si->header;
|
|
|
|
return 0;
|
2006-01-23 10:47:10 -08:00
|
|
|
}
|
|
|
|
|
2007-06-06 20:49:09 -07:00
|
|
|
EAPI void
|
|
|
|
e_ilist_nth_geometry_get(Evas_Object *obj, int n, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
|
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
2007-06-06 20:49:09 -07:00
|
|
|
|
|
|
|
API_ENTRY return;
|
|
|
|
if (!sd->items) return;
|
2008-10-22 04:49:33 -07:00
|
|
|
if (!(si = eina_list_nth(sd->items, n))) return;
|
2007-06-06 20:49:09 -07:00
|
|
|
evas_object_geometry_get(si->o_base, x, y, w, h);
|
|
|
|
*x -= sd->x;
|
|
|
|
*y -= sd->y;
|
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI void
|
|
|
|
e_ilist_icon_size_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
2006-01-24 20:06:51 -08:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l = NULL;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2006-11-27 06:23:07 -08:00
|
|
|
API_ENTRY return;
|
2007-01-08 11:23:21 -08:00
|
|
|
if ((sd->iw == w) && (sd->ih == h)) return;
|
|
|
|
sd->iw = w;
|
|
|
|
sd->ih = h;
|
|
|
|
for (l = sd->items; l; l = l->next)
|
2006-01-24 20:06:51 -08:00
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
2007-01-08 11:23:21 -08:00
|
|
|
Evas_Coord mw = 0, mh = 0;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
|
|
|
if (!(si = l->data)) continue;
|
2007-01-08 11:23:21 -08:00
|
|
|
if (!si->o_icon) continue;
|
|
|
|
edje_extern_object_min_size_set(si->o_icon, w, h);
|
|
|
|
edje_object_part_swallow(si->o_base, "e.swallow.icon", si->o_icon);
|
|
|
|
edje_object_size_min_calc(si->o_base, &mw, &mh);
|
|
|
|
e_box_pack_options_set(si->o_icon, 1, 1, 1, 0, 0.5, 0.5,
|
|
|
|
mw, mh, 99999, 99999);
|
2006-01-24 20:06:51 -08:00
|
|
|
}
|
|
|
|
}
|
2006-01-23 10:47:10 -08:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
EAPI Eina_List *
|
2007-01-08 11:23:21 -08:00
|
|
|
e_ilist_items_get(Evas_Object *obj)
|
2006-06-08 05:48:36 -07:00
|
|
|
{
|
2007-01-12 05:00:29 -08:00
|
|
|
API_ENTRY return NULL;
|
2007-01-08 11:23:21 -08:00
|
|
|
return sd->items;
|
|
|
|
}
|
2006-06-08 05:48:36 -07:00
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI void
|
|
|
|
e_ilist_multi_select(Evas_Object *obj, int n)
|
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
2007-01-08 11:23:21 -08:00
|
|
|
int i;
|
2008-08-18 05:57:15 -07:00
|
|
|
const char *stacking, *selectraise;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
API_ENTRY return;
|
2008-05-10 00:44:01 -07:00
|
|
|
if ((!sd->items) || (!sd->multi_select)) return;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
i = eina_list_count(sd->items);
|
2007-01-08 11:23:21 -08:00
|
|
|
if (n >= i) n = i - 1;
|
|
|
|
else if (n < 0) n = 0;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
if (!(si = eina_list_nth(sd->items, n))) return;
|
2007-01-08 11:23:21 -08:00
|
|
|
sd->selected = n;
|
2008-10-17 23:27:33 -07:00
|
|
|
selectraise = edje_object_data_get(si->o_base, "selectraise");
|
2007-01-08 11:23:21 -08:00
|
|
|
if (si->selected)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(si->o_base, "e,state,unselected", "e");
|
|
|
|
si->selected = 0;
|
2008-08-18 05:57:15 -07:00
|
|
|
stacking = edje_object_data_get(si->o_base, "stacking");
|
|
|
|
if ((selectraise) && (!strcmp(selectraise, "on")))
|
|
|
|
{
|
|
|
|
if ((stacking) && (!strcmp(stacking, "below")))
|
|
|
|
evas_object_lower(si->o_base);
|
|
|
|
}
|
2007-01-08 18:29:51 -08:00
|
|
|
if (si->func_hilight) si->func_hilight(si->data, si->data2);
|
|
|
|
if (sd->selector) return;
|
2008-01-23 01:04:56 -08:00
|
|
|
if (!sd->on_hold)
|
|
|
|
{
|
|
|
|
if (si->func) si->func(si->data, si->data2);
|
|
|
|
}
|
2007-01-08 11:23:21 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
si->selected = 1;
|
2008-08-18 05:57:15 -07:00
|
|
|
if ((selectraise) && (!strcmp(selectraise, "on")))
|
|
|
|
evas_object_raise(si->o_base);
|
2007-01-08 11:23:21 -08:00
|
|
|
edje_object_signal_emit(si->o_base, "e,state,selected", "e");
|
|
|
|
if (si->func_hilight) si->func_hilight(si->data, si->data2);
|
|
|
|
if (sd->selector) return;
|
2008-01-23 01:04:56 -08:00
|
|
|
if (!sd->on_hold)
|
|
|
|
{
|
|
|
|
if (si->func) si->func(si->data, si->data2);
|
|
|
|
}
|
2006-06-08 05:48:36 -07:00
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
EAPI void
|
|
|
|
e_ilist_range_select(Evas_Object *obj, int n)
|
2006-11-27 06:23:07 -08:00
|
|
|
{
|
2008-04-17 23:23:21 -07:00
|
|
|
E_Ilist_Item *si = NULL;
|
2007-01-08 11:23:21 -08:00
|
|
|
int i, j, dir;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2006-11-27 06:23:07 -08:00
|
|
|
API_ENTRY return;
|
2008-05-10 00:44:01 -07:00
|
|
|
if ((!sd->items) || (!sd->multi_select)) return;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
i = eina_list_count(sd->items);
|
2007-01-08 11:23:21 -08:00
|
|
|
if (n >= i) n = i - 1;
|
|
|
|
else if (n < 0) n = 0;
|
|
|
|
|
|
|
|
if (n < sd->selected) dir = 0;
|
|
|
|
else dir = 1;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
if (!(si = eina_list_nth(sd->items, n))) return;
|
2007-01-08 11:23:21 -08:00
|
|
|
if (dir == 1)
|
|
|
|
{
|
|
|
|
for (j = (sd->selected + 1); ((j < i) && (j <= n)); j++)
|
|
|
|
e_ilist_multi_select(sd->o_smart, j);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (j = (sd->selected - 1); ((j >= 0) && (j >= n)); j--)
|
|
|
|
e_ilist_multi_select(sd->o_smart, j);
|
|
|
|
}
|
2006-11-27 06:23:07 -08:00
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
/* SMART FUNCTIONS */
|
|
|
|
static void
|
|
|
|
_e_smart_init(void)
|
2006-11-27 06:23:07 -08:00
|
|
|
{
|
2007-01-08 11:23:21 -08:00
|
|
|
if (_e_smart) return;
|
2007-08-04 06:12:43 -07:00
|
|
|
{
|
|
|
|
static const Evas_Smart_Class sc =
|
|
|
|
{
|
|
|
|
SMART_NAME,
|
|
|
|
EVAS_SMART_CLASS_VERSION,
|
|
|
|
_e_smart_add,
|
|
|
|
_e_smart_del,
|
|
|
|
_e_smart_move,
|
|
|
|
_e_smart_resize,
|
|
|
|
_e_smart_show,
|
|
|
|
_e_smart_hide,
|
|
|
|
_e_smart_color_set,
|
|
|
|
_e_smart_clip_set,
|
|
|
|
_e_smart_clip_unset,
|
2008-09-06 18:25:49 -07:00
|
|
|
NULL,
|
2007-08-04 06:12:43 -07:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
_e_smart = evas_smart_class_new(&sc);
|
|
|
|
}
|
2007-01-08 11:23:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_add(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
sd = calloc(1, sizeof(E_Smart_Data));
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_smart_data_set(obj, sd);
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
sd->o_smart = obj;
|
|
|
|
sd->x = sd->y = sd->w = sd->h = 0;
|
|
|
|
sd->iw = sd->ih = 24;
|
|
|
|
sd->selected = -1;
|
|
|
|
sd->multi_select = 0;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-09-22 06:29:34 -07:00
|
|
|
sd->typebuf.buf = NULL;
|
|
|
|
sd->typebuf.size = 0;
|
|
|
|
sd->typebuf.timer = NULL;
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
sd->o_box = e_box_add(evas_object_evas_get(obj));
|
|
|
|
e_box_align_set(sd->o_box, 0.0, 0.0);
|
|
|
|
e_box_homogenous_set(sd->o_box, 0);
|
|
|
|
evas_object_smart_member_add(sd->o_box, obj);
|
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
|
|
|
|
_e_smart_event_key_down, sd);
|
|
|
|
evas_object_propagate_events_set(obj, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_del(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
2008-09-22 06:29:34 -07:00
|
|
|
|
|
|
|
_e_typebuf_clean(obj);
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
e_ilist_clear(obj);
|
|
|
|
evas_object_del(sd->o_box);
|
|
|
|
free(sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_show(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
|
|
|
evas_object_show(sd->o_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_hide(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
|
|
|
evas_object_hide(sd->o_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
|
|
|
if ((sd->x == x) && (sd->y == y)) return;
|
|
|
|
sd->x = x;
|
|
|
|
sd->y = y;
|
|
|
|
_e_smart_reconfigure(sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
|
|
|
if ((sd->w == w) && (sd->h == h)) return;
|
|
|
|
sd->w = w;
|
|
|
|
sd->h = h;
|
|
|
|
_e_smart_reconfigure(sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
|
|
|
evas_object_color_set(sd->o_box, r, g, b, a);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
|
|
|
evas_object_clip_set(sd->o_box, clip);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_clip_unset(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
|
|
|
evas_object_clip_unset(sd->o_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_reconfigure(E_Smart_Data *sd)
|
|
|
|
{
|
|
|
|
evas_object_move(sd->o_box, sd->x, sd->y);
|
|
|
|
evas_object_resize(sd->o_box, sd->w, sd->h);
|
2006-11-27 06:23:07 -08:00
|
|
|
}
|
|
|
|
|
2005-11-05 04:12:17 -08:00
|
|
|
static void
|
2007-01-08 11:23:21 -08:00
|
|
|
_e_smart_event_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
2005-11-05 04:12:17 -08:00
|
|
|
{
|
2007-01-08 11:23:21 -08:00
|
|
|
E_Smart_Data *sd;
|
2005-11-05 04:12:17 -08:00
|
|
|
Evas_Event_Mouse_Down *ev;
|
2007-01-08 11:23:21 -08:00
|
|
|
E_Ilist_Item *si;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l = NULL;
|
2005-11-05 04:12:17 -08:00
|
|
|
int i;
|
2006-06-08 19:53:16 -07:00
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
ev = event_info;
|
|
|
|
si = data;
|
|
|
|
sd = si->sd;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-01-23 01:04:56 -08:00
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = 1;
|
|
|
|
else sd->on_hold = 0;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
|
|
|
/* NB: Remove if headers ever become selectable */
|
2006-06-08 19:53:16 -07:00
|
|
|
if (si->header) return;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
if (!sd->items) return;
|
|
|
|
for (i = 0, l = sd->items; l; l = l->next, i++)
|
2005-11-05 04:12:17 -08:00
|
|
|
{
|
2007-01-08 11:23:21 -08:00
|
|
|
if (l->data == si)
|
2005-11-05 04:12:17 -08:00
|
|
|
{
|
2007-01-08 11:23:21 -08:00
|
|
|
if (!sd->multi_select)
|
|
|
|
e_ilist_selected_set(sd->o_smart, i);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
|
|
|
|
e_ilist_range_select(sd->o_smart, i);
|
|
|
|
else if (evas_key_modifier_is_set(ev->modifiers, "Control"))
|
|
|
|
e_ilist_multi_select(sd->o_smart, i);
|
|
|
|
else
|
|
|
|
e_ilist_selected_set(sd->o_smart, i);
|
|
|
|
}
|
2005-11-05 04:12:17 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2006-10-27 20:53:22 -07:00
|
|
|
if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
|
2007-01-08 11:23:21 -08:00
|
|
|
evas_object_smart_callback_call(sd->o_smart, "selected", NULL);
|
2005-11-05 04:12:17 -08:00
|
|
|
}
|
|
|
|
|
2005-11-11 21:27:58 -08:00
|
|
|
static void
|
2007-01-08 11:23:21 -08:00
|
|
|
_e_smart_event_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
2005-11-11 21:27:58 -08:00
|
|
|
{
|
2007-01-08 11:23:21 -08:00
|
|
|
E_Smart_Data *sd;
|
2005-11-11 21:27:58 -08:00
|
|
|
Evas_Event_Mouse_Up *ev;
|
2007-01-08 11:23:21 -08:00
|
|
|
E_Ilist_Item *si;
|
2006-06-08 19:53:16 -07:00
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
ev = event_info;
|
|
|
|
si = data;
|
|
|
|
sd = si->sd;
|
2008-01-23 01:04:56 -08:00
|
|
|
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = 1;
|
|
|
|
else sd->on_hold = 0;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
|
|
|
/* NB: Remove if headers ever become selectable */
|
2006-06-08 19:53:16 -07:00
|
|
|
if (si->header) return;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-05-10 00:44:01 -07:00
|
|
|
if ((!sd->items) || (!sd->selector)) return;
|
2008-10-22 04:49:33 -07:00
|
|
|
if (!(si = eina_list_nth(sd->items, sd->selected))) return;
|
2008-01-23 01:04:56 -08:00
|
|
|
if (sd->on_hold)
|
|
|
|
{
|
|
|
|
sd->on_hold = 0;
|
|
|
|
return;
|
|
|
|
}
|
2007-01-08 11:23:21 -08:00
|
|
|
if (si->func) si->func(si->data, si->data2);
|
2005-11-11 21:27:58 -08:00
|
|
|
}
|
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
static void
|
|
|
|
_e_smart_event_key_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
2005-11-05 04:12:17 -08:00
|
|
|
{
|
|
|
|
Evas_Event_Key_Down *ev;
|
|
|
|
E_Smart_Data *sd;
|
2007-01-08 11:23:21 -08:00
|
|
|
E_Ilist_Item *si;
|
|
|
|
int n, ns;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2005-11-05 04:12:17 -08:00
|
|
|
sd = data;
|
|
|
|
ev = event_info;
|
2007-01-08 11:23:21 -08:00
|
|
|
ns = sd->selected;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2008-01-23 01:04:56 -08:00
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = 1;
|
|
|
|
else sd->on_hold = 0;
|
2008-04-17 23:23:21 -07:00
|
|
|
|
2007-01-08 11:23:21 -08:00
|
|
|
if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
|
2005-11-05 04:12:17 -08:00
|
|
|
{
|
2006-04-29 21:31:42 -07:00
|
|
|
n = ns;
|
2006-03-27 06:46:26 -08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (n == 0)
|
|
|
|
{
|
2006-04-29 21:31:42 -07:00
|
|
|
n = ns;
|
2006-03-27 06:46:26 -08:00
|
|
|
break;
|
|
|
|
}
|
2008-04-17 23:23:21 -07:00
|
|
|
--n;
|
2008-10-22 04:49:33 -07:00
|
|
|
si = eina_list_nth(sd->items, n);
|
2006-03-27 06:46:26 -08:00
|
|
|
}
|
|
|
|
while ((si) && (si->header));
|
2007-01-08 11:23:21 -08:00
|
|
|
if (n != ns)
|
|
|
|
{
|
|
|
|
if (!sd->multi_select)
|
|
|
|
e_ilist_selected_set(sd->o_smart, n);
|
|
|
|
else if (evas_key_modifier_is_set(ev->modifiers, "Control"))
|
|
|
|
e_ilist_multi_select(sd->o_smart, n);
|
|
|
|
else if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
|
|
|
|
e_ilist_range_select(sd->o_smart, n);
|
|
|
|
else
|
|
|
|
e_ilist_selected_set(sd->o_smart, n);
|
|
|
|
}
|
2005-11-05 04:12:17 -08:00
|
|
|
}
|
2007-01-08 11:23:21 -08:00
|
|
|
else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
|
2005-11-05 04:12:17 -08:00
|
|
|
{
|
2006-04-29 21:31:42 -07:00
|
|
|
n = ns;
|
2006-03-27 06:46:26 -08:00
|
|
|
do
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
if (n == (eina_list_count(sd->items) - 1))
|
2006-03-27 06:46:26 -08:00
|
|
|
{
|
2006-04-29 21:31:42 -07:00
|
|
|
n = ns;
|
2006-03-27 06:46:26 -08:00
|
|
|
break;
|
|
|
|
}
|
2008-04-17 23:23:21 -07:00
|
|
|
++n;
|
2008-10-22 04:49:33 -07:00
|
|
|
si = eina_list_nth(sd->items, n);
|
2006-03-27 06:46:26 -08:00
|
|
|
}
|
|
|
|
while ((si) && (si->header));
|
2007-01-08 11:23:21 -08:00
|
|
|
if (n != ns)
|
|
|
|
{
|
|
|
|
if (!sd->multi_select)
|
|
|
|
e_ilist_selected_set(sd->o_smart, n);
|
|
|
|
else if (evas_key_modifier_is_set(ev->modifiers, "Control"))
|
|
|
|
e_ilist_multi_select(sd->o_smart, n);
|
|
|
|
else if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
|
|
|
|
e_ilist_range_select(sd->o_smart, n);
|
|
|
|
else
|
|
|
|
e_ilist_selected_set(sd->o_smart, n);
|
|
|
|
}
|
2006-04-29 21:31:42 -07:00
|
|
|
}
|
2007-01-08 11:23:21 -08:00
|
|
|
else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
|
2006-04-29 21:31:42 -07:00
|
|
|
{
|
|
|
|
n = -1;
|
|
|
|
do
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
if (n == (eina_list_count(sd->items) - 1))
|
2006-04-29 21:31:42 -07:00
|
|
|
{
|
|
|
|
n = ns;
|
|
|
|
break;
|
|
|
|
}
|
2008-04-17 23:23:21 -07:00
|
|
|
++n;
|
2008-10-22 04:49:33 -07:00
|
|
|
si = eina_list_nth(sd->items, n);
|
2006-04-29 21:31:42 -07:00
|
|
|
}
|
|
|
|
while ((si) && (si->header));
|
2007-01-08 11:23:21 -08:00
|
|
|
if (n != ns)
|
|
|
|
{
|
|
|
|
if (!sd->multi_select)
|
|
|
|
e_ilist_selected_set(sd->o_smart, n);
|
|
|
|
else if (evas_key_modifier_is_set(ev->modifiers, "Control"))
|
|
|
|
e_ilist_multi_select(sd->o_smart, n);
|
|
|
|
else if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
|
|
|
|
e_ilist_range_select(sd->o_smart, n);
|
|
|
|
else
|
|
|
|
e_ilist_selected_set(sd->o_smart, n);
|
|
|
|
}
|
2006-04-29 21:31:42 -07:00
|
|
|
}
|
2007-01-08 11:23:21 -08:00
|
|
|
else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
|
2006-04-29 21:31:42 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
n = eina_list_count(sd->items);
|
2006-04-29 21:31:42 -07:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (n == 0)
|
|
|
|
{
|
|
|
|
n = ns;
|
|
|
|
break;
|
|
|
|
}
|
2008-04-17 23:23:21 -07:00
|
|
|
--n;
|
2008-10-22 04:49:33 -07:00
|
|
|
si = eina_list_nth(sd->items, n);
|
2006-04-29 21:31:42 -07:00
|
|
|
}
|
|
|
|
while ((si) && (si->header));
|
2007-01-08 11:23:21 -08:00
|
|
|
if (n != ns)
|
|
|
|
{
|
|
|
|
if (!sd->multi_select)
|
|
|
|
e_ilist_selected_set(sd->o_smart, n);
|
|
|
|
else if (evas_key_modifier_is_set(ev->modifiers, "Control"))
|
|
|
|
e_ilist_multi_select(sd->o_smart, n);
|
|
|
|
else if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
|
|
|
|
e_ilist_range_select(sd->o_smart, n);
|
|
|
|
else
|
|
|
|
e_ilist_selected_set(sd->o_smart, n);
|
|
|
|
}
|
2005-11-05 04:12:17 -08:00
|
|
|
}
|
2005-11-11 21:27:58 -08:00
|
|
|
else if ((!strcmp(ev->keyname, "Return")) ||
|
2006-04-29 21:31:42 -07:00
|
|
|
(!strcmp(ev->keyname, "KP_Enter")) ||
|
2008-09-22 06:29:34 -07:00
|
|
|
(!strcmp(ev->keyname, "space") && !sd->typebuf.buf))
|
2005-11-11 21:27:58 -08:00
|
|
|
{
|
2008-01-23 01:04:56 -08:00
|
|
|
if (!sd->on_hold)
|
2005-11-11 21:27:58 -08:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
si = eina_list_nth(sd->items, sd->selected);
|
2008-01-23 01:04:56 -08:00
|
|
|
if (si)
|
|
|
|
{
|
|
|
|
if (si->func) si->func(si->data, si->data2);
|
|
|
|
}
|
2005-11-11 21:27:58 -08:00
|
|
|
}
|
2008-09-22 06:29:34 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(ev->keyname, "Escape"))
|
|
|
|
{
|
|
|
|
_e_typebuf_clean(obj);
|
|
|
|
}
|
|
|
|
else if (strcmp(ev->keyname, "BackSpace") && strcmp(ev->keyname, "Tab") && ev->string)
|
|
|
|
{
|
|
|
|
_e_typebuf_add(obj, ev->string);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-23 01:04:56 -08:00
|
|
|
sd->on_hold = 0;
|
2005-11-05 04:12:17 -08:00
|
|
|
}
|
2008-09-22 06:29:34 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_e_typebuf_add(Evas_Object *obj, const char *s)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
INTERNAL_ENTRY;
|
|
|
|
|
|
|
|
if (!sd->typebuf.buf)
|
|
|
|
{
|
|
|
|
sd->typebuf.buf = malloc(16);
|
|
|
|
if (sd->typebuf.buf)
|
|
|
|
{
|
|
|
|
sd->typebuf.size = 16;
|
|
|
|
sd->typebuf.buf[0] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_e_typebuf_clean(obj);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
len = strlen(sd->typebuf.buf);
|
|
|
|
if (len + strlen(s) + 2 + 1 >= sd->typebuf.size)
|
|
|
|
{
|
|
|
|
sd->typebuf.buf = realloc(sd->typebuf.buf, sd->typebuf.size + strlen(s) + 16);
|
|
|
|
if (sd->typebuf.buf)
|
|
|
|
sd->typebuf.size = sd->typebuf.size + strlen(s) + 16;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_e_typebuf_clean(obj);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
strcat(sd->typebuf.buf, s);
|
|
|
|
|
|
|
|
_e_typebuf_match(obj);
|
|
|
|
_e_typebuf_timer_update(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_typebuf_match(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
char *match;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2008-09-22 06:29:34 -07:00
|
|
|
int n;
|
|
|
|
E_Ilist_Item *si = NULL;
|
|
|
|
|
|
|
|
INTERNAL_ENTRY;
|
|
|
|
|
|
|
|
match = malloc(strlen(sd->typebuf.buf) + 2 + 1);
|
|
|
|
if (!match) return;
|
|
|
|
|
|
|
|
strcpy(match, "*");
|
|
|
|
strcat(match, sd->typebuf.buf);
|
|
|
|
strcat(match, "*");
|
|
|
|
|
|
|
|
l = sd->items;
|
|
|
|
n = 0;
|
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
|
|
|
const char *label = NULL;
|
|
|
|
si = l->data;
|
|
|
|
if (si)
|
|
|
|
{
|
|
|
|
label = edje_object_part_text_get(si->o_base, "e.text.label");
|
|
|
|
|
|
|
|
if (e_util_glob_case_match(label, match))
|
|
|
|
{
|
|
|
|
e_ilist_selected_set(obj, n);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
l = l->next;
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(match);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_e_typebuf_timer_cb(void *data)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
|
|
|
|
_e_typebuf_clean(obj);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_typebuf_timer_update(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
|
|
|
|
|
|
|
if (sd->typebuf.timer)
|
|
|
|
{
|
|
|
|
ecore_timer_del(sd->typebuf.timer);
|
|
|
|
}
|
|
|
|
|
|
|
|
sd->typebuf.timer = ecore_timer_add(3.0, _e_typebuf_timer_cb, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_typebuf_timer_delete(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
|
|
|
|
|
|
|
if (sd->typebuf.timer)
|
|
|
|
{
|
|
|
|
ecore_timer_del(sd->typebuf.timer);
|
|
|
|
sd->typebuf.timer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_typebuf_clean(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
|
|
|
|
|
|
|
E_FREE(sd->typebuf.buf);
|
|
|
|
sd->typebuf.size = 0;
|
|
|
|
|
|
|
|
_e_typebuf_timer_delete(obj);
|
|
|
|
}
|