'everything' module:
- added begging of help view plugin (trigger with space+?) - fix fuzzy match to handle punctuation correctly - fix view plugin api for singleton plugins SVN revision: 41909
This commit is contained in:
parent
f562bba47f
commit
b1225d5251
|
@ -137,14 +137,16 @@ struct _Evry_View
|
||||||
{
|
{
|
||||||
Evry_View *id;
|
Evry_View *id;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
const char *trigger;
|
||||||
|
int active;
|
||||||
Evas_Object *o_list;
|
Evas_Object *o_list;
|
||||||
Evas_Object *o_bar;
|
Evas_Object *o_bar;
|
||||||
|
|
||||||
Evry_View *(*create) (const Evry_View *view, const Evry_State *s, const Evas_Object *swallow);
|
Evry_View *(*create) (Evry_View *view, const Evry_State *s, const Evas_Object *swallow);
|
||||||
void (*destroy) (const Evry_View *view);
|
void (*destroy) (Evry_View *view);
|
||||||
int (*cb_key_down) (const Evry_View *view, const Ecore_Event_Key *ev);
|
int (*cb_key_down) (Evry_View *view, const Ecore_Event_Key *ev);
|
||||||
int (*update) (const Evry_View *view);
|
int (*update) (Evry_View *view);
|
||||||
void (*clear) (const Evry_View *view);
|
void (*clear) (Evry_View *view);
|
||||||
|
|
||||||
int priority;
|
int priority;
|
||||||
};
|
};
|
||||||
|
|
|
@ -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_LDFLAGS = -no-undefined -module -avoid-version
|
||||||
evry_plug_view_list_la_LIBTOOLFLAGS = --tag=disable-static
|
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:
|
uninstall:
|
||||||
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)
|
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ static void _evry_view_clear(Evry_State *s);
|
||||||
static void _evry_list_win_update(Evry_State *s);
|
static void _evry_list_win_update(Evry_State *s);
|
||||||
static void _evry_view_update(Evry_State *s, Evry_Plugin *plugin);
|
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_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_show(Evry_View *v);
|
||||||
static void _evry_view_hide(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++);
|
for (; (*m != 0) && isspace(*m); m++);
|
||||||
m_min[m_num++] = MAX_FUZZ;
|
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;
|
if (ip && ispunct(*m)) ip = 0;
|
||||||
|
|
||||||
next = str;
|
next = str;
|
||||||
|
@ -491,7 +491,7 @@ evry_fuzzy_match(const char *str, const char *match)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* go to next word */
|
/* go to next word */
|
||||||
for (; (*p != 0) && (isspace(*p) || (ip && ispunct(*p))); p++);
|
for (; (*p != 0) && ((isspace(*p) || (ip && ispunct(*p)))); p++);
|
||||||
cnt++;
|
cnt++;
|
||||||
next = p;
|
next = p;
|
||||||
m_cnt = 0;
|
m_cnt = 0;
|
||||||
|
@ -549,8 +549,8 @@ evry_fuzzy_match(const char *str, const char *match)
|
||||||
else if(*p != 0)
|
else if(*p != 0)
|
||||||
{
|
{
|
||||||
/* go to next word */
|
/* 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++;
|
cnt++;
|
||||||
next = p;
|
next = p;
|
||||||
m_cnt = 0;
|
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)
|
_evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||||
{
|
{
|
||||||
Ecore_Event_Key *ev;
|
Ecore_Event_Key *ev;
|
||||||
|
@ -1235,7 +1235,7 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||||
_evry_browse_back(selector);
|
_evry_browse_back(selector);
|
||||||
}
|
}
|
||||||
else if (!strcmp(key, "1"))
|
else if (!strcmp(key, "1"))
|
||||||
_evry_view_toggle(s);
|
_evry_view_toggle(s, NULL);
|
||||||
else if (!strcmp(key, "Return"))
|
else if (!strcmp(key, "Return"))
|
||||||
_evry_plugin_action(selector, 0);
|
_evry_plugin_action(selector, 0);
|
||||||
else if (!strcmp(key, "v"))
|
else if (!strcmp(key, "v"))
|
||||||
|
@ -1272,10 +1272,17 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||||
goto end;
|
goto end;
|
||||||
else if ((ev->compose && !(ev->modifiers & ECORE_EVENT_MODIFIER_ALT)))
|
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);
|
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);
|
_evry_update(s, 0);
|
||||||
else
|
else
|
||||||
_evry_update(s, 1);
|
_evry_update(s, 1);
|
||||||
|
@ -1494,20 +1501,29 @@ _evry_view_clear(Evry_State *s)
|
||||||
static int
|
static int
|
||||||
_evry_view_key_press(Evry_State *s, Ecore_Event_Key *ev)
|
_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);
|
return s->view->cb_key_down(s->view, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
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;
|
Eina_List *l, *ll;
|
||||||
|
|
||||||
_evry_list_win_show();
|
if (trigger)
|
||||||
|
{
|
||||||
|
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);
|
l = eina_list_data_find_list(evry_conf->views, s->view->id);
|
||||||
|
|
||||||
if (l && l->next)
|
if (l && l->next)
|
||||||
|
@ -1517,13 +1533,26 @@ _evry_view_toggle(Evry_State *s)
|
||||||
|
|
||||||
EINA_LIST_FOREACH(l, ll, view)
|
EINA_LIST_FOREACH(l, ll, view)
|
||||||
{
|
{
|
||||||
if ((view != s->view->id) &&
|
if ((!view->trigger) &&
|
||||||
(v = view->create(view, s, list->o_main)))
|
((view == s->view->id) ||
|
||||||
break;
|
(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;
|
if (!v) return 0;
|
||||||
|
|
||||||
|
_evry_list_win_show();
|
||||||
|
|
||||||
if (s->view)
|
if (s->view)
|
||||||
{
|
{
|
||||||
_evry_view_hide(s->view);
|
_evry_view_hide(s->view);
|
||||||
|
@ -1531,8 +1560,8 @@ _evry_view_toggle(Evry_State *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
s->view = v;
|
s->view = v;
|
||||||
v->update(v);
|
|
||||||
_evry_view_show(v);
|
_evry_view_show(v);
|
||||||
|
v->update(v);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ _show_item(Image_View *v, const Evry_Item *it, int dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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;
|
Image_View *v = (Image_View *) view;
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ _cb_key_down(const Evry_View *view, const Ecore_Event_Key *ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_view_clear(const Evry_View *view)
|
_view_clear(Evry_View *view)
|
||||||
{
|
{
|
||||||
Image_View *v = (Image_View *) view;
|
Image_View *v = (Image_View *) view;
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ _get_list(const Evry_State *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_view_update(const Evry_View *view)
|
_view_update(Evry_View *view)
|
||||||
{
|
{
|
||||||
Image_View *v = (Image_View *) view;
|
Image_View *v = (Image_View *) view;
|
||||||
Evry_Item *it;
|
Evry_Item *it;
|
||||||
|
@ -190,7 +190,7 @@ _view_update(const Evry_View *view)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evry_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;
|
Image_View *v;
|
||||||
int w, h, x, y;
|
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
|
static void
|
||||||
_view_destroy(const Evry_View *view)
|
_view_destroy(Evry_View *view)
|
||||||
{
|
{
|
||||||
Image_View *v = (Image_View *) view;
|
Image_View *v = (Image_View *) view;
|
||||||
|
|
||||||
|
|
|
@ -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 =
|
||||||
|
"<title><b>Welcome!</b></title>"
|
||||||
|
"Ok, here comes the explanation of <hilight>everything</hilight>...<br>"
|
||||||
|
"<hilight>everything</hilight> is simple! Just type a few letters of <br>"
|
||||||
|
"the thing you are looking for. Use cursor <hilight><up/down></hilight> <br>"
|
||||||
|
"to choose from the list of found 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)
|
||||||
|
{
|
||||||
|
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);
|
|
@ -538,7 +538,7 @@ _list_plugin_prev(List_View *v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_update(const Evry_View *view)
|
_update(Evry_View *view)
|
||||||
{
|
{
|
||||||
List_View *v = (List_View *) view;
|
List_View *v = (List_View *) view;
|
||||||
_list_update(v);
|
_list_update(v);
|
||||||
|
@ -547,7 +547,7 @@ _update(const Evry_View *view)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_clear(const Evry_View *view)
|
_clear(Evry_View *view)
|
||||||
{
|
{
|
||||||
List_View *v = (List_View *) view;
|
List_View *v = (List_View *) view;
|
||||||
_list_clear(v);
|
_list_clear(v);
|
||||||
|
@ -556,7 +556,7 @@ _clear(const Evry_View *view)
|
||||||
|
|
||||||
|
|
||||||
static int
|
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;
|
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 *
|
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;
|
List_View *v;
|
||||||
Evas_Object *o;
|
Evas_Object *o;
|
||||||
|
@ -626,7 +626,7 @@ _create(const Evry_View *view, const Evry_State *s, const Evas_Object *swallow)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_destroy(const Evry_View *view)
|
_destroy(Evry_View *view)
|
||||||
{
|
{
|
||||||
List_View *v = (List_View *) view;
|
List_View *v = (List_View *) view;
|
||||||
List_Tab *tab;
|
List_Tab *tab;
|
||||||
|
|
Loading…
Reference in New Issue