forked from enlightenment/enlightenment
'everything'
- remember context of action. e.g. which app was used for opening a file with a specific mimetype SVN revision: 42205
This commit is contained in:
parent
bbdf974635
commit
b5ca26e9e9
|
@ -70,6 +70,10 @@ struct _Evry_Item
|
||||||
const char *label;
|
const char *label;
|
||||||
const char *icon;
|
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;
|
||||||
|
|
||||||
/* item can be browsed, e.g. folders */
|
/* item can be browsed, e.g. folders */
|
||||||
Eina_Bool browseable;
|
Eina_Bool browseable;
|
||||||
|
|
||||||
|
|
|
@ -140,8 +140,8 @@ void evry_history_init(void);
|
||||||
void evry_history_free(void);
|
void evry_history_free(void);
|
||||||
void evry_history_load(void);
|
void evry_history_load(void);
|
||||||
void evry_history_unload(void);
|
void evry_history_unload(void);
|
||||||
void evry_history_add(Eina_Hash *hist, Evry_State *s);
|
void evry_history_add(Eina_Hash *hist, Evry_State *s, const char *ctxt);
|
||||||
EAPI int evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input);
|
int evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, const char *ctxt);
|
||||||
|
|
||||||
EAPI int evry_browse_item(Evry_Selector *sel);
|
EAPI int evry_browse_item(Evry_Selector *sel);
|
||||||
void evry_browse_back(Evry_Selector *sel);
|
void evry_browse_back(Evry_Selector *sel);
|
||||||
|
|
|
@ -306,6 +306,7 @@ evry_item_free(Evry_Item *it)
|
||||||
|
|
||||||
if (it->label) eina_stringshare_del(it->label);
|
if (it->label) eina_stringshare_del(it->label);
|
||||||
if (it->id) eina_stringshare_del(it->id);
|
if (it->id) eina_stringshare_del(it->id);
|
||||||
|
if (it->context) eina_stringshare_del(it->context);
|
||||||
|
|
||||||
if (it->free)
|
if (it->free)
|
||||||
it->free(it);
|
it->free(it);
|
||||||
|
@ -1080,7 +1081,7 @@ evry_browse_item(Evry_Selector *sel)
|
||||||
if (!plugins)
|
if (!plugins)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
evry_history_add(sel->history, s);
|
evry_history_add(sel->history, s, NULL);
|
||||||
|
|
||||||
if (s->view)
|
if (s->view)
|
||||||
{
|
{
|
||||||
|
@ -1440,9 +1441,9 @@ _evry_plugin_action(Evry_Selector *sel, int finished)
|
||||||
}
|
}
|
||||||
else return;
|
else return;
|
||||||
|
|
||||||
evry_history_add(evry_hist->subjects, s_subject);
|
evry_history_add(evry_hist->subjects, s_subject, NULL);
|
||||||
evry_history_add(evry_hist->actions, s_action);
|
evry_history_add(evry_hist->actions, s_action, s_subject->cur_item->context);
|
||||||
evry_history_add(evry_hist->subjects, s_object);
|
evry_history_add(evry_hist->subjects, s_object, s_action->cur_item->context);
|
||||||
|
|
||||||
/* let subject and object plugin know that an action was performed */
|
/* let subject and object plugin know that an action was performed */
|
||||||
if (s_subject->plugin->action)
|
if (s_subject->plugin->action)
|
||||||
|
|
|
@ -195,7 +195,7 @@ evry_history_unload(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
evry_history_add(Eina_Hash *hist, Evry_State *s)
|
evry_history_add(Eina_Hash *hist, Evry_State *s, const char *ctxt)
|
||||||
{
|
{
|
||||||
History_Entry *he;
|
History_Entry *he;
|
||||||
History_Item *hi = NULL;
|
History_Item *hi = NULL;
|
||||||
|
@ -219,7 +219,9 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EINA_LIST_FOREACH(he->items, l, hi)
|
EINA_LIST_FOREACH(he->items, l, hi)
|
||||||
if (hi->plugin == it->plugin->name) break;
|
if ((hi->plugin == it->plugin->name) &&
|
||||||
|
(ctxt == hi->context))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hi)
|
if (!hi)
|
||||||
|
@ -236,6 +238,8 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
||||||
hi->usage += TIME_FACTOR(hi->last_used);
|
hi->usage += TIME_FACTOR(hi->last_used);
|
||||||
hi->transient = it->transient;
|
hi->transient = it->transient;
|
||||||
hi->count += (hi->transient ? 2:1);
|
hi->count += (hi->transient ? 2:1);
|
||||||
|
if (ctxt && !hi->context)
|
||||||
|
hi->context = eina_stringshare_ref(ctxt);
|
||||||
|
|
||||||
if (s->input)
|
if (s->input)
|
||||||
{
|
{
|
||||||
|
@ -248,7 +252,7 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input)
|
evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, const char *ctxt)
|
||||||
{
|
{
|
||||||
History_Entry *he;
|
History_Entry *he;
|
||||||
History_Item *hi;
|
History_Item *hi;
|
||||||
|
@ -266,7 +270,7 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input)
|
||||||
|
|
||||||
if (!input || !hi->input)
|
if (!input || !hi->input)
|
||||||
{
|
{
|
||||||
it->usage = hi->usage * hi->count;
|
it->usage += hi->usage * hi->count;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -280,6 +284,11 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input)
|
||||||
it->usage += hi->usage * hi->count;
|
it->usage += hi->usage * hi->count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (hi->context && ctxt)
|
||||||
|
{
|
||||||
|
if (hi->context == ctxt)
|
||||||
|
it->usage += hi->usage * hi->count * 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it->usage > 0.0)
|
if (it->usage > 0.0)
|
||||||
|
|
|
@ -99,13 +99,25 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
||||||
Evry_State *s;
|
Evry_State *s;
|
||||||
Eina_List *l, *ll, *lp;
|
Eina_List *l, *ll, *lp;
|
||||||
Evry_Item *it;
|
Evry_Item *it;
|
||||||
int cnt = 0;
|
int i, cnt = 0;
|
||||||
Eina_List *items = NULL;
|
Eina_List *items = NULL;
|
||||||
|
const char *context = NULL;
|
||||||
|
|
||||||
EVRY_PLUGIN_ITEMS_FREE(p);
|
EVRY_PLUGIN_ITEMS_FREE(p);
|
||||||
|
|
||||||
s = p->selector->state;
|
s = p->selector->state;
|
||||||
|
|
||||||
|
for (i = 1; i < 3; i++)
|
||||||
|
{
|
||||||
|
Evry_Item *item;
|
||||||
|
if (p->selector == selectors[i])
|
||||||
|
{
|
||||||
|
item = selectors[i-1]->state->cur_item;
|
||||||
|
context = item->context;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* first is aggregator itself */
|
/* first is aggregator itself */
|
||||||
lp = s->cur_plugins->next;
|
lp = s->cur_plugins->next;
|
||||||
|
|
||||||
|
@ -153,7 +165,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
||||||
{
|
{
|
||||||
EINA_LIST_FOREACH(pp->items, ll, it)
|
EINA_LIST_FOREACH(pp->items, ll, it)
|
||||||
{
|
{
|
||||||
if (evry_history_item_usage_set(p->selector->history, it, input) &&
|
if (evry_history_item_usage_set(p->selector->history, it, input, context) &&
|
||||||
(!eina_list_data_find_list(items, it)))
|
(!eina_list_data_find_list(items, it)))
|
||||||
{
|
{
|
||||||
evry_item_ref(it);
|
evry_item_ref(it);
|
||||||
|
|
|
@ -50,6 +50,7 @@ _item_fill(Evry_Item_File *file)
|
||||||
if ((mime = efreet_mime_type_get(file->uri)))
|
if ((mime = efreet_mime_type_get(file->uri)))
|
||||||
{
|
{
|
||||||
file->mime = eina_stringshare_add(mime);
|
file->mime = eina_stringshare_add(mime);
|
||||||
|
EVRY_ITEM(file)->context = eina_stringshare_ref(file->mime);
|
||||||
|
|
||||||
if ((!strcmp(mime, "inode/directory")) ||
|
if ((!strcmp(mime, "inode/directory")) ||
|
||||||
(!strcmp(mime, "inode/mount-point")))
|
(!strcmp(mime, "inode/mount-point")))
|
||||||
|
@ -202,7 +203,10 @@ _scan_end_func(void *data)
|
||||||
p->files = eina_list_append(p->files, file);
|
p->files = eina_list_append(p->files, file);
|
||||||
|
|
||||||
if (item->browseable)
|
if (item->browseable)
|
||||||
|
{
|
||||||
file->mime = eina_stringshare_ref(mime_folder);
|
file->mime = eina_stringshare_ref(mime_folder);
|
||||||
|
EVRY_ITEM(file)->context = eina_stringshare_ref(file->mime);
|
||||||
|
}
|
||||||
|
|
||||||
if (p->command || cnt >= MAX_ITEMS) continue;
|
if (p->command || cnt >= MAX_ITEMS) continue;
|
||||||
cnt += _append_file(p, file);
|
cnt += _append_file(p, file);
|
||||||
|
|
Loading…
Reference in New Issue