1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
|
#ifndef EVRY_H
#define EVRY_H
#include "e.h"
#define EVRY_API_VERSION 1
#define EVRY_ACTION_OTHER 0
#define EVRY_ACTION_FINISHED 1
#define EVRY_ACTION_CONTINUE 2
#define EVRY_ASYNC_UPDATE_ADD 0
#define EVRY_ASYNC_UPDATE_CLEAR 1
#define EVRY_ASYNC_UPDATE_REFRESH 2
extern int _e_module_evry_log_dom;
#ifndef EINA_LOG_DEFAULT_COLOR
#define EINA_LOG_DEFAULT_COLOR EINA_COLOR_CYAN
#endif
#undef DBG
#undef INF
#undef WRN
#undef ERR
#define DBG(...) EINA_LOG_DOM_DBG(_e_module_evry_log_dom , __VA_ARGS__)
#define INF(...) EINA_LOG_DOM_INFO(_e_module_evry_log_dom , __VA_ARGS__)
#define WRN(...) EINA_LOG_DOM_WARN(_e_module_evry_log_dom , __VA_ARGS__)
#define ERR(...) EINA_LOG_DOM_ERR(_e_module_evry_log_dom , __VA_ARGS__)
typedef struct _Evry_Plugin Evry_Plugin;
typedef struct _Evry_Item Evry_Item;
typedef struct _Evry_Item_App Evry_Item_App;
typedef struct _Evry_Item_File Evry_Item_File;
typedef struct _Evry_Action Evry_Action;
typedef struct _Evry_State Evry_State;
typedef struct _Evry_View Evry_View;
typedef struct _Plugin_Config Plugin_Config;
typedef struct _History Evry_History;
typedef struct _History_Entry History_Entry;
typedef struct _History_Item History_Item;
typedef struct _Config Evry_Config;
#define EVRY_ITEM(_item) ((Evry_Item *)_item)
#define EVRY_PLUGIN(_plugin) ((Evry_Plugin *) _plugin)
#define EVRY_VIEW(_view) ((Evry_View *) _view)
#define ITEM_FILE(_file, _item) Evry_Item_File *_file = (Evry_Item_File *) _item
#define ITEM_APP(_app, _item) Evry_Item_App *_app = (Evry_Item_App *) _item
#define PLUGIN(_p, _plugin) Plugin *_p = (Plugin*) _plugin
#define VIEW(_v, _view) View *_v = (View*) _view
#define EVRY_PLUGIN_ITEMS_CLEAR(_p) \
if (EVRY_PLUGIN(_p)->items) \
eina_list_free(EVRY_PLUGIN(_p)->items); \
EVRY_PLUGIN(_p)->items = NULL;
#define EVRY_PLUGIN_ITEMS_FREE(_p) \
Evry_Item *evryitem; \
EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, evryitem) \
evry_item_free(evryitem);
#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_FREE(_p) \
evry_plugin_free(EVRY_PLUGIN(_p), 0); \
E_FREE(_p);
struct _Plugin_Config
{
const char *name;
int loaded;
int enabled;
/* minimum input chars to query this source */
int min_query;
int priority;
const char *trigger;
};
struct _Evry_Item
{
/* label to show for this item */
const char *label;
const char *icon;
/* context provided by item. e.g. to remember which action
* was performed on a file with a specific mimetype */
const char *context;
/* item can be browsed, e.g. folders */
Eina_Bool browseable;
Eina_Bool selected;
/* for internally use by plugins */
void *data;
/* priority hints for sorting */
int priority;
/* store value of fuzzy match with input */
int fuzzy_match;
/* optional: plugin can set id to identify
* it in history otherwise label is used */
const char *id;
/* if transient item is removed from history
* on shutdown */
Eina_Bool transient;
/* do not set by plugin! */
Evry_Item *next;
Evry_Plugin *plugin;
int ref;
void (*free) (Evry_Item *item);
double usage;
};
struct _Evry_Item_App
{
Evry_Item base;
const char *file;
Efreet_Desktop *desktop;
};
struct _Evry_Item_File
{
Evry_Item base;
const char *url;
const char *path;
const char *mime;
};
struct _Evry_Plugin
{
const char *name;
const char *icon;
enum { type_subject, type_action, type_object } type;
const char *type_in;
const char *type_out;
const char *trigger;
/* list of items visible for everything */
Eina_List *items;
/* run when plugin is activated. when returns positve it is added
to the list of current plugins and queried for results */
Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item);
/* get candidates matching string, fill 'items' list */
int (*fetch) (Evry_Plugin *p, const char *input);
/* run when state is removed in which this plugin is active */
void (*cleanup) (Evry_Plugin *p);
Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e);
/* provide more information for a candidate */
/* int (*candidate_info) (Evas *evas, Evry_Item *item); */
/* only used when plugin is of type_action */
int (*action) (Evry_Plugin *p, const Evry_Item *item);
Evas_Object *(*config_page) (Evry_Plugin *p);
void (*config_apply) (Evry_Plugin *p);
int (*cb_key_down) (Evry_Plugin *p, const Ecore_Event_Key *ev);
/* show in aggregator. default is TRUE */
Eina_Bool aggregate;
/* whether the plugin uses evry_async_update to add new
items. default is FALSE */
Eina_Bool async_fetch;
/* not to be set by plugin! */
Plugin_Config *config;
};
struct _Evry_State
{
char *input;
/* all available plugins for current state */
Eina_List *plugins;
/* currently active plugins, i.e. those that provide items */
Eina_List *cur_plugins;
/* active plugin */
Evry_Plugin *plugin;
/* selected item */
Evry_Item *cur_item;
Eina_List *sel_items;
/* this is for the case when the current plugin was not selected
manually and a higher priority (async) plugin retrieves
candidates, the higher priority plugin is made current */
Eina_Bool plugin_auto_selected;
Eina_Bool item_auto_selected;
Evry_View *view;
};
struct _Config
{
int version;
/* position */
double rel_x, rel_y;
/* size */
int width, height;
Eina_List *modules;
/* generic plugin config */
Eina_List *conf_subjects;
Eina_List *conf_actions;
Eina_List *conf_objects;
Eina_List *conf_views;
int scroll_animate;
double scroll_speed;
int hide_input;
int hide_list;
int quick_nav;
const char *cmd_terminal;
const char *cmd_sudo;
int view_mode;
int view_zoom;
int history_sort_mode;
/* use up/down keys for prev/next in thumb view */
int cycle_mode;
/* not saved data */
Eina_List *plugins;
Eina_List *actions;
Eina_List *views;
int min_w, min_h;
};
struct _Evry_View
{
Evry_View *id;
const char *name;
const char *trigger;
int active;
Evas_Object *o_list;
Evas_Object *o_bar;
Evry_View *(*create) (Evry_View *view, const Evry_State *s, const Evas_Object *swallow);
void (*destroy) (Evry_View *view);
int (*cb_key_down) (Evry_View *view, const Ecore_Event_Key *ev);
int (*update) (Evry_View *view);
void (*clear) (Evry_View *view);
int priority;
};
struct _Evry_Action
{
const char *name;
const char *type_in1;
const char *type_in2;
const char *type_out;
const Evry_Item *item1;
const Evry_Item *item2;
int (*action) (Evry_Action *act);
int (*check_item) (Evry_Action *act, const Evry_Item *it);
int (*intercept) (Evry_Action *act);
void (*cleanup) (Evry_Action *act);
Eina_List *(*actions) (Evry_Action *act);
Evas_Object *(*icon_get) (Evry_Action *act, Evas *e);
/* use icon name from theme */
const char *icon;
void *data;
int priority;
};
struct _History_Entry
{
Eina_List *items;
};
struct _History
{
int version;
Eina_Hash *subjects;
Eina_Hash *actions;
double begin;
};
struct _History_Item
{
const char *plugin;
const char *context;
const char *input;
double last_used;
double usage;
int count;
int transient;
};
/* evry.c */
EAPI void evry_item_select(const Evry_State *s, Evry_Item *it);
EAPI void evry_item_mark(const Evry_State *state, Evry_Item *it, Eina_Bool mark);
EAPI void evry_plugin_select(const Evry_State *s, Evry_Plugin *p);
EAPI int evry_list_win_show(void);
EAPI void evry_list_win_hide(void);
EAPI Evry_Item *evry_item_new(Evry_Item *base, Evry_Plugin *p, const char *label, void (*cb_free) (Evry_Item *item));
EAPI void evry_item_free(Evry_Item *it);
EAPI void evry_item_ref(Evry_Item *it);
EAPI void evry_plugin_async_update(Evry_Plugin *plugin, int state);
EAPI void evry_clear_input(void);
/* evry_util.c */
EAPI Evas_Object *evry_icon_mime_get(const char *mime, Evas *e);
EAPI Evas_Object *evry_icon_theme_get(const char *icon, Evas *e);
EAPI int evry_fuzzy_match(const char *str, const char *match);
EAPI Eina_List *evry_fuzzy_match_sort(Eina_List *items);
EAPI int evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file);
EAPI char *evry_util_unescape(const char *string, int length);
/* e_mod_main.c */
EAPI void evry_plugin_register(Evry_Plugin *p, int priority);
EAPI void evry_plugin_unregister(Evry_Plugin *p);
EAPI void evry_action_register(Evry_Action *act, int priority);
EAPI void evry_action_unregister(Evry_Action *act);
EAPI void evry_view_register(Evry_View *view, int priority);
EAPI void evry_view_unregister(Evry_View *view);
EAPI void evry_history_load(void);
EAPI void evry_history_unload(void);
EAPI void evry_history_add(Eina_Hash *hist, Evry_State *s, const char *ctxt);
EAPI int evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, const char *ctxt);
EAPI Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, int type,
const char *type_in, const char *type_out,
int async_fetch, const char *icon, const char *trigger,
Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item),
void (*cleanup) (Evry_Plugin *p),
int (*fetch) (Evry_Plugin *p, const char *input),
int (*action) (Evry_Plugin *p, const Evry_Item *item),
Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e),
Evas_Object *(*config_page) (Evry_Plugin *p),
void (*config_apply) (Evry_Plugin *p));
EAPI void evry_plugin_free(Evry_Plugin *p, int free_pointer);
EAPI Evry_Action *evry_action_new(const char *name, const char *type_in1,
const char *type_in2, const char *type_out,
const char *icon,
int (*action) (Evry_Action *act),
int (*check_item) (Evry_Action *act, const Evry_Item *it),
void (*cleanup) (Evry_Action *act),
int (*intercept) (Evry_Action *act),
Evas_Object *(*icon_get) (Evry_Action *act, Evas *e));
EAPI void evry_action_free(Evry_Action *act);
EAPI int evry_api_version_check(int version);
typedef struct _Evry_Event_Item_Changed Evry_Event_Item_Changed;
struct _Evry_Event_Item_Changed
{
Evry_Item *item;
};
extern EAPI int EVRY_EVENT_ITEM_SELECT;
extern EAPI int EVRY_EVENT_ITEM_CHANGED;
extern EAPI int EVRY_EVENT_ITEMS_UPDATE;
EAPI extern Evry_History *evry_hist;
EAPI extern Evry_Config *evry_conf;
#endif
|