Log:
elm genlist: Refactoring. Moved internal functions and added more description.
Author: seoz
Date: 2013-01-25 23:11:32 -0800 (Fri, 25 Jan 2013)
New Revision: 83348
Trac: http://trac.enlightenment.org/e/changeset/83348
Modified:
trunk/elementary/src/lib/elm_genlist.c
Modified: trunk/elementary/src/lib/elm_genlist.c
===================================================================
--- trunk/elementary/src/lib/elm_genlist.c 2013-01-26 06:53:10 UTC (rev 83347)
+++ trunk/elementary/src/lib/elm_genlist.c 2013-01-26 07:11:32 UTC (rev 83348)
@@ -1125,7 +1125,71 @@
it->want_unrealize = EINA_FALSE;
}
+//-- tree expand/contract signal handle routine --//
static void
+_expand_toggle_signal_cb(void *data,
+ Evas_Object *obj __UNUSED__,
+ const char *emission __UNUSED__,
+ const char *source __UNUSED__)
+{
+ Elm_Gen_Item *it = data;
+
+ if (it->item->expanded)
+ evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
+ else
+ evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
+}
+
+static void
+_expand_signal_cb(void *data,
+ Evas_Object *obj __UNUSED__,
+ const char *emission __UNUSED__,
+ const char *source __UNUSED__)
+{
+ Elm_Gen_Item *it = data;
+
+ if (!it->item->expanded)
+ evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
+}
+
+static void
+_contract_signal_cb(void *data,
+ Evas_Object *obj __UNUSED__,
+ const char *emission __UNUSED__,
+ const char *source __UNUSED__)
+{
+ Elm_Gen_Item *it = data;
+
+ if (it->item->expanded)
+ evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
+}
+
+//-- item cache handle routine --//
+// clean up item cache by removing overflowed caches
+static void
+_item_cache_clean(Elm_Genlist_Smart_Data *sd)
+{
+ evas_event_freeze(evas_object_evas_get(sd->obj));
+
+ while ((sd->item_cache) && (sd->item_cache_count > sd->item_cache_max))
+ {
+ Item_Cache *itc;
+
+ itc = EINA_INLIST_CONTAINER_GET(sd->item_cache->last, Item_Cache);
+ sd->item_cache = eina_inlist_remove
+ (sd->item_cache, sd->item_cache->last);
+ sd->item_cache_count--;
+ if (itc->spacer) evas_object_del(itc->spacer);
+ if (itc->base_view) evas_object_del(itc->base_view);
+ eina_stringshare_del(itc->item_style);
+ free(itc);
+ }
+ evas_event_thaw(evas_object_evas_get(sd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(sd->obj));
+}
+
+// free one item cache
+static void
_item_cache_free(Item_Cache *itc)
{
if (itc->spacer) evas_object_del(itc->spacer);
@@ -1134,6 +1198,89 @@
free(itc);
}
+// empty all item caches
+static void
+_item_cache_zero(Elm_Genlist_Smart_Data *sd)
+{
+ int pmax = sd->item_cache_max;
+
+ sd->item_cache_max = 0;
+ _item_cache_clean(sd);
+ sd->item_cache_max = pmax;
+}
+
+// add an item to item cache
+static void
+_item_cache_add(Elm_Gen_Item *it)
+{
+ Item_Cache *itc;
+ Evas_Object *obj = GL_IT(it)->wsd->obj;
+
+ evas_event_freeze(evas_object_evas_get(obj));
+ if (GL_IT(it)->wsd->item_cache_max <= 0)
+ {
+ evas_object_del(VIEW(it));
+ VIEW(it) = NULL;
+ if (it->spacer)
+ {
+ evas_object_del(it->spacer);
+ it->spacer = NULL;
+ }
+ evas_event_thaw(evas_object_evas_get(obj));
+ evas_event_thaw_eval(evas_object_evas_get(obj));
+
+ return;
+ }
+
+ GL_IT(it)->wsd->item_cache_count++;
+ itc = calloc(1, sizeof(Item_Cache));
+ if (!itc)
+ {
+ evas_event_thaw(evas_object_evas_get(obj));
+ evas_event_thaw_eval(evas_object_evas_get(obj));
+ return;
+ }
+ GL_IT(it)->wsd->item_cache =
+ eina_inlist_prepend(GL_IT(it)->wsd->item_cache, EINA_INLIST_GET(itc));
+ itc->spacer = it->spacer;
+ it->spacer = NULL;
+ itc->base_view = VIEW(it);
+
+ VIEW(it) = NULL;
+ edje_object_signal_emit(itc->base_view, "elm,state,unselected", "elm");
+ evas_object_hide(itc->base_view);
+ evas_object_move(itc->base_view, -9999, -9999);
+ itc->item_style = eina_stringshare_add(it->itc->item_style);
+ if (it->item->type & ELM_GENLIST_ITEM_TREE) itc->tree = 1;
+ itc->selected = it->selected;
+ itc->disabled = elm_widget_item_disabled_get(it);
+ itc->expanded = it->item->expanded;
+ if (it->long_timer)
+ {
+ ecore_timer_del(it->long_timer);
+ it->long_timer = NULL;
+ }
+ if (it->item->swipe_timer)
+ {
+ ecore_timer_del(it->item->swipe_timer);
+ it->item->swipe_timer = NULL;
+ }
+ // FIXME: other callbacks?
+ edje_object_signal_callback_del_full
+ (itc->base_view, "elm,action,expand,toggle", "elm",
+ _expand_toggle_signal_cb, it);
+ edje_object_signal_callback_del_full
+ (itc->base_view, "elm,action,expand", "elm", _expand_signal_cb, it);
+ edje_object_signal_callback_del_full
+ (itc->base_view, "elm,action,contract", "elm", _contract_signal_cb, it);
+ _item_mouse_callbacks_del(it, itc->base_view);
+ _item_cache_clean(GL_IT(it)->wsd);
+
+ evas_event_thaw(evas_object_evas_get(obj));
+ evas_event_thaw_eval(evas_object_evas_get(obj));
+}
+
+// find an item from item cache and remove it from the cache
static Item_Cache *
_item_cache_find(Elm_Gen_Item *it)
{
@@ -1163,44 +1310,6 @@
return NULL;
}
-static void
-_expand_toggle_signal_cb(void *data,
- Evas_Object *obj __UNUSED__,
- const char *emission __UNUSED__,
- const char *source __UNUSED__)
-{
- Elm_Gen_Item *it = data;
-
- if (it->item->expanded)
- evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
- else
- evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
-}
-
-static void
-_expand_signal_cb(void *data,
- Evas_Object *obj __UNUSED__,
- const char *emission __UNUSED__,
- const char *source __UNUSED__)
-{
- Elm_Gen_Item *it = data;
-
- if (!it->item->expanded)
- evas_object_smart_callback_call(WIDGET(it), SIG_EXPAND_REQUEST, it);
-}
-
-static void
-_contract_signal_cb(void *data,
- Evas_Object *obj __UNUSED__,
- const char *emission __UNUSED__,
- const char *source __UNUSED__)
-{
- Elm_Gen_Item *it = data;
-
- if (it->item->expanded)
- evas_object_smart_callback_call(WIDGET(it), SIG_CONTRACT_REQUEST, it);
-}
-
static Eina_List *
_item_content_realize(Elm_Gen_Item *it,
Evas_Object *target,
@@ -2464,38 +2573,6 @@
}
static void
-_item_cache_clean(Elm_Genlist_Smart_Data *sd)
-{
- evas_event_freeze(evas_object_evas_get(sd->obj));
-
- while ((sd->item_cache) && (sd->item_cache_count > sd->item_cache_max))
- {
- Item_Cache *itc;
-
- itc = EINA_INLIST_CONTAINER_GET(sd->item_cache->last, Item_Cache);
- sd->item_cache = eina_inlist_remove
- (sd->item_cache, sd->item_cache->last);
- sd->item_cache_count--;
- if (itc->spacer) evas_object_del(itc->spacer);
- if (itc->base_view) evas_object_del(itc->base_view);
- eina_stringshare_del(itc->item_style);
- free(itc);
- }
- evas_event_thaw(evas_object_evas_get(sd->obj));
- evas_event_thaw_eval(evas_object_evas_get(sd->obj));
-}
-
-static void
-_item_cache_zero(Elm_Genlist_Smart_Data *sd)
-{
- int pmax = sd->item_cache_max;
-
- sd->item_cache_max = 0;
- _item_cache_clean(sd);
- sd->item_cache_max = pmax;
-}
-
-static void
_mirrored_set(Evas_Object *obj,
Eina_Bool rtl)
{
@@ -4124,76 +4201,6 @@
evas_event_thaw_eval(te);
}
-static void
-_item_cache_add(Elm_Gen_Item *it)
-{
- Item_Cache *itc;
- Evas_Object *obj = GL_IT(it)->wsd->obj;
-
- evas_event_freeze(evas_object_evas_get(obj));
- if (GL_IT(it)->wsd->item_cache_max <= 0)
- {
- evas_object_del(VIEW(it));
- VIEW(it) = NULL;
- if (it->spacer)
- {
- evas_object_del(it->spacer);
- it->spacer = NULL;
- }
- evas_event_thaw(evas_object_evas_get(obj));
- evas_event_thaw_eval(evas_object_evas_get(obj));
-
- return;
- }
-
- GL_IT(it)->wsd->item_cache_count++;
- itc = calloc(1, sizeof(Item_Cache));
- if (!itc)
- {
- evas_event_thaw(evas_object_evas_get(obj));
- evas_event_thaw_eval(evas_object_evas_get(obj));
- return;
- }
- GL_IT(it)->wsd->item_cache =
- eina_inlist_prepend(GL_IT(it)->wsd->item_cache, EINA_INLIST_GET(itc));
- itc->spacer = it->spacer;
- it->spacer = NULL;
- itc->base_view = VIEW(it);
-
- VIEW(it) = NULL;
- edje_object_signal_emit(itc->base_view, "elm,state,unselected", "elm");
- evas_object_hide(itc->base_view);
- evas_object_move(itc->base_view, -9999, -9999);
- itc->item_style = eina_stringshare_add(it->itc->item_style);
- if (it->item->type & ELM_GENLIST_ITEM_TREE) itc->tree = 1;
- itc->selected = it->selected;
- itc->disabled = elm_widget_item_disabled_get(it);
- itc->expanded = it->item->expanded;
- if (it->long_timer)
- {
- ecore_timer_del(it->long_timer);
- it->long_timer = NULL;
- }
- if (it->item->swipe_timer)
- {
- ecore_timer_del(it->item->swipe_timer);
- it->item->swipe_timer = NULL;
- }
- // FIXME: other callbacks?
- edje_object_signal_callback_del_full
- (itc->base_view, "elm,action,expand,toggle", "elm",
- _expand_toggle_signal_cb, it);
- edje_object_signal_callback_del_full
- (itc->base_view, "elm,action,expand", "elm", _expand_signal_cb, it);
- edje_object_signal_callback_del_full
- (itc->base_view, "elm,action,contract", "elm", _contract_signal_cb, it);
- _item_mouse_callbacks_del(it, itc->base_view);
- _item_cache_clean(GL_IT(it)->wsd);
-
- evas_event_thaw(evas_object_evas_get(obj));
- evas_event_thaw_eval(evas_object_evas_get(obj));
-}
-
static Eina_List *
_item_mode_content_unrealize(Elm_Gen_Item *it,
Evas_Object *target,
|