static const Evry_API *evry = NULL;
static Evry_Module *evry_module = NULL;
-static Evry_Plugin *p1;
+static Evry_Plugin *_plug;
+static Ecore_Event_Handler *action_handler = NULL;
static Ecore_Exe *exe = NULL;
static Eina_List *history = NULL;
}
}
-/* static int
- * _action(Evry_Plugin *p, const Evry_Item *act __UNUSED__, const Evry_Item *it)
- * {
- * Eina_List *l;
- * Evry_Item *it2, *it_old;
- *
- * /\* remove duplicates *\/
- * if (p->items->next)
- * {
- * it = p->items->data;
- *
- * EINA_LIST_FOREACH(p->items->next, l, it2)
- * {
- * if (!strcmp(it->label, it2->label))
- * break;
- * it2 = NULL;
- * }
- *
- * if (it2)
- * {
- * p->items = eina_list_remove(p->items, it2);
- * evry_item_free(it2);
- * }
- * }
- *
- * it_old = p->items->data;
- * it_old->selected = EINA_FALSE;
- *
- * it2 = evry_item_new(NULL, p, it_old->label, NULL);
- * it2->context = eina_stringshare_ref(p->name);
- * p->items = eina_list_prepend(p->items, it2);
- *
- * evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
- *
- * return EVRY_ACTION_FINISHED;
- * } */
+static int
+_cb_action_performed(void *data, int type, void *event)
+{
+ Eina_List *l;
+ Evry_Item *it, *it2, *it_old;
+ Evry_Event_Action_Performed *ev = event;
+ Evry_Plugin *p = _plug;
+
+ if (!ev->it1 || !(ev->it1->plugin == p))
+ return 1;
+
+ /* remove duplicates */
+ if (p->items->next)
+ {
+ it = p->items->data;
+
+ EINA_LIST_FOREACH(p->items->next, l, it2)
+ {
+ if (!strcmp(it->label, it2->label))
+ break;
+ it2 = NULL;
+ }
+
+ if (it2)
+ {
+ p->items = eina_list_remove(p->items, it2);
+ EVRY_ITEM_FREE(it2);
+ }
+ }
+
+ it_old = p->items->data;
+ it_old->selected = EINA_FALSE;
+
+ 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_PLUGIN_UPDATE(p, EVRY_UPDATE_ADD);
+
+ return 1;
+}
static int
_fetch(Evry_Plugin *p, const char *input)
static int
_plugins_init(const Evry_API *_api)
-{
- if (evry_module->active)
+{
+ if (evry_module->active)
return EINA_TRUE;
evry = _api;
return EINA_FALSE;
EVRY_TYPE_TEXT = evry->type_register("TEXT");
-
- p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Calculator"),
+
+ action_handler = ecore_event_handler_add(EVRY_EVENT_ACTION_PERFORMED,
+ _cb_action_performed, NULL);
+
+ _plug = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Calculator"),
_module_icon,
EVRY_TYPE_TEXT,
_begin, _cleanup, _fetch, NULL);
- p1->history = EINA_FALSE;
- p1->async_fetch = EINA_TRUE;
+ _plug->history = EINA_FALSE;
+ _plug->async_fetch = EINA_TRUE;
- if (evry->plugin_register(p1, EVRY_PLUGIN_SUBJECT, 0))
+ if (evry->plugin_register(_plug, EVRY_PLUGIN_SUBJECT, 0))
{
- Plugin_Config *pc = p1->config;
+ Plugin_Config *pc = _plug->config;
pc->view_mode = VIEW_MODE_LIST;
- pc->aggregate = EINA_FALSE;
pc->trigger = eina_stringshare_add("=");
+ pc->trigger_only = EINA_TRUE;
}
return EINA_TRUE;
_plugins_shutdown(void)
{
if (!evry_module->active) return;
- printf("calc shut down\n");
- EVRY_PLUGIN_FREE(p1);
+ ecore_event_handler_del(action_handler);
+ action_handler = NULL;
+
+ EVRY_PLUGIN_FREE(_plug);
evry_module->active = EINA_FALSE;
}
EAPI void *
e_modapi_init(E_Module *m)
-{
+{
evry_module = E_NEW(Evry_Module, 1);
evry_module->init = &_plugins_init;
evry_module->shutdown = &_plugins_shutdown;
evry_module->active = _plugins_init(evry);
e_module_delayed_set(m, 1);
-
+
return m;
}
e_modapi_shutdown(E_Module *m)
{
_plugins_shutdown();
-
+
EVRY_MODULE_UNREGISTER(evry_module);
E_FREE(evry_module);