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