forked from enlightenment/enlightenment
'everything'
- this is hopefully the last format change of history for now.. - keep the numbers low. need to add normalization when first item hits 1.0 SVN revision: 42137
This commit is contained in:
parent
bc0dfbad47
commit
66a5ec3e92
|
@ -65,6 +65,7 @@ struct _History
|
||||||
int version;
|
int version;
|
||||||
Eina_Hash *subjects;
|
Eina_Hash *subjects;
|
||||||
Eina_Hash *actions;
|
Eina_Hash *actions;
|
||||||
|
double begin;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#include "e_mod_main.h"
|
#include "e_mod_main.h"
|
||||||
|
|
||||||
#define HISTORY_VERSION 4
|
#define HISTORY_VERSION 6
|
||||||
|
|
||||||
#define SEVEN_DAYS 604800
|
#define TIME_NOW (1.0 - (evry_hist->begin / ecore_time_get())) / 1000000000000.0
|
||||||
#define THIRTY_DAYS 2592000
|
|
||||||
#define SOME_YEARS 1230336000
|
|
||||||
|
|
||||||
typedef struct _Cleanup_Data Cleanup_Data;
|
typedef struct _Cleanup_Data Cleanup_Data;
|
||||||
|
|
||||||
|
@ -12,6 +10,7 @@ struct _Cleanup_Data
|
||||||
{
|
{
|
||||||
double time;
|
double time;
|
||||||
Eina_List *keys;
|
Eina_List *keys;
|
||||||
|
Eina_Bool normalize;
|
||||||
};
|
};
|
||||||
|
|
||||||
static E_Config_DD *hist_entry_edd = NULL;
|
static E_Config_DD *hist_entry_edd = NULL;
|
||||||
|
@ -42,12 +41,13 @@ evry_history_init(void)
|
||||||
E_CONFIG_LIST(D, T, items, hist_item_edd);
|
E_CONFIG_LIST(D, T, items, hist_item_edd);
|
||||||
#undef T
|
#undef T
|
||||||
#undef D
|
#undef D
|
||||||
hist_edd = E_CONFIG_DD_NEW("History_Item", History);
|
hist_edd = E_CONFIG_DD_NEW("History", History);
|
||||||
#define T History
|
#define T History
|
||||||
#define D hist_edd
|
#define D hist_edd
|
||||||
E_CONFIG_VAL(D, T, version, INT);
|
E_CONFIG_VAL(D, T, version, INT);
|
||||||
E_CONFIG_HASH(D, T, subjects, hist_entry_edd);
|
E_CONFIG_HASH(D, T, subjects, hist_entry_edd);
|
||||||
E_CONFIG_HASH(D, T, actions, hist_entry_edd);
|
E_CONFIG_HASH(D, T, actions, hist_entry_edd);
|
||||||
|
E_CONFIG_VAL(D, T, begin, DOUBLE);
|
||||||
#undef T
|
#undef T
|
||||||
#undef D
|
#undef D
|
||||||
}
|
}
|
||||||
|
@ -83,12 +83,6 @@ _hist_cleanup_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata
|
||||||
|
|
||||||
EINA_LIST_FOREACH_SAFE(he->items, l, ll, hi)
|
EINA_LIST_FOREACH_SAFE(he->items, l, ll, hi)
|
||||||
{
|
{
|
||||||
if (hi->last_used < d->time - SEVEN_DAYS)
|
|
||||||
{
|
|
||||||
hi->last_used = d->time;
|
|
||||||
hi->count--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* item is transient or too old */
|
/* item is transient or too old */
|
||||||
if (!hi->count || hi->transient)
|
if (!hi->count || hi->transient)
|
||||||
{
|
{
|
||||||
|
@ -123,7 +117,7 @@ evry_history_free(void)
|
||||||
if (evry_hist)
|
if (evry_hist)
|
||||||
{
|
{
|
||||||
d = E_NEW(Cleanup_Data, 1);
|
d = E_NEW(Cleanup_Data, 1);
|
||||||
d->time = ecore_time_get() - SOME_YEARS;
|
/* d->time = ecore_time_get() - SOME_YEARS; */
|
||||||
|
|
||||||
if (evry_hist->subjects)
|
if (evry_hist->subjects)
|
||||||
{
|
{
|
||||||
|
@ -168,7 +162,7 @@ evry_history_load(void)
|
||||||
{
|
{
|
||||||
evry_hist = E_NEW(History, 1);
|
evry_hist = E_NEW(History, 1);
|
||||||
evry_hist->version = HISTORY_VERSION;
|
evry_hist->version = HISTORY_VERSION;
|
||||||
|
evry_hist->begin = ecore_time_get();
|
||||||
}
|
}
|
||||||
if (!evry_hist->subjects)
|
if (!evry_hist->subjects)
|
||||||
evry_hist->subjects = eina_hash_string_superfast_new(NULL);
|
evry_hist->subjects = eina_hash_string_superfast_new(NULL);
|
||||||
|
@ -230,7 +224,7 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
||||||
if (!s->input || !strncmp (hi->input, s->input, strlen(s->input)))
|
if (!s->input || !strncmp (hi->input, s->input, strlen(s->input)))
|
||||||
{
|
{
|
||||||
/* s->input matches hi->input and is equal or shorter */
|
/* s->input matches hi->input and is equal or shorter */
|
||||||
hi->last_used = (ecore_time_get() - SOME_YEARS);
|
hi->last_used = TIME_NOW;
|
||||||
hi->count++;
|
hi->count++;
|
||||||
hi->transient = it->transient;
|
hi->transient = it->transient;
|
||||||
if (it->transient)
|
if (it->transient)
|
||||||
|
@ -262,7 +256,7 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
||||||
hi->count++;
|
hi->count++;
|
||||||
|
|
||||||
/* hi->last_used /= 2.0; */
|
/* hi->last_used /= 2.0; */
|
||||||
hi->last_used = (ecore_time_get() - SOME_YEARS);
|
hi->last_used = TIME_NOW;
|
||||||
|
|
||||||
if (s->input)
|
if (s->input)
|
||||||
hi->input = eina_stringshare_add(s->input);
|
hi->input = eina_stringshare_add(s->input);
|
||||||
|
@ -274,7 +268,7 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
||||||
{
|
{
|
||||||
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() - SOME_YEARS);
|
hi->last_used = TIME_NOW;
|
||||||
|
|
||||||
hi->count = 1;
|
hi->count = 1;
|
||||||
if (it->transient)
|
if (it->transient)
|
||||||
|
@ -322,11 +316,11 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input)
|
||||||
/* higher priority for exact matches */
|
/* higher priority for exact matches */
|
||||||
if (!strncmp(input, hi->input, strlen(input)))
|
if (!strncmp(input, hi->input, strlen(input)))
|
||||||
{
|
{
|
||||||
cnt += + hi->count;
|
cnt += hi->count*2;
|
||||||
}
|
}
|
||||||
if (!strncmp(input, hi->input, strlen(hi->input)))
|
if (!strncmp(input, hi->input, strlen(hi->input)))
|
||||||
{
|
{
|
||||||
cnt += 4 + hi->count;
|
cnt += hi->count*2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
it->usage += (cnt * hi->last_used);
|
it->usage += (cnt * hi->last_used);
|
||||||
|
|
|
@ -16,7 +16,7 @@ _cb_sort_recent(const void *data1, const void *data2)
|
||||||
const Evry_Item *it2 = data2;
|
const Evry_Item *it2 = data2;
|
||||||
|
|
||||||
if (it1->usage && it2->usage)
|
if (it1->usage && it2->usage)
|
||||||
return (it2->usage - it1->usage);
|
return (it1->usage > it2->usage ? -1 : 1);
|
||||||
if (it1->usage && !it2->usage)
|
if (it1->usage && !it2->usage)
|
||||||
return -1;
|
return -1;
|
||||||
if (it2->usage && !it1->usage)
|
if (it2->usage && !it1->usage)
|
||||||
|
@ -46,7 +46,7 @@ _cb_sort(const void *data1, const void *data2)
|
||||||
const Evry_Item *it2 = data2;
|
const Evry_Item *it2 = data2;
|
||||||
|
|
||||||
if (it1->usage && it2->usage)
|
if (it1->usage && it2->usage)
|
||||||
return (it2->usage - it1->usage);
|
return (it1->usage > it2->usage ? -1 : 1);
|
||||||
if (it1->usage && !it2->usage)
|
if (it1->usage && !it2->usage)
|
||||||
return -1;
|
return -1;
|
||||||
if (it2->usage && !it1->usage)
|
if (it2->usage && !it1->usage)
|
||||||
|
|
Loading…
Reference in New Issue