From 88568ea5b1f85ce987517c6cc0626b203d75eeb5 Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Tue, 13 Apr 2010 22:15:56 +0000 Subject: [PATCH] 'everything' added detailed list view SVN revision: 47991 --- data/themes/default.edc | 99 ++++++++- src/modules/everything-apps/e_mod_main.c | 7 +- src/modules/everything-files/e_mod_main.c | 30 ++- src/modules/everything/Evry.h | 22 +- src/modules/everything/evry.c | 1 + src/modules/everything/evry_config.c | 6 +- src/modules/everything/evry_history.c | 16 +- src/modules/everything/evry_plug_view_thumb.c | 203 +++++++++++------- 8 files changed, 282 insertions(+), 102 deletions(-) diff --git a/data/themes/default.edc b/data/themes/default.edc index 38d4bf975..54de88acd 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc @@ -34428,7 +34428,7 @@ collections { rel2 { to: "base"; relative: 0.0 1.0; - offset: 36 -1; + offset: 40 -1; } color: 235 235 235 255; } @@ -34471,12 +34471,14 @@ collections { description { state: "default" 0.0; align: 0.0 0.5; - aspect_preference: VERTICAL; - visible: 0; + min: 16 16; + max: 16 16; + /* aspect_preference: */ + visible: 0; rel1 { to: "base"; relative: 1.0 0.0; - offset: -6 6; + offset: -21 6; } rel2 { to: "base"; @@ -34491,7 +34493,9 @@ collections { state: "visible" 0.0; inherit: "default" 0.0; visible: 1; - max: 20 20; + /* min: 12 12; + * max: 12 12; */ + rel1 { to: "base"; relative: 1.0 0.0; @@ -34511,7 +34515,7 @@ collections { rel1 { to_x: "clip"; to_y: "base"; - offset: 5 6; + offset: 5 4; relative: 1.0 0.5; } rel2 { @@ -34520,15 +34524,78 @@ collections { to_y: "base"; to_x: "arrow"; } - color: 210 210 210 255; + color: 230 230 230 255; color3: 0 0 0 0; text { font: "Sans"; - size: 11; + size: 10; min: 0 1; align: 0.0 0.5; } } + description { + state: "detail" 0.0; + /* inherit: "default" 0.0; */ + rel1 { + to_x: "clip"; + to_y: "base"; + offset: 5 9; + relative: 1.0 0.0; + } + rel2 { + relative: 0.0 0.5; + offset: 4 -1; + to_y: "base"; + to_x: "arrow"; + } + color: 230 230 230 255; + color3: 0 0 0 0; + + text { + font: "Sans"; + size: 10; + min: 0 1; + align: 0.0 0.0; + } + } + } + part { + name: "e.text.detail"; + type: TEXT; + clip_to: "base"; + /* effect: SOFT_SHADOW; */ + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + + rel1 { + to_x: "clip"; + to_y: "base"; + offset: 5 2; + relative: 1.0 0.5; + } + rel2 { + relative: 0.0 1.0; + offset: 4 -1; + to_y: "base"; + to_x: "arrow"; + } + color: 200 200 200 255; + color3: 0 0 0 0; + text { + font: "Sans"; + size: 9; + min: 0 1; + align: 0.0 0.0; + } + } + description { + state: "detail" 0.0; + inherit: "default" 0.0; + visible: 1; + } } } programs { @@ -34597,6 +34664,22 @@ collections { /* transition: SINUSOIDAL 0.1; */ target: "base"; } + program { + name: "detail_show"; + signal: "e,state,detail,show"; + source: "e"; + action: STATE_SET "detail" 0.0; + target: "e.text.label"; + target: "e.text.detail"; + } + program { + name: "detail_hide"; + signal: "e,state,detail,hide"; + source: "e"; + action: STATE_SET "default" 0.0; + target: "e.text.label"; + target: "e.text.detail"; + } } } group { diff --git a/src/modules/everything-apps/e_mod_main.c b/src/modules/everything-apps/e_mod_main.c index c2f9110f2..afdd3da07 100644 --- a/src/modules/everything-apps/e_mod_main.c +++ b/src/modules/everything-apps/e_mod_main.c @@ -303,11 +303,16 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, const char *file, int match) { evry_item_new(EVRY_ITEM(app), EVRY_PLUGIN(p), desktop->name, _item_free); EVRY_ITEM(app)->id = eina_stringshare_add(desktop->exec); + if (desktop->comment) + EVRY_ITEM(app)->detail = eina_stringshare_add(desktop->comment); + else if (desktop->generic_name) + EVRY_ITEM(app)->detail = eina_stringshare_add(desktop->generic_name); } else { evry_item_new(EVRY_ITEM(app), EVRY_PLUGIN(p), file, _item_free); EVRY_ITEM(app)->id = eina_stringshare_add(file); + /* EVRY_ITEM(app)->detail = eina_stringshare_add(file); */ } app->desktop = desktop; @@ -501,7 +506,7 @@ _fetch(Evry_Plugin *plugin, const char *input) int found_cmd = 0; /* add executables */ - if (input && len > 3) + if (input && len > 2) { char *space; Evry_Item_App *app; diff --git a/src/modules/everything-files/e_mod_main.c b/src/modules/everything-files/e_mod_main.c index 8b5608874..ac3a76567 100644 --- a/src/modules/everything-files/e_mod_main.c +++ b/src/modules/everything-files/e_mod_main.c @@ -41,21 +41,23 @@ static Evry_Plugin *p2 = NULL; static Evry_Action *act1 = NULL; static Evry_Action *act2 = NULL; -static const char *mime_folder; - +static const char *mime_folder = NULL; +static char *home_dir; +static int home_dir_len; + static void _item_fill(Evry_Item_File *file) { const char *mime; - + if (file->mime) return; if ((mime = efreet_mime_type_get(file->path))) { file->mime = eina_stringshare_add(mime); EVRY_ITEM(file)->context = eina_stringshare_ref(file->mime); - + if ((!strcmp(mime, "inode/directory")) || (!strcmp(mime, "inode/mount-point"))) EVRY_ITEM(file)->browseable = EINA_TRUE; @@ -207,7 +209,7 @@ _scan_end_func(void *data) int cnt = 0; Evry_Item *item; char *filename, *path; - + char buf[1024]; p->thread = NULL; EINA_LIST_FREE(d->files, item) @@ -231,7 +233,21 @@ _scan_end_func(void *data) } if (p->command || cnt >= MAX_ITEMS) continue; - if (!file->mime) _item_fill(file); + if (!file->mime) _item_fill(file); + + if (!item->browseable) + path = ecore_file_dir_get(file->path); + else + path = file->path; + + if (path && !strncmp(path, home_dir, home_dir_len)) + { + snprintf(buf, sizeof(buf), "~%s", path + home_dir_len); + EVRY_ITEM(file)->detail = eina_stringshare_add(buf); + } + else + EVRY_ITEM(file)->detail = eina_stringshare_ref(file->path); + cnt += _append_file(p, file); } @@ -548,6 +564,8 @@ e_modapi_init(E_Module *m) active = module_init(); mime_folder = eina_stringshare_add("inode/directory"); + home_dir = e_user_homedir_get(); + home_dir_len = strlen(home_dir); e_module_delayed_set(m, 1); diff --git a/src/modules/everything/Evry.h b/src/modules/everything/Evry.h index d5ed56983..48902b4ae 100644 --- a/src/modules/everything/Evry.h +++ b/src/modules/everything/Evry.h @@ -98,8 +98,13 @@ struct _Evry_Item { /* label to show for this item */ const char *label; - const char *icon; + /**/ + const char *detail; + + /* for 'static' fdo icon name, otherwise use _icon_get */ + const char *icon; + /* context provided by item. e.g. to remember which action * was performed on a file with a specific mimetype */ const char *context; @@ -118,14 +123,18 @@ struct _Evry_Item /* store value of fuzzy match with input */ int fuzzy_match; - /* optional: plugin can set id to identify + + /*** HISTORY + * optional: plugin can set id to identify * it in history otherwise label is used */ const char *id; - - /* if transient item is removed from history - * on shutdown */ + + /* if transient item is removed from history on shutdown */ Eina_Bool transient; + /* ignores completely from usage statistic */ + Eina_Bool no_history; + /* do not set by plugin! */ Evry_Item *next; Evry_Plugin *plugin; @@ -193,6 +202,9 @@ struct _Evry_Plugin /* whether the plugin uses evry_async_update to add new items. default is FALSE */ Eina_Bool async_fetch; + + /* TODO request list-view */ + Eina_Bool show_list_view; /* not to be set by plugin! */ Plugin_Config *config; diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c index 2b3a221f1..ac841a421 100644 --- a/src/modules/everything/evry.c +++ b/src/modules/everything/evry.c @@ -348,6 +348,7 @@ evry_item_free(Evry_Item *it) if (it->label) eina_stringshare_del(it->label); if (it->id) eina_stringshare_del(it->id); if (it->context) eina_stringshare_del(it->context); + if (it->detail) eina_stringshare_del(it->detail); if (it->free) it->free(it); diff --git a/src/modules/everything/evry_config.c b/src/modules/everything/evry_config.c index 162a54696..e493b2b61 100644 --- a/src/modules/everything/evry_config.c +++ b/src/modules/everything/evry_config.c @@ -261,10 +261,10 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf of = e_widget_framelist_add(evas, _("Default View"), 0); rg = e_widget_radio_group_new(&cfdata->view_mode); ob = e_widget_radio_add(evas, "List", 0, rg); - e_widget_radio_toggle_set(ob, (cfdata->view_mode == 0)); e_widget_framelist_object_append(of, ob); - ob = e_widget_radio_add(evas, "Icons", 1, rg); - e_widget_radio_toggle_set(ob, (cfdata->view_mode == 1)); + ob = e_widget_radio_add(evas, "Detailed", 1, rg); + e_widget_framelist_object_append(of, ob); + ob = e_widget_radio_add(evas, "Icons", 2, rg); e_widget_framelist_object_append(of, ob); ob = e_widget_check_add(evas, _("Animate scrolling"), diff --git a/src/modules/everything/evry_history.c b/src/modules/everything/evry_history.c index 49095af5d..c267a8309 100644 --- a/src/modules/everything/evry_history.c +++ b/src/modules/everything/evry_history.c @@ -216,7 +216,7 @@ evry_history_add(Eina_Hash *hist, Evry_State *s, const char *ctxt) if (!s) return; it = s->cur_item; - if (!it) return; + if (!it || it->no_history) return; id = (it->id ? it->id : it->label); @@ -253,6 +253,7 @@ evry_history_add(Eina_Hash *hist, Evry_State *s, const char *ctxt) if (s->input) { + if (hi->input) eina_stringshare_del(hi->input); @@ -268,8 +269,10 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, c History_Item *hi; Eina_List *l; + if (it->no_history) + return 0; + it->usage = 0.0; - if (!(he = eina_hash_find(hist, (it->id ? it->id : it->label)))) return 0; @@ -280,6 +283,12 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, c if (ctxt != hi->context) continue; + if (it->plugin->type == type_action) + { + if (hi->last_used > it->usage) + it->usage = hi->last_used; + } + if (evry_conf->history_sort_mode == 0) { @@ -311,7 +320,8 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, c } else if (evry_conf->history_sort_mode == 2) { - it->usage = hi->last_used; + if (hi->last_used > it->usage) + it->usage = hi->last_used; } } diff --git a/src/modules/everything/evry_plug_view_thumb.c b/src/modules/everything/evry_plug_view_thumb.c index a300ae6b8..708727032 100644 --- a/src/modules/everything/evry_plug_view_thumb.c +++ b/src/modules/everything/evry_plug_view_thumb.c @@ -6,6 +6,14 @@ typedef struct _View View; typedef struct _Smart_Data Smart_Data; typedef struct _Item Item; +#define MODE_LIST 0 +#define MODE_DETAIL 1 +#define MODE_THUMB 2 + +#define SIZE_LIST 30 +#define SIZE_DETAIL 38 + + struct _View { Evry_View view; @@ -18,7 +26,7 @@ struct _View Evas_Object *bg, *sframe, *span; int iw, ih; int zoom; - int list_mode; + int mode; Eina_List *handlers; }; @@ -45,6 +53,8 @@ struct _Smart_Data double scroll_align; double scroll_align_to; Ecore_Animator *animator; + + double last_select; }; struct _Item @@ -177,33 +187,42 @@ _e_smart_reconfigure_do(void *data) aspect_w = sd->w; aspect_h = sd->h; - if (sd->view->list_mode) + if (sd->view->mode == MODE_LIST) { iw = sd->w; + hh = SIZE_LIST; } - else if (sd->view->zoom == 0) - { - int cnt = eina_list_count(sd->items); - - aspect_w *= 3; - aspect_w /= 4; - - if (cnt < 3) - iw = (double)sd->w / 2.5; - else if (cnt < 7) - iw = sd->w / 3; - else - iw = sd->w / 4; - } - else if (sd->view->zoom == 1) - { - aspect_w *= 2; - aspect_w /= 3; - iw = sd->w / 3; - } - else /* if (sd->zoom == 2) */ + else if (sd->view->mode == MODE_DETAIL) { iw = sd->w; + hh = SIZE_DETAIL; + } + else + { + if (sd->view->zoom == 0) + { + int cnt = eina_list_count(sd->items); + + aspect_w *= 3; + aspect_w /= 4; + + if (cnt < 3) + iw = (double)sd->w / 2.5; + else if (cnt < 7) + iw = sd->w / 3; + else + iw = sd->w / 4; + } + else if (sd->view->zoom == 1) + { + aspect_w *= 2; + aspect_w /= 3; + iw = sd->w / 3; + } + else /* if (sd->zoom == 2) */ + { + iw = sd->w; + } } if (aspect_w <= 0) aspect_w = 1; @@ -212,9 +231,8 @@ _e_smart_reconfigure_do(void *data) x = 0; y = 0; ww = iw; - if (sd->view->list_mode) - hh = 32; - else + + if (sd->view->mode == MODE_THUMB) hh = (aspect_h * iw) / (aspect_w); mw = mh = 0; @@ -236,17 +254,15 @@ _e_smart_reconfigure_do(void *data) x += ww; } - if (sd->view->list_mode) - mh += sd->h % 32; + if (sd->view->mode == MODE_LIST || + sd->view->mode == MODE_DETAIL) + mh += sd->h % hh; if ((mw != sd->cw) || (mh != sd->ch)) { sd->cw = mw; sd->ch = mh; - /* if (sd->view->list_mode) - * sd->ch += sd->h % 32; */ - if (sd->cx > (sd->cw - sd->w)) { sd->cx = sd->cw - sd->w; @@ -289,10 +305,13 @@ _e_smart_reconfigure_do(void *data) return 0; } - if (!sd->view->list_mode) + if (sd->view->mode == MODE_THUMB) { if (sd->w > sd->cw) ox = (sd->w - sd->cw) / 2; if (sd->h > sd->ch) oy = (sd->h - sd->ch) / 2; + + if (sd->selector) + evas_object_hide(sd->selector); } else { @@ -329,18 +348,29 @@ _e_smart_reconfigure_do(void *data) if (!it->frame) { it->frame = edje_object_add(sd->view->evas); - if (sd->view->list_mode) - e_theme_edje_object_set(it->frame, "base/theme/widgets", - "e/modules/everything/thumbview/item/list"); + if (sd->view->mode == MODE_THUMB) + { + e_theme_edje_object_set(it->frame, "base/theme/widgets", + "e/modules/everything/thumbview/item/thumb"); + } else - e_theme_edje_object_set(it->frame, "base/theme/widgets", - "e/modules/everything/thumbview/item/thumb"); + { + e_theme_edje_object_set(it->frame, "base/theme/widgets", + "e/modules/everything/thumbview/item/list"); + if (sd->view->mode == MODE_DETAIL) + edje_object_signal_emit(it->frame, "e,state,detail,show", "e"); + } + evas_object_smart_member_add(it->frame, obj); evas_object_clip_set(it->frame, evas_object_clip_get(obj)); } edje_object_part_text_set(it->frame, "e.text.label", it->item->label); + + if (sd->view->mode == MODE_DETAIL && it->item->detail) + edje_object_part_text_set(it->frame, "e.text.detail", it->item->detail); + evas_object_show(it->frame); if (it->changed) @@ -605,7 +635,7 @@ _animator(void *data) { Smart_Data *sd = evas_object_smart_data_get(data); double da; - double spd = 50.0 / e_config->framerate; + double spd = 55.0 / e_config->framerate; int wait = 0; if (sd->scroll_align != sd->scroll_align_to) @@ -648,7 +678,8 @@ _pan_item_select(Evas_Object *obj, Item *it, int scroll) Smart_Data *sd = evas_object_smart_data_get(obj); double align = -1; int prev = -1; - + int align_to = -1; + if (sd->cur_item) { prev = sd->cur_item->y / sd->cur_item->h; @@ -665,15 +696,13 @@ _pan_item_select(Evas_Object *obj, Item *it, int scroll) sd->cur_item = it; sd->cur_item->selected = EINA_TRUE; - e_scrollframe_child_pos_get(sd->view->sframe, 0, (Evas_Coord *)&sd->scroll_align); - - if (sd->view->list_mode) + if (sd->view->mode == MODE_LIST || + sd->view->mode == MODE_DETAIL) { int all = sd->ch / it->h; int rows = (sd->h < sd->ch) ? (sd->h / it->h) : all; int cur = it->y /it->h; int dist = rows/2; - int align_to = -1; int scroll = (prev > 0 ? cur - prev : 0); if (scroll >= 0) @@ -718,18 +747,6 @@ _pan_item_select(Evas_Object *obj, Item *it, int scroll) } } - if (align_to >= 0) - { - if (!evry_conf->scroll_animate) - { - sd->sel_pos = align_to * it->h; - } - else - { - sd->sel_pos_to = align_to * it->h; - } - } - align *= it->h; } else @@ -743,19 +760,41 @@ _pan_item_select(Evas_Object *obj, Item *it, int scroll) align = it->y; } - if (align >= 0) + if (evry_conf->scroll_animate) { - if (!scroll || !evry_conf->scroll_animate) + double now = ecore_time_get(); + + if (now - sd->last_select < 0.05) + scroll = 0; + + sd->last_select = now; + } + else scroll = 0; + + if (!scroll) + { + if (align_to >= 0) + sd->sel_pos = align_to * it->h; + + if (align >= 0) { sd->scroll_align = align; e_scrollframe_child_pos_set(sd->view->sframe, 0, sd->scroll_align); } - else - { - sd->scroll_align_to = align; - if (!sd->animator) - sd->animator = ecore_animator_add(_animator, obj); - } + if (sd->animator) + ecore_animator_del(sd->animator); + sd->animator = NULL; + } + else + { + if (align_to >= 0) + sd->sel_pos_to = align_to * it->h; + + if (align >= 0) + sd->scroll_align_to = align; + + if (!sd->animator) + sd->animator = ecore_animator_add(_animator, obj); } if (sd->idle_enter) ecore_idle_enterer_del(sd->idle_enter); @@ -842,7 +881,7 @@ _update_frame(Evas_Object *obj) _e_smart_reconfigure_do(obj); - if (sd->view->list_mode) + if (sd->view->mode) { evas_object_show(sd->selector); edje_object_signal_emit(sd->selector, "e,state,selected", "e"); @@ -999,7 +1038,11 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) && (!strcmp(ev->key, "2"))) { - v->list_mode = v->list_mode ? EINA_FALSE : EINA_TRUE; + if (v->mode == MODE_LIST) + v->mode = MODE_DETAIL; + else + v->mode = MODE_LIST; + v->zoom = 0; _clear_items(v->span); _update_frame(v->span); @@ -1009,11 +1052,19 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) ((!strcmp(ev->key, "plus")) || (!strcmp(ev->key, "3")))) { - v->zoom++; - if (v->zoom > 2) v->zoom = 0; - if (v->zoom == 2) - _clear_items(v->span); - + if (v->mode != MODE_THUMB) + { + v->zoom = 0; + v->mode = MODE_THUMB; + _clear_items(v->span); + } + else + { + v->zoom++; + if (v->zoom > 2) v->zoom = 0; + if (v->zoom == 2) + _clear_items(v->span); + } _update_frame(v->span); goto end; } @@ -1027,7 +1078,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) if (sd->items) l = eina_list_data_find_list(sd->items, sd->cur_item); - if (!v->list_mode && !evry_conf->cycle_mode) + if (!v->mode && !evry_conf->cycle_mode) { if (!strcmp(ev->key, "Right")) { @@ -1108,7 +1159,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) } else if (!strcmp(ev->key, "Return")) { - if (!v->list_mode) + if (!v->mode) { if (evry_browse_item(NULL)) goto end; @@ -1175,10 +1226,10 @@ _view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow) v->state = s; v->evas = evas_object_evas_get(swallow); - if (parent->list_mode < 0) - v->list_mode = evry_conf->view_mode ? 0 : 1; + if (parent->mode < 0) + v->mode = evry_conf->view_mode; else - v->list_mode = parent->list_mode; + v->mode = parent->mode; v->zoom = parent->zoom; @@ -1245,7 +1296,7 @@ view_thumb_init(void) v->view.update = &_view_update; v->view.clear = &_view_clear; v->view.cb_key_down = &_cb_key_down; - v->list_mode = -1; + v->mode = -1; evry_view_register(EVRY_VIEW(v), 1);