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