forked from enlightenment/enlightenment
add action option whether it is specific for a context provided by subject item.
e.g. copy is not specific for images while image viewer action is SVN revision: 48547
This commit is contained in:
parent
12c8a33b11
commit
60ae3759de
|
@ -89,6 +89,83 @@ static Eina_Bool clear_cache = EINA_FALSE;
|
|||
static void _cleanup(Evry_Plugin *plugin);
|
||||
static Eina_Bool _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata);
|
||||
|
||||
/* static E_Config_DD *cache_item_edd = NULL;
|
||||
* static E_Config_DD *cache_edd = NULL;
|
||||
*
|
||||
* static void
|
||||
* _cache_init(void)
|
||||
* {
|
||||
* #undef T
|
||||
* #undef D
|
||||
* cache_item_edd = E_CONFIG_DD_NEW("Cache_Item", Cache_Item);
|
||||
* #define T History_Item
|
||||
* #define D hist_item_edd
|
||||
* E_CONFIG_VAL(D, T, last_used, DOUBLE);
|
||||
* E_CONFIG_VAL(D, T, mime, STR);
|
||||
* #undef T
|
||||
* #undef D
|
||||
* cache_edd = E_CONFIG_DD_NEW("File_Cache", File_Cache);
|
||||
* #define T Evry_History
|
||||
* #define D hist_edd
|
||||
* E_CONFIG_VAL(D, T, version, INT);
|
||||
* E_CONFIG_HASH(D, T, files, hist_item_edd);
|
||||
* #undef T
|
||||
* #undef D
|
||||
* }
|
||||
*
|
||||
* static Eina_Bool
|
||||
* _cache_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata)
|
||||
* {
|
||||
* Cache_Item *ci = data;
|
||||
*
|
||||
* eina_stringshare_del(ci->mime);
|
||||
* E_FREE(ci);
|
||||
*
|
||||
* return 1;
|
||||
* }
|
||||
*
|
||||
* static void
|
||||
* _cache_free(void)
|
||||
* {
|
||||
* Cleanup_Data *d;
|
||||
* char *key;
|
||||
*
|
||||
* _cache = e_config_domain_load("module.everything.filecache", cache_edd);
|
||||
*
|
||||
* if (_cache)
|
||||
* {
|
||||
* Eina_List *keys = NULL
|
||||
* if (_cache->files)
|
||||
* {
|
||||
* eina_hash_foreach(_cache->items, _cache_cleanup_cb, &keys);
|
||||
* EINA_LIST_FREE(keys, key)
|
||||
* eina_hash_del_by_key(evry_hist->subjects, key);
|
||||
* }
|
||||
*
|
||||
* _cache_unload();
|
||||
* }
|
||||
*
|
||||
* E_CONFIG_DD_FREE(cache_item_edd);
|
||||
* E_CONFIG_DD_FREE(cache_edd);
|
||||
* }
|
||||
*
|
||||
* static void
|
||||
* _cache_load(void)
|
||||
* {
|
||||
* if (_cache) return;
|
||||
*
|
||||
* _cache = e_config_domain_load("module.everything.filecache", cache_edd);
|
||||
*
|
||||
* if (!_cache)
|
||||
* {
|
||||
* _cache = E_NEW(File_Cache, 1);
|
||||
* evry_hist->version = 1;
|
||||
* }
|
||||
* if (!_cache->files)
|
||||
* _cache->files = eina_hash_string_superfast_new(NULL);
|
||||
* } */
|
||||
|
||||
|
||||
|
||||
static void
|
||||
_item_fill(Evry_Item_File *file)
|
||||
|
@ -1192,6 +1269,7 @@ _plugins_init(void)
|
|||
EVRY_TYPE_FILE, 0,
|
||||
"system-run",
|
||||
_open_term_action, NULL);
|
||||
act->remember_context = EINA_FALSE;
|
||||
evry_action_register(act, 2);
|
||||
_actions = eina_list_append(_actions, act);
|
||||
|
||||
|
@ -1199,6 +1277,7 @@ _plugins_init(void)
|
|||
EVRY_TYPE_FILE, 0,
|
||||
"edit-delete",
|
||||
_file_trash_action, NULL);
|
||||
act->remember_context = EINA_FALSE;
|
||||
EVRY_ITEM_DATA_INT_SET(act, ACT_TRASH);
|
||||
evry_action_register(act, 2);
|
||||
_actions = eina_list_append(_actions, act);
|
||||
|
@ -1217,6 +1296,7 @@ _plugins_init(void)
|
|||
"go-next",
|
||||
_file_copy_action, NULL);
|
||||
act->it2.subtype = EVRY_TYPE_DIR;
|
||||
act->remember_context = EINA_FALSE;
|
||||
EVRY_ITEM_DATA_INT_SET(act, ACT_COPY);
|
||||
evry_action_register(act, 2);
|
||||
_actions = eina_list_append(_actions, act);
|
||||
|
@ -1226,6 +1306,7 @@ _plugins_init(void)
|
|||
"go-next",
|
||||
_file_copy_action, NULL);
|
||||
act->it2.subtype = EVRY_TYPE_DIR;
|
||||
act->remember_context = EINA_FALSE;
|
||||
EVRY_ITEM_DATA_INT_SET(act, ACT_MOVE);
|
||||
evry_action_register(act, 2);
|
||||
_actions = eina_list_append(_actions, act);
|
||||
|
|
|
@ -200,6 +200,10 @@ struct _Evry_Action
|
|||
Eina_List *items;
|
||||
} it2;
|
||||
|
||||
/* this action is specific for a context. e.g. copy for file-type
|
||||
is not, image viewer is. default is TRUE */
|
||||
Eina_Bool remember_context;
|
||||
|
||||
int (*action) (Evry_Action *act);
|
||||
int (*check_item) (Evry_Action *act, const Evry_Item *it);
|
||||
void (*free) (Evry_Action *act);
|
||||
|
@ -396,6 +400,9 @@ struct _Plugin_Config
|
|||
|
||||
int view_mode;
|
||||
|
||||
int min_query;
|
||||
int aggregate;
|
||||
|
||||
Evry_Plugin *plugin;
|
||||
};
|
||||
|
||||
|
|
|
@ -264,12 +264,21 @@ evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *i
|
|||
const char *id;
|
||||
const char *type;
|
||||
|
||||
if (!it || !it->plugin->history) return NULL;
|
||||
int rem_ctxt = 1;
|
||||
|
||||
if (!it) return NULL;
|
||||
|
||||
type = evry_type_get(it->type);
|
||||
|
||||
id = (it->id ? it->id : it->label);
|
||||
|
||||
if (it->type == EVRY_TYPE_ACTION)
|
||||
{
|
||||
GET_ACTION(act, it);
|
||||
if (!act->remember_context)
|
||||
rem_ctxt = 0;
|
||||
}
|
||||
|
||||
he = eina_hash_find(hist, id);
|
||||
if (!he)
|
||||
{
|
||||
|
@ -280,7 +289,7 @@ evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *i
|
|||
{
|
||||
EINA_LIST_FOREACH(he->items, l, hi)
|
||||
if ((hi->plugin == it->plugin->name) &&
|
||||
(ctxt == hi->context) &&
|
||||
(!rem_ctxt || (ctxt == hi->context)) &&
|
||||
(type == hi->type))
|
||||
break;
|
||||
}
|
||||
|
@ -302,8 +311,10 @@ evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *i
|
|||
hi->transient = it->plugin->transient;
|
||||
hi->count += 1;
|
||||
|
||||
if (ctxt && !hi->context)
|
||||
hi->context = eina_stringshare_ref(ctxt);
|
||||
if (ctxt && !hi->context && rem_ctxt)
|
||||
{
|
||||
hi->context = eina_stringshare_ref(ctxt);
|
||||
}
|
||||
|
||||
if (input)
|
||||
{
|
||||
|
@ -323,7 +334,8 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, c
|
|||
History_Entry *he;
|
||||
History_Item *hi;
|
||||
Eina_List *l;
|
||||
|
||||
int rem_ctxt = 1;
|
||||
|
||||
if (!it->plugin->history)
|
||||
return 0;
|
||||
|
||||
|
@ -331,6 +343,13 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, c
|
|||
if (!(he = eina_hash_find(hist, (it->id ? it->id : it->label))))
|
||||
return 0;
|
||||
|
||||
if (it->type == EVRY_TYPE_ACTION)
|
||||
{
|
||||
GET_ACTION(act, it);
|
||||
if (!act->remember_context)
|
||||
rem_ctxt = 0;
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(he->items, l, hi)
|
||||
{
|
||||
if (hi->plugin != it->plugin->name)
|
||||
|
@ -371,6 +390,13 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, c
|
|||
it->usage = hi->last_used;
|
||||
}
|
||||
|
||||
/* XXX remopve just for update */
|
||||
if (!rem_ctxt && hi->context)
|
||||
{
|
||||
eina_stringshare_del(hi->context);
|
||||
hi->context = NULL;
|
||||
}
|
||||
|
||||
if (ctxt != hi->context)
|
||||
it->usage /= 2.0;
|
||||
|
||||
|
|
|
@ -227,6 +227,8 @@ evry_action_new(const char *name, const char *label,
|
|||
act->it1.type = type_in1;
|
||||
act->it2.type = type_in2;
|
||||
|
||||
act->remember_context = EINA_TRUE;
|
||||
|
||||
act->action = action;
|
||||
act->check_item = check_item;
|
||||
|
||||
|
|
Loading…
Reference in New Issue