diff options
Diffstat (limited to 'src/modules/everything')
21 files changed, 142 insertions, 5145 deletions
diff --git a/src/modules/everything/Evry.h b/src/modules/everything/Evry.h index f60bb6efdd..b1cc691107 100644 --- a/src/modules/everything/Evry.h +++ b/src/modules/everything/Evry.h @@ -38,6 +38,10 @@ typedef struct _Evry_Action Evry_Action; typedef struct _Evry_State Evry_State; typedef struct _Evry_View Evry_View; typedef struct _Plugin_Config Plugin_Config; +typedef struct _History Evry_History; +typedef struct _History_Entry History_Entry; +typedef struct _History_Item History_Item; +typedef struct _Config Evry_Config; #define EVRY_ITEM(_item) ((Evry_Item *)_item) #define EVRY_PLUGIN(_plugin) ((Evry_Plugin *) _plugin) @@ -218,6 +222,49 @@ struct _Evry_State Evry_View *view; }; +struct _Config +{ + int version; + /* position */ + double rel_x, rel_y; + /* size */ + int width, height; + + Eina_List *modules; + + /* generic plugin config */ + Eina_List *conf_subjects; + Eina_List *conf_actions; + Eina_List *conf_objects; + Eina_List *conf_views; + + int scroll_animate; + double scroll_speed; + + int hide_input; + int hide_list; + + int quick_nav; + + const char *cmd_terminal; + const char *cmd_sudo; + + int view_mode; + int view_zoom; + + int history_sort_mode; + + /* use up/down keys for prev/next in thumb view */ + int cycle_mode; + + /* not saved data */ + Eina_List *plugins; + Eina_List *actions; + Eina_List *views; + + int min_w, min_h; +}; + struct _Evry_View { Evry_View *id; @@ -262,6 +309,30 @@ struct _Evry_Action int priority; }; +struct _History_Entry +{ + Eina_List *items; +}; + +struct _History +{ + int version; + Eina_Hash *subjects; + Eina_Hash *actions; + double begin; +}; + +struct _History_Item +{ + const char *plugin; + const char *context; + const char *input; + double last_used; + double usage; + int count; + int transient; +}; + /* evry.c */ EAPI void evry_item_select(const Evry_State *s, Evry_Item *it); EAPI void evry_item_mark(const Evry_State *state, Evry_Item *it, Eina_Bool mark); @@ -291,6 +362,11 @@ EAPI void evry_action_unregister(Evry_Action *act); EAPI void evry_view_register(Evry_View *view, int priority); EAPI void evry_view_unregister(Evry_View *view); +EAPI void evry_history_load(void); +EAPI void evry_history_unload(void); +EAPI void evry_history_add(Eina_Hash *hist, Evry_State *s, const char *ctxt); +EAPI int evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, const char *ctxt); + EAPI Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, int type, const char *type_in, const char *type_out, int async_fetch, const char *icon, const char *trigger, @@ -329,4 +405,7 @@ extern EAPI int EVRY_EVENT_ITEM_SELECT; extern EAPI int EVRY_EVENT_ITEM_CHANGED; extern EAPI int EVRY_EVENT_ITEMS_UPDATE; +EAPI extern Evry_History *evry_hist; +EAPI extern Evry_Config *evry_conf; + #endif diff --git a/src/modules/everything/Makefile.am b/src/modules/everything/Makefile.am index 697d175dac..fab59638c0 100644 --- a/src/modules/everything/Makefile.am +++ b/src/modules/everything/Makefile.am @@ -1,8 +1,6 @@ MAINTAINERCLEANFILES = Makefile.in everything.pc MODULE = everything -SUBDIRS = . sources actions views - # data files for the module filesdir = $(libdir)/enlightenment/modules/$(MODULE) files_DATA = \ @@ -21,7 +19,7 @@ INCLUDES = -I. \ pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH) pkg_LTLIBRARIES = module.la -noinst_LTLIBRARIES = libfoo.la +# noinst_LTLIBRARIES = libfoo.la EVRYHEADERS = Evry.h @@ -34,7 +32,11 @@ module_la_SOURCES = $(EVRYHEADERS) \ evry_history.c \ evry_plug_aggregator.c \ evry_plug_actions.c \ - evry_view_plugin_tabs.c + evry_view_plugin_tabs.c \ + evry_plug_view_thumb.c \ + evry_plug_preview.c \ + evry_plug_view_help.c \ + evry_plug_clipboard.c module_la_LIBADD = @e_libs@ @dlopen_libs@ module_la_LDFLAGS = -module -avoid-version @@ -43,10 +45,10 @@ module_la_DEPENDENCIES = $(top_builddir)/config.h installed_headersdir = $(prefix)/include/@PACKAGE@ installed_headers_DATA = $(EVRYHEADERS) -libfoo_la_SOURCES = evry.c e_mod_main.h evry_util.c evry_config.c evry_history.c evry_view_plugin_tabs.c -libfoo_la_LIBADD = @e_libs@ @dlopen_libs@ -libfoo_la_LDFLAGS = -avoid-version -libfoo_la_DEPENDENCIES = $(top_builddir)/config.h +# libfoo_la_SOURCES = evry.c e_mod_main.h evry_util.c evry_config.c evry_history.c evry_view_plugin_tabs.c +# libfoo_la_LIBADD = @e_libs@ @dlopen_libs@ +# libfoo_la_LDFLAGS = -avoid-version +# libfoo_la_DEPENDENCIES = $(top_builddir)/config.h pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = everything.pc diff --git a/src/modules/everything/actions/Makefile.am b/src/modules/everything/actions/Makefile.am deleted file mode 100644 index 17eb3d7599..0000000000 --- a/src/modules/everything/actions/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in -MODULE = everything - -# the module .so file -INCLUDES = -I.. \ - -I$(top_srcdir) \ - -I$(top_srcdir)/src/modules/$(MODULE) \ - -I$(top_srcdir)/src/bin \ - -I$(top_srcdir)/src/lib \ - -I$(top_srcdir)/src/modules \ - @e_cflags@ - -plugindir = $(libdir)/enlightenment/modules/$(MODULE)/plugins/core/$(MODULE_ARCH) - -evry_plug_border_actdir = $(plugindir) -evry_plug_border_act_LTLIBRARIES = evry_plug_border_act.la -evry_plug_border_act_la_SOURCES = evry_plug_border_act.c -evry_plug_border_act_la_LIBADD = @e_libs@ ../libfoo.la -evry_plug_border_act_la_LDFLAGS = -module -avoid-version -evry_plug_border_act_la_LIBTOOLFLAGS = --tag=disable-static - -evry_plug_clipboarddir = $(plugindir) -evry_plug_clipboard_LTLIBRARIES = evry_plug_clipboard.la -evry_plug_clipboard_la_SOURCES = evry_plug_clipboard.c -evry_plug_clipboard_la_LIBADD = @e_libs@ ../libfoo.la -evry_plug_clipboard_la_LDFLAGS = -module -avoid-version -evry_plug_clipboard_la_LIBTOOLFLAGS = --tag=disable-static - -evry_plug_wallpaperdir = $(plugindir) -evry_plug_wallpaper_LTLIBRARIES = evry_plug_wallpaper.la -evry_plug_wallpaper_la_SOURCES = evry_plug_wallpaper.c -evry_plug_wallpaper_la_LIBADD = @e_libs@ ../libfoo.la -evry_plug_wallpaper_la_LDFLAGS = -module -avoid-version -evry_plug_wallpaper_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/src/modules/everything/actions/evry_plug_border_act.c b/src/modules/everything/actions/evry_plug_border_act.c deleted file mode 100644 index 12a8b4b34f..0000000000 --- a/src/modules/everything/actions/evry_plug_border_act.c +++ /dev/null @@ -1,279 +0,0 @@ -#include "Evry.h" - - -typedef struct _Inst Inst; - -struct _Inst -{ - E_Border *border; -}; - -static Evry_Plugin *plugin = NULL; -static Inst *inst = NULL; -static Evry_Action *act = NULL; - -static void -_act_cb_border_switch_to(E_Border *bd) -{ - E_Zone *zone; - - zone = e_util_zone_current_get(e_manager_current_get()); - - if (bd->desk != (e_desk_current_get(zone))) - e_desk_show(bd->desk); - - if (bd->shaded) - e_border_unshade(bd, E_DIRECTION_UP); - - if (bd->iconic) - e_border_uniconify(bd); - else - e_border_raise(bd); - - /* e_border_focus_set(bd, 1, 1); */ - e_border_focus_set_with_pointer(bd); -} - -static void -_act_cb_border_to_desktop(E_Border *bd) -{ - E_Zone *zone; - E_Desk *desk; - zone = e_util_zone_current_get(e_manager_current_get()); - desk = e_desk_current_get(zone); - - e_border_desk_set(bd, desk); - - if (bd->shaded) - e_border_unshade(bd, E_DIRECTION_UP); - - if (bd->iconic) - e_border_uniconify(bd); - else - e_border_raise(bd); - - /* e_border_focus_set(bd, 1, 1); */ - e_border_focus_set_with_pointer(bd); -} - -static void -_act_cb_border_fullscreen(E_Border *bd) -{ - if (!bd->fullscreen) - e_border_fullscreen(bd, E_FULLSCREEN_RESIZE); - else - e_border_unfullscreen(bd); -} - -static void -_act_cb_border_close(E_Border *bd) -{ - if (!bd->lock_close) e_border_act_close_begin(bd); -} - -static void -_act_cb_border_minimize(E_Border *bd) -{ - if (!bd->lock_user_iconify) e_border_iconify(bd); -} - -static void -_act_cb_border_unminimize(E_Border *bd) -{ - if (!bd->lock_user_iconify) e_border_uniconify(bd); -} - -static Evry_Plugin * -_begin(Evry_Plugin *p __UNUSED__, const Evry_Item *item) -{ - E_Border *bd; - - bd = item->data; - /* e_object_ref(E_OBJECT(bd)); */ - inst->border = bd; - - return p; -} - -static int -_cb_sort(const void *data1, const void *data2) -{ - const Evry_Item *it1 = data1; - const Evry_Item *it2 = data2; - - return (it1->fuzzy_match - it2->fuzzy_match); -} - -static void -_item_add(Evry_Plugin *p, const char *label, void (*action_cb) (E_Border *bd), const char *icon, const char *input) -{ - Evry_Item *it; - int match = 1; - - if (input) - match = evry_fuzzy_match(label, input); - - if (!match) return; - - it = evry_item_new(NULL, p, label, NULL); - it->icon = eina_stringshare_add(icon); - it->data = action_cb; - it->fuzzy_match = match; - - p->items = eina_list_prepend(p->items, it); -} - -static void -_cleanup(Evry_Plugin *p) -{ - EVRY_PLUGIN_ITEMS_FREE(p); -} - -static int -_fetch(Evry_Plugin *p, const char *input) -{ - E_Zone *zone; - E_Desk *desk; - - zone = e_util_zone_current_get(e_manager_current_get()); - desk = e_desk_current_get(zone); - - _cleanup(p); - - _item_add(p, _("Switch to Window"), - _act_cb_border_switch_to, - "go-next", input); - - if (desk != inst->border->desk) - _item_add(p, _("Send to Deskop"), - _act_cb_border_to_desktop, - "go-previous", input); - - if (inst->border->iconic) - _item_add(p, _("Uniconify"), - _act_cb_border_unminimize, - "window-minimize", input); - else - _item_add(p, _("Iconify"), - _act_cb_border_minimize, - "window-minimize", input); - - if (!inst->border->fullscreen) - _item_add(p, _("Fullscreen"), - _act_cb_border_fullscreen, - "view-fullscreen", input); - else - _item_add(p, _("Unfullscreen"), - _act_cb_border_fullscreen, - "view-restore", input); - - _item_add(p, _("Close"), - _act_cb_border_close, - "window-close", input); - - if (!p->items) return 0; - - EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort); - - return 1; -} - -static int -_action(Evry_Plugin *p __UNUSED__, const Evry_Item *item) -{ - void (*border_action) (E_Border *bd); - border_action = item->data; - border_action(inst->border); - - return EVRY_ACTION_FINISHED; -} - -static Evas_Object * -_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) -{ - Evas_Object *o; - - o = evry_icon_theme_get(it->icon, e); - - return o; -} - - -static int -_exec_border_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it) -{ - E_Border *bd = it->data; - E_OBJECT_CHECK_RETURN(bd, 0); - E_OBJECT_TYPE_CHECK_RETURN(bd, E_BORDER_TYPE, 0); - - if ((bd->desktop && bd->desktop->exec) && - ((strstr(bd->desktop->exec, "%u")) || - (strstr(bd->desktop->exec, "%U")) || - (strstr(bd->desktop->exec, "%f")) || - (strstr(bd->desktop->exec, "%F")))) - return 1; - - return 0; -} - -static int -_exec_border_action(Evry_Action *act) -{ - return evry_util_exec_app(act->item1, act->item2); -} - -static int -_exec_border_intercept(Evry_Action *act) -{ - Evry_Item_App *app = E_NEW(Evry_Item_App, 1); - E_Border *bd = act->item1->data; - - app->desktop = bd->desktop; - act->item1 = EVRY_ITEM(app); - - return 1; -} - - -static void -_exec_border_cleanup(Evry_Action *act) -{ - ITEM_APP(app, act->item1); - E_FREE(app); -} - - - -static Eina_Bool -_init(void) -{ - if (!evry_api_version_check(EVRY_API_VERSION)) - return EINA_FALSE; - - plugin = evry_plugin_new(NULL, "Window Action", type_action, "BORDER", NULL, 0, NULL, NULL, - _begin, _cleanup, _fetch, _action, _item_icon_get, NULL, NULL); - - evry_plugin_register(plugin, 1); - inst = E_NEW(Inst, 1); - - act = evry_action_new("Open File...", "BORDER", "FILE", "APPLICATION", - "everything-launch", - _exec_border_action, _exec_border_check_item, - _exec_border_cleanup, _exec_border_intercept, NULL); - evry_action_register(act, 10); - - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - EVRY_PLUGIN_FREE(plugin); - E_FREE(inst); - - evry_action_free(act); -} - - -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/actions/evry_plug_clipboard.c b/src/modules/everything/actions/evry_plug_clipboard.c deleted file mode 100644 index 1ecd412901..0000000000 --- a/src/modules/everything/actions/evry_plug_clipboard.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "Evry.h" - - -static Evry_Action *act; -static Ecore_X_Window clipboard_win = 0; - -static int -_action(Evry_Action *act) -{ - const Evry_Item *it = act->item1; - - ecore_x_selection_primary_set(clipboard_win, it->label, strlen(it->label)); - ecore_x_selection_clipboard_set(clipboard_win, it->label, strlen(it->label)); - - return 1; -} - -static int -_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it) -{ - return (it && it->label && (strlen(it->label) > 0)); -} - -static Eina_Bool -_init(void) -{ - if (!evry_api_version_check(EVRY_API_VERSION)) - return EINA_FALSE; - - Ecore_X_Window win = ecore_x_window_new(0, 0, 0, 1, 1); - if (!win) return EINA_FALSE; - - act = evry_action_new("Copy to Clipboard", "TEXT", NULL, NULL, "edit-copy", - _action, _check_item, NULL, NULL, NULL); - - evry_action_register(act, 10); - - clipboard_win = win; - - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - ecore_x_window_free(clipboard_win); - evry_action_free(act); -} - -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); - diff --git a/src/modules/everything/actions/evry_plug_wallpaper.c b/src/modules/everything/actions/evry_plug_wallpaper.c deleted file mode 100644 index 9d629fa986..0000000000 --- a/src/modules/everything/actions/evry_plug_wallpaper.c +++ /dev/null @@ -1,451 +0,0 @@ -#include "Evry.h" - -#define IMPORT_STRETCH 0 -#define IMPORT_TILE 1 -#define IMPORT_CENTER 2 -#define IMPORT_SCALE_ASPECT_IN 3 -#define IMPORT_SCALE_ASPECT_OUT 4 - -typedef struct _Plugin Plugin; -typedef struct _Import Import; -typedef struct _Item Item; - -struct _Plugin -{ - Evry_Plugin base; - Plugin *prev; - Eina_List *items; - const Evry_Item_File *file; -}; - -struct _Import -{ - const char *file; - int method; - int external; - int quality; - - Ecore_Exe *exe; - Ecore_Event_Handler *exe_handler; - char *tmpf; - char *fdest; -}; - -struct _Item -{ - Evry_Item base; - const char *icon; - int method; -}; - - -static void _import_edj_gen(Import *import); -static int _import_cb_edje_cc_exit(void *data, int type, void *event); -static Import *import = NULL; - -static Evry_Plugin *plugin; - -static void -_item_free(Evry_Item *item) -{ - Item *it = (Item*) item; - E_FREE(it); -} - -static void -_item_add(Plugin *p, const char *name, int method, const char *icon) -{ - Item *item = E_NEW(Item, 1); - evry_item_new(EVRY_ITEM(item), EVRY_PLUGIN(p), name, _item_free); - - item->icon = icon; - item->method = method; - - p->items = eina_list_append(p->items, EVRY_ITEM(item)); -} - -static Evas_Object * -_item_icon_get(Evry_Plugin *plugin, const Evry_Item *item, Evas *e) -{ - return evry_icon_theme_get(((Item*)item)->icon, e); -} - -static Evas_Object * -_icon_get(Evry_Plugin *plugin, const Evry_Item *it, Evas *e) -{ - return evry_icon_theme_get("preferences-desktop-wallpaper", e); -} - -static Evry_Plugin * -_begin(Evry_Plugin *plugin, const Evry_Item *item) -{ - PLUGIN(p, plugin); - - if (!item) return NULL; - - /* is FILE ? */ - if (item->plugin->type_out == plugin->type_in) - { - Evry_Item *it; - ITEM_FILE(file, item); - - if (!file->mime || (strncmp(file->mime, "image/", 6))) - return NULL; - - p = E_NEW(Plugin, 1); - p->base = *plugin; - p->base.items = NULL; - p->file = file; - - it = evry_item_new(NULL, EVRY_PLUGIN(p), _("Set as Wallpaper"), NULL); - it->browseable = EINA_TRUE; - - p->items = eina_list_append(p->items, it); - - return EVRY_PLUGIN(p); - } - else if (item->plugin->type_out == plugin->type_out) - { - p = E_NEW(Plugin, 1); - p->base = *plugin; - p->base.items = NULL; - p->base.icon_get = &_item_icon_get; - p->prev = (Plugin*) item->plugin; - - _item_add(p, _("Stretch"), IMPORT_STRETCH, - "enlightenment/wallpaper_stretch"); - _item_add(p, _("Center"), IMPORT_CENTER, - "enlightenment/wallpaper_center"); - _item_add(p, _("Tile"), IMPORT_TILE, - "enlightenment/wallpaper_tile"); - _item_add(p, _("Within"), IMPORT_SCALE_ASPECT_IN, - "enlightenment/wallpaper_scale_aspect_in"); - _item_add(p, _("Fill"), IMPORT_SCALE_ASPECT_OUT, - "enlightenment/wallpaper_stretch"); - - return EVRY_PLUGIN(p); - } - - return NULL; -} - -static void -_cleanup(Evry_Plugin *plugin) -{ - PLUGIN(p, plugin); - Evry_Item *it; - - EVRY_PLUGIN_ITEMS_CLEAR(p); - - EINA_LIST_FREE(p->items, it) - evry_item_free(it); - - E_FREE(p); -} - -static int -_fetch(Evry_Plugin *plugin, const char *input) -{ - PLUGIN(p, plugin); - Evry_Item *it = NULL; - Eina_List *l; - int match = 0; - - EVRY_PLUGIN_ITEMS_CLEAR(p); - - EINA_LIST_FOREACH(p->items, l, it) - if (!input || (match = evry_fuzzy_match(it->label, input))) - { - it->fuzzy_match = match; - EVRY_PLUGIN_ITEM_APPEND(p, it); - } - - if (input) - plugin->items = evry_fuzzy_match_sort(plugin->items); - - return 1; -} - -static int -_action(Evry_Plugin *plugin, const Evry_Item *item) -{ - PLUGIN(p, plugin); - - if (p->prev && p->prev->file) - { - if (import) - { - if (import->exe_handler) - ecore_event_handler_del(import->exe_handler); - E_FREE(import); - } - - Item *it = (Item*) item; - import = E_NEW(Import, 1); - import->method = it->method; - import->file = p->prev->file->path; - import->quality = 100; - import->external = 0; - _import_edj_gen(import); - - return 1; - } - - return 0; -} - -static Eina_Bool -_init(void) -{ - if (!evry_api_version_check(EVRY_API_VERSION)) - return EINA_FALSE; - - plugin = evry_plugin_new(NULL, "Wallpaper", type_action, "FILE", "", - 0, "preferences-desktop-wallpaper", NULL, - _begin, _cleanup, _fetch, _action, _icon_get, - NULL, NULL); - - evry_plugin_register(plugin, 10); - - - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - EVRY_PLUGIN_FREE(plugin); - - if (import) - { - if (import->exe_handler) - ecore_event_handler_del(import->exe_handler); - E_FREE(import); - } -} - - -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); - - - -/* taken from e_int_config_wallpaper_import.c */ -static void -_import_edj_gen(Import *import) -{ - Ecore_Evas *ee = ecore_evas_buffer_new(100, 100); - Evas *evas = ecore_evas_get(ee); - Evas_Object *img; - int fd, num = 1; - int w = 0, h = 0; - const char *file, *locale; - char buf[4096], cmd[4096], tmpn[4096], ipart[4096], enc[128]; - char *imgdir = NULL, *fstrip; - int cr = 255, cg = 255, cb = 255, ca = 255; - FILE *f; - size_t len, off; - - file = ecore_file_file_get(import->file); - fstrip = ecore_file_strip_ext(file); - if (!fstrip) return; - len = e_user_dir_snprintf(buf, sizeof(buf), "backgrounds/%s.edj", fstrip); - if (len >= sizeof(buf)) return; - off = len - (sizeof(".edj") - 1); - while (ecore_file_exists(buf)) - { - snprintf(buf + off, sizeof(buf) - off, "-%d.edj", num); - num++; - } - free(fstrip); - strcpy(tmpn, "/tmp/e_bgdlg_new.edc-tmp-XXXXXX"); - fd = mkstemp(tmpn); - if (fd < 0) - { - printf("Error Creating tmp file: %s\n", strerror(errno)); - return; - } - close(fd); - - f = fopen(tmpn, "w"); - if (!f) - { - printf("Cannot open %s for writing\n", tmpn); - return; - } - - imgdir = ecore_file_dir_get(import->file); - if (!imgdir) ipart[0] = '\0'; - else - { - snprintf(ipart, sizeof(ipart), "-id %s", e_util_filename_escape(imgdir)); - free(imgdir); - } - - img = evas_object_image_add(evas); - evas_object_image_file_set(img, import->file, NULL); - evas_object_image_size_get(img, &w, &h); - evas_object_del(img); - ecore_evas_free(ee); - - printf("w%d h%d\n", w, h); - - if (import->external) - { - fstrip = strdup(e_util_filename_escape(import->file)); - snprintf(enc, sizeof(enc), "USER"); - } - else - { - fstrip = strdup(e_util_filename_escape(file)); - if (import->quality == 100) - snprintf(enc, sizeof(enc), "COMP"); - else - snprintf(enc, sizeof(enc), "LOSSY %i", import->quality); - } - switch (import->method) - { - case IMPORT_STRETCH: - fprintf(f, - "images { image: \"%s\" %s; }\n" - "collections {\n" - "group { name: \"e/desktop/background\";\n" - "data { item: \"style\" \"0\"; }\n" - "max: %i %i;\n" - "parts {\n" - "part { name: \"bg\"; mouse_events: 0;\n" - "description { state: \"default\" 0.0;\n" - "image { normal: \"%s\"; scale_hint: STATIC; }\n" - "} } } } }\n" - , fstrip, enc, w, h, fstrip); - break; - case IMPORT_TILE: - fprintf(f, - "images { image: \"%s\" %s; }\n" - "collections {\n" - "group { name: \"e/desktop/background\";\n" - "data { item: \"style\" \"1\"; }\n" - "max: %i %i;\n" - "parts {\n" - "part { name: \"bg\"; mouse_events: 0;\n" - "description { state: \"default\" 0.0;\n" - "image { normal: \"%s\"; }\n" - "fill { size {\n" - "relative: 0.0 0.0;\n" - "offset: %i %i;\n" - "} } } } } } }\n" - , fstrip, enc, w, h, fstrip, w, h); - break; - case IMPORT_CENTER: - fprintf(f, - "images { image: \"%s\" %s; }\n" - "collections {\n" - "group { name: \"e/desktop/background\";\n" - "data { item: \"style\" \"2\"; }\n" - "max: %i %i;\n" - "parts {\n" - "part { name: \"col\"; type: RECT; mouse_events: 0;\n" - "description { state: \"default\" 0.0;\n" - "color: %i %i %i %i;\n" - "} }\n" - "part { name: \"bg\"; mouse_events: 0;\n" - "description { state: \"default\" 0.0;\n" - "min: %i %i; max: %i %i;\n" - "image { normal: \"%s\"; }\n" - "} } } } }\n" - , fstrip, enc, w, h, cr, cg, cb, ca, w, h, w, h, fstrip); - break; - case IMPORT_SCALE_ASPECT_IN: - locale = e_intl_language_get(); - setlocale(LC_NUMERIC, "C"); - fprintf(f, - "images { image: \"%s\" %s; }\n" - "collections {\n" - "group { name: \"e/desktop/background\";\n" - "data { item: \"style\" \"3\"; }\n" - "max: %i %i;\n" - "parts {\n" - "part { name: \"col\"; type: RECT; mouse_events: 0;\n" - "description { state: \"default\" 0.0;\n" - "color: %i %i %i %i;\n" - "} }\n" - "part { name: \"bg\"; mouse_events: 0;\n" - "description { state: \"default\" 0.0;\n" - "aspect: %1.9f %1.9f; aspect_preference: BOTH;\n" - "image { normal: \"%s\"; scale_hint: STATIC; }\n" - "} } } } }\n" - , fstrip, enc, w, h, cr, cg, cb, ca, (double)w / (double)h, (double)w / (double)h, fstrip); - setlocale(LC_NUMERIC, locale); - break; - case IMPORT_SCALE_ASPECT_OUT: - locale = e_intl_language_get(); - setlocale(LC_NUMERIC, "C"); - fprintf(f, - "images { image: \"%s\" %s; }\n" - "collections {\n" - "group { name: \"e/desktop/background\";\n" - "data { item: \"style\" \"4\"; }\n" - "max: %i %i;\n" - "parts {\n" - "part { name: \"bg\"; mouse_events: 0;\n" - "description { state: \"default\" 0.0;\n" - "aspect: %1.9f %1.9f; aspect_preference: NONE;\n" - "image { normal: \"%s\"; scale_hint: STATIC; }\n" - "} } } } }\n" - , fstrip, enc, w, h, (double)w / (double)h, (double)w / (double)h, fstrip); - setlocale(LC_NUMERIC, locale); - break; - default: - /* won't happen */ - break; - } - free(fstrip); - - fclose(f); - - snprintf(cmd, sizeof(cmd), "edje_cc -v %s %s %s", - ipart, tmpn, e_util_filename_escape(buf)); - - import->tmpf = strdup(tmpn); - import->fdest = strdup(buf); - import->exe_handler = - ecore_event_handler_add(ECORE_EXE_EVENT_DEL, - _import_cb_edje_cc_exit, import); - import->exe = ecore_exe_run(cmd, NULL); -} - -static int -_import_cb_edje_cc_exit(void *data, int type, void *event) -{ - Import *import; - Ecore_Exe_Event_Del *ev; - char *fdest; - int r = 1; - - ev = event; - import = data; - - if (!ev->exe) return 1; - - if (ev->exe != import->exe) return 1; - - if (ev->exit_code != 0) - { - e_util_dialog_show(_("Picture Import Error"), - _("Enlightenment was unable to import the picture<br>" - "due to conversion errors.")); - r = 0; - } - - - fdest = strdup(import->fdest); - if (r) - { - e_bg_default_set(fdest); - e_bg_update(); - } - - E_FREE(fdest); - - return 0; -} diff --git a/src/modules/everything/e_mod_main.c b/src/modules/everything/e_mod_main.c index 7e7811547b..adb383288f 100644 --- a/src/modules/everything/e_mod_main.c +++ b/src/modules/everything/e_mod_main.c @@ -9,6 +9,9 @@ #include "e_mod_main.h" +/* #undef DBG + * #define DBG(...) ERR(__VA_ARGS__) */ + #define CONFIG_VERSION 7 /* actual module specifics */ @@ -22,14 +25,14 @@ static void _config_free(void); static E_Int_Menu_Augmentation *maug = NULL; static E_Action *act = NULL; -static Eina_Array *plugins = NULL; +/* static Eina_Array *plugins = NULL; */ static E_Config_DD *conf_edd = NULL; static E_Config_DD *conf_item_edd = NULL; EAPI int _e_module_evry_log_dom = -1; -EAPI Config *evry_conf = NULL; +EAPI Evry_Config *evry_conf = NULL; EAPI int EVRY_EVENT_ITEM_SELECT; EAPI int EVRY_EVENT_ITEM_CHANGED; @@ -42,19 +45,6 @@ EAPI E_Module_Api e_modapi = "Everything" }; -static Eina_Bool list_cb(Eina_Module *m, void *data) -{ - int err; - - if ((err = eina_module_load(m))) - { - return EINA_TRUE; - } - - ERR("loading failed (%d), %s", err, eina_module_file_get(m)); - return EINA_FALSE; -} - EAPI void * e_modapi_init(E_Module *m) { @@ -78,34 +68,11 @@ e_modapi_init(E_Module *m) _config_init(); evry_history_init(); - - snprintf(dir, sizeof(dir), "%s/enlightenment/modules/everything/plugins", - e_prefix_lib_get()); - files = ecore_file_ls(dir); - EINA_LIST_FREE(files, file) - { - snprintf(buf, sizeof(buf), "%s/%s/%s", dir, file, MODULE_ARCH); - - if (ecore_file_is_dir(buf)) - plugins = eina_module_list_get(plugins, buf, 1, &list_cb, NULL); - - free(file); - } - - snprintf(dir, sizeof(dir), "%s/.e/e/modules/everything/plugins", - e_user_homedir_get()); - files = ecore_file_ls(dir); - - EINA_LIST_FREE(files, file) - { - snprintf(buf, sizeof(buf), "%s/%s/%s", dir, file, MODULE_ARCH); - - if (ecore_file_is_dir(buf)) - plugins = eina_module_list_get(plugins, buf, 1, &list_cb, NULL); - - free(file); - } + view_thumb_init(); + view_preview_init(); + view_help_init(); + evry_plug_clipboard_init(); /* add module supplied action */ act = e_action_add("everything"); @@ -137,8 +104,13 @@ e_modapi_init(E_Module *m) if (!EVRY_EVENT_ITEM_CHANGED) EVRY_EVENT_ITEM_CHANGED = ecore_event_type_new(); - e_module_delayed_set(m, 1); + e_module_delayed_set(m, 0); + + /* make sure module is loaded before others */ + e_module_priority_set(m, -1000); + e_datastore_set("everything_loaded", ""); + return m; } @@ -162,14 +134,12 @@ e_modapi_shutdown(E_Module *m __UNUSED__) e_action_del("everything"); } - if (plugins) - { - eina_module_list_free(plugins); - eina_array_free(plugins); - plugins = NULL; - } - + view_thumb_shutdown(); + view_preview_shutdown(); + view_help_shutdown(); + evry_plug_clipboard_shutdown(); + while ((cfd = e_config_dialog_get("E", "_config_everything_dialog"))) e_object_del(E_OBJECT(cfd)); @@ -182,6 +152,9 @@ e_modapi_shutdown(E_Module *m __UNUSED__) /* Clean EET */ E_CONFIG_DD_FREE(conf_item_edd); E_CONFIG_DD_FREE(conf_edd); + + e_datastore_del("everything_loaded"); + return 1; } @@ -210,9 +183,9 @@ _config_init() #undef T #undef D -#define T Config +#define T Evry_Config #define D conf_edd - conf_edd = E_CONFIG_DD_NEW("Config", Config); + conf_edd = E_CONFIG_DD_NEW("Config", Evry_Config); E_CONFIG_VAL(D, T, version, INT); E_CONFIG_VAL(D, T, width, INT); E_CONFIG_VAL(D, T, height, INT); @@ -245,7 +218,7 @@ _config_init() if (!evry_conf) { - evry_conf = E_NEW(Config, 1); + evry_conf = E_NEW(Evry_Config, 1); evry_conf->version = CONFIG_VERSION; evry_conf->rel_x = 0.5; evry_conf->rel_y = 0.33; @@ -368,8 +341,6 @@ _e_mod_menu_add(void *data __UNUSED__, E_Menu *m) } - - EAPI int evry_api_version_check(int version) { if (EVRY_API_VERSION == version) @@ -423,6 +394,8 @@ evry_plugin_new(Evry_Plugin *base, const char *name, int type, p->config_apply = config_apply; p->aggregate = EINA_TRUE; p->async_fetch = EINA_FALSE; + + DBG("%s", p->name); return p; } @@ -432,6 +405,8 @@ evry_plugin_free(Evry_Plugin *p, int free_pointer) { evry_plugin_unregister(p); + DBG("%s", p->name); + if (p->name) eina_stringshare_del(p->name); if (p->type_in) eina_stringshare_del(p->type_in); if (p->type_out) eina_stringshare_del(p->type_out); @@ -462,6 +437,8 @@ evry_action_new(const char *name, const char *type_in1, const char *type_in2, act->cleanup = cleanup; act->icon = (icon ? eina_stringshare_add(icon) : NULL); + DBG("%s", name); + return act; } @@ -487,6 +464,8 @@ evry_plugin_register(Evry_Plugin *p, int priority) Eina_List *l, *confs = NULL; Plugin_Config *pc; + DBG("%s", p->name); + evry_conf->plugins = eina_list_append(evry_conf->plugins, p); if (p->type == type_subject) @@ -539,6 +518,8 @@ evry_plugin_register(Evry_Plugin *p, int priority) void evry_plugin_unregister(Evry_Plugin *p) { + DBG("%s", p->name); + evry_conf->plugins = eina_list_remove(evry_conf->plugins, p); if (p->type == type_subject) diff --git a/src/modules/everything/e_mod_main.h b/src/modules/everything/e_mod_main.h index 96489e22ab..ed543e69a6 100644 --- a/src/modules/everything/e_mod_main.h +++ b/src/modules/everything/e_mod_main.h @@ -4,80 +4,9 @@ #define E_MOD_MAIN_H -typedef struct _Config Config; typedef struct _Evry_Selector Evry_Selector; typedef struct _Tab_View Tab_View; -typedef struct _History History; -typedef struct _History_Entry History_Entry; -typedef struct _History_Item History_Item; -struct _Config -{ - int version; - /* position */ - double rel_x, rel_y; - /* size */ - int width, height; - - /* generic plugin config */ - Eina_List *conf_subjects; - Eina_List *conf_actions; - Eina_List *conf_objects; - Eina_List *conf_views; - - int scroll_animate; - double scroll_speed; - - int hide_input; - int hide_list; - - int quick_nav; - - const char *cmd_terminal; - const char *cmd_sudo; - - int view_mode; - int view_zoom; - - int history_sort_mode; - - /* use up/down keys for prev/next in thumb view */ - int cycle_mode; - - /* not saved data */ - Eina_List *plugins; - Eina_List *actions; - Eina_List *views; - - int min_w, min_h; -}; - - - -struct _History_Item -{ - const char *plugin; - const char *context; - const char *input; - double last_used; - double usage; - int count; - int transient; -}; - -struct _History_Entry -{ - Eina_List *items; -}; - -struct _History -{ - int version; - Eina_Hash *subjects; - Eina_Hash *actions; - double begin; -}; - struct _Evry_Selector { @@ -137,6 +66,18 @@ EAPI E_Config_Dialog *evry_config_dialog(E_Container *con, const char *params); EAPI Tab_View *evry_tab_view_new(const Evry_State *s, Evas *e); EAPI void evry_tab_view_free(Tab_View *v); +Eina_Bool view_thumb_init(void); +void view_thumb_shutdown(void); + +Eina_Bool view_help_init(void); +void view_help_shutdown(void); + +Eina_Bool view_preview_init(void); +void view_preview_shutdown(void); + +Eina_Bool evry_plug_clipboard_init(void); +void evry_plug_clipboard_shutdown(void); + int evry_init(void); int evry_shutdown(void); int evry_show(E_Zone *zone, const char *params); @@ -150,16 +91,11 @@ EAPI void evry_plug_actions_free(Evry_Plugin *plugin); void evry_history_init(void); void evry_history_free(void); -EAPI void evry_history_load(void); -EAPI void evry_history_unload(void); -EAPI void evry_history_add(Eina_Hash *hist, Evry_State *s, const char *ctxt); -EAPI int evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, const char *ctxt); EAPI int evry_browse_item(Evry_Selector *sel); void evry_browse_back(Evry_Selector *sel); -EAPI extern Config *evry_conf; -EAPI extern History *evry_hist; extern Evry_Selector **selectors; extern const char *action_selector; + #endif diff --git a/src/modules/everything/evry_history.c b/src/modules/everything/evry_history.c index 4bb602218a..99bcc6a945 100644 --- a/src/modules/everything/evry_history.c +++ b/src/modules/everything/evry_history.c @@ -20,7 +20,7 @@ static E_Config_DD *hist_entry_edd = NULL; static E_Config_DD *hist_item_edd = NULL; static E_Config_DD *hist_edd = NULL; -History *evry_hist = NULL; +Evry_History *evry_hist = NULL; void evry_history_init(void) @@ -45,8 +45,8 @@ evry_history_init(void) E_CONFIG_LIST(D, T, items, hist_item_edd); #undef T #undef D - hist_edd = E_CONFIG_DD_NEW("History", History); -#define T History + hist_edd = E_CONFIG_DD_NEW("History", Evry_History); +#define T Evry_History #define D hist_edd E_CONFIG_VAL(D, T, version, INT); E_CONFIG_VAL(D, T, begin, DOUBLE); @@ -177,7 +177,7 @@ evry_history_load(void) if (!evry_hist) { - evry_hist = E_NEW(History, 1); + evry_hist = E_NEW(Evry_History, 1); evry_hist->version = HISTORY_VERSION; evry_hist->begin = ecore_time_get(); } diff --git a/src/modules/everything/sources/Makefile.am b/src/modules/everything/sources/Makefile.am deleted file mode 100644 index f9d2bfb85f..0000000000 --- a/src/modules/everything/sources/Makefile.am +++ /dev/null @@ -1,64 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in -MODULE = everything - -# the module .so file -INCLUDES = -I.. \ - -I$(top_srcdir) \ - -I$(top_srcdir)/src/modules/$(MODULE) \ - -I$(top_srcdir)/src/bin \ - -I$(top_srcdir)/src/lib \ - -I$(top_srcdir)/src/modules \ - @e_cflags@ - -plugindir = $(libdir)/enlightenment/modules/$(MODULE)/plugins/core/$(MODULE_ARCH) - -evry_plug_appsdir = $(plugindir) -evry_plug_apps_LTLIBRARIES = evry_plug_apps.la -evry_plug_apps_la_SOURCES = evry_plug_apps.c -evry_plug_apps_la_LIBADD = @e_libs@ ../libfoo.la -evry_plug_apps_la_LDFLAGS = -module -avoid-version -evry_plug_apps_la_LIBTOOLFLAGS = --tag=disable-static - -evry_plug_borderdir = $(plugindir) -evry_plug_border_LTLIBRARIES = evry_plug_border.la -evry_plug_border_la_SOURCES = evry_plug_border.c -evry_plug_border_la_LIBADD = @e_libs@ ../libfoo.la -evry_plug_border_la_LDFLAGS = -module -avoid-version -evry_plug_border_la_LIBTOOLFLAGS = --tag=disable-static - -evry_plug_dir_browsedir = $(plugindir) -evry_plug_dir_browse_LTLIBRARIES = evry_plug_dir_browse.la -evry_plug_dir_browse_la_SOURCES = evry_plug_dir_browse.c -evry_plug_dir_browse_la_LIBADD = @e_libs@ ../libfoo.la -evry_plug_dir_browse_la_LDFLAGS = -module -avoid-version -evry_plug_dir_browse_la_LIBTOOLFLAGS = --tag=disable-static - -evry_plug_calcdir = $(plugindir) -evry_plug_calc_LTLIBRARIES = evry_plug_calc.la -evry_plug_calc_la_SOURCES = evry_plug_calc.c -evry_plug_calc_la_LIBADD = @e_libs@ ../libfoo.la -evry_plug_calc_la_LDFLAGS = -module -avoid-version -evry_plug_calc_la_LIBTOOLFLAGS = --tag=disable-static - -evry_plug_configdir = $(plugindir) -evry_plug_config_LTLIBRARIES = evry_plug_config.la -evry_plug_config_la_SOURCES = evry_plug_config.c -evry_plug_config_la_LIBADD = @e_libs@ ../libfoo.la -evry_plug_config_la_LDFLAGS = -module -avoid-version -evry_plug_config_la_LIBTOOLFLAGS = --tag=disable-static - -evry_plug_aspelldir = $(plugindir) -evry_plug_aspell_LTLIBRARIES = evry_plug_aspell.la -evry_plug_aspell_la_SOURCES = evry_plug_aspell.c -evry_plug_aspell_la_LIBADD = @e_libs@ ../libfoo.la -evry_plug_aspell_la_LDFLAGS = -module -avoid-version -evry_plug_aspell_la_LIBTOOLFLAGS = --tag=disable-static - -evry_plug_textdir = $(plugindir) -evry_plug_text_LTLIBRARIES = evry_plug_text.la -evry_plug_text_la_SOURCES = evry_plug_text.c -evry_plug_text_la_LIBADD = @e_libs@ ../libfoo.la -evry_plug_text_la_LDFLAGS = -module -avoid-version -evry_plug_text_la_LIBTOOLFLAGS = --tag=disable-static - - diff --git a/src/modules/everything/sources/evry_plug_apps.c b/src/modules/everything/sources/evry_plug_apps.c deleted file mode 100644 index 6b81dee34b..0000000000 --- a/src/modules/everything/sources/evry_plug_apps.c +++ /dev/null @@ -1,992 +0,0 @@ -#include "e_mod_main.h" - - -typedef struct _Plugin Plugin; - -struct _Plugin -{ - Evry_Plugin base; - Eina_List *apps_mime; - Eina_List *apps_all; - Eina_List *apps_hist; - const Evry_Item *candidate; - Eina_Hash *added; -}; - -/* taken from exebuf module */ -typedef struct _E_Exe E_Exe; -typedef struct _E_Exe_List E_Exe_List; - -struct _E_Exe -{ - const char *path; -}; - -struct _E_Exe_List -{ - Eina_List *list; -}; - -static Plugin *p1 = NULL; -static Plugin *p2 = NULL; -static Evry_Action *act = NULL; -static Evry_Action *act1 = NULL; -static Evry_Action *act2 = NULL; -static Evry_Action *act3 = NULL; -static Evry_Action *act4 = NULL; -static Evry_Action *act5 = NULL; - -static Eina_List *exe_path = NULL; -static Ecore_Idler *exe_scan_idler = NULL; -static E_Config_DD *exelist_exe_edd = NULL; -static E_Config_DD *exelist_edd = NULL; -static DIR *exe_dir = NULL; -static Eina_List *exe_list = NULL; -static Eina_List *exe_list2 = NULL; - -static int _scan_idler(void *data); - -static void _hash_free(void *data) -{ - ITEM_APP(app, data); - evry_item_free(EVRY_ITEM(app)); -} - - -static Evry_Plugin * -_begin_open_with(Evry_Plugin *plugin, const Evry_Item *item) -{ - PLUGIN(p, plugin); - - const char *mime; - - if (!item) return 0; - - ITEM_FILE(file, item); - Efreet_Desktop *d, *d2; - - if (!file->path) return NULL; - - if (!file->mime) - mime = efreet_mime_type_get(file->path); - else - mime = file->mime; - - if (!mime) return NULL; - - p->candidate = item; - - p->apps_mime = efreet_util_desktop_mime_list(mime); - - if (strcmp(mime, "text/plain") && - !strncmp(mime, "text/", 5)) - { - Eina_List *tmp; - tmp = efreet_util_desktop_mime_list("text/plain"); - - EINA_LIST_FREE(tmp, d) - { - if (!eina_list_data_find_list(p->apps_mime, d)) - p->apps_mime = eina_list_append(p->apps_mime, d); - else - efreet_desktop_free(d); - } - } - - d = e_exehist_mime_desktop_get(mime); - if (d) - { - if (d2 = eina_list_data_find(p->apps_mime, d)) - { - p->apps_mime = eina_list_remove(p->apps_mime, d2); - efreet_desktop_free(d2); - } - - p->apps_mime = eina_list_prepend(p->apps_mime, d); - } - - p->added = eina_hash_string_small_new(_hash_free); - - return plugin; -} - -static Evry_Plugin * -_begin(Evry_Plugin *plugin, const Evry_Item *item) -{ - PLUGIN(p, plugin); - - /* taken from exebuf module */ - char *path, *pp, *last; - E_Exe_List *el; - - el = e_config_domain_load("exebuf_exelist_cache", exelist_edd); - if (el) - { - E_Exe *ee; - - EINA_LIST_FREE(el->list, ee) - { - exe_list = eina_list_append(exe_list, strdup(ee->path)); - eina_stringshare_del(ee->path); - free(ee); - } - free(el); - } - path = getenv("PATH"); - if (path) - { - path = strdup(path); - last = path; - for (pp = path; pp[0]; pp++) - { - if (pp[0] == ':') pp[0] = '\0'; - if (pp[0] == 0) - { - exe_path = eina_list_append(exe_path, strdup(last)); - last = pp + 1; - } - } - if (pp > last) - exe_path = eina_list_append(exe_path, strdup(last)); - free(path); - } - - exe_scan_idler = ecore_idler_add(_scan_idler, NULL); - - p->added = eina_hash_string_small_new(_hash_free); - - return plugin; -} - -static void -_item_free(Evry_Item *item) -{ - ITEM_APP(app, item); - - if (app->desktop) - efreet_desktop_free(app->desktop); - if (app->file) - eina_stringshare_del(app->file); - - E_FREE(app); -} - -static void -_cleanup(Evry_Plugin *plugin) -{ - PLUGIN(p, plugin); - Efreet_Desktop *desktop; - - if (p->added) - eina_hash_free(p->added); - - EVRY_PLUGIN_ITEMS_CLEAR(p); - - EINA_LIST_FREE(p->apps_all, desktop) - efreet_desktop_free(desktop); - - EINA_LIST_FREE(p->apps_hist, desktop) - efreet_desktop_free(desktop); - - if (plugin->type == type_action) - { - EINA_LIST_FREE(p->apps_mime, desktop) - efreet_desktop_free(desktop); - } - else - { - char *str; - - if (exe_dir) - { - closedir(exe_dir); - exe_dir = NULL; - } - EINA_LIST_FREE(exe_path, str) - free(str); - - if (exe_scan_idler) - { - ecore_idler_del(exe_scan_idler); - exe_scan_idler = NULL; - } - EINA_LIST_FREE(exe_list, str) - free(str); - EINA_LIST_FREE(exe_list2, str) - free(str); - } -} - -static Evry_Item_App * -_item_add(Plugin *p, Efreet_Desktop *desktop, char *file, int match) -{ - Evry_Item_App *app; - Efreet_Desktop *d2; - int already_refd = 0; - char *exe; - - if (file) - { - Eina_List *l; - int len; - char buf[1024]; - char *tmp; - - if ((app = eina_hash_find(p->added, file))) - { - if (!eina_list_data_find_list(EVRY_PLUGIN(p)->items, app)) - { - EVRY_ITEM(app)->fuzzy_match = match; - EVRY_ITEM(app)->plugin = EVRY_PLUGIN(p); - EVRY_PLUGIN_ITEM_APPEND(p, app); - } - return app; - } - - len = strlen(file); - tmp = ecore_file_app_exe_get(file); - snprintf(buf, sizeof(buf), "%s*", tmp); - l = efreet_util_desktop_exec_glob_list(buf); - - EINA_LIST_FREE(l, d2) - { - if (!desktop && d2->exec && !strncmp(file, d2->exec, len)) - { - desktop = d2; - already_refd = 1; - efreet_desktop_ref(desktop); - } - efreet_desktop_free(d2); - } - free(tmp); - } - - if (desktop) - exe = desktop->exec; - else - exe = file; - - if (!exe) return NULL; - - if (app = eina_hash_find(p->added, exe)) - { - if (!desktop || (!app->desktop) || - (desktop == app->desktop) || - (!strcmp(desktop->exec, app->desktop->exec))) - { - if (!eina_list_data_find_list(EVRY_PLUGIN(p)->items, app)) - { - EVRY_ITEM(app)->fuzzy_match = match; - EVRY_ITEM(app)->plugin = EVRY_PLUGIN(p); - EVRY_PLUGIN_ITEM_APPEND(p, app); - } - return app; - } - } - if (desktop && !already_refd) - efreet_desktop_ref(desktop); - - app = E_NEW(Evry_Item_App, 1); - - if (desktop) - { - evry_item_new(EVRY_ITEM(app), EVRY_PLUGIN(p), desktop->name, _item_free); - EVRY_ITEM(app)->id = eina_stringshare_add(desktop->exec); - } - else - { - evry_item_new(EVRY_ITEM(app), EVRY_PLUGIN(p), file, _item_free); - EVRY_ITEM(app)->id = eina_stringshare_add(file); - } - - app->desktop = desktop; - - eina_hash_add(p->added, exe, app); - - if (desktop) - { - const char *tmp = ecore_file_file_get(desktop->exec); - - if (tmp && strcmp(exe, tmp)) - { - evry_item_ref(EVRY_ITEM(app)); - eina_hash_add(p->added, tmp, app); - } - } - - if (file) - { - app->file = eina_stringshare_add(file); - - if (strcmp(exe, file)) - { - evry_item_ref(EVRY_ITEM(app)); - eina_hash_add(p->added, file, app); - } - } - - EVRY_ITEM(app)->fuzzy_match = match; - EVRY_PLUGIN_ITEM_APPEND(p, app); - - return app; -} - -static void -_add_desktop_list(Plugin *p, Eina_List *apps, const char *input) -{ - Efreet_Desktop *desktop; - Eina_List *l; - int m1, m2; - - EINA_LIST_FOREACH(apps, l, desktop) - { - if (eina_list_count(EVRY_PLUGIN(p)->items) > 199) break; - if (!desktop->name || !desktop->exec) continue; - - if (input) - { - char *exec = strrchr(desktop->exec, '/'); - if (!exec++ || !exec) exec = desktop->exec; - - m1 = evry_fuzzy_match(exec, input); - m2 = evry_fuzzy_match(desktop->name, input); - - if (!m1 || (m2 && m2 < m1)) - m1 = m2; - } - - if (!input || m1) _item_add(p, desktop, NULL, m1); - } -} - -static int -_cb_sort(const void *data1, const void *data2) -{ - const Evry_Item *it1 = data1; - const Evry_Item *it2 = data2; - - if (it1->usage && it2->usage) - return (it1->usage > it2->usage ? -1 : 1); - if (it1->usage && !it2->usage) - return -1; - if (it2->usage && !it1->usage) - return 1; - - if (it1->fuzzy_match || it2->fuzzy_match) - { - if (it1->fuzzy_match && !it2->fuzzy_match) - return -1; - - if (!it1->fuzzy_match && it2->fuzzy_match) - return 1; - - if (it1->fuzzy_match - it2->fuzzy_match) - return (it1->fuzzy_match - it2->fuzzy_match); - } - - return 0; -} - -static Eina_Bool -_hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata) -{ - History_Entry *he = data; - History_Item *hi; - Plugin *p = fdata; - Efreet_Desktop *d; - Eina_List *l; - Evry_Item_App *app; - - EINA_LIST_FOREACH(he->items, l, hi) - { - if (hi->plugin != p->base.name) - continue; - - if ((d = efreet_util_desktop_exec_find(key))) - { - app = _item_add(p, d, NULL, 1); - } - else - { - app = _item_add(p, NULL, (char *) key, 1); - if (app && app->desktop) - efreet_desktop_ref(app->desktop); - } - - if (app && app->desktop) - { - p->apps_hist = eina_list_append(p->apps_hist, app->desktop); - } - - if (app) break; - } - return EINA_TRUE; -} - -static int -_fetch(Evry_Plugin *plugin, const char *input) -{ - PLUGIN(p, plugin); - Eina_List *l; - Efreet_Desktop *desktop; - Evry_Item *it; - char *file; - int prio = 0; - int len = input ? strlen(input) : 0; - - EVRY_PLUGIN_ITEMS_CLEAR(p); - - /* add apps for a given mimetype */ - if (plugin->type == type_action) - _add_desktop_list(p, p->apps_mime, input); - - /* add apps matching input */ - if (input) - { - if (!p->apps_all) - { - Eina_List *apps = NULL; - Eina_List *cat_ss, *cat_app, *cat_sys, *cat_set; - Eina_List *l, *ll; - - apps = efreet_util_desktop_name_glob_list("*"); - - /* remove screensaver */ - cat_ss = efreet_util_desktop_category_list("Screensaver"); - EINA_LIST_FOREACH(cat_ss, l, desktop) - { - if ((ll = eina_list_data_find_list(apps, desktop))) - { - efreet_desktop_free(desktop); - apps = eina_list_remove_list(apps, ll); - } - efreet_desktop_free(desktop); - } - - p->apps_all = apps; - } - - _add_desktop_list(p, p->apps_all, input); - } - /* add exe history items */ - else if (!plugin->items) - { - if (!p->apps_hist) - eina_hash_foreach(evry_hist->subjects, _hist_items_add_cb, p); - else - _add_desktop_list(p, p->apps_hist, NULL); - } - - /* add executables */ - if (input && len > 2) - { - char *space; - Evry_Item_App *app; - char buf[256]; - if ((space = strchr(input, ' '))) - len = (space - input); - - EINA_LIST_FOREACH(exe_list, l, file) - { - if (!strncmp(file, input, len)) - { - app = _item_add(p, NULL, file, 100); - - if (!app) continue; - - if (space) - { - eina_stringshare_del(EVRY_ITEM(app)->label); - snprintf(buf, sizeof(buf), "%s%s", file, space); - EVRY_ITEM(app)->label = eina_stringshare_add(buf); - eina_stringshare_del(app->file); - app->file = eina_stringshare_add(buf); - } - } - } - } - - if (!plugin->items) return 0; - - if (plugin->type == type_action) - { - EINA_LIST_FOREACH(plugin->items, l, it) - evry_history_item_usage_set(evry_hist->actions, it, input, NULL); - } - else - { - EINA_LIST_FOREACH(plugin->items, l, it) - evry_history_item_usage_set(evry_hist->subjects, it, input, NULL); - } - - if (plugin->type != type_action || input) - EVRY_PLUGIN_ITEMS_SORT(plugin, _cb_sort); - - return 1; -} - -static Evas_Object * -_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) -{ - ITEM_APP(app, it); - Evas_Object *o = NULL; - - if (app->desktop) - o = e_util_desktop_icon_add(app->desktop, 64, e); - - if (!o) - o = evry_icon_theme_get("system-run", e); - - return o; -} - -static int -_exec_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it) -{ - /* ITEM_APP(app, it); */ - - /* if (app->desktop) - * return 1; */ - - /* run in terminal or do a .desktop entry! it's easy now */ - /* if (app->file && strlen(app->file) > 0) - * return 1; */ - - return 1; -} - -static int -_exec_app_action(Evry_Action *act) -{ - return evry_util_exec_app(act->item1, act->item2); -} - -static int -_exec_term_action(Evry_Action *act) -{ - ITEM_APP(app, act->item1); - Evry_Item_App *tmp; - char buf[1024]; - int ret; - char *escaped = ecore_file_escape_name(app->file); - - tmp = E_NEW(Evry_Item_App, 1); - snprintf(buf, sizeof(buf), "%s -hold -e %s", - evry_conf->cmd_terminal, - (escaped ? escaped : app->file)); - - tmp->file = buf; - ret = evry_util_exec_app(EVRY_ITEM(tmp), NULL); - - E_FREE(tmp); - E_FREE(escaped); - - return ret; -} - -static int -_exec_term_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it) -{ - ITEM_APP(app, it); - - if (app->file) - return 1; - - return 0; -} - -static int -_exec_sudo_action(Evry_Action *act) -{ - ITEM_APP(app, act->item1); - Evry_Item_App *tmp; - char buf[1024]; - int ret; - - tmp = E_NEW(Evry_Item_App, 1); - snprintf(buf, sizeof(buf), "%s %s", - evry_conf->cmd_sudo, - (app->desktop ? app->desktop->exec : app->file)); - - tmp->file = buf; - ret = evry_util_exec_app(EVRY_ITEM(tmp), NULL); - - E_FREE(tmp); - - return ret; -} - -static int -_open_with_action(Evry_Plugin *plugin, const Evry_Item *it) -{ - PLUGIN(p, plugin); - - if (p->candidate) - return evry_util_exec_app(it, p->candidate); - - return 0; -} - -static int -_edit_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it) -{ - ITEM_APP(app, it); - - if (app->desktop) - return 1; - - return 0; -} - -static int -_edit_app_action(Evry_Action *act) -{ - Efreet_Desktop *desktop; - ITEM_APP(app, act->item1); - - if (app->desktop) - desktop = app->desktop; - else - { - char buf[128]; - snprintf(buf, 128, "%s/.local/share/applications/%s.desktop", - e_user_homedir_get(), app->file); - desktop = efreet_desktop_empty_new(eina_stringshare_add(buf)); - /* XXX check if this is freed by efreet*/ - desktop->exec = strdup(app->file); - } - - e_desktop_edit(e_container_current_get(e_manager_current_get()), desktop); - - return 1; -} - -static int -_new_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it) -{ - ITEM_APP(app, it); - - if (app->desktop) - return 1; - - if (app->file && strlen(app->file) > 0) - return 1; - - return 0; -} - -static int -_new_app_action(Evry_Action *act) -{ - char *name; - char buf[4096]; - char *end; - Efreet_Desktop *desktop; - int i; - - ITEM_APP(app, act->item1); - - if (app->desktop) - name = strdup(app->desktop->name); - else - /* TODO replace '/' and remove other special characters */ - name = strdup(app->file); - - if ((end = strchr(name, ' '))) - name[end - name] = '\0'; - - for (i = 0; i < 10; i++) - { - snprintf(buf, 4096, "%s/.local/share/applications/%s-%d.desktop", - e_user_homedir_get(), name, i); - if (ecore_file_exists(buf)) - { - buf[0] = '\0'; - continue; - } - else break; - } - - free(name); - - if (strlen(buf) == 0) - return 0; - - if (!app->desktop) - { - desktop = efreet_desktop_empty_new(buf); - desktop->exec = strdup(app->file); - } - else - { - efreet_desktop_save_as(app->desktop, buf); - desktop = efreet_desktop_new(buf); - } - - e_desktop_edit(e_container_current_get(e_manager_current_get()), desktop); - - return 1; -} - -//#define TIME_FACTOR(_now) (1.0 - (evry_hist->begin / _now)) / 1000000000000000.0 - -static Eina_Bool -_init(void) -{ - if (!evry_api_version_check(EVRY_API_VERSION)) - return EINA_FALSE; - - p1 = E_NEW(Plugin, 1); - evry_plugin_new(EVRY_PLUGIN(p1), "Applications", type_subject, "", "APPLICATION", 0, NULL, NULL, - _begin, _cleanup, _fetch, NULL, _icon_get, NULL, NULL); - - p2 = E_NEW(Plugin, 1); - evry_plugin_new(EVRY_PLUGIN(p2), "Open With...", type_action, "FILE", "", 0, NULL, NULL, - _begin_open_with, _cleanup, _fetch, _open_with_action, - _icon_get, NULL, NULL); - - evry_plugin_register(EVRY_PLUGIN(p1), 1); - evry_plugin_register(EVRY_PLUGIN(p2), 1); - - act = evry_action_new("Launch", "APPLICATION", NULL, NULL, - "everything-launch", - _exec_app_action, _exec_app_check_item, - NULL, NULL,NULL); - - act1 = evry_action_new("Open File...", "APPLICATION", "FILE", "APPLICATION", - "document-open", - _exec_app_action, _exec_app_check_item, - NULL, NULL, NULL); - - act2 = evry_action_new("Run in Terminal", "APPLICATION", NULL, NULL, - "system-run", - _exec_term_action, _exec_term_check_item, - NULL, NULL, NULL); - - act3 = evry_action_new("Edit Application Entry", "APPLICATION", NULL, NULL, - "everything-launch", - _edit_app_action, _edit_app_check_item, - NULL, NULL, NULL); - - act4 = evry_action_new("New Application Entry", "APPLICATION", NULL, NULL, - "everything-launch", - _new_app_action, _new_app_check_item, - NULL, NULL, NULL); - - act5 = evry_action_new("Run with Sudo", "APPLICATION", NULL, NULL, - "system-run", - _exec_sudo_action, NULL, NULL, NULL, NULL); - - evry_action_register(act, 0); - evry_action_register(act1, 1); - evry_action_register(act2, 2); - evry_action_register(act3, 3); - evry_action_register(act4, 4); - evry_action_register(act5, 5); - - /* - Eina_List *l, *ll; - const char *file, *name; - History_Entry *he; - History_Item *hi; - name = EVRY_PLUGIN(p1)->name; - double t; - int found = 0; - - evry_history_load(); - - EINA_LIST_FOREACH(e_exehist_list_get(), l, file) - { - t = e_exehist_newest_run_get(file); - he = eina_hash_find(evry_hist->subjects, file); - - if (!he) - { - he = E_NEW(History_Entry, 1); - eina_hash_add(evry_hist->subjects, file, he); - } - else - { - EINA_LIST_FOREACH(he->items, ll, hi) - { - if (hi->plugin != name) continue; - - if (t > hi->last_used - 1.0) - { - hi->last_used = t; - hi->usage += TIME_FACTOR(hi->last_used); - hi->count = e_exehist_popularity_get(file); - } - found = 1; - break; - } - - } - - if (!found) - { - hi = E_NEW(History_Item, 1); - hi->plugin = eina_stringshare_ref(name); - hi->last_used = t; - hi->count = e_exehist_popularity_get(file); - hi->usage += TIME_FACTOR(hi->last_used); - he->items = eina_list_append(he->items, hi); - } - found = 0; - } - evry_history_unload(); - */ - /* taken from e_exebuf.c */ - exelist_exe_edd = E_CONFIG_DD_NEW("E_Exe", E_Exe); -#undef T -#undef D -#define T E_Exe -#define D exelist_exe_edd - E_CONFIG_VAL(D, T, path, STR); - - exelist_edd = E_CONFIG_DD_NEW("E_Exe_List", E_Exe_List); -#undef T -#undef D -#define T E_Exe_List -#define D exelist_edd - E_CONFIG_LIST(D, T, list, exelist_exe_edd); - - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - EVRY_PLUGIN_FREE(p1); - EVRY_PLUGIN_FREE(p2); - - evry_action_free(act); - evry_action_free(act1); - evry_action_free(act2); - evry_action_free(act3); - evry_action_free(act4); - evry_action_free(act5); - - E_CONFIG_DD_FREE(exelist_edd); - E_CONFIG_DD_FREE(exelist_exe_edd); -} - -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); - - -/* taken from e_exebuf.c */ -static int -_scan_idler(void *data) -{ - struct stat st; - struct dirent *dp; - char *dir; - char buf[4096]; - - /* no more path items left - stop scanning */ - if (!exe_path) - { - Eina_List *l, *l2; - E_Exe_List *el; - E_Exe *ee; - int different = 0; - - /* FIXME: check wheter they match or not */ - for (l = exe_list, l2 = exe_list2; l && l2; l = l->next, l2 = l2->next) - { - if (strcmp(l->data, l2->data)) - { - different = 1; - break; - } - } - if ((l) || (l2)) different = 1; - if (exe_list2) - { - while (exe_list) - { - free(eina_list_data_get(exe_list)); - exe_list = eina_list_remove_list(exe_list, exe_list); - } - exe_list = exe_list2; - exe_list2 = NULL; - } - if (different) - { - el = calloc(1, sizeof(E_Exe_List)); - if (el) - { - el->list = NULL; - for (l = exe_list; l; l = l->next) - { - ee = malloc(sizeof(E_Exe)); - if (ee) - { - ee->path = eina_stringshare_add(l->data); - el->list = eina_list_append(el->list, ee); - } - } - e_config_domain_save("exebuf_exelist_cache", exelist_edd, el); - while (el->list) - { - ee = eina_list_data_get(el->list); - eina_stringshare_del(ee->path); - free(ee); - el->list = eina_list_remove_list(el->list, el->list); - } - free(el); - } - } - exe_scan_idler = NULL; - return 0; - } - /* no dir is open - open the first path item */ - if (!exe_dir) - { - dir = exe_path->data; - exe_dir = opendir(dir); - } - /* if we have an opened dir - scan the next item */ - if (exe_dir) - { - dir = exe_path->data; - - dp = readdir(exe_dir); - if (dp) - { - if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, ".."))) - { - snprintf(buf, sizeof(buf), "%s/%s", dir, dp->d_name); - if ((stat(buf, &st) == 0) && - ((!S_ISDIR(st.st_mode)) && - (!access(buf, X_OK)))) - { - if (!exe_list) - exe_list = eina_list_append(exe_list, strdup(dp->d_name)); - else - exe_list2 = eina_list_append(exe_list2, strdup(dp->d_name)); - } - } - } - else - { - /* we reached the end of a dir - remove the dir at the head - * of the path list so we advance and next loop we will pick up - * the next item, or if null- abort - */ - closedir(exe_dir); - exe_dir = NULL; - free(eina_list_data_get(exe_path)); - exe_path = eina_list_remove_list(exe_path, exe_path); - } - } - /* obviously the dir open failed - so remove the first path item */ - else - { - free(eina_list_data_get(exe_path)); - exe_path = eina_list_remove_list(exe_path, exe_path); - } - /* we have mroe scannign to do */ - return 1; -} diff --git a/src/modules/everything/sources/evry_plug_aspell.c b/src/modules/everything/sources/evry_plug_aspell.c deleted file mode 100644 index 9f0d285782..0000000000 --- a/src/modules/everything/sources/evry_plug_aspell.c +++ /dev/null @@ -1,347 +0,0 @@ -#include "Evry.h" -#include <ctype.h> - -static const char TRIGGER[] = "aspell "; -static const char LANG_MODIFIER[] = "lang="; - -typedef struct _Plugin Plugin; - - -struct _Plugin -{ - Evry_Plugin base; - struct - { - Ecore_Event_Handler *data; - Ecore_Event_Handler *del; - } handler; - Ecore_Exe *exe; - const char *lang; - const char *input; - Eina_Bool is_first; -}; - -static Plugin *plugin = NULL; - -static Eina_Bool -_exe_restart(Plugin *p) -{ - char cmd[1024]; - const char *lang_opt, *lang_val; - int len; - - if (p->lang && (p->lang[0] != '\0')) - { - lang_opt = "-l"; - lang_val = p->lang; - } - else - { - lang_opt = ""; - lang_val = ""; - } - - len = snprintf(cmd, sizeof(cmd), - "aspell -a --encoding=UTF-8 %s%s", - lang_opt, lang_val); - if (len >= (int)sizeof(cmd)) - return 0; - - if (p->exe) - ecore_exe_quit(p->exe); - p->exe = ecore_exe_pipe_run - (cmd, - ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_READ_LINE_BUFFERED | - ECORE_EXE_PIPE_WRITE, - NULL); - p->is_first = 1; - return !!p->exe; -} - -static const char * -_space_skip(const char *line) -{ - for (; *line != '\0'; line++) - if (!isspace(*line)) - break; - return line; -} - -static const char * -_space_find(const char *line) -{ - for (; *line != '\0'; line++) - if (isspace(*line)) - break; - return line; -} - -static void -_item_add(Plugin *p, const char *word, int word_size, int prio) -{ - Evry_Item *it; - - it = evry_item_new(NULL, EVRY_PLUGIN(p), NULL, NULL); - if (!it) return; - it->priority = prio; - it->label = eina_stringshare_add_length(word, word_size); - - EVRY_PLUGIN_ITEM_APPEND(p, it); -} - -static void -_suggestions_add(Plugin *p, const char *line) -{ - const char *s; - - s = strchr(line, ':'); - if (!s) - { - fprintf(stderr, "ASPELL: ERROR missing suggestion delimiter: '%s'\n", - line); - return; - } - s++; - - line = _space_skip(s); - while (*line) - { - int len; - - s = strchr(line, ','); - if (s) - len = s - line; - else - len = strlen(line); - - _item_add(p, line, len, 1); - - if (s) - line = _space_skip(s + 1); - else - break; - } -} - -static int -_cb_data(void *data, int type __UNUSED__, void *event) -{ - PLUGIN(p, data); - Ecore_Exe_Event_Data *e = event; - Ecore_Exe_Event_Data_Line *l; - const char *word; - - if (e->exe != p->exe) - return 1; - - EVRY_PLUGIN_ITEMS_FREE(p); - - word = p->input; - for (l = e->lines; l && l->line; l++) - { - const char *word_end; - int word_size; - - if (p->is_first) - { - fprintf(stderr, "ASPELL: %s\n", l->line); - p->is_first = 0; - continue; - } - - word_end = _space_find(word); - word_size = word_end - word; - - switch (l->line[0]) - { - case '*': - _item_add(plugin, word, word_size, 1); - break; - case '&': - _item_add(plugin, word, word_size, 1); - _suggestions_add(plugin, l->line); - break; - case '#': - break; - case '\0': - break; - default: - fprintf(stderr, "ASPELL: unknown output: '%s'\n", l->line); - } - - if (*word_end) - word = _space_skip(word_end + 1); - } - - if (EVRY_PLUGIN(p)->items) - { - evry_list_win_show(); - } - - evry_plugin_async_update(EVRY_PLUGIN(p), EVRY_ASYNC_UPDATE_ADD); - - return 1; -} - -static int -_cb_del(void *data, int type __UNUSED__, void *event) -{ - Plugin *p = data; - Ecore_Exe_Event_Del *e = event; - - if (e->exe != p->exe) - return 1; - - p->exe = NULL; - return 1; -} - -static int -_begin(Evry_Plugin *plugin, const Evry_Item *it __UNUSED__) -{ - PLUGIN(p, plugin); - - if (!p->handler.data) - p->handler.data = ecore_event_handler_add - (ECORE_EXE_EVENT_DATA, _cb_data, p); - if (!p->handler.del) - p->handler.del = ecore_event_handler_add - (ECORE_EXE_EVENT_DEL, _cb_del, p); - - return _exe_restart(p); -} - -static int -_fetch(Evry_Plugin *plugin, const char *input) -{ - PLUGIN(p, plugin); - const char *s; - int len; - - if (!input) return 0; - - if (!p->handler.data && !_begin(plugin, NULL)) return 0; - - len = sizeof(LANG_MODIFIER) - 1; - if (strncmp(input, LANG_MODIFIER, len) == 0) - { - const char *lang; - - EVRY_PLUGIN_ITEMS_FREE(p); - - input += len; - for (s = input; *s != '\0'; s++) - if (isspace(*s) || *s == ';') - break; - - if (*s == '\0') /* just apply language on ' ' or ';' */ - return 1; - - if (s - input > 0) - lang = eina_stringshare_add_length(input, s - input); - else - lang = NULL; - - if (p->lang) eina_stringshare_del(p->lang); - if (p->lang != lang) - { - p->lang = lang; - if (!_exe_restart(p)) - return 0; - } - - if (*s == '\0') - return 1; - - input = s + 1; - } - - input = _space_skip(input); - for (s = input; *s != '\0'; s++) - ; - for (s--; s > input; s--) - if (!isspace(*s)) - break; - - len = s - input + 1; - if (len < 1) - return 1; - input = eina_stringshare_add_length(input, len); - if (p->input) eina_stringshare_del(p->input); - if (p->input == input) - return 1; - - p->input = input; - if (!p->exe) - return 1; - - ecore_exe_send(p->exe, (char *)p->input, len); - ecore_exe_send(p->exe, "\n", 1); - - return 1; -} - -static void -_cleanup(Evry_Plugin *plugin) -{ - PLUGIN(p, plugin); - - EVRY_PLUGIN_ITEMS_FREE(p) - - if (p->handler.data) - { - ecore_event_handler_del(p->handler.data); - p->handler.data = NULL; - } - if (p->handler.del) - { - ecore_event_handler_del(p->handler.del); - p->handler.del = NULL; - } - if (p->exe) - { - ecore_exe_quit(p->exe); - ecore_exe_free(p->exe); - p->exe = NULL; - } - if (p->lang) - { - eina_stringshare_del(p->lang); - p->lang = NULL; - } - if (p->input) - { - eina_stringshare_del(p->input); - p->input = NULL; - } -} - -static Eina_Bool -_init(void) -{ - Plugin *p; - - if (!evry_api_version_check(EVRY_API_VERSION)) - return EINA_FALSE; - - p = E_NEW(Plugin, 1); - evry_plugin_new(EVRY_PLUGIN(p), "Spell Checker", type_subject, "", "TEXT", 1, - "accessories-dictionary", TRIGGER, - NULL, _cleanup, _fetch, NULL, NULL, NULL, NULL); - - EVRY_PLUGIN(p)->aggregate = EINA_FALSE; - - evry_plugin_register(EVRY_PLUGIN(p), 100); - - plugin = p; - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - EVRY_PLUGIN_FREE(plugin); -} - -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/sources/evry_plug_border.c b/src/modules/everything/sources/evry_plug_border.c deleted file mode 100644 index 20a3141a30..0000000000 --- a/src/modules/everything/sources/evry_plug_border.c +++ /dev/null @@ -1,260 +0,0 @@ -#include "e.h" -#include "e_mod_main.h" - -static Evry_Plugin *plugin; -static Eina_List *handlers = NULL; -static Eina_Hash *border_hash = NULL; - -static int -_cb_border_remove(void *data, int type, void *event) -{ - E_Event_Border_Remove *ev = event; - Evry_Item *it; - Evry_Plugin *p = data; - - it = eina_hash_find(border_hash, &(ev->border)); - - if (!it) return 1; - - p->items = eina_list_remove(p->items, it); - eina_hash_del_by_key(border_hash, &(ev->border)); - - evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD); - - return 1; -} - -static void _hash_free(void *data) -{ - Evry_Item *it = data; - - evry_item_free(it); -} - -static Evry_Plugin * -_begin(Evry_Plugin *p, const Evry_Item *it) -{ - handlers = eina_list_append - (handlers, ecore_event_handler_add - (E_EVENT_BORDER_REMOVE, _cb_border_remove, p)); - - border_hash = eina_hash_pointer_new(_hash_free); - - return p; -} - -static void -_cleanup(Evry_Plugin *p) -{ - Ecore_Event_Handler *h; - - EINA_LIST_FREE(handlers, h) - ecore_event_handler_del(h); - - if (border_hash) eina_hash_free(border_hash); - border_hash = NULL; - - EVRY_PLUGIN_ITEMS_CLEAR(p); -} - -static void -_item_free(Evry_Item *it) -{ - if (it->data) - e_object_unref(E_OBJECT(it->data)); - - E_FREE(it); -} - -static void -_item_add(Evry_Plugin *p, E_Border *bd, int match, int *prio) -{ - Evry_Item *it = NULL; - - if ((it = eina_hash_find(border_hash, &bd))) - { - it->priority = *prio; - EVRY_PLUGIN_ITEM_APPEND(p, it); - it->fuzzy_match = match; - *prio += 1; - return; - } - - it = evry_item_new(NULL, p, e_border_name_get(bd), _item_free); - - e_object_ref(E_OBJECT(bd)); - it->data = bd; - it->fuzzy_match = match; - it->priority = *prio; - it->transient = EINA_TRUE; - it->id = eina_stringshare_add(e_util_winid_str_get(bd->win)); - - *prio += 1; - - eina_hash_add(border_hash, &bd, it); - - EVRY_PLUGIN_ITEM_APPEND(p, it); -} - -static int -_cb_sort(const void *data1, const void *data2) -{ - const Evry_Item *it1 = data1; - const Evry_Item *it2 = data2; - - if (it1->fuzzy_match - it2->fuzzy_match) - return (it1->fuzzy_match - it2->fuzzy_match); - - return (it1->priority - it2->priority); -} - -static int -_fetch(Evry_Plugin *p, const char *input) -{ - E_Zone *zone; - E_Border *bd; - Eina_List *l; - int prio = 0; - int m1, m2; - - EVRY_PLUGIN_ITEMS_CLEAR(p); - - zone = e_util_zone_current_get(e_manager_current_get()); - - EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd) - { - if (zone == bd->zone) - { - if (!input) - _item_add(p, bd, 0, &prio); - else - { - m1 = evry_fuzzy_match(e_border_name_get(bd), input); - - if (bd->client.icccm.name) - { - m2 = evry_fuzzy_match(bd->client.icccm.name, input); - if (!m1 || (m2 && m2 < m1)) - m1 = m2; - } - - if (bd->desktop) - { - m2 = evry_fuzzy_match(bd->desktop->name, input); - if (!m1 || (m2 && m2 < m1)) - m1 = m2; - } - - if (m1) - _item_add(p, bd, m1, &prio); - } - } - } - - if (!p->items) return 0; - - EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort); - - return 1; -} - -static Evas_Object * -_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) -{ - Evas_Object *o = NULL; - E_Border *bd = it->data; - - if (bd->internal) - { - o = edje_object_add(e); - if (!bd->internal_icon) - e_util_edje_icon_set(o, "enlightenment/e"); - else - { - if (!bd->internal_icon_key) - { - char *ext; - ext = strrchr(bd->internal_icon, '.'); - if ((ext) && ((!strcmp(ext, ".edj")))) - { - if (!edje_object_file_set(o, bd->internal_icon, "icon")) - e_util_edje_icon_set(o, "enlightenment/e"); - } - else if (ext) - { - evas_object_del(o); - o = e_icon_add(e); - e_icon_file_set(o, bd->internal_icon); - } - else - { - if (!e_util_edje_icon_set(o, bd->internal_icon)) - e_util_edje_icon_set(o, "enlightenment/e"); - } - } - else - { - edje_object_file_set(o, bd->internal_icon, - bd->internal_icon_key); - } - } - return o; - } - - if (!o && bd->desktop) - o = e_util_desktop_icon_add(bd->desktop, 128, e); - - if (!o && bd->client.netwm.icons) - { - int i, size, tmp, found = 0; - o = e_icon_add(e); - - size = bd->client.netwm.icons[0].width; - - for (i = 1; i < bd->client.netwm.num_icons; i++) - { - if ((tmp = bd->client.netwm.icons[i].width) > size) - { - size = tmp; - found = i; - } - } - - e_icon_data_set(o, bd->client.netwm.icons[found].data, - bd->client.netwm.icons[found].width, - bd->client.netwm.icons[found].height); - e_icon_alpha_set(o, 1); - return o; - } - - if (!o) - o = e_border_icon_add(bd, e); - - return o; -} - - - -static Eina_Bool -_init(void) -{ - if (!evry_api_version_check(EVRY_API_VERSION)) - return EINA_FALSE; - - plugin = evry_plugin_new(NULL, "Windows", type_subject, NULL, "BORDER", 0, NULL, NULL, - _begin, _cleanup, _fetch, NULL, _item_icon_get, NULL, NULL); - - evry_plugin_register(plugin, 2); - - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - EVRY_PLUGIN_FREE(plugin); -} - - -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/sources/evry_plug_calc.c b/src/modules/everything/sources/evry_plug_calc.c deleted file mode 100644 index bf2fc45aad..0000000000 --- a/src/modules/everything/sources/evry_plug_calc.c +++ /dev/null @@ -1,250 +0,0 @@ -#include "Evry.h" -// TODO - show error when input not parseable - -static int _cb_data(void *data, int type, void *event); -static int _cb_error(void *data, int type, void *event); -static int _cb_del(void *data, int type, void *event); - -static Evry_Plugin *p1; -static Ecore_Exe *exe = NULL; -static Eina_List *history = NULL; -static Eina_List *handlers = NULL; - -static int error = 0; - - - -static Evry_Plugin * -_begin(Evry_Plugin *p, const Evry_Item *item __UNUSED__) -{ - Evry_Item *it; - - if (history) - { - const char *result; - - EINA_LIST_FREE(history, result) - { - it = evry_item_new(NULL, p, result, NULL); - p->items = eina_list_prepend(p->items, it); - eina_stringshare_del(result); - } - } - - it = evry_item_new(NULL, p, "0", NULL); - p->items = eina_list_prepend(p->items, it); - - return p; -} - -static int -_run_bc(Evry_Plugin *p) -{ - handlers = eina_list_append - (handlers, ecore_event_handler_add - (ECORE_EXE_EVENT_DATA, _cb_data, p)); - handlers = eina_list_append - (handlers, ecore_event_handler_add - (ECORE_EXE_EVENT_ERROR, _cb_error, p)); - handlers = eina_list_append - (handlers, ecore_event_handler_add - (ECORE_EXE_EVENT_DEL, _cb_del, p)); - - exe = ecore_exe_pipe_run("bc -l", - ECORE_EXE_PIPE_READ | - ECORE_EXE_PIPE_READ_LINE_BUFFERED | - ECORE_EXE_PIPE_WRITE | - ECORE_EXE_PIPE_ERROR | - ECORE_EXE_PIPE_ERROR_LINE_BUFFERED, - NULL); - return !!exe; -} - - -static void -_cleanup(Evry_Plugin *p) -{ - Ecore_Event_Handler *h; - Evry_Item *it; - int items = 10; - - if (p->items) - { - evry_item_free(p->items->data); - p->items = eina_list_remove_list(p->items, p->items); - } - - EINA_LIST_FREE(p->items, it) - { - if (items-- > 0) - history = eina_list_prepend(history, eina_stringshare_add(it->label)); - - evry_item_free(it); - } - - EINA_LIST_FREE(handlers, h) - ecore_event_handler_del(h); - - if (exe) - { - ecore_exe_quit(exe); - ecore_exe_free(exe); - exe = NULL; - } -} - -static int -_action(Evry_Plugin *p, const Evry_Item *it) -{ - Eina_List *l; - Evry_Item *it2, *it_old; - - /* remove duplicates */ - if (p->items->next) - { - it = p->items->data; - - EINA_LIST_FOREACH(p->items->next, l, it2) - { - if (!strcmp(it->label, it2->label)) - break; - it2 = NULL; - } - - if (it2) - { - p->items = eina_list_remove(p->items, it2); - evry_item_free(it2); - } - } - - it_old = p->items->data; - it_old->selected = EINA_FALSE; - - it2 = evry_item_new(NULL, p, it_old->label, NULL); - p->items = eina_list_prepend(p->items, it2); - - evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD); - - return EVRY_ACTION_FINISHED; -} - -static int -_fetch(Evry_Plugin *p, const char *input) -{ - char buf[1024]; - - if (!input) return 0; - - if (!exe && !_run_bc(p)) return 0; - - if (!strncmp(input, "scale=", 6)) - snprintf(buf, 1024, "%s\n", input); - else - snprintf(buf, 1024, "scale=3;%s\n", input); - - ecore_exe_send(exe, buf, strlen(buf)); - - /* XXX after error we get no response for first input ?! - send a - second time...*/ - if (error) - { - ecore_exe_send(exe, buf, strlen(buf)); - error = 0; - } - - return 1; -} - - -static void -_cb_free_item_changed(void *data, void *event) -{ - Evry_Event_Item_Changed *ev = event; - - evry_item_free(ev->item); - E_FREE(ev); -} - -static int -_cb_data(void *data, int type __UNUSED__, void *event) -{ - Ecore_Exe_Event_Data *ev = event; - Evry_Plugin *p = data; - Evry_Item *it; - - if (ev->exe != exe) return 1; - - if (ev->lines) - { - it = p->items->data; - eina_stringshare_del(it->label); - it->label = eina_stringshare_add(ev->lines->line); - - if (it) - { - Evry_Event_Item_Changed *ev = E_NEW(Evry_Event_Item_Changed, 1); - ev->item = it; - evry_item_ref(it); - ecore_event_add(EVRY_EVENT_ITEM_CHANGED, ev, _cb_free_item_changed, NULL); - } - } - - return 1; -} - -static int -_cb_error(void *data __UNUSED__, int type __UNUSED__, void *event) -{ - Ecore_Exe_Event_Data *ev = event; - - if (ev->exe != exe) - return 1; - - error = 1; - - return 1; -} - -static int -_cb_del(void *data __UNUSED__, int type __UNUSED__, void *event) -{ - Ecore_Exe_Event_Del *e = event; - - if (e->exe != exe) - return 1; - - exe = NULL; - return 1; -} - -static Eina_Bool -_init(void) -{ - if (!evry_api_version_check(EVRY_API_VERSION)) - return EINA_FALSE; - - p1 = evry_plugin_new(NULL, "Calculator", type_subject, NULL, "TEXT", 1, "accessories-calculator", "=", - _begin, _cleanup, _fetch, _action, NULL, NULL, NULL); - - p1->aggregate = EINA_FALSE; - - evry_plugin_register(p1, 0); - - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - char *result; - - EINA_LIST_FREE(history, result) - eina_stringshare_del(result); - - EVRY_PLUGIN_FREE(p1); -} - - -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/sources/evry_plug_config.c b/src/modules/everything/sources/evry_plug_config.c deleted file mode 100644 index 4392815109..0000000000 --- a/src/modules/everything/sources/evry_plug_config.c +++ /dev/null @@ -1,143 +0,0 @@ -#include "Evry.h" - -static Evry_Plugin *p; -static Evry_Action *act; - - -static void -_cleanup(Evry_Plugin *p) -{ - EVRY_PLUGIN_ITEMS_FREE(p); -} - -static void -_item_add(Evry_Plugin *p, E_Configure_It *eci, int match, int prio) -{ - Evry_Item *it; - - it = evry_item_new(NULL, p, eci->label, NULL); - it->data = eci; - it->priority = prio; - it->fuzzy_match = match; - - EVRY_PLUGIN_ITEM_APPEND(p, it); -} - -static int -_fetch(Evry_Plugin *p, const char *input) -{ - Eina_List *l, *ll; - E_Configure_Cat *ecat; - E_Configure_It *eci; - int match; - - _cleanup(p); - - EINA_LIST_FOREACH(e_configure_registry, l, ecat) - { - if ((ecat->pri < 0) || (!ecat->items)) continue; - if (!strcmp(ecat->cat, "system")) continue; - - EINA_LIST_FOREACH(ecat->items, ll, eci) - { - if (eci->pri >= 0) - { - if ((match = evry_fuzzy_match(eci->label, input))) - _item_add(p, eci, match, 0); - else if ((match = evry_fuzzy_match(ecat->label, input))) - _item_add(p, eci, match, 1); - } - } - } - - if (eina_list_count(p->items) > 0) - { - p->items = evry_fuzzy_match_sort(p->items); - return 1; - } - - return 0; -} - -static Evas_Object * -_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) -{ - Evas_Object *o = NULL; - E_Configure_It *eci = it->data; - - if (eci->icon) - { - if (!(o = evry_icon_theme_get(eci->icon, e))) - { - o = e_util_icon_add(eci->icon, e); - } - } - - return o; -} - -static int -_action(Evry_Action *act) -{ - E_Configure_It *eci, *eci2; - E_Container *con; - E_Configure_Cat *ecat; - Eina_List *l, *ll; - char buf[1024]; - int found = 0; - - eci = act->item1->data; - con = e_container_current_get(e_manager_current_get()); - - EINA_LIST_FOREACH(e_configure_registry, l, ecat) - { - if (found) break; - - EINA_LIST_FOREACH(ecat->items, ll, eci2) - { - if (eci == eci2) - { - snprintf(buf, sizeof(buf), "%s/%s", - ecat->cat, - eci->item); - found = 1; - break; - } - } - } - - if (found) - e_configure_registry_call(buf, con, NULL); - - return EVRY_ACTION_FINISHED; -} - -static Eina_Bool -_init(void) -{ - if (!evry_api_version_check(EVRY_API_VERSION)) - return EINA_FALSE; - - p = evry_plugin_new(NULL, "Settings", type_subject, NULL, "E_SETTINGS", 0, NULL, NULL, - NULL, _cleanup, _fetch, NULL, _item_icon_get, NULL, NULL); - - act = evry_action_new("Show Dialog", "E_SETTINGS", NULL, NULL, "preferences-advanced", - _action, NULL, NULL, NULL, NULL); - - evry_plugin_register(p, 10); - - evry_action_register(act, 0); - - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - EVRY_PLUGIN_FREE(p); - - evry_action_free(act); -} - -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/sources/evry_plug_dir_browse.c b/src/modules/everything/sources/evry_plug_dir_browse.c deleted file mode 100644 index 3507f9140b..0000000000 --- a/src/modules/everything/sources/evry_plug_dir_browse.c +++ /dev/null @@ -1,541 +0,0 @@ -#include "e_mod_main.h" - -#define MAX_ITEMS 100 -#define TERM_ACTION_DIR "%s" - -typedef struct _Plugin Plugin; -typedef struct _Data Data; - -struct _Plugin -{ - Evry_Plugin base; - - const char *directory; - /* all files of directory */ - Eina_List *files; - /* current list of files */ - Eina_List *cur; - Eina_Bool command; - - const char *input; - - Ecore_Thread *thread; -}; - -struct _Data -{ - Plugin *plugin; - long id; - int level; - int cnt; - Eina_List *files; -}; - -static Evry_Plugin *p1 = NULL; -static Evry_Plugin *p2 = NULL; -static Evry_Action *act1 = NULL; -static Evry_Action *act2 = NULL; - -/* static long thread_cnt = 0; - * static long thread_last = 0; */ - -static const char *mime_folder; - - -static void -_item_fill(Evry_Item_File *file) -{ - const char *mime; - - if (file->mime) return; - - if ((mime = efreet_mime_type_get(file->path))) - { - file->mime = eina_stringshare_add(mime); - EVRY_ITEM(file)->context = eina_stringshare_ref(file->mime); - - if ((!strcmp(mime, "inode/directory")) || - (!strcmp(mime, "inode/mount-point"))) - EVRY_ITEM(file)->browseable = EINA_TRUE; - - return; - } - - file->mime = eina_stringshare_add("None"); -} - -static int -_cb_sort(const void *data1, const void *data2) -{ - const Evry_Item *it1 = data1; - const Evry_Item *it2 = data2; - - if (it1->browseable && !it2->browseable) - return -1; - - if (!it1->browseable && it2->browseable) - return 1; - - if (it1->fuzzy_match && it2->fuzzy_match) - if (it1->fuzzy_match - it2->fuzzy_match) - return (it1->fuzzy_match - it2->fuzzy_match); - - return strcasecmp(it1->label, it2->label); -} - -static void -_item_free(Evry_Item *it) -{ - ITEM_FILE(file, it); - if (file->path) eina_stringshare_del(file->path); - if (file->mime) eina_stringshare_del(file->mime); - - E_FREE(file); -} - -static void -_scan_func(void *data) -{ - Data *d = data; - Plugin *p = d->plugin; - Eina_List *files; - char *filename; - Evry_Item_File *file; - char buf[4096]; - - files = ecore_file_ls(p->directory); - - EINA_LIST_FREE(files, filename) - { - if (filename[0] == '.') - { - free(filename); - continue; - } - - file = E_NEW(Evry_Item_File, 1); - if (!file) - { - free(filename); - continue; - } - - evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), NULL, _item_free); - - EVRY_ITEM(file)->data = filename; - - snprintf(buf, sizeof(buf), "%s/%s", p->directory, filename); - file->path = strdup(buf); - - if (ecore_file_is_dir(file->path)) - EVRY_ITEM(file)->browseable = EINA_TRUE; - - d->files = eina_list_append(d->files, file); - } -} - -static int -_append_file(Plugin *p, Evry_Item_File *file) -{ - int match; - - if (p->input && (match = evry_fuzzy_match(EVRY_ITEM(file)->label, p->input))) - { - EVRY_ITEM(file)->fuzzy_match = match; - EVRY_PLUGIN_ITEM_APPEND(p, file); - return 1; - } - else if (!p->input) - { - EVRY_PLUGIN_ITEM_APPEND(p, file); - return 1; - } - - return 0; -} - -static const char * -_item_id(const char *path) -{ - const char *s1, *s2, *s3; - s1 = s2 = s3 = path; - - while (s1 && ++s1 && (s1 = strchr(s1, '/'))) - { - s3 = s2; - s2 = s1; - } - - return s3; -} -static void -_scan_cancel_func(void *data) -{ - Data *d = data; - Plugin *p = d->plugin; - int cnt = 0; - Evry_Item *item; - char *filename, *path; - Evry_Item_File *file; - - EINA_LIST_FREE(d->files, item) - { - filename = item->data; - free(filename); - evry_item_free(item); - } - E_FREE(d); - - if (p->directory) - eina_stringshare_del(p->directory); - - EINA_LIST_FREE(p->files, file) - evry_item_free(EVRY_ITEM(file)); - - EVRY_PLUGIN_ITEMS_CLEAR(p); - - E_FREE(p); -} - -static void -_scan_end_func(void *data) -{ - Data *d = data; - Plugin *p = d->plugin; - int cnt = 0; - Evry_Item *item; - char *filename, *path; - - p->thread = NULL; - - EINA_LIST_FREE(d->files, item) - { - ITEM_FILE(file, item); - - filename = item->data; - path = (char *) file->path; - file->path = eina_stringshare_add(path); - item->id = eina_stringshare_add(_item_id(path)); - item->label = eina_stringshare_add(filename); - free(filename); - free(path); - - p->files = eina_list_append(p->files, file); - - if (item->browseable) - { - file->mime = eina_stringshare_ref(mime_folder); - EVRY_ITEM(file)->context = eina_stringshare_ref(file->mime); - } - - if (p->command || cnt >= MAX_ITEMS) continue; - cnt += _append_file(p, file); - } - - if (!p->command) - { - EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort); - evry_plugin_async_update(EVRY_PLUGIN(p), EVRY_ASYNC_UPDATE_ADD); - } - - E_FREE(d); -} - -static void -_read_directory(Plugin *p) -{ - /* thread_last = ++thread_cnt; */ - - Data *d = E_NEW(Data, 1); - d->plugin = p; - /* d->id = thread_cnt; */ - p->thread = ecore_thread_run(_scan_func, _scan_end_func, _scan_cancel_func, d); -} - -static Evry_Plugin * -_begin(Evry_Plugin *plugin, const Evry_Item *it) -{ - Plugin *p = NULL; - - /* is FILE ? */ - if (it && (it->plugin->type_out == plugin->type_in)) - { - ITEM_FILE(file, it); - - if (!file->path || !ecore_file_is_dir(file->path)) - return NULL; - - p = E_NEW(Plugin, 1); - p->base = *plugin; - p->base.items = NULL; - - p->directory = eina_stringshare_add(file->path); - } - else - { - p = E_NEW(Plugin, 1); - p->base = *plugin; - p->base.items = NULL; - p->directory = eina_stringshare_add(e_user_homedir_get()); - } - - _read_directory(p); - - return EVRY_PLUGIN(p); -} - -static void -_cleanup(Evry_Plugin *plugin) -{ - PLUGIN(p, plugin); - - Evry_Item_File *file; - - /* if a thread for this plugin returns - it will free its data if its id is smaller - than thread_last */ - /* thread_last = ++thread_cnt; */ - - if (p->thread) - { - - ecore_thread_cancel(p->thread); - } - else - { - if (p->directory) - eina_stringshare_del(p->directory); - - EINA_LIST_FREE(p->files, file) - evry_item_free(EVRY_ITEM(file)); - - EVRY_PLUGIN_ITEMS_CLEAR(p); - - E_FREE(p); - } -} - -static void -_folder_item_add(Plugin *p, const char *path) -{ - Evry_Item_File *file = E_NEW(Evry_Item_File, 1); - - if (!file) return; - - evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), path, _item_free); - file->path = eina_stringshare_add(path); - file->mime = eina_stringshare_ref(mime_folder); - EVRY_ITEM(file)->browseable = EINA_TRUE; - EVRY_PLUGIN_ITEM_APPEND(p, file); -} - -static int -_fetch(Evry_Plugin *plugin, const char *input) -{ - PLUGIN(p, plugin); - Evry_Item_File *file; - Eina_List *l; - int cnt = 0; - - if (!p->command) - EVRY_PLUGIN_ITEMS_CLEAR(p); - - p->input = input; - - /* input is command ? */ - if (input) - { - if (!strncmp(input, "/", 1)) - { - if (p->command) return 1; - - _folder_item_add(p, "/"); - p->command = EINA_TRUE; - return 1; - } - else if (!strncmp(input, "..", 2)) - { - char *end; - char dir[4096]; - char *tmp; - int prio = 0; - - if (p->command) return 1; - if (strncmp(p->directory, "/", 1)) return 0; - if (!strcmp(p->directory, "/")) return 0; - - snprintf(dir, 4096, "%s", p->directory); - end = strrchr(dir, '/'); - - while (end != dir) - { - tmp = strdup(dir); - snprintf(dir, (end - dir) + 1, "%s", tmp); - - _folder_item_add(p, dir); - - end = strrchr(dir, '/'); - free(tmp); - prio--; - } - - _folder_item_add(p, "/"); - - p->command = EINA_TRUE; - return 1; - } - } - - if (p->command) - { - p->command = EINA_FALSE; - EVRY_PLUGIN_ITEMS_FREE(p); - } - - EINA_LIST_FOREACH(p->files, l, file) - { - if (cnt >= MAX_ITEMS); - cnt += _append_file(p, file); - } - - if (!EVRY_PLUGIN(p)->items) - return 0; - - EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort); - - return 1; -} - -static Evas_Object * -_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) -{ - Evas_Object *o = NULL; - ITEM_FILE(file, it); - - if (!file->mime) - _item_fill(file); - - if (!file->mime) return NULL; - - if (it->browseable) - o = evry_icon_theme_get("folder", e); - else - o = evry_icon_mime_get(file->mime, e); - - return o; -} - - -static int -_open_folder_check(Evry_Action *act __UNUSED__, const Evry_Item *it) -{ - return (it->browseable && e_action_find("fileman")); -} - -static int -_open_folder_action(Evry_Action *act) -{ - E_Action *action = e_action_find("fileman"); - char *path; - Eina_List *m; - - if (!action) return 0; - - m = e_manager_list(); - - ITEM_FILE(file, act->item1); - - if (!act->item1->browseable) - { - path = ecore_file_dir_get(file->path); - if (!path) return 0; - action->func.go(E_OBJECT(m->data), path); - free(path); - } - else - { - action->func.go(E_OBJECT(m->data), file->path); - } - - return 1; -} - -static int -_open_term_action(Evry_Action *act) -{ - ITEM_FILE(file, act->item1); - Evry_Item_App *tmp; - char cwd[4096]; - char *dir; - int ret = 0; - - if (act->item1->browseable) - dir = strdup(file->path); - else - dir = ecore_file_dir_get(file->path); - - if (dir) - { - getcwd(cwd, sizeof(cwd)); - chdir(dir); - - tmp = E_NEW(Evry_Item_App, 1); - tmp->file = evry_conf->cmd_terminal; - - ret = evry_util_exec_app(EVRY_ITEM(tmp), NULL); - E_FREE(tmp); - E_FREE(dir); - chdir(cwd); - } - - return ret; -} - -static Eina_Bool -_init(void) -{ - if (!evry_api_version_check(EVRY_API_VERSION)) - return EINA_FALSE; - - p1 = evry_plugin_new(NULL, "Files", type_subject, "FILE", "FILE", 0, NULL, NULL, - _begin, _cleanup, _fetch, NULL, _icon_get, - NULL, NULL); - - p2 = evry_plugin_new(NULL, "Files", type_object, "FILE", "FILE", 0, NULL, NULL, - _begin, _cleanup, _fetch, NULL, _icon_get, - NULL, NULL); - - evry_plugin_register(p1, 3); - evry_plugin_register(p2, 1); - - act1 = evry_action_new("Open Folder (EFM)", "FILE", NULL, NULL, "folder-open", - _open_folder_action, _open_folder_check, NULL, NULL, NULL); - evry_action_register(act1, 0); - - act2 = evry_action_new("Open Terminal here", "FILE", NULL, NULL, - "system-run", - _open_term_action, NULL, NULL, NULL, NULL); - evry_action_register(act2, 2); - - - - - mime_folder = eina_stringshare_add("inode/directory"); - - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - EVRY_PLUGIN_FREE(p1); - EVRY_PLUGIN_FREE(p2); - - eina_stringshare_del(mime_folder); - - evry_action_free(act1); - evry_action_free(act2); -} - -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/sources/evry_plug_text.c b/src/modules/everything/sources/evry_plug_text.c deleted file mode 100644 index 74b6e0117e..0000000000 --- a/src/modules/everything/sources/evry_plug_text.c +++ /dev/null @@ -1,60 +0,0 @@ -#include "Evry.h" - -static Evry_Plugin *p1; -static Evry_Plugin *p2; - - - -static void -_cleanup(Evry_Plugin *p) -{ - EVRY_PLUGIN_ITEMS_FREE(p); -} - -static int -_fetch(Evry_Plugin *p, const char *input) -{ - Evry_Item *it; - - EVRY_PLUGIN_ITEMS_FREE(p); - - if (input) - { - it = evry_item_new(NULL, p, input, NULL); - it->fuzzy_match = 9999; - EVRY_PLUGIN_ITEM_APPEND(p, it); - - return 1; - } - - return 0; -} - -static Eina_Bool -_init(void) -{ - if (!evry_api_version_check(EVRY_API_VERSION)) - return EINA_FALSE; - - p1 = evry_plugin_new(NULL, "Text", type_subject, NULL, "TEXT", 1, "accessories-text-editor", NULL, - NULL, _cleanup, _fetch, NULL, NULL, NULL, NULL); - - p2 = evry_plugin_new(NULL, "Text", type_object, NULL, "TEXT", 1, "accessories-text-editor", NULL, - NULL, _cleanup, _fetch, NULL, NULL, NULL, NULL); - - evry_plugin_register(p1, 100); - evry_plugin_register(p2, 100); - - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - EVRY_PLUGIN_FREE(p1); - EVRY_PLUGIN_FREE(p2); -} - - -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/views/Makefile.am b/src/modules/everything/views/Makefile.am deleted file mode 100644 index a6a736330f..0000000000 --- a/src/modules/everything/views/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in -MODULE = everything - -# the module .so file -INCLUDES = -I.. \ - -I$(top_srcdir) \ - -I$(top_srcdir)/src/modules/$(MODULE) \ - -I$(top_srcdir)/src/bin \ - -I$(top_srcdir)/src/lib \ - -I$(top_srcdir)/src/modules \ - @e_cflags@ - -plugindir = $(libdir)/enlightenment/modules/$(MODULE)/plugins/core/$(MODULE_ARCH) - -evry_plug_previewdir = $(plugindir) -evry_plug_preview_LTLIBRARIES = evry_plug_preview.la -evry_plug_preview_la_SOURCES = evry_plug_preview.c -evry_plug_preview_la_LIBADD = @e_libs@ ../libfoo.la -evry_plug_preview_la_LDFLAGS = -module -avoid-version -evry_plug_preview_la_LIBTOOLFLAGS = --tag=disable-static - -evry_plug_view_helpdir = $(plugindir) -evry_plug_view_help_LTLIBRARIES = evry_plug_view_help.la -evry_plug_view_help_la_SOURCES = evry_plug_view_help.c -evry_plug_view_help_la_LIBADD = @e_libs@ ../libfoo.la -evry_plug_view_help_la_LDFLAGS = -module -avoid-version -evry_plug_view_help_la_LIBTOOLFLAGS = --tag=disable-static - -evry_plug_view_thumbdir = $(plugindir) -evry_plug_view_thumb_LTLIBRARIES = evry_plug_view_thumb.la -evry_plug_view_thumb_la_SOURCES = evry_plug_view_thumb.c -evry_plug_view_thumb_la_LIBADD = @e_libs@ ../libfoo.la -evry_plug_view_thumb_la_LDFLAGS = -module -avoid-version -evry_plug_view_thumb_la_LIBTOOLFLAGS = --tag=disable-static - - diff --git a/src/modules/everything/views/evry_plug_preview.c b/src/modules/everything/views/evry_plug_preview.c deleted file mode 100644 index 1a66718857..0000000000 --- a/src/modules/everything/views/evry_plug_preview.c +++ /dev/null @@ -1,266 +0,0 @@ -#include "Evry.h" - -typedef struct _Image_View Image_View; - - -struct _Image_View -{ - Evry_View view; - Evas *evas; - - const Evry_State *state; - - Evas_Object *o_main; - - Eina_List *items; - Evas_Object *o_thumb[4]; -}; - - -static Evry_View *view = NULL; -static const char *view_types = NULL; - -static int -_check_item(const Evry_Item *it) -{ - if (!it || it->plugin->type_out != view_types) return 0; - - ITEM_FILE(file, it); - - if (!file->path || !file->mime) return 0; - - if (!strncmp(file->mime, "image/", 6)) - return 1; - - return 0; -} - -static void -_cb_preview_thumb_gen(void *data, Evas_Object *obj, void *event_info) -{ - Evas_Coord w, h; - Image_View *v = data; - - e_icon_size_get(v->o_thumb[1], &w, &h); - edje_extern_object_min_size_set(v->o_thumb[1], w, h); - edje_object_part_swallow(v->o_main, "e.swallow.icon2", v->o_thumb[1]); - evas_object_show(v->o_thumb[1]); -} - -void -_show_item(Image_View *v, const Evry_Item_File *file, int dir) -{ - int w, h; - - if (v->o_thumb[1 + dir]) - { - e_thumb_icon_end(v->o_thumb[1+dir]); - edje_object_part_unswallow(v->o_main, v->o_thumb[1+dir]); - evas_object_hide(v->o_thumb[1+dir]); - evas_object_del(v->o_thumb[1+dir]); - } - - if (dir && v->o_thumb[1]) - { - edje_object_part_unswallow(v->o_main, v->o_thumb[1]); - - if (dir > 0) - { - v->o_thumb[2] = v->o_thumb[1]; - edje_object_part_swallow(v->o_main, "e.swallow.icon1", v->o_thumb[2]); - } - else - { - v->o_thumb[0] = v->o_thumb[1]; - edje_object_part_swallow(v->o_main, "e.swallow.icon3", v->o_thumb[0]); - } - } - - v->o_thumb[1] = e_thumb_icon_add(v->evas); - e_thumb_icon_file_set(v->o_thumb[1], file->path, NULL); - evas_object_smart_callback_add(v->o_thumb[1], "e_thumb_gen", _cb_preview_thumb_gen, v); - edje_object_part_geometry_get(v->o_main, "e.swallow.icon2", NULL, NULL, &w, &h); - e_thumb_icon_size_set(v->o_thumb[1], w, h); - e_thumb_icon_begin(v->o_thumb[1]); - - if (dir) - { - if (dir > 0) - edje_object_signal_emit(v->o_main, "e,signal,slide_left", "e"); - else - edje_object_signal_emit(v->o_main, "e,signal,slide_right", "e"); - } -} - -static int -_cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) -{ - Image_View *v = (Image_View *) view; - - Eina_List *l; - Evry_Item_File *file = NULL; - - ITEM_FILE(cur_item, v->state->cur_item); - - if (!strcmp(ev->key, "Down")) - { - if (!v->items) return 1; - - l = eina_list_data_find_list(v->items, cur_item); - - if (l && l->next) - file = l->next->data; - else - file = v->items->data; - - if (file && (file != cur_item)) - { - _show_item(v, file, 1); - evry_item_select(v->state, EVRY_ITEM(file)); - } - return 1; - } - else if (!strcmp(ev->key, "Up")) - { - if (!v->items) return 1; - - l = eina_list_data_find_list(v->items, cur_item); - - if (l && l->prev) - file = l->prev->data; - else - file = eina_list_last(v->items)->data; - - if (file && (file != cur_item)) - { - _show_item(v, file, -1); - evry_item_select(v->state, EVRY_ITEM(file)); - } - return 1; - } - - return 0; -} - -static void -_view_clear(Evry_View *view) -{ - Image_View *v = (Image_View *) view; - - if (v->o_thumb[0]) evas_object_del(v->o_thumb[0]); - v->o_thumb[0] = NULL; - if (v->o_thumb[1]) evas_object_del(v->o_thumb[1]); - v->o_thumb[1] = NULL; - if (v->o_thumb[2]) evas_object_del(v->o_thumb[2]); - v->o_thumb[2] = NULL; - if (v->items) eina_list_free(v->items); - v->items = NULL; -} - -static Eina_List * -_get_list(const Evry_State *s) -{ - Eina_List *l, *items = NULL; - Evry_Item *it; - - EINA_LIST_FOREACH(s->plugin->items, l, it) - if (_check_item(it)) - items = eina_list_append(items, it); - - return items; -} - -static int -_view_update(Evry_View *view) -{ - Image_View *v = (Image_View *) view; - Evry_Item_File *file; - Evry_Item *selected = v->state->cur_item; - - v->items = _get_list(v->state); - if (!v->items) return 0; - - file = eina_list_data_find(v->items, selected); - if (!file) - { - file = v->items->data; - evry_item_select(v->state, EVRY_ITEM(file)); - } - - _show_item(v, file, 0); - - return 1; -} - -static Evry_View * -_view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow) -{ - Image_View *v; - int w, h, x, y; - - if (!s->plugin) - return NULL; - - if (!_get_list(s)) - return NULL; - - v = E_NEW(Image_View, 1); - v->view = *view; - v->state = s; - v->evas = evas_object_evas_get(swallow); - v->o_main = edje_object_add(v->evas); - e_theme_edje_object_set(v->o_main, "base/theme/everything", - "e/modules/everything/preview"); - - edje_object_part_geometry_get(swallow, "e.swallow.list", &x, &y, &w, &h); - edje_extern_object_min_size_set(v->o_main, w * 3, 100); - evas_object_resize(v->o_main, w * 3, h); - - EVRY_VIEW(v)->o_list = v->o_main; - - return EVRY_VIEW(v); -} - -static void -_view_destroy(Evry_View *view) -{ - Image_View *v = (Image_View *) view; - - _view_clear(view); - evas_object_del(v->o_main); - - E_FREE(v); -} - -static Eina_Bool -_init(void) -{ - if (!evry_api_version_check(EVRY_API_VERSION)) - return EINA_FALSE; - - view = E_NEW(Evry_View, 1); - view->id = view; - view->name = "Image Viewer"; - view->create = &_view_create; - view->destroy = &_view_destroy; - view->update = &_view_update; - view->clear = &_view_clear; - view->cb_key_down = &_cb_key_down; - evry_view_register(view, 3); - - view_types = eina_stringshare_add("FILE"); - - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - eina_stringshare_del(view_types); - evry_view_unregister(view); - E_FREE(view); -} - - -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/views/evry_plug_view_help.c b/src/modules/everything/views/evry_plug_view_help.c deleted file mode 100644 index 4c453d5ef1..0000000000 --- a/src/modules/everything/views/evry_plug_view_help.c +++ /dev/null @@ -1,139 +0,0 @@ -#include "Evry.h" - -static Evry_View *view; -static Evas_Object *o_text = NULL; - -static void -_view_clear(Evry_View *v) -{ - v->active = 0; - evas_object_del(v->o_list); - evas_object_del(o_text); - o_text = NULL; -} - - -static int -_view_update(Evry_View *v) -{ - return 1; -} - -static int -_cb_key_down(Evry_View *v, const Ecore_Event_Key *ev) -{ - Evas_Object *o; - double align; - int h; - - if (!strcmp(ev->key, "Down")) - { - o = v->o_list; - evas_object_geometry_get(o, NULL, NULL, NULL, &h); - e_box_align_get(o, NULL, &align); - - align = align - (double)10/(double)h; - if (align < 0.0) align = 0.0; - - e_box_align_set(v->o_list, 0.5, align); - - return 1; - } - else if (!strcmp(ev->key, "Up")) - { - o = v->o_list; - evas_object_geometry_get(o, NULL, NULL, NULL, &h); - e_box_align_get(o, NULL, &align); - - align = align + (double)10/(double)h; - if (align > 1.0) align = 1.0; - - e_box_align_set(v->o_list, 0.5, align); - return 1; - } - - return 0; -} - -static Evry_View * -_view_create(Evry_View *v, const Evry_State *s, const Evas_Object *swallow) -{ - Evas_Object *o; - int mw, mh; - - char *text = - "<title><b>Welcome!</b></title>" - "Ok, here comes the explanation of <hilight>everything</hilight>...<br>" - "Just type a few letters of the thing you are looking for. <br>" - "Use cursor <hilight><up/down></hilight> to choose from the list of things.<br>" - "Press <hilight><tab></hilight> to select " - "an action, then press <hilight><return></hilight>.<br>" - /* "You might want to know <br>some mo keybinding to ease your experience though.<br>" */ - "<hilight><space><?></hilight> show this page<br>" - "<hilight><ctrl+letter></hilight> jump to plugin beginning with 'letter'<br>" - "<hilight><ctrl+left/right></hilight>" - "cycle through plugins<br>" - "<hilight><ctrl+1></hilight> " - "choose a different view (e.g. for images)<br>"; - - if (v->active) return v; - - o = e_box_add(evas_object_evas_get(swallow)); - e_box_orientation_set(o, 0); - e_box_align_set(o, 0.5, 1.0); - v->o_list = o; - e_box_freeze(v->o_list); - o = edje_object_add(evas_object_evas_get(swallow)); - e_theme_edje_object_set(o, "base/theme/widgets", - "e/widgets/textblock"); - - edje_object_part_text_set(o, "e.textblock.text", text); - e_box_pack_start(v->o_list, o); - edje_object_size_min_calc(o, &mw, &mh); - e_box_pack_options_set(o, 1, 0, 1, 0, 0.5, 0.5, mw, mh + 200, 999, 999); - e_box_thaw(v->o_list); - evas_object_show(o); - o_text = o; - - v->active = 1; - - return v; -} - -static void -_view_destroy(Evry_View *v) -{ - v->active = 0; -} - -static Eina_Bool -_init(void) -{ - if (!evry_api_version_check(EVRY_API_VERSION)) - return EINA_FALSE; - - view = E_NEW(Evry_View, 1); - view->id = view; - view->name = "Help"; - view->create = &_view_create; - view->destroy = &_view_destroy; - view->update = &_view_update; - view->clear = &_view_clear; - view->cb_key_down = &_cb_key_down; - view->trigger = "?"; - /* view->types = "NONE"; */ - evry_view_register(view, 2); - - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - evry_view_unregister(view); - E_FREE(view); -} - - -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/views/evry_plug_view_thumb.c b/src/modules/everything/views/evry_plug_view_thumb.c deleted file mode 100644 index e5c4afab23..0000000000 --- a/src/modules/everything/views/evry_plug_view_thumb.c +++ /dev/null @@ -1,1087 +0,0 @@ -#include "e_mod_main.h" - -typedef struct _View View; -typedef struct _Smart_Data Smart_Data; -typedef struct _Item Item; - -struct _View -{ - Evry_View view; - Tab_View *tabs; - - const Evry_State *state; - const Evry_Plugin *plugin; - - Evas *evas; - Evas_Object *bg, *sframe, *span; - int iw, ih; - int zoom; - int list_mode; - - Eina_List *handlers; -}; - -/* smart object based on wallpaper module */ -struct _Smart_Data -{ - View *view; - Eina_List *items; - Item *cur_item; - Ecore_Idle_Enterer *idle_enter; - Ecore_Idle_Enterer *thumb_idler; - Ecore_Idle_Enterer *update_idler; - Ecore_Animator *animator; - Evas_Coord x, y, w, h; - Evas_Coord cx, cy, cw, ch; - Evas_Coord sx, sy; - double selmove; - Eina_Bool update : 1; - Eina_Bool switch_mode : 1; - Eina_List *queue; -}; - -struct _Item -{ - Evry_Item *item; - Evas_Object *obj; - Evas_Coord x, y, w, h; - Evas_Object *frame, *image, *thumb; - Eina_Bool selected : 1; - Eina_Bool have_thumb : 1; - Eina_Bool do_thumb : 1; - Eina_Bool get_thumb : 1; - Eina_Bool showing : 1; - Eina_Bool visible : 1; - Eina_Bool changed : 1; - int pos; -}; - -static View *view = NULL; -static const char *view_types = NULL; - -static void -_thumb_gen(void *data, Evas_Object *obj, void *event_info) -{ - Evas_Coord w, h; - Item *it = data; - - if (!it->frame) return; - - e_icon_size_get(it->thumb, &w, &h); - edje_extern_object_aspect_set(it->thumb, EDJE_ASPECT_CONTROL_BOTH, w, h); - edje_object_part_swallow(it->frame, "e.swallow.thumb", it->thumb); - evas_object_show(it->thumb); - it->have_thumb = EINA_TRUE; - it->do_thumb = EINA_FALSE; - - if (it->image) evas_object_del(it->image); - it->image = NULL; - -} - -static int -_check_item(const Evry_Item *it) -{ - if (it->plugin->type_out != view_types) return 0; - - ITEM_FILE(file, it); - - if (!file->path || !file->mime) return 0; - - if (!strncmp(file->mime, "image/", 6)) - return 1; - - return 0; -} - -static int -_thumb_idler(void *data) -{ - Smart_Data *sd = data; - Eina_List *l, *ll; - Item *it; - - EINA_LIST_FOREACH_SAFE(sd->queue, l, ll, it) - { - if (!it->image && !it->have_thumb && - sd->view->state->plugin && - sd->view->state->plugin->icon_get) - { - it->image = sd->view->state->plugin->icon_get - (it->item->plugin, it->item, sd->view->evas); - - if (it->image) - { - edje_object_part_swallow(it->frame, "e.swallow.icon", it->image); - evas_object_show(it->image); - } - - /* dirbrowse fetches the mimetype for icon_get */ - if (!it->get_thumb && _check_item(it->item)) - it->get_thumb = EINA_TRUE; - } - - if (it->get_thumb && !it->thumb && !(it->have_thumb || it->do_thumb)) - { - it->thumb = e_thumb_icon_add(sd->view->evas); - - ITEM_FILE(file, it->item); - - evas_object_smart_callback_add(it->thumb, "e_thumb_gen", _thumb_gen, it); - - e_thumb_icon_file_set(it->thumb, file->path, NULL); - e_thumb_icon_size_set(it->thumb, it->w, it->h); - e_thumb_icon_begin(it->thumb); - it->do_thumb = EINA_TRUE; - } - - sd->queue = eina_list_remove_list(sd->queue, l); - e_util_wakeup(); - return 1; - } - - sd->thumb_idler = NULL; - - return 0; -} - -static int -_e_smart_reconfigure_do(void *data) -{ - Evas_Object *obj = data; - Smart_Data *sd = evas_object_smart_data_get(obj); - Eina_List *l; - Item *it; - int iw, redo = 0, changed = 0; - static int recursion = 0; - Evas_Coord x, y, xx, yy, ww, hh, mw, mh, ox = 0, oy = 0; - Evas_Coord aspect_w, aspect_h; - - if (!sd) return 0; - if (sd->cx > (sd->cw - sd->w)) sd->cx = sd->cw - sd->w; - if (sd->cy > (sd->ch - sd->h)) sd->cy = sd->ch - sd->h; - if (sd->cx < 0) sd->cx = 0; - if (sd->cy < 0) sd->cy = 0; - - aspect_w = sd->w; - aspect_h = sd->h; - - if (sd->view->list_mode) - { - iw = sd->w; - } - else if (sd->view->zoom == 0) - { - int cnt = eina_list_count(sd->items); - - aspect_w *= 3; - aspect_w /= 4; - - if (cnt < 3) - iw = (double)sd->w / 2.5; - else if (cnt < 7) - iw = sd->w / 3; - else - iw = sd->w / 4; - } - else if (sd->view->zoom == 1) - { - aspect_w *= 2; - aspect_w /= 3; - iw = sd->w / 3; - } - else /* if (sd->zoom == 2) */ - { - iw = sd->w; - } - - if (aspect_w <= 0) aspect_w = 1; - if (aspect_h <= 0) aspect_h = 1; - - x = 0; - y = 0; - ww = iw; - if (sd->view->list_mode) - hh = 32; - else - hh = (aspect_h * iw) / (aspect_w); - - mw = mh = 0; - EINA_LIST_FOREACH(sd->items, l, it) - { - if (x > (sd->w - ww)) - { - x = 0; - y += hh; - } - - it->x = x; - it->y = y; - it->w = ww; - it->h = hh; - - if ((x + ww) > mw) mw = x + ww; - if ((y + hh) > mh) mh = y + hh; - x += ww; - } - - if ((mw != sd->cw) || (mh != sd->ch)) - { - sd->cw = mw; - sd->ch = mh; - if (sd->cx > (sd->cw - sd->w)) - { - sd->cx = sd->cw - sd->w; - redo = 1; - } - if (sd->cy > (sd->ch - sd->h)) - { - sd->cy = sd->ch - sd->h; - redo = 1; - } - if (sd->cx < 0) - { - sd->cx = 0; - redo = 1; - } - if (sd->cy < 0) - { - sd->cy = 0; - redo = 1; - } - if (redo) - { - recursion = 1; - _e_smart_reconfigure_do(obj); - recursion = 0; - } - changed = 1; - } - - if (sd->switch_mode) - { - if (changed) - evas_object_smart_callback_call(obj, "changed", NULL); - - sd->update = EINA_TRUE; - sd->switch_mode = EINA_FALSE; - - if (recursion == 0) - sd->idle_enter = NULL; - return 0; - } - - if (!sd->view->list_mode) - { - if (sd->w > sd->cw) ox = (sd->w - sd->cw) / 2; - if (sd->h > sd->ch) oy = (sd->h - sd->ch) / 2; - } - - EINA_LIST_FOREACH(sd->items, l, it) - { - xx = sd->x - sd->cx + it->x + ox; - yy = sd->y - sd->cy + it->y + oy; - - if (E_INTERSECTS(xx, yy, it->w, it->h, 0, sd->y - (it->h*4), - sd->x + sd->w, sd->y + sd->h + it->h*8)) - { - if (!it->visible) - { - if (!it->frame) - { - it->frame = edje_object_add(sd->view->evas); - if (sd->view->list_mode) - e_theme_edje_object_set(it->frame, "base/theme/widgets", - "e/modules/everything/thumbview/item/list"); - else - e_theme_edje_object_set(it->frame, "base/theme/widgets", - "e/modules/everything/thumbview/item/thumb"); - - evas_object_smart_member_add(it->frame, obj); - evas_object_clip_set(it->frame, evas_object_clip_get(obj)); - } - - edje_object_part_text_set(it->frame, "e.text.label", it->item->label); - evas_object_show(it->frame); - - if (it->changed) - edje_object_signal_emit(it->frame, "e,action,thumb,show_delayed", "e"); - else - edje_object_signal_emit(it->frame, "e,action,thumb,show", "e"); - - if (it->item->browseable) - edje_object_signal_emit(it->frame, "e,state,browseable", "e"); - - it->visible = EINA_TRUE; - } - - if (!eina_list_data_find(sd->queue, it)) - { - sd->queue = eina_list_append(sd->queue, it); - } - - evas_object_move(it->frame, xx, yy); - evas_object_resize(it->frame, it->w, it->h); - - /* if (sd->update || it->changed) - * { - * if (it->selected && sd->view->zoom < 2) - * edje_object_signal_emit(it->frame, "e,state,selected", "e"); - * else - * edje_object_signal_emit(it->frame, "e,state,unselected", "e"); - * } */ - } - else if (it->visible) - { - sd->queue = eina_list_remove(sd->queue, it); - if (it->do_thumb) e_thumb_icon_end(it->thumb); - if (it->thumb) evas_object_del(it->thumb); - if (it->image) evas_object_del(it->image); - if (it->frame) evas_object_del(it->frame); - - it->thumb = NULL; - it->image = NULL; - it->frame = NULL; - - it->have_thumb = EINA_FALSE; - it->do_thumb = EINA_FALSE; - it->visible = EINA_FALSE; - } - it->changed = EINA_FALSE; - } - - if (changed) - evas_object_smart_callback_call(obj, "changed", NULL); - - if (!sd->thumb_idler) - sd->thumb_idler = ecore_idle_enterer_before_add(_thumb_idler, sd); - - sd->update = EINA_TRUE; - - if (recursion == 0) - sd->idle_enter = NULL; - return 0; -} - -static void -_e_smart_reconfigure(Evas_Object *obj) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - - if (sd->idle_enter) return; - sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, obj); -} - -static void -_e_smart_add(Evas_Object *obj) -{ - Smart_Data *sd = calloc(1, sizeof(Smart_Data)); - if (!sd) return; - sd->x = sd->y = sd->w = sd->h = 0; - sd->sx = sd->sy = -1; - evas_object_smart_data_set(obj, sd); -} - -static void -_e_smart_del(Evas_Object *obj) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - Item *it; - - if (sd->idle_enter) - ecore_idle_enterer_del(sd->idle_enter); - if (sd->thumb_idler) - ecore_idle_enterer_del(sd->thumb_idler); - - // sd->view is just referenced - // sd->child_obj is unused - EINA_LIST_FREE(sd->items, it) - { - if (it->do_thumb) e_thumb_icon_end(it->thumb); - if (it->thumb) evas_object_del(it->thumb); - if (it->frame) evas_object_del(it->frame); - if (it->image) evas_object_del(it->image); - evry_item_free(it->item); - free(it); - } - free(sd); - evas_object_smart_data_set(obj, NULL); -} - -static void -_e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - sd->x = x; - sd->y = y; - _e_smart_reconfigure(obj); -} - -static void -_e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - sd->w = w; - sd->h = h; - _e_smart_reconfigure(obj); - evas_object_smart_callback_call(obj, "changed", NULL); -} - -static void -_e_smart_show(Evas_Object *obj){} - -static void -_e_smart_hide(Evas_Object *obj){} - -static void -_e_smart_color_set(Evas_Object *obj, int r, int g, int b, int a){} - -static void -_e_smart_clip_set(Evas_Object *obj, Evas_Object * clip){} - -static void -_e_smart_clip_unset(Evas_Object *obj){} - -static Evas_Object * -_pan_add(Evas *evas) -{ - static Evas_Smart *smart = NULL; - static const Evas_Smart_Class sc = - { - "wp_pan", - EVAS_SMART_CLASS_VERSION, - _e_smart_add, - _e_smart_del, - _e_smart_move, - _e_smart_resize, - _e_smart_show, - _e_smart_hide, - _e_smart_color_set, - _e_smart_clip_set, - _e_smart_clip_unset, - NULL, - NULL, - NULL, - NULL - }; - smart = evas_smart_class_new(&sc); - return evas_object_smart_add(evas, smart); -} - -static void -_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - if (x > (sd->cw - sd->w)) x = sd->cw - sd->w; - if (y > (sd->ch - sd->h)) y = sd->ch - sd->h; - if (x < 0) x = 0; - if (y < 0) y = 0; - if ((sd->cx == x) && (sd->cy == y)) return; - sd->cx = x; - sd->cy = y; - _e_smart_reconfigure(obj); -} - -static void -_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - if (x) *x = sd->cx; - if (y) *y = sd->cy; -} - -static void -_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - if (x) - { - if (sd->w < sd->cw) *x = sd->cw - sd->w; - else *x = 0; - } - if (y) - { - if (sd->h < sd->ch) *y = sd->ch - sd->h; - else *y = 0; - } -} - -static void -_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - if (w) *w = sd->cw; - if (h) *h = sd->ch; -} - -static void -_pan_view_set(Evas_Object *obj, View *view) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - sd->view = view; -} - -static Item * -_pan_item_add(Evas_Object *obj, Evry_Item *item) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - Item *it; - - it = E_NEW(Item, 1); - if (!it) return NULL; - - sd->items = eina_list_append(sd->items, it); - it->obj = obj; - it->item = item; - it->changed = EINA_TRUE; - - if (_check_item(item)) - it->get_thumb = EINA_TRUE; - - evry_item_ref(item); - - _e_smart_reconfigure(obj); - - return it; -} - -static void -_pan_item_remove(Evas_Object *obj, Item *it) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - - sd->items = eina_list_remove(sd->items, it); - if (it->do_thumb) e_thumb_icon_end(it->thumb); - if (it->thumb) evas_object_del(it->thumb); - if (it->frame) evas_object_del(it->frame); - if (it->image) evas_object_del(it->image); - - sd->queue = eina_list_remove(sd->queue, it); - - evry_item_free(it->item); - E_FREE(it); - - _e_smart_reconfigure(obj); -} - -static void -_pan_item_select(Evas_Object *obj, Item *it) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - int align = -1; - - if (sd->cur_item) - { - sd->cur_item->selected = EINA_FALSE; - edje_object_signal_emit(sd->cur_item->frame, "e,state,unselected", "e"); - } - - if (it) - { - sd->update = EINA_FALSE; - - sd->cur_item = it; - sd->cur_item->selected = EINA_TRUE; - - if (sd->view->list_mode) - align = it->y - (double)it->y / (double)sd->ch * (sd->h - it->h); - else if ((it->y + it->h) - sd->cy > sd->h) - align = it->y - (2 - sd->view->zoom) * it->h; - else if (it->y < sd->cy) - align = it->y; - - if (align >= 0) - e_scrollframe_child_pos_set(sd->view->sframe, 0, align); - - if (sd->view->zoom < 2) - edje_object_signal_emit(sd->cur_item->frame, "e,state,selected", "e"); - - if (sd->idle_enter) ecore_idle_enterer_del(sd->idle_enter); - sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, obj); - } -} - -static void -_clear_items(Evas_Object *obj) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - Eina_List *l; - Item *it; - - EINA_LIST_FOREACH(sd->items, l, it) - { - if (it->do_thumb) - e_thumb_icon_end(it->thumb); - if (it->frame) evas_object_del(it->frame); - if (it->image) evas_object_del(it->image); - if (it->thumb) evas_object_del(it->thumb); - it->frame = NULL; - it->image = NULL; - it->thumb = NULL; - it->have_thumb = EINA_FALSE; - it->do_thumb = EINA_FALSE; - it->visible = EINA_FALSE; - } - - if (sd->queue) - eina_list_free(sd->queue); - sd->queue = NULL; - - if (sd->thumb_idler) - ecore_idle_enterer_del(sd->thumb_idler); - sd->thumb_idler = NULL; -} - -static void -_view_clear(Evry_View *view) -{ - View *v = (View*) view; - Smart_Data *sd = evas_object_smart_data_get(v->span); - Item *it; - - _clear_items(v->span); - - EINA_LIST_FREE(sd->items, it) - { - evry_item_free(it->item); - E_FREE(it); - } - - if (sd->idle_enter) ecore_idle_enterer_del(sd->idle_enter); - sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, v->span); - - v->tabs->clear(v->tabs); -} - -static int -_sort_cb(const void *data1, const void *data2) -{ - const Item *it1 = data1; - const Item *it2 = data2; - - return it1->pos - it2->pos; -} - -static int -_update_frame(Evas_Object *obj) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - //sd->switch_mode = EINA_TRUE; - _e_smart_reconfigure_do(obj); - //sd->switch_mode = EINA_FALSE; - _pan_item_select(obj, sd->cur_item); - - return 0; -} - -static int -_view_update(Evry_View *view) -{ - VIEW(v, view); - Smart_Data *sd = evas_object_smart_data_get(v->span); - Item *v_it; - Evry_Item *p_it; - Eina_List *l, *ll, *p_items, *v_remove = NULL, *v_items = NULL; - int pos, last_pos, last_vis = 0, first_vis = 0; - Eina_Bool update = EINA_FALSE; - - if (!v->state->plugin) - { - _view_clear(view); - return 1; - } - - p_items = v->state->plugin->items; - - /* go through current view items */ - EINA_LIST_FOREACH(sd->items, l, v_it) - { - last_pos = v_it->pos; - v_it->pos = 0; - pos = 1; - - /* go through plugins current items */ - EINA_LIST_FOREACH(p_items, ll, p_it) - { - if (v_it->item == p_it) - { - if (pos != last_pos) - v_it->changed = EINA_TRUE; - - v_it->pos = pos; - - /* set selected state -> TODO remove*/ - /* if (p_it == v->state->cur_item) */ - if (p_it->selected) - { - sd->cur_item = v_it; - v_it->selected = EINA_TRUE; - } - else - { - v_it->selected = EINA_FALSE; - edje_object_signal_emit(v_it->frame, "e,state,unselected", "e"); - } - - break; - } - pos++; - } - - if (v_it->visible) - { - if (!first_vis) - first_vis = v_it->pos; - last_vis = v_it->pos; - } - - /* view item is in list of current items */ - if (v_it->pos) - { - v_items = eina_list_append(v_items, v_it->item); - - if (_check_item(v_it->item)) - v_it->get_thumb = EINA_TRUE; - - if (v_it->visible && v_it->changed) - update = EINA_TRUE; - } - else - { - if (v_it->visible) update = EINA_TRUE; - v_remove = eina_list_append(v_remove, v_it); - } - } - - EINA_LIST_FREE(v_remove, v_it) - _pan_item_remove(v->span, v_it); - - /* go through plugins current items */ - pos = 1; - EINA_LIST_FOREACH(p_items, l, p_it) - { - /* item is not already in view */ - if (!eina_list_data_find_list(v_items, p_it)) - { - v_it = _pan_item_add(v->span, p_it); - - if (!v_it) continue; - - v_it->pos = pos; - - /* TODO no needed */ - /* if (p_it == v->state->cur_item) */ - if (p_it->selected) - { - sd->cur_item = v_it; - v_it->selected = EINA_TRUE; - } - - if (pos > first_vis && pos < last_vis) - update = EINA_TRUE; - } - pos++; - } - - sd->items = eina_list_sort(sd->items, eina_list_count(sd->items), _sort_cb); - - if (update || !last_vis || v->plugin != v->state->plugin) - { - v->plugin = v->state->plugin; - - sd->update = EINA_TRUE; - _update_frame(v->span); - } - - if (v_items) eina_list_free(v_items); - - v->tabs->update(v->tabs); - - sd->update_idler = NULL; - - return 0; -} - -static int -_cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) -{ - View *v = (View *) view; - Smart_Data *sd = evas_object_smart_data_get(v->span); - Eina_List *l = NULL, *ll; - Item *it = NULL; - - if (!v->state->plugin) - return 0; - - if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) && - (!strcmp(ev->key, "2"))) - { - v->list_mode = v->list_mode ? EINA_FALSE : EINA_TRUE; - v->zoom = 0; - _clear_items(v->span); - _update_frame(v->span); - goto end; - } - else if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) && - ((!strcmp(ev->key, "plus")) || - (!strcmp(ev->key, "3")))) - { - v->zoom++; - if (v->zoom > 2) v->zoom = 0; - if (v->zoom == 2) - _clear_items(v->span); - - _update_frame(v->span); - goto end; - } - - if (v->tabs->key_down(v->tabs, ev)) - { - _view_update(view); - return 1; - } - - if (sd->items) - l = eina_list_data_find_list(sd->items, sd->cur_item); - - if (!v->list_mode && !evry_conf->cycle_mode) - { - if (!strcmp(ev->key, "Right")) - { - if (l && l->next) - it = l->next->data; - - if (it) - { - _pan_item_select(v->span, it); - evry_item_select(v->state, it->item); - } - goto end; - } - else if (!strcmp(ev->key, "Left")) - { - if (!sd->items) return 1; - - if (l && l->prev) - it = l->prev->data; - - if (it) - { - _pan_item_select(v->span, it); - evry_item_select(v->state, it->item); - } - goto end; - } - } - if (!strcmp(ev->key, "Down")) - { - if (!sd->items) return 1; - - if (!evry_conf->cycle_mode) - { - EINA_LIST_FOREACH(l, ll, it) - { - if (it->y > sd->cur_item->y && - it->x >= sd->cur_item->x) - break; - } - } - - if (!it && l && l->next) - it = l->next->data; - - if (it) - { - _pan_item_select(v->span, it); - evry_item_select(v->state, it->item); - } - goto end; - } - else if (!strcmp(ev->key, "Up")) - { - if (!sd->items) return 1; - - if (!evry_conf->cycle_mode) - { - for(ll = l; ll; ll = ll->prev) - { - it = ll->data; - - if (it->y < sd->cur_item->y && - it->x <= sd->cur_item->x) - break; - } - } - - if (!it && l && l->prev) - it = l->prev->data; - - if (it) - { - _pan_item_select(v->span, it); - evry_item_select(v->state, it->item); - } - goto end; - } - else if (!strcmp(ev->key, "Return")) - { - if (!v->list_mode) - { - if (evry_browse_item(NULL)) - goto end; - } - } - - return 0; - - end: - return 1; -} - -static int -_cb_item_changed(void *data, int type, void *event) -{ - Evry_Event_Item_Changed *ev = event; - View *v = data; - Eina_List *l; - Item *it; - Smart_Data *sd = evas_object_smart_data_get(v->span); - - if (!sd) return 0; - - EINA_LIST_FOREACH(sd->items, l, it) - if (it->item == ev->item) - { - if (!it->visible) break; - - edje_object_part_text_set(it->frame, "e.text.label", it->item->label); - - if (it->do_thumb) e_thumb_icon_end(it->thumb); - if (it->thumb) evas_object_del(it->thumb); - if (it->image) evas_object_del(it->image); - - it->thumb = NULL; - it->image = NULL; - - it->have_thumb = EINA_FALSE; - it->do_thumb = EINA_FALSE; - - if (!eina_list_data_find(sd->queue, it)) - sd->queue = eina_list_append(sd->queue, it); - - if (!sd->thumb_idler) - sd->thumb_idler = ecore_idle_enterer_before_add(_thumb_idler, sd); - } - - return 1; -} - -static Evry_View * -_view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow) -{ - VIEW(parent, view); - - View *v; - Ecore_Event_Handler *h; - - if (!s->plugin) - return NULL; - - v = E_NEW(View, 1); - v->view = *view; - v->state = s; - v->evas = evas_object_evas_get(swallow); - - if (parent->list_mode < 0) - v->list_mode = evry_conf->view_mode ? 0 : 1; - else - v->list_mode = parent->list_mode; - - v->zoom = parent->zoom; - - v->bg = edje_object_add(v->evas); - e_theme_edje_object_set(v->bg, "base/theme/widgets", - "e/modules/everything/thumbview/main/window"); - // scrolled thumbs - v->span = _pan_add(v->evas); - _pan_view_set(v->span, v); - - // the scrollframe holding the scrolled thumbs - v->sframe = e_scrollframe_add(v->evas); - e_scrollframe_custom_theme_set(v->sframe, "base/theme/widgets", - "e/modules/everything/thumbview/main/scrollframe"); - e_scrollframe_extern_pan_set(v->sframe, v->span, - _pan_set, _pan_get, _pan_max_get, - _pan_child_size_get); - edje_object_part_swallow(v->bg, "e.swallow.list", v->sframe); - evas_object_show(v->sframe); - evas_object_show(v->span); - - EVRY_VIEW(v)->o_list = v->bg; - - v->tabs = evry_tab_view_new(s, v->evas); - v->view.o_bar = v->tabs->o_tabs; - - h = ecore_event_handler_add(EVRY_EVENT_ITEM_CHANGED, _cb_item_changed, v); - v->handlers = eina_list_append(v->handlers, h); - - return EVRY_VIEW(v); -} - -static void -_view_destroy(Evry_View *view) -{ - VIEW(v, view); - - Ecore_Event_Handler *h; - - evas_object_del(v->bg); - evas_object_del(v->sframe); - evas_object_del(v->span); - - evry_tab_view_free(v->tabs); - - EINA_LIST_FREE(v->handlers, h) - ecore_event_handler_del(h); - - E_FREE(v); -} - -static Eina_Bool -_init(void) -{ - if (!evry_api_version_check(EVRY_API_VERSION)) - return EINA_FALSE; - - View *v = E_NEW(View, 1); - - v->view.id = EVRY_VIEW(v); - v->view.name = "Icon View"; - v->view.create = &_view_create; - v->view.destroy = &_view_destroy; - v->view.update = &_view_update; - v->view.clear = &_view_clear; - v->view.cb_key_down = &_cb_key_down; - v->list_mode = -1; - - evry_view_register(EVRY_VIEW(v), 1); - - view = v; - - view_types = eina_stringshare_add("FILE"); - - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - eina_stringshare_del(view_types); - evry_view_unregister(EVRY_VIEW(view)); - E_FREE(view); -} - - -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); - |