4 #include "evry_types.h"
6 #define EVRY_API_VERSION 26
8 #define EVRY_ACTION_OTHER 0
9 #define EVRY_ACTION_FINISHED 1
10 #define EVRY_ACTION_CONTINUE 2
12 #define EVRY_UPDATE_ADD 0
13 #define EVRY_UPDATE_CLEAR 1
14 #define EVRY_UPDATE_REFRESH 2
16 #define EVRY_COMPLETE_NONE 0
17 #define EVRY_COMPLETE_INPUT 1
18 #define EVRY_COMPLETE_BROWSE 2
20 #define VIEW_MODE_NONE -1
21 #define VIEW_MODE_LIST 0
22 #define VIEW_MODE_DETAIL 1
23 #define VIEW_MODE_THUMB 2
25 #define EVRY_PLUGIN_SUBJECT 0
26 #define EVRY_PLUGIN_ACTION 1
27 #define EVRY_PLUGIN_OBJECT 2
29 #define EVRY_TYPE_NONE 0
30 #define EVRY_TYPE_FILE 1
31 #define EVRY_TYPE_DIR 2
32 #define EVRY_TYPE_APP 3
33 #define EVRY_TYPE_ACTION 4
34 #define EVRY_TYPE_PLUGIN 5
35 #define EVRY_TYPE_BORDER 6
36 #define EVRY_TYPE_TEXT 7
37 #define NUM_EVRY_TYPES 8
39 #define EVRY_EVENT_ITEM_SELECTED 0
40 #define EVRY_EVENT_ITEM_CHANGED 1
41 #define EVRY_EVENT_ITEMS_UPDATE 2
42 #define EVRY_EVENT_ACTION_PERFORMED 3
43 #define EVRY_EVENT_PLUGIN_SELECTED 4
44 #define NUM_EVRY_EVENTS 5
46 typedef struct _Evry_API Evry_API;
47 typedef struct _Evry_Module Evry_Module;
49 typedef struct _Evry_Event_Item_Changed Evry_Event_Item_Changed;
50 typedef struct _Evry_Event_Item_Selected Evry_Event_Item_Selected;
51 typedef struct _Evry_Event_Action_Performed Evry_Event_Action_Performed;
58 int (*init)(const Evry_API *api);
59 void (*shutdown)(void);
64 int (*api_version_check)(int version);
66 Evry_Item *(*item_new)(Evry_Item *base, Evry_Plugin *p, const char *label,
67 Evas_Object *(*icon_get) (Evry_Item *it, Evas *e),
68 void (*cb_free) (Evry_Item *item));
70 void (*item_free)(Evry_Item *it);
71 void (*item_ref)(Evry_Item *it);
72 /* send EVRY_EVENT_ITEM_CHANGED event */
73 void (*item_changed)(Evry_Item *it, int change_icon, int change_selected);
75 Evry_Plugin *(*plugin_new)(Evry_Plugin *base, const char *name,
76 const char *label, const char *icon,
78 Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item),
79 void (*cleanup) (Evry_Plugin *p),
80 int (*fetch) (Evry_Plugin *p, const char *input),
81 void (*free) (Evry_Plugin *p));
83 void (*plugin_free)(Evry_Plugin *p);
84 /* when a new plugin config was created return val is 1. in this
85 case you can set defaults of p->config */
86 int (*plugin_register)(Evry_Plugin *p, int type, int priority);
87 void (*plugin_unregister)(Evry_Plugin *p);
88 void (*plugin_update)(Evry_Plugin *plugin, int state);
89 Evry_Plugin *(*plugin_find)(const char *name);
91 Evry_Action *(*action_new)(const char *name, const char *label,
92 Evry_Type type1, Evry_Type type2,
94 int (*action) (Evry_Action *act),
95 int (*check_item) (Evry_Action *act, const Evry_Item *it));
97 void (*action_free)(Evry_Action *act);
98 void (*action_register)(Evry_Action *act, int priority);
99 void (*action_unregister)(Evry_Action *act);
100 Evry_Action *(*action_find)(const char *name);
101 Evry_Type (*type_register)(const char *type);
104 Evas_Object *(*icon_mime_get)(const char *mime, Evas *e);
105 Evas_Object *(*icon_theme_get)(const char *icon, Evas *e);
106 int (*fuzzy_match)(const char *str, const char *match);
107 int (*util_exec_app)(const Evry_Item *it_app, const Evry_Item *it_file);
108 char *(*util_url_escape)(const char *string, int inlength);
109 char *(*util_url_unescape)(const char *string, int length);
110 void (*util_file_detail_set)(Evry_Item_File *file);
111 int (*util_plugin_items_add)(Evry_Plugin *p, Eina_List *items, const char *input, int match_detail, int set_usage);
112 char *(*util_md5_sum)(const char *str);
113 Evas_Object *(*util_icon_get)(Evry_Item *it, Evas *e);
114 int (*items_sort_func)(const void *data1, const void *data2);
116 const char *(*file_path_get)(Evry_Item_File *file);
117 const char *(*file_url_get)(Evry_Item_File *file);
119 History_Item *(*history_item_add)(Evry_Item *it, const char *ctxt, const char *input);
120 History_Types *(*history_types_get)(Evry_Type type);
121 int (*history_item_usage_set)(Evry_Item *it, const char *input, const char *ctxt);
123 Ecore_Event_Handler *(*event_handler_add)(int type, Eina_Bool (*func) (void *data, int type, void *event), const void *data);
128 struct _Evry_Event_Item_Changed
131 int changed_selection;
135 struct _Evry_Event_Item_Selected
140 struct _Evry_Event_Action_Performed
143 const Evry_Item *it1;
144 const Evry_Item *it2;
148 /*** cast default types ***/
149 #define EVRY_ITEM(_item) ((Evry_Item *)_item)
150 #define EVRY_ACTN(_item) ((Evry_Action *) _item)
151 #define EVRY_PLUGIN(_plugin) ((Evry_Plugin *) _plugin)
152 #define EVRY_VIEW(_view) ((Evry_View *) _view)
153 #define EVRY_FILE(_it) ((Evry_Item_File *) _it)
155 #define GET_APP(_app, _item) Evry_Item_App *_app = (Evry_Item_App *) _item
156 #define GET_CMD(_app, _item) Evry_Item_App *_app = (Evry_Item_App *) _item
157 #define GET_FILE(_file, _item) Evry_Item_File *_file = (Evry_Item_File *) _item
158 #define GET_EVRY_PLUGIN(_p, _plugin) Evry_Plugin *_p = (Evry_Plugin*) _plugin
159 #define GET_PLUGIN(_p, _plugin) Plugin *_p = (Plugin*) _plugin
160 #define GET_VIEW(_v, _view) View *_v = (View*) _view
161 #define GET_ACTION(_act, _item) Evry_Action *_act = (Evry_Action *) _item
162 #define GET_ITEM(_it, _any) Evry_Item *_it = (Evry_Item *) _any
164 /*** Evry_Item macros ***/
166 #define EVRY_ITEM_NEW(_base, _plugin, _label, _icon_get, _free) \
167 (_base *) evry->item_new(EVRY_ITEM(E_NEW(_base, 1)), \
168 EVRY_PLUGIN(_plugin), \
169 _label, _icon_get, _free)
171 #define EVRY_ITEM_FREE(_item) evry->item_free((Evry_Item *)_item)
172 #define EVRY_ITEM_REF(_item) evry->item_ref((Evry_Item *)_item)
175 #define EVRY_ITEM_DATA_INT_SET(_item, _data) \
176 ((Evry_Item *)_item)->data = (void*)(long) _data
178 #define EVRY_ITEM_DATA_INT_GET(_item) (long) \
179 ((Evry_Item *)_item)->data
181 #define EVRY_ITEM_DETAIL_SET(_it, _detail) \
182 if (EVRY_ITEM(_it)->detail) \
183 eina_stringshare_del(EVRY_ITEM(_it)->detail); \
184 EVRY_ITEM(_it)->detail = eina_stringshare_add(_detail);
186 #define EVRY_ITEM_LABEL_SET(_it, _label) \
187 if (EVRY_ITEM(_it)->label) \
188 eina_stringshare_del(EVRY_ITEM(_it)->label); \
189 EVRY_ITEM(_it)->label = eina_stringshare_add(_label);
191 #define EVRY_ITEM_CONTEXT_SET(_it, _context) \
192 if (EVRY_ITEM(_it)->context) \
193 eina_stringshare_del(EVRY_ITEM(_it)->context); \
194 EVRY_ITEM(_it)->context = eina_stringshare_add(_context);
196 #define EVRY_ITEM_ICON_SET(_it, _icon) \
197 if (EVRY_ITEM(_it)->icon) \
198 eina_stringshare_del(EVRY_ITEM(_it)->icon); \
199 EVRY_ITEM(_it)->icon = eina_stringshare_add(_icon);
201 #define CHECK_TYPE(_item, _type) \
202 (((Evry_Item *)_item)->type && ((Evry_Item *)_item)->type == _type)
204 #define CHECK_SUBTYPE(_item, _type) \
205 (((Evry_Item *)_item)->subtype && ((Evry_Item *)_item)->subtype == _type)
207 #define IS_BROWSEABLE(_item) ((Evry_Item *)_item)->browseable
209 /*** Evry_Plugin macros ***/
211 #define EVRY_PLUGIN_NEW(_base, _name, _icon, _item_type, _begin, _finish, _fetch, _free) \
212 evry->plugin_new(EVRY_PLUGIN(E_NEW(_base, 1)), _name, _(_name), _icon, _item_type, \
213 _begin, _finish, _fetch, _free)
215 #define EVRY_PLUGIN_FREE(_p) if (_p) evry->plugin_free(EVRY_PLUGIN(_p))
217 #define EVRY_PLUGIN_ITEMS_FREE(_p) { \
219 EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, it) \
220 evry->item_free(it); }
222 #define EVRY_PLUGIN_ITEMS_ADD(_plugin, _items, _input, _match_detail, _set_usage) \
223 evry->util_plugin_items_add(EVRY_PLUGIN(_plugin), _items, _input, _match_detail, _set_usage)
225 #define EVRY_PLUGIN_UPDATE(_p, _action) \
226 if (_p) evry->plugin_update(EVRY_PLUGIN(_p), _action)
228 #define EVRY_PLUGIN_ITEMS_SORT(_p, _sortcb) \
229 EVRY_PLUGIN(_p)->items = eina_list_sort \
230 (EVRY_PLUGIN(_p)->items, eina_list_count(EVRY_PLUGIN(_p)->items), _sortcb)
232 #define EVRY_PLUGIN_ITEM_APPEND(_p, _item) \
233 EVRY_PLUGIN(_p)->items = eina_list_append(EVRY_PLUGIN(_p)->items, EVRY_ITEM(_item))
235 typedef void (*Evry_Item_Free_Cb) (Evry_Item *it);
237 #define EVRY_PLUGIN_INSTANCE(_p, _plugin) { \
238 _p = E_NEW(Plugin, 1); \
239 _p->base = *_plugin; \
240 _p->base.items = NULL; \
241 _p->base.base.ref = 1; \
242 _p->base.base.free = (Evry_Item_Free_Cb)_p->base.finish; \
243 _p->base.base.label = eina_stringshare_add(_plugin->base.label); \
244 _p->base.base.detail = eina_stringshare_add(_plugin->base.detail); \
245 _p->base.base.icon = eina_stringshare_add(_plugin->base.icon); \
246 _p->base.base.context = eina_stringshare_add(_plugin->base.context); \
247 _p->base.base.id = eina_stringshare_add(_plugin->base.id); \
248 _p->base.base.plugin = (Evry_Plugin*)_p; } \
250 #define EVRY_PLUGIN_ITEMS_CLEAR(_p) { \
252 EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, it) \
253 if (it) it->fuzzy_match = 0; }
255 /*** Evry_Action macros ***/
257 #define EVRY_ACTION_NEW(_name, _in1, _in2, _icon, _action, _check) \
258 evry->action_new(_name, _(_name), _in1, _in2, _icon, _action, _check)
260 #define EVRY_ACTION_FREE(_act) if (_act) evry->action_free(EVRY_ACTN(_act))
263 #define EVRY_MODULE_NEW(_module, _evry_api, _init, _shutdown) \
265 _module = E_NEW(Evry_Module, 1); \
266 _module->init = &_init; \
267 _module->shutdown = &_shutdown; \
268 Eina_List *l = e_datastore_get("evry_modules"); \
269 l = eina_list_append(l, _module); \
270 e_datastore_set("evry_modules", l); \
271 if ((_evry_api = e_datastore_get("evry_api"))) \
272 evry_module->active = _init(_evry_api); \
275 #define EVRY_MODULE_FREE(_module) \
277 _module->shutdown(); \
278 Eina_List *l = e_datastore_get("evry_modules"); \
279 l = eina_list_remove(l, _module); \
280 if (l) e_datastore_set("evry_modules", l); \
281 else e_datastore_del("evry_modules"); \
286 /*** handy macros ***/
288 #define IF_RELEASE(x) do { \
290 const char *__tmp; __tmp = (x); \
291 (x) = NULL; eina_stringshare_del(__tmp); \
299 #ifndef EINA_LOG_DEFAULT_COLOR
300 #define EINA_LOG_DEFAULT_COLOR EINA_COLOR_CYAN
308 #define DBG(...) EINA_LOG_DOM_DBG(evry->log_dom , __VA_ARGS__)
309 #define INF(...) EINA_LOG_DOM_INFO(evry->log_dom , __VA_ARGS__)
310 #define WRN(...) EINA_LOG_DOM_WARN(evry->log_dom , __VA_ARGS__)
311 #define ERR(...) EINA_LOG_DOM_ERR(evry->log_dom , __VA_ARGS__)