From 965f96fb1420497e2481a708b9559f381250b835 Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Sat, 22 May 2010 06:35:46 +0000 Subject: [PATCH] - exebuf: only create param items for executables that exist - calc/aspell, dont show in agregator. looks bad to have only text items in icon view - calc: show plugin item in aggregator - files: fix files plugin to provide items for 'object' - files: make browse action show inheriting folder for files, content for dirs - help: hide view on input (other than up/down) SVN revision: 49125 --- src/modules/everything-apps/e_mod_main.c | 45 ++-- src/modules/everything-aspell/e_mod_main.c | 6 +- src/modules/everything-calc/e_mod_main.c | 8 +- src/modules/everything-files/e_mod_main.c | 73 +++--- src/modules/everything/e_mod_main.c | 14 +- src/modules/everything/e_mod_main.h | 8 +- src/modules/everything/evry.c | 352 ++++++++++++++------------- src/modules/everything/evry_plug_view_help.c | 9 +- src/modules/everything/evry_util.c | 12 - 9 files changed, 276 insertions(+), 251 deletions(-) diff --git a/src/modules/everything-apps/e_mod_main.c b/src/modules/everything-apps/e_mod_main.c index 8411f61..5b1dfed 100644 --- a/src/modules/everything-apps/e_mod_main.c +++ b/src/modules/everything-apps/e_mod_main.c @@ -182,19 +182,24 @@ _item_exe_add(Plugin *p, const char *exe, int match) return app; } -static void +static int _add_executables(Plugin *p, const char *input) { Eina_List *l; char *file, *space; - int len, match, cnt = 0; + int len = 0, match, cnt = 0, found = 0; if (input) { if ((space = strchr(input, ' '))) - len = (space - input); + { + input = eina_stringshare_add_length(input, (space - input)); + } else - len = strlen(input); + { + input = eina_stringshare_add(input); + } + len = strlen(input); } EINA_LIST_FOREACH(exe_list, l, file) @@ -207,10 +212,17 @@ _add_executables(Plugin *p, const char *input) else if ((match = evry->fuzzy_match(file, input))) { _item_exe_add(p, file, match); + if (!strncmp(input, file, len)) + found = 1; + cnt++; } - if (cnt > 100) break; + if (cnt > 50) break; } + + IF_RELEASE(input); + + return found; } static Eina_Bool @@ -228,7 +240,7 @@ _hist_exe_get_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata { app = NULL; - if (strcmp(hi->plugin, EVRY_PLUGIN(p)->name)) + if (strcmp(hi->plugin, EVRY_PLUGIN(p)->name)) continue; @@ -277,15 +289,16 @@ _fetch_exe(Evry_Plugin *plugin, const char *input) if (input) { - GET_ITEM(it, p->command); - EVRY_ITEM_LABEL_SET(it, input); - IF_RELEASE(it->id); - it->id = eina_stringshare_ref(it->label); - p->command->file = eina_stringshare_ref(it->id); - it->fuzzy_match = 15; - EVRY_PLUGIN_ITEM_APPEND(p, it); - evry->item_changed(it, 0, 0); - _add_executables(p, input); + if (_add_executables(p, input)) + { + GET_ITEM(it, p->command); + EVRY_ITEM_LABEL_SET(it, input); + IF_RELEASE(p->command->file); + p->command->file = eina_stringshare_ref(it->label); + it->fuzzy_match = 1; + EVRY_PLUGIN_ITEM_APPEND(p, it); + evry->item_changed(it, 0, 0); + } } EINA_LIST_FOREACH(plugin->items, l, it) @@ -965,7 +978,7 @@ _plugins_init(const Evry_API *api) p->complete = &_complete; p->config_path = "extensions/everything-apps"; _plugins = eina_list_append(_plugins, p); - if (evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 1)) + if (evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 3)) p->config->min_query = 5; p = EVRY_PLUGIN_NEW(Plugin, N_("Applications"), NULL, EVRY_TYPE_APP, diff --git a/src/modules/everything-aspell/e_mod_main.c b/src/modules/everything-aspell/e_mod_main.c index a88b945..f8e01d0 100644 --- a/src/modules/everything-aspell/e_mod_main.c +++ b/src/modules/everything-aspell/e_mod_main.c @@ -397,10 +397,10 @@ _plugins_init(const Evry_API *_api) { Plugin_Config *pc = _plug->config; pc->view_mode = VIEW_MODE_LIST; - pc->aggregate = EINA_TRUE; - pc->top_level = EINA_FALSE; + pc->aggregate = EINA_FALSE; + /* pc->top_level = EINA_FALSE; */ pc->trigger = eina_stringshare_add(TRIGGER); - /* pc->trigger_only = EINA_TRUE; */ + pc->trigger_only = EINA_TRUE; pc->min_query = 4; } diff --git a/src/modules/everything-calc/e_mod_main.c b/src/modules/everything-calc/e_mod_main.c index e1170a0..20f3591 100644 --- a/src/modules/everything-calc/e_mod_main.c +++ b/src/modules/everything-calc/e_mod_main.c @@ -128,6 +128,7 @@ _cb_action_performed(void *data, int type, void *event) if (!strcmp(it->label, it2->label)) { p->items = eina_list_promote_list(p->items, l); + evry->item_changed(it, 0, 1); EVRY_PLUGIN_UPDATE(p, EVRY_UPDATE_ADD); return 1; } @@ -140,7 +141,7 @@ _cb_action_performed(void *data, int type, void *event) it2 = EVRY_ITEM_NEW(Evry_Item, p, it_old->label, NULL, NULL); it2->context = eina_stringshare_ref(p->name); p->items = eina_list_prepend(p->items, it2); - + evry->item_changed(it2, 0, 1); EVRY_PLUGIN_UPDATE(p, EVRY_UPDATE_ADD); return 1; @@ -248,7 +249,10 @@ _plugins_init(const Evry_API *_api) Plugin_Config *pc = _plug->config; pc->view_mode = VIEW_MODE_LIST; pc->trigger = eina_stringshare_add("="); - pc->trigger_only = EINA_TRUE; + /* pc->trigger_only = EINA_TRUE; */ + pc->aggregate = EINA_FALSE; + pc->top_level = EINA_FALSE; + pc->min_query = 3; } return EINA_TRUE; diff --git a/src/modules/everything-files/e_mod_main.c b/src/modules/everything-files/e_mod_main.c index 7c9a446..a63389d 100644 --- a/src/modules/everything-files/e_mod_main.c +++ b/src/modules/everything-files/e_mod_main.c @@ -2,7 +2,10 @@ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ -/* TODO option for maximum items to cache */ +/*************************************************** + TODO option for maximum items to cache + TODO keep common list for recent file instances +*/ #include "e.h" #include "e_mod_main.h" @@ -466,7 +469,8 @@ _scan_end_func(void *data) { GET_FILE(file, item); - if ((!(item->hi) && (hi = evry->history_item_add(item, NULL, NULL)))) + if (!(item->hi) && + (hi = evry->history_item_add(item, NULL, NULL))) { hi->last_used = SIX_DAYS_AGO; hi->usage = MIN_USAGE * (double) cnt++; @@ -594,26 +598,37 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it) if (it) { const char *dir = NULL; - /* provide object */ + if ((CHECK_TYPE(it, EVRY_TYPE_FILE)) || - (CHECK_SUBTYPE(it, EVRY_TYPE_FILE))) + (CHECK_SUBTYPE(it, EVRY_TYPE_FILE))) { + /* browse */ GET_FILE(file, it); if (!evry->file_path_get(file)) return NULL; - char *tmp = ecore_file_dir_get(file->path); - dir = eina_stringshare_add(tmp); - E_FREE(tmp); + if (!ecore_file_is_dir(file->path)) + { + char *tmp = ecore_file_dir_get(file->path); + dir = eina_stringshare_add(tmp); + E_FREE(tmp); + } + else + { + dir = eina_stringshare_add(file->path); + } + } + else + { + /* provide object */ + if (!CHECK_TYPE(it, EVRY_TYPE_ACTION)) + return NULL; } - else return NULL; if (!dir) dir = eina_stringshare_add(e_user_homedir_get()); - p = E_NEW(Plugin, 1); - p->base = *plugin; - p->base.items = NULL; + EVRY_PLUGIN_INSTANCE(p, plugin); p->directory = dir; p->parent = EINA_FALSE; _read_directory(p); @@ -621,9 +636,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it) else { /* provide subject */ - p = E_NEW(Plugin, 1); - p->base = *plugin; - p->base.items = NULL; + EVRY_PLUGIN_INSTANCE(p, plugin); p->min_query = plugin->config->min_query; if (_conf->show_homedir) @@ -1072,10 +1085,7 @@ _recentf_browse(Evry_Plugin *plugin, const Evry_Item *it) !ecore_file_is_dir(file->path)) return NULL; - p = E_NEW(Plugin, 1); - p->base = *plugin; - p->base.items = NULL; - + EVRY_PLUGIN_INSTANCE(p, plugin); p->directory = eina_stringshare_add(file->path); p->parent = EINA_TRUE; @@ -1282,30 +1292,27 @@ _plugins_init(const Evry_API *api) _mime_dir = eina_stringshare_add("inode/directory"); _mime_mount = eina_stringshare_add("inode/mountpoint"); -#define PLUGIN_NEW(_name, _icon, _begin, _finish, _fetch) \ - p = EVRY_PLUGIN_NEW(Evry_Plugin, _name, _icon, EVRY_TYPE_FILE, \ - _begin, _finish, _fetch, NULL); \ - p->config_path = "extensions/everything-files"; \ - _plugins = eina_list_append(_plugins, p); \ +#define PLUGIN_NEW(_name, _icon, _begin, _finish, _fetch, _browse) \ + p = EVRY_PLUGIN_NEW(Evry_Plugin, _name, _icon, EVRY_TYPE_FILE, \ + _begin, _finish, _fetch, NULL); \ + p->browse = &_browse; \ + p->config_path = "extensions/everything-files"; \ + _plugins = eina_list_append(_plugins, p); \ - PLUGIN_NEW(N_("Files"), _module_icon, - _begin, _finish, _fetch); - p->browse = &_browse; + PLUGIN_NEW(N_("Files"), _module_icon, _begin, _finish, _fetch, _browse); p->input_type = EVRY_TYPE_FILE; if (evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 2)) p->config->min_query = 1; - PLUGIN_NEW(N_("Files"), _module_icon, - _begin, _finish, _fetch); - p->browse = &_browse; + PLUGIN_NEW(N_("Files"), _module_icon, _begin, _finish, _fetch, _browse); evry->plugin_register(p, EVRY_PLUGIN_OBJECT, 2); if (_conf->show_recent || _conf->search_recent) { PLUGIN_NEW(N_("Recent Files"), _module_icon, - _recentf_begin, _finish, _recentf_fetch); - p->browse = &_recentf_browse; + _recentf_begin, _finish, _recentf_fetch, _recentf_browse); + if (evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 3)) { p->config->top_level = EINA_FALSE; @@ -1313,8 +1320,8 @@ _plugins_init(const Evry_API *api) } PLUGIN_NEW(N_("Recent Files"), _module_icon, - _recentf_begin, _finish, _recentf_fetch); - p->browse = &_recentf_browse; + _recentf_begin, _finish, _recentf_fetch, _recentf_browse); + if (evry->plugin_register(p, EVRY_PLUGIN_OBJECT, 3)) { p->config->top_level = EINA_FALSE; diff --git a/src/modules/everything/e_mod_main.c b/src/modules/everything/e_mod_main.c index 7668ca8..05f380d 100644 --- a/src/modules/everything/e_mod_main.c +++ b/src/modules/everything/e_mod_main.c @@ -359,7 +359,7 @@ _config_init() /* setup defaults */ IFMODCFG(0x0001); evry_conf->rel_x = 0.5; - evry_conf->rel_y = 0.32; + evry_conf->rel_y = 0.33; evry_conf->width = 435; evry_conf->height = 415; evry_conf->scroll_animate = 1; @@ -372,9 +372,6 @@ _config_init() evry_conf->cycle_mode = 0; evry_conf->history_sort_mode = 0; evry_conf->first_run = EINA_TRUE; - IFMODCFGEND; - - IFMODCFG(0x0002); evry_conf->width = 435; evry_conf->height = 415; evry_conf->rel_y = 0.40; @@ -420,7 +417,7 @@ _config_free(void) /* action callback */ -static Ecore_Idle_Enterer *idler = NULL; +static Ecore_Idle_Enterer *_idler = NULL; static const char *_params = NULL; static int @@ -430,6 +427,8 @@ _e_mod_run_defer_cb(void *data) zone = data; if (zone) evry_show(zone, _params); + + _idler = NULL; return 0; } @@ -456,9 +455,10 @@ _e_mod_action_cb(E_Object *obj, const char *params) IF_RELEASE(_params); if (params && params[0]) _params = eina_stringshare_add(params); + /* if (zone) evry_show(zone, _params); */ - if (idler) ecore_idle_enterer_del(idler); - ecore_idle_enterer_add(_e_mod_run_defer_cb, zone); + if (_idler) ecore_idle_enterer_del(_idler); + _idler = ecore_idle_enterer_add(_e_mod_run_defer_cb, zone); } /* menu item callback(s) */ diff --git a/src/modules/everything/e_mod_main.h b/src/modules/everything/e_mod_main.h index 2a426b6..1f9cf01 100644 --- a/src/modules/everything/e_mod_main.h +++ b/src/modules/everything/e_mod_main.h @@ -209,6 +209,7 @@ void evry_clear_input(Evry_Plugin *p); Evas_Object *evry_icon_mime_get(const char *mime, Evas *e); Evas_Object *evry_icon_theme_get(const char *icon, Evas *e); int evry_fuzzy_match(const char *str, const char *match); +int evry_fuzzy_match_len(const char *str, const char *match, int len); Eina_List *evry_fuzzy_match_sort(Eina_List *items); int evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file); char *evry_util_url_escape(const char *string, int inlength); @@ -296,10 +297,11 @@ void evry_history_free(void); int evry_browse_item(Evry_Item *it); int evry_browse_back(Evry_Selector *sel); -void evry_plugin_action(int finished); +void evry_plugin_action(int finished); -int evry_state_push(Evry_Selector *sel, Eina_List *plugins); -void evry_selectors_switch(int dir); +int evry_state_push(Evry_Selector *sel, Eina_List *plugins); +void evry_selectors_switch(int dir); +int evry_view_toggle(Evry_State *s, const char *trigger); extern Evry_History *evry_hist; extern Evry_Config *evry_conf; diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c index 595f571..bb5d12c 100644 --- a/src/modules/everything/evry.c +++ b/src/modules/everything/evry.c @@ -49,7 +49,6 @@ static void _evry_list_win_clear(int hide); static void _evry_view_clear(Evry_State *s); static void _evry_view_update(Evry_State *s, Evry_Plugin *plugin); static int _evry_view_key_press(Evry_State *s, Ecore_Event_Key *ev); -static int _evry_view_toggle(Evry_State *s, const char *trigger); static void _evry_view_show(Evry_View *v); static void _evry_view_hide(Evry_View *v, int slide); @@ -60,6 +59,30 @@ static int _evry_cb_key_down(void *data, int type, void *event); static int _evry_cb_selection_notify(void *data, int type, void *event); static int _evry_cb_mouse(void *data, int type, void *event); +/* local subsystem globals */ +static Evry_Window *win = NULL; +static Ecore_X_Window input_window = 0; + +#define SUBJ_SEL win->selectors[0] +#define ACTN_SEL win->selectors[1] +#define OBJ_SEL win->selectors[2] +#define CUR_SEL win->selector + +/* externally accessible functions */ +int +evry_init(void) +{ + return 1; +} + +int +evry_shutdown(void) +{ + evry_hide(0); + + return 1; +} + static int _evry_aggregator_fetch(Evry_Selector *sel, const char *input) { @@ -81,25 +104,6 @@ _evry_aggregator_fetch(Evry_Selector *sel, const char *input) return 1; } -/* local subsystem globals */ -static Evry_Window *win = NULL; -static Ecore_X_Window input_window = 0; - -/* externally accessible functions */ -int -evry_init(void) -{ - return 1; -} - -int -evry_shutdown(void) -{ - evry_hide(0); - - return 1; -} - static int _evry_cb_item_changed(void *data, int type, void *event) { @@ -126,7 +130,7 @@ static int _cb_show_timer(void *data) { Evry_Window *win = data; - Evry_Selector *sel = win->selector; + Evry_Selector *sel = CUR_SEL; win->show_timer = NULL; @@ -137,7 +141,7 @@ _cb_show_timer(void *data) if (evry_conf->first_run) { - _evry_view_toggle(s, "?"); + evry_view_toggle(s, "?"); evry_conf->first_run = EINA_FALSE; } else @@ -167,24 +171,24 @@ evry_show(E_Zone *zone, const char *params) return 1; if (!(params) && - (win->selector == win->selectors[2]) && - (win->selector->state && win->selector->state->cur_item)) + (CUR_SEL == OBJ_SEL) && + ((CUR_SEL)->state && (CUR_SEL)->state->cur_item)) { _evry_selectors_shift(1); return 1; } - if (!(params && eina_list_count(win->selectors[0]->states) == 1)) + if (!(params && eina_list_count((SUBJ_SEL)->states) == 1)) evry_hide(1); - if (win && win->selector && params) + if (win && CUR_SEL && params) { - EINA_LIST_FOREACH(win->selectors[0]->plugins, l, p) + EINA_LIST_FOREACH((SUBJ_SEL)->plugins, l, p) if (!strcmp(params, p->name)) break; - _evry_plugin_select(win->selector->state, p); - _evry_selector_update(win->selector); - _evry_view_update(win->selector->state, p); + _evry_plugin_select((CUR_SEL)->state, p); + _evry_selector_update(CUR_SEL); + _evry_view_update((CUR_SEL)->state, p); } return 1; } @@ -257,8 +261,8 @@ evry_show(E_Zone *zone, const char *params) e_popup_show(win->popup); _evry_selector_subjects_get(params); - _evry_selector_update(win->selectors[0]); - _evry_selector_activate(win->selectors[0]); + _evry_selector_update(SUBJ_SEL); + _evry_selector_activate(SUBJ_SEL); if (!evry_conf->hide_input) edje_object_signal_emit(win->o_main, "e,state,entry_show", "e"); @@ -277,33 +281,33 @@ evry_hide(int clear) if (!win) return; - if ((clear && win->selector) && - ((eina_list_count(win->selectors[0]->states) > 1) || - ((win->selectors[0]->state) && - (win->selectors[0]->state->input[0])))) + if ((clear && CUR_SEL) && + ((eina_list_count((SUBJ_SEL)->states) > 1) || + (((SUBJ_SEL)->state) && + ((SUBJ_SEL)->state->input[0])))) { int slide = 0; Evry_Selector *sel; Evry_State *s; - if (win->selector != win->selectors[0]) + if (CUR_SEL != SUBJ_SEL) { - if (win->selector == win->selectors[1]) + if (CUR_SEL == ACTN_SEL) evry_selectors_switch(-1); - else if (win->selector == win->selectors[2]) + else if (CUR_SEL == OBJ_SEL) evry_selectors_switch(1); } /* just to be sure */ - win->selector = win->selectors[0]; + CUR_SEL = SUBJ_SEL; - while (win->selector->states->next) + while ((CUR_SEL)->states->next) { slide = 1; - _evry_state_pop(win->selector); + _evry_state_pop(CUR_SEL); } - sel = win->selector; + sel = CUR_SEL; s = sel->state; _evry_clear(sel); @@ -372,14 +376,14 @@ _evry_selectors_shift(int dir) _evry_selector_new(win, EVRY_PLUGIN_ACTION); _evry_selector_new(win, EVRY_PLUGIN_OBJECT); - win->selector = win->selectors[0]; - sel = win->selector; + CUR_SEL = SUBJ_SEL; + sel = CUR_SEL; _evry_selector_signal_emit(sel, "e,state,selected"); - _evry_selector_item_update(win->selectors[0]); - _evry_selector_item_update(win->selectors[1]); - _evry_selector_item_update(win->selectors[2]); + _evry_selector_item_update(SUBJ_SEL); + _evry_selector_item_update(ACTN_SEL); + _evry_selector_item_update(OBJ_SEL); /* was checked before. anyway */ if ((s = sel->state) && (s->cur_item)) @@ -391,20 +395,20 @@ _evry_selectors_shift(int dir) } else if ((dir < 0) && (win->level > 0)) { - _evry_selector_item_clear(win->selectors[0]); - _evry_selector_free(win->selectors[1]); - _evry_selector_free(win->selectors[2]); + _evry_selector_item_clear(SUBJ_SEL); + _evry_selector_free(ACTN_SEL); + _evry_selector_free(OBJ_SEL); win->selectors = win->sel_list; win->sel_list[3] = NULL; - win->selector = NULL; + CUR_SEL = NULL; edje_object_signal_emit(win->o_main, "e,state,object_selector_show", "e"); - _evry_selector_item_update(win->selectors[0]); - _evry_selector_item_update(win->selectors[1]); - _evry_selector_item_update(win->selectors[2]); - _evry_selector_activate(win->selectors[2]); + _evry_selector_item_update(SUBJ_SEL); + _evry_selector_item_update(ACTN_SEL); + _evry_selector_item_update(OBJ_SEL); + _evry_selector_activate(OBJ_SEL); win->level = 0; @@ -422,7 +426,7 @@ evry_clear_input(Evry_Plugin *p) if (!(s = p->state)) return; - if (s->selector != win->selector) return; + if (s->selector != CUR_SEL) return; if (s->inp[0] != 0) { @@ -517,7 +521,7 @@ static int _evry_timer_cb_actions_get(void *data) { Evry_Item *it = data; - Evry_Selector *sel = win->selectors[1]; + Evry_Selector *sel = ACTN_SEL; Evry_State *s; sel->update_timer = NULL; @@ -525,7 +529,7 @@ _evry_timer_cb_actions_get(void *data) _evry_selector_actions_get(it); _evry_selector_update(sel); - if (win->selector == sel && win->selector->state) + if (CUR_SEL == sel && (CUR_SEL)->state) { s = sel->state; if (s->view) @@ -541,7 +545,7 @@ static void _evry_selector_update_actions(Evry_Selector *sel) { Evry_Item *it = sel->state->cur_item; - sel = win->selectors[1]; + sel = ACTN_SEL; if (sel->update_timer) ecore_timer_del(sel->update_timer); @@ -565,7 +569,7 @@ evry_item_select(const Evry_State *state, Evry_Item *it) if (s == sel->state) { _evry_selector_update(sel); - if (win->selector == win->selectors[0]) + if (CUR_SEL == SUBJ_SEL) _evry_selector_update_actions(sel); } } @@ -658,12 +662,12 @@ evry_plugin_update(Evry_Plugin *p, int action) } /* switch back to subject selector when no current items */ - if ((sel == win->selectors[0]) && + if ((sel == SUBJ_SEL) && (!(s->plugin) || !(s->plugin->items)) && - (win->selector == win->selectors[1])) + (CUR_SEL == ACTN_SEL)) { evry_selectors_switch(-1); - _evry_clear(win->selectors[0]); + _evry_clear(SUBJ_SEL); } } else if (action == EVRY_UPDATE_REFRESH) @@ -682,7 +686,7 @@ _evry_list_win_show(void) if (win->visible) return; win->visible = EINA_TRUE; - _evry_list_win_update(win->selector->state); + _evry_list_win_update((CUR_SEL)->state); edje_object_signal_emit(win->o_main, "e,state,list_show", "e"); edje_object_signal_emit(win->o_main, "e,state,entry_show", "e"); @@ -691,18 +695,19 @@ _evry_list_win_show(void) static void _evry_list_win_clear(int hide) { + Evry_Selector *sel = CUR_SEL; + if (!win->visible) return; - if (win->selector->state) - _evry_view_clear(win->selector->state); + if (sel->state) + _evry_view_clear(sel->state); if (hide) { win->visible = EINA_FALSE; edje_object_signal_emit(win->o_main, "e,state,list_hide", "e"); - if (evry_conf->hide_input && - (!win->selector->state || !win->selector->state->input || - strlen(win->selector->state->input) == 0)) + + if (evry_conf->hide_input && (!(sel->state) || (sel->state->input[0]))) edje_object_signal_emit(win->o_main, "e,state,entry_hide", "e"); } } @@ -798,7 +803,7 @@ _evry_cb_mouse(void *data, int type, void *event) Evry_State *s; if ((win->mouse_button == 3) && - (s = win->selector->state) && (s->cur_item) && + (s = (CUR_SEL)->state) && (s->cur_item) && (CHECK_TYPE(s->cur_item, EVRY_TYPE_FILE)) && (!E_INSIDE(ev->x, ev->y, pop->x + pop->zone->x, pop->y + pop->zone->y, pop->w, pop->h))) @@ -893,7 +898,6 @@ _evry_window_free(Evry_Window *win) e_popup_hide(win->popup); evas_event_freeze(win->popup->evas); evas_object_del(win->o_main); - /* evas_event_thaw(win->popup->evas); */ e_object_del(E_OBJECT(win->popup)); E_FREE(win); } @@ -919,7 +923,7 @@ _evry_selector_cb_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info) if (ev->z > 0) { /* FIXME dont loose selector 2 state until state 0 changed: */ - if (win->selector != win->selectors[2]) + if (CUR_SEL != OBJ_SEL) evry_selectors_switch(1); } else if (ev->z < 0) @@ -934,7 +938,7 @@ _evry_selector_cb_up(void *data, Evas *e, Evas_Object *obj, void *event_info) Evas_Event_Mouse_Up *ev = event_info; Evry_Selector *sel = data; - if (sel == win->selector) + if (sel == CUR_SEL) return; if (ev->button == 3) @@ -943,24 +947,24 @@ _evry_selector_cb_up(void *data, Evas *e, Evas_Object *obj, void *event_info) } else if (ev->button == 1) { - if (sel == win->selectors[0]) + if (sel == SUBJ_SEL) { - if (win->selector == win->selectors[1]) + if (CUR_SEL == ACTN_SEL) evry_selectors_switch(-1); else evry_selectors_switch(1); } - else if (sel == win->selectors[1]) + else if (sel == ACTN_SEL) { - if (win->selector == win->selectors[0]) + if (CUR_SEL == SUBJ_SEL) evry_selectors_switch(1); else evry_selectors_switch(-1); } - else if (sel == win->selectors[2]) + else if (sel == OBJ_SEL) { - if (win->selector == win->selectors[1]) + if (CUR_SEL == ACTN_SEL) evry_selectors_switch(1); } } @@ -1022,7 +1026,7 @@ _evry_selector_free(Evry_Selector *sel) { _evry_selector_item_clear(sel); - if (win->visible && (sel == win->selector)) + if (win->visible && (sel == CUR_SEL)) _evry_view_clear(sel->state); while (sel->states) @@ -1043,11 +1047,11 @@ static void _evry_selector_signal_emit(Evry_Selector *sel, const char *msg) { char buf[1024]; - if (sel == win->selectors[0]) + if (sel == SUBJ_SEL) snprintf(buf, sizeof(buf), "subject_selector:%s", msg); - else if (sel == win->selectors[1]) + else if (sel == ACTN_SEL) snprintf(buf, sizeof(buf), "action_selector:%s", msg); - else if (sel == win->selectors[2]) + else if (sel == OBJ_SEL) snprintf(buf, sizeof(buf), "object_selector:%s", msg); edje_object_signal_emit(win->o_main, buf, "e"); @@ -1057,11 +1061,11 @@ static void _evry_selector_label_set(Evry_Selector *sel, const char *part, const char *label) { char buf[1024]; - if (sel == win->selectors[0]) + if (sel == SUBJ_SEL) snprintf(buf, sizeof(buf), "subject_selector:%s", part); - else if (sel == win->selectors[1]) + else if (sel == ACTN_SEL) snprintf(buf, sizeof(buf), "action_selector:%s", part); - else if (sel == win->selectors[2]) + else if (sel == OBJ_SEL) snprintf(buf, sizeof(buf), "object_selector:%s", part); edje_object_part_text_set(win->o_main, buf, label); @@ -1072,14 +1076,13 @@ _evry_selector_activate(Evry_Selector *sel) { Evry_State *s; - if (win->selector) + if (CUR_SEL) { - Evry_Selector *sel = win->selector; - _evry_selector_label_set(sel, "e.text.plugin", ""); - _evry_selector_signal_emit(sel, "e,state,unselected"); + Evry_Selector *cur = CUR_SEL; + _evry_selector_signal_emit(cur, "e,state,unselected"); - if (sel->state && sel->state->view) - _evry_view_hide(sel->state->view, 0); + if (cur->state && cur->state->view) + _evry_view_hide(cur->state->view, 0); _evry_list_win_clear(evry_conf->hide_list); } @@ -1090,7 +1093,7 @@ _evry_selector_activate(Evry_Selector *sel) return; } - win->selector = sel; + CUR_SEL = sel; _evry_selector_signal_emit(sel, "e,state,selected"); @@ -1121,11 +1124,11 @@ _evry_selector_thumb_gen(void *data, Evas_Object *obj, void *event_info) e_icon_size_get(sel->o_thumb, &w, &h); edje_extern_object_aspect_set(sel->o_thumb, EDJE_ASPECT_CONTROL_BOTH, w, h); - if (sel == win->selectors[0]) + if (sel == SUBJ_SEL) edje_object_part_swallow(win->o_main, "subject_selector:e.swallow.thumb", sel->o_thumb); - else if (sel == win->selectors[1]) + else if (sel == ACTN_SEL) edje_object_part_swallow(win->o_main, "action_selector:e.swallow.thumb", sel->o_thumb); - else if (sel == win->selectors[2]) + else if (sel == OBJ_SEL) edje_object_part_swallow(win->o_main, "object_selector:e.swallow.thumb", sel->o_thumb); evas_object_show(sel->o_thumb); @@ -1211,7 +1214,7 @@ _evry_selector_item_update(Evry_Selector *sel) /* no items for this state - clear selector */ _evry_selector_label_set(sel, "e.text.label",""); - if (sel == win->selector && s && s->plugin) + if (sel == CUR_SEL && s && s->plugin) _evry_selector_label_set(sel, "e.text.plugin", EVRY_ITEM(s->plugin)->label); else @@ -1224,11 +1227,8 @@ _evry_selector_item_update(Evry_Selector *sel) { _evry_selector_label_set(sel, "e.text.label", it->label); - if (sel == win->selector) - _evry_selector_label_set(sel, "e.text.plugin", - EVRY_ITEM(s->plugin)->label); - else - _evry_selector_label_set(sel, "e.text.plugin", ""); + _evry_selector_label_set(sel, "e.text.plugin", + EVRY_ITEM(it->plugin)->label); if (!_evry_selector_thumb(sel, it)) { @@ -1246,11 +1246,11 @@ _evry_selector_item_update(Evry_Selector *sel) if (o) { - if (sel == win->selectors[0]) + if (sel == SUBJ_SEL) edje_object_part_swallow(win->o_main, "subject_selector:e.swallow.icons", o); - else if (sel == win->selectors[1]) + else if (sel == ACTN_SEL) edje_object_part_swallow(win->o_main, "action_selector:e.swallow.icons", o); - else if (sel == win->selectors[2]) + else if (sel == OBJ_SEL) edje_object_part_swallow(win->o_main, "object_selector:e.swallow.icons", o); evas_object_show(o); @@ -1299,7 +1299,7 @@ _evry_selector_update(Evry_Selector *sel) _evry_selector_item_update(sel); - if (sel == win->selectors[0]) + if (sel == SUBJ_SEL) { if (item_changed) { @@ -1307,7 +1307,7 @@ _evry_selector_update(Evry_Selector *sel) } else { - sel = win->selectors[1]; + sel = ACTN_SEL; if (sel->update_timer) ecore_timer_del(sel->update_timer); sel->update_timer = NULL; @@ -1318,7 +1318,7 @@ _evry_selector_update(Evry_Selector *sel) static void _evry_list_win_update(Evry_State *s) { - if (s != win->selector->state) return; + if (s != (CUR_SEL)->state) return; if (!win->visible) return; /* if (s->changed) */ @@ -1330,7 +1330,7 @@ _evry_selector_subjects_get(const char *plugin_name) { Eina_List *l, *plugins = NULL; Evry_Plugin *p, *pp; - Evry_Selector *sel = win->selectors[0]; + Evry_Selector *sel = SUBJ_SEL; EINA_LIST_FOREACH(sel->plugins, l, p) { @@ -1364,7 +1364,7 @@ _evry_selector_actions_get(Evry_Item *it) { Eina_List *l, *plugins = NULL; Evry_Plugin *p, *pp; - Evry_Selector *sel = win->selectors[1]; + Evry_Selector *sel = ACTN_SEL; while (sel->state) _evry_state_pop(sel); @@ -1398,13 +1398,13 @@ _evry_selector_objects_get(Evry_Action *act) { Eina_List *l, *plugins = NULL; Evry_Plugin *p, *pp; - Evry_Selector *sel = win->selectors[2]; + Evry_Selector *sel = OBJ_SEL; Evry_Item *it; while (sel->state) _evry_state_pop(sel); - it = win->selectors[1]->state->cur_item; + it = (ACTN_SEL)->state->cur_item; EINA_LIST_FOREACH(sel->plugins, l, p) { @@ -1645,7 +1645,7 @@ evry_browse_item(Evry_Item *it) int evry_browse_back(Evry_Selector *sel) { - if (!sel) sel = win->selector; + if (!sel) sel = CUR_SEL; Evry_State *s = sel->state; DBG("%p", sel); @@ -1658,7 +1658,7 @@ evry_browse_back(Evry_Selector *sel) s = sel->state; _evry_aggregator_fetch(sel, s->input); _evry_selector_update(sel); - if (sel == win->selectors[0]) + if (sel == SUBJ_SEL) _evry_selector_update_actions(sel); _evry_update_text_label(s); _evry_view_show(s->view); @@ -1670,61 +1670,62 @@ evry_browse_back(Evry_Selector *sel) void evry_selectors_switch(int dir) { - Evry_State *s = win->selector->state; + Evry_State *s = (CUR_SEL)->state; if (win->show_timer) _cb_show_timer(NULL); - if (win->selector->update_timer) + if ((CUR_SEL)->update_timer) { - if ((win->selector == win->selectors[0]) || - (win->selector == win->selectors[1])) + if ((CUR_SEL == SUBJ_SEL) || + (CUR_SEL == ACTN_SEL)) { - _evry_matches_update(win->selector, 0); - _evry_selector_update(win->selector); + _evry_matches_update(CUR_SEL, 0); + _evry_selector_update(CUR_SEL); } } - if (win->selector == win->selectors[0] && dir > 0) + if (CUR_SEL == SUBJ_SEL && dir > 0) { if (s->cur_item) - _evry_selector_activate(win->selectors[1]); + _evry_selector_activate(ACTN_SEL); } - else if (win->selector == win->selectors[1] && dir > 0) + else if (CUR_SEL == ACTN_SEL && dir > 0) { int next_selector = 0; Evry_Item *it; if (s && (it = s->cur_item) && - (it->plugin == win->selector->actions)) + (it->plugin == (CUR_SEL)->actions)) { GET_ACTION(act,it); if (act->it2.type) { _evry_selector_objects_get(act); - _evry_selector_update(win->selectors[2]); - edje_object_signal_emit(win->o_main, "e,state,object_selector_show", "e"); + _evry_selector_update(OBJ_SEL); + edje_object_signal_emit + (win->o_main, "e,state,object_selector_show", "e"); next_selector = 2; } } _evry_selector_activate(win->selectors[next_selector]); } - else if (win->selector == win->selectors[1] && dir < 0) + else if (CUR_SEL == ACTN_SEL && dir < 0) { - _evry_selector_activate(win->selectors[0]); - edje_object_signal_emit(win->o_main, "e,state,object_selector_hide", "e"); + _evry_selector_activate(SUBJ_SEL); + edje_object_signal_emit(win->o_main, "e,state,object_selector_hide", "e"); } - else if (win->selector == win->selectors[2] && dir > 0) + else if (CUR_SEL == OBJ_SEL && dir > 0) { - while (win->selector->states) - _evry_state_pop(win->selector); + while ((CUR_SEL)->states) + _evry_state_pop(CUR_SEL); edje_object_signal_emit(win->o_main, "e,state,object_selector_hide", "e"); - _evry_selector_activate(win->selectors[0]); + _evry_selector_activate(SUBJ_SEL); } - else if (win->selector == win->selectors[2] && dir < 0) + else if (CUR_SEL == OBJ_SEL && dir < 0) { - _evry_selector_activate(win->selectors[1]); + _evry_selector_activate(ACTN_SEL); } } static int @@ -1749,7 +1750,7 @@ _evry_input_complete(Evry_State *s) { strncpy(s->input, input, INPUTLEN - 1); _evry_update_text_label(s); - _evry_cb_update_timer(win->selector); + _evry_cb_update_timer(CUR_SEL); evry_item_select(s, it); } @@ -1910,7 +1911,7 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) ev->key = "Return"; } - if (!win || !(sel = win->selector)) + if (!win || !(sel = CUR_SEL)) goto end; if (!strcmp(ev->key, "Tab") && @@ -1927,6 +1928,7 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) if (!win->visible && (!strcmp(ev->key, "Down"))) { _evry_list_win_show(); + goto end; } else if ((!strcmp(ev->key, "ISO_Left_Tab") || (((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) || @@ -1955,7 +1957,7 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) goto end; } else if (!strcmp(ev->key, "1")) - _evry_view_toggle(s, NULL); + evry_view_toggle(s, NULL); else if (!strcmp(ev->key, "Return")) _evry_plugin_action(sel, 0); else if (!strcmp(ev->key, "v")) @@ -1980,7 +1982,7 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) else if (!strcmp(ev->key, "Right")) { if (!evry_browse_item(sel->state->cur_item) && - (sel != win->selectors[2])) + (sel != OBJ_SEL)) evry_selectors_switch(1); } else if (!strcmp(ev->key, "Left")) @@ -2006,7 +2008,7 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) { int len = strlen(s->inp); - if (len == 0 && (_evry_view_toggle(s, ev->compose))) + if (len == 0 && (evry_view_toggle(s, ev->compose))) goto end; if (len < (INPUTLEN - strlen(ev->compose))) @@ -2168,7 +2170,7 @@ _evry_action_do(Evry_Action *act) void evry_plugin_action(int finished) { - _evry_plugin_action(win->selector, finished); + _evry_plugin_action(CUR_SEL, finished); } static void @@ -2178,30 +2180,30 @@ _evry_plugin_action(Evry_Selector *sel, int finished) Evry_Item *it, *it_subj, *it_act, *it_obj = NULL; Eina_List *l; - if (win->selectors[0]->update_timer) + if ((SUBJ_SEL)->update_timer) { - _evry_matches_update(win->selectors[0], 0); - _evry_selector_update(win->selectors[0]); + _evry_matches_update(SUBJ_SEL, 0); + _evry_selector_update(SUBJ_SEL); } - if (!(s_subj = win->selectors[0]->state)) + if (!(s_subj = (SUBJ_SEL)->state)) return; if (!(it_subj = s_subj->cur_item)) return; - if (win->selector == win->selectors[0] && - win->selectors[1]->update_timer) + if (CUR_SEL == SUBJ_SEL && + (ACTN_SEL)->update_timer) { _evry_selector_actions_get(it_subj); - if (!win->selectors[1]->state) + if (!(ACTN_SEL)->state) return; - _evry_selector_update(win->selectors[1]); + _evry_selector_update(ACTN_SEL); } - if (!(s_act = win->selectors[1]->state)) + if (!(s_act = (ACTN_SEL)->state)) return; if (!(it_act = s_act->cur_item)) @@ -2219,14 +2221,14 @@ _evry_plugin_action(Evry_Selector *sel, int finished) if (act->it2.type) { /* check if object is provided */ - if ((s_obj = win->selectors[2]->state)) + if ((s_obj = (OBJ_SEL)->state)) { it_obj = s_obj->cur_item; } if (!it_obj) { - if (win->selectors[1] == win->selector) + if (ACTN_SEL == CUR_SEL) evry_selectors_switch(1); return; } @@ -2353,8 +2355,8 @@ _evry_view_key_press(Evry_State *s, Ecore_Event_Key *ev) return s->view->cb_key_down(s->view, ev); } -static int -_evry_view_toggle(Evry_State *s, const char *trigger) +int +evry_view_toggle(Evry_State *s, const char *trigger) { Evry_View *view, *v = NULL; Eina_List *l, *ll; @@ -2423,17 +2425,17 @@ _evry_matches_update(Evry_Selector *sel, int async) Evry_Plugin *p; Eina_List *l; Evry_Item *it; - const char *input; + const char *input = NULL; + int len_inp = 0; s->changed = 1; + s->request++; if (s->inp[0]) - input = s->inp; - else - input = NULL; - - s->request++; - DBG("matches update %d", s->request); + { + len_inp = strlen(s->inp); + input = s->inp; + } if (s->sel_items) eina_list_free(s->sel_items); @@ -2459,7 +2461,6 @@ _evry_matches_update(Evry_Selector *sel, int async) if (!s->cur_plugins && input) { int len_trigger = 0; - int len_inp = strlen(s->inp); EINA_LIST_FOREACH(s->plugins, l, p) { @@ -2503,13 +2504,20 @@ _evry_matches_update(Evry_Selector *sel, int async) { EINA_LIST_FOREACH(s->plugins, l, p) { - /* skip plugins in toplevel which trigger-only */ - if ((!(sel->states->next)) && - (sel == win->selectors[0]) && - (p->config->top_level) && - (p->config->trigger) && - (p->config->trigger_only)) - continue; + if (!sel->states->next) + { + /* skip plugins in toplevel which trigger-only */ + if ((sel == SUBJ_SEL) && + (p->config->top_level) && + (p->config->trigger) && + (p->config->trigger_only)) + continue; + + /* skip non-toplevel plugins when input < min_query */ + if ((!p->config->top_level) && + (p->config->min_query > len_inp)) + continue; + } /* dont wait for async plugin. use their current items */ if (!async && p->async_fetch && p->items) @@ -2628,7 +2636,7 @@ _evry_cb_selection_notify(void *data, int type, void *event) { Ecore_X_Event_Selection_Notify *ev; /* FIXME Evry_Selector *sel = data; */ - Evry_State *s = win->selector->state; + Evry_State *s = (CUR_SEL)->state; if (!s || (data != win)) return 1; if (!win->request_selection) return 1; @@ -2646,7 +2654,7 @@ _evry_cb_selection_notify(void *data, int type, void *event) text_data = ev->data; strncat(s->input, text_data->text, (INPUTLEN - strlen(s->input)) - 1); - _evry_update(win->selector, 1); + _evry_update(CUR_SEL, 1); } } diff --git a/src/modules/everything/evry_plug_view_help.c b/src/modules/everything/evry_plug_view_help.c index d719720..9d0f8ff 100644 --- a/src/modules/everything/evry_plug_view_help.c +++ b/src/modules/everything/evry_plug_view_help.c @@ -2,6 +2,7 @@ static Evry_View *view; static Evas_Object *o_text = NULL; +static const Evry_State *state = NULL; static void _view_clear(Evry_View *v, int slide) @@ -51,8 +52,9 @@ _cb_key_down(Evry_View *v, const Ecore_Event_Key *ev) e_box_align_set(v->o_list, 0.5, align); return 1; } - - return 0; + + evry_view_toggle(state, NULL); + return 1; } static Evry_View * @@ -102,7 +104,8 @@ _view_create(Evry_View *v, const Evry_State *s, const Evas_Object *swallow) o_text = o; v->active = 1; - + state = s; + return v; } diff --git a/src/modules/everything/evry_util.c b/src/modules/everything/evry_util.c index 733fd3f..85141e1 100644 --- a/src/modules/everything/evry_util.c +++ b/src/modules/everything/evry_util.c @@ -862,18 +862,6 @@ evry_file_url_get(Evry_Item_File *file) file->url = eina_stringshare_add(dest); return file->url; - - /* escaped = _evry_util_url_escape(file->path, 0, 1); - * - * if (escaped) - * { - * snprintf(buf, sizeof(buf), "file://%s", escaped); - * E_FREE(escaped); - * - * file->url = eina_stringshare_add(buf); - * - * return file->url; - * } */ } static void -- 2.7.4