switch aggregator and action plugins to create new instances in _begin.

action plugin is no special selector plugin anymore
added 'plugins' collection plugin. dont use! some plugins must be converted
to return new instances in begin. 
fix leak in browse_item function 
fix aspell config path
cleanups


SVN revision: 49333
This commit is contained in:
Hannes Janetzek 2010-05-30 19:16:33 +00:00
parent a93aadf1fc
commit 5dad426676
13 changed files with 447 additions and 355 deletions

View File

@ -49,8 +49,8 @@ static const Evry_API *evry = NULL;
static Evry_Module *evry_module = NULL; static Evry_Module *evry_module = NULL;
static Module_Config *_conf; static Module_Config *_conf;
static Evry_Plugin *_plug = NULL; static Evry_Plugin *_plug = NULL;
static char _config_path[] = "extensions/everthing-aspell"; static char _config_path[] = "extensions/everything-aspell";
static char _config_domain[] = "module.everyhing-aspell"; static char _config_domain[] = "module.everything-aspell";
static char _module_icon[] = "accessories-dictionary"; static char _module_icon[] = "accessories-dictionary";
static E_Config_DD *_conf_edd = NULL; static E_Config_DD *_conf_edd = NULL;

View File

@ -283,6 +283,7 @@ _append_files(Plugin *p)
int cnt = 0; int cnt = 0;
Evry_Item *it; Evry_Item *it;
Eina_List *l; Eina_List *l;
int len = p->input ? strlen(p->input) : 0;
EVRY_PLUGIN_ITEMS_CLEAR(p); EVRY_PLUGIN_ITEMS_CLEAR(p);
@ -290,7 +291,7 @@ _append_files(Plugin *p)
{ {
if (!p->input) if (!p->input)
return 0; return 0;
if (strlen(p->input) < p->min_query) if (len < p->min_query)
return 0; return 0;
} }
@ -301,7 +302,7 @@ _append_files(Plugin *p)
if (p->dirs_only && !it->browseable) if (p->dirs_only && !it->browseable)
continue; continue;
if (p->input && (match = evry->fuzzy_match(it->label, p->input))) if (len && (match = evry->fuzzy_match(it->label, p->input)))
{ {
it->fuzzy_match = match; it->fuzzy_match = match;
if (!it->browseable) if (!it->browseable)
@ -309,7 +310,7 @@ _append_files(Plugin *p)
EVRY_PLUGIN_ITEM_APPEND(p, it); EVRY_PLUGIN_ITEM_APPEND(p, it);
cnt++; cnt++;
} }
else if (!p->input) else if (len == 0)
{ {
if (!it->browseable) if (!it->browseable)
it->priority = 1; it->priority = 1;

View File

@ -14,6 +14,7 @@ struct _Plugin
Evry_Plugin base; Evry_Plugin base;
Eina_List *items; Eina_List *items;
Eina_List *categories; Eina_List *categories;
Eina_Bool parent;
}; };
struct _Settings_Item struct _Settings_Item
@ -79,6 +80,7 @@ _browse(Evry_Plugin *plugin, const Evry_Item *item)
it = (Settings_Item *) item; it = (Settings_Item *) item;
EVRY_PLUGIN_INSTANCE(p, plugin); EVRY_PLUGIN_INSTANCE(p, plugin);
p->parent = EINA_TRUE;
GET_PLUGIN(parent, item->plugin); GET_PLUGIN(parent, item->plugin);
@ -113,7 +115,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
EVRY_PLUGIN_ITEMS_CLEAR(p); EVRY_PLUGIN_ITEMS_CLEAR(p);
if (len < plugin->config->min_query) if ((!p->parent) && (len < plugin->config->min_query))
return 0; return 0;
if (!p->categories && !p->items) if (!p->categories && !p->items)
@ -149,7 +151,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
EVRY_PLUGIN_ITEMS_ADD(p, p->categories, input, 1, 1); EVRY_PLUGIN_ITEMS_ADD(p, p->categories, input, 1, 1);
if (input || !p->categories) if (input || p->parent)
return EVRY_PLUGIN_ITEMS_ADD(p, p->items, input, 1, 1); return EVRY_PLUGIN_ITEMS_ADD(p, p->items, input, 1, 1);
} }

View File

@ -64,8 +64,8 @@ e_modapi_init(E_Module *m)
_evry_type_init("TEXT"); _evry_type_init("TEXT");
_config_init(); _config_init();
evry_history_init();
evry_history_init();
evry_plug_actions_init(); evry_plug_actions_init();
evry_plug_collection_init(); evry_plug_collection_init();
evry_plug_clipboard_init(); evry_plug_clipboard_init();
@ -214,6 +214,16 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
if (cleanup_timer) if (cleanup_timer)
ecore_timer_del(cleanup_timer); ecore_timer_del(cleanup_timer);
#ifdef CHECK_REFS
Evry_Item *it;
printf("___________________________________________\n");
EINA_LIST_FREE(refd, it)
printf("%d %s\n", it->ref, it->label);
#endif
return 1; return 1;
} }
@ -454,41 +464,32 @@ _config_free(void)
Plugin_Config *pc, *pc2; Plugin_Config *pc, *pc2;
EINA_LIST_FREE(evry_conf->collections, pc) EINA_LIST_FREE(evry_conf->collections, pc)
EINA_LIST_FREE(pc->plugins, pc2)
{ {
EINA_LIST_FREE(pc->plugins, pc2) IF_RELEASE(pc2->name);
{ IF_RELEASE(pc2->trigger);
IF_RELEASE(pc2->name); E_FREE(pc2);
IF_RELEASE(pc2->trigger);
E_FREE(pc2);
}
} }
EINA_LIST_FREE(evry_conf->conf_subjects, pc) EINA_LIST_FREE(evry_conf->conf_subjects, pc)
{ {
IF_RELEASE(pc->name); IF_RELEASE(pc->name);
IF_RELEASE(pc->trigger); IF_RELEASE(pc->trigger);
if (pc->plugin)
evry_plugin_free(pc->plugin);
E_FREE(pc); E_FREE(pc);
} }
EINA_LIST_FREE(evry_conf->conf_actions, pc) EINA_LIST_FREE(evry_conf->conf_actions, pc)
{ {
IF_RELEASE(pc->name); IF_RELEASE(pc->name);
IF_RELEASE(pc->trigger); IF_RELEASE(pc->trigger);
if (pc->plugin)
evry_plugin_free(pc->plugin);
E_FREE(pc); E_FREE(pc);
} }
EINA_LIST_FREE(evry_conf->conf_objects, pc) EINA_LIST_FREE(evry_conf->conf_objects, pc)
{ {
IF_RELEASE(pc->name); IF_RELEASE(pc->name);
IF_RELEASE(pc->trigger); IF_RELEASE(pc->trigger);
if (pc->plugin)
evry_plugin_free(pc->plugin);
E_FREE(pc); E_FREE(pc);
} }
E_FREE(evry_conf); E_FREE(evry_conf);
} }
@ -536,7 +537,7 @@ _e_mod_action_cb(E_Object *obj, const char *params)
/* if (zone) evry_show(zone, _params); */ /* if (zone) evry_show(zone, _params); */
if (_idler) ecore_idle_enterer_del(_idler); if (_idler) ecore_idle_enterer_del(_idler);
_idler = ecore_idle_enterer_add(_e_mod_run_defer_cb, zone); _idler = ecore_idle_enterer_add(_e_mod_run_defer_cb, zone);
} }
static void static void

View File

