forked from enlightenment/enlightenment
'everything' module:
- pass plugin priority hints with plugin registration for initial sorting - register "select action" as normal plugin (move it before "open with.." action to use efm as default to browse dirs) SVN revision: 41822
This commit is contained in:
parent
4e590e43cf
commit
43ebda5a4d
|
@ -83,7 +83,6 @@ struct _Evry_Plugin
|
|||
/* run when plugin is activated. */
|
||||
int (*begin) (Evry_Plugin *p, const Evry_Item *item);
|
||||
|
||||
|
||||
int (*browse) (Evry_Plugin *p, const Evry_Item *item);
|
||||
|
||||
/* get candidates matching string, fills 'candidates' list */
|
||||
|
@ -148,7 +147,7 @@ struct _Evry_App
|
|||
Efreet_Desktop *desktop;
|
||||
};
|
||||
|
||||
void evry_plugin_register(Evry_Plugin *p);
|
||||
void evry_plugin_register(Evry_Plugin *p, int priority);
|
||||
void evry_plugin_unregister(Evry_Plugin *p);
|
||||
void evry_action_register(Evry_Action *act);
|
||||
void evry_action_unregister(Evry_Action *act);
|
||||
|
|
|
@ -16,7 +16,6 @@ static void _e_mod_run_cb(void *data, E_Menu *m, E_Menu_Item *mi);
|
|||
static void _e_mod_menu_add(void *data, E_Menu *m);
|
||||
|
||||
/* static E_Module *conf_module = NULL; */
|
||||
static E_Action *act = NULL;
|
||||
static E_Int_Menu_Augmentation *maug = NULL;
|
||||
|
||||
static Eina_Array *plugins = NULL;
|
||||
|
@ -49,6 +48,7 @@ e_modapi_init(E_Module *m)
|
|||
Eina_List *files;
|
||||
char buf[4096], dir[4096];
|
||||
char *file;
|
||||
E_Action *act;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s/module.everything",
|
||||
e_user_homedir_get(), e_config_profile_get());
|
||||
|
@ -122,6 +122,7 @@ e_modapi_init(E_Module *m)
|
|||
act->func.go = _e_mod_action_exebuf_cb;
|
||||
e_action_predef_name_set(_("Launch"), _("Run Everything Dialog"), "everything",
|
||||
NULL, NULL, 0);
|
||||
evry_conf->action_show = act;
|
||||
}
|
||||
|
||||
maug = e_int_menus_menu_augmentation_add("main/1", _e_mod_menu_add, NULL, NULL, NULL);
|
||||
|
@ -146,11 +147,10 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
|
|||
maug = NULL;
|
||||
}
|
||||
/* remove module-supplied action */
|
||||
if (act)
|
||||
if (evry_conf->action_show)
|
||||
{
|
||||
e_action_predef_name_del(_("Launch"), _("Run Everything Dialog"));
|
||||
e_action_del("everything");
|
||||
act = NULL;
|
||||
}
|
||||
|
||||
evry_shutdown();
|
||||
|
@ -247,7 +247,7 @@ _evry_cb_plugin_sort(const void *data1, const void *data2)
|
|||
}
|
||||
|
||||
EAPI void
|
||||
evry_plugin_register(Evry_Plugin *plugin)
|
||||
evry_plugin_register(Evry_Plugin *plugin, int priority)
|
||||
{
|
||||
Eina_List *l;
|
||||
Plugin_Config *pc;
|
||||
|
@ -269,7 +269,7 @@ evry_plugin_register(Evry_Plugin *plugin)
|
|||
pc = E_NEW(Plugin_Config, 1);
|
||||
pc->name = eina_stringshare_add(plugin->name);
|
||||
pc->enabled = 1;
|
||||
pc->priority = eina_list_count(evry_conf->plugins);
|
||||
pc->priority = priority ? priority : 100;;
|
||||
|
||||
evry_conf->plugins_conf = eina_list_append(evry_conf->plugins_conf, pc);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ struct _Config
|
|||
Eina_List *actions;
|
||||
|
||||
Eina_Hash *history;
|
||||
E_Action *action_show;
|
||||
};
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#define INPUTLEN 40
|
||||
#define MATCH_LAG 0.33
|
||||
#define MAX_FUZZ 150
|
||||
#define MAX_WORDS 64
|
||||
|
||||
|
||||
typedef struct _Evry_State Evry_State;
|
||||
|
@ -360,11 +361,10 @@ evry_item_free(Evry_Item *it)
|
|||
|
||||
if (it->ref > 0) return;
|
||||
|
||||
/* printf("%d, %d\t 0x%x 0x%x 0x%x free: %s\n",
|
||||
/* printf("%d, %d\t free: %s\n",
|
||||
* it->ref, item_cnt - 1,
|
||||
* it->label, it->uri, it->mime,
|
||||
* it->label); */
|
||||
/* item_cnt--; */
|
||||
* it->label);
|
||||
* item_cnt--; */
|
||||
|
||||
if (it->cb_free) it->cb_free(it);
|
||||
|
||||
|
@ -468,7 +468,7 @@ evry_fuzzy_match(const char *str, const char *match)
|
|||
/* words in match */
|
||||
unsigned int words = 1;
|
||||
unsigned int word = 0;
|
||||
unsigned int word_min[64];
|
||||
unsigned int word_min[MAX_WORDS];
|
||||
|
||||
if (!match || !str) return 0;
|
||||
|
||||
|
@ -478,7 +478,7 @@ evry_fuzzy_match(const char *str, const char *match)
|
|||
|
||||
/* count words in match */
|
||||
word_min[0] = MAX_FUZZ;
|
||||
for (m = match; *m != 0 && *(m+1) != 0; m++)
|
||||
for (m = match; (*m != 0) && (*(m+1) != 0) && (words < MAX_WORDS); m++)
|
||||
{
|
||||
if (isspace(*m) && !isspace(*(m+1)))
|
||||
{
|
||||
|
@ -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 < words) && (*next != 0);)
|
||||
{
|
||||
/* reset match */
|
||||
if (word == 0) m = match;
|
||||
|
@ -792,8 +792,8 @@ _evry_selector_new(int type)
|
|||
if (p->type != type) continue;
|
||||
sel->plugins = eina_list_append(sel->plugins, p);
|
||||
}
|
||||
if (type == type_action)
|
||||
sel->plugins = eina_list_append(sel->plugins, action_selector);
|
||||
/* if (type == type_action)
|
||||
* sel->plugins = eina_list_append(sel->plugins, action_selector); */
|
||||
|
||||
return sel;
|
||||
}
|
||||
|
@ -1283,14 +1283,6 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
|||
}
|
||||
else _evry_list_plugin_next_by_name(s, ev->key);
|
||||
}
|
||||
else if (!strcmp(ev->key, "Up"))
|
||||
_evry_list_item_prev(s);
|
||||
else if (!strcmp(ev->key, "Down"))
|
||||
_evry_list_item_next(s);
|
||||
else if (!strcmp(ev->key, "Next"))
|
||||
_evry_list_plugin_next(s);
|
||||
else if (!strcmp(ev->key, "Prior"))
|
||||
_evry_list_plugin_prev(s);
|
||||
else if (!strcmp(ev->key, "Right"))
|
||||
{
|
||||
if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)
|
||||
|
@ -1312,12 +1304,21 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
|||
else
|
||||
_evry_plugin_action(selector, 1);
|
||||
}
|
||||
else if (!strcmp(ev->key, "Tab"))
|
||||
_evry_selectors_switch();
|
||||
else if (!strcmp(ev->key, "Escape"))
|
||||
evry_hide();
|
||||
else if ((!strcmp(ev->key, "BackSpace")) ||
|
||||
(!strcmp(ev->key, "Delete")))
|
||||
else if (!strcmp(ev->key, "Up"))
|
||||
_evry_list_item_prev(s);
|
||||
else if (!strcmp(ev->key, "Down"))
|
||||
_evry_list_item_next(s);
|
||||
else if (!strcmp(ev->key, "Next"))
|
||||
_evry_list_plugin_next(s);
|
||||
else if (!strcmp(ev->key, "Prior"))
|
||||
_evry_list_plugin_prev(s);
|
||||
else if (!strcmp(ev->key, "Tab"))
|
||||
_evry_selectors_switch();
|
||||
else if (!strcmp(ev->key, "BackSpace"))
|
||||
_evry_backspace(s);
|
||||
else if (!strcmp(ev->key, "Delete"))
|
||||
_evry_backspace(s);
|
||||
else if (!strcmp(ev->key, "End"))
|
||||
_evry_list_item_last(s);
|
||||
|
@ -1681,6 +1682,8 @@ _evry_matches_update(Evry_Selector *sel)
|
|||
{
|
||||
sel->aggregator->fetch(sel->aggregator, s->input);
|
||||
s->cur_plugins = eina_list_prepend(s->cur_plugins, sel->aggregator);
|
||||
if (s->plugin_auto_selected)
|
||||
_evry_select_plugin(s, NULL);
|
||||
}
|
||||
else
|
||||
sel->aggregator->cleanup(sel->aggregator);
|
||||
|
@ -1787,13 +1790,10 @@ _evry_list_item_desel(Evry_State *s, Evry_Item *it)
|
|||
{
|
||||
it = s->sel_item;
|
||||
|
||||
if (list->visible)
|
||||
{
|
||||
if (it->o_bg)
|
||||
edje_object_signal_emit(it->o_bg, "e,state,unselected", "e");
|
||||
if (it->o_icon)
|
||||
edje_object_signal_emit(it->o_icon, "e,state,unselected", "e");
|
||||
}
|
||||
if (it->o_bg)
|
||||
edje_object_signal_emit(it->o_bg, "e,state,unselected", "e");
|
||||
if (it->o_icon)
|
||||
edje_object_signal_emit(it->o_icon, "e,state,unselected", "e");
|
||||
|
||||
evry_item_free(it);
|
||||
s->sel_item = NULL;
|
||||
|
@ -1841,12 +1841,12 @@ _evry_list_item_next(Evry_State *s)
|
|||
s->plugin_auto_selected = EINA_FALSE;
|
||||
s->item_auto_selected = EINA_FALSE;
|
||||
|
||||
if (!s->sel_item)
|
||||
{
|
||||
_evry_list_item_sel(s, s->plugin->items->data);
|
||||
_evry_selector_update(selector);
|
||||
return;
|
||||
}
|
||||
/* if (!s->sel_item)
|
||||
* {
|
||||
* _evry_list_item_sel(s, s->plugin->items->data);
|
||||
* _evry_selector_update(selector);
|
||||
* return;
|
||||
* } */
|
||||
|
||||
EINA_LIST_FOREACH (s->plugin->items, l, it)
|
||||
{
|
||||
|
@ -1888,6 +1888,7 @@ _evry_list_item_prev(Evry_State *s)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_evry_list_win_hide();
|
||||
}
|
||||
|
||||
|
@ -2155,19 +2156,25 @@ _evry_fuzzy_sort_cb(const void *data1, const void *data2)
|
|||
(it1->priority - it2->priority))
|
||||
return (it1->priority - it2->priority);
|
||||
|
||||
if (it1->fuzzy_match && !it2->fuzzy_match)
|
||||
return -1;
|
||||
if (it1->fuzzy_match || it2->fuzzy_match)
|
||||
{
|
||||
if (it1->fuzzy_match && !it2->fuzzy_match)
|
||||
return -1;
|
||||
|
||||
if (!it1->fuzzy_match && it2->fuzzy_match)
|
||||
return 1;
|
||||
if (!it1->fuzzy_match && it2->fuzzy_match)
|
||||
return 1;
|
||||
|
||||
if (it1->fuzzy_match - it2->fuzzy_match)
|
||||
return (it1->fuzzy_match - it2->fuzzy_match);
|
||||
if (it1->fuzzy_match - it2->fuzzy_match)
|
||||
return (it1->fuzzy_match - it2->fuzzy_match);
|
||||
}
|
||||
|
||||
if (it1->plugin->config->priority - it2->plugin->config->priority)
|
||||
return (it1->plugin->config->priority - it2->plugin->config->priority);
|
||||
|
||||
return (it1->priority - it2->priority);
|
||||
if (it1->priority - it2->priority)
|
||||
return (it1->priority - it2->priority);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* action selector plugin: provides list of actions registered for
|
||||
|
@ -2175,7 +2182,6 @@ _evry_fuzzy_sort_cb(const void *data1, const void *data2)
|
|||
static int
|
||||
_evry_plug_actions_init(void)
|
||||
{
|
||||
Plugin_Config *pc;
|
||||
Evry_Plugin *p = E_NEW(Evry_Plugin, 1);
|
||||
p->name = "Select Action";
|
||||
p->type = type_action;
|
||||
|
@ -2186,13 +2192,8 @@ _evry_plug_actions_init(void)
|
|||
p->fetch = &_evry_plug_actions_fetch;
|
||||
p->icon_get = &_evry_plug_actions_item_icon_get;
|
||||
|
||||
pc = E_NEW(Plugin_Config, 1);
|
||||
pc->name = eina_stringshare_add(p->name);
|
||||
pc->enabled = 1;
|
||||
pc->priority = 1;
|
||||
p->config = pc;
|
||||
|
||||
action_selector = p;
|
||||
evry_plugin_register(p, 2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -2202,6 +2203,7 @@ _evry_plug_actions_free(void)
|
|||
{
|
||||
Evry_Plugin *p = action_selector;
|
||||
|
||||
evry_plugin_unregister(p);
|
||||
eina_stringshare_del(p->config->name);
|
||||
E_FREE(p->config);
|
||||
E_FREE(p);
|
||||
|
|
|
@ -662,7 +662,7 @@ _init(void)
|
|||
p1->fetch = &_fetch;
|
||||
p1->cleanup = &_cleanup;
|
||||
p1->icon_get = &_item_icon_get;
|
||||
evry_plugin_register(p1);
|
||||
evry_plugin_register(p1, 1);
|
||||
|
||||
p2 = E_NEW(Evry_Plugin, 1);
|
||||
p2->name = "Open With...";
|
||||
|
@ -675,7 +675,7 @@ _init(void)
|
|||
p2->action = &_open_with_action;
|
||||
p2->cleanup = &_cleanup;
|
||||
p2->icon_get = &_item_icon_get;
|
||||
evry_plugin_register(p2);
|
||||
evry_plugin_register(p2, 3);
|
||||
|
||||
act = E_NEW(Evry_Action, 1);
|
||||
act->name = "Launch";
|
||||
|
|
|
@ -343,7 +343,7 @@ _init(void)
|
|||
p->base.fetch = _fetch;
|
||||
p->base.cleanup = _cleanup;
|
||||
|
||||
evry_plugin_register(&p->base);
|
||||
evry_plugin_register(&p->base, 100);
|
||||
|
||||
_singleton = p;
|
||||
return EINA_TRUE;
|
||||
|
|
|
@ -108,7 +108,44 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
|||
Evas_Object *o = NULL;
|
||||
E_Border *bd = it->data[0];
|
||||
|
||||
if (bd->desktop)
|
||||
if (bd->internal)
|
||||
{
|
||||
o = edje_object_add(e);
|
||||
if (!bd->internal_icon)
|
||||
e_util_edje_icon_set(o, "enlightenment/e");
|
||||
else
|
||||
{
|
||||
if (!bd->internal_icon_key)
|
||||
{
|
||||
char *ext;
|
||||
ext = strrchr(bd->internal_icon, '.');
|
||||
if ((ext) && ((!strcmp(ext, ".edj"))))
|
||||
{
|
||||
if (!edje_object_file_set(o, bd->internal_icon, "icon"))
|
||||
e_util_edje_icon_set(o, "enlightenment/e");
|
||||
}
|
||||
else if (ext)
|
||||
{
|
||||
evas_object_del(o);
|
||||
o = e_icon_add(e);
|
||||
e_icon_file_set(o, bd->internal_icon);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!e_util_edje_icon_set(o, bd->internal_icon))
|
||||
e_util_edje_icon_set(o, "enlightenment/e");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
edje_object_file_set(o, bd->internal_icon,
|
||||
bd->internal_icon_key);
|
||||
}
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
if (!o && bd->desktop)
|
||||
o = e_util_desktop_icon_add(bd->desktop, 128, e);
|
||||
|
||||
if (!o && bd->client.netwm.icons)
|
||||
|
@ -152,7 +189,7 @@ _init(void)
|
|||
p->fetch = &_fetch;
|
||||
p->cleanup = &_cleanup;
|
||||
p->icon_get = &_item_icon_get;
|
||||
evry_plugin_register(p);
|
||||
evry_plugin_register(p, 2);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ _init(void)
|
|||
p->cleanup = &_cleanup;
|
||||
p->icon_get = &_item_icon_get;
|
||||
|
||||
evry_plugin_register(p);
|
||||
evry_plugin_register(p, 1);
|
||||
|
||||
inst = E_NEW(Inst, 1);
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ _init(void)
|
|||
p1->fetch = &_fetch;
|
||||
p1->action = &_action;
|
||||
p1->cleanup = &_cleanup;
|
||||
evry_plugin_register(p1);
|
||||
evry_plugin_register(p1, 0);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ _init(void)
|
|||
p->cleanup = &_cleanup;
|
||||
p->icon_get = &_item_icon_get;
|
||||
|
||||
evry_plugin_register(p);
|
||||
evry_plugin_register(p, 10);
|
||||
|
||||
act = E_NEW(Evry_Action, 1);
|
||||
act->name = "Show Dialog";
|
||||
|
|
|
@ -384,7 +384,7 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
|||
static int
|
||||
_open_folder_check(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
||||
{
|
||||
return (it->uri && e_action_find("fileman"));
|
||||
return (it->browseable && e_action_find("fileman"));
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -427,7 +427,7 @@ _init(void)
|
|||
p1->fetch = &_fetch;
|
||||
p1->cleanup = &_cleanup;
|
||||
p1->icon_get = &_item_icon_get;
|
||||
evry_plugin_register(p1);
|
||||
evry_plugin_register(p1, 3);
|
||||
|
||||
p2 = E_NEW(Evry_Plugin, 1);
|
||||
p2->name = "Files";
|
||||
|
@ -440,7 +440,7 @@ _init(void)
|
|||
p2->fetch = &_fetch;
|
||||
p2->cleanup = &_cleanup;
|
||||
p2->icon_get = &_item_icon_get;
|
||||
evry_plugin_register(p2);
|
||||
evry_plugin_register(p2, 1);
|
||||
|
||||
act = E_NEW(Evry_Action, 1);
|
||||
act->name = "Open Folder (EFM)";
|
||||
|
@ -448,7 +448,7 @@ _init(void)
|
|||
act->type_in1 = "FILE";
|
||||
act->action = &_open_folder_action;
|
||||
act->check_item = &_open_folder_check;
|
||||
act->icon = "folder";
|
||||
act->icon = "folder-open";
|
||||
evry_action_register(act);
|
||||
|
||||
return EINA_TRUE;
|
||||
|
|
|
@ -18,7 +18,7 @@ struct _Inst
|
|||
|
||||
static E_DBus_Connection *conn = NULL;
|
||||
static Eina_List *plugins = NULL;
|
||||
|
||||
static int _prio = 5;
|
||||
|
||||
static int
|
||||
_begin(Evry_Plugin *p, const Evry_Item *it)
|
||||
|
@ -376,7 +376,7 @@ _plugin_new(const char *name, int type, char *service, int max_hits, int begin)
|
|||
inst->max_hits = max_hits;
|
||||
inst->active = 0;
|
||||
p->private = inst;
|
||||
evry_plugin_register(p);
|
||||
evry_plugin_register(p, _prio++);
|
||||
plugins = eina_list_append(plugins, p);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue