'everything' module:

- made triggers exclusive for now. i.e. '=' only shows calc plugin
- calc: create special window for clipboard selection
- fixed apps glob matches


SVN revision: 41351
This commit is contained in:
Hannes Janetzek 2009-07-15 14:37:01 +00:00
parent ff06789039
commit fc6c3e8461
3 changed files with 134 additions and 65 deletions

View File

@ -63,6 +63,7 @@ static int _evry_push_state(void);
static int _evry_pop_state(void);
static void _evry_plugin_selector_show(Evry_Plugin *p);
static int _evry_cb_plugin_sort(const void *data1, const void *data2);
static int _evry_cb_plugin_sort_by_trigger(const void *data1, const void *data2);
static int _evry_plug_act_select_init(void);
static int _evry_plug_act_select_begin(Evry_Plugin *p, Evry_Item *it);
@ -340,7 +341,12 @@ evry_plugin_async_update(Evry_Plugin *p, int action)
{
if (!eina_list_data_find(s->cur_plugins, p))
{
s->cur_plugins = eina_list_append(s->cur_plugins, p);
s->cur_plugins = eina_list_prepend(s->cur_plugins, p);
s->cur_plugins = eina_list_sort(s->cur_plugins,
eina_list_count(s->cur_plugins),
_evry_cb_plugin_sort_by_trigger);
_evry_plugin_selector_show(p);
}
else
@ -350,8 +356,8 @@ evry_plugin_async_update(Evry_Plugin *p, int action)
edje_object_part_text_set(p->tab, "e.text.label", buf);
}
if ((!s->cur_plugin && s->cur_plugins) || (s->cur_plugin == p) ||
(s->plugin_auto_selected && (s->cur_plugin->config->priority > p->config->priority)))
if ((!s->cur_plugin && s->cur_plugins) || (s->cur_plugin == p))
/* || (s->plugin_auto_selected && (s->cur_plugin->config->priority > p->config->priority))) */
{
if (!s->cur_plugin)
s->plugin_auto_selected = 1;
@ -359,6 +365,13 @@ evry_plugin_async_update(Evry_Plugin *p, int action)
_evry_list_clear();
_evry_show_items(s->cur_plugins->data);
}
else if (/*s->plugin_auto_selected &&*/ p->trigger &&
(!strncmp(s->input, p->trigger, strlen(p->trigger))))
{
_evry_list_clear();
_evry_show_items(p);
/* s->plugin_auto_selected = 0; */
}
else if (s->cur_plugin)
_evry_tab_scroll_to(s->cur_plugin);
}
@ -375,7 +388,7 @@ evry_clear_input(void)
{
if (cur_state->input[0] != 0)
{
cur_state->input[0] = 0;
cur_state->input[0] = 0;
}
}
@ -389,6 +402,20 @@ _evry_cb_plugin_sort(const void *data1, const void *data2)
return p1->config->priority - p2->config->priority;
}
static int
_evry_cb_plugin_sort_by_trigger(const void *data1, const void *data2)
{
const Evry_Plugin *p1 = data1;
const Evry_Plugin *p2 = data2;
if (p1->trigger)
{
if (!strncmp(cur_state->input, p1->trigger, strlen(p1->trigger)))
return 1;
}
return p1->config->priority - p2->config->priority;
}
static int
_evry_push_state(void)
{
@ -1002,24 +1029,33 @@ _evry_matches_update(Evry_Plugin *cur_plugin)
s->cur_plugins = NULL;
s->sel_item = NULL;
if (s->input)
EINA_LIST_FOREACH(s->plugins, l, p)
{
/* input matches trigger? */
if (p->trigger)
{
const char *trigger = p->trigger;
if ((strlen(s->input) < strlen(trigger)) ||
(strncmp(s->input, trigger, strlen(trigger))))
continue;
if ((strlen(s->input) >= strlen(p->trigger)) &&
(!strncmp(s->input, p->trigger, strlen(p->trigger))))
{
s->cur_plugins = eina_list_append(s->cur_plugins, p);
items = p->fetch(p, s->input);
break;
}
}
}
if (!s->cur_plugins)
EINA_LIST_FOREACH(s->plugins, l, p)
{
if (p->trigger) continue;
if (strlen(s->input) == 0)
items = !p->need_query ? p->fetch(p, NULL) : 0;
else
items = p->fetch(p, s->input);
if (!s->initial || (items && eina_list_count(p->items) > 0))
if (!s->initial || (items && eina_list_count(p->items) > 0) || p->async_query)
s->cur_plugins = eina_list_append(s->cur_plugins, p);
}
@ -1039,6 +1075,10 @@ _evry_matches_update(Evry_Plugin *cur_plugin)
if (s->cur_plugins)
{
/* s->cur_plugins = eina_list_sort(s->cur_plugins,
* eina_list_count(s->cur_plugins),
* _evry_cb_plugin_sort_by_trigger); */
if (cur_plugin && eina_list_data_find(s->cur_plugins, cur_plugin))
_evry_show_items(cur_plugin);
else

View File

@ -18,9 +18,11 @@ static void _item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int p
static int _cb_sort(const void *data1, const void *data2);
static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
static int _exec_app_action(Evry_Action *act);
static int _exec_app_check_item(Evry_Action *act, Evry_Item *it);
static int _edit_app_action(Evry_Action *act);
static int _edit_app_check_item(Evry_Action *act, Evry_Item *it);
static int _new_app_action(Evry_Action *act);
static int _new_app_check_item(Evry_Action *act, Evry_Item *it);
static Evry_Plugin *p1;
static Evry_Plugin *p2;
@ -63,6 +65,7 @@ evry_plug_apps_init(void)
act->type_in2 = "FILE";
act->type_out = "NONE";
act->action = &_exec_app_action;
act->check_item = &_exec_app_check_item;
evry_action_register(act);
act2 = E_NEW(Evry_Action, 1);
@ -80,6 +83,7 @@ evry_plug_apps_init(void)
act3->type_in2 = "NONE";
act3->type_out = "NONE";
act3->action = &_new_app_action;
act3->check_item = &_new_app_check_item;
evry_action_register(act3);
inst = NULL;
@ -277,27 +281,35 @@ _fetch(Evry_Plugin *p, const char *input)
EINA_LIST_FREE(l, desktop)
_item_add(p, desktop, NULL, 1);
snprintf(match1, sizeof(match1), "*%s*", input);
l = efreet_util_desktop_name_glob_list(match1);
EINA_LIST_FREE(l, desktop)
_item_add(p, desktop, NULL, 3);
snprintf(match1, sizeof(match1), "*%s*", input);
l = efreet_util_desktop_exec_glob_list(match1);
EINA_LIST_FREE(l, desktop)
_item_add(p, desktop, NULL, 2);
l = efreet_util_desktop_name_glob_list(match1);
EINA_LIST_FREE(l, desktop)
_item_add(p, desktop, NULL, 4);
// TODO make these optional/configurable
l = efreet_util_desktop_generic_name_glob_list(match1);
EINA_LIST_FREE(l, desktop)
_item_add(p, desktop, NULL, 3);
_item_add(p, desktop, NULL, 5);
l = efreet_util_desktop_comment_glob_list(match1);
EINA_LIST_FREE(l, desktop)
_item_add(p, desktop, NULL, 3);
}
else if (!p->items)
{
// TODO option for popular/recent
l = e_exehist_list_get();
EINA_LIST_FREE(l, file)
_item_add(p, NULL, file, 1);
_item_add(p, desktop, NULL, 5);
}
/* else if (!p->items)
* {
* // TODO option for popular/recent
* l = e_exehist_list_get();
* EINA_LIST_FREE(l, file)
* _item_add(p, NULL, file, 1);
* } */
if (inst->added)
{
@ -462,6 +474,20 @@ _cb_sort(const void *data1, const void *data2)
else return 0;
}
static int
_exec_app_check_item(Evry_Action *act, Evry_Item *it)
{
Evry_App *app = it->data[0];
if (app->desktop)
return 1;
if (app->file && strlen(app->file) > 0)
return 1;
return 0;
}
static int
_exec_app_action(Evry_Action *act)
{
@ -544,7 +570,7 @@ _edit_app_action(Evry_Action *act)
snprintf(buf, 128, "%s/.local/share/applications/%s.desktop", e_user_homedir_get(), app->file);
desktop = efreet_desktop_empty_new(eina_stringshare_add(buf));
/* XXX check if this is freed */
/* XXX check if this gets freed by efreet*/
desktop->exec = strdup(app->file);
}
@ -557,6 +583,20 @@ _edit_app_action(Evry_Action *act)
}
static int
_new_app_check_item(Evry_Action *act, Evry_Item *it)
{
Evry_App *app = it->data[0];
if (app->desktop)
return 1;
if (app->file && strlen(app->file) > 0)
return 1;
return 0;
}
static int
_new_app_action(Evry_Action *act)
{

View File

@ -19,7 +19,7 @@ static Ecore_Exe *exe = NULL;
static Eina_List *history = NULL;
static Ecore_Event_Handler *data_handler = NULL;
static Ecore_Event_Handler *error_handler = NULL;
static Ecore_X_Window clipboard_win = 0;
EAPI int
evry_plug_calc_init(void)
@ -38,6 +38,7 @@ evry_plug_calc_init(void)
p->icon_get = &_item_icon_get;
evry_plugin_register(p);
clipboard_win = ecore_x_window_new(0, 0, 0, 1, 1);
return 1;
}
@ -55,6 +56,8 @@ evry_plug_calc_shutdown(void)
evry_plugin_unregister(p);
E_FREE(p);
ecore_x_window_free(clipboard_win);
return 1;
}
@ -110,58 +113,44 @@ _send_input(const char *input)
static int
_action(Evry_Plugin *p, Evry_Item *it, const char *input)
{
if (!it)
if (!it) return EVRY_ACTION_CONTINUE;
if (p->items)
{
if (p->items)
Eina_List *l;
Evry_Item *it2;
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_CLEAR);
/* remove duplicates */
if (p->items->next)
{
Eina_List *l;
Evry_Item *it2;
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_CLEAR);
/* remove duplicates */
if (p->items->next)
{
it = p->items->data;
it = p->items->data;
EINA_LIST_FOREACH(p->items->next, l, it2)
{
if (!strcmp(it->label, it2->label))
break;
it2 = NULL;
}
if (it2)
{
p->items = eina_list_remove(p->items, it2);
eina_stringshare_del(it2->label);
E_FREE(it2);
}
EINA_LIST_FOREACH(p->items->next, l, it2)
{
if (!strcmp(it->label, it2->label))
break;
it2 = NULL;
}
it = p->items->data;
_item_add(p, (char *) it->label, 1);
if (it2)
{
p->items = eina_list_remove(p->items, it2);
eina_stringshare_del(it2->label);
E_FREE(it2);
}
}
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
it = p->items->data;
/* return EVRY_ACTION_CONTINUE; */
_item_add(p, (char *) it->label, 1);
}
/* else */
{
/* XXX on which windows must the selection be set? */
ecore_x_selection_primary_set(e_manager_current_get()->win,
it->label, strlen(it->label));
ecore_x_selection_clipboard_set(e_manager_current_get()->win,
it->label, strlen(it->label));
/* if (p->items->data == it)
* {
* Evry_Item *it2 = p->items->data;
* _item_add(p, (char *) it2->label, 1);
* } */
}
/* evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD); */
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 EVRY_ACTION_FINISHED;
}