1 #ifndef EVRY_H
2 #define EVRY_H
3 
4 #include "e.h"
5 #include "evry_api.h"
6 
7 /* Increment for Major Changes */
8 #define MOD_CONFIG_FILE_EPOCH      1
9 /* Increment for Minor Changes (ie: user doesn't need a new config) */
10 #define MOD_CONFIG_FILE_GENERATION 0
11 #define MOD_CONFIG_FILE_VERSION    ((MOD_CONFIG_FILE_EPOCH * 1000000) + MOD_CONFIG_FILE_GENERATION)
12 
13 #define SLIDE_LEFT   1
14 #define SLIDE_RIGHT -1
15 
16 typedef struct _History		Evry_History;
17 typedef struct _Config		Evry_Config;
18 typedef struct _Evry_Selector	Evry_Selector;
19 typedef struct _Tab_View	Tab_View;
20 typedef struct _Evry_Window	Evry_Window;
21 typedef struct _Gadget_Config   Gadget_Config;
22 
23 struct _Evry_Window
24 {
25   Evas_Object *ewin;
26   Evas *evas;
27   E_Zone *zone;
28   Evas_Object *o_main;
29 
30   Eina_Bool request_selection;
31   Eina_Bool plugin_dedicated;
32   Eina_Bool visible;
33 
34   Eina_List *handlers;
35 
36   Evry_Selector  *selector;
37   Evry_Selector **selectors;
38   Evry_Selector **sel_list;
39 
40   unsigned int level;
41 
42   unsigned int mouse_button;
43   Eina_Bool mouse_out;
44 
45   Eina_Bool grab;
46 
47   Evry_State *state_clearing;
48 
49   struct
50   {
51       void (*hide) (Evry_Window *win, int finished);
52   } func;
53 
54   /* only to be used by creator of win */
55   void *data;
56 
57   Ecore_Timer *delay_hide_action;
58 };
59 
60 struct _Evry_Selector
61 {
62   Evry_Window *win;
63 
64   /* current state */
65   Evry_State  *state;
66 
67   /* stack of states (for browseable plugins) */
68   Eina_List   *states;
69 
70   /* provides collection of items from other plugins */
71   Evry_Plugin *aggregator;
72 
73   /* action selector plugin */
74   Evry_Plugin *actions;
75 
76   /* all plugins that belong to this selector*/
77   Eina_List   *plugins;
78 
79   /* list view instance */
80   Evry_View   *view;
81 
82   Evas_Object *o_icon;
83   Evas_Object *o_thumb;
84   const Evas_Object *event_object;
85   Eina_Bool    do_thumb;
86 
87   Ecore_Timer *update_timer;
88   Ecore_Timer *action_timer;
89 
90   const char *edje_part;
91 };
92 
93 struct _Evry_State
94 {
95   Evry_Selector *selector;
96 
97   char *inp; /* alloced input */
98 
99   char *input; /* pointer to input + trigger */
100   /* all available plugins for current state */
101   Eina_List   *plugins;
102 
103   /* currently active plugins, i.e. those that provide items */
104   Eina_List   *cur_plugins;
105 
106   /* active plugin */
107   Evry_Plugin *plugin;
108 
109   /* aggregator instance */
110   Evry_Plugin *aggregator;
111 
112   /* selected item */
113   Evry_Item   *cur_item;
114 
115   /* marked items */
116   Eina_List   *sel_items;
117 
118   Eina_Bool plugin_auto_selected;
119   Eina_Bool item_auto_selected;
120 
121   /* current view instance */
122   Evry_View *view;
123 
124   Eina_Bool changed;
125   Eina_Bool trigger_active;
126 
127   unsigned int request;
128 
129   Ecore_Timer *clear_timer;
130 
131   Eina_Bool delete_me;
132 };
133 
134 struct _Tab_View
135 {
136   const Evry_State *state;
137 
138   Evry_View *view;
139   Evas *evas;
140 
141   Evas_Object *o_tabs;
142   Eina_List *tabs;
143 
144   void (*update) (Tab_View *tv);
145   void (*clear) (Tab_View *tv);
146   int (*key_down) (Tab_View *tv, const Ecore_Event_Key *ev);
147 
148   double align;
149   double align_to;
150   Ecore_Animator *animator;
151   Ecore_Timer *timer;
152 };
153 
154 struct _Config
155 {
156   int version;
157   /* position */
158   double rel_x, rel_y;
159   /* size */
160   int width, height;
161   int edge_width, edge_height;
162 
163   Eina_List *modules;
164 
165   /* generic plugin config */
166   Eina_List *conf_subjects;
167   Eina_List *conf_actions;
168   Eina_List *conf_objects;
169   Eina_List *conf_views;
170   Eina_List *collections;
171 
172   int scroll_animate;
173   double scroll_speed;
174 
175   int hide_input;
176   int hide_list;
177 
178   /* quick navigation mode */
179   int quick_nav;
180 
181   /* default view mode */
182   int view_mode;
183   int view_zoom;
184 
185   int history_sort_mode;
186 
187   /* use up/down keys for prev/next in thumb view */
188   int cycle_mode;
189 
190   Eina_List *gadgets;
191 
192   unsigned char first_run;
193   /* not saved data */
194   Eina_List *actions;
195   Eina_List *views;
196 
197   int min_w, min_h;
198 };
199 
200 struct _Gadget_Config
201 {
202   const char *id;
203   const char *plugin;
204   int hide_after_action;
205   int popup;
206 };
207 
208 struct _History
209 {
210   int version;
211   Eina_Hash *subjects;
212   double begin;
213 };
214 
215 /*** Evry_Api functions ***/
216 void  evry_item_select(const Evry_State *s, Evry_Item *it);
217 void  evry_item_mark(const Evry_State *state, Evry_Item *it, Eina_Bool mark);
218 void  evry_plugin_select(Evry_Plugin *p);
219 Evry_Item *evry_item_new(Evry_Item *base, Evry_Plugin *p, const char *label,
220 			      Evas_Object *(*icon_get) (Evry_Item *it, Evas *e),
221 			      void (*cb_free) (Evry_Item *item));
222 void  evry_item_free(Evry_Item *it);
223 void  evry_item_ref(Evry_Item *it);
224 
225 void  evry_plugin_update(Evry_Plugin *plugin, int state);
226 void  evry_clear_input(Evry_Plugin *p);
227 
228 /* evry_util.c */
229 /* Evas_Object *evry_icon_mime_get(const char *mime, Evas *e); */
230 Evas_Object *evry_icon_theme_get(const char *icon, Evas *e);
231 int   evry_fuzzy_match(const char *str, const char *match);
232 Eina_List *evry_fuzzy_match_sort(Eina_List *items);
233 int   evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file);
234 char *evry_util_url_escape(const char *string, int inlength);
235 char *evry_util_url_unescape(const char *string, int length);
236 void  evry_util_file_detail_set(Evry_Item_File *file);
237 int   evry_util_module_config_check(const char *module_name, int conf, int epoch, int version);
238 Evas_Object *evry_util_icon_get(Evry_Item *it, Evas *e);
239 int   evry_util_plugin_items_add(Evry_Plugin *p, Eina_List *items, const char *input, int match_detail, int set_usage);
240 void  evry_item_changed(Evry_Item *it, int change_icon, int change_selected);
241 char *evry_util_md5_sum(const char *str);
242 void evry_util_items_sort(Eina_List **items, int flags);
243 
244 const char *evry_file_path_get(Evry_Item_File *file);
245 const char *evry_file_url_get(Evry_Item_File *file);
246 
247 int   evry_plugin_register(Evry_Plugin *p, int type, int priority);
248 void  evry_plugin_unregister(Evry_Plugin *p);
249 Evry_Plugin *evry_plugin_find(const char *name);
250 void  evry_action_register(Evry_Action *act, int priority);
251 void  evry_action_unregister(Evry_Action *act);
252 void  evry_view_register(Evry_View *view, int priority);
253 void  evry_view_unregister(Evry_View *view);
254 Evry_Action *evry_action_find(const char *name);
255 
256 void  evry_history_load(void);
257 void  evry_history_unload(void);
258 History_Item *evry_history_item_add(Evry_Item *it, const char *ctxt, const char *input);
259 int   evry_history_item_usage_set(Evry_Item *it, const char *input, const char *ctxt);
260 History_Types *evry_history_types_get(Evry_Type type);
261 
262 Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, const char *icon,
263 			     Evry_Type item_type,
264 			     Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item),
265 			     void (*cleanup) (Evry_Plugin *p),
266 			     int  (*fetch)   (Evry_Plugin *p, const char *input));
267 
268 void  evry_plugin_free(Evry_Plugin *p);
269 
270 Evry_Action *evry_action_new(const char *name, const char *label,
271 			     Evry_Type type1, Evry_Type type2,
272 			     const char *icon,
273 			     int  (*action)     (Evry_Action *act),
274 			     int  (*check_item) (Evry_Action *act, const Evry_Item *it));
275 
276 void  evry_action_free(Evry_Action *act);
277 
278 int   evry_api_version_check(int version);
279 
280 Evry_Type evry_type_register(const char *type);
281 const char *evry_type_get(Evry_Type type);
282 
283 /*** internal ***/
284 Tab_View *evry_tab_view_new(Evry_View *view, const Evry_State *s, Evas_Object *parent);
285 void  evry_tab_view_free(Tab_View *v);
286 
287 Eina_Bool evry_view_init(void);
288 void  evry_view_shutdown(void);
289 
290 Eina_Bool evry_view_help_init(void);
291 void  evry_view_help_shutdown(void);
292 
293 Eina_Bool evry_plug_clipboard_init(void);
294 void  evry_plug_clipboard_shutdown(void);
295 
296 Eina_Bool evry_plug_text_init(void);
297 void  evry_plug_text_shutdown(void);
298 
299 Eina_Bool evry_plug_collection_init(void);
300 void  evry_plug_collection_shutdown(void);
301 
302 int   evry_init(void);
303 int   evry_shutdown(void);
304 Evry_Window *evry_show(E_Zone *zone, E_Zone_Edge edge, const char *params, Eina_Bool popup);
305 void  evry_hide(Evry_Window *win, int clear);
306 
307 int   evry_plug_actions_init(void);
308 void  evry_plug_actions_shutdown(void);
309 
310 Evry_Plugin *evry_aggregator_new(int type);
311 
312 void  evry_history_init(void);
313 void  evry_history_free(void);
314 
315 int   evry_browse_item(Evry_Item *it);
316 int   evry_browse_back(Evry_Selector *sel);
317 
318 void  evry_plugin_action(Evry_Window *win, int finished);
319 
320 int   evry_state_push(Evry_Selector *sel, Eina_List *plugins);
321 int   evry_selectors_switch(Evry_Window *win,int dir, int slide);
322 int   evry_view_toggle(Evry_State *s, const char *trigger);
323 
324 int evry_gadget_init(void);
325 void evry_gadget_shutdown(void);
326 
327 Eina_Bool evry_plug_apps_init(E_Module *m);
328 void evry_plug_apps_shutdown(void);
329 void evry_plug_apps_save(void);
330 
331 Eina_Bool evry_plug_files_init(E_Module *m);
332 void evry_plug_files_shutdown(void);
333 void evry_plug_files_save(void);
334 
335 Eina_Bool evry_plug_windows_init(E_Module *m);
336 void evry_plug_windows_shutdown(void);
337 void evry_plug_windows_save(void);
338 
339 Eina_Bool evry_plug_settings_init(E_Module *m);
340 void evry_plug_settings_shutdown(void);
341 void evry_plug_settings_save(void);
342 
343 Eina_Bool evry_plug_calc_init(E_Module *m);
344 void evry_plug_calc_shutdown(void);
345 void evry_plug_calc_save(void);
346 
347 Ecore_Event_Handler *evry_event_handler_add(int type, Eina_Bool (*func) (void *data, int type, void *event), const void *data);
348 
349 extern Evry_API *evry;
350 extern Evry_History *evry_hist;
351 extern Evry_Config  *evry_conf;
352 extern int  _evry_events[NUM_EVRY_EVENTS];
353 extern E_Module *_mod_evry;
354 
355 /*** E Module ***/
356 E_API void *e_modapi_init     (E_Module *m);
357 E_API int   e_modapi_shutdown (E_Module *m);
358 E_API int   e_modapi_save     (E_Module *m);
359 E_API E_Config_Dialog *evry_config_dialog(Evas_Object *parent, const char *params);
360 E_API E_Config_Dialog *evry_collection_conf_dialog(Evas_Object *parent, const char *params);
361 E_API extern E_Module_Api e_modapi;
362 
363 /* #define CHECK_REFS 1
364  * #define PRINT_REFS 1
365  * #define CHECK_TIME 1
366  * #undef DBG
367  * #define DBG(...) ERR(__VA_ARGS__) */
368 
369 #ifdef CHECK_REFS
370 extern Eina_List *_refd;
371 #endif
372 
373 #ifdef CHECK_TIME
374 extern double _evry_time;
375 #endif
376 
377 
378 /**
379  * @addtogroup Optional_Launcher
380  * @{
381  *
382  * @defgroup Module_Everything Everything Launcher
383  *
384  * Flexible launcher with plugins. Can do search as you type
385  * filtering, browse directories, view pictures, simple math, spell
386  * checking and of course: launching programs and executing commands.
387  *
388  * @}
389  */
390 
391 #endif
392