ed7a62d25945c340771818ac9d280dd4795a192f
[framework/uifw/e17.git] / src / modules / everything / evry_types.h
1 #ifndef EVRY_TYPES_H
2 #define EVRY_TYPES_H
3
4 typedef struct _Evry_Plugin             Evry_Plugin;
5 typedef struct _Plugin_Config           Plugin_Config;
6 typedef struct _Evry_Item               Evry_Item;
7 typedef struct _Evry_Item_App           Evry_Item_App;
8 typedef struct _Evry_Item_File          Evry_Item_File;
9 typedef struct _Evry_Action             Evry_Action;
10 typedef struct _History_Item            History_Item;
11 typedef struct _History_Entry           History_Entry;
12 typedef struct _History_Types           History_Types;
13 typedef struct _Evry_State              Evry_State;
14
15 typedef unsigned int Evry_Type;
16
17 struct _Evry_Item
18 {
19   /* label to show for this item (stringshared) */
20   const char *label;
21
22   /* optional: (stringshared) more information to be shown */
23   const char *detail;
24
25   /* optional: (stringshared) fdo icon name, otherwise use _icon_get */
26   const char *icon;
27
28   /* item can be browsed, e.g. folders */
29   Eina_Bool browseable;
30
31   /* optional: for internally use by plugins */
32   void *data;
33
34   /* optional: priority hints for sorting */
35   int priority;
36
37   /* optional: store value of fuzzy match with input */
38   int fuzzy_match;
39
40   /* optional: plugin can set id to identify
41    * it in history otherwise label is used */
42   const char *id;
43
44   /* optional: context provided by item. e.g. to remember which action
45    * was performed on a file with a specific mimetype */
46   const char *context;
47
48   /* is set to type of Evry_Plugin by default */
49   Evry_Type type;
50
51   /* optional */
52   Evry_Type subtype;
53   
54   Evas_Object *(*icon_get) (Evry_Item *it, Evas *e);
55   void (*free) (Evry_Item *it);
56
57   /* do not set! */
58   int ref;
59   Eina_List *items;
60   Eina_Bool selected;
61   Eina_Bool marked;
62   Evry_Plugin *plugin;
63   double usage;
64   History_Item *hi;
65 };
66
67 struct _Evry_Action
68 {
69   Evry_Item base;
70
71   /* identifier */
72   const char *name;
73   
74   struct
75   {
76     /* requested type for action */
77     Evry_Type type;
78     Evry_Type subtype;
79     /* handle multiple items */
80     Eina_Bool accept_list;
81
82     /* do not set ! */
83     const Evry_Item *item;
84     Eina_List *items;
85   } it1;
86
87   struct
88   {
89     Evry_Type type;
90     Evry_Type subtype;
91     Eina_Bool accept_list;
92
93     /* do not set ! */
94     const Evry_Item *item;
95     Eina_List *items;
96   } it2;
97
98
99   /* optional: this action is specific for a item 'context'.
100      e.g. 'copy' for file mime-type is not, 'image viewer' is.
101      default is FALSE */
102   Eina_Bool remember_context;
103
104   /* required: do something */
105   int  (*action)     (Evry_Action *act);
106
107   /* optional: check whether action fits to chosen item */
108   int  (*check_item) (Evry_Action *act, const Evry_Item *it);
109   /* optional */
110   void (*free)       (Evry_Action *act);
111   /* optional: must be defined when  action is browseable, return
112      list of Evry_Action items */
113   Eina_List *(*fetch) (Evry_Action *act);
114 };
115
116 struct _Evry_Item_App
117 {
118   Evry_Action base;
119   const char *file;
120   Efreet_Desktop *desktop;
121 };
122
123 struct _Evry_Item_File
124 {
125   Evry_Item base;
126   /* path and url must always be checked with
127      evry_file_path/uri_get before use !!! */
128   const char *url;
129   const char *path;
130   const char *mime;
131
132   unsigned int modified;
133 };
134
135 struct _Evry_Plugin
136 {
137   Evry_Item base;
138
139   /* identifier */
140   const char *name;
141
142   /* list of items visible for everything after fetch */
143   Eina_List *items;
144
145   /* required: get candidates matching string, fill 'items' list */
146   int  (*fetch) (Evry_Plugin *p, const char *input);
147
148   /* required: run when state is removed in which this plugin is
149      active. free 'items' here */
150   void (*finish) (Evry_Plugin *p);
151
152   /* plugin is added to the list of current plugins and
153      queried for results when not returning NULL. The previous
154      selectors item is passed, i.e. a plugin registered as action
155      receives the subject, a plugin registered as object receives the
156      action item. here you can check wheter the plugin can be queried,
157      for given context (provided by item) */
158   Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item);
159
160   /* optional: provide a list of subitems of 'item'. this function
161      must return a new instance which must be freed in 'finish' */
162   Evry_Plugin *(*browse) (Evry_Plugin *p, const Evry_Item *item);
163
164   /* optional: try to complete current item:
165      return: EVRY_COMPLETE_INPUT when input was changed
166      return: EVRY_COMPLETE_BROWSE to browse item */
167   int  (*complete) (Evry_Plugin *p, const Evry_Item *item, char **input);
168
169   /* optional: handle key events: return positive when key was
170      handled */
171   int  (*cb_key_down)  (Evry_Plugin *p, const Ecore_Event_Key *ev);
172
173   /* optional: use this when begin returned a new instance or you
174      have extended plugin struct */
175   void (*free) (Evry_Plugin *p);
176
177   /* optiona: actions only used with this plugin, dont require */
178   Eina_List *actions;
179   
180   /* optional: set type which the plugin can handle in begin */
181   Evry_Type input_type;
182
183   /* optional: whether the plugin uses evry_async_update to add new items */
184   /* default FALSE */
185   Eina_Bool async_fetch;
186
187   /* optional: request items to be remembered for usage statistic */
188   /* default TRUE */
189   Eina_Bool history;
190
191   /* optional: if transient, item is removed from history on cleanup */
192   /* default FALSE */
193   Eina_Bool transient;
194
195   /* optional: config path registered for the module, to show
196      'configure' button in everything config */
197   const char *config_path;
198
199   /* set theme file to fetch icons from */
200   const char *theme_path;
201
202   /* not to be set by plugin! */
203   Plugin_Config *config;
204   unsigned int request;
205   Evry_State *state;
206 };
207
208 struct _Plugin_Config
209 {
210   /* do not set! */
211   const char *name;
212   int enabled;
213
214   /* request initial sort order of this plugin */
215   int priority;
216
217   /* trigger to show plugin exclusively */
218   const char *trigger;
219
220   /* only show plugin when triggered */
221   int trigger_only;
222
223   /* preffered view mode */
224   int view_mode;
225
226   /* minimum input char to start query items,
227      this must be handled by plugin */
228   int min_query;
229
230   /* show items of plugin in aggregator */
231   int aggregate;
232
233   /* if not top-level the plugin is shown in aggregator
234      instead of the items  */
235   int top_level;
236
237   /* Eina_Hash *settings; */
238
239   /* do not set! */
240   Evry_Plugin *plugin;
241
242   Eina_List *plugins;
243 };
244
245 struct _History_Item
246 {
247   const char *plugin;
248   const char *context;
249   const char *input;
250   double last_used;
251   double usage;
252   int count;
253   int transient;
254   const char *data;
255 };
256
257 struct _History_Entry
258 {
259   Eina_List *items;
260 };
261
262 struct _History_Types
263 {
264   Eina_Hash *types;
265 };
266
267 #endif