diff --git a/src/modules/everything/Evry.h b/src/modules/everything/Evry.h index 90aeb0d20..d23c70ca8 100644 --- a/src/modules/everything/Evry.h +++ b/src/modules/everything/Evry.h @@ -137,14 +137,16 @@ struct _Evry_View { Evry_View *id; const char *name; + const char *trigger; + int active; Evas_Object *o_list; Evas_Object *o_bar; - Evry_View *(*create) (const Evry_View *view, const Evry_State *s, const Evas_Object *swallow); - void (*destroy) (const Evry_View *view); - int (*cb_key_down) (const Evry_View *view, const Ecore_Event_Key *ev); - int (*update) (const Evry_View *view); - void (*clear) (const Evry_View *view); + Evry_View *(*create) (Evry_View *view, const Evry_State *s, const Evas_Object *swallow); + void (*destroy) (Evry_View *view); + int (*cb_key_down) (Evry_View *view, const Ecore_Event_Key *ev); + int (*update) (Evry_View *view); + void (*clear) (Evry_View *view); int priority; }; diff --git a/src/modules/everything/Makefile.am b/src/modules/everything/Makefile.am index 4ec707f01..278b1bdec 100644 --- a/src/modules/everything/Makefile.am +++ b/src/modules/everything/Makefile.am @@ -119,6 +119,13 @@ evry_plug_view_list_la_LIBADD = @e_libs@ evry_plug_view_list_la_LDFLAGS = -no-undefined -module -avoid-version evry_plug_view_list_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@ +evry_plug_view_help_la_LDFLAGS = -no-undefined -module -avoid-version +evry_plug_view_help_la_LIBTOOLFLAGS = --tag=disable-static + uninstall: rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE) diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c index 4e5618ecf..9349e0137 100644 --- a/src/modules/everything/evry.c +++ b/src/modules/everything/evry.c @@ -95,7 +95,7 @@ static void _evry_view_clear(Evry_State *s); static void _evry_list_win_update(Evry_State *s); static void _evry_view_update(Evry_State *s, Evry_Plugin *plugin); static int _evry_view_key_press(Evry_State *s, Ecore_Event_Key *ev); -static int _evry_view_toggle(Evry_State *s); +static int _evry_view_toggle(Evry_State *s, const char *trigger); static void _evry_view_show(Evry_View *v); static void _evry_view_hide(Evry_View *v); @@ -455,7 +455,7 @@ evry_fuzzy_match(const char *str, const char *match) for (; (*m != 0) && isspace(*m); m++); m_min[m_num++] = MAX_FUZZ; } - for (m = match; (*m != 0) && (m_num < MAX_WORDS); m++) + for (m = match; ip && (*m != 0); m++) if (ip && ispunct(*m)) ip = 0; next = str; @@ -491,7 +491,7 @@ evry_fuzzy_match(const char *str, const char *match) else { /* go to next word */ - for (; (*p != 0) && (isspace(*p) || (ip && ispunct(*p))); p++); + for (; (*p != 0) && ((isspace(*p) || (ip && ispunct(*p)))); p++); cnt++; next = p; m_cnt = 0; @@ -549,8 +549,8 @@ evry_fuzzy_match(const char *str, const char *match) else if(*p != 0) { /* go to next word */ - for (; (*p != 0) && (!isspace(*p) || (ip && !ispunct(*p))); p++); - for (; (*p != 0) && (isspace(*p) || (ip && ispunct(*p))); p++); + for (; (*p != 0) && !((isspace(*p) || (ip && ispunct(*p)))); p++); + for (; (*p != 0) && ((isspace(*p) || (ip && ispunct(*p)))); p++); cnt++; next = p; m_cnt = 0; @@ -1182,7 +1182,7 @@ _evry_selectors_switch(void) } } - static int +static int _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) { Ecore_Event_Key *ev; @@ -1235,7 +1235,7 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) _evry_browse_back(selector); } else if (!strcmp(key, "1")) - _evry_view_toggle(s); + _evry_view_toggle(s, NULL); else if (!strcmp(key, "Return")) _evry_plugin_action(selector, 0); else if (!strcmp(key, "v")) @@ -1272,10 +1272,17 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) goto end; else if ((ev->compose && !(ev->modifiers & ECORE_EVENT_MODIFIER_ALT))) { - if (strlen(s->input) < (INPUTLEN - strlen(ev->compose))) + int len = strlen(s->input); + if (len < (INPUTLEN - strlen(ev->compose))) { strcat(s->input, ev->compose); - if (isspace(*ev->compose)) + /* if ((len == 0) && isspace(s->input[0])) + * _evry_show_triggers(); */ + if ((len == 1) && + (isspace(s->input[0])) && + (_evry_view_toggle(s, s->input + 1))) + _evry_update(s, 0); + else if (isspace(*ev->compose)) _evry_update(s, 0); else _evry_update(s, 1); @@ -1494,36 +1501,58 @@ _evry_view_clear(Evry_State *s) static int _evry_view_key_press(Evry_State *s, Ecore_Event_Key *ev) { - if (!s || !s->view) return 0; + if (!s || !s->view || !s->view->cb_key_down) return 0; return s->view->cb_key_down(s->view, ev); } static int -_evry_view_toggle(Evry_State *s) +_evry_view_toggle(Evry_State *s, const char *trigger) { - Evry_View *view, *v; + Evry_View *view, *v = NULL; Eina_List *l, *ll; - _evry_list_win_show(); - - l = eina_list_data_find_list(evry_conf->views, s->view->id); - - if (l && l->next) - l = l->next; - else - l = evry_conf->views; - - EINA_LIST_FOREACH(l, ll, view) + if (trigger) { - if ((view != s->view->id) && - (v = view->create(view, s, list->o_main))) - break; + EINA_LIST_FOREACH(evry_conf->views, ll, view) + { + if (view->trigger && !strncmp(trigger, view->trigger, 1) && + (v = view->create(view, s, list->o_main))) + break; + } + } + else + { + l = eina_list_data_find_list(evry_conf->views, s->view->id); + + if (l && l->next) + l = l->next; + else + l = evry_conf->views; + + EINA_LIST_FOREACH(l, ll, view) + { + if ((!view->trigger) && + ((view == s->view->id) || + (v = view->create(view, s, list->o_main)))) + goto found; + } + + EINA_LIST_FOREACH(evry_conf->views, ll, view) + { + if ((!view->trigger) && + ((view == s->view->id) || + (v = view->create(view, s, list->o_main)))) + goto found; + } } + found: if (!v) return 0; + _evry_list_win_show(); + if (s->view) { _evry_view_hide(s->view); @@ -1531,8 +1560,8 @@ _evry_view_toggle(Evry_State *s) } s->view = v; - v->update(v); _evry_view_show(v); + v->update(v); return 1; } diff --git a/src/modules/everything/evry_plug_preview.c b/src/modules/everything/evry_plug_preview.c index 2c24a82f5..4d3f2953c 100644 --- a/src/modules/everything/evry_plug_preview.c +++ b/src/modules/everything/evry_plug_preview.c @@ -91,7 +91,7 @@ _show_item(Image_View *v, const Evry_Item *it, int dir) } static int -_cb_key_down(const Evry_View *view, const Ecore_Event_Key *ev) +_cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) { Image_View *v = (Image_View *) view; @@ -141,7 +141,7 @@ _cb_key_down(const Evry_View *view, const Ecore_Event_Key *ev) } static void -_view_clear(const Evry_View *view) +_view_clear(Evry_View *view) { Image_View *v = (Image_View *) view; @@ -169,7 +169,7 @@ _get_list(const Evry_State *s) } static int -_view_update(const Evry_View *view) +_view_update(Evry_View *view) { Image_View *v = (Image_View *) view; Evry_Item *it; @@ -190,7 +190,7 @@ _view_update(const Evry_View *view) } static Evry_View * -_view_create(const Evry_View *view, const Evry_State *s, const Evas_Object *swallow) +_view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow) { Image_View *v; int w, h, x, y; @@ -216,7 +216,7 @@ _view_create(const Evry_View *view, const Evry_State *s, const Evas_Object *swal } static void -_view_destroy(const Evry_View *view) +_view_destroy(Evry_View *view) { Image_View *v = (Image_View *) view; diff --git a/src/modules/everything/evry_plug_view_help.c b/src/modules/everything/evry_plug_view_help.c new file mode 100644 index 000000000..267483c1b --- /dev/null +++ b/src/modules/everything/evry_plug_view_help.c @@ -0,0 +1,137 @@ +#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 = + "<b>Welcome!</b>" + "Ok, here comes the explanation of everything...
" + "everything is simple! Just type a few letters of
" + "the thing you are looking for. Use cursor <up/down>
" + "to choose from the list of found things.
" + "Press <tab> to select " + "an action, then press <return>.
" + /* "You might want to know
some mo keybinding to ease your experience though.
" */ + "<space><?> show this page
" + "<ctrl+letter> jump to plugin beginning with 'letter'
" + "<ctrl+left/right>" + "cycle through plugins
" + "<ctrl+1> " + "choose a different view (e.g. for images)
"; + + 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) +{ + 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/evry_plug_view_list.c b/src/modules/everything/evry_plug_view_list.c index d2d6ba856..87b9e4610 100644 --- a/src/modules/everything/evry_plug_view_list.c +++ b/src/modules/everything/evry_plug_view_list.c @@ -538,7 +538,7 @@ _list_plugin_prev(List_View *v) } static int -_update(const Evry_View *view) +_update(Evry_View *view) { List_View *v = (List_View *) view; _list_update(v); @@ -547,7 +547,7 @@ _update(const Evry_View *view) } static void -_clear(const Evry_View *view) +_clear(Evry_View *view) { List_View *v = (List_View *) view; _list_clear(v); @@ -556,7 +556,7 @@ _clear(const Evry_View *view) static int -_cb_key_down(const Evry_View *view, const Ecore_Event_Key *ev) +_cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) { List_View *v = (List_View *) view; @@ -599,7 +599,7 @@ _cb_key_down(const Evry_View *view, const Ecore_Event_Key *ev) } static Evry_View * -_create(const Evry_View *view, const Evry_State *s, const Evas_Object *swallow) +_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow) { List_View *v; Evas_Object *o; @@ -626,7 +626,7 @@ _create(const Evry_View *view, const Evry_State *s, const Evas_Object *swallow) } static void -_destroy(const Evry_View *view) +_destroy(Evry_View *view) { List_View *v = (List_View *) view; List_Tab *tab;