diff --git a/src/modules/everything-apps/e_mod_main.c b/src/modules/everything-apps/e_mod_main.c index d956ae776..9eba26067 100644 --- a/src/modules/everything-apps/e_mod_main.c +++ b/src/modules/everything-apps/e_mod_main.c @@ -664,6 +664,30 @@ _fetch(Evry_Plugin *plugin, const char *input) return 1; } + +static int +_complete(Evry_Plugin *plugin, const Evry_Item *it, char **input) +{ + ITEM_APP(app, it); + + char buf[128]; + + if (app->desktop) + { + char *space = strchr(app->desktop->exec, ' '); + + snprintf(buf, sizeof(buf), "%s ", app->desktop->exec); + if (space) + buf[1 + space - app->desktop->exec] = '\0'; + } + else + snprintf(buf, sizeof(buf), "%s ", app->file); + + *input = strdup(buf); + + return EVRY_COMPLETE_INPUT; +} + static Evas_Object * _icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) { @@ -887,7 +911,8 @@ module_init(void) p1 = E_NEW(Plugin, 1); evry_plugin_new(EVRY_PLUGIN(p1), "Applications", type_subject, "", "APPLICATION", 0, NULL, NULL, _begin, _cleanup, _fetch, NULL, _icon_get, _free_plugin); - + EVRY_PLUGIN(p1)->complete = &_complete; + p2 = E_NEW(Plugin, 1); evry_plugin_new(EVRY_PLUGIN(p2), "Open With...", type_action, "FILE", "", 0, NULL, NULL, _begin_open_with, _cleanup, _fetch, _open_with_action, diff --git a/src/modules/everything/Evry.h b/src/modules/everything/Evry.h index 7cd2874ec..160713900 100644 --- a/src/modules/everything/Evry.h +++ b/src/modules/everything/Evry.h @@ -3,7 +3,7 @@ #include "e.h" -#define EVRY_API_VERSION 1 +#define EVRY_API_VERSION 2 #define EVRY_ACTION_OTHER 0 @@ -14,6 +14,10 @@ #define EVRY_ASYNC_UPDATE_CLEAR 1 #define EVRY_ASYNC_UPDATE_REFRESH 2 +#define EVRY_COMPLETE_NONE 0 +#define EVRY_COMPLETE_INPUT 1 +#define EVRY_COMPLETE_BROWSE 2 + #define VIEW_MODE_LIST 0 #define VIEW_MODE_DETAIL 1 #define VIEW_MODE_THUMB 2 @@ -184,7 +188,10 @@ struct _Evry_Plugin /* only used when plugin is of type_action */ int (*action) (Evry_Plugin *p, const Evry_Item *item); - /* int (*complete) (Evry_Plugin *p, const Evry_Item *item, char *input); */ + /* try to complete current item: + return: EVRY_COMPLETE_INPUT when input was changed + return: EVRY_COMPLETE_BROWSE to browse item */ + int (*complete) (Evry_Plugin *p, const Evry_Item *item, char **input); /* handle key events: return 1 when key is handled by plugin */ int (*cb_key_down) (Evry_Plugin *p, const Ecore_Event_Key *ev); diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c index 6a080906b..32282d8ef 100644 --- a/src/modules/everything/evry.c +++ b/src/modules/everything/evry.c @@ -1373,11 +1373,28 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)) && (!strcmp(key, "Tab"))))) { - /* int action = 0; - * if (s->plugin->complete) - * action = s->plugin->complete(s->plugin, s->cur_item, &s->input); */ + int action = 0; + char *input = NULL; + Evry_Item *it = s->cur_item; - evry_browse_item(selector); + evry_item_ref(it); + + if (it->plugin->complete) + action = it->plugin->complete(it->plugin, it, &input); + else + evry_browse_item(selector); + + if (action == EVRY_COMPLETE_INPUT) + { + snprintf(s->input, INPUTLEN, "%s", input); + _evry_update_text_label(s); + _evry_cb_update_timer(selector); + evry_item_select(s, it); + } + + E_FREE(input); + + evry_item_free(it); } else if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) && (!strcmp(key, "Delete") || !strcmp(key, "Insert"))) diff --git a/src/modules/everything/evry_plug_aggregator.c b/src/modules/everything/evry_plug_aggregator.c index 9d757aec8..963203bdd 100644 --- a/src/modules/everything/evry_plug_aggregator.c +++ b/src/modules/everything/evry_plug_aggregator.c @@ -50,6 +50,11 @@ _cb_sort(const void *data1, const void *data2) const Evry_Item *it1 = data1; const Evry_Item *it2 = data2; + if (it1->selected) + return -1; + if (it2->selected) + return 1; + if (it1->usage && it2->usage) return (it1->usage > it2->usage ? -1 : 1); if (it1->usage && !it2->usage) diff --git a/src/modules/everything/evry_util.c b/src/modules/everything/evry_util.c index b484a6296..bee55ad26 100644 --- a/src/modules/everything/evry_util.c +++ b/src/modules/everything/evry_util.c @@ -194,6 +194,13 @@ evry_fuzzy_match(const char *str, const char *match) } } + if (sum > 0) + { + /* exact match ? */ + if (strlen(str) != m_len) + sum += 10; + } + return sum; }