e17/evry:

- started to update docs
- remove base plugins' free_cb which was used for one special case only


SVN revision: 65774
This commit is contained in:
Hannes Janetzek 2011-12-01 10:56:55 +00:00
parent d6ea3ac561
commit d81bad581a
5 changed files with 75 additions and 84 deletions

View File

@ -260,8 +260,7 @@ Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, const char *la
Evry_Type item_type,
Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item),
void (*cleanup) (Evry_Plugin *p),
int (*fetch) (Evry_Plugin *p, const char *input),
void (*free) (Evry_Plugin *p));
int (*fetch) (Evry_Plugin *p, const char *input));
void evry_plugin_free(Evry_Plugin *p);
@ -358,11 +357,11 @@ EAPI E_Config_Dialog *evry_config_dialog(E_Container *con, const char *params);
EAPI E_Config_Dialog *evry_collection_conf_dialog(E_Container *con, const char *params);
EAPI extern E_Module_Api e_modapi;
//#define CHECK_REFS 1
//#define PRINT_REFS 1
//#define CHECK_TIME 1
//#undef DBG
//#define DBG(...) ERR(__VA_ARGS__)
/* #define CHECK_REFS 1
* #define PRINT_REFS 1
* #define CHECK_TIME 1
* #undef DBG
* #define DBG(...) ERR(__VA_ARGS__) */
#ifdef CHECK_REFS
extern Eina_List *_refd;

View File

