diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c index 12f0df6c9..2a2c2db12 100644 --- a/src/bin/e_fm.c +++ b/src/bin/e_fm.c @@ -88,7 +88,6 @@ struct _E_Fm2_Smart_Data } new_file; E_Fm2_Icon *last_selected; - E_Fm2_Icon *range_selected; Eina_List *selected_icons; Eina_List *icons_place; Eina_List *queue; @@ -311,7 +310,6 @@ static void _e_fm2_icon_sel_prev(Evas_Object *obj, Eina_Bool add); static void _e_fm2_icon_sel_next(Evas_Object *obj, Eina_Bool add); static void _e_fm2_icon_sel_down(Evas_Object *obj, Eina_Bool add); static void _e_fm2_icon_sel_up(Evas_Object *obj, Eina_Bool add); -static void _e_fm2_icon_range_select(E_Fm2_Icon *ic); static void _e_fm2_typebuf_show(Evas_Object *obj); static void _e_fm2_typebuf_hide(Evas_Object *obj); @@ -5033,7 +5031,6 @@ _e_fm2_icon_select(E_Fm2_Icon *ic) { E_Fm2_Icon *prev; if (ic->selected) return; - ic->sd->range_selected = NULL; prev = eina_list_last_data_get(ic->sd->selected_icons); if (prev) prev->last_selected = EINA_FALSE; ic->selected = EINA_TRUE; @@ -5062,7 +5059,6 @@ static void _e_fm2_icon_deselect(E_Fm2_Icon *ic) { if (!ic->selected) return; - ic->sd->range_selected = NULL; ic->selected = EINA_FALSE; ic->last_selected = EINA_FALSE; if (ic->sd->last_selected == ic) ic->sd->last_selected = NULL; @@ -5434,19 +5430,25 @@ _e_fm2_icon_next_find(Evas_Object *obj, int next, int (*match_func)(E_Fm2_Icon * custom = 1; ic_next = NULL; - - if (custom || match_func) + /* find selected item / current position */ + EINA_LIST_FOREACH(sd->icons, l, ic) { - EINA_LIST_FOREACH(sd->icons, l, ic) + if (ic->selected) { - if (ic->selected) + if (!custom && !match_func) + { + ic_next = ic; + } + else { x = ic->x; y = ic->y; - break; } + break; } - + } + if (next && (custom || match_func)) + { /* find next item in custom grid, or list/grid when match func is given */ if (next == 1) @@ -5518,19 +5520,10 @@ _e_fm2_icon_next_find(Evas_Object *obj, int next, int (*match_func)(E_Fm2_Icon * } } /* not custom, items are arranged in list order */ - else + else if (ic_next) { - l = eina_list_data_find_list(sd->icons, (sd->range_selected) ? - sd->range_selected : - sd->last_selected); - - if (next == 0) - { - if (l) ic_next = eina_list_data_get(l); - } if (next == 1) { - if (!l) return eina_list_data_get(sd->icons); if (!eina_list_next(l)) return NULL; ic_next = eina_list_data_get(eina_list_next(l)); } @@ -5551,18 +5544,15 @@ _e_fm2_icon_sel_prev(Evas_Object *obj, Eina_Bool add) ic_prev = _e_fm2_icon_next_find(obj, -1, NULL, NULL); - if (!ic_prev) return; - + if (!ic_prev) + { + /* FIXME this is not the bottomright item for custom grid */ + _e_fm2_icon_sel_last(obj, add); + return; + } if ((!add) || ic_prev->sd->config->selection.single) - { - _e_fm2_icon_desel_any(obj); - _e_fm2_icon_select(ic_prev); - } - else - { - _e_fm2_icon_range_select(ic_prev); - } - + _e_fm2_icon_desel_any(obj); + _e_fm2_icon_select(ic_prev); evas_object_smart_callback_call(obj, "selection_change", NULL); /*XXX sd->obj*/ _e_fm2_icon_make_visible(ic_prev); } @@ -5573,18 +5563,15 @@ _e_fm2_icon_sel_next(Evas_Object *obj, Eina_Bool add) E_Fm2_Icon *ic_next; ic_next = _e_fm2_icon_next_find(obj, 1, NULL, NULL); - - if (!ic_next) return; - - if ((!add) || ic_next->sd->config->selection.single) - { - _e_fm2_icon_desel_any(obj); - _e_fm2_icon_select(ic_next); - } - else + if (!ic_next) { - _e_fm2_icon_range_select(ic_next); + /* FIXME this is not the topleft item for custom grid */ + _e_fm2_icon_sel_first(obj, add); + return; } + if ((!add) || ic_next->sd->config->selection.single) + _e_fm2_icon_desel_any(obj); + _e_fm2_icon_select(ic_next); evas_object_smart_callback_call(obj, "selection_change", NULL); _e_fm2_icon_make_visible(ic_next); } @@ -5595,7 +5582,7 @@ _e_fm2_icon_sel_down(Evas_Object *obj, Eina_Bool add) E_Fm2_Smart_Data *sd; Eina_List *l; E_Fm2_Icon *ic, *ic_down; - int x = -1, y = -1, custom = 0; + int found, x = -1, y = -1, custom = 0; int dist, min = 65535; char view_mode; @@ -5610,18 +5597,21 @@ _e_fm2_icon_sel_down(Evas_Object *obj, Eina_Bool add) custom = 1; ic_down = NULL; - - ic = (sd->range_selected) ? sd->range_selected : sd->last_selected; - - if (ic) - { - x = ic->x; - y = ic->y; - } + found = 0; EINA_LIST_FOREACH(sd->icons, l, ic) { - if (ic->y > y) + if (!found) + { + if (ic->selected) + { + found = 1; + x = ic->x; + y = ic->y; + if (custom) break; + } + } + else if (ic->y > y) { dist = (abs(ic->x - x)) + (ic->y - y) * 2; if (dist < min) @@ -5655,14 +5645,8 @@ _e_fm2_icon_sel_down(Evas_Object *obj, Eina_Bool add) return; } if ((!add) || ic_down->sd->config->selection.single) - { - _e_fm2_icon_desel_any(obj); - _e_fm2_icon_select(ic_down); - } - else - { - _e_fm2_icon_range_select(ic_down); - } + _e_fm2_icon_desel_any(obj); + _e_fm2_icon_select(ic_down); evas_object_smart_callback_call(sd->obj, "selection_change", NULL); _e_fm2_icon_make_visible(ic_down); } @@ -5690,17 +5674,19 @@ _e_fm2_icon_sel_up(Evas_Object *obj, Eina_Bool add) ic_up = NULL; - ic = (sd->range_selected) ? sd->range_selected : sd->last_selected; - - if (ic) - { - x = ic->x; - y = ic->y; - } - EINA_LIST_REVERSE_FOREACH(sd->icons, l, ic) { - if (ic->y < y) + if (!found) + { + if (ic->selected) + { + found = 1; + x = ic->x; + y = ic->y; + if (custom) break; + } + } + else if (ic->y < y) { dist = (abs(ic->x - x)) + (y - ic->y) * 2; if (dist < min) @@ -5734,40 +5720,12 @@ _e_fm2_icon_sel_up(Evas_Object *obj, Eina_Bool add) return; } if ((!add) || ic_up->sd->config->selection.single) - { - _e_fm2_icon_desel_any(obj); - _e_fm2_icon_select(ic_up); - } - else - { - _e_fm2_icon_range_select(ic_up); - } + _e_fm2_icon_desel_any(obj); + _e_fm2_icon_select(ic_up); evas_object_smart_callback_call(sd->obj, "selection_change", NULL); _e_fm2_icon_make_visible(ic_up); } -static void -_e_fm2_icon_range_select(E_Fm2_Icon *ic) -{ - E_Fm2_Icon *last = ic->sd->last_selected; - int trig = 2; - _e_fm2_icon_desel_any(ic->sd->obj); - - const Eina_List *l; - E_Fm2_Icon *ic2; - if ((last) && (last != ic)) - { - EINA_LIST_FOREACH(ic->sd->icons, l, ic2) - { - if ((ic2 == last) || (ic2 == ic)) trig--; - if ((trig < 2) && (ic2 != last)) _e_fm2_icon_select(ic2); - if (!trig) break; - } - } - _e_fm2_icon_select((last) ? last : ic); - ic->sd->range_selected = ic; -} - /* FIXME: prototype */ static void _e_fm2_typebuf_show(Evas_Object *obj) @@ -7282,7 +7240,39 @@ _e_fm2_mouse_1_handler(E_Fm2_Icon *ic, int up, void *evas_event) if (range_sel) { - if (!up) _e_fm2_icon_range_select(ic); + const Eina_List *l, *l2; + E_Fm2_Icon *ic2; + Eina_Bool seen = 0; + /* find last selected - if any, and select all icons between */ + EINA_LIST_FOREACH(ic->sd->icons, l, ic2) + { + if (ic2 == ic) seen = 1; + if (ic2->last_selected) + { + ic2->last_selected = 0; + if (seen) + { + for (l2 = l, ic2 = l2->data; l2; l2 = l2->prev, ic2 = l2->data) + { + if (ic == ic2) break; + if (!ic2->selected) sel_change = 1; + _e_fm2_icon_select(ic2); + ic2->last_selected = 0; + } + } + else + { + EINA_LIST_FOREACH(l, l2, ic2) + { + if (ic == ic2) break; + if (!ic2->selected) sel_change = 1; + _e_fm2_icon_select(ic2); + ic2->last_selected = 0; + } + } + break; + } + } } else if ((!multi_sel) && ((up) || ((!up) && (!ic->selected)))) {