@ -92,6 +92,9 @@ struct _Evry_State
/* active plugin */ /* active plugin */
Evry_Plugin *plugin; Evry_Plugin *plugin;
/* aggregator instance */
Evry_Plugin *aggregator;
/* selected item */ /* selected item */
Evry_Item *cur_item; Evry_Item *cur_item;
@ -301,7 +304,6 @@ void evry_hide(int clear);
int evry_plug_actions_init(); int evry_plug_actions_init();
void evry_plug_actions_shutdown(); void evry_plug_actions_shutdown();
Evry_Plugin *evry_plug_actions_new(Evry_Selector *selector, int type);
Evry_Plugin *evry_aggregator_new(Evry_Window *win, int type); Evry_Plugin *evry_aggregator_new(Evry_Window *win, int type);
@ -378,4 +380,10 @@ EAPI E_Config_Dialog *evry_collection_conf_dialog(E_Container *con, const char *
EAPI extern E_Module_Api e_modapi; EAPI extern E_Module_Api e_modapi;
/* #define CHECK_REFS */
#ifdef CHECK_REFS
extern Eina_List *refd;
#endif
#endif #endif

View File

@ -47,7 +47,7 @@ static void _evry_list_win_hide(void);
static void _evry_list_win_update(Evry_State *s); static void _evry_list_win_update(Evry_State *s);
static void _evry_view_clear(Evry_State *s); static void _evry_view_clear(Evry_State *s);
static void _evry_view_update(Evry_State *s, Evry_Plugin *plugin); static int _evry_view_update(Evry_State *s);
static int _evry_view_key_press(Evry_State *s, Ecore_Event_Key *ev); static int _evry_view_key_press(Evry_State *s, Ecore_Event_Key *ev);
static void _evry_view_show(Evry_View *v, int slide); static void _evry_view_show(Evry_View *v, int slide);
static void _evry_view_hide(Evry_View *v, int slide, int destroy); static void _evry_view_hide(Evry_View *v, int slide, int destroy);
@ -85,24 +85,20 @@ evry_shutdown(void)
} }
static int static int
_evry_aggregator_fetch(Evry_Selector *sel, const char *input) _evry_aggregator_fetch(Evry_State *s)
{ {
Evry_State *s = sel->state;
if (!s) if (!s)
{ {
sel->aggregator->finish(sel->aggregator); ERR("no state");
return 1; return 0;
} }
if ((sel->aggregator->fetch(sel->aggregator, input)) && if ((s->aggregator->fetch(s->aggregator, s->input)) &&
(!eina_list_data_find(s->cur_plugins, sel->aggregator))) (!eina_list_data_find(s->cur_plugins, s->aggregator)))
{ {
s->cur_plugins = eina_list_prepend(s->cur_plugins, sel->aggregator); s->cur_plugins = eina_list_prepend(s->cur_plugins, s->aggregator);
} }
sel->aggregator->state = s;
return 1; return 1;
} }
@ -139,9 +135,6 @@ _cb_show_timer(void *data)
if (sel && sel->state && evry_conf->views) if (sel && sel->state && evry_conf->views)
{ {
/* Evry_View *view =eina_list_stevry_conf->views->data; */
/* Evry_State *s = sel->state; */
if (evry_conf->first_run) if (evry_conf->first_run)
{ {
evry_view_toggle(sel->state, "?"); evry_view_toggle(sel->state, "?");
@ -187,17 +180,16 @@ evry_show(E_Zone *zone, E_Zone_Edge edge, const char *params)
return 1; return 1;
} }
if (eina_list_count((SUBJ_SEL)->states) < 2) evry_hide(1);
evry_hide(1);
if (win && CUR_SEL && params) if (win && CUR_SEL && params && (!edge))
{ {
EINA_LIST_FOREACH((SUBJ_SEL)->plugins, l, p) EINA_LIST_FOREACH((SUBJ_SEL)->plugins, l, p)
if (!strcmp(params, p->name)) break; if (!strcmp(params, p->name)) break;
_evry_plugin_select((CUR_SEL)->state, p); _evry_plugin_select((CUR_SEL)->state, p);
_evry_selector_update(CUR_SEL); _evry_selector_update(CUR_SEL);
_evry_view_update((CUR_SEL)->state, p); _evry_view_update((CUR_SEL)->state);
} }
return 1; return 1;
} }
@ -312,8 +304,9 @@ evry_hide(int clear)
if ((clear && CUR_SEL) && if ((clear && CUR_SEL) &&
((eina_list_count((SUBJ_SEL)->states) > 1) || ((eina_list_count((SUBJ_SEL)->states) > 1) ||
(((SUBJ_SEL)->state) && (CUR_SEL != SUBJ_SEL) ||
((SUBJ_SEL)->state->input[0])))) (((CUR_SEL)->state) &&
((CUR_SEL)->state->input[0]))))
{ {
int slide = 0; int slide = 0;
Evry_Selector *sel; Evry_Selector *sel;
@ -342,7 +335,7 @@ evry_hide(int clear)
_evry_clear(sel); _evry_clear(sel);
_evry_clear(sel); _evry_clear(sel);
_evry_aggregator_fetch(sel, s->input); _evry_aggregator_fetch(s);
_evry_selector_update(sel); _evry_selector_update(sel);
_evry_update_text_label(s); _evry_update_text_label(s);
_evry_view_show(s->view, slide); _evry_view_show(s->view, slide);
@ -471,10 +464,9 @@ evry_clear_input(Evry_Plugin *p)
_evry_update_text_label(s); _evry_update_text_label(s);
} }
//#define CHECK_REFS
#ifdef CHECK_REFS #ifdef CHECK_REFS
static int item_cnt = 0; static int item_cnt = 0;
Eina_List *refd = NULL;
#endif #endif
Evry_Item * Evry_Item *
@ -506,6 +498,7 @@ evry_item_new(Evry_Item *base, Evry_Plugin *p, const char *label,
#ifdef CHECK_REFS #ifdef CHECK_REFS
item_cnt++; item_cnt++;
refd = eina_list_append(refd, it);
printf("%d, %d\t new : %s\n", it->ref, item_cnt, it->label); printf("%d, %d\t new : %s\n", it->ref, item_cnt, it->label);
#endif #endif
@ -520,13 +513,14 @@ evry_item_free(Evry_Item *it)
it->ref--; it->ref--;
#ifdef CHECK_REFS #ifdef CHECK_REFS
printf("%d, %d\t unref: %s\n", it->ref, item_cnt - 1, it->label); printf("%d, %d\t unref: %s\n", it->ref, item_cnt - 1, it->label);
#endif #endif
if (it->ref > 0) return; if (it->ref > 0) return;
#ifdef CHECK_REFS #ifdef CHECK_REFS
item_cnt--; item_cnt--;
refd = eina_list_remove(refd, it);
#endif #endif
IF_RELEASE(it->label); IF_RELEASE(it->label);
@ -583,10 +577,13 @@ _evry_timer_cb_actions_get(void *data)
if ((CUR_SEL == sel) && (s = sel->state)) if ((CUR_SEL == sel) && (s = sel->state))
{ {
if (s->view) if (_evry_view_update(s))
s->view->update(s->view); _evry_view_show(s->view, 0);
else
_evry_view_update(s, NULL); /* if (s->view)
* s->view->update(s->view);
* else
* _evry_view_update(s, NULL) */
} }
return 0; return 0;
@ -661,6 +658,12 @@ evry_plugin_update(Evry_Plugin *p, int action)
if (action == EVRY_UPDATE_ADD) if (action == EVRY_UPDATE_ADD)
{ {
if (s->sel_items)
{
eina_list_free(s->sel_items);
s->sel_items = NULL;
}
if (!p->items && !s->trigger_active) if (!p->items && !s->trigger_active)
{ {
/* remove plugin */ /* remove plugin */
@ -668,6 +671,8 @@ evry_plugin_update(Evry_Plugin *p, int action)
s->cur_plugins = eina_list_remove(s->cur_plugins, p); s->cur_plugins = eina_list_remove(s->cur_plugins, p);
_evry_aggregator_fetch(s);
if (s->plugin == p) if (s->plugin == p)
_evry_plugin_select(s, NULL); _evry_plugin_select(s, NULL);
} }
@ -676,23 +681,22 @@ evry_plugin_update(Evry_Plugin *p, int action)
/* add plugin to current plugins*/ /* add plugin to current plugins*/
_evry_plugin_list_insert(s, p); _evry_plugin_list_insert(s, p);
if (!s->plugin || !eina_list_data_find_list(s->cur_plugins, s->plugin)) _evry_aggregator_fetch(s);
if ((!s->plugin) || (s->plugin_auto_selected) ||
(!eina_list_data_find_list(s->cur_plugins, s->plugin)))
_evry_plugin_select(s, NULL); _evry_plugin_select(s, NULL);
} }
if (s->sel_items)
eina_list_free(s->sel_items);
s->sel_items = NULL;
_evry_aggregator_fetch(sel, s->input);
/* plugin is visible */ /* plugin is visible */
if ((sel->state == s) && if ((sel->state == s) &&
((s->plugin == p) || ((s->plugin == p) ||
(s->plugin == sel->aggregator))) (s->plugin == s->aggregator)))
{ {
_evry_selector_update(sel); _evry_selector_update(sel);
_evry_view_update(s, NULL); if (_evry_view_update(s))
_evry_view_show(s->view, 0);
} }
/* switch back to subject selector when no current items */ /* switch back to subject selector when no current items */
@ -707,7 +711,7 @@ evry_plugin_update(Evry_Plugin *p, int action)
else if (action == EVRY_UPDATE_REFRESH) else if (action == EVRY_UPDATE_REFRESH)
{ {
_evry_view_clear(s); _evry_view_clear(s);
_evry_view_update(s, NULL); _evry_view_update(s);
} }
} }
@ -1101,13 +1105,11 @@ _evry_selector_new(Evry_Window *win, int type)
if (type == EVRY_PLUGIN_SUBJECT) if (type == EVRY_PLUGIN_SUBJECT)
{ {
sel->actions = evry_plug_actions_new(sel, type);
pcs = evry_conf->conf_subjects; pcs = evry_conf->conf_subjects;
o = edje_object_part_swallow_get(win->o_main, "subject_selector"); o = edje_object_part_swallow_get(win->o_main, "subject_selector");
} }
else if (type == EVRY_PLUGIN_ACTION) else if (type == EVRY_PLUGIN_ACTION)
{ {
sel->actions = evry_plug_actions_new(sel, type);
pcs = evry_conf->conf_actions; pcs = evry_conf->conf_actions;
o = edje_object_part_swallow_get(win->o_main, "action_selector"); o = edje_object_part_swallow_get(win->o_main, "action_selector");
} }
@ -1153,7 +1155,6 @@ _evry_selector_free(Evry_Selector *sel)
_evry_state_pop(sel, 1); _evry_state_pop(sel, 1);
EVRY_PLUGIN_FREE(sel->aggregator); EVRY_PLUGIN_FREE(sel->aggregator);
EVRY_PLUGIN_FREE(sel->actions);
if (sel->plugins) eina_list_free(sel->plugins); if (sel->plugins) eina_list_free(sel->plugins);
@ -1304,8 +1305,6 @@ _evry_selector_thumb(Evry_Selector *sel, const Evry_Item *it)
sel->o_thumb = e_thumb_icon_add(win->popup->evas); sel->o_thumb = e_thumb_icon_add(win->popup->evas);
evas_object_smart_callback_add(sel->o_thumb, "e_thumb_gen", evas_object_smart_callback_add(sel->o_thumb, "e_thumb_gen",
_evry_selector_thumb_gen, sel); _evry_selector_thumb_gen, sel);
/* edje_object_part_geometry_get(sel->o_main, "e.swallow.thumb",
* NULL, NULL, &w, &h); */
if (suffix) if (suffix)
e_thumb_icon_file_set(sel->o_thumb, file->path, "e/desktop/background"); e_thumb_icon_file_set(sel->o_thumb, file->path, "e/desktop/background");
else else
@ -1457,8 +1456,8 @@ _evry_list_win_update(Evry_State *s)
if (s != (CUR_SEL)->state) return; if (s != (CUR_SEL)->state) return;
if (!win->visible) return; if (!win->visible) return;
/* if (s->changed) */ if (_evry_view_update(s))
_evry_view_update(s, s->plugin); _evry_view_show(s->view, 0);
} }
static int static int
@ -1473,9 +1472,6 @@ _evry_selector_subjects_get(const char *plugin_name)
if (plugin_name && strcmp(plugin_name, p->name)) if (plugin_name && strcmp(plugin_name, p->name))
continue; continue;
/* if (!p->config->top_level)
* continue; */
if (p->begin && (pp = p->begin(p, NULL))) if (p->begin && (pp = p->begin(p, NULL)))
plugins = eina_list_append(plugins, pp); plugins = eina_list_append(plugins, pp);
@ -1486,12 +1482,6 @@ _evry_selector_subjects_get(const char *plugin_name)
if (!plugins) return 0; if (!plugins) return 0;
_evry_state_new(sel, plugins); _evry_state_new(sel, plugins);
EINA_LIST_FOREACH(plugins, l, p)
p->state = sel->state;
DBG("%s", plugin_name);
_evry_matches_update(sel, 1); _evry_matches_update(sel, 1);
return 1; return 1;
@ -1511,9 +1501,6 @@ _evry_selector_actions_get(Evry_Item *it)
EINA_LIST_FOREACH(sel->plugins, l, p) EINA_LIST_FOREACH(sel->plugins, l, p)
{ {
/* if (!p->config->top_level)
* continue; */
if (p->begin && (pp = p->begin(p, it))) if (p->begin && (pp = p->begin(p, it)))
plugins = eina_list_append(plugins, pp); plugins = eina_list_append(plugins, pp);
} }
@ -1521,10 +1508,6 @@ _evry_selector_actions_get(Evry_Item *it)
if (!plugins) return 0; if (!plugins) return 0;
_evry_state_new(sel, plugins); _evry_state_new(sel, plugins);
EINA_LIST_FOREACH(plugins, l, p)
p->state = sel->state;
_evry_matches_update(sel, 1); _evry_matches_update(sel, 1);
return 1; return 1;
@ -1546,11 +1529,6 @@ _evry_selector_objects_get(Evry_Action *act)
EINA_LIST_FOREACH(sel->plugins, l, p) EINA_LIST_FOREACH(sel->plugins, l, p)
{ {
DBG("p %s %d %d\n", p->name, EVRY_ITEM(p)->subtype, act->it2.type);
/* if (!p->config->top_level)
* continue; */
if (!CHECK_SUBTYPE(p, act->it2.type)) if (!CHECK_SUBTYPE(p, act->it2.type))
continue; continue;
@ -1564,9 +1542,6 @@ _evry_selector_objects_get(Evry_Action *act)
if (!plugins) return 0; if (!plugins) return 0;
_evry_state_new(sel, plugins); _evry_state_new(sel, plugins);
EINA_LIST_FOREACH(plugins, l, p)
p->state = sel->state;
_evry_matches_update(sel, 1); _evry_matches_update(sel, 1);
return 1; return 1;
@ -1576,6 +1551,11 @@ static Evry_State *
_evry_state_new(Evry_Selector *sel, Eina_List *plugins) _evry_state_new(Evry_Selector *sel, Eina_List *plugins)
{ {
Evry_State *s = E_NEW(Evry_State, 1); Evry_State *s = E_NEW(Evry_State, 1);
Eina_List *l;
Evry_Plugin *p;
if (!s) return NULL;
s->inp = malloc(INPUTLEN); s->inp = malloc(INPUTLEN);
s->inp[0] = 0; s->inp[0] = 0;
s->input = s->inp; s->input = s->inp;
@ -1585,6 +1565,13 @@ _evry_state_new(Evry_Selector *sel, Eina_List *plugins)
sel->states = eina_list_prepend(sel->states, s); sel->states = eina_list_prepend(sel->states, s);
sel->state = s; sel->state = s;
p = sel->aggregator->begin(sel->aggregator, NULL);
s->plugins = eina_list_append(s->plugins, p);
s->aggregator = p;
EINA_LIST_FOREACH(s->plugins, l, p)
p->state = s;
return s; return s;
} }
@ -1593,48 +1580,39 @@ _evry_state_pop(Evry_Selector *sel, int immediate)
{ {
Evry_Plugin *p; Evry_Plugin *p;
Evry_State *s; Evry_State *s;
Evry_State *prev = NULL; Evry_State *prev;
s = sel->state; s = sel->state;
_evry_item_desel(s, NULL); _evry_item_desel(s, NULL);
free(s->inp);
if (s->view) if (s->view)
{ {
if (immediate) if (immediate)
s->view->destroy(s->view); s->view->destroy(s->view);
else else
_evry_view_hide(s->view, SLIDE_RIGHT, 1); _evry_view_hide(s->view, SLIDE_RIGHT, 1);
/* XXX delay free state? is it possible that
view can receive events here? */
} }
if (s->sel_items) if (s->sel_items)
eina_list_free(s->sel_items); eina_list_free(s->sel_items);
sel->states = eina_list_remove_list(sel->states, sel->states); sel->states = eina_list_remove_list(sel->states, sel->states);
prev = eina_list_data_get(sel->states);
if (sel->states)
prev = sel->states->data;
EINA_LIST_FREE(s->plugins, p) EINA_LIST_FREE(s->plugins, p)
{ {
/* FIXME use it->free cb also for plugin instances*/
/* skip non top-level plugins */ /* skip non top-level plugins */
if (prev && eina_list_data_find(prev->plugins, p)) if (prev && eina_list_data_find(prev->plugins, p))
{ {
p->state = prev; p->state = prev;
continue; continue;
} }
/* if (EVRY_ITEM(p)->ref == 0) */
p->finish(p); p->finish(p);
/* else
* p->state = NULL; */
} }
E_FREE(s->inp);
E_FREE(s); E_FREE(s);
sel->state = prev; sel->state = prev;
@ -1710,29 +1688,32 @@ evry_browse_item(Evry_Item *it)
sel = s->selector; sel = s->selector;
if ((it->plugin->browse) &&
(pp = it->plugin->browse(it->plugin, it)))
{
plugins = eina_list_append(plugins, pp);
pref = pp;
}
EINA_LIST_FOREACH(sel->plugins, l, p)
{
if ((p->browse) && (pp = p->browse(p, it)))
{
if (pref && !strcmp(pp->name, pref->name))
continue;
plugins = eina_list_append(plugins, pp);
}
}
/* aggregator */ /* aggregator */
if (!(plugins) && CHECK_TYPE(it, EVRY_TYPE_PLUGIN)) if (CHECK_TYPE(it, EVRY_TYPE_PLUGIN))
{ {
browse_aggregator = 1; browse_aggregator = 1;
plugins = eina_list_append(plugins, it); plugins = eina_list_append(plugins, it);
} }
else
{
if ((it->plugin->browse) &&
(pp = it->plugin->browse(it->plugin, it)))
{
plugins = eina_list_append(plugins, pp);
pref = pp;
}
EINA_LIST_FOREACH(sel->plugins, l, p)
{
if (pref && !strcmp(p->name, pref->name))
continue;
if ((p->browse) && (pp = p->browse(p, it)))
{
plugins = eina_list_append(plugins, pp);
}
}
}
if (!(plugins)) if (!(plugins))
{ {
@ -1746,9 +1727,6 @@ evry_browse_item(Evry_Item *it)
return 0; return 0;
} }
EINA_LIST_FOREACH(plugins, l, p)
p->state = new_state;
if (s->view) if (s->view)
{ {
_evry_view_hide(s->view, SLIDE_LEFT, 0); _evry_view_hide(s->view, SLIDE_LEFT, 0);
@ -1757,13 +1735,24 @@ evry_browse_item(Evry_Item *it)
if (browse_aggregator) if (browse_aggregator)
{ {
strncpy(new_state->input, s->input, INPUTLEN); it->hi = NULL;
evry_history_item_add(it, NULL, NULL); if (!EVRY_PLUGIN(it)->items)
{
evry_history_item_add(it, NULL, s->input);
s = new_state;
EVRY_PLUGIN(it)->state = s;
_evry_matches_update(sel, 1);
}
else
{
evry_history_item_add(it, NULL, NULL);
strncpy(new_state->input, s->input, INPUTLEN);
s = new_state;
EVRY_PLUGIN(it)->state = s;
s->cur_plugins = eina_list_append(s->cur_plugins, it);
}
s = new_state;
EVRY_PLUGIN(it)->state = s;
s->cur_plugins = eina_list_append(s->cur_plugins, it);
_evry_plugin_select(s, EVRY_PLUGIN(it)); _evry_plugin_select(s, EVRY_PLUGIN(it));
} }
else else
@ -1773,6 +1762,7 @@ evry_browse_item(Evry_Item *it)
_evry_matches_update(sel, 1); _evry_matches_update(sel, 1);
s = new_state; s = new_state;
_evry_plugin_select(s, pref);
} }
_evry_selector_update(sel); _evry_selector_update(sel);
@ -1806,7 +1796,7 @@ evry_browse_back(Evry_Selector *sel)
_evry_state_pop(sel, 0); _evry_state_pop(sel, 0);
s = sel->state; s = sel->state;
_evry_aggregator_fetch(sel, s->input); /* _evry_aggregator_fetch(s); */
_evry_selector_update(sel); _evry_selector_update(sel);
if (sel == SUBJ_SEL) if (sel == SUBJ_SEL)
_evry_selector_update_actions(ACTN_SEL); _evry_selector_update_actions(ACTN_SEL);
@ -1970,8 +1960,8 @@ _evry_cheat_history(Evry_State *s, int promote, int delete)
if (hi->count < 0) hi->count = 1; if (hi->count < 0) hi->count = 1;
} }
} }
if (s->plugin == s->selector->aggregator) if (s->plugin == s->aggregator)
_evry_aggregator_fetch(s->selector, s->input); _evry_aggregator_fetch(s);
if (s->view) if (s->view)
s->view->update(s->view); s->view->update(s->view);
@ -2567,10 +2557,14 @@ _evry_view_slide_clear(Evry_View *v)
evas_object_hide(v->o_list); evas_object_hide(v->o_list);
} }
win->view_clearing = NULL; win->view_clearing = NULL;
}
/* replay mouse down to allow direct sliding back */ /* replay mouse down to allow direct sliding back */
if (win->mouse_button) if (win->mouse_button)
evas_event_feed_mouse_down(win->popup->evas, win->mouse_button, 0, 0, NULL); {
evas_event_feed_mouse_down(win->popup->evas,
win->mouse_button,
0, 0, NULL);
} }
} }
@ -2586,18 +2580,18 @@ _evry_view_hide(Evry_View *v, int slide, int destroy)
{ {
/* replay mouse up to allow direct sliding back */ /* replay mouse up to allow direct sliding back */
if (win->mouse_button) if (win->mouse_button)
evas_event_feed_mouse_up(win->popup->evas, win->mouse_button, 0, 0, NULL); {
evas_event_feed_mouse_up(win->popup->evas,
win->mouse_button,
0, 0, NULL);
}
evas_object_hide(v->o_list);
edje_object_part_unswallow(win->o_main, v->o_list);
if (slide == SLIDE_RIGHT) if (slide == SLIDE_RIGHT)
{ {
evas_object_hide(v->o_list);
edje_object_part_unswallow(win->o_main, v->o_list);
edje_object_part_swallow(win->o_main, "list:e.swallow.list2", v->o_list); edje_object_part_swallow(win->o_main, "list:e.swallow.list2", v->o_list);
evas_object_show(v->o_list);
edje_object_signal_emit(v->o_list, "e,action,hide,list", "e");
edje_object_signal_emit(v->o_list, "e.swallow.list:e,action,hide,list", "e");
v->clear_timer = ecore_timer_add(0.3, _clear_timer, v);
if (destroy) if (destroy)
win->view_freeing = v; win->view_freeing = v;
else else
@ -2605,17 +2599,14 @@ _evry_view_hide(Evry_View *v, int slide, int destroy)
} }
else /* if (slide == SLIDE_LEFT) */ else /* if (slide == SLIDE_LEFT) */
{ {
evas_object_hide(v->o_list);
edje_object_part_unswallow(win->o_main, v->o_list);
edje_object_part_swallow(win->o_main, "list:e.swallow.list", v->o_list); edje_object_part_swallow(win->o_main, "list:e.swallow.list", v->o_list);
evas_object_show(v->o_list);
edje_object_signal_emit(v->o_list, "e,action,hide,list", "e");
edje_object_signal_emit(v->o_list, "e.swallow.list:e,action,hide,list", "e");
v->clear_timer = ecore_timer_add(0.3, _clear_timer, v);
win->view_clearing = v; win->view_clearing = v;
} }
evas_object_show(v->o_list);
edje_object_signal_emit(v->o_list, "e,action,hide,list", "e");
v->clear_timer = ecore_timer_add(0.3, _clear_timer, v);
if (v->o_bar) if (v->o_bar)
{ {
edje_object_part_unswallow(win->o_main, v->o_bar); edje_object_part_unswallow(win->o_main, v->o_bar);
@ -2643,20 +2634,25 @@ _evry_view_hide(Evry_View *v, int slide, int destroy)
v->destroy(v); v->destroy(v);
} }
static void static int
_evry_view_update(Evry_State *s, Evry_Plugin *p) _evry_view_update(Evry_State *s)
{ {
if (!win->visible) return; if (!win->visible) return 0;
if (!s->view) if (!s->view)
{ {
Evry_View *view = evry_conf->views->data; Evry_View *view = evry_conf->views->data;
s->view = view->create(view, s, win->o_main); if (!(s->view = view->create(view, s, win->o_main)))
/* _evry_view_show(s->view, 0); */ return 0;
s->view->update(s->view);
return 1;
} }
if (s->view) if (s->view)
s->view->update(s->view); s->view->update(s->view);
return 0;
} }
static void static void
@ -2726,10 +2722,7 @@ evry_view_toggle(Evry_State *s, const char *trigger)
_evry_list_win_show(); _evry_list_win_show();
if (s->view) if (s->view)
{ _evry_view_hide(s->view, 0, 1);
_evry_view_hide(s->view, 0, 1);
/* s->view->destroy(s->view); */
}
s->view = v; s->view = v;
_evry_view_show(s->view, 0); _evry_view_show(s->view, 0);
@ -2832,20 +2825,7 @@ _evry_matches_update(Evry_Selector *sel, int async)
/* query all other plugins for this state */ /* query all other plugins for this state */
EINA_LIST_FOREACH(s->plugins, l, p) EINA_LIST_FOREACH(s->plugins, l, p)
{ {
if (!sel->states->next) p->request = s->request;
{
/* 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 */ /* dont wait for async plugin. use their current items */
if (!async && p->async_fetch && p->items) if (!async && p->async_fetch && p->items)
@ -2854,16 +2834,37 @@ _evry_matches_update(Evry_Selector *sel, int async)
continue; continue;
} }
p->request = s->request; if ((sel->states->next) ||
((CUR_SEL == SUBJ_SEL) && (win->plugin_dedicated)))
if ((p->fetch(p, input)) || (sel->states->next))
{ {
p->fetch(p, input);
s->cur_plugins = eina_list_append(s->cur_plugins, p); s->cur_plugins = eina_list_append(s->cur_plugins, p);
continue;
}
/* 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;
if (p->fetch(p, input))
{
if (p == s->aggregator)
s->cur_plugins = eina_list_prepend(s->cur_plugins, p);
else
s->cur_plugins = eina_list_append(s->cur_plugins, p);
} }
} }
found: found:
_evry_aggregator_fetch(sel, input); /* _evry_aggregator_fetch(s); */
if (s->plugin_auto_selected || if (s->plugin_auto_selected ||
(s->plugin && (!eina_list_data_find(s->cur_plugins, s->plugin)))) (s->plugin && (!eina_list_data_find(s->cur_plugins, s->plugin))))

View File

@ -413,11 +413,14 @@ _create_plugin_page(E_Config_Dialog_Data *cfdata, Evas *e, Plugin_Page *page)
e_widget_table_object_append(ob, of, 1, 0, 1, 1, 1, 1, 1, 0); e_widget_table_object_append(ob, of, 1, 0, 1, 1, 1, 1, 1, 0);
of = e_widget_framelist_add(e, _("Plugin Trigger"), 0); of = e_widget_framelist_add(e, _("Plugin Trigger"), 0);
o = e_widget_label_add(e, _("Default is plugin name"));
e_widget_framelist_object_append(of, o);
o = e_widget_entry_add(e, &(page->trigger), NULL, NULL, NULL); o = e_widget_entry_add(e, &(page->trigger), NULL, NULL, NULL);
e_widget_disabled_set(o, 1); e_widget_disabled_set(o, 1);
page->o_trigger = o; page->o_trigger = o;
e_widget_framelist_object_append(of, o); e_widget_framelist_object_append(of, o);
o = e_widget_check_add(e, _("Show only when triggered"), o = e_widget_check_add(e, _("Search only when triggered"),
&(page->trigger_only)); &(page->trigger_only));
e_widget_disabled_set(o, 1); e_widget_disabled_set(o, 1);
page->o_trigger_only = o; page->o_trigger_only = o;

View File

@ -270,6 +270,9 @@ evry_history_item_add(Evry_Item *it, const char *ctxt, const char *input)
if (!it) if (!it)
return NULL; return NULL;
if ((!it->plugin->history) && (!CHECK_TYPE(it, EVRY_TYPE_PLUGIN)))
return NULL;
if (it->type == EVRY_TYPE_ACTION) if (it->type == EVRY_TYPE_ACTION)
{ {
GET_ACTION(act, it); GET_ACTION(act, it);
@ -360,7 +363,7 @@ evry_history_item_usage_set(Evry_Item *it, const char *input, const char *ctxt)
int rem_ctxt = 1; int rem_ctxt = 1;
it->usage = 0.0; it->usage = 0.0;
if (!it->plugin->history) if ((!it->plugin->history) && (!CHECK_TYPE(it, EVRY_TYPE_PLUGIN)))
return 0; return 0;
if (it->hi) if (it->hi)

View File

@ -8,13 +8,12 @@ typedef struct _Plugin Plugin;
struct _Plugin struct _Plugin
{ {
Evry_Plugin base; Evry_Plugin base;
Evry_Selector *selector;
Eina_List *actions; Eina_List *actions;
Eina_Bool parent; Eina_Bool parent;
Evry_Action *action; Evry_Action *action;
}; };
static Evry_Plugin *_base_plug = NULL; static Evry_Plugin *_plug = NULL;
static void static void
_finish(Evry_Plugin *plugin) _finish(Evry_Plugin *plugin)
@ -22,15 +21,8 @@ _finish(Evry_Plugin *plugin)
GET_PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
Evry_Action *act; Evry_Action *act;
if (p->parent) EINA_LIST_FREE(p->actions, act);
{ E_FREE(p);
EINA_LIST_FREE(p->actions, act);
E_FREE(p);
}
else
{
EINA_LIST_FREE(p->actions, act);
}
} }
static Evry_Plugin * static Evry_Plugin *
@ -44,9 +36,7 @@ _browse(Evry_Plugin *plugin, const Evry_Item *it)
act = EVRY_ACTN(it); act = EVRY_ACTN(it);
p = E_NEW(Plugin, 1); EVRY_PLUGIN_INSTANCE(p, plugin);
p->base = *plugin;
p->base.items = NULL;
p->actions = act->fetch(act); p->actions = act->fetch(act);
p->parent = EINA_TRUE; p->parent = EINA_TRUE;
p->action = act; p->action = act;
@ -59,10 +49,9 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
{ {
Evry_Action *act; Evry_Action *act;
Eina_List *l; Eina_List *l;
Plugin *p;
GET_PLUGIN(p, plugin); EVRY_PLUGIN_INSTANCE(p, plugin);
EINA_LIST_FREE(p->actions, act);
if (!(CHECK_TYPE(it, EVRY_TYPE_PLUGIN))) if (!(CHECK_TYPE(it, EVRY_TYPE_PLUGIN)))
{ {
@ -76,7 +65,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
if (act->check_item && !(act->check_item(act, it))) if (act->check_item && !(act->check_item(act, it)))
continue; continue;
act->base.plugin = plugin; act->base.plugin = EVRY_PLUGIN(p);
act->it1.item = it; act->it1.item = it;
EVRY_ITEM(act)->hi = NULL; EVRY_ITEM(act)->hi = NULL;
@ -88,7 +77,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
{ {
EINA_LIST_FOREACH(it->plugin->actions, l, act) EINA_LIST_FOREACH(it->plugin->actions, l, act)
{ {
act->base.plugin = plugin; act->base.plugin = EVRY_PLUGIN(p);
act->it1.item = EVRY_ITEM(it->plugin); act->it1.item = EVRY_ITEM(it->plugin);
EVRY_ITEM(act)->hi = NULL; EVRY_ITEM(act)->hi = NULL;
@ -96,9 +85,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
} }
} }
if (!p->actions) return NULL; return EVRY_PLUGIN(p);
return plugin;
} }
static int static int
@ -177,39 +164,18 @@ _fetch(Evry_Plugin *plugin, const char *input)
return 1; return 1;
} }
Evry_Plugin *
evry_plug_actions_new(Evry_Selector *sel, int type)
{
Evry_Plugin *plugin;
if (type == EVRY_PLUGIN_SUBJECT)
{
plugin = EVRY_PLUGIN_NEW(Plugin, N_("Actions"), NULL, 0,
NULL, _finish, _fetch, NULL);
}
else if (type == EVRY_PLUGIN_ACTION)
{
plugin = EVRY_PLUGIN_NEW(Plugin, N_("Actions"), NULL, 0,
_begin, _finish, _fetch, NULL);
}
else return NULL;
plugin->browse = &_browse;
GET_PLUGIN(p, plugin);
p->selector = sel;
evry_plugin_register(plugin, type, 2);
return plugin;
}
/***************************************************************************/ /***************************************************************************/
int int
evry_plug_actions_init() evry_plug_actions_init()
{ {
_base_plug = evry_plugin_new(NULL, _("Actions"), NULL, NULL, _plug = EVRY_PLUGIN_NEW(Plugin, N_("Actions"), NULL,
EVRY_TYPE_ACTION, NULL, NULL, NULL, NULL); EVRY_TYPE_ACTION,
_begin, _finish, _fetch, NULL);
_plug->browse = &_browse;
evry_plugin_register(_plug, EVRY_PLUGIN_ACTION, 2);
return 1; return 1;
} }
@ -219,7 +185,7 @@ evry_plug_actions_shutdown()
{ {
Evry_Item *it; Evry_Item *it;
evry_plugin_free(_base_plug); evry_plugin_free(_plug);
/* bypass unregister, because it modifies the list */ /* bypass unregister, because it modifies the list */
EINA_LIST_FREE(evry_conf->actions, it) EINA_LIST_FREE(evry_conf->actions, it)
@ -248,7 +214,7 @@ _action_free_cb(Evry_Item *it)
{ {
GET_ACTION(act, it); GET_ACTION(act, it);
if (act->name) eina_stringshare_del(act->name); IF_RELEASE(act->name);
E_FREE(act); E_FREE(act);
} }
@ -260,8 +226,8 @@ evry_action_new(const char *name, const char *label,
int (*action) (Evry_Action *act), int (*action) (Evry_Action *act),
int (*check_item) (Evry_Action *act, const Evry_Item *it)) int (*check_item) (Evry_Action *act, const Evry_Item *it))
{ {
Evry_Action *act = EVRY_ITEM_NEW(Evry_Action, _base_plug, label, NULL, _action_free_cb); Evry_Action *act = EVRY_ITEM_NEW(Evry_Action, _plug, label,
NULL, _action_free_cb);
if (icon) if (icon)
act->base.icon = eina_stringshare_add(icon); act->base.icon = eina_stringshare_add(icon);

View File

@ -1,5 +1,7 @@
#include "e_mod_main.h" #include "e_mod_main.h"
//TODO min input for items not in history
#define MAX_ITEMS 50 #define MAX_ITEMS 50
typedef struct _Plugin Plugin; typedef struct _Plugin Plugin;
@ -17,34 +19,31 @@ static int
_fetch(Evry_Plugin *plugin, const char *input) _fetch(Evry_Plugin *plugin, const char *input)
{ {
Plugin *p = (Plugin *) plugin; Plugin *p = (Plugin *) plugin;
Evry_Plugin *pp; Evry_Plugin *pp, *pp2;
Evry_State *s; Evry_State *s;
Eina_List *l, *ll, *lp = NULL; Eina_List *l, *ll, *lp = NULL;
Evry_Item *it, *it2; Evry_Item *it, *it2;
int i, cnt = 0; int i, top_level = 0, subj_sel = 0, inp_len = 0, cnt = 0;
Eina_List *items = NULL; Eina_List *items = NULL;
const char *context = NULL; const char *context = NULL;
char buf[128]; char buf[128];
Evry_Selector *sel = p->win->selectors[p->type]; Evry_Selector *sel = p->win->selectors[p->type];
if (input && !input[0]) input = NULL; if (input && input[0])
inp_len = strlen(input);
else
input = NULL;
EVRY_PLUGIN_ITEMS_FREE(p); EVRY_PLUGIN_ITEMS_FREE(p);
s = sel->state; s = sel->state;
if (!s) return 0; if (!s) return 0;
if (!s->cur_plugins) if (sel == p->win->selectors[0])
{ subj_sel = 1;
/* 'text' and 'actions' are always loaded */
if ((sel == p->win->selectors[0]) && if (!sel->states->next)
(eina_list_count(s->plugins) == 2)) top_level = 1;
{
evry_item_ref(p->warning);
EVRY_PLUGIN_ITEM_APPEND(p, p->warning);
}
return 1;
}
/* get current items' context ... */ /* get current items' context ... */
for (i = 1; i < 3; i++) for (i = 1; i < 3; i++)
@ -56,54 +55,79 @@ _fetch(Evry_Plugin *plugin, const char *input)
} }
} }
/* filter all to be shown in aggregator */ /* collect plugins to be shown in aggregator */
EINA_LIST_FOREACH(s->cur_plugins, l, pp) EINA_LIST_FOREACH(s->cur_plugins, l, pp)
{ {
if (!pp->config->aggregate || pp == plugin) if (!pp->config->aggregate)
continue; continue;
if (!sel->states->next && !pp->config->top_level) if (pp == plugin)
continue;
if (top_level && !pp->config->top_level)
continue; continue;
lp = eina_list_append(lp, pp); lp = eina_list_append(lp, pp);
} }
/* show non-top-level plugins as item */ if (top_level && (!s->trigger_active))
if (!s->trigger_active && !sel->states->next)
{ {
/* show non-top-level plugins as item */
EINA_LIST_FOREACH(s->plugins, l, pp) EINA_LIST_FOREACH(s->plugins, l, pp)
{ {
GET_ITEM(it, pp); int min_fuzz = 0;
double max_usage = 0.0;
if (pp->config->top_level || pp == plugin) if (pp->config->top_level)
continue;
if (pp == plugin)
continue; continue;
if (!pp->items) if (!pp->items)
continue; continue;
it->hi = NULL; /* give plugin item the highest priority of its items */
it->usage = 0; EINA_LIST_FOREACH(pp->items, ll, it)
it->fuzzy_match = 0; {
if (it->usage >= 0)
evry_history_item_usage_set(it, input, context);
/* if (input) if (it->usage && it->usage > max_usage)
* { {
* evry_history_item_usage_set(it, NULL, NULL); max_usage = it->usage;
* it->usage /= 100.0; }
* it->fuzzy_match = ;
* } */ if (it->fuzzy_match == 0)
it->fuzzy_match = evry_fuzzy_match(it->label, input);
if ((!min_fuzz) || ((it->fuzzy_match > 0) &&
(it->fuzzy_match < min_fuzz)))
min_fuzz = it->fuzzy_match;
}
GET_ITEM(it, pp);
it->hi = NULL;
evry_history_item_usage_set(it, NULL, NULL);
it->usage /= 100.0;
if (it->usage && max_usage && (it->usage < max_usage))
it->usage = max_usage;
it->fuzzy_match = min_fuzz;
IF_RELEASE(it->detail); IF_RELEASE(it->detail);
snprintf(buf, sizeof(buf), "%d %s", eina_list_count(pp->items), _("Items")); snprintf(buf, sizeof(buf), "%d %s",
eina_list_count(pp->items), _("Items"));
it->detail = eina_stringshare_add(buf); it->detail = eina_stringshare_add(buf);
items = eina_list_append(items, it); items = eina_list_append(items, it);
} }
/* only one plugin: show items */ /* only one plugin: show items */
if (eina_list_count(s->cur_plugins) == 1 && items) if ((eina_list_count(s->cur_plugins)) == 1 && items &&
(pp = eina_list_data_get(items)) && (pp->config->aggregate))
{ {
pp = eina_list_data_get(items);
eina_list_free(items); eina_list_free(items);
items = NULL; items = NULL;
EINA_LIST_FOREACH(pp->items, l, it) EINA_LIST_FOREACH(pp->items, l, it)
{ {
if (it->usage >= 0) if (it->usage >= 0)
@ -114,27 +138,63 @@ _fetch(Evry_Plugin *plugin, const char *input)
items = eina_list_append(items, it); items = eina_list_append(items, it);
} }
} }
#if 0
/* append all plugins as items (which were not added above) */
if (inp_len >= plugin->config->min_query)
{
EINA_LIST_FOREACH(s->plugins, l, pp)
{
if (!strcmp(pp->name, "Actions"))
continue;
/* items MUST only conatin plugins here ! */
EINA_LIST_FOREACH(items, ll, pp2)
if (pp2->name == pp->name) break;
if (pp2)
continue;
GET_ITEM(it, pp);
if ((!input) ||
(it->fuzzy_match = evry_fuzzy_match(it->label, input)))
{
evry_history_item_usage_set(it, input, NULL);
it->usage /= 100.0;
EVRY_ITEM(pp)->plugin->state = s;
items = eina_list_append(items, pp);
}
}
}
#endif
if (!lp && (eina_list_count(items) < 2))
{
if (items) eina_list_free(items);
return 0;
}
} }
if (!lp && !items) return 0; if (!lp && !items)
return 0;
/* if there is only one plugin append all items */ /* if there is only one plugin append all items */
if (lp && !lp->next) if (lp && !lp->next)
{ {
pp = lp->data; pp = eina_list_data_get(lp);
EINA_LIST_FOREACH(pp->items, l, it) EINA_LIST_FOREACH(pp->items, l, it)
{ {
if (it->usage >= 0) if (it->usage >= 0)
evry_history_item_usage_set(it, input, context); evry_history_item_usage_set(it, input, context);
if (it->fuzzy_match == 0)
it->fuzzy_match = evry_fuzzy_match(it->label, input);
items = eina_list_append(items, it); if (it->fuzzy_match == 0)
} it->fuzzy_match = evry_fuzzy_match(it->label, input);
items = eina_list_append(items, it);
}
} }
/* if there is input append all items that match or have /* if there is input append all items that match */
fuzzy_match set to -1 */
else if (input) else if (input)
{ {
EINA_LIST_FOREACH(lp, l, pp) EINA_LIST_FOREACH(lp, l, pp)
@ -144,32 +204,16 @@ _fetch(Evry_Plugin *plugin, const char *input)
if (it->fuzzy_match == 0) if (it->fuzzy_match == 0)
it->fuzzy_match = evry_fuzzy_match(it->label, input); it->fuzzy_match = evry_fuzzy_match(it->label, input);
if (it->fuzzy_match || sel == p->win->selectors[2])
{
if (it->usage >= 0)
evry_history_item_usage_set(it, input, context);
items = eina_list_append(items, it);
}
}
}
}
/* always append items of action or object selector */
else if ((!input) &&
((sel == p->win->selectors[1]) ||
(sel == p->win->selectors[2])))
{
EINA_LIST_FOREACH(lp, l, pp)
{
EINA_LIST_FOREACH(pp->items, ll, it)
{
if (it->usage >= 0) if (it->usage >= 0)
evry_history_item_usage_set(it, NULL, context); evry_history_item_usage_set(it, input, context);
it->fuzzy_match = 0;
if ((subj_sel) && (top_level) &&
(!it->usage) && (inp_len < 2))
continue;
items = eina_list_append(items, it); items = eina_list_append(items, it);
} }
} }
} }
/* no input: append all items that are in history */ /* no input: append all items that are in history */
else else
@ -178,9 +222,9 @@ _fetch(Evry_Plugin *plugin, const char *input)
{ {
EINA_LIST_FOREACH(pp->items, ll, it) EINA_LIST_FOREACH(pp->items, ll, it)
{ {
if ((it->usage >= 0) && if (((it->usage >= 0) &&
(evry_history_item_usage_set(it, input, context)) && (evry_history_item_usage_set(it, input, context))) ||
(!eina_list_data_find_list(items, it))) (!subj_sel))
{ {
it->fuzzy_match = 0; it->fuzzy_match = 0;
items = eina_list_append(items, it); items = eina_list_append(items, it);
@ -189,22 +233,18 @@ _fetch(Evry_Plugin *plugin, const char *input)
} }
} }
if (lp && lp->next && eina_list_count(items) < MAX_ITEMS) if ((!top_level) && (eina_list_count(items) < MAX_ITEMS))
{ {
EINA_LIST_FOREACH(lp, l, pp) EINA_LIST_FOREACH(lp, l, pp)
{ {
EINA_LIST_FOREACH(pp->items, ll, it) EINA_LIST_FOREACH(pp->items, ll, it)
{ {
if (!eina_list_data_find_list(items, it)) if (eina_list_data_find_list(items, it))
{ continue;
it->usage = -1;
if (it->fuzzy_match == 0)
it->fuzzy_match = evry_fuzzy_match(it->label, input);
items = eina_list_append(items, it); items = eina_list_append(items, it);
} }
} }
}
} }
items = eina_list_sort(items, -1, evry_items_sort_func); items = eina_list_sort(items, -1, evry_items_sort_func);
@ -234,16 +274,45 @@ _fetch(Evry_Plugin *plugin, const char *input)
} }
if (items) eina_list_free(items);
if (lp) eina_list_free(lp); if (lp) eina_list_free(lp);
if (items)
{
eina_list_free(items);
}
/* 'text' and 'actions' are always loaded */
else if ((subj_sel) && (eina_list_count(s->plugins) == 2))
{
evry_item_ref(p->warning);
EVRY_PLUGIN_ITEM_APPEND(p, p->warning);
}
return !!(p->base.items); return !!(p->base.items);
} }
static void static void
_finish(Evry_Plugin *p) _finish(Evry_Plugin *plugin)
{ {
GET_PLUGIN(p, plugin);
EVRY_PLUGIN_ITEMS_FREE(p); EVRY_PLUGIN_ITEMS_FREE(p);
E_FREE(p);
}
static Evry_Plugin *
_begin(Evry_Plugin *plugin, const Evry_Item *it __UNUSED__)
{
Plugin *p;
GET_PLUGIN(base, plugin);
EVRY_PLUGIN_INSTANCE(p, plugin);
p->type = base->type;
p->win = base->win;
p->warning = base->warning;
return EVRY_PLUGIN(p);
} }
static void static void
@ -251,8 +320,6 @@ _free(Evry_Plugin *plugin)
{ {
GET_PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
_finish(plugin);
evry_item_free(p->warning); evry_item_free(p->warning);
free(p); free(p);
@ -263,7 +330,7 @@ evry_aggregator_new(Evry_Window *win, int type)
{ {
Evry_Plugin *p; Evry_Plugin *p;
p = EVRY_PLUGIN_NEW(Plugin, N_("All"), NULL, 0, NULL, _finish, _fetch, _free); p = EVRY_PLUGIN_NEW(Plugin, N_("All"), NULL, 0, _begin, _finish, _fetch, _free);
if (evry_plugin_register(p, type, -1)) if (evry_plugin_register(p, type, -1))
{ {

View File

@ -10,8 +10,6 @@ typedef struct _Plugin Plugin;
struct _Plugin struct _Plugin
{ {
Evry_Plugin base; Evry_Plugin base;
const char *input;
Eina_List *items;
}; };
static Eina_List *plugins = NULL; static Eina_List *plugins = NULL;
@ -44,32 +42,59 @@ _browse(Evry_Plugin *plugin, const Evry_Item *item)
return NULL; return NULL;
} }
static Evry_Item *
_add_item(Plugin *p, Plugin_Config *pc)
{
Evry_Plugin *pp;
Evry_Item *it = NULL;
if (pc->enabled && (pp = evry_plugin_find(pc->name)))
{
pc->plugin = pp;
GET_ITEM(itp, pp);
it = EVRY_ITEM_NEW(Evry_Item, EVRY_PLUGIN(p), itp->label, NULL, NULL);
if (itp->icon) it->icon = eina_stringshare_ref(itp->icon);
it->icon_get = itp->icon_get;
it->data = pc;
it->browseable = EINA_TRUE;
p->base.items = eina_list_append(p->base.items, it);
}
return it;
}
static Evry_Plugin * static Evry_Plugin *
_begin(Evry_Plugin *plugin, const Evry_Item *item) _begin(Evry_Plugin *plugin, const Evry_Item *item)
{ {
Evry_Plugin *pp;
Plugin_Config *pc; Plugin_Config *pc;
Evry_Item *it;
Eina_List *l; Eina_List *l;
Plugin *p; Plugin *p;
EVRY_PLUGIN_INSTANCE(p, plugin); EVRY_PLUGIN_INSTANCE(p, plugin);
EINA_LIST_FOREACH(plugin->config->plugins, l, pc) EINA_LIST_FOREACH(plugin->config->plugins, l, pc)
_add_item(p, pc);
return EVRY_PLUGIN(p);
}
static Evry_Plugin *
_begin_all(Evry_Plugin *plugin, const Evry_Item *item)
{
Plugin_Config *pc;
Eina_List *l;
Plugin *p;
EVRY_PLUGIN_INSTANCE(p, plugin);
EINA_LIST_FOREACH(evry_conf->conf_subjects, l, pc)
{ {
if (!pc->enabled) if (!strcmp(pc->name, "All") ||
!strcmp(pc->name, "Actions") ||
!strcmp(pc->name, "Plugins"))
continue; continue;
if ((pp = evry_plugin_find(pc->name))) _add_item(p, pc);
{
GET_ITEM(itp, pp);
it = EVRY_ITEM_NEW(Evry_Item, EVRY_PLUGIN(p), itp->label, NULL, NULL);
if (itp->icon) it->icon = eina_stringshare_ref(itp->icon);
pc->plugin = pp;
it->data = pc;
it->browseable = EINA_TRUE;
p->base.items = eina_list_append(p->base.items, it);
}
} }
return EVRY_PLUGIN(p); return EVRY_PLUGIN(p);
@ -84,8 +109,6 @@ _finish(Evry_Plugin *plugin)
EVRY_PLUGIN_ITEMS_FREE(p); EVRY_PLUGIN_ITEMS_FREE(p);
IF_RELEASE(p->input);
E_FREE(p); E_FREE(p);
} }
@ -111,6 +134,19 @@ evry_plug_collection_init(void)
e_configure_registry_category_add e_configure_registry_category_add
("extensions", 80, _("Extensions"), NULL, "preferences-extensions"); ("extensions", 80, _("Extensions"), NULL, "preferences-extensions");
p = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Plugins"),
_module_icon, COLLECTION_PLUGIN,
_begin_all, _finish, _fetch, NULL);
p->browse = &_browse;
if (evry_plugin_register(p, EVRY_PLUGIN_SUBJECT, 1))
{
p->config->enabled = EINA_FALSE;
p->config->aggregate = EINA_FALSE;
}
plugins = eina_list_append(plugins, p);
EINA_LIST_FOREACH(evry_conf->collections, l, pc) EINA_LIST_FOREACH(evry_conf->collections, l, pc)
{ {
p = EVRY_PLUGIN_NEW(Evry_Plugin, N_(pc->name), p = EVRY_PLUGIN_NEW(Evry_Plugin, N_(pc->name),
@ -146,9 +182,12 @@ evry_plug_collection_shutdown(void)
EINA_LIST_FREE(plugins, p) EINA_LIST_FREE(plugins, p)
{ {
e_configure_registry_item_del(p->config_path); if (p->config_path)
eina_stringshare_del(p->config_path); {
e_configure_registry_item_del(p->config_path);
eina_stringshare_del(p->config_path);
}
EVRY_PLUGIN_FREE(p); EVRY_PLUGIN_FREE(p);
} }
} }

View File

@ -149,6 +149,7 @@ evry_plugin_register(Evry_Plugin *p, int type, int priority)
act = EVRY_ACTION_NEW(buf, p->input_type, 0, EVRY_ITEM(p)->icon, act = EVRY_ACTION_NEW(buf, p->input_type, 0, EVRY_ITEM(p)->icon,
_evry_plugin_action_browse, NULL); _evry_plugin_action_browse, NULL);
EVRY_ITEM(act)->icon_get = EVRY_ITEM(p)->icon_get;
EVRY_ITEM(act)->data = p; EVRY_ITEM(act)->data = p;
evry_action_register(act, 1); evry_action_register(act, 1);
actions = eina_list_append(actions, act); actions = eina_list_append(actions, act);