-/*
- *
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
#include <Elementary.h>
#include "elm_priv.h"
Eina_Bool bring_in : 1;
Eina_Bool compress : 1;
Eina_Bool homogeneous : 1;
+ Eina_Bool clear_me : 1;
+ int walking;
int item_width;
int item_height;
int max_items_per_block;
+ double longpress_timeout;
};
struct _Item_Block
_item_del(Elm_Genlist_Item *it)
{
elm_genlist_item_subitems_clear(it);
+ it->wd->walking -= it->walking;
if (it->wd->show_item == it) it->wd->show_item = NULL;
if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
if (it->realized) _item_unrealize(it);
it->wd->selected = eina_list_append(it->wd->selected, it);
call:
it->walking++;
+ it->wd->walking++;
if (it->func.func) it->func.func((void *)it->func.data, it->wd->obj, it);
if (!it->delete_me)
evas_object_smart_callback_call(it->wd->obj, "selected", it);
it->walking--;
- if ((it->walking == 0) && (it->delete_me))
+ it->wd->walking--;
+ if ((it->wd->clear_me) && (it->wd->walking == 0))
+ elm_genlist_clear(it->wd->obj);
+ else
{
- if (it->relcount == 0) _item_del(it);
+ if ((it->walking == 0) && (it->delete_me))
+ {
+ if (it->relcount == 0) _item_del(it);
+ }
}
}
if (!it->wd->on_hold)
{
it->wd->on_hold = EINA_TRUE;
- _item_unselect(it);
+ if (!it->wd->wasselected)
+ _item_unselect(it);
}
}
if ((it->dragging) && (it->down))
}
if (!it->wd->wasselected)
_item_unselect(it);
- it->wd->wasselected = 0;
if (dy < 0)
{
if (ady > adx)
}
}
-static int
+static Eina_Bool
_long_press(void *data)
{
Elm_Genlist_Item *it = data;
it->long_timer = NULL;
- if ((it->disabled) || (it->dragging)) return 0;
+ if ((it->disabled) || (it->dragging)) return ECORE_CALLBACK_CANCEL;
it->wd->longpressed = EINA_TRUE;
evas_object_smart_callback_call(it->wd->obj, "longpressed", it);
- return 0;
+ return ECORE_CALLBACK_CANCEL;
}
static void
Evas_Coord x, y;
if (ev->button != 1) return;
+
it->down = 1;
it->dragging = 0;
evas_object_geometry_get(obj, &x, &y, NULL, NULL);
evas_object_smart_callback_call(it->wd->obj, "clicked", it);
if (it->long_timer) ecore_timer_del(it->long_timer);
if (it->realized)
- it->long_timer = ecore_timer_add(1.0, _long_press, it);
+ it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press, it);
else
it->long_timer = NULL;
}
wd->obj = obj;
wd->mode = ELM_LIST_SCROLL;
wd->max_items_per_block = 32;
+ wd->longpress_timeout = 1.0;
evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
return n;
}
-static int
+static Eina_Bool
_item_idler(void *data)
{
Widget_Data *wd = data;
if (!wd->queue)
{
wd->queue_idler = NULL;
- return 0;
+ return ECORE_CALLBACK_CANCEL;
}
- return 1;
+ return ECORE_CALLBACK_RENEW;
}
static void
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
+ if (wd->walking > 0)
+ {
+ Elm_Genlist_Item *it;
+
+ wd->clear_me = 1;
+ EINA_INLIST_FOREACH(wd->items, it)
+ {
+ it->delete_me = 1;
+ }
+ return;
+ }
+ wd->clear_me = 0;
while (wd->items)
{
Elm_Genlist_Item *it = (Elm_Genlist_Item *)(wd->items);
if (!wd) return 0;
return wd->max_items_per_block;
}
+
+/**
+ * Set the timeout in seconds for the longpress event
+ *
+ * @param obj The genlist object
+ * @param timeout timeout in seconds
+ *
+ * @ingroup Genlist
+ */
+EAPI void
+elm_genlist_longpress_timeout_set(const Evas_Object *obj, double timeout)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ wd->longpress_timeout = timeout;
+}
+
+/**
+ * Get the timeout in seconds for the longpress event
+ *
+ * @param obj The genlist object
+ * @return timeout in seconds
+ *
+ * @ingroup Genlist
+ */
+EAPI double
+elm_genlist_longpress_timeout_get(const Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) 0;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return 0;
+ return wd->longpress_timeout;
+}