1 #include "e_mod_main.h"
3 static void _e_mod_action_cb(E_Object *obj, const char *params);
4 static void _e_mod_action_cb_edge(E_Object *obj, const char *params, E_Event_Zone_Edge *ev);
5 static Eina_Bool _e_mod_run_defer_cb(void *data);
6 static void _e_mod_run_cb(void *data, E_Menu *m, E_Menu_Item *mi);
7 static void _e_mod_menu_add(void *data, E_Menu *m);
8 static void _config_init(void);
9 static void _config_free(void);
10 static Eina_Bool _cleanup_history(void *data);
11 static void _evry_type_init(const char *type);
13 static Evry_API *_api = NULL;
14 static Eina_List *_evry_types = NULL;
15 static E_Int_Menu_Augmentation *maug = NULL;
16 static E_Action *act = NULL;
17 static Ecore_Timer *cleanup_timer;
18 static const char *module_icon = NULL;
19 static E_Config_DD *conf_edd = NULL;
20 static E_Config_DD *plugin_conf_edd = NULL;
22 Evry_Config *evry_conf = NULL;
23 int _evry_events[NUM_EVRY_EVENTS];
24 int _e_module_evry_log_dom = -1;
28 EAPI E_Module_Api e_modapi =
36 e_modapi_init(E_Module *m)
42 _e_module_evry_log_dom = eina_log_domain_register
43 ("e_module_everything", EINA_LOG_DEFAULT_COLOR);
45 if(_e_module_evry_log_dom < 0)
48 ("impossible to create a log domain for everything module");
52 /* add module supplied action */
53 act = e_action_add("everything");
56 act->func.go = _e_mod_action_cb;
57 act->func.go_edge = _e_mod_action_cb_edge;
58 e_action_predef_name_set
59 (_("Everything Launcher"),
60 _("Show Everything Launcher"),
61 "everything", "", NULL, 0);
64 maug = e_int_menus_menu_augmentation_add
65 ("main/1", _e_mod_menu_add, NULL, NULL, NULL);
67 e_configure_registry_category_add
68 ("launcher", 80, _("Launcher"), NULL, "modules-launcher");
70 snprintf(buf, sizeof(buf), "%s/e-module-everything.edj", e_module_dir_get(m));
71 module_icon = eina_stringshare_add(buf);
73 e_configure_registry_item_add
74 ("launcher/run_everything", 40, _("Everything Configuration"),
75 NULL, module_icon, evry_config_dialog);
78 _evry_type_init("NONE");
79 _evry_type_init("FILE");
80 _evry_type_init("DIRECTORY");
81 _evry_type_init("APPLICATION");
82 _evry_type_init("ACTION");
83 _evry_type_init("PLUGIN");
84 _evry_type_init("BORDER");
85 _evry_type_init("TEXT");
89 _evry_events[EVRY_EVENT_ITEMS_UPDATE] = ecore_event_type_new();
90 _evry_events[EVRY_EVENT_ITEM_SELECTED] = ecore_event_type_new();
91 _evry_events[EVRY_EVENT_ITEM_CHANGED] = ecore_event_type_new();
92 _evry_events[EVRY_EVENT_ACTION_PERFORMED] = ecore_event_type_new();
93 _evry_events[EVRY_EVENT_PLUGIN_SELECTED] = ecore_event_type_new();
95 _api = E_NEW(Evry_API, 1);
96 _api->log_dom = _e_module_evry_log_dom;
97 #define SET(func) (_api->func = &evry_##func);
98 SET(api_version_check);
104 SET(plugin_register);
105 SET(plugin_unregister);
110 SET(action_register);
111 SET(action_unregister);
113 SET(api_version_check);
119 SET(util_url_escape);
120 SET(util_url_unescape);
121 SET(util_file_detail_set);
122 SET(util_plugin_items_add);
125 SET(items_sort_func);
129 SET(history_item_add);
130 SET(history_types_get);
131 SET(history_item_usage_set);
132 SET(event_handler_add);
136 evry_plug_actions_init();
137 evry_plug_apps_init(m);
138 evry_plug_files_init(m);
139 evry_plug_windows_init(m);
140 evry_plug_settings_init(m);
141 evry_plug_calc_init(m);
142 e_datastore_set("evry_api", _api);
144 EINA_LIST_FOREACH(e_datastore_get("evry_modules"), l, em)
145 em->active = em->init(_api);
147 evry_plug_collection_init();
148 evry_plug_clipboard_init();
149 evry_plug_text_init();
151 evry_view_help_init();
154 e_module_priority_set(m, -1000);
155 e_module_delayed_set(m, 1);
157 /* cleanup every hour :) */
158 cleanup_timer = ecore_timer_add(3600, _cleanup_history, NULL);
164 e_modapi_shutdown(E_Module *m __UNUSED__)
166 E_Config_Dialog *cfd;
171 EINA_LIST_FOREACH(e_datastore_get("evry_modules"), l, em)
174 e_datastore_del("evry_api");
177 #ifndef USE_MODULE_EVERYTHING_AS_MODULES
178 evry_plug_apps_shutdown();
179 evry_plug_files_shutdown();
180 evry_plug_settings_shutdown();
181 evry_plug_windows_shutdown();
182 evry_plug_calc_shutdown();
184 evry_gadget_shutdown();
186 evry_view_shutdown();
187 evry_view_help_shutdown();
188 evry_plug_clipboard_shutdown();
189 evry_plug_text_shutdown();
190 evry_plug_collection_shutdown();
191 evry_plug_actions_shutdown();
196 EINA_LIST_FREE(_evry_types, t)
197 eina_stringshare_del(t);
199 e_configure_registry_item_del("launcher/run_everything");
200 e_configure_registry_category_del("launcher");
202 while ((cfd = e_config_dialog_get("E", "_config_everything_dialog")))
203 e_object_del(E_OBJECT(cfd));
207 e_action_predef_name_del(_("Everything Launcher"),
208 _("Show Everything Dialog"));
209 e_action_del("everything");
214 e_int_menus_menu_augmentation_del("main/1", maug);
219 eina_stringshare_del(module_icon);
222 E_CONFIG_DD_FREE(conf_edd);
223 E_CONFIG_DD_FREE(plugin_conf_edd);
226 ecore_timer_del(cleanup_timer);
230 EINA_LIST_FREE(_refd, it)
231 printf("%d %s\n", it->ref, it->label);
238 e_modapi_save(E_Module *m __UNUSED__)
240 e_config_domain_save("module.everything", conf_edd, evry_conf);
242 #ifndef USE_MODULE_EVERYTHING_AS_MODULES
243 evry_plug_apps_save();
244 evry_plug_files_save();
245 evry_plug_settings_save();
246 evry_plug_windows_save();
247 evry_plug_calc_save();
253 /***************************************************************************/
255 Ecore_Event_Handler *
256 evry_event_handler_add(int type, Eina_Bool (*func) (void *data, int type, void *event), const void *data)
258 return ecore_event_handler_add(_evry_events[type], func, data);
263 evry_type_register(const char *type)
265 const char *t = eina_stringshare_add(type);
266 Evry_Type ret = NUM_EVRY_TYPES;
270 EINA_LIST_FOREACH(_evry_types, l, i)
278 _evry_types = eina_list_append(_evry_types, t);
281 eina_stringshare_del(t);
287 _evry_type_init(const char *type)
289 const char *t = eina_stringshare_add(type);
290 _evry_types = eina_list_append(_evry_types, t);
294 evry_type_get(Evry_Type type)
296 const char *ret = eina_list_nth(_evry_types, type);
298 return eina_stringshare_add("");
303 int evry_api_version_check(int version)
305 if (EVRY_API_VERSION == version)
308 ERR("module API is %d, required is %d", version, EVRY_API_VERSION);
315 _evry_cb_view_sort(const void *data1, const void *data2)
317 const Evry_View *v1 = data1;
318 const Evry_View *v2 = data2;
319 return v1->priority - v2->priority;
324 evry_view_register(Evry_View *view, int priority)
326 view->priority = priority;
328 evry_conf->views = eina_list_append(evry_conf->views, view);
330 evry_conf->views = eina_list_sort(evry_conf->views,
331 eina_list_count(evry_conf->views),
336 evry_view_unregister(Evry_View *view)
338 evry_conf->views = eina_list_remove(evry_conf->views, view);
341 /***************************************************************************/
344 _cleanup_history(void *data __UNUSED__)
346 /* evrything is active */
348 return ECORE_CALLBACK_RENEW;
350 /* cleanup old entries */
354 return ECORE_CALLBACK_RENEW;
360 Plugin_Config *pc, *pcc;
364 #define T Plugin_Config
365 #define D plugin_conf_edd
366 plugin_conf_edd = E_CONFIG_DD_NEW("Plugin_Config", Plugin_Config);
367 E_CONFIG_VAL(D, T, name, STR);
368 E_CONFIG_VAL(D, T, enabled, INT);
369 E_CONFIG_VAL(D, T, priority, INT);
370 E_CONFIG_VAL(D, T, trigger, STR);
371 E_CONFIG_VAL(D, T, trigger_only, INT);
372 E_CONFIG_VAL(D, T, view_mode, INT);
373 E_CONFIG_VAL(D, T, aggregate, INT);
374 E_CONFIG_VAL(D, T, top_level, INT);
375 E_CONFIG_VAL(D, T, min_query, INT);
376 E_CONFIG_LIST(D, T, plugins, plugin_conf_edd);
379 #define T Evry_Config
381 conf_edd = E_CONFIG_DD_NEW("Config", Evry_Config);
382 E_CONFIG_VAL(D, T, version, INT);
383 E_CONFIG_VAL(D, T, width, INT);
384 E_CONFIG_VAL(D, T, height, INT);
385 E_CONFIG_VAL(D, T, edge_width, INT);
386 E_CONFIG_VAL(D, T, edge_height, INT);
387 E_CONFIG_VAL(D, T, rel_x, DOUBLE);
388 E_CONFIG_VAL(D, T, rel_y, DOUBLE);
389 E_CONFIG_VAL(D, T, scroll_animate, INT);
390 E_CONFIG_VAL(D, T, scroll_speed, DOUBLE);
391 E_CONFIG_VAL(D, T, hide_input, INT);
392 E_CONFIG_VAL(D, T, hide_list, INT);
393 E_CONFIG_VAL(D, T, quick_nav, INT);
394 E_CONFIG_VAL(D, T, view_mode, INT);
395 E_CONFIG_VAL(D, T, view_zoom, INT);
396 E_CONFIG_VAL(D, T, cycle_mode, INT);
397 E_CONFIG_VAL(D, T, history_sort_mode, INT);
398 E_CONFIG_LIST(D, T, conf_subjects, plugin_conf_edd);
399 E_CONFIG_LIST(D, T, conf_actions, plugin_conf_edd);
400 E_CONFIG_LIST(D, T, conf_objects, plugin_conf_edd);
401 E_CONFIG_LIST(D, T, conf_views, plugin_conf_edd);
402 E_CONFIG_LIST(D, T, collections, plugin_conf_edd);
403 E_CONFIG_VAL(D, T, first_run, UCHAR);
406 evry_conf = e_config_domain_load("module.everything", conf_edd);
408 if (evry_conf && !e_util_module_config_check
409 (_("Everything Module"), evry_conf->version,
410 MOD_CONFIG_FILE_EPOCH, MOD_CONFIG_FILE_VERSION))
415 evry_conf = E_NEW(Evry_Config, 1);
416 evry_conf->version = (MOD_CONFIG_FILE_EPOCH << 16);
419 #define IFMODCFG(v) if ((evry_conf->version & 0xffff) < v) {
420 #define IFMODCFGEND }
424 evry_conf->rel_x = 0.5;
425 evry_conf->rel_y = 0.43;
426 evry_conf->width = 455;
427 evry_conf->height = 430;
428 evry_conf->scroll_animate = 1;
429 evry_conf->scroll_speed = 10.0;
430 evry_conf->hide_input = 0;
431 evry_conf->hide_list = 0;
432 evry_conf->quick_nav = 1;
433 evry_conf->view_mode = VIEW_MODE_DETAIL;
434 evry_conf->view_zoom = 0;
435 evry_conf->cycle_mode = 0;
436 evry_conf->history_sort_mode = 0;
437 evry_conf->edge_width = 340;
438 evry_conf->edge_height = 385;
439 evry_conf->first_run = EINA_TRUE;
441 pcc = E_NEW(Plugin_Config, 1);
442 pcc->name = eina_stringshare_add("Start");
443 pcc->enabled = EINA_FALSE;
444 pcc->aggregate = EINA_FALSE;
445 pcc->top_level = EINA_TRUE;
446 pcc->view_mode = VIEW_MODE_THUMB;
447 evry_conf->collections = eina_list_append(evry_conf->collections, pcc);
449 pc = E_NEW(Plugin_Config, 1);
450 pc->name = eina_stringshare_add("Windows");
451 pc->enabled = EINA_TRUE;
452 pc->view_mode = VIEW_MODE_NONE;
453 pcc->plugins = eina_list_append(pcc->plugins, pc);
455 pc = E_NEW(Plugin_Config, 1);
456 pc->name = eina_stringshare_add("Settings");
457 pc->enabled = EINA_TRUE;
458 pc->view_mode = VIEW_MODE_NONE;
459 pcc->plugins = eina_list_append(pcc->plugins, pc);
461 pc = E_NEW(Plugin_Config, 1);
462 pc->name = eina_stringshare_add("Files");
463 pc->enabled = EINA_TRUE;
464 pc->view_mode = VIEW_MODE_NONE;
465 pcc->plugins = eina_list_append(pcc->plugins, pc);
467 pc = E_NEW(Plugin_Config, 1);
468 pc->name = eina_stringshare_add("Applications");
469 pc->enabled = EINA_TRUE;
470 pc->view_mode = VIEW_MODE_NONE;
471 pcc->plugins = eina_list_append(pcc->plugins, pc);
475 evry_conf->width = 464;
476 evry_conf->height = 366;
479 evry_conf->version = MOD_CONFIG_FILE_VERSION;
485 Plugin_Config *pc, *pc2;
487 EINA_LIST_FREE(evry_conf->collections, pc)
488 EINA_LIST_FREE(pc->plugins, pc2)
490 IF_RELEASE(pc2->name);
491 IF_RELEASE(pc2->trigger);
495 EINA_LIST_FREE(evry_conf->conf_subjects, pc)
497 IF_RELEASE(pc->name);
498 IF_RELEASE(pc->trigger);
501 EINA_LIST_FREE(evry_conf->conf_actions, pc)
503 IF_RELEASE(pc->name);
504 IF_RELEASE(pc->trigger);
507 EINA_LIST_FREE(evry_conf->conf_objects, pc)
509 IF_RELEASE(pc->name);
510 IF_RELEASE(pc->trigger);
517 /***************************************************************************/
518 /* action callback */
520 static Ecore_Idle_Enterer *_idler = NULL;
521 static const char *_params = NULL;
524 _e_mod_run_defer_cb(void *data)
529 if (zone) evry_show(zone, E_ZONE_EDGE_NONE, _params);
532 return ECORE_CALLBACK_CANCEL;
536 _e_mod_action_cb(E_Object *obj, const char *params)
542 if (obj->type == E_MANAGER_TYPE)
543 zone = e_util_zone_current_get((E_Manager *)obj);
544 else if (obj->type == E_CONTAINER_TYPE)
545 zone = e_util_zone_current_get(((E_Container *)obj)->manager);
546 else if (obj->type == E_ZONE_TYPE)
547 zone = e_util_zone_current_get(((E_Zone *)obj)->container->manager);
549 zone = e_util_zone_current_get(e_manager_current_get());
551 if (!zone) zone = e_util_zone_current_get(e_manager_current_get());
556 if (params && params[0])
557 _params = eina_stringshare_add(params);
558 /* if (zone) evry_show(zone, _params); */
560 if (_idler) ecore_idle_enterer_del(_idler);
561 _idler = ecore_idle_enterer_add(_e_mod_run_defer_cb, zone);
565 _e_mod_action_cb_edge(E_Object *obj __UNUSED__, const char *params, E_Event_Zone_Edge *ev)
568 if (params && params[0])
569 _params = eina_stringshare_add(params);
571 if (_idler) ecore_idle_enterer_del(_idler);
573 evry_show(ev->zone, ev->edge, _params);
576 /* menu item callback(s) */
578 _e_mod_run_cb(void *data __UNUSED__, E_Menu *m, E_Menu_Item *mi __UNUSED__)
581 ecore_idle_enterer_add(_e_mod_run_defer_cb, m->zone);
584 /* menu item add hook */
586 _e_mod_menu_add(void *data __UNUSED__, E_Menu *m)
590 mi = e_menu_item_new(m);
591 e_menu_item_label_set(mi, _("Run Everything"));
592 e_util_menu_item_theme_icon_set(mi, "system-run");
593 e_menu_item_callback_set(mi, _e_mod_run_cb, NULL);