static Evry_Module *evry_module = NULL;
static Module_Config *_conf;
static Evry_Plugin *_plug = NULL;
-static char _config_path[] = "extensions/everthing-aspell";
-static char _config_domain[] = "module.everyhing-aspell";
+static char _config_path[] = "extensions/everything-aspell";
+static char _config_domain[] = "module.everything-aspell";
static char _module_icon[] = "accessories-dictionary";
static E_Config_DD *_conf_edd = NULL;
int cnt = 0;
Evry_Item *it;
Eina_List *l;
+ int len = p->input ? strlen(p->input) : 0;
EVRY_PLUGIN_ITEMS_CLEAR(p);
{
if (!p->input)
return 0;
- if (strlen(p->input) < p->min_query)
+ if (len < p->min_query)
return 0;
}
if (p->dirs_only && !it->browseable)
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;
if (!it->browseable)
EVRY_PLUGIN_ITEM_APPEND(p, it);
cnt++;
}
- else if (!p->input)
+ else if (len == 0)
{
if (!it->browseable)
it->priority = 1;
/* provide subject */
EVRY_PLUGIN_INSTANCE(p, plugin);
p->parent = EINA_FALSE;
-
+
if (_conf->show_homedir)
p->directory = eina_stringshare_add(e_user_homedir_get());
if (!p->parent)
p->min_query = plugin->config->min_query;
-
+
if ((p->command) || (!p->min_query) || (len >= p->min_query))
_append_files(p);
Evry_Plugin base;
Eina_List *items;
Eina_List *categories;
+ Eina_Bool parent;
};
struct _Settings_Item
it = (Settings_Item *) item;
EVRY_PLUGIN_INSTANCE(p, plugin);
+ p->parent = EINA_TRUE;
GET_PLUGIN(parent, item->plugin);
EVRY_PLUGIN_ITEMS_CLEAR(p);
- if (len < plugin->config->min_query)
+ if ((!p->parent) && (len < plugin->config->min_query))
return 0;
if (!p->categories && !p->items)
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);
}
_evry_type_init("TEXT");
_config_init();
- evry_history_init();
+ evry_history_init();
evry_plug_actions_init();
evry_plug_collection_init();
evry_plug_clipboard_init();
if (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;
}
Plugin_Config *pc, *pc2;
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);
- E_FREE(pc2);
- }
+ IF_RELEASE(pc2->name);
+ IF_RELEASE(pc2->trigger);
+ E_FREE(pc2);
}
EINA_LIST_FREE(evry_conf->conf_subjects, pc)
{
IF_RELEASE(pc->name);
IF_RELEASE(pc->trigger);
- if (pc->plugin)
- evry_plugin_free(pc->plugin);
E_FREE(pc);
}
EINA_LIST_FREE(evry_conf->conf_actions, pc)
{
IF_RELEASE(pc->name);
IF_RELEASE(pc->trigger);
- if (pc->plugin)
- evry_plugin_free(pc->plugin);
E_FREE(pc);
}
EINA_LIST_FREE(evry_conf->conf_objects, pc)
{
IF_RELEASE(pc->name);
IF_RELEASE(pc->trigger);
- if (pc->plugin)
- evry_plugin_free(pc->plugin);
E_FREE(pc);
}
-
E_FREE(evry_conf);
}
/* if (zone) evry_show(zone, _params); */
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
/* active plugin */
Evry_Plugin *plugin;
+ /* aggregator instance */
+ Evry_Plugin *aggregator;
+
/* selected item */
Evry_Item *cur_item;
int evry_plug_actions_init();
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);
EAPI extern E_Module_Api e_modapi;
+/* #define CHECK_REFS */
+
+#ifdef CHECK_REFS
+extern Eina_List *refd;
+#endif
+
#endif
static void _evry_list_win_update(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 void _evry_view_show(Evry_View *v, int slide);
static void _evry_view_hide(Evry_View *v, int slide, int destroy);
}
static int
-_evry_aggregator_fetch(Evry_Selector *sel, const char *input)
+_evry_aggregator_fetch(Evry_State *s)
{
- Evry_State *s = sel->state;
-
if (!s)
{
- sel->aggregator->finish(sel->aggregator);
- return 1;
+ ERR("no state");
+ return 0;
}
- if ((sel->aggregator->fetch(sel->aggregator, input)) &&
- (!eina_list_data_find(s->cur_plugins, sel->aggregator)))
+ if ((s->aggregator->fetch(s->aggregator, s->input)) &&
+ (!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;
}
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)
{
evry_view_toggle(sel->state, "?");
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)
if (!strcmp(params, p->name)) break;
_evry_plugin_select((CUR_SEL)->state, p);
_evry_selector_update(CUR_SEL);
- _evry_view_update((CUR_SEL)->state, p);
+ _evry_view_update((CUR_SEL)->state);
}
return 1;
}
if ((clear && CUR_SEL) &&
((eina_list_count((SUBJ_SEL)->states) > 1) ||
- (((SUBJ_SEL)->state) &&
- ((SUBJ_SEL)->state->input[0]))))
+ (CUR_SEL != SUBJ_SEL) ||
+ (((CUR_SEL)->state) &&
+ ((CUR_SEL)->state->input[0]))))
{
int slide = 0;
Evry_Selector *sel;
_evry_clear(sel);
_evry_clear(sel);
- _evry_aggregator_fetch(sel, s->input);
+ _evry_aggregator_fetch(s);
_evry_selector_update(sel);
_evry_update_text_label(s);
_evry_view_show(s->view, slide);
_evry_update_text_label(s);
}
-//#define CHECK_REFS
-
#ifdef CHECK_REFS
static int item_cnt = 0;
+Eina_List *refd = NULL;
#endif
Evry_Item *
#ifdef CHECK_REFS
item_cnt++;
+ refd = eina_list_append(refd, it);
printf("%d, %d\t new : %s\n", it->ref, item_cnt, it->label);
#endif
it->ref--;
#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
if (it->ref > 0) return;
#ifdef CHECK_REFS
item_cnt--;
+ refd = eina_list_remove(refd, it);
#endif
IF_RELEASE(it->label);
if ((CUR_SEL == sel) && (s = sel->state))
{
- if (s->view)
- s->view->update(s->view);
- else
- _evry_view_update(s, NULL);
+ if (_evry_view_update(s))
+ _evry_view_show(s->view, 0);
+
+ /* if (s->view)
+ * s->view->update(s->view);
+ * else
+ * _evry_view_update(s, NULL) */
}
return 0;
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)
{
/* remove plugin */
s->cur_plugins = eina_list_remove(s->cur_plugins, p);
+ _evry_aggregator_fetch(s);
+
if (s->plugin == p)
_evry_plugin_select(s, NULL);
}
/* add plugin to current plugins*/
_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);
}
- if (s->sel_items)
- eina_list_free(s->sel_items);
- s->sel_items = NULL;
-
- _evry_aggregator_fetch(sel, s->input);
-
/* plugin is visible */
if ((sel->state == s) &&
((s->plugin == p) ||
- (s->plugin == sel->aggregator)))
+ (s->plugin == s->aggregator)))
{
_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 */
else if (action == EVRY_UPDATE_REFRESH)
{
_evry_view_clear(s);
- _evry_view_update(s, NULL);
+ _evry_view_update(s);
}
}
if (type == EVRY_PLUGIN_SUBJECT)
{
- sel->actions = evry_plug_actions_new(sel, type);
pcs = evry_conf->conf_subjects;
o = edje_object_part_swallow_get(win->o_main, "subject_selector");
}
else if (type == EVRY_PLUGIN_ACTION)
{
- sel->actions = evry_plug_actions_new(sel, type);
pcs = evry_conf->conf_actions;
o = edje_object_part_swallow_get(win->o_main, "action_selector");
}
_evry_state_pop(sel, 1);
EVRY_PLUGIN_FREE(sel->aggregator);
- EVRY_PLUGIN_FREE(sel->actions);
if (sel->plugins) eina_list_free(sel->plugins);
sel->o_thumb = e_thumb_icon_add(win->popup->evas);
evas_object_smart_callback_add(sel->o_thumb, "e_thumb_gen",
_evry_selector_thumb_gen, sel);
- /* edje_object_part_geometry_get(sel->o_main, "e.swallow.thumb",
- * NULL, NULL, &w, &h); */
if (suffix)
e_thumb_icon_file_set(sel->o_thumb, file->path, "e/desktop/background");
else
if (s != (CUR_SEL)->state) return;
if (!win->visible) return;
- /* if (s->changed) */
- _evry_view_update(s, s->plugin);
+ if (_evry_view_update(s))
+ _evry_view_show(s->view, 0);
}
static int
if (plugin_name && strcmp(plugin_name, p->name))
continue;
- /* if (!p->config->top_level)
- * continue; */
-
if (p->begin && (pp = p->begin(p, NULL)))
plugins = eina_list_append(plugins, pp);
if (!plugins) return 0;
_evry_state_new(sel, plugins);
-
- EINA_LIST_FOREACH(plugins, l, p)
- p->state = sel->state;
-
- DBG("%s", plugin_name);
-
_evry_matches_update(sel, 1);
return 1;
EINA_LIST_FOREACH(sel->plugins, l, p)
{
- /* if (!p->config->top_level)
- * continue; */
-
if (p->begin && (pp = p->begin(p, it)))
plugins = eina_list_append(plugins, pp);
}
if (!plugins) return 0;
_evry_state_new(sel, plugins);
-
- EINA_LIST_FOREACH(plugins, l, p)
- p->state = sel->state;
-
_evry_matches_update(sel, 1);
return 1;
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))
continue;
if (!plugins) return 0;
_evry_state_new(sel, plugins);
- EINA_LIST_FOREACH(plugins, l, p)
- p->state = sel->state;
-
_evry_matches_update(sel, 1);
return 1;
_evry_state_new(Evry_Selector *sel, Eina_List *plugins)
{
Evry_State *s = E_NEW(Evry_State, 1);
+ Eina_List *l;
+ Evry_Plugin *p;
+
+ if (!s) return NULL;
+
s->inp = malloc(INPUTLEN);
s->inp[0] = 0;
s->input = s->inp;
sel->states = eina_list_prepend(sel->states, 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;
}
{
Evry_Plugin *p;
Evry_State *s;
- Evry_State *prev = NULL;
+ Evry_State *prev;
s = sel->state;
_evry_item_desel(s, NULL);
- free(s->inp);
-
if (s->view)
{
if (immediate)
s->view->destroy(s->view);
else
_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)
eina_list_free(s->sel_items);
sel->states = eina_list_remove_list(sel->states, sel->states);
-
- if (sel->states)
- prev = sel->states->data;
+ prev = eina_list_data_get(sel->states);
EINA_LIST_FREE(s->plugins, p)
{
- /* FIXME use it->free cb also for plugin instances*/
-
/* skip non top-level plugins */
if (prev && eina_list_data_find(prev->plugins, p))
{
p->state = prev;
continue;
}
-
- /* if (EVRY_ITEM(p)->ref == 0) */
p->finish(p);
- /* else
- * p->state = NULL; */
}
-
-
+ E_FREE(s->inp);
E_FREE(s);
sel->state = prev;
sel = s->selector;
- if ((it->plugin->browse) &&
- (pp = it->plugin->browse(it->plugin, it)))
+ /* aggregator */
+ if (CHECK_TYPE(it, EVRY_TYPE_PLUGIN))
{
- plugins = eina_list_append(plugins, pp);
- pref = pp;
+ browse_aggregator = 1;
+ plugins = eina_list_append(plugins, it);
}
-
- EINA_LIST_FOREACH(sel->plugins, l, p)
+ else
{
- if ((p->browse) && (pp = p->browse(p, it)))
+ if ((it->plugin->browse) &&
+ (pp = it->plugin->browse(it->plugin, it)))
{
- if (pref && !strcmp(pp->name, pref->name))
- continue;
plugins = eina_list_append(plugins, pp);
+ pref = pp;
}
- }
- /* aggregator */
- if (!(plugins) && CHECK_TYPE(it, EVRY_TYPE_PLUGIN))
- {
- browse_aggregator = 1;
- plugins = eina_list_append(plugins, it);
+ 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))
return 0;
}
- EINA_LIST_FOREACH(plugins, l, p)
- p->state = new_state;
-
if (s->view)
{
_evry_view_hide(s->view, SLIDE_LEFT, 0);
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));
}
else
_evry_matches_update(sel, 1);
s = new_state;
+ _evry_plugin_select(s, pref);
}
_evry_selector_update(sel);
_evry_state_pop(sel, 0);
s = sel->state;
- _evry_aggregator_fetch(sel, s->input);
+ /* _evry_aggregator_fetch(s); */
_evry_selector_update(sel);
if (sel == SUBJ_SEL)
_evry_selector_update_actions(ACTN_SEL);
if (hi->count < 0) hi->count = 1;
}
}
- if (s->plugin == s->selector->aggregator)
- _evry_aggregator_fetch(s->selector, s->input);
+ if (s->plugin == s->aggregator)
+ _evry_aggregator_fetch(s);
if (s->view)
s->view->update(s->view);
evas_object_hide(v->o_list);
}
win->view_clearing = NULL;
+ }
- /* replay mouse down to allow direct sliding back */
- if (win->mouse_button)
- evas_event_feed_mouse_down(win->popup->evas, win->mouse_button, 0, 0, NULL);
+ /* replay mouse down to allow direct sliding back */
+ if (win->mouse_button)
+ {
+ evas_event_feed_mouse_down(win->popup->evas,
+ win->mouse_button,
+ 0, 0, NULL);
}
}
{
/* replay mouse up to allow direct sliding back */
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)
{
- 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);
- 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)
win->view_freeing = v;
else
}
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);
- 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;
}
-
+
+ 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)
{
edje_object_part_unswallow(win->o_main, v->o_bar);
v->destroy(v);
}
-static void
-_evry_view_update(Evry_State *s, Evry_Plugin *p)
+static int
+_evry_view_update(Evry_State *s)
{
- if (!win->visible) return;
+ if (!win->visible) return 0;
if (!s->view)
{
Evry_View *view = evry_conf->views->data;
- s->view = view->create(view, s, win->o_main);
- /* _evry_view_show(s->view, 0); */
+ if (!(s->view = view->create(view, s, win->o_main)))
+ return 0;
+
+ s->view->update(s->view);
+ return 1;
}
if (s->view)
s->view->update(s->view);
+
+ return 0;
}
static void
_evry_list_win_show();
if (s->view)
- {
- _evry_view_hide(s->view, 0, 1);
- /* s->view->destroy(s->view); */
- }
+ _evry_view_hide(s->view, 0, 1);
s->view = v;
_evry_view_show(s->view, 0);
/* query all other plugins for this state */
EINA_LIST_FOREACH(s->plugins, l, p)
{
- 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;
- }
+ p->request = s->request;
/* dont wait for async plugin. use their current items */
if (!async && p->async_fetch && p->items)
continue;
}
- p->request = s->request;
-
- if ((p->fetch(p, input)) || (sel->states->next))
+ if ((sel->states->next) ||
+ ((CUR_SEL == SUBJ_SEL) && (win->plugin_dedicated)))
{
+ p->fetch(p, input);
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:
- _evry_aggregator_fetch(sel, input);
+ /* _evry_aggregator_fetch(s); */
if (s->plugin_auto_selected ||
(s->plugin && (!eina_list_data_find(s->cur_plugins, s->plugin))))
e_widget_table_object_append(ob, of, 1, 0, 1, 1, 1, 1, 1, 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);
e_widget_disabled_set(o, 1);
page->o_trigger = 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));
e_widget_disabled_set(o, 1);
page->o_trigger_only = o;
if (!it)
return NULL;
+ if ((!it->plugin->history) && (!CHECK_TYPE(it, EVRY_TYPE_PLUGIN)))
+ return NULL;
+
if (it->type == EVRY_TYPE_ACTION)
{
GET_ACTION(act, it);
int rem_ctxt = 1;
it->usage = 0.0;
- if (!it->plugin->history)
+ if ((!it->plugin->history) && (!CHECK_TYPE(it, EVRY_TYPE_PLUGIN)))
return 0;
if (it->hi)
struct _Plugin
{
Evry_Plugin base;
- Evry_Selector *selector;
Eina_List *actions;
Eina_Bool parent;
Evry_Action *action;
};
-static Evry_Plugin *_base_plug = NULL;
+static Evry_Plugin *_plug = NULL;
static void
_finish(Evry_Plugin *plugin)
GET_PLUGIN(p, plugin);
Evry_Action *act;
- if (p->parent)
- {
- EINA_LIST_FREE(p->actions, act);
- E_FREE(p);
- }
- else
- {
- EINA_LIST_FREE(p->actions, act);
- }
+ EINA_LIST_FREE(p->actions, act);
+ E_FREE(p);
}
static Evry_Plugin *
act = EVRY_ACTN(it);
- p = E_NEW(Plugin, 1);
- p->base = *plugin;
- p->base.items = NULL;
+ EVRY_PLUGIN_INSTANCE(p, plugin);
p->actions = act->fetch(act);
p->parent = EINA_TRUE;
p->action = act;
{
Evry_Action *act;
Eina_List *l;
+ Plugin *p;
- GET_PLUGIN(p, plugin);
-
- EINA_LIST_FREE(p->actions, act);
+ EVRY_PLUGIN_INSTANCE(p, plugin);
if (!(CHECK_TYPE(it, EVRY_TYPE_PLUGIN)))
{
if (act->check_item && !(act->check_item(act, it)))
continue;
- act->base.plugin = plugin;
+ act->base.plugin = EVRY_PLUGIN(p);
act->it1.item = it;
EVRY_ITEM(act)->hi = NULL;
{
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);
EVRY_ITEM(act)->hi = NULL;
}
}
- if (!p->actions) return NULL;
-
- return plugin;
+ return EVRY_PLUGIN(p);
}
static int
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
evry_plug_actions_init()
{
- _base_plug = evry_plugin_new(NULL, _("Actions"), NULL, NULL,
- EVRY_TYPE_ACTION, NULL, NULL, NULL, NULL);
+ _plug = EVRY_PLUGIN_NEW(Plugin, N_("Actions"), NULL,
+ EVRY_TYPE_ACTION,
+ _begin, _finish, _fetch, NULL);
+
+ _plug->browse = &_browse;
+
+ evry_plugin_register(_plug, EVRY_PLUGIN_ACTION, 2);
return 1;
}
{
Evry_Item *it;
- evry_plugin_free(_base_plug);
+ evry_plugin_free(_plug);
/* bypass unregister, because it modifies the list */
EINA_LIST_FREE(evry_conf->actions, it)
{
GET_ACTION(act, it);
- if (act->name) eina_stringshare_del(act->name);
+ IF_RELEASE(act->name);
E_FREE(act);
}
int (*action) (Evry_Action *act),
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)
act->base.icon = eina_stringshare_add(icon);
#include "e_mod_main.h"
+//TODO min input for items not in history
+
#define MAX_ITEMS 50
typedef struct _Plugin Plugin;
_fetch(Evry_Plugin *plugin, const char *input)
{
Plugin *p = (Plugin *) plugin;
- Evry_Plugin *pp;
+ Evry_Plugin *pp, *pp2;
Evry_State *s;
Eina_List *l, *ll, *lp = NULL;
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;
const char *context = NULL;
char buf[128];
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);
s = sel->state;
if (!s) return 0;
- if (!s->cur_plugins)
- {
- /* 'text' and 'actions' are always loaded */
- if ((sel == p->win->selectors[0]) &&
- (eina_list_count(s->plugins) == 2))
- {
- evry_item_ref(p->warning);
- EVRY_PLUGIN_ITEM_APPEND(p, p->warning);
- }
- return 1;
- }
+ if (sel == p->win->selectors[0])
+ subj_sel = 1;
+
+ if (!sel->states->next)
+ top_level = 1;
/* get current items' context ... */
for (i = 1; i < 3; i++)
}
}
- /* filter all to be shown in aggregator */
+ /* collect plugins to be shown in aggregator */
EINA_LIST_FOREACH(s->cur_plugins, l, pp)
{
- if (!pp->config->aggregate || pp == plugin)
+ if (!pp->config->aggregate)
+ continue;
+ if (pp == plugin)
continue;
- if (!sel->states->next && !pp->config->top_level)
+ if (top_level && !pp->config->top_level)
continue;
lp = eina_list_append(lp, pp);
}
- /* show non-top-level plugins as item */
- if (!s->trigger_active && !sel->states->next)
+ if (top_level && (!s->trigger_active))
{
+ /* show non-top-level plugins as item */
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;
if (!pp->items)
continue;
+ /* give plugin item the highest priority of its items */
+ EINA_LIST_FOREACH(pp->items, ll, it)
+ {
+ if (it->usage >= 0)
+ evry_history_item_usage_set(it, input, context);
+
+ if (it->usage && it->usage > max_usage)
+ {
+ max_usage = it->usage;
+ }
+
+ 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;
- it->usage = 0;
- it->fuzzy_match = 0;
- /* if (input)
- * {
- * evry_history_item_usage_set(it, NULL, NULL);
- * it->usage /= 100.0;
- * it->fuzzy_match = ;
- * } */
+ 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);
- 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);
items = eina_list_append(items, it);
}
/* 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);
items = NULL;
-
EINA_LIST_FOREACH(pp->items, l, it)
{
if (it->usage >= 0)
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 (lp && !lp->next)
{
- pp = lp->data;
+ pp = eina_list_data_get(lp);
- EINA_LIST_FOREACH(pp->items, l, it)
- {
- if (it->usage >= 0)
- evry_history_item_usage_set(it, input, context);
- if (it->fuzzy_match == 0)
- it->fuzzy_match = evry_fuzzy_match(it->label, input);
+ EINA_LIST_FOREACH(pp->items, l, it)
+ {
+ if (it->usage >= 0)
+ evry_history_item_usage_set(it, input, context);
- 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
- fuzzy_match set to -1 */
+ /* if there is input append all items that match */
else if (input)
{
EINA_LIST_FOREACH(lp, l, pp)
if (it->fuzzy_match == 0)
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)
- evry_history_item_usage_set(it, NULL, context);
- it->fuzzy_match = 0;
+ evry_history_item_usage_set(it, input, context);
+
+ if ((subj_sel) && (top_level) &&
+ (!it->usage) && (inp_len < 2))
+ continue;
items = eina_list_append(items, it);
- }
- }
+ }
+ }
}
/* no input: append all items that are in history */
else
{
EINA_LIST_FOREACH(pp->items, ll, it)
{
- if ((it->usage >= 0) &&
- (evry_history_item_usage_set(it, input, context)) &&
- (!eina_list_data_find_list(items, it)))
+ if (((it->usage >= 0) &&
+ (evry_history_item_usage_set(it, input, context))) ||
+ (!subj_sel))
{
it->fuzzy_match = 0;
items = eina_list_append(items, it);
}
}
- 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(pp->items, ll, it)
- {
- if (!eina_list_data_find_list(items, it))
- {
- it->usage = -1;
- if (it->fuzzy_match == 0)
- it->fuzzy_match = evry_fuzzy_match(it->label, input);
+ EINA_LIST_FOREACH(lp, l, pp)
+ {
+ EINA_LIST_FOREACH(pp->items, ll, it)
+ {
+ if (eina_list_data_find_list(items, it))
+ continue;
- items = eina_list_append(items, it);
- }
- }
- }
+ items = eina_list_append(items, it);
+ }
+ }
}
items = eina_list_sort(items, -1, evry_items_sort_func);
}
- if (items) eina_list_free(items);
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);
}
static void
-_finish(Evry_Plugin *p)
+_finish(Evry_Plugin *plugin)
{
+ GET_PLUGIN(p, plugin);
+
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
{
GET_PLUGIN(p, plugin);
- _finish(plugin);
-
evry_item_free(p->warning);
free(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))
{
struct _Plugin
{
Evry_Plugin base;
- const char *input;
- Eina_List *items;
};
static Eina_List *plugins = 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 *
_begin(Evry_Plugin *plugin, const Evry_Item *item)
{
- Evry_Plugin *pp;
Plugin_Config *pc;
- Evry_Item *it;
Eina_List *l;
Plugin *p;
EVRY_PLUGIN_INSTANCE(p, plugin);
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;
-
- if ((pp = evry_plugin_find(pc->name)))
- {
- 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);
- }
+
+ _add_item(p, pc);
}
-
+
return EVRY_PLUGIN(p);
}
EVRY_PLUGIN_ITEMS_FREE(p);
- IF_RELEASE(p->input);
-
E_FREE(p);
}
e_configure_registry_category_add
("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)
{
p = EVRY_PLUGIN_NEW(Evry_Plugin, N_(pc->name),
plugins = eina_list_append(plugins, p);
}
-
+
return EINA_TRUE;
}
EINA_LIST_FREE(plugins, p)
{
- e_configure_registry_item_del(p->config_path);
- eina_stringshare_del(p->config_path);
+ if (p->config_path)
+ {
+ e_configure_registry_item_del(p->config_path);
+ eina_stringshare_del(p->config_path);
+ }
+
EVRY_PLUGIN_FREE(p);
}
-
}
act = EVRY_ACTION_NEW(buf, p->input_type, 0, EVRY_ITEM(p)->icon,
_evry_plugin_action_browse, NULL);
+ EVRY_ITEM(act)->icon_get = EVRY_ITEM(p)->icon_get;
EVRY_ITEM(act)->data = p;
evry_action_register(act, 1);
actions = eina_list_append(actions, act);
int cnt = eina_list_count(sd->items);
double col = 1;
int width = sd->w - 8;
-
+
if (cnt < 5)
{
col = 2;
sel = sd->view->state->selector;
if (!sel || !sel->states)
return;
-
+
diff_x = abs(ev->cur.canvas.x - sd->mouse_x);
diff_y = abs(ev->cur.canvas.y - sd->mouse_y);