'everything' module:

- added 'send to current desk' border action
- fuzzy match cosmetic
- strip off path from desktop->exec for matching. now '/' shows dir browser as first entry :)
- wider list popup
- open file with apps that only support x-directoy as mimetype strips off filename


SVN revision: 41812
This commit is contained in:
Hannes Janetzek 2009-08-16 08:36:56 +00:00
parent 4394e81ec6
commit 50a4589a10
4 changed files with 108 additions and 37 deletions

View File

@ -183,7 +183,7 @@ int
evry_init(void)
{
_evry_plug_actions_init();
return 1;
}
@ -192,6 +192,7 @@ evry_shutdown(void)
{
evry_hide();
_evry_plug_actions_free();
return 1;
}
@ -457,7 +458,6 @@ int
evry_fuzzy_match(const char *str, const char *match)
{
const char *p, *m, *next;
char mc, pc;
int sum = 0;
unsigned int last = 0;
@ -489,7 +489,7 @@ evry_fuzzy_match(const char *str, const char *match)
next = str;
m = match;
for (word = 0; word < words && *next != 0; )
for (word = 0; (word < words) && (*next != 0);)
{
/* reset match */
if (word == 0) m = match;
@ -497,7 +497,6 @@ evry_fuzzy_match(const char *str, const char *match)
/* end of matching */
if (*m == 0) break;
mc = tolower(*m);
offset = 0;
last = 0;
min = 1;
@ -507,7 +506,7 @@ evry_fuzzy_match(const char *str, const char *match)
for (p = next; *next != 0; p++)
{
/* new word of string begins */
if (*p == 0 || isspace(*p))
if ((*p == 0) || isspace(*p))
{
if (word < words - 1)
{
@ -527,10 +526,8 @@ evry_fuzzy_match(const char *str, const char *match)
}
}
pc = tolower(*p);
/* current char matches? */
if (pc != mc)
if (tolower(*p) != tolower(*m))
{
offset++;
continue;
@ -548,12 +545,9 @@ evry_fuzzy_match(const char *str, const char *match)
last = offset;
/* try next char of match */
m++;
if (*m != 0 && !isspace(*m))
{
mc = tolower(*m);
continue;
}
if (*(++m) != 0 && !isspace(*m))
continue;
/* end of match: store min weight of match */
if (min < word_min[word])
@ -613,8 +607,8 @@ _evry_list_win_new(E_Zone *zone)
y = (zone->h / 2);
/* TODO get offsets from theme */
popup = e_popup_new(zone, x + 50, y - 4,
win->popup->w * 2/3 - 100,
popup = e_popup_new(zone, x + 30, y - 4,
win->popup->w * 2/3 - 60,
evry_conf->height);
if (!popup) return NULL;

View File

@ -188,7 +188,10 @@ _add_desktop_list(Evry_Plugin *p, Eina_List *apps, const char *input)
if (eina_list_count(p->items) > 199) continue;
if (!desktop->name || !desktop->exec) continue;
m1 = evry_fuzzy_match(desktop->exec, 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))
@ -313,7 +316,7 @@ _fetch(Evry_Plugin *p, const char *input)
char *dir;
char cmd[1024];
char path[1024];
if (input)
{
snprintf(cmd, sizeof(cmd), "%s", input);
@ -441,15 +444,48 @@ _app_action(const Evry_Item *it_app, const Evry_Item *it_file)
if (app->desktop)
{
if (it_file && it_file->uri)
files = eina_list_append(files, it_file->uri);
if (it_file)
{
Eina_List *l;
char *mime;
char *path = NULL;
int open_folder = 0;
e_exec(zone, app->desktop, NULL, files, "everything");
if (!it_file->browseable)
{
EINA_LIST_FOREACH(app->desktop->mime_types, l, mime)
{
if (!strcmp(mime, "x-directory/normal"))
{
open_folder = 1;
break;
}
}
}
if (it_file && it_file->mime)
e_exehist_mime_desktop_add(it_file->mime, app->desktop);
if (open_folder)
{
path = ecore_file_dir_get(it_file->uri);
files = eina_list_append(files, path);
}
else
{
files = eina_list_append(files, it_file->uri);
}
if (files) eina_list_free(files);
e_exec(zone, app->desktop, NULL, files, NULL);
if (it_file && it_file->mime && !open_folder)
e_exehist_mime_desktop_add(it_file->mime, app->desktop);
if (files)
eina_list_free(files);
if (open_folder && path)
free(path);
}
else
e_exec(zone, app->desktop, NULL, NULL, "everything");
}
else if (app->file)
{
@ -601,8 +637,7 @@ _new_app_action(Evry_Action *act, const Evry_Item *it1, const Evry_Item *it2, co
else
{
efreet_desktop_save_as(app->desktop, buf);
/*XXX hackish - desktop is removed on save_as..*/
efreet_desktop_new(app->desktop->orig_path);
/* efreet_desktop_new(app->desktop->orig_path); */
desktop = efreet_desktop_new(buf);
}
@ -657,7 +692,7 @@ _init(void)
act1->type_in2 = "FILE";
act1->action = &_exec_app_action;
act1->check_item = &_exec_app_check_item;
act1->icon = "everything-launch";
act1->icon = "document-open";
evry_action_register(act1);
act2 = E_NEW(Evry_Action, 1);

View File

@ -57,7 +57,7 @@ _fetch(Evry_Plugin *p, const char *input)
Eina_List *l;
int prio = 0;
int m1, m2;
_cleanup(p);
zone = e_util_zone_current_get(e_manager_current_get());

View File

@ -34,6 +34,28 @@ _act_cb_border_switch_to(E_Border *bd)
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)
{
@ -119,21 +141,44 @@ _cleanup(Evry_Plugin *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"), _act_cb_border_switch_to, "go-next", input);
_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);
_item_add(p, _("Uniconify"),
_act_cb_border_unminimize,
"window-minimize", input);
else
_item_add(p, _("Iconify"), _act_cb_border_minimize, "window-minimize", input);
_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);
_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, _("Unfullscreen"),
_act_cb_border_fullscreen,
"view-restore", input);
_item_add(p, _("Close"), _act_cb_border_close, "window-close", input);
_item_add(p, _("Close"),
_act_cb_border_close,
"window-close", input);
if (eina_list_count(p->items) > 0)
{
@ -162,9 +207,6 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
o = e_icon_add(e);
evry_icon_theme_set(o, (const char *)it->data[1]);
/* icon = edje_object_add(e);
* e_theme_edje_object_set(icon, "base/theme/borders", (const char *)it->data[1]); */
return o;
}