forked from enlightenment/enlightenment
e17/evry: better macros for plugin creation
SVN revision: 62403
This commit is contained in:
parent
1ea8e5a0e1
commit
04d8b8d521
|
@ -209,6 +209,22 @@ struct _Evry_Event_Action_Performed
|
|||
evry->plugin_new(EVRY_PLUGIN(E_NEW(_base, 1)), _name, _(_name), _icon, _item_type, \
|
||||
_begin, _finish, _fetch, _free)
|
||||
|
||||
#define EVRY_PLUGIN_BASE(_name, _icon, _item_type, _begin, _finish, _fetch) \
|
||||
EVRY_PLUGIN_NEW(Evry_Plugin, _name, _icon, _item_type, _begin, _finish, _fetch, NULL)
|
||||
|
||||
#define EVRY_PLUGIN_INSTANCE(_p, _plugin) { \
|
||||
_p = E_NEW(Plugin, 1); \
|
||||
_p->base = *_plugin; \
|
||||
_p->base.items = NULL; \
|
||||
evry->item_new(&_p->base.base, (Evry_Plugin*)_p, \
|
||||
_plugin->base.label, NULL, \
|
||||
(Evry_Item_Free_Cb)_p->base.finish); \
|
||||
_p->base.base.detail = eina_stringshare_add(_plugin->base.detail); \
|
||||
_p->base.base.icon = eina_stringshare_add(_plugin->base.icon); \
|
||||
_p->base.base.context = eina_stringshare_add(_plugin->base.context); \
|
||||
_p->base.base.id = eina_stringshare_add(_plugin->base.id); \
|
||||
}
|
||||
|
||||
#define EVRY_PLUGIN_FREE(_p) if (_p) evry->plugin_free(EVRY_PLUGIN(_p))
|
||||
|
||||
#define EVRY_PLUGIN_ITEMS_FREE(_p) { \
|
||||
|
@ -231,19 +247,6 @@ struct _Evry_Event_Action_Performed
|
|||
|
||||
typedef void (*Evry_Item_Free_Cb) (Evry_Item *it);
|
||||
|
||||
#define EVRY_PLUGIN_INSTANCE(_p, _plugin) { \
|
||||
_p = E_NEW(Plugin, 1); \
|
||||
_p->base = *_plugin; \
|
||||
_p->base.items = NULL; \
|
||||
evry->item_new(&_p->base.base, (Evry_Plugin*)_p, \
|
||||
_plugin->base.label, NULL, \
|
||||
(Evry_Item_Free_Cb)_p->base.finish); \
|
||||
_p->base.base.detail = eina_stringshare_add(_plugin->base.detail); \
|
||||
_p->base.base.icon = eina_stringshare_add(_plugin->base.icon); \
|
||||
_p->base.base.context = eina_stringshare_add(_plugin->base.context); \
|
||||
_p->base.base.id = eina_stringshare_add(_plugin->base.id); \
|
||||
}
|
||||
|
||||
#define EVRY_PLUGIN_ITEMS_CLEAR(_p) { \
|
||||
Evry_Item *it; \
|
||||
EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, it) \
|
||||
|
|
|
@ -169,9 +169,8 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
int
|
||||
evry_plug_actions_init()
|
||||
{
|
||||
_plug = EVRY_PLUGIN_NEW(Plugin, N_("Actions"), NULL,
|
||||
EVRY_TYPE_ACTION,
|
||||
_begin, _finish, _fetch, NULL);
|
||||
_plug = EVRY_PLUGIN_BASE("Actions", NULL, EVRY_TYPE_ACTION,
|
||||
_begin, _finish, _fetch);
|
||||
|
||||
_plug->browse = &_browse;
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ evry_aggregator_new(Evry_Window *win, int type)
|
|||
{
|
||||
Evry_Plugin *p;
|
||||
|
||||
p = EVRY_PLUGIN_NEW(Plugin, N_("All"), NULL, 0, _begin, _finish, _fetch, _free);
|
||||
p = EVRY_PLUGIN_NEW(Plugin, "All", NULL, 0, _begin, _finish, _fetch, _free);
|
||||
|
||||
if (evry_plugin_register(p, type, -1))
|
||||
{
|
||||
|
|
|
@ -1023,35 +1023,31 @@ _plugins_init(const Evry_API *api)
|
|||
if (!evry->api_version_check(EVRY_API_VERSION))
|
||||
return EINA_FALSE;
|
||||
|
||||
p = EVRY_PLUGIN_NEW(Plugin, N_("Applications"),
|
||||
_module_icon, EVRY_TYPE_APP,
|
||||
_begin, _finish, _fetch, NULL);
|
||||
p = EVRY_PLUGIN_BASE("Applications", _module_icon, EVRY_TYPE_APP,
|
||||
_begin, _finish, _fetch);
|
||||
p->complete = &_complete;
|
||||
p->config_path = "extensions/everything-apps";
|
||||
evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 1);
|
||||
_plugins = eina_list_append(_plugins, p);
|
||||
|
||||
|
||||
p = EVRY_PLUGIN_NEW(Plugin, N_("Exebuf"),
|
||||
_module_icon, EVRY_TYPE_APP,
|
||||
_begin_exe, _finish_exe, _fetch_exe, NULL);
|
||||
p = EVRY_PLUGIN_BASE("Exebuf", _module_icon, EVRY_TYPE_APP,
|
||||
_begin_exe, _finish_exe, _fetch_exe);
|
||||
p->complete = &_complete;
|
||||
p->config_path = "extensions/everything-apps";
|
||||
_plugins = eina_list_append(_plugins, p);
|
||||
if (evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 3))
|
||||
p->config->min_query = 5;
|
||||
|
||||
p = EVRY_PLUGIN_NEW(Plugin, N_("Applications"),
|
||||
_module_icon, EVRY_TYPE_APP,
|
||||
_begin_mime, _finish, _fetch, NULL);
|
||||
p = EVRY_PLUGIN_BASE("Applications", _module_icon, EVRY_TYPE_APP,
|
||||
_begin_mime, _finish, _fetch);
|
||||
p->complete = &_complete;
|
||||
p->config_path = "extensions/everything-apps";
|
||||
evry->plugin_register(p, EVRY_PLUGIN_OBJECT, 1);
|
||||
_plugins = eina_list_append(_plugins, p);
|
||||
|
||||
p = EVRY_PLUGIN_NEW(Plugin, N_("Open With..."),
|
||||
_module_icon, EVRY_TYPE_APP,
|
||||
_begin_mime, _finish_mime, _fetch_mime, NULL);
|
||||
p = EVRY_PLUGIN_BASE("Open With...", _module_icon, EVRY_TYPE_APP,
|
||||
_begin_mime, _finish_mime, _fetch_mime);
|
||||
p->config_path = "extensions/everything-apps";
|
||||
evry->plugin_register(p, EVRY_PLUGIN_ACTION, 1);
|
||||
_plugins = eina_list_append(_plugins, p);
|
||||
|
|
|
@ -31,7 +31,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *item __UNUSED__)
|
|||
{
|
||||
Evry_Item *it;
|
||||
Plugin *p;
|
||||
|
||||
|
||||
if (active)
|
||||
return NULL;
|
||||
|
||||
|
@ -54,7 +54,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *item __UNUSED__)
|
|||
it->context = eina_stringshare_ref(p->base.name);
|
||||
cur_item = it;
|
||||
active = EINA_TRUE;
|
||||
|
||||
|
||||
return EVRY_PLUGIN(p);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ _run_bc(Plugin *p)
|
|||
static void
|
||||
_finish(Evry_Plugin *plugin)
|
||||
{
|
||||
GET_PLUGIN(p, plugin);
|
||||
GET_PLUGIN(p, plugin);
|
||||
Ecore_Event_Handler *h;
|
||||
Evry_Item *it;
|
||||
int items = 0;
|
||||
|
@ -158,7 +158,7 @@ static int
|
|||
_fetch(Evry_Plugin *plugin, const char *input)
|
||||
{
|
||||
GET_PLUGIN(p, plugin);
|
||||
|
||||
|
||||
char buf[1024];
|
||||
|
||||
if (!input) return 0;
|
||||
|
@ -214,7 +214,7 @@ _cb_error(void *data, int type __UNUSED__, void *event)
|
|||
{
|
||||
Ecore_Exe_Event_Data *ev = event;
|
||||
Evry_Plugin *p = data;
|
||||
|
||||
|
||||
if (ev->exe != exe)
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
|
||||
|
@ -248,10 +248,8 @@ _plugins_init(const Evry_API *_api)
|
|||
action_handler = evry->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, _finish, _fetch, NULL);
|
||||
_plug = EVRY_PLUGIN_BASE("Calculator", _module_icon, EVRY_TYPE_TEXT,
|
||||
_begin, _finish, _fetch);
|
||||
|
||||
_plug->history = EINA_FALSE;
|
||||
_plug->async_fetch = EINA_TRUE;
|
||||
|
|
|
@ -139,9 +139,8 @@ _add_plugin(const char *name)
|
|||
char path[4096];
|
||||
char title[4096];
|
||||
|
||||
p = EVRY_PLUGIN_NEW(Evry_Plugin, N_(name),
|
||||
_module_icon, COLLECTION_PLUGIN,
|
||||
_begin, _finish, _fetch, NULL);
|
||||
p = EVRY_PLUGIN_BASE(name, _module_icon, COLLECTION_PLUGIN,
|
||||
_begin, _finish, _fetch);
|
||||
p->browse = &_browse;
|
||||
|
||||
snprintf(path, sizeof(path), "launcher/everything-%s", p->name);
|
||||
|
|
|
@ -1355,51 +1355,55 @@ _plugins_init(const Evry_API *api)
|
|||
|
||||
#undef ACTION_NEW
|
||||
|
||||
#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, _browse);
|
||||
p = EVRY_PLUGIN_BASE("Files", _module_icon, EVRY_TYPE_FILE,
|
||||
_begin, _finish, _fetch);
|
||||
p->input_type = EVRY_TYPE_FILE;
|
||||
p->cb_key_down = &_cb_key_down;
|
||||
p->browse = &_browse;
|
||||
p->config_path = "extensions/everything-files";
|
||||
p->actions = eina_list_append(p->actions, act_sort_date);
|
||||
p->actions = eina_list_append(p->actions, act_sort_name);
|
||||
_plugins = eina_list_append(_plugins, p);
|
||||
|
||||
if (evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 2))
|
||||
p->config->min_query = 1;
|
||||
|
||||
|
||||
PLUGIN_NEW(N_("Files"), _module_icon, _begin, _finish, _fetch, _browse);
|
||||
p = EVRY_PLUGIN_BASE("Files", _module_icon, EVRY_TYPE_FILE,
|
||||
_begin, _finish, _fetch);
|
||||
p->cb_key_down = &_cb_key_down;
|
||||
p->browse = &_browse;
|
||||
p->config_path = "extensions/everything-files";
|
||||
p->actions = eina_list_append(p->actions, act_sort_date);
|
||||
p->actions = eina_list_append(p->actions, act_sort_name);
|
||||
_plugins = eina_list_append(_plugins, p);
|
||||
evry->plugin_register(p, EVRY_PLUGIN_OBJECT, 2);
|
||||
|
||||
if (_conf->show_recent || _conf->search_recent)
|
||||
if (!_conf->show_recent && !_conf->search_recent)
|
||||
return EINA_TRUE;
|
||||
|
||||
p = EVRY_PLUGIN_BASE("Recent Files", _module_icon, EVRY_TYPE_FILE,
|
||||
_recentf_begin, _finish, _recentf_fetch);
|
||||
p->browse = &_recentf_browse;
|
||||
p->config_path = "extensions/everything-files";
|
||||
|
||||
if (evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 3))
|
||||
{
|
||||
PLUGIN_NEW(N_("Recent Files"), _module_icon,
|
||||
_recentf_begin, _finish, _recentf_fetch, _recentf_browse);
|
||||
|
||||
if (evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 3))
|
||||
{
|
||||
p->config->top_level = EINA_FALSE;
|
||||
p->config->min_query = 3;
|
||||
}
|
||||
|
||||
PLUGIN_NEW(N_("Recent Files"), _module_icon,
|
||||
_recentf_begin, _finish, _recentf_fetch, _recentf_browse);
|
||||
|
||||
if (evry->plugin_register(p, EVRY_PLUGIN_OBJECT, 3))
|
||||
{
|
||||
p->config->top_level = EINA_FALSE;
|
||||
p->config->min_query = 3;
|
||||
}
|
||||
p->config->top_level = EINA_FALSE;
|
||||
p->config->min_query = 3;
|
||||
}
|
||||
|
||||
#undef PLUGIN_NEW
|
||||
p = EVRY_PLUGIN_BASE("Recent Files", _module_icon, EVRY_TYPE_FILE,
|
||||
_recentf_begin, _finish, _recentf_fetch);
|
||||
p->browse = &_recentf_browse;
|
||||
p->config_path = "extensions/everything-files";
|
||||
|
||||
if (evry->plugin_register(p, EVRY_PLUGIN_OBJECT, 3))
|
||||
{
|
||||
p->config->top_level = EINA_FALSE;
|
||||
p->config->min_query = 3;
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
@ -1627,7 +1631,7 @@ static void
|
|||
_conf_shutdown(void)
|
||||
{
|
||||
e_configure_registry_item_del("launcher/everything-files");
|
||||
|
||||
|
||||
E_FREE(_conf);
|
||||
E_CONFIG_DD_FREE(conf_edd);
|
||||
}
|
||||
|
|
|
@ -183,9 +183,7 @@ _plugins_init(const Evry_API *_api)
|
|||
|
||||
E_SETTINGS = evry->type_register("E_SETTINGS");
|
||||
|
||||
p = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Settings"),
|
||||
"configure", E_SETTINGS,
|
||||
_begin, _finish, _fetch, NULL);
|
||||
p = EVRY_PLUGIN_BASE("Settings", "configure", E_SETTINGS, _begin, _finish, _fetch);
|
||||
p->browse = &_browse;
|
||||
evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 10);
|
||||
|
||||
|
|
|
@ -60,13 +60,11 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
Eina_Bool
|
||||
evry_plug_text_init(void)
|
||||
{
|
||||
p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Text"),
|
||||
"accessories-text-editor", EVRY_TYPE_TEXT,
|
||||
_begin, _finish, _fetch, NULL);
|
||||
p1 = EVRY_PLUGIN_BASE("Text", "accessories-text-editor",
|
||||
EVRY_TYPE_TEXT, _begin, _finish, _fetch);
|
||||
|
||||
p2 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Text"),
|
||||
"accessories-text-editor", EVRY_TYPE_TEXT,
|
||||
_begin, _finish, _fetch, NULL);
|
||||
p2 = EVRY_PLUGIN_BASE("Text", "accessories-text-editor",
|
||||
EVRY_TYPE_TEXT, _begin, _finish, _fetch);
|
||||
|
||||
if (evry_plugin_register(p1, EVRY_PLUGIN_OBJECT, 999))
|
||||
{
|
||||
|
|
|
@ -411,10 +411,8 @@ _plugins_init(const Evry_API *_api)
|
|||
if (!evry->api_version_check(EVRY_API_VERSION))
|
||||
return EINA_FALSE;
|
||||
|
||||
_plug = EVRY_PLUGIN_NEW(Plugin, N_("Windows"),
|
||||
"preferences-system-windows",
|
||||
EVRY_TYPE_BORDER,
|
||||
_begin, _finish, _fetch, NULL);
|
||||
_plug = EVRY_PLUGIN_BASE("Windows", "preferences-system-windows",
|
||||
EVRY_TYPE_BORDER, _begin, _finish, _fetch);
|
||||
_plug->transient = EINA_TRUE;
|
||||
evry->plugin_register(_plug, EVRY_PLUGIN_SUBJECT, 2);
|
||||
|
||||
|
|
Loading…
Reference in New Issue