allow only one instance of calc and aspell to be started

delay scan executables until input > min_query



SVN revision: 49454
This commit is contained in:
Hannes Janetzek 2010-06-04 19:40:14 +00:00
parent c197c02360
commit 34bb103433
3 changed files with 38 additions and 18 deletions

View File

@ -287,6 +287,9 @@ _fetch_exe(Evry_Plugin *plugin, const char *input)
if (input)
{
if (!(exe_list) && !(exe_scan_idler))
_scan_executables();
if (_add_executables(p, input))
{
GET_ITEM(it, p->command);
@ -325,8 +328,6 @@ _begin_exe(Evry_Plugin *plugin, const Evry_Item *item)
p->added = eina_hash_string_small_new(_hash_free);
_scan_executables();
app = EVRY_ITEM_NEW(Evry_Item_App, p, NULL, _icon_get, _item_free);
EVRY_ACTN(app)->action = &_exec_open_file_action;
EVRY_ACTN(app)->remember_context = EINA_TRUE;

View File

@ -25,6 +25,8 @@ struct _Plugin
const char *lang;
const char *input;
Eina_Bool is_first;
unsigned int instances;
};
struct _Module_Config
@ -256,19 +258,16 @@ _cb_del(void *data, int type __UNUSED__, void *event)
return 1;
}
static int
static Evry_Plugin *
_begin(Evry_Plugin *plugin, const Evry_Item *it __UNUSED__)
{
GET_PLUGIN(p, plugin);
p->instances++;
if (!p->handler.data)
p->handler.data = ecore_event_handler_add
(ECORE_EXE_EVENT_DATA, _cb_data, p);
if (!p->handler.del)
p->handler.del = ecore_event_handler_add
(ECORE_EXE_EVENT_DEL, _cb_del, p);
return _exe_restart(p);
if (p->instances > 1)
return NULL;
return EVRY_PLUGIN(p);
}
static int
@ -286,7 +285,18 @@ _fetch(Evry_Plugin *plugin, const char *input)
return 0;
}
if (!p->handler.data && !_begin(plugin, NULL)) return 0;
if (!p->handler.data)
{
if (!p->handler.data)
p->handler.data = ecore_event_handler_add
(ECORE_EXE_EVENT_DATA, _cb_data, p);
if (!p->handler.del)
p->handler.del = ecore_event_handler_add
(ECORE_EXE_EVENT_DEL, _cb_del, p);
if (!_exe_restart(p))
return 0;
}
len = sizeof(LANG_MODIFIER) - 1;
if (strncmp(input, LANG_MODIFIER, len) == 0)
@ -347,12 +357,17 @@ _fetch(Evry_Plugin *plugin, const char *input)
}
static void
_cleanup(Evry_Plugin *plugin)
_finish(Evry_Plugin *plugin)
{
GET_PLUGIN(p, plugin);
EVRY_PLUGIN_ITEMS_FREE(p);
p->instances--;
if (p->instances > 0)
return;
if (p->handler.data)
{
ecore_event_handler_del(p->handler.data);
@ -388,7 +403,7 @@ _plugins_init(const Evry_API *_api)
_plug = EVRY_PLUGIN_NEW(Plugin, N_("Spell Checker"),
_module_icon,
EVRY_TYPE_TEXT,
NULL, _cleanup, _fetch, NULL);
_begin, _finish, _fetch, NULL);
_plug->config_path = _config_path;
_plug->history = EINA_FALSE;
_plug->async_fetch = EINA_TRUE;

View File

@ -20,7 +20,7 @@ static Ecore_Exe *exe = NULL;
static Eina_List *history = NULL;
static Eina_List *handlers = NULL;
static int error = 0;
static Eina_Bool active = EINA_FALSE;
static char _module_icon[] = "accessories-calculator";
static Evry_Plugin *
@ -28,6 +28,9 @@ _begin(Evry_Plugin *p, const Evry_Item *item __UNUSED__)
{
Evry_Item *it;
if (active)
return NULL;
if (history)
{
const char *result;
@ -45,6 +48,7 @@ _begin(Evry_Plugin *p, const Evry_Item *item __UNUSED__)
it->context = eina_stringshare_ref(p->name);
p->items = eina_list_prepend(p->items, it);
active = EINA_TRUE;
return p;
}
@ -71,9 +75,8 @@ _run_bc(Evry_Plugin *p)
return !!exe;
}
static void
_cleanup(Evry_Plugin *p)
_finish(Evry_Plugin *p)
{
Ecore_Event_Handler *h;
Evry_Item *it;
@ -102,6 +105,7 @@ _cleanup(Evry_Plugin *p)
ecore_exe_free(exe);
exe = NULL;
}
active = EINA_FALSE;
}
static int
@ -237,7 +241,7 @@ _plugins_init(const Evry_API *_api)
_plug = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Calculator"),
_module_icon,
EVRY_TYPE_TEXT,
_begin, _cleanup, _fetch, NULL);
_begin, _finish, _fetch, NULL);
_plug->history = EINA_FALSE;
_plug->async_fetch = EINA_TRUE;