From 5a1556acca2a070aa2f1e6ecf6a0ddadabbdbac8 Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Sun, 21 Mar 2010 15:55:03 +0000 Subject: [PATCH] 'everything' - use idler for retrieving icons. - delay initial update of matches SVN revision: 47357 --- src/modules/everything/evry.c | 5 +- .../everything/views/evry_plug_view_thumb.c | 147 ++++++++++++--------- 2 files changed, 84 insertions(+), 68 deletions(-) diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c index 6d92e06..1729e4f 100644 --- a/src/modules/everything/evry.c +++ b/src/modules/everything/evry.c @@ -10,6 +10,7 @@ */ #define INPUTLEN 256 #define MATCH_LAG 0.1 +#define INITIAL_MATCH_LAG 0.2 typedef struct _Evry_Window Evry_Window; typedef struct _Evry_List_Window Evry_List_Window; @@ -143,8 +144,8 @@ evry_show(E_Zone *zone, const char *params) _evry_selector_subjects_get(params); _evry_selector_activate(selectors[0]); - _evry_selector_update(selector); - + update_timer = ecore_timer_add(INITIAL_MATCH_LAG, _evry_update_timer, NULL); + if (evry_conf->views && selector->state) { Evry_View *view =evry_conf->views->data; diff --git a/src/modules/everything/views/evry_plug_view_thumb.c b/src/modules/everything/views/evry_plug_view_thumb.c index 399b2bd..2b1b1a6 100644 --- a/src/modules/everything/views/evry_plug_view_thumb.c +++ b/src/modules/everything/views/evry_plug_view_thumb.c @@ -35,6 +35,7 @@ struct _Smart_Data double selmove; Eina_Bool update : 1; Eina_Bool switch_mode : 1; + Eina_List *queue; }; struct _Item @@ -77,17 +78,51 @@ _thumb_gen(void *data, Evas_Object *obj, void *event_info) } static int +_check_item(const Evry_Item *it) +{ + if (it->plugin->type_out != view_types) return 0; + + ITEM_FILE(file, it); + + if (!file->uri || !file->mime) return 0; + + if (!strncmp(file->mime, "image/", 6)) + return 1; + + return 0; +} + +static int _thumb_idler(void *data) { Smart_Data *sd = data; - Eina_List *l; + Eina_List *l, *ll; Item *it; int cnt = 0; - EINA_LIST_FOREACH(sd->items, l, it) + EINA_LIST_FOREACH_SAFE(sd->queue, l, ll, it) { - if (it->thumb && !(it->have_thumb || it->do_thumb)) + if (!it->image && !it->have_thumb && + sd->view->state->plugin->icon_get) { + it->image = sd->view->state->plugin->icon_get + (it->item->plugin, it->item, sd->view->evas); + + if (it->image) + { + edje_object_part_swallow(it->frame, "e.swallow.icon", it->image); + evas_object_show(it->image); + } + + /* dirbrowse fetches the mimetype for icon_get */ + if (!it->get_thumb && _check_item(it->item)) + it->get_thumb = EINA_TRUE; + } + + if (it->get_thumb && !it->thumb && !(it->have_thumb || it->do_thumb)) + { + it->thumb = e_thumb_icon_add(sd->view->evas); + ITEM_FILE(file, it->item); evas_object_smart_callback_add(it->thumb, "e_thumb_gen", _thumb_gen, it); @@ -96,11 +131,13 @@ _thumb_idler(void *data) e_thumb_icon_size_set(it->thumb, it->w, it->h); e_thumb_icon_begin(it->thumb); it->do_thumb = EINA_TRUE; - - cnt++; } - if (cnt > 4) + sd->queue = eina_list_remove_list(sd->queue, l); + + cnt++; + + if (cnt > 2) { e_util_wakeup(); return 1; @@ -113,21 +150,6 @@ _thumb_idler(void *data) } static int -_check_item(const Evry_Item *it) -{ - if (it->plugin->type_out != view_types) return 0; - - ITEM_FILE(file, it); - - if (!file->uri || !file->mime) return 0; - - if (!strncmp(file->mime, "image/", 6)) - return 1; - - return 0; -} - -static int _e_smart_reconfigure_do(void *data) { Evas_Object *obj = data; @@ -284,63 +306,32 @@ _e_smart_reconfigure_do(void *data) evas_object_show(it->frame); if (it->changed) - { - edje_object_signal_emit(it->frame, "e,action,thumb,show_delayed", "e"); - } + edje_object_signal_emit(it->frame, "e,action,thumb,show_delayed", "e"); else - { - edje_object_signal_emit(it->frame, "e,action,thumb,show", "e"); - } - + edje_object_signal_emit(it->frame, "e,action,thumb,show", "e"); + if (it->item->browseable) edje_object_signal_emit(it->frame, "e,state,browseable", "e"); - it->visible = EINA_TRUE; - } - - if (!it->image && !it->have_thumb && - sd->view->state->plugin->icon_get) - { - it->image = sd->view->state->plugin->icon_get - (it->item->plugin, it->item, sd->view->evas); - - if (it->image) - { - edje_object_part_swallow(it->frame, "e.swallow.icon", it->image); - evas_object_show(it->image); - } - - /* dirbrowse fetches the mimetype for icon_get */ - if (!it->get_thumb && _check_item(it->item)) - it->get_thumb = EINA_TRUE; + sd->queue = eina_list_append(sd->queue, it); } evas_object_move(it->frame, xx, yy); evas_object_resize(it->frame, it->w, it->h); - if (sd->update || it->changed) - { - if (it->selected && sd->view->zoom < 2) - edje_object_signal_emit(it->frame, "e,state,selected", "e"); - else - edje_object_signal_emit(it->frame, "e,state,unselected", "e"); - } - - if (it->get_thumb && !it->thumb) - { - it->thumb = e_thumb_icon_add(sd->view->evas); - - if (!sd->thumb_idler) - sd->thumb_idler = ecore_idle_enterer_before_add(_thumb_idler, sd); - } - - it->changed = EINA_FALSE; - + /* if (sd->update || it->changed) + * { + * if (it->selected && sd->view->zoom < 2) + * edje_object_signal_emit(it->frame, "e,state,selected", "e"); + * else + * edje_object_signal_emit(it->frame, "e,state,unselected", "e"); + * } */ } else if (it->visible) { + sd->queue = eina_list_remove(sd->queue, it); if (it->do_thumb) e_thumb_icon_end(it->thumb); if (it->thumb) evas_object_del(it->thumb); if (it->image) evas_object_del(it->image); @@ -360,6 +351,9 @@ _e_smart_reconfigure_do(void *data) if (changed) evas_object_smart_callback_call(obj, "changed", NULL); + if (!sd->thumb_idler) + sd->thumb_idler = ecore_idle_enterer_before_add(_thumb_idler, sd); + sd->update = EINA_TRUE; if (recursion == 0) @@ -623,6 +617,14 @@ _view_clear(Evry_View *view) if (sd->idle_enter) ecore_idle_enterer_del(sd->idle_enter); sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, v->span); + if (sd->queue) + eina_list_free(sd->queue); + sd->queue = NULL; + + if (sd->thumb_idler) + ecore_idle_enterer_del(sd->thumb_idler); + sd->thumb_idler = NULL; + v->tabs->clear(v->tabs); } @@ -639,9 +641,9 @@ static int _update_frame(Evas_Object *obj) { Smart_Data *sd = evas_object_smart_data_get(obj); - sd->switch_mode = EINA_TRUE; + //sd->switch_mode = EINA_TRUE; _e_smart_reconfigure_do(obj); - sd->switch_mode = EINA_FALSE; + //sd->switch_mode = EINA_FALSE; _pan_item_select(obj, sd->cur_item); return 0; @@ -663,6 +665,10 @@ _view_update(Evry_View *view) _view_clear(view); return 1; } + + if (sd->queue) + eina_list_free(sd->queue); + sd->queue = NULL; p_items = v->state->plugin->items; @@ -791,6 +797,14 @@ _clear_items(Evas_Object *obj) it->do_thumb = EINA_FALSE; it->visible = EINA_FALSE; } + + if (sd->queue) + eina_list_free(sd->queue); + sd->queue = NULL; + + if (sd->thumb_idler) + ecore_idle_enterer_del(sd->thumb_idler); + sd->thumb_idler = NULL; } static int @@ -811,6 +825,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) v->zoom = 0; _clear_items(v->span); _update_frame(v->span); + goto end; } else if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) && ((!strcmp(ev->key, "plus")) || -- 2.7.4