@ -3,7 +3,7 @@
#include "evry_types.h"
#define EVRY_API_VERSION 29
#define EVRY_API_VERSION 30
#define EVRY_ACTION_OTHER 0
#define EVRY_ACTION_FINISHED 1
@ -70,7 +70,7 @@ struct _Evry_API
void (*item_free)(Evry_Item *it);
void (*item_ref)(Evry_Item *it);
/* send EVRY_EVENT_ITEM_CHANGED event */
/* sends EVRY_EVENT_ITEM_CHANGED event */
void (*item_changed)(Evry_Item *it, int change_icon, int change_selected);
Evry_Plugin *(*plugin_new)(Evry_Plugin *base, const char *name,
@ -78,8 +78,7 @@ struct _Evry_API
Evry_Type item_type,
Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item),
void (*cleanup) (Evry_Plugin *p),
int (*fetch) (Evry_Plugin *p, const char *input),
void (*free) (Evry_Plugin *p));
int (*fetch) (Evry_Plugin *p, const char *input));
void (*plugin_free)(Evry_Plugin *p);
/* when a new plugin config was created return val is 1. in this
@ -162,6 +161,8 @@ struct _Evry_Event_Action_Performed
#define GET_ITEM(_it, _any) Evry_Item *_it = (Evry_Item *) _any
/*** Evry_Item macros ***/
/* */
#define EVRY_ITEM_NEW(_base, _plugin, _label, _icon_get, _free) \
(_base *) evry->item_new(EVRY_ITEM(E_NEW(_base, 1)), \
EVRY_PLUGIN(_plugin), \
@ -177,24 +178,16 @@ struct _Evry_Event_Action_Performed
((Evry_Item *)_item)->data
#define EVRY_ITEM_DETAIL_SET(_it, _detail) \
if (EVRY_ITEM(_it)->detail) \
eina_stringshare_del(EVRY_ITEM(_it)->detail); \
EVRY_ITEM(_it)->detail = eina_stringshare_add(_detail);
eina_stringshare_replace(&(EVRY_ITEM(_it)->detail), _detail);
#define EVRY_ITEM_LABEL_SET(_it, _label) \
if (EVRY_ITEM(_it)->label) \
eina_stringshare_del(EVRY_ITEM(_it)->label); \
EVRY_ITEM(_it)->label = eina_stringshare_add(_label);
eina_stringshare_replace(&(EVRY_ITEM(_it)->label), _label);
#define EVRY_ITEM_CONTEXT_SET(_it, _context) \
if (EVRY_ITEM(_it)->context) \
eina_stringshare_del(EVRY_ITEM(_it)->context); \
EVRY_ITEM(_it)->context = eina_stringshare_add(_context);
eina_stringshare_replace(&(EVRY_ITEM(_it)->context), _context);
#define EVRY_ITEM_ICON_SET(_it, _icon) \
if (EVRY_ITEM(_it)->icon) \
eina_stringshare_del(EVRY_ITEM(_it)->icon); \
EVRY_ITEM(_it)->icon = eina_stringshare_add(_icon);
eina_stringshare_replace(&(EVRY_ITEM(_it)->icon), _icon);
#define CHECK_TYPE(_item, _type) \
(((Evry_Item *)_item)->type == _type)
@ -205,13 +198,13 @@ struct _Evry_Event_Action_Performed
#define IS_BROWSEABLE(_item) ((Evry_Item *)_item)->browseable
/*** Evry_Plugin macros ***/
#define EVRY_PLUGIN_NEW(_base, _name, _icon, _item_type, _begin, _finish, _fetch, _free) \
evry->plugin_new(EVRY_PLUGIN(E_NEW(_base, 1)), _name, _(_name), _icon, _item_type, \
_begin, _finish, _fetch, _free)
/* creates a Evry_Plugin to be registered with evry */
#define EVRY_PLUGIN_BASE(_name, _icon, _item_type, _begin, _finish, _fetch) \
EVRY_PLUGIN_NEW(Evry_Plugin, _name, _icon, _item_type, _begin, _finish, _fetch, NULL)
evry->plugin_new(EVRY_PLUGIN(E_NEW(Evry_Plugin, 1)), _name, _(_name), _icon, _item_type, \
_begin, _finish, _fetch)
/* creates the plugin instance '_p' for the Evry_Plugin '_plugin' */
#define EVRY_PLUGIN_INSTANCE(_p, _plugin) { \
_p = E_NEW(Plugin, 1); \
_p->base = *_plugin; \
@ -219,32 +212,43 @@ struct _Evry_Event_Action_Performed
_p->base.base.ref = 1; \
_p->base.base.plugin = (Evry_Plugin*)_p; \
_p->base.base.free = (Evry_Item_Free_Cb)_p->base.finish; \
_p->base.base.label = eina_stringshare_add(_plugin->base.label); \
_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); \
_p->base.base.label = eina_stringshare_ref(_plugin->base.label); \
_p->base.base.detail = eina_stringshare_ref(_plugin->base.detail); \
_p->base.base.icon = eina_stringshare_ref(_plugin->base.icon); \
_p->base.base.context = eina_stringshare_ref(_plugin->base.context); \
_p->base.base.id = eina_stringshare_ref(_plugin->base.id); \
}
/* free the plugin instance '_p' */
#define EVRY_PLUGIN_FREE(_p) if (_p) evry->plugin_free(EVRY_PLUGIN(_p))
/* call free on all items provided by plugin instance '_p' */
#define EVRY_PLUGIN_ITEMS_FREE(_p) { \
Evry_Item *it; \
EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, it) \
evry->item_free(it); }
/* append '_item' to list of items provided by plugin instance '_p' */
#define EVRY_PLUGIN_ITEM_APPEND(_p, _item) \
EVRY_PLUGIN(_p)->items = eina_list_append(EVRY_PLUGIN(_p)->items, EVRY_ITEM(_item))
/* */
#define EVRY_PLUGIN_ITEMS_ADD(_plugin, _items, _input, _match_detail, _set_usage) \
evry->util_plugin_items_add(EVRY_PLUGIN(_plugin), _items, _input, _match_detail, _set_usage)
#define EVRY_PLUGIN_UPDATE(_p, _action) \
/* call EVRY_PLUGIN_UPDATE when the list of items provided by plugin '_p' has
* changed. e.g. for files plugin when files were created or deleted
* while evry is active.
* '_action' can be EVRY_UPDATE_ADD (new items were added),
* EVRY_UPDATE_CLEAR (plugin does not provide any items) or
* EVRY_UPDATE_REFRESH (items have changed) */
#define EVRY_PLUGIN_UPDATE(_p, _action) \
if (_p) evry->plugin_update(EVRY_PLUGIN(_p), _action)
#define EVRY_PLUGIN_ITEMS_SORT(_p, _sortcb) \
EVRY_PLUGIN(_p)->items = eina_list_sort \
(EVRY_PLUGIN(_p)->items, eina_list_count(EVRY_PLUGIN(_p)->items), _sortcb)
#define EVRY_PLUGIN_ITEM_APPEND(_p, _item) \
EVRY_PLUGIN(_p)->items = eina_list_append(EVRY_PLUGIN(_p)->items, EVRY_ITEM(_item))
#define EVRY_PLUGIN_MIN_QUERY(_p, _input) \
if (!(EVRY_PLUGIN(_p)->config->min_query) || \
@ -263,6 +267,7 @@ struct _Evry_Event_Action_Performed
#define EVRY_ACTION_FREE(_act) if (_act) evry->action_free(EVRY_ACTN(_act))
/* register */
#define EVRY_MODULE_NEW(_module, _evry, _init, _shutdown) \
{ \
_module = E_NEW(Evry_Module, 1); \

View File

@ -2,8 +2,8 @@
//TODO min input for items not in history
#define MAX_ITEMS 50
#define MAX_PLUGIN 15
#define MAX_ITEMS 100
#define MAX_PLUGIN 25
typedef struct _Plugin Plugin;
@ -285,6 +285,8 @@ _finish(Evry_Plugin *plugin)
EVRY_PLUGIN_ITEMS_FREE(p);
evry_item_free(p->warning);
E_FREE(p);
}
@ -296,38 +298,24 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it __UNUSED__)
GET_PLUGIN(base, plugin);
EVRY_PLUGIN_INSTANCE(p, plugin);
p->warning = base->warning;
p->warning = evry_item_new(NULL, EVRY_PLUGIN(p), N_("No plugins loaded"), NULL, NULL);
p->warning->type = EVRY_TYPE_NONE;
return EVRY_PLUGIN(p);
}
static void
_free(Evry_Plugin *plugin)
{
GET_PLUGIN(p, plugin);
evry_item_free(p->warning);
free(p);
}
Evry_Plugin *
evry_aggregator_new(int type)
{
Evry_Plugin *p;
p = EVRY_PLUGIN_NEW(Plugin, "All", NULL, 0, _begin, _finish, _fetch, _free);
p = EVRY_PLUGIN_BASE("All", NULL, 0, _begin, _finish, _fetch);
if (evry_plugin_register(p, type, -1))
{
p->config->view_mode = VIEW_MODE_THUMB;
}
GET_PLUGIN(pa, p);
pa->warning = evry_item_new(NULL, p, N_("No plugins loaded"), NULL, NULL);
pa->warning->type = EVRY_TYPE_NONE;
return p;
}

View File

@ -37,10 +37,7 @@ _evry_plugin_free(Evry_Item *it)
if (p->config) p->config->plugin = NULL;
if (p->name) eina_stringshare_del(p->name);
if (p->free)
p->free(p);
else
E_FREE(p);
E_FREE(p);
}
Evry_Plugin *
@ -48,8 +45,7 @@ evry_plugin_new(Evry_Plugin *base, const char *name, const char *label,
const char *icon, Evry_Type item_type,
Evry_Plugin *(*begin)(Evry_Plugin * p, const Evry_Item * item),
void (*finish)(Evry_Plugin *p),
int (*fetch)(Evry_Plugin *p, const char *input),
void (*cb_free)(Evry_Plugin *p))
int (*fetch)(Evry_Plugin *p, const char *input))
{
Evry_Plugin *p;
Evry_Item *it;
@ -76,8 +72,6 @@ evry_plugin_new(Evry_Plugin *base, const char *name, const char *label,
p->async_fetch = EINA_FALSE;
p->history = EINA_TRUE;
p->free = cb_free;
return p;
}

View File

@ -145,26 +145,34 @@ struct _Evry_Plugin
/* identifier */
const char *name;
/* list of items visible for everything after fetch */
/* list of items visible to everything */
Eina_List *items;
/* required: get candidates matching string, fill 'items' list */
/* required:
Called each time Evry updates the state to which this plugin
instance belongs to, i.e. when the user typed something.
Query for candidates matching string.
return positive when items were found, zero otherwise. */
int (*fetch) (Evry_Plugin *p, const char *input);
/* required: run when state is removed in which this plugin is
active. free 'items' here */
void (*finish) (Evry_Plugin *p);
/* plugin is added to the list of current plugins and
queried for results when not returning NULL. The previous
selectors item is passed, i.e. a plugin registered as action
receives the subject, a plugin registered as object receives the
action item. here you can check wheter the plugin can be queried,
for given context (provided by item) */
/* required:
Called when an Evry_State is created in which this plugin could
be querid. Return a new instance of base plugin 'p'. The plugin
instance is added to the list of current plugins and queried for
results when not returning NULL.
The previous selectors 'item' is passed, i.e. a plugin registered
as action receives the subject, a plugin registered as object
receives the action item. here you can check wheter the plugin
should be queried in given context (provided by item) */
Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item);
/* optional: provide a list of subitems of 'item'. this function
must return a new instance which must be freed in 'finish' */
/* required:
Called when the Evry_State to which the plugin instance belongs
to is destroyed.
Free instance returned by 'begin' */
void (*finish) (Evry_Plugin *p);
/* optional: provide a list of subitems to 'item'. */
Evry_Plugin *(*browse) (Evry_Plugin *p, const Evry_Item *item);
/* optional: try to complete current item:
@ -173,17 +181,13 @@ struct _Evry_Plugin
int (*complete) (Evry_Plugin *p, const Evry_Item *item, char **input);
/* optional: handle key events: return positive when key was
handled */
handled by plugin */
int (*cb_key_down) (Evry_Plugin *p, const Ecore_Event_Key *ev);
/* optional: use this when begin returned a new instance or you
have extended plugin struct */
void (*free) (Evry_Plugin *p);
/* optiona: actions only used with this plugin, dont require */
/* optional: list of Evry_Action that are specific for items of this plugin */
Eina_List *actions;
/* optional: set type which the plugin can handle in begin */
/* optional: set type which the plugin can handle in 'begin' */
Evry_Type input_type;
/* optional: whether the plugin uses evry_async_update to add new items */
@ -202,9 +206,10 @@ struct _Evry_Plugin
'configure' button in everything config */
const char *config_path;
/* set theme file to fetch icons from */
/* optional: set theme file to fetch icons from */
const char *theme_path;
/* optional: provide a view that is specific for this plugins' items */
Evry_View *view;
};