forked from enlightenment/enlightenment
'everything'
- identify border items as transient to be removed from history on shutdown - history_add function cleanup SVN revision: 42103
This commit is contained in:
parent
66bfba1958
commit
e6de679678
|
@ -73,8 +73,7 @@ struct _Evry_Item
|
||||||
/* item can be browsed, e.g. folders */
|
/* item can be browsed, e.g. folders */
|
||||||
Eina_Bool browseable;
|
Eina_Bool browseable;
|
||||||
|
|
||||||
/* these are only for internally use by plugins */
|
/* for internally use by plugins */
|
||||||
/* used e.g. as pointer for item data (Efreet_Desktop) */
|
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
/* priority hints for sorting */
|
/* priority hints for sorting */
|
||||||
|
@ -83,9 +82,13 @@ struct _Evry_Item
|
||||||
/* store value of fuzzy match with input */
|
/* store value of fuzzy match with input */
|
||||||
int fuzzy_match;
|
int fuzzy_match;
|
||||||
|
|
||||||
/* optional: plugin can set id to identify it in
|
/* optional: plugin can set id to identify
|
||||||
history otherwise label is used */
|
* it in history otherwise label is used */
|
||||||
const char *id;
|
const char *id;
|
||||||
|
|
||||||
|
/* if transient item is removed from history
|
||||||
|
* on shutdown */
|
||||||
|
Eina_Bool transient;
|
||||||
|
|
||||||
/* do not set by plugin! */
|
/* do not set by plugin! */
|
||||||
Evry_Item *next;
|
Evry_Item *next;
|
||||||
|
|
|
@ -60,9 +60,61 @@ _hist_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_hist_cleanup_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata)
|
||||||
|
{
|
||||||
|
History_Entry *he = data;
|
||||||
|
History_Item *hi;
|
||||||
|
Eina_List *l, *ll, *keys = fdata;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH_SAFE(he->items, l, ll, hi)
|
||||||
|
{
|
||||||
|
/* item is transient */
|
||||||
|
if (!hi->count)
|
||||||
|
{
|
||||||
|
if (hi->input)
|
||||||
|
eina_stringshare_del(hi->input);
|
||||||
|
if (hi->plugin)
|
||||||
|
eina_stringshare_del(hi->plugin);
|
||||||
|
if (hi->context)
|
||||||
|
eina_stringshare_del(hi->context);
|
||||||
|
E_FREE(hi);
|
||||||
|
|
||||||
|
he->items = eina_list_remove_list(he->items, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!he->items)
|
||||||
|
{
|
||||||
|
E_FREE(he);
|
||||||
|
keys = eina_list_append(keys, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
evry_history_free(void)
|
evry_history_free(void)
|
||||||
{
|
{
|
||||||
|
Eina_List *keys = NULL;
|
||||||
|
char *key;
|
||||||
|
|
||||||
|
evry_hist = e_config_domain_load("module.everything.history", hist_edd);
|
||||||
|
if (evry_hist)
|
||||||
|
{
|
||||||
|
keys = eina_list_append(keys, NULL);
|
||||||
|
eina_hash_foreach(evry_hist->subjects, _hist_cleanup_cb, keys);
|
||||||
|
EINA_LIST_FREE(keys, key)
|
||||||
|
if (key) eina_hash_del_by_key(evry_hist->subjects, key);
|
||||||
|
|
||||||
|
keys = eina_list_append(keys, NULL);
|
||||||
|
eina_hash_foreach(evry_hist->actions, _hist_cleanup_cb, keys);
|
||||||
|
EINA_LIST_FREE(keys, key)
|
||||||
|
if (key) eina_hash_del_by_key(evry_hist->subjects, key);
|
||||||
|
|
||||||
|
evry_history_unload();
|
||||||
|
}
|
||||||
|
|
||||||
E_CONFIG_DD_FREE(hist_item_edd);
|
E_CONFIG_DD_FREE(hist_item_edd);
|
||||||
E_CONFIG_DD_FREE(hist_entry_edd);
|
E_CONFIG_DD_FREE(hist_entry_edd);
|
||||||
E_CONFIG_DD_FREE(hist_edd);
|
E_CONFIG_DD_FREE(hist_edd);
|
||||||
|
@ -77,6 +129,9 @@ evry_history_load(void)
|
||||||
{
|
{
|
||||||
eina_hash_foreach(evry_hist->subjects, _hist_free_cb, NULL);
|
eina_hash_foreach(evry_hist->subjects, _hist_free_cb, NULL);
|
||||||
eina_hash_foreach(evry_hist->actions, _hist_free_cb, NULL);
|
eina_hash_foreach(evry_hist->actions, _hist_free_cb, NULL);
|
||||||
|
eina_hash_free(evry_hist->subjects);
|
||||||
|
eina_hash_free(evry_hist->actions);
|
||||||
|
|
||||||
E_FREE(evry_hist);
|
E_FREE(evry_hist);
|
||||||
evry_hist = NULL;
|
evry_hist = NULL;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +167,7 @@ void
|
||||||
evry_history_add(Eina_Hash *hist, Evry_State *s)
|
evry_history_add(Eina_Hash *hist, Evry_State *s)
|
||||||
{
|
{
|
||||||
History_Entry *he;
|
History_Entry *he;
|
||||||
History_Item *hi;
|
History_Item *hi = NULL;
|
||||||
Evry_Item *it;
|
Evry_Item *it;
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
const char *id;
|
const char *id;
|
||||||
|
@ -128,7 +183,12 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
||||||
id = it->label;
|
id = it->label;
|
||||||
|
|
||||||
he = eina_hash_find(hist, id);
|
he = eina_hash_find(hist, id);
|
||||||
if (he)
|
if (!he)
|
||||||
|
{
|
||||||
|
he = E_NEW(History_Entry, 1);
|
||||||
|
eina_hash_add(hist, id, he);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/* found history entry */
|
/* found history entry */
|
||||||
EINA_LIST_FOREACH(he->items, l, hi)
|
EINA_LIST_FOREACH(he->items, l, hi)
|
||||||
|
@ -165,7 +225,8 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* remember input for item */
|
/* remember input for item */
|
||||||
hi->count++;
|
if (!it->transient)
|
||||||
|
hi->count++;
|
||||||
hi->last_used /= 2.0;
|
hi->last_used /= 2.0;
|
||||||
hi->last_used += ecore_time_get();
|
hi->last_used += ecore_time_get();
|
||||||
|
|
||||||
|
@ -173,31 +234,19 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
||||||
hi->input = eina_stringshare_add(s->input);
|
hi->input = eina_stringshare_add(s->input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hi)
|
|
||||||
{
|
|
||||||
hi = E_NEW(History_Item, 1);
|
|
||||||
hi->plugin = eina_stringshare_ref(it->plugin->name);
|
|
||||||
hi->last_used = ecore_time_get();
|
|
||||||
hi->count = 1;
|
|
||||||
if (s->input)
|
|
||||||
hi->input = eina_stringshare_add(s->input);
|
|
||||||
|
|
||||||
he->items = eina_list_append(he->items, hi);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
if (!hi)
|
||||||
he = E_NEW(History_Entry, 1);
|
{
|
||||||
hi = E_NEW(History_Item, 1);
|
hi = E_NEW(History_Item, 1);
|
||||||
hi->plugin = eina_stringshare_ref(it->plugin->name);
|
hi->plugin = eina_stringshare_ref(it->plugin->name);
|
||||||
hi->last_used = ecore_time_get();
|
hi->last_used = ecore_time_get();
|
||||||
hi->count = 1;
|
if (!it->transient)
|
||||||
|
hi->count = 1;
|
||||||
if (s->input)
|
if (s->input)
|
||||||
hi->input = eina_stringshare_add(s->input);
|
hi->input = eina_stringshare_add(s->input);
|
||||||
|
|
||||||
he->items = eina_list_append(he->items, hi);
|
he->items = eina_list_append(he->items, hi);
|
||||||
eina_hash_add(hist, id, he);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,11 +91,9 @@ _item_add(Evry_Plugin *p, E_Border *bd, int match, int *prio)
|
||||||
it->data = bd;
|
it->data = bd;
|
||||||
it->fuzzy_match = match;
|
it->fuzzy_match = match;
|
||||||
it->priority = *prio;
|
it->priority = *prio;
|
||||||
if (bd->client.icccm.class)
|
it->transient = EINA_TRUE;
|
||||||
it->id = eina_stringshare_add(bd->client.icccm.class);
|
it->id = eina_stringshare_add(e_util_winid_str_get(bd->win));
|
||||||
if (bd->client.icccm.name)
|
|
||||||
it->id = eina_stringshare_add(bd->client.icccm.name);
|
|
||||||
|
|
||||||
*prio += 1;
|
*prio += 1;
|
||||||
|
|
||||||
eina_hash_add(border_hash, &bd, it);
|
eina_hash_add(border_hash, &bd, it);
|
||||||
|
|
Loading…
Reference in New Issue