forked from enlightenment/enlightenment
'everything'
- more work on history sort - use return for browsing only in thumb mode. one needs it also to launch actions on folders.. - cleanups SVN revision: 42122
This commit is contained in:
parent
324e84908c
commit
ea01d21682
|
@ -139,6 +139,9 @@ void evry_history_unload(void);
|
|||
void evry_history_add(Eina_Hash *hist, Evry_State *s);
|
||||
int evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input);
|
||||
|
||||
int evry_browse_item(Evry_Selector *sel);
|
||||
void evry_browse_back(Evry_Selector *sel);
|
||||
|
||||
extern Config *evry_conf;
|
||||
extern History *evry_hist;
|
||||
extern Evry_Selector **selectors;
|
||||
|
|
|
@ -57,9 +57,6 @@ static int _evry_selector_subjects_get(const char *plugin_name);
|
|||
static int _evry_selector_actions_get(Evry_Item *it);
|
||||
static int _evry_selector_objects_get(Evry_Action *act);
|
||||
|
||||
static int _evry_browse_item(Evry_Selector *sel);
|
||||
static void _evry_browse_back(Evry_Selector *sel);
|
||||
|
||||
static Evry_Window *_evry_window_new(E_Zone *zone);
|
||||
static void _evry_window_free(Evry_Window *win);
|
||||
|
||||
|
@ -488,7 +485,6 @@ _evry_list_win_new(E_Zone *zone)
|
|||
if (evry_conf->height > mh)
|
||||
mh = evry_conf->height;
|
||||
|
||||
/* x = (win->popup->x + win->popup->w / 2) - (mw / 2); */
|
||||
x = win->popup->x + (offset_x ? atoi(offset_x) : 0);
|
||||
y = (win->popup->y + win->popup->h) + (offset_y ? atoi(offset_y) : 0);
|
||||
|
||||
|
@ -1040,9 +1036,10 @@ _evry_state_pop(Evry_Selector *sel)
|
|||
sel->state = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
_evry_browse_item(Evry_Selector *sel)
|
||||
int
|
||||
evry_browse_item(Evry_Selector *sel)
|
||||
{
|
||||
if (!sel) sel = selector;
|
||||
Evry_State *s = sel->state;
|
||||
Evry_Item *it;
|
||||
Eina_List *l, *plugins = NULL;
|
||||
|
@ -1050,6 +1047,9 @@ _evry_browse_item(Evry_Selector *sel)
|
|||
Evry_View *view = NULL;
|
||||
const char *type_out;
|
||||
|
||||
if (!s)
|
||||
return 0;
|
||||
|
||||
it = s->cur_item;
|
||||
|
||||
if (!it || !it->browseable)
|
||||
|
@ -1077,7 +1077,8 @@ _evry_browse_item(Evry_Selector *sel)
|
|||
}
|
||||
}
|
||||
|
||||
if (!plugins) return 1;
|
||||
if (!plugins)
|
||||
return 1;
|
||||
|
||||
evry_history_add(sel->history, s);
|
||||
|
||||
|
@ -1107,8 +1108,8 @@ _evry_browse_item(Evry_Selector *sel)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_evry_browse_back(Evry_Selector *sel)
|
||||
void
|
||||
evry_browse_back(Evry_Selector *sel)
|
||||
{
|
||||
Evry_State *s = sel->state;
|
||||
|
||||
|
@ -1227,7 +1228,7 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
|||
if (!strcmp(key, "u"))
|
||||
{
|
||||
if (!_evry_clear(s))
|
||||
_evry_browse_back(selector);
|
||||
evry_browse_back(selector);
|
||||
}
|
||||
else if (!strcmp(key, "1"))
|
||||
_evry_view_toggle(s, NULL);
|
||||
|
@ -1245,14 +1246,14 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
|||
else if (_evry_view_key_press(s, ev))
|
||||
goto end;
|
||||
else if (!strcmp(key, "Right"))
|
||||
_evry_browse_item(selector);
|
||||
evry_browse_item(selector);
|
||||
else if (!strcmp(key, "Left"))
|
||||
_evry_browse_back(selector);
|
||||
evry_browse_back(selector);
|
||||
else if (!strcmp(key, "Return"))
|
||||
{
|
||||
if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)
|
||||
_evry_plugin_action(selector, 0);
|
||||
else if (!_evry_browse_item(selector))
|
||||
else /*if (!_evry_browse_item(selector))*/
|
||||
_evry_plugin_action(selector, 1);
|
||||
}
|
||||
else if (!strcmp(key, "Escape"))
|
||||
|
@ -1262,7 +1263,7 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
|||
else if (!strcmp(key, "BackSpace"))
|
||||
{
|
||||
if (!_evry_backspace(s))
|
||||
_evry_browse_back(selector);
|
||||
evry_browse_back(selector);
|
||||
}
|
||||
else if (!strcmp(key, "Delete"))
|
||||
_evry_backspace(s);
|
||||
|
@ -1420,8 +1421,12 @@ _evry_plugin_action(Evry_Selector *sel, int finished)
|
|||
it_object = selector->state->cur_item;
|
||||
|
||||
if (act->type_in2 && !it_object)
|
||||
return;
|
||||
|
||||
{
|
||||
if (selectors[1] == selector)
|
||||
_evry_selectors_switch();
|
||||
return;
|
||||
}
|
||||
|
||||
act->item2 = it_object;
|
||||
|
||||
if (!act->action(act))
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include "e_mod_main.h"
|
||||
|
||||
#define HISTORY_VERSION 2
|
||||
#define HISTORY_VERSION 3
|
||||
#define SEVEN_DAYS 604800.0
|
||||
#define THIRTY_DAYS 2592000.0
|
||||
#define SOME_YEARS 1230336000.0
|
||||
|
||||
typedef struct _Cleanup_Data Cleanup_Data;
|
||||
|
||||
|
@ -30,7 +31,7 @@ evry_history_init(void)
|
|||
E_CONFIG_VAL(D, T, context, STR);
|
||||
E_CONFIG_VAL(D, T, input, STR);
|
||||
E_CONFIG_VAL(D, T, last_used, DOUBLE);
|
||||
E_CONFIG_VAL(D, T, count, INT);
|
||||
E_CONFIG_VAL(D, T, count, INT);
|
||||
#undef T
|
||||
#undef D
|
||||
hist_entry_edd = E_CONFIG_DD_NEW("History_Entry", History_Entry);
|
||||
|
@ -46,7 +47,7 @@ evry_history_init(void)
|
|||
E_CONFIG_HASH(D, T, subjects, hist_entry_edd);
|
||||
E_CONFIG_HASH(D, T, actions, hist_entry_edd);
|
||||
#undef T
|
||||
#undef D
|
||||
#undef D
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
|
@ -54,7 +55,7 @@ _hist_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata)
|
|||
{
|
||||
History_Entry *he = data;
|
||||
History_Item *hi;
|
||||
|
||||
|
||||
EINA_LIST_FREE(he->items, hi)
|
||||
{
|
||||
if (hi->input)
|
||||
|
@ -77,7 +78,7 @@ _hist_cleanup_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata
|
|||
Cleanup_Data *d = fdata;
|
||||
History_Item *hi;
|
||||
Eina_List *l, *ll;
|
||||
|
||||
|
||||
EINA_LIST_FOREACH_SAFE(he->items, l, ll, hi)
|
||||
{
|
||||
/* item is transient or too old */
|
||||
|
@ -101,7 +102,7 @@ _hist_cleanup_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata
|
|||
E_FREE(he);
|
||||
d->keys = eina_list_append(d->keys, key);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -110,7 +111,7 @@ evry_history_free(void)
|
|||
{
|
||||
Cleanup_Data *d;
|
||||
char *key;
|
||||
|
||||
|
||||
evry_hist = e_config_domain_load("module.everything.history", hist_edd);
|
||||
if (evry_hist)
|
||||
{
|
||||
|
@ -130,11 +131,11 @@ evry_history_free(void)
|
|||
EINA_LIST_FREE(d->keys, key)
|
||||
eina_hash_del_by_key(evry_hist->actions, key);
|
||||
}
|
||||
|
||||
|
||||
E_FREE(d);
|
||||
evry_history_unload();
|
||||
}
|
||||
|
||||
|
||||
E_CONFIG_DD_FREE(hist_item_edd);
|
||||
E_CONFIG_DD_FREE(hist_entry_edd);
|
||||
E_CONFIG_DD_FREE(hist_edd);
|
||||
|
@ -144,23 +145,23 @@ void
|
|||
evry_history_load(void)
|
||||
{
|
||||
evry_hist = e_config_domain_load("module.everything.history", hist_edd);
|
||||
|
||||
|
||||
if (evry_hist && evry_hist->version != HISTORY_VERSION)
|
||||
{
|
||||
eina_hash_foreach(evry_hist->subjects, _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);
|
||||
evry_hist = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (!evry_hist)
|
||||
{
|
||||
evry_hist = E_NEW(History, 1);
|
||||
evry_hist->version = HISTORY_VERSION;
|
||||
|
||||
|
||||
}
|
||||
if (!evry_hist->subjects)
|
||||
evry_hist->subjects = eina_hash_string_superfast_new(NULL);
|
||||
|
@ -173,12 +174,12 @@ void
|
|||
evry_history_unload(void)
|
||||
{
|
||||
if (!evry_hist) return;
|
||||
|
||||
|
||||
e_config_domain_save("module.everything.history", hist_edd, evry_hist);
|
||||
|
||||
eina_hash_foreach(evry_hist->subjects, _hist_free_cb, NULL);
|
||||
eina_hash_foreach(evry_hist->actions, _hist_free_cb, NULL);
|
||||
|
||||
|
||||
E_FREE(evry_hist);
|
||||
evry_hist = NULL;
|
||||
}
|
||||
|
@ -193,7 +194,7 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
|||
const char *id;
|
||||
|
||||
if (!s) return;
|
||||
|
||||
|
||||
it = s->cur_item;
|
||||
if (!it) return;
|
||||
|
||||
|
@ -201,7 +202,7 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
|||
id = it->id;
|
||||
else
|
||||
id = it->label;
|
||||
|
||||
|
||||
he = eina_hash_find(hist, id);
|
||||
if (!he)
|
||||
{
|
||||
|
@ -257,7 +258,7 @@ evry_history_add(Eina_Hash *hist, Evry_State *s)
|
|||
}
|
||||
|
||||
if (!hi)
|
||||
{
|
||||
{
|
||||
hi = E_NEW(History_Item, 1);
|
||||
hi->plugin = eina_stringshare_ref(it->plugin->name);
|
||||
hi->last_used = ecore_time_get();
|
||||
|
@ -279,8 +280,9 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input)
|
|||
History_Item *hi;
|
||||
const char *id;
|
||||
Eina_List *l;
|
||||
int cnt = 1;
|
||||
int cnt = 0;
|
||||
int matched;
|
||||
double usage = 0;
|
||||
|
||||
if (it->id)
|
||||
id = it->id;
|
||||
|
@ -288,7 +290,7 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input)
|
|||
id = it->label;
|
||||
|
||||
it->usage = 0;
|
||||
|
||||
|
||||
if ((he = eina_hash_find(hist, id)))
|
||||
{
|
||||
EINA_LIST_FOREACH(he->items, l, hi)
|
||||
|
@ -297,8 +299,8 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input)
|
|||
{
|
||||
if ((!input) || (!input && !hi->input))
|
||||
{
|
||||
cnt++;
|
||||
it->usage = hi->last_used;
|
||||
cnt += hi->count;
|
||||
usage = hi->last_used;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -307,27 +309,27 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input)
|
|||
if (!strncmp(input, hi->input, strlen(input)))
|
||||
{
|
||||
matched = 1;
|
||||
it->usage += hi->last_used;
|
||||
usage += hi->last_used;
|
||||
}
|
||||
if (!strncmp(input, hi->input, strlen(hi->input)))
|
||||
{
|
||||
matched = 1;
|
||||
it->usage += hi->last_used;
|
||||
usage += hi->last_used;
|
||||
}
|
||||
|
||||
if (matched) cnt++;
|
||||
|
||||
if (matched) cnt += hi->count;
|
||||
}
|
||||
|
||||
it->usage *= (double) hi->count;
|
||||
}
|
||||
}
|
||||
if (it->usage)
|
||||
if (usage)
|
||||
{
|
||||
it->usage /= (double) cnt;
|
||||
usage -= SOME_YEARS;
|
||||
|
||||
it->usage = usage * cnt;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,10 @@
|
|||
static void
|
||||
_cleanup(Evry_Plugin *p)
|
||||
{
|
||||
Evry_Item *it;
|
||||
Evry_Action *act;
|
||||
Evry_Selector *sel = selectors[1];
|
||||
|
||||
EINA_LIST_FREE(p->items, it)
|
||||
evry_item_free(it);
|
||||
EVRY_PLUGIN_ITEMS_FREE(p);
|
||||
|
||||
EINA_LIST_FREE(sel->actions, act)
|
||||
if (act->cleanup) act->cleanup(act);
|
||||
|
@ -85,8 +83,7 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
Evry_Selector *sel = selectors[1];
|
||||
int match = 0;
|
||||
|
||||
EINA_LIST_FREE(p->items, it)
|
||||
evry_item_free(it);
|
||||
EVRY_PLUGIN_ITEMS_FREE(p);
|
||||
|
||||
EINA_LIST_FOREACH(sel->actions, l, act)
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ _cb_sort_recent(const void *data1, const void *data2)
|
|||
const Evry_Item *it2 = data2;
|
||||
|
||||
if (it1->usage && it2->usage)
|
||||
return (it2->usage - it1->usage);
|
||||
return ((int)it2->usage - (int)it1->usage);
|
||||
if (it1->usage && !it2->usage)
|
||||
return -1;
|
||||
if (it2->usage && !it1->usage)
|
||||
|
|
|
@ -905,7 +905,15 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev)
|
|||
}
|
||||
goto end;
|
||||
}
|
||||
|
||||
else if (!strcmp(ev->key, "Return"))
|
||||
{
|
||||
if (!v->list_mode)
|
||||
{
|
||||
evry_browse_item(NULL);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
end:
|
||||
|
|
Loading…
Reference in New Issue