From 857d06422093e09b2b5204efae25ae9fb050c6ec Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Sun, 25 Apr 2010 00:31:11 +0000 Subject: [PATCH] 'everyhing' - when trigger active clear input without clearing the trigger - nicer macro for EVRY_PLUGIN_NEW SVN revision: 48294 --- src/modules/everything-apps/e_mod_main.c | 29 ++++++------ src/modules/everything-aspell/e_mod_main.c | 47 ++++++++++++++----- src/modules/everything-calc/e_mod_main.c | 2 +- src/modules/everything-files/e_mod_main.c | 4 +- src/modules/everything-settings/e_mod_main.c | 2 +- src/modules/everything-wallpaper/e_mod_main.c | 6 +-- src/modules/everything-windows/e_mod_main.c | 9 ++-- src/modules/everything/Evry.h | 5 +- src/modules/everything/evry.c | 24 +++++----- src/modules/everything/evry_plug_aggregator.c | 18 +++---- src/modules/everything/evry_plug_text.c | 4 +- 11 files changed, 89 insertions(+), 61 deletions(-) diff --git a/src/modules/everything-apps/e_mod_main.c b/src/modules/everything-apps/e_mod_main.c index 13a4e1d6e..a8a75904f 100644 --- a/src/modules/everything-apps/e_mod_main.c +++ b/src/modules/everything-apps/e_mod_main.c @@ -963,25 +963,26 @@ _new_app_action(Evry_Action *act) static Eina_Bool _plugins_init(void) { + Evry_Plugin *p; + if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - p1 = E_NEW(Plugin, 1); - EVRY_PLUGIN_NEW(EVRY_PLUGIN(p1), N_("Applications"), type_subject, "", "APPLICATION", - _begin, _cleanup, _fetch, _icon_get, NULL); - EVRY_PLUGIN(p1)->complete = &_complete; - EVRY_PLUGIN(p1)->config_path = "extensions/everything-apps"; + p = EVRY_PLUGIN_NEW(Plugin, N_("Applications"), type_subject, "", "APPLICATION", + _begin, _cleanup, _fetch, _icon_get, NULL); + p->complete = &_complete; + p->config_path = "extensions/everything-apps"; + evry_plugin_register(p, 1); + p1 = (Plugin *) p; - p2 = E_NEW(Plugin, 1); - EVRY_PLUGIN_NEW(EVRY_PLUGIN(p2), N_("Open With..."), type_action, "FILE", "", - _begin_open_with, _cleanup, _fetch, - _icon_get, NULL); + p = EVRY_PLUGIN_NEW(Plugin, N_("Open With..."), type_action, "FILE", "", + _begin_open_with, _cleanup, _fetch, + _icon_get, NULL); - EVRY_PLUGIN(p2)->action = &_open_with_action; - EVRY_PLUGIN(p2)->config_path = "extensions/everything-apps"; - - evry_plugin_register(EVRY_PLUGIN(p1), 1); - evry_plugin_register(EVRY_PLUGIN(p2), 1); + p->action = &_open_with_action; + p->config_path = "extensions/everything-apps"; + evry_plugin_register(p, 1); + p2 = (Plugin *) p; act = EVRY_ACTION_NEW(N_("Launch"), "APPLICATION", NULL, "everything-launch", _exec_app_action, _exec_app_check_item); diff --git a/src/modules/everything-aspell/e_mod_main.c b/src/modules/everything-aspell/e_mod_main.c index 0c8093b62..17cf1e082 100644 --- a/src/modules/everything-aspell/e_mod_main.c +++ b/src/modules/everything-aspell/e_mod_main.c @@ -321,28 +321,53 @@ _cleanup(Evry_Plugin *plugin) } } +/* static int + * _action(Evry_Action *act) + * { + * const Evry_Item *it = act->item2; + * if (!it) return 0; + * + * 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 Eina_Bool _plugins_init(void) { - Plugin *p; + Evry_Plugin *p; if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - p = E_NEW(Plugin, 1); - - EVRY_PLUGIN_NEW(p, N_("Spell Checker"), type_subject, "", "TEXT", + p = EVRY_PLUGIN_NEW(Plugin, N_("Spell Checker"), type_subject, "", "TEXT", NULL, _cleanup, _fetch, NULL, NULL); - EVRY_PLUGIN(p)->aggregate = EINA_FALSE; - EVRY_PLUGIN(p)->history = EINA_FALSE; - EVRY_PLUGIN(p)->async_fetch = EINA_TRUE; - EVRY_PLUGIN(p)->icon = "accessories-dictionary"; - EVRY_PLUGIN(p)->trigger = TRIGGER; + p->aggregate = EINA_FALSE; + p->history = EINA_FALSE; + p->async_fetch = EINA_TRUE; + p->icon = "accessories-dictionary"; + p->trigger = TRIGGER; - evry_plugin_register(EVRY_PLUGIN(p), 100); + evry_plugin_register(p, 100); + _plug = (Plugin *) p; - _plug = p; + /* TODO show spell check action for given text */ + /* p = EVRY_PLUGIN_NEW2(Plugin, N_("Spell Checker"), type_object, "", "TEXT", + * _begin, _cleanup, _fetch, NULL, NULL); + * + * p->aggregate = EINA_FALSE; + * p->history = EINA_FALSE; + * p->async_fetch = EINA_TRUE; + * p->icon = "accessories-dictionary"; + * p->trigger = TRIGGER; + * + * evry_plugin_register(p, 100); + * _plug2 = (Plugin *) p; + * + * _act = EVRY_ACTION_NEW(N_("Spell Checker"), "TEXT", "ASPELL", _action, NULL); */ return EINA_TRUE; } diff --git a/src/modules/everything-calc/e_mod_main.c b/src/modules/everything-calc/e_mod_main.c index 52a735852..1e8b4a210 100644 --- a/src/modules/everything-calc/e_mod_main.c +++ b/src/modules/everything-calc/e_mod_main.c @@ -229,7 +229,7 @@ _plugins_init(void) if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - p1 = EVRY_PLUGIN_NEW(NULL, N_("Calculator"), type_subject, NULL, "TEXT", + p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Calculator"), type_subject, NULL, "TEXT", _begin, _cleanup, _fetch, NULL, NULL); p1->view_mode = VIEW_MODE_LIST; diff --git a/src/modules/everything-files/e_mod_main.c b/src/modules/everything-files/e_mod_main.c index b34325b5a..450f6b18b 100644 --- a/src/modules/everything-files/e_mod_main.c +++ b/src/modules/everything-files/e_mod_main.c @@ -704,12 +704,12 @@ _plugins_init(void) if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - p1 = EVRY_PLUGIN_NEW(NULL, N_("Files"), type_subject, "FILE", "FILE", + p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Files"), type_subject, "FILE", "FILE", _begin, _cleanup, _fetch, _icon_get, NULL); EVRY_PLUGIN(p1)->config_path = "extensions/everything-files"; evry_plugin_register(p1, 3); - p2 = EVRY_PLUGIN_NEW(NULL, N_("Files"), type_object, "FILE", "FILE", + p2 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Files"), type_object, "FILE", "FILE", _begin, _cleanup, _fetch, _icon_get, NULL); EVRY_PLUGIN(p2)->config_path = "extensions/everything-files"; evry_plugin_register(p2, 1); diff --git a/src/modules/everything-settings/e_mod_main.c b/src/modules/everything-settings/e_mod_main.c index 7b30f6596..b56782c6d 100644 --- a/src/modules/everything-settings/e_mod_main.c +++ b/src/modules/everything-settings/e_mod_main.c @@ -123,7 +123,7 @@ _plugins_init(void) if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - p = EVRY_PLUGIN_NEW(NULL, N_("Settings"), type_subject, NULL, "E_SETTINGS", + p = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Settings"), type_subject, NULL, "E_SETTINGS", NULL, _cleanup, _fetch, _item_icon_get, NULL); evry_plugin_register(p, 10); diff --git a/src/modules/everything-wallpaper/e_mod_main.c b/src/modules/everything-wallpaper/e_mod_main.c index 26df95528..65ea53624 100644 --- a/src/modules/everything-wallpaper/e_mod_main.c +++ b/src/modules/everything-wallpaper/e_mod_main.c @@ -205,11 +205,11 @@ _plugins_init(void) if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - _plug = EVRY_PLUGIN_NEW(NULL, N_("Wallpaper"), type_action, "FILE", "", + _plug = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Wallpaper"), type_action, "FILE", "", _begin, _cleanup, _fetch, _icon_get, NULL); - EVRY_PLUGIN(_plug)->icon = "preferences-desktop-wallpaper"; - EVRY_PLUGIN(_plug)->action = &_action; + _plug->icon = "preferences-desktop-wallpaper"; + _plug->action = &_action; evry_plugin_register(_plug, 10); diff --git a/src/modules/everything-windows/e_mod_main.c b/src/modules/everything-windows/e_mod_main.c index 9d72abd9d..d539374a8 100644 --- a/src/modules/everything-windows/e_mod_main.c +++ b/src/modules/everything-windows/e_mod_main.c @@ -492,14 +492,13 @@ _plugins_init(void) if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - p1 = EVRY_PLUGIN_NEW(NULL, N_("Windows"), type_subject, NULL, "BORDER", - _begin, _cleanup, _fetch, _item_icon_get, NULL); + p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Windows"), type_subject, NULL, "BORDER", + _begin, _cleanup, _fetch, _item_icon_get, NULL); p1->transient = EINA_TRUE; evry_plugin_register(p1, 2); - - p2 = EVRY_PLUGIN_NEW(NULL, N_("Window Action"), type_action, "BORDER", NULL, - _act_begin, _act_cleanup, _act_fetch, _act_item_icon_get, NULL); + p2 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Window Action"), type_action, "BORDER", NULL, + _act_begin, _act_cleanup, _act_fetch, _act_item_icon_get, NULL); EVRY_PLUGIN(p2)->action = &_act_action; diff --git a/src/modules/everything/Evry.h b/src/modules/everything/Evry.h index f7bdf7830..7fd453cac 100644 --- a/src/modules/everything/Evry.h +++ b/src/modules/everything/Evry.h @@ -435,8 +435,11 @@ EAPI void evry_history_unload(void); EAPI History_Item *evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *input); EAPI int evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, const char *ctxt); +/* #define EVRY_PLUGIN_NEW(_base, _name, _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \ + * evry_plugin_new(EVRY_PLUGIN(_base), _name, _(_name), _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \ */ + #define EVRY_PLUGIN_NEW(_base, _name, _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \ - evry_plugin_new(EVRY_PLUGIN(_base), _name, _(_name), _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \ + evry_plugin_new(EVRY_PLUGIN(E_NEW(_base, 1)), _name, _(_name), _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \ EAPI Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, int type, const char *type_in, const char *type_out, diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c index 1ed84b1a8..77bad6040 100644 --- a/src/modules/everything/evry.c +++ b/src/modules/everything/evry.c @@ -1651,19 +1651,19 @@ _evry_clear(Evry_Selector *sel) { Evry_State *s = sel->state; - if ((s->plugin && s->plugin->trigger && s->inp) && - (!strncmp(s->plugin->trigger, s->inp, - strlen(s->plugin->trigger)))) + if (s->inp && s->inp[0] != 0) { - s->input[strlen(s->plugin->trigger)] = 0; - _evry_update(sel, 1); - return 1; - } - else if (s->inp && s->inp[0] != 0) - { - s->inp[0] = 0; - s->input = s->inp; - + if (s->trigger_active && s->inp[1] != 0) + { + s->inp[1] = 0; + s->input = s->inp + 1; + } + else + { + s->inp[0] = 0; + s->input = s->inp; + } + _evry_update(sel, 1); if (!list->visible && evry_conf->hide_input) edje_object_signal_emit(list->o_main, "e,state,entry_hide", "e"); diff --git a/src/modules/everything/evry_plug_aggregator.c b/src/modules/everything/evry_plug_aggregator.c index 0f3eb553a..fe663854a 100644 --- a/src/modules/everything/evry_plug_aggregator.c +++ b/src/modules/everything/evry_plug_aggregator.c @@ -295,17 +295,17 @@ _icon_get(Evry_Plugin *plugin, const Evry_Item *it, Evas *e) Evry_Plugin * evry_plug_aggregator_new(Evry_Selector *sel, int type) { - Plugin *p; + Evry_Plugin *p; - p = E_NEW(Plugin, 1); - EVRY_PLUGIN_NEW(EVRY_PLUGIN(p), N_("All"), type, "", "", + p = EVRY_PLUGIN_NEW(Plugin, N_("All"), type, "", "", NULL, _cleanup, _fetch, _icon_get, NULL); - EVRY_PLUGIN(p)->action = &_action; - EVRY_PLUGIN(p)->history = EINA_FALSE; + p->action = &_action; + p->history = EINA_FALSE; + evry_plugin_register(p, -1); + + PLUGIN(pa, p); + pa->selector = sel; - evry_plugin_register(EVRY_PLUGIN(p), -1); - p->selector = sel; - - return EVRY_PLUGIN(p); + return p; } diff --git a/src/modules/everything/evry_plug_text.c b/src/modules/everything/evry_plug_text.c index 5194a3c7c..7db09008a 100644 --- a/src/modules/everything/evry_plug_text.c +++ b/src/modules/everything/evry_plug_text.c @@ -41,10 +41,10 @@ _fetch(Evry_Plugin *p, const char *input) Eina_Bool evry_plug_text_init(void) { - p1 = EVRY_PLUGIN_NEW(NULL, N_("Text"), type_subject, NULL, "TEXT", + p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Text"), type_subject, NULL, "TEXT", NULL, _cleanup, _fetch, NULL, NULL); - p2 = EVRY_PLUGIN_NEW(NULL, N_("Text"), type_object, NULL, "TEXT", + p2 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Text"), type_object, NULL, "TEXT", NULL, _cleanup, _fetch, NULL, NULL); p1->icon = "accessories-text-editor";