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 *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 */
|
||||
Eina_Bool browseable;
|
||||
|
||||
|
|
|
@ -140,8 +140,8 @@ void evry_history_init(void);
|
|||
void evry_history_free(void);
|
||||
void evry_history_load(void);
|
||||
void evry_history_unload(void);
|
||||
void evry_history_add(Eina_Hash *hist, Evry_State *s);
|
||||
EAPI int evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input);
|
||||
void evry_history_add(Eina_Hash *hist, Evry_State *s, const char *ctxt);
|
||||
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);
|
||||
void evry_browse_back(Evry_Selector *sel);
|
||||
|
|
|
@ -306,7 +306,8 @@ 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->free)
|
||||
it->free(it);
|
||||
else
|
||||
|
@ -1080,7 +1081,7 @@ evry_browse_item(Evry_Selector *sel)
|
|||
if (!plugins)
|
||||
return 1;
|
||||
|
||||
evry_history_add(sel->history, s);
|
||||
evry_history_add(sel->history, s, NULL);
|
||||
|
||||
if (s->view)
|
||||
{
|
||||
|
@ -1440,9 +1441,9 @@ _evry_plugin_action(Evry_Selector *sel, int finished)
|
|||
}
|
||||
else return;
|
||||
|
||||
evry_history_add(evry_hist->subjects, s_subject);
|
||||
evry_history_add(evry_hist->actions, s_action);
|
||||
evry_history_add(evry_hist->subjects, s_object);
|
||||
evry_history_add(evry_hist->subjects, s_subject, NULL);
|
||||
evry_history_add(evry_hist->actions, s_action, s_subject->cur_item->context);
|
||||
evry_history_add(evry_hist->subjects, s_object, s_action->cur_item->context);
|
||||
|
||||
/* let subject and object plugin know that an action was performed */
|
||||
if (s_subject->plugin->action)
|
||||
|
|
|
@ -195,7 +195,7 @@ evry_history_unload(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_Item *hi = NULL;
|
||||
|
@ -219,7 +219,9 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
|||
else
|
||||
{
|
||||
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)
|
||||
|
@ -236,7 +238,9 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
|||
hi->usage += TIME_FACTOR(hi->last_used);
|
||||
hi->transient = it->transient;
|
||||
hi->count += (hi->transient ? 2:1);
|
||||
|
||||
if (ctxt && !hi->context)
|
||||
hi->context = eina_stringshare_ref(ctxt);
|
||||
|
||||
if (s->input)
|
||||
{
|
||||
if (hi->input)
|
||||
|
@ -248,7 +252,7 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
|||
}
|
||||
|
||||
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_Item *hi;
|
||||
|
@ -266,7 +270,7 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input)
|
|||
|
||||
if (!input || !hi->input)
|
||||
{
|
||||
it->usage = hi->usage * hi->count;
|
||||
it->usage += hi->usage * hi->count;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (hi->context && ctxt)
|
||||
{
|
||||
if (hi->context == ctxt)
|
||||
it->usage += hi->usage * hi->count * 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (it->usage > 0.0)
|
||||
|
|
|
@ -99,13 +99,25 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
Evry_State *s;
|
||||
Eina_List *l, *ll, *lp;
|
||||
Evry_Item *it;
|
||||
int cnt = 0;
|
||||
int i, cnt = 0;
|
||||
Eina_List *items = NULL;
|
||||
|
||||
const char *context = NULL;
|
||||
|
||||
EVRY_PLUGIN_ITEMS_FREE(p);
|
||||
|
||||
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 */
|
||||
lp = s->cur_plugins->next;
|
||||
|
||||
|
@ -153,7 +165,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
{
|
||||
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)))
|
||||
{
|
||||
evry_item_ref(it);
|
||||
|
|
|
@ -50,7 +50,8 @@ _item_fill(Evry_Item_File *file)
|
|||
if ((mime = efreet_mime_type_get(file->uri)))
|
||||
{
|
||||
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;
|
||||
|
@ -202,8 +203,11 @@ _scan_end_func(void *data)
|
|||
p->files = eina_list_append(p->files, file);
|
||||
|
||||
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;
|
||||
cnt += _append_file(p, file);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue