From c5507a54dd2d7552744f416ccac1fc6399eaa606 Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Sun, 30 Aug 2009 08:51:15 +0000 Subject: [PATCH] =?UTF-8?q?'everything'=20-=20added=20history=20that=20sho?= =?UTF-8?q?uld=20adapt=20sort=20list=20sorting=20to=20usage=20-=20conf=20d?= =?UTF-8?q?ialog:=20moved=20plugi=CE=B3=20types=20to=20separate=20pages=20?= =?UTF-8?q?-=20fixed=20bug=20from=20shared=20hash=20of=20apps=20plugins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SVN revision: 42095 --- src/modules/everything/Evry.h | 4 +- src/modules/everything/e_mod_main.c | 334 ++++++++++++------ src/modules/everything/e_mod_main.h | 38 +- src/modules/everything/evry.c | 158 +++++++-- src/modules/everything/evry_config.c | 41 ++- src/modules/everything/evry_plug_aggregator.c | 50 ++- .../everything/evry_view_plugin_tabs.c | 10 +- .../everything/sources/evry_plug_apps.c | 28 +- .../everything/sources/evry_plug_border.c | 15 + .../everything/sources/evry_plug_dir_browse.c | 11 + .../everything/sources/evry_plug_tracker.c | 117 +++--- 11 files changed, 585 insertions(+), 221 deletions(-) diff --git a/src/modules/everything/Evry.h b/src/modules/everything/Evry.h index e129b5d43..7acb39c11 100644 --- a/src/modules/everything/Evry.h +++ b/src/modules/everything/Evry.h @@ -88,6 +88,7 @@ struct _Evry_Item Evry_Plugin *plugin; int ref; void (*free) (Evry_Item *item); + double usage; }; struct _Evry_Item_App @@ -136,7 +137,8 @@ struct _Evry_Plugin Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e); /* provide more information for a candidate */ /* int (*candidate_info) (Evas *evas, Evry_Item *item); */ - + const char *(*item_id) (Evry_Plugin *p, const Evry_Item *it); + /* optional: default action for this plugins items */ int (*action) (Evry_Plugin *p, const Evry_Item *item); diff --git a/src/modules/everything/e_mod_main.c b/src/modules/everything/e_mod_main.c index ca24f69d0..c4c8aba5d 100644 --- a/src/modules/everything/e_mod_main.c +++ b/src/modules/everything/e_mod_main.c @@ -9,13 +9,18 @@ #include "e_mod_main.h" -#define CONFIG_VERSION 3 +#define CONFIG_VERSION 5 +#define HISTORY_VERSION 1 /* actual module specifics */ -static void _e_mod_action_exebuf_cb(E_Object *obj, const char *params); +static void _e_mod_action_cb(E_Object *obj, const char *params); static int _e_mod_run_defer_cb(void *data); static void _e_mod_run_cb(void *data, E_Menu *m, E_Menu_Item *mi); static void _e_mod_menu_add(void *data, E_Menu *m); +static void _config_init(void); +static void _config_free(void); +static void _history_init(void); +static void _history_free(void); static E_Int_Menu_Augmentation *maug = NULL; static E_Action *act = NULL; @@ -23,8 +28,13 @@ static E_Action *act = NULL; static Eina_Array *plugins = NULL; static E_Config_DD *conf_edd = NULL; static E_Config_DD *conf_item_edd = NULL; +static E_Config_DD *hist_entry_edd = NULL; +static E_Config_DD *hist_item_edd = NULL; +static E_Config_DD *hist_edd = NULL; + Config *evry_conf = NULL; +History *evry_hist = NULL; /* module setup */ EAPI E_Module_Api e_modapi = @@ -33,7 +43,6 @@ EAPI E_Module_Api e_modapi = "Everything" }; - static Eina_Bool list_cb(Eina_Module *m, void *data) { if (eina_module_load(m)) @@ -50,67 +59,18 @@ e_modapi_init(E_Module *m) char *file; E_Action *act; - snprintf(buf, sizeof(buf), "%s/.e/e/config/%s/module.everything", - e_user_homedir_get(), e_config_profile_get()); - ecore_file_mkdir(buf); - - conf_item_edd = E_CONFIG_DD_NEW("Plugin_Config", Plugin_Config); -#undef T -#undef D -#define T Plugin_Config -#define D conf_item_edd - E_CONFIG_VAL(D, T, name, STR); - E_CONFIG_VAL(D, T, trigger, STR); - E_CONFIG_VAL(D, T, min_query, INT); - E_CONFIG_VAL(D, T, loaded, INT); - E_CONFIG_VAL(D, T, enabled, INT); - E_CONFIG_VAL(D, T, priority, INT); - conf_edd = E_CONFIG_DD_NEW("Config", Config); -#undef T -#undef D -#define T Config -#define D conf_edd - E_CONFIG_VAL(D, T, version, INT); - E_CONFIG_VAL(D, T, width, INT); - E_CONFIG_VAL(D, T, height, INT); - E_CONFIG_VAL(D, T, rel_x, DOUBLE); - E_CONFIG_VAL(D, T, rel_y, DOUBLE); - E_CONFIG_VAL(D, T, scroll_animate, INT); - E_CONFIG_VAL(D, T, scroll_speed, DOUBLE); - E_CONFIG_VAL(D, T, hide_input, INT); - E_CONFIG_VAL(D, T, hide_list, INT); - E_CONFIG_VAL(D, T, quick_nav, INT); - E_CONFIG_LIST(D, T, conf_subjects, conf_item_edd); - E_CONFIG_LIST(D, T, conf_actions, conf_item_edd); - E_CONFIG_LIST(D, T, conf_objects, conf_item_edd); - E_CONFIG_LIST(D, T, conf_views, conf_item_edd); -#undef T -#undef D - evry_conf = e_config_domain_load("module.everything", conf_edd); - - if (!evry_conf || (evry_conf->version != CONFIG_VERSION)) - { - evry_conf = E_NEW(Config, 1); - evry_conf->version = CONFIG_VERSION; - evry_conf->rel_x = 50.0; - evry_conf->rel_y = 50.0; - evry_conf->width = 400; - evry_conf->height = 350; - evry_conf->scroll_animate = 0; - evry_conf->scroll_speed = 0.08; - evry_conf->hide_input = 0; - evry_conf->hide_list = 1; - evry_conf->quick_nav = 1; - evry_conf->conf_subjects = NULL; - evry_conf->conf_actions = NULL; - evry_conf->conf_objects = NULL; - evry_conf->conf_views = NULL; - } + /* snprintf(buf, sizeof(buf), "%s/.e/e/config/%s/module.everything", + * e_user_homedir_get(), e_config_profile_get()); + * ecore_file_mkdir(buf); */ + _config_init(); + _history_init(); + /* search for plugins */ eina_module_init(); - snprintf(dir, sizeof(dir), "%s/enlightenment/everything_plugins", e_prefix_lib_get()); + snprintf(dir, sizeof(dir), "%s/enlightenment/everything_plugins", + e_prefix_lib_get()); files = ecore_file_ls(dir); EINA_LIST_FREE(files, file) @@ -127,20 +87,23 @@ e_modapi_init(E_Module *m) act = e_action_add("everything"); if (act) { - act->func.go = _e_mod_action_exebuf_cb; + act->func.go = _e_mod_action_cb; + e_action_predef_name_set(_("Everything"), + _("Show Everything Dialog"), + "everything", "", NULL, 0); } - e_action_predef_name_set(_("Everything"), _("Show Everything Dialog"), - "everything", "", NULL, 0); - - maug = e_int_menus_menu_augmentation_add("main/1", _e_mod_menu_add, NULL, NULL, NULL); + maug = e_int_menus_menu_augmentation_add("main/1", + _e_mod_menu_add, + NULL, NULL, NULL); e_configure_registry_category_add("extensions", 80, _("Extensions"), NULL, "preferences-extensions"); - e_configure_registry_item_add("extensions/run_everything", 40, _("Run Everything"), - NULL, "system-run", evry_config_dialog); - + e_configure_registry_item_add("extensions/run_everything", 40, + _("Run Everything"), + NULL, "system-run", + evry_config_dialog); evry_init(); e_module_delayed_set(m, 1); @@ -152,7 +115,7 @@ EAPI int e_modapi_shutdown(E_Module *m __UNUSED__) { E_Config_Dialog *cfd; - + evry_shutdown(); /* remove module-supplied menu additions */ @@ -183,17 +146,15 @@ e_modapi_shutdown(E_Module *m __UNUSED__) e_configure_registry_item_del("extensions/run_everything"); e_configure_registry_category_del("extensions"); - if (evry_conf->plugins) eina_list_free(evry_conf->plugins); - if (evry_conf->actions) eina_list_free(evry_conf->actions); - if (evry_conf->conf_subjects) eina_list_free(evry_conf->conf_subjects); - if (evry_conf->conf_actions) eina_list_free(evry_conf->conf_actions); - if (evry_conf->conf_objects) eina_list_free(evry_conf->conf_objects); - - E_FREE(evry_conf); + _config_free(); + _history_free(); /* Clean EET */ E_CONFIG_DD_FREE(conf_item_edd); E_CONFIG_DD_FREE(conf_edd); + E_CONFIG_DD_FREE(hist_item_edd); + E_CONFIG_DD_FREE(hist_entry_edd); + E_CONFIG_DD_FREE(hist_edd); return 1; } @@ -201,12 +162,200 @@ EAPI int e_modapi_save(E_Module *m __UNUSED__) { e_config_domain_save("module.everything", conf_edd, evry_conf); + return 1; } +void +evry_save_history(void) +{ + e_config_domain_save("module.everything.history", hist_edd, evry_hist); +} + + +static void +_config_init() +{ +#undef T +#undef D +#define T Plugin_Config +#define D conf_item_edd + conf_item_edd = E_CONFIG_DD_NEW("Plugin_Config", Plugin_Config); + E_CONFIG_VAL(D, T, name, STR); + E_CONFIG_VAL(D, T, trigger, STR); + E_CONFIG_VAL(D, T, min_query, INT); + E_CONFIG_VAL(D, T, loaded, INT); + E_CONFIG_VAL(D, T, enabled, INT); + E_CONFIG_VAL(D, T, priority, INT); +#undef T +#undef D + +#define T Config +#define D conf_edd + conf_edd = E_CONFIG_DD_NEW("Config", Config); + E_CONFIG_VAL(D, T, version, INT); + E_CONFIG_VAL(D, T, width, INT); + E_CONFIG_VAL(D, T, height, INT); + E_CONFIG_VAL(D, T, rel_x, DOUBLE); + E_CONFIG_VAL(D, T, rel_y, DOUBLE); + E_CONFIG_VAL(D, T, scroll_animate, INT); + E_CONFIG_VAL(D, T, scroll_speed, DOUBLE); + E_CONFIG_VAL(D, T, hide_input, INT); + E_CONFIG_VAL(D, T, hide_list, INT); + E_CONFIG_VAL(D, T, quick_nav, INT); + E_CONFIG_VAL(D, T, cmd_terminal, STR); + E_CONFIG_LIST(D, T, conf_subjects, conf_item_edd); + E_CONFIG_LIST(D, T, conf_actions, conf_item_edd); + E_CONFIG_LIST(D, T, conf_objects, conf_item_edd); + E_CONFIG_LIST(D, T, conf_views, conf_item_edd); +#undef T +#undef D + evry_conf = e_config_domain_load("module.everything", conf_edd); + + if (evry_conf && evry_conf->version != CONFIG_VERSION) + { + _config_free(); + evry_conf = NULL; + } + + if (!evry_conf) + { + evry_conf = E_NEW(Config, 1); + evry_conf->version = CONFIG_VERSION; + evry_conf->rel_x = 50.0; + evry_conf->rel_y = 50.0; + evry_conf->width = 400; + evry_conf->height = 350; + evry_conf->scroll_animate = 0; + evry_conf->scroll_speed = 0.08; + evry_conf->hide_input = 0; + evry_conf->hide_list = 1; + evry_conf->quick_nav = 1; + evry_conf->conf_subjects = NULL; + evry_conf->conf_actions = NULL; + evry_conf->conf_objects = NULL; + evry_conf->conf_views = NULL; + evry_conf->cmd_terminal = eina_stringshare_add("/usr/bin/xterm"); + } +} + + +static void +_config_free(void) +{ + Plugin_Config *pc; + + /* free config */ + if (evry_conf->cmd_terminal) + eina_stringshare_del(evry_conf->cmd_terminal); + EINA_LIST_FREE(evry_conf->conf_subjects, pc) + { + if (pc->name) eina_stringshare_del(pc->name); + if (pc->trigger) eina_stringshare_del(pc->trigger); + E_FREE(pc); + } + EINA_LIST_FREE(evry_conf->conf_actions, pc) + { + if (pc->name) eina_stringshare_del(pc->name); + if (pc->trigger) eina_stringshare_del(pc->trigger); + E_FREE(pc); + } + EINA_LIST_FREE(evry_conf->conf_objects, pc) + { + if (pc->name) eina_stringshare_del(pc->name); + if (pc->trigger) eina_stringshare_del(pc->trigger); + E_FREE(pc); + } + E_FREE(evry_conf); +} + + +static void +_history_init(void) +{ +#undef T +#undef D +#define T History_Item +#define D hist_item_edd + hist_item_edd = E_CONFIG_DD_NEW("History_Item", History_Item); + E_CONFIG_VAL(D, T, plugin, STR); + E_CONFIG_VAL(D, T, context, STR); + E_CONFIG_VAL(D, T, input, STR); + E_CONFIG_VAL(D, T, last_used, DOUBLE); + E_CONFIG_VAL(D, T, count, INT); +#undef T +#undef D + +#define T History_Entry +#define D hist_entry_edd + hist_entry_edd = E_CONFIG_DD_NEW("History_Entry", History_Entry); + E_CONFIG_LIST(D, T, items, hist_item_edd); +#undef T +#undef D + +#define T History +#define D hist_edd + hist_edd = E_CONFIG_DD_NEW("History_Item", History); + E_CONFIG_VAL(D, T, version, INT); + E_CONFIG_HASH(D, T, subjects, hist_entry_edd); + E_CONFIG_HASH(D, T, actions, hist_entry_edd); +#undef T +#undef D + evry_hist = e_config_domain_load("module.everything.history", hist_edd); + + if (evry_hist && evry_hist->version != HISTORY_VERSION) + { + _history_free(); + evry_hist = NULL; + } + + if (!evry_hist) + { + evry_hist = E_NEW(History, 1); + evry_hist->version = HISTORY_VERSION; + + } + if (!evry_hist->subjects) + evry_hist->subjects = eina_hash_string_superfast_new(NULL); + if (!evry_hist->actions) + evry_hist->actions = eina_hash_string_superfast_new(NULL); + +} + +static Eina_Bool +_hist_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata) +{ + History_Entry *he = data; + History_Item *hi; + + EINA_LIST_FREE(he->items, hi) + { + if (hi->input) + eina_stringshare_del(hi->input); + if (hi->plugin) + eina_stringshare_del(hi->plugin); + if (hi->context) + eina_stringshare_del(hi->context); + E_FREE(hi); + } + + E_FREE(he); + return 1; +} + +static void +_history_free(void) +{ + eina_hash_foreach(evry_hist->subjects, _hist_free_cb, NULL); + eina_hash_foreach(evry_hist->actions, _hist_free_cb, NULL); + + E_FREE(evry_hist); +} + + /* action callback */ static void -_e_mod_action_exebuf_cb(E_Object *obj, const char *params) +_e_mod_action_cb(E_Object *obj, const char *params) { E_Zone *zone = NULL; @@ -317,23 +466,6 @@ evry_plugin_free(Evry_Plugin *p, int free_pointer) if (p->trigger) eina_stringshare_del(p->trigger); if (p->icon) eina_stringshare_del(p->icon); - if (p->config) - { - if (p->type == type_subject) - evry_conf->conf_subjects = eina_list_remove(evry_conf->conf_subjects, p->config); - else if (p->type == type_action) - evry_conf->conf_actions = eina_list_remove(evry_conf->conf_actions, p->config); - else if (p->type == type_object) - evry_conf->conf_objects = eina_list_remove(evry_conf->conf_objects, p->config); - - if (p->config->name) - eina_stringshare_del(p->config->name); - if (p->config->trigger) - eina_stringshare_del(p->config->trigger); - - E_FREE(p->config); - } - if (free_pointer) E_FREE(p); } @@ -380,7 +512,6 @@ evry_plugin_register(Evry_Plugin *p, int priority) { Eina_List *l, *confs = NULL; Plugin_Config *pc; - Eina_Bool found = 0; evry_conf->plugins = eina_list_append(evry_conf->plugins, p); @@ -392,15 +523,10 @@ evry_plugin_register(Evry_Plugin *p, int priority) confs = evry_conf->conf_objects; EINA_LIST_FOREACH(confs, l, pc) - { - if (pc->name && p->name && !strcmp(pc->name, p->name)) - { - found = 1; - break; - } - } + if (pc->name && p->name && !strcmp(pc->name, p->name)) + break; - if (!found) + if (!pc) { pc = E_NEW(Plugin_Config, 1); pc->name = eina_stringshare_add(p->name); @@ -414,7 +540,6 @@ evry_plugin_register(Evry_Plugin *p, int priority) * pc->trigger = eina_stringshare_add(plugin->trigger); */ p->config = pc; - evry_conf->plugins = eina_list_sort(evry_conf->plugins, eina_list_count(evry_conf->plugins), _evry_cb_plugin_sort); @@ -434,7 +559,6 @@ evry_plugin_register(Evry_Plugin *p, int priority) e_action_predef_name_set(_("Everything"), buf, "everything", p->name, NULL, 1); } - /* TODO sorting, initialization, etc */ } void diff --git a/src/modules/everything/e_mod_main.h b/src/modules/everything/e_mod_main.h index c03559b09..f1a7fdd52 100644 --- a/src/modules/everything/e_mod_main.h +++ b/src/modules/everything/e_mod_main.h @@ -7,6 +7,9 @@ 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 { @@ -29,17 +32,38 @@ struct _Config int hide_list; int quick_nav; - - Eina_Hash *key_bindings; - - /**/ + Eina_List *plugins; Eina_List *actions; Eina_List *views; - Eina_Hash *history; + const char *cmd_terminal; }; + + +struct _History_Item +{ + const char *plugin; + const char *context; + const char *input; + double last_used; + int count; +}; + +struct _History_Entry +{ + Eina_List *items; +}; + +struct _History +{ + int version; + Eina_Hash *subjects; + Eina_Hash *actions; +}; + + struct _Evry_Selector { Evas_Object *o_main; @@ -64,6 +88,8 @@ struct _Evry_Selector Evas_Object *o_thumb; Eina_Bool do_thumb; + + Eina_Hash *history; }; struct _Tab_View @@ -93,6 +119,7 @@ int evry_init(void); int evry_shutdown(void); int evry_show(E_Zone *zone, const char *params); void evry_hide(void); +void evry_save_history(void); Evry_Plugin *evry_plug_aggregator_new(Evry_Selector *selector); void evry_plug_aggregator_free(Evry_Plugin *plugin); @@ -104,6 +131,7 @@ EAPI Tab_View *evry_tab_view_new(const Evry_State *s, Evas *e); EAPI void evry_tab_view_free(Tab_View *v); extern Config *evry_conf; +extern History *evry_hist; extern Evry_Selector **selectors; extern Evry_Plugin *action_selector; #endif diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c index 94f158caf..c903d1f6b 100644 --- a/src/modules/everything/evry.c +++ b/src/modules/everything/evry.c @@ -81,6 +81,8 @@ static void _evry_item_sel(Evry_State *s, Evry_Item *it); static int _evry_cb_key_down(void *data, int type, void *event); static int _evry_cb_selection_notify(void *data, int type, void *event); +static void _evry_history_item_add(Eina_Hash *hist, Evry_State *s); + /* local subsystem globals */ static Evry_Window *win = NULL; @@ -163,7 +165,7 @@ evry_show(E_Zone *zone, const char *params) if (!evry_conf->hide_input) edje_object_signal_emit(list->o_main, "e,state,entry_show", "e"); - + handlers = eina_list_append (handlers, ecore_event_handler_add (ECORE_EVENT_KEY_DOWN, _evry_cb_key_down, NULL)); @@ -180,6 +182,12 @@ evry_show(E_Zone *zone, const char *params) e_popup_show(win->popup); e_popup_show(list->popup); + if (!evry_conf->hide_input) + { + edje_object_part_text_set(win->o_main, "e.text.label", "Search:"); + edje_object_part_text_set(list->o_main, "e.text.label", "Search:"); + } + return 1; error: @@ -393,7 +401,7 @@ evry_plugin_async_update(Evry_Plugin *p, int action) } /* update aggregator */ - if (eina_list_count(s->cur_plugins) > 1) + if (eina_list_count(s->cur_plugins) > 0) { agg->fetch(agg, s->input); @@ -447,12 +455,7 @@ _evry_list_win_new(E_Zone *zone) return NULL; } list_win->popup = popup; - - /* evas_event_freeze(popup->evas); - * evas_event_feed_mouse_in(popup->evas, ecore_x_current_time_get(), NULL); - * evas_event_feed_mouse_move(popup->evas, -1000000, -1000000, - * ecore_x_current_time_get(), NULL); */ - + o = edje_object_add(popup->evas); list_win->o_main = o; e_theme_edje_object_set(o, "base/theme/everything", @@ -470,9 +473,6 @@ _evry_list_win_new(E_Zone *zone) edje_object_size_min_calc(o, &mw, &mh); - printf("list min size %d %d - %d\n", mw, mh, atoi(offset_y)); - - if (mh == 0) mh = 200; if (mw == 0) mw = win->popup->w / 2; @@ -486,9 +486,7 @@ _evry_list_win_new(E_Zone *zone) evas_object_resize(o, list_win->popup->w, list_win->popup->h); evas_object_show(o); e_popup_edje_bg_object_set(popup, o); - - /* evas_event_thaw(popup->evas); */ - + return list_win; } @@ -609,12 +607,22 @@ _evry_selector_new(int type) evas_object_show(o); if (type == type_subject) - edje_object_part_swallow(win->o_main, "e.swallow.subject_selector", o); + { + sel->history = evry_hist->subjects; + edje_object_part_swallow(win->o_main, "e.swallow.subject_selector", o); + } else if (type == type_action) - edje_object_part_swallow(win->o_main, "e.swallow.action_selector", o); + { + sel->history = evry_hist->actions; + edje_object_part_swallow(win->o_main, "e.swallow.action_selector", o); + } + else if (type == type_object) - edje_object_part_swallow(win->o_main, "e.swallow.object_selector", o); - + { + sel->history = evry_hist->subjects; + edje_object_part_swallow(win->o_main, "e.swallow.object_selector", o); + } + p = evry_plug_aggregator_new(sel); sel->plugins = eina_list_append(sel->plugins, p); @@ -1052,6 +1060,8 @@ _evry_browse_item(Evry_Selector *sel) if (!plugins) return 1; + _evry_history_item_add(sel->history, s); + if (s->view) { _evry_view_hide(s->view); @@ -1352,6 +1362,102 @@ _evry_clear(Evry_State *s) return 0; } +static void +_evry_history_item_add(Eina_Hash *hist, Evry_State *s) +{ + History_Entry *he; + History_Item *hi; + Evry_Item *it; + Eina_List *l; + const char *id; + + if (!s) return; + + it = s->cur_item; + if (!it) return; + + if (it->plugin->item_id) + id = it->plugin->item_id(it->plugin, it); + else + id = it->label; + + he = eina_hash_find(hist, id); + if (he) + { + /* found history entry */ + EINA_LIST_FOREACH(he->items, l, hi) + if (hi->plugin == it->plugin->name) break; + + if (hi) + { + /* found history item */ + if (hi->input) + { + if (!s->input || !strncmp (hi->input, s->input, strlen(s->input))) + { + /* s->input matches hi->input and is equal or shorter */ + hi->count++; + hi->last_used /= 1000.0; + hi->last_used += ecore_time_get(); + } + else if (s->input) + { + if (!strncmp (hi->input, s->input, strlen(hi->input))) + { + /* s->input matches hi->input but is longer */ + eina_stringshare_del(hi->input); + hi->input = eina_stringshare_add(s->input); + } + else + { + /* s->input is different from hi->input + -> create new item */ + hi = NULL; + } + } + } + else + { + /* remember input for item */ + hi->count++; + hi->last_used /= 2.0; + hi->last_used += ecore_time_get(); + + if (s->input) + hi->input = eina_stringshare_add(s->input); + } + } + + if (!hi) + { + hi = E_NEW(History_Item, 1); + hi->plugin = eina_stringshare_ref(it->plugin->name); + hi->last_used = ecore_time_get(); + hi->count = 1; + if (s->input) + hi->input = eina_stringshare_add(s->input); + + he->items = eina_list_append(he->items, hi); + } + } + else + { + he = E_NEW(History_Entry, 1); + hi = E_NEW(History_Item, 1); + hi->plugin = eina_stringshare_ref(it->plugin->name); + hi->last_used = ecore_time_get(); + hi->count = 1; + if (s->input) + hi->input = eina_stringshare_add(s->input); + + he->items = eina_list_append(he->items, hi); + eina_hash_add(hist, id, he); + } + evry_save_history(); + +} + + static void _evry_plugin_action(Evry_Selector *sel, int finished) { @@ -1361,7 +1467,8 @@ _evry_plugin_action(Evry_Selector *sel, int finished) s_action = selectors[1]->state; s_object = NULL; - if (!s_subject || !s_action) return; + if (!s_subject || !s_action) + return; if (update_timer) { @@ -1372,7 +1479,8 @@ _evry_plugin_action(Evry_Selector *sel, int finished) update_timer = NULL; } - if (!s_subject->cur_item || !s_action->cur_item) return; + if (!s_subject->cur_item || !s_action->cur_item) + return; if (s_action->cur_item->plugin == action_selector) { @@ -1382,7 +1490,8 @@ _evry_plugin_action(Evry_Selector *sel, int finished) if (selectors[2] == selector) it_object = selector->state->cur_item; - if (act->type_in2 && !it_object) return; + if (act->type_in2 && !it_object) + return; act->item2 = it_object; @@ -1397,6 +1506,11 @@ _evry_plugin_action(Evry_Selector *sel, int finished) } else return; + _evry_history_item_add(evry_hist->subjects, s_subject); + _evry_history_item_add(evry_hist->actions, s_action); + _evry_history_item_add(evry_hist->subjects, s_object); + + /* let subject and object plugin know that an action was performed */ if (s_subject->plugin->action) s_subject->plugin->action(s_subject->plugin, s_subject->cur_item); @@ -1591,7 +1705,7 @@ _evry_matches_update(Evry_Selector *sel, int async) } } - if (eina_list_count(s->cur_plugins) > 1) + if (eina_list_count(s->cur_plugins) > 0) { sel->aggregator->fetch(sel->aggregator, s->input); s->cur_plugins = eina_list_prepend(s->cur_plugins, sel->aggregator); diff --git a/src/modules/everything/evry_config.c b/src/modules/everything/evry_config.c index 2703eee6c..ad99a433a 100644 --- a/src/modules/everything/evry_config.c +++ b/src/modules/everything/evry_config.c @@ -21,6 +21,8 @@ struct _E_Config_Dialog_Data int width, height; int scroll_animate; + char *cmd_terminal; + Evas_Object *l_subject; Evas_Object *l_action; Evas_Object *l_object; @@ -73,6 +75,9 @@ _fill_data(E_Config_Dialog_Data *cfdata) cfdata->p_action = eina_list_append(cfdata->p_action, p); else if (p->type == type_object) cfdata->p_object = eina_list_append(cfdata->p_object, p); + + if (evry_conf->cmd_terminal) + cfdata->cmd_terminal = strdup(evry_conf->cmd_terminal); } static void * @@ -91,7 +96,7 @@ _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) if (cfdata->p_subject) eina_list_free(cfdata->p_subject); if (cfdata->p_action) eina_list_free(cfdata->p_action); if (cfdata->p_object) eina_list_free(cfdata->p_object); - + E_FREE(cfdata->cmd_terminal); E_FREE(cfdata); } @@ -116,6 +121,10 @@ _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) eina_list_count(evry_conf->plugins), _evry_cb_plugin_sort); + if (evry_conf->cmd_terminal) + eina_stringshare_del(evry_conf->cmd_terminal); + evry_conf->cmd_terminal = eina_stringshare_add(cfdata->cmd_terminal); + e_config_save_queue(); return 1; } @@ -209,9 +218,15 @@ _basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dial ob = e_widget_check_add(evas, _("Quick Navigation (ALT + h,j,k,l,n,p,m,i)"), &(cfdata->quick_nav)); e_widget_framelist_object_append(of, ob); + + ob = e_widget_label_add(evas, _("Terminal Command")); + e_widget_framelist_object_append(of, ob); + ob = e_widget_entry_add(evas, &(cfdata->cmd_terminal), NULL, NULL, NULL); + e_widget_framelist_object_append(of, ob); + e_widget_list_object_append(o, of, 1, 1, 0.5); - + /* ob = e_widget_label_add(evas, _("Popup Width")); * e_widget_framelist_object_append(of, ob); * ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"), @@ -235,10 +250,10 @@ _basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dial e_widget_toolbook_page_append(otb, NULL, _("General Settings"), - o, 0, 0, 0, 0, 0.5, 0.0); + o, 1, 0, 1, 0, 0.5, 0.0); ob = e_widget_list_add(evas, 1, 1); - of = e_widget_framelist_add(evas, _("Subject Plugins"), 0); + of = e_widget_framelist_add(evas, _("Active Plugins"), 0); o = e_widget_ilist_add(evas, 24, 24, NULL); cfdata->l_subject = o; /* e_widget_on_change_hook_set(ol, _avail_list_cb_change, cfdata); */ @@ -255,8 +270,12 @@ _basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dial cfdata->p_subject); e_widget_framelist_object_append(of, o); e_widget_list_object_append(ob, of, 1, 1, 0.5); + e_widget_toolbook_page_append(otb, NULL, _("Subject Plugins"), + of, 1, 0, 1, 0, 0.5, 0.0); - of = e_widget_framelist_add(evas, _("Action Plugins"), 0); + + ob = e_widget_list_add(evas, 1, 1); + of = e_widget_framelist_add(evas, _("Active Plugins"), 0); o = e_widget_ilist_add(evas, 24, 24, NULL); cfdata->l_action = o; _fill_list(cfdata->p_action, o, 0); @@ -272,8 +291,11 @@ _basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dial cfdata->p_action); e_widget_framelist_object_append(of, o); e_widget_list_object_append(ob, of, 1, 1, 0.5); + e_widget_toolbook_page_append(otb, NULL, _("Action Plugins"), + of, 1, 0, 1, 0, 0.5, 0.0); - of = e_widget_framelist_add(evas, _("Object Plugins"), 0); + ob = e_widget_list_add(evas, 1, 1); + of = e_widget_framelist_add(evas, _("Active Plugins"), 0); o = e_widget_ilist_add(evas, 24, 24, NULL); cfdata->l_object = o; _fill_list(cfdata->p_object, o, 0); @@ -290,9 +312,10 @@ _basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dial e_widget_framelist_object_append(of, o); e_widget_list_object_append(ob, of, 1, 1, 0.5); - e_widget_toolbook_page_append(otb, NULL, _("Plugins"), - ob, 0, 0, 0, 0, 0.5, 0.0); - e_widget_toolbook_page_show(otb, 1); + e_widget_toolbook_page_append(otb, NULL, _("Object Plugins"), + ob, 1, 0, 1, 0, 0.5, 0.0); + + e_widget_toolbook_page_show(otb, 0); return otb; } diff --git a/src/modules/everything/evry_plug_aggregator.c b/src/modules/everything/evry_plug_aggregator.c index bb6065e69..a3b22642b 100644 --- a/src/modules/everything/evry_plug_aggregator.c +++ b/src/modules/everything/evry_plug_aggregator.c @@ -15,6 +15,13 @@ _cb_sort_recent(const void *data1, const void *data2) const Evry_Item *it1 = data1; const Evry_Item *it2 = data2; + if (it1->usage && it2->usage) + return (it2->usage - it1->usage); + if (it1->usage && !it2->usage) + return -1; + if (it2->usage && !it1->usage) + return 1; + if ((it1->plugin == action_selector) || (it2->plugin == action_selector)) { @@ -26,7 +33,7 @@ _cb_sort_recent(const void *data1, const void *data2) - it2->plugin->config->priority); else return (it1->plugin->config->priority - - (it1->plugin->config->priority + it2->priority)); + (it2->plugin->config->priority + it2->priority)); } return -1; @@ -38,6 +45,13 @@ _cb_sort(const void *data1, const void *data2) const Evry_Item *it1 = data1; const Evry_Item *it2 = data2; + if (it1->usage && it2->usage) + return (it2->usage - it1->usage); + if (it1->usage && !it2->usage) + return -1; + if (it2->usage && !it1->usage) + return 1; + if ((it1->plugin == action_selector) || (it2->plugin == action_selector)) { @@ -87,6 +101,9 @@ _fetch(Evry_Plugin *plugin, const char *input) Evry_Item *it; int cnt = 0; Eina_List *items = NULL; + History_Entry *he; + History_Item *hi; + const char *id; s = p->selector->state; @@ -115,11 +132,11 @@ _fetch(Evry_Plugin *plugin, const char *input) } } - if (!input[0] || eina_list_count(items) < 20) + if (!input[0] || eina_list_count(items) < 50) { EINA_LIST_FOREACH(s->cur_plugins, l, pp) { - for (cnt = 0, ll = pp->items; ll && cnt < 15; ll = ll->next, cnt++) + for (cnt = 0, ll = pp->items; ll && cnt < 50; ll = ll->next, cnt++) { if (!items || !eina_list_data_find_list(items, ll->data)) { @@ -134,7 +151,34 @@ _fetch(Evry_Plugin *plugin, const char *input) } if (items) eina_list_free(items); + + EINA_LIST_FOREACH(EVRY_PLUGIN(p)->items, l, it) + { + cnt = 1; + if (it->usage) continue; + if (it->plugin->item_id) + id = it->plugin->item_id(it->plugin, it); + else + id = it->label; + + if ((he = eina_hash_find(p->selector->history, id))) + { + EINA_LIST_FOREACH(he->items, ll, hi) + { + if ((hi->plugin == it->plugin->name) && + ((!input[0]) || (!input[0] && !hi->input) || + (!strncmp(input, hi->input, strlen(input))) || + (!strncmp(input, hi->input, strlen(hi->input))))) + { + cnt++; + it->usage += hi->last_used; + } + } + it->usage /= (double)cnt; + } + } + if (input[0]) { EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort); diff --git a/src/modules/everything/evry_view_plugin_tabs.c b/src/modules/everything/evry_view_plugin_tabs.c index 2c4c16c62..183882cd4 100644 --- a/src/modules/everything/evry_view_plugin_tabs.c +++ b/src/modules/everything/evry_view_plugin_tabs.c @@ -104,9 +104,13 @@ _tabs_update(Tab_View *v) evas_object_show(o); e_box_pack_end(v->o_tabs, o); - e_box_pack_options_set(o, 1, 1, 1, 0, 0.0, 0.5, - (tab->mw < tab->cw ? tab->cw : tab->mw), 10, - (w ? w/3 : 150), 9999); + if (eina_list_count(s->cur_plugins) == 2) + e_box_pack_options_set(o, 1, 1, 0, 0, 0.0, 0.5, + 120, 10, 120, 9999); + else + e_box_pack_options_set(o, 1, 1, 1, 0, 0.0, 0.5, + (tab->mw < tab->cw ? tab->cw : tab->mw), 10, + (w ? w/3 : 120), 9999); if (s->plugin == p) edje_object_signal_emit(o, "e,state,selected", "e"); else diff --git a/src/modules/everything/sources/evry_plug_apps.c b/src/modules/everything/sources/evry_plug_apps.c index d967dd446..d0187160c 100644 --- a/src/modules/everything/sources/evry_plug_apps.c +++ b/src/modules/everything/sources/evry_plug_apps.c @@ -11,6 +11,7 @@ struct _Plugin Eina_List *apps_mime; Eina_List *apps_all; const Evry_Item *candidate; + Eina_Hash *added; }; /* taken from exebuf module */ @@ -84,12 +85,19 @@ _begin_open_with(Evry_Plugin *plugin, const Evry_Item *item) p->apps_mime = eina_list_prepend(p->apps_mime, desktop); } + p->added = added; + if (!p->added) + p->added = eina_hash_string_small_new(_hash_free); + added = p->added; + 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; @@ -128,7 +136,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *item) exe_scan_idler = ecore_idler_add(_scan_idler, NULL); - added = eina_hash_string_small_new(_hash_free); + p->added = eina_hash_string_small_new(_hash_free); return plugin; } @@ -153,7 +161,12 @@ _cleanup(Evry_Plugin *plugin) Efreet_Desktop *desktop; char *str; + /* TODO popup end func !!! + - cleanup hash for open-with plugin */ eina_hash_free(added); + added = NULL; + + eina_hash_free(p->added); EVRY_PLUGIN_ITEMS_CLEAR(p); @@ -209,7 +222,7 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, char *file, int match) char buf[1024]; char *tmp; - if ((app = eina_hash_find(added, file))) + if ((app = eina_hash_find(p->added, file))) { if (!eina_list_data_find_list(EVRY_PLUGIN(p)->items, app)) { @@ -245,7 +258,7 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, char *file, int match) if (!exe) return 0; - if ((app = eina_hash_find(added, exe)) && + if ((app = eina_hash_find(p->added, exe)) && (!desktop || (desktop == app->desktop))) { if (!eina_list_data_find_list(EVRY_PLUGIN(p)->items, app)) @@ -270,7 +283,7 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, char *file, int match) app->desktop = desktop; if (file) app->file = eina_stringshare_add(file); - eina_hash_add(added, exe, app); + eina_hash_add(p->added, exe, app); if (desktop) { @@ -279,13 +292,13 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, char *file, int match) if (tmp && strcmp(exe, tmp)) { evry_item_ref(EVRY_ITEM(app)); - eina_hash_add(added, tmp, app); + eina_hash_add(p->added, tmp, app); } } if (file && strcmp(exe, file)) { evry_item_ref(EVRY_ITEM(app)); - eina_hash_add(added, file, app); + eina_hash_add(p->added, file, app); } EVRY_ITEM(app)->fuzzy_match = match; @@ -454,7 +467,8 @@ _fetch(Evry_Plugin *plugin, const char *input) if (!plugin->items) return 0; - EVRY_PLUGIN_ITEMS_SORT(plugin, _cb_sort); + if (plugin->type != type_action || input) + EVRY_PLUGIN_ITEMS_SORT(plugin, _cb_sort); EINA_LIST_FOREACH(plugin->items, l, it) it->priority = prio++; diff --git a/src/modules/everything/sources/evry_plug_border.c b/src/modules/everything/sources/evry_plug_border.c index 0d83a349f..3c5b8a902 100644 --- a/src/modules/everything/sources/evry_plug_border.c +++ b/src/modules/everything/sources/evry_plug_border.c @@ -235,12 +235,27 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) return o; } +static const char * +_item_id(Evry_Plugin *p, const Evry_Item *it) +{ + E_Border *bd = it->data; + if (bd->client.icccm.class) + return (bd->client.icccm.class); + if (bd->client.icccm.name) + return (bd->client.icccm.name); + else + return NULL; +} + + static Eina_Bool _init(void) { plugin = evry_plugin_new(NULL, "Windows", type_subject, NULL, "BORDER", 0, NULL, NULL, _begin, _cleanup, _fetch, NULL, _item_icon_get, NULL, NULL); + plugin->item_id = &_item_id; + evry_plugin_register(plugin, 2); return EINA_TRUE; diff --git a/src/modules/everything/sources/evry_plug_dir_browse.c b/src/modules/everything/sources/evry_plug_dir_browse.c index a36a3de76..b7957c5f7 100644 --- a/src/modules/everything/sources/evry_plug_dir_browse.c +++ b/src/modules/everything/sources/evry_plug_dir_browse.c @@ -448,6 +448,14 @@ _open_term_action(Evry_Action *act) return ret; } +static const char * +_item_id(Evry_Plugin *p, const Evry_Item *item) +{ + ITEM_FILE(file, item); + + return file->uri; +} + static Eina_Bool _init(void) { @@ -459,6 +467,9 @@ _init(void) _begin, _cleanup, _fetch, NULL, _icon_get, NULL, NULL); + p1->item_id = &_item_id; + p1->item_id = &_item_id; + evry_plugin_register(p1, 3); evry_plugin_register(p2, 1); diff --git a/src/modules/everything/sources/evry_plug_tracker.c b/src/modules/everything/sources/evry_plug_tracker.c index fa35ca683..99aee8dd6 100644 --- a/src/modules/everything/sources/evry_plug_tracker.c +++ b/src/modules/everything/sources/evry_plug_tracker.c @@ -1,5 +1,4 @@ -#include "Evry.h" - +#include "e_mod_main.h" /* TODO check if trackerd is running and version */ @@ -21,7 +20,7 @@ struct _Plugin static E_DBus_Connection *conn = NULL; static Eina_List *plugins = NULL; static int _prio = 5; - +static int active = 0; static Evry_Plugin * _begin(Evry_Plugin *plugin, const Evry_Item *it) @@ -170,6 +169,7 @@ _dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error) if (dbus_error_is_set(error)) { _cleanup(EVRY_PLUGIN(p)); + active = 0; printf("Error: %s - %s\n", error->name, error->message); return; } @@ -253,6 +253,47 @@ _dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error) evry_plugin_async_update(EVRY_PLUGIN(p), EVRY_ASYNC_UPDATE_ADD); } +static void +_dbus_cb_version(void *data, DBusMessage *msg, DBusError *error) +{ + DBusMessageIter iter; + int version = 0; + + if (dbus_error_is_set(error)) + { + printf("Error: %s - %s\n", error->name, error->message); + return; + } + + dbus_message_iter_init(msg, &iter); + + if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INT32) + dbus_message_iter_get_basic(&iter, &version); + + printf("tracker version %d\n", version); + + if (version < 690) + active = 0; + else + active = 2; +} + +static void +_get_version(void) +{ + DBusMessage *msg; + + msg = dbus_message_new_method_call("org.freedesktop.Tracker", + "/org/freedesktop/Tracker", + "org.freedesktop.Tracker", + "GetVersion"); + + e_dbus_message_send(conn, msg, _dbus_cb_version, -1, NULL); + dbus_message_unref(msg); + + active = 1; +} + static int _fetch(Evry_Plugin *plugin, const char *input) { @@ -305,6 +346,13 @@ _fetch(Evry_Plugin *plugin, const char *input) return 0; } + + if (!active) + _get_version(); + + if (active != 2) + return 0; + p->active++; msg = dbus_message_new_method_call("org.freedesktop.Tracker", @@ -377,70 +425,7 @@ _plugin_new(const char *name, int type, char *service, int max_hits, int begin) evry_plugin_register(EVRY_PLUGIN(p), _prio++); } -static void -_dbus_cb_version(void *data, DBusMessage *msg, DBusError *error) -{ - DBusMessageIter iter; - Plugin *p; - int version = 0; - if (dbus_error_is_set(error)) - { - printf("Error: %s - %s\n", error->name, error->message); - e_dbus_connection_close(conn); - - EINA_LIST_FREE(plugins, p) - { - if (p->condition[0]) free(p->condition); - - EVRY_PLUGIN_FREE(p); - } - return; - } - - dbus_message_iter_init(msg, &iter); - - if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INT32) - dbus_message_iter_get_basic(&iter, &version); - - printf("tracker version %d\n", version); - - if (version < 690) - { - e_dbus_connection_close(conn); - - EINA_LIST_FREE(plugins, p) - { - if (p->condition[0]) free(p->condition); - - EVRY_PLUGIN_FREE(p); - } - } -} - - -static void -_get_version(void) -{ - DBusMessage *msg; - - msg = dbus_message_new_method_call("org.freedesktop.Tracker", - "/org/freedesktop/Tracker", - "org.freedesktop.Tracker", - "GetVersion"); - - e_dbus_message_send(conn, msg, _dbus_cb_version, -1, NULL); - dbus_message_unref(msg); -} - - -/* static Evry_Plugin * - * _begin_subject(Evry_Plugin *plugin, const Evry_Item *it) - * { - * if (!conn) return NULL; - * - * return plugin; - * } */ static Eina_Bool