forked from enlightenment/enlightenment
'everything' module:
- use const for items passed to plugin functions - fixed possible segv in dirbrowse plugin - added tracker search for folders - restrict tracker search results to supported mimetypes when using 'open file' action SVN revision: 41702
This commit is contained in:
parent
5e3f6b5179
commit
363bd7a050
|
@ -110,7 +110,10 @@ struct _Evry_Plugin
|
||||||
Eina_Bool browseable;
|
Eina_Bool browseable;
|
||||||
|
|
||||||
/* run when plugin is activated. */
|
/* run when plugin is activated. */
|
||||||
int (*begin) (Evry_Plugin *p, Evry_Item *item);
|
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 */
|
/* get candidates matching string, fills 'candidates' list */
|
||||||
int (*fetch) (Evry_Plugin *p, const char *input);
|
int (*fetch) (Evry_Plugin *p, const char *input);
|
||||||
|
@ -118,12 +121,12 @@ struct _Evry_Plugin
|
||||||
/* run before new query and when hiding 'everything' */
|
/* run before new query and when hiding 'everything' */
|
||||||
void (*cleanup) (Evry_Plugin *p);
|
void (*cleanup) (Evry_Plugin *p);
|
||||||
|
|
||||||
Evas_Object *(*icon_get) (Evry_Plugin *p, Evry_Item *it, Evas *e);
|
Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e);
|
||||||
/* provide more information for a candidate */
|
/* provide more information for a candidate */
|
||||||
/* int (*candidate_info) (Evas *evas, Evry_Item *item); */
|
/* int (*candidate_info) (Evas *evas, Evry_Item *item); */
|
||||||
|
|
||||||
/* optional: default action for this plugins items */
|
/* optional: default action for this plugins items */
|
||||||
int (*action) (Evry_Plugin *p, Evry_Item *item, const char *input);
|
int (*action) (Evry_Plugin *p, const Evry_Item *item, const char *input);
|
||||||
Evry_Action *act;
|
Evry_Action *act;
|
||||||
|
|
||||||
/* optional: create list of items when shown (e.g. for sorting) */
|
/* optional: create list of items when shown (e.g. for sorting) */
|
||||||
|
@ -150,9 +153,9 @@ struct _Evry_Action
|
||||||
const char *type_in2;
|
const char *type_in2;
|
||||||
const char *type_out;
|
const char *type_out;
|
||||||
|
|
||||||
int (*action) (Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input);
|
int (*action) (Evry_Action *act, const Evry_Item *it1, const Evry_Item *it2, const char *input);
|
||||||
|
|
||||||
int (*check_item) (Evry_Action *act, Evry_Item *it);
|
int (*check_item) (Evry_Action *act, const Evry_Item *it);
|
||||||
|
|
||||||
Evas_Object *(*icon_get) (Evry_Action *act, Evas *e);
|
Evas_Object *(*icon_get) (Evry_Action *act, Evas *e);
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ static int _evry_cb_key_down(void *data, int type, void *event);
|
||||||
* static void _evry_cb_item_mouse_in(void *data, Evas *evas, Evas_Object *obj, void *event_info);
|
* static void _evry_cb_item_mouse_in(void *data, Evas *evas, Evas_Object *obj, void *event_info);
|
||||||
* static void _evry_cb_item_mouse_out(void *data, Evas *evas, Evas_Object *obj, void *event_info); */
|
* static void _evry_cb_item_mouse_out(void *data, Evas *evas, Evas_Object *obj, void *event_info); */
|
||||||
|
|
||||||
static void _evry_matches_update(Evry_Selector *sel, Evry_Plugin *plugin);
|
static void _evry_matches_update(Evry_Selector *sel);
|
||||||
static void _evry_plugin_action(Evry_Selector *sel, int finished);
|
static void _evry_plugin_action(Evry_Selector *sel, int finished);
|
||||||
static void _evry_backspace(Evry_State *s);
|
static void _evry_backspace(Evry_State *s);
|
||||||
static void _evry_update(Evry_State *s);
|
static void _evry_update(Evry_State *s);
|
||||||
|
@ -157,18 +157,18 @@ static int _evry_list_scroll_timer(void *data);
|
||||||
static int _evry_list_item_idler(void *data);
|
static int _evry_list_item_idler(void *data);
|
||||||
|
|
||||||
static int _evry_plug_actions_init(void);
|
static int _evry_plug_actions_init(void);
|
||||||
static int _evry_plug_actions_begin(Evry_Plugin *p, Evry_Item *it);
|
static int _evry_plug_actions_begin(Evry_Plugin *p, const Evry_Item *it);
|
||||||
static int _evry_plug_actions_fetch(Evry_Plugin *p, const char *input);
|
static int _evry_plug_actions_fetch(Evry_Plugin *p, const char *input);
|
||||||
static void _evry_plug_actions_cleanup(Evry_Plugin *p);
|
static void _evry_plug_actions_cleanup(Evry_Plugin *p);
|
||||||
static Evas_Object *_evry_plug_actions_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
|
static Evas_Object *_evry_plug_actions_item_icon_get(Evry_Plugin *p, const Evry_Item *it, Evas *e);
|
||||||
|
|
||||||
static Evry_Plugin *_evry_plug_aggregator_new(void);
|
static Evry_Plugin *_evry_plug_aggregator_new(void);
|
||||||
static void _evry_plug_aggregator_free(Evry_Plugin *p);
|
static void _evry_plug_aggregator_free(Evry_Plugin *p);
|
||||||
static int _evry_plug_aggregator_begin(Evry_Plugin *p, Evry_Item *it);
|
static int _evry_plug_aggregator_begin(Evry_Plugin *p, const Evry_Item *it);
|
||||||
static int _evry_plug_aggregator_fetch(Evry_Plugin *p, const char *input);
|
static int _evry_plug_aggregator_fetch(Evry_Plugin *p, const char *input);
|
||||||
static int _evry_plug_aggregator_action(Evry_Plugin *p, Evry_Item *item, const char *input);
|
static int _evry_plug_aggregator_action(Evry_Plugin *p, const Evry_Item *item, const char *input);
|
||||||
static void _evry_plug_aggregator_cleanup(Evry_Plugin *p);
|
static void _evry_plug_aggregator_cleanup(Evry_Plugin *p);
|
||||||
static Evas_Object *_evry_plug_aggregator_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
|
static Evas_Object *_evry_plug_aggregator_item_icon_get(Evry_Plugin *p, const Evry_Item *it, Evas *e);
|
||||||
/* static int _evry_cb_plugin_sort_by_trigger(const void *data1, const void *data2); */
|
/* static int _evry_cb_plugin_sort_by_trigger(const void *data1, const void *data2); */
|
||||||
|
|
||||||
/* local subsystem globals */
|
/* local subsystem globals */
|
||||||
|
@ -592,7 +592,7 @@ _evry_selector_free(Evry_Selector *sel)
|
||||||
|
|
||||||
_evry_plug_aggregator_free(sel->aggregator);
|
_evry_plug_aggregator_free(sel->aggregator);
|
||||||
|
|
||||||
eina_list_free(sel->plugins);
|
if (sel->plugins) eina_list_free(sel->plugins);
|
||||||
E_FREE(sel);
|
E_FREE(sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,7 +613,7 @@ _evry_selector_activate(Evry_Selector *sel)
|
||||||
if (s && s->plugin && !s->plugin->async_query)
|
if (s && s->plugin && !s->plugin->async_query)
|
||||||
{
|
{
|
||||||
_evry_list_clear_list(s);
|
_evry_list_clear_list(s);
|
||||||
_evry_matches_update(selector, s->plugin);
|
_evry_matches_update(selector);
|
||||||
_evry_selector_update(selector);
|
_evry_selector_update(selector);
|
||||||
}
|
}
|
||||||
ecore_timer_del(update_timer);
|
ecore_timer_del(update_timer);
|
||||||
|
@ -697,7 +697,10 @@ _evry_selector_update(Evry_Selector *sel)
|
||||||
_evry_select_plugin(s, s->cur_plugins->data);
|
_evry_select_plugin(s, s->cur_plugins->data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
s->plugin = NULL;
|
{
|
||||||
|
s->plugin = NULL;
|
||||||
|
s->sel_item = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
it = s->sel_item;
|
it = s->sel_item;
|
||||||
|
|
||||||
|
@ -775,7 +778,7 @@ _evry_selector_subjects_get(void)
|
||||||
|
|
||||||
_evry_state_new(sel, plugins);
|
_evry_state_new(sel, plugins);
|
||||||
|
|
||||||
_evry_matches_update(sel, NULL);
|
_evry_matches_update(sel);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -815,7 +818,7 @@ _evry_selector_actions_get(Evry_Item *it)
|
||||||
|
|
||||||
_evry_state_new(sel, plugins);
|
_evry_state_new(sel, plugins);
|
||||||
|
|
||||||
_evry_matches_update(sel, NULL);
|
_evry_matches_update(sel);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -831,8 +834,9 @@ _evry_selector_objects_get(const char *type)
|
||||||
while (sel->state)
|
while (sel->state)
|
||||||
_evry_state_pop(sel);
|
_evry_state_pop(sel);
|
||||||
|
|
||||||
it = NULL; // TODO let 'object' plugins take subject and action
|
// TODO let 'object' plugins take subject and action
|
||||||
// into account. selectors[0]->state->sel_item;
|
// into account. selectors[0]->state->sel_item;
|
||||||
|
it = selectors[0]->state->sel_item;
|
||||||
|
|
||||||
EINA_LIST_FOREACH(sel->plugins, l, p)
|
EINA_LIST_FOREACH(sel->plugins, l, p)
|
||||||
{
|
{
|
||||||
|
@ -852,7 +856,7 @@ _evry_selector_objects_get(const char *type)
|
||||||
|
|
||||||
_evry_state_new(sel, plugins);
|
_evry_state_new(sel, plugins);
|
||||||
|
|
||||||
_evry_matches_update(sel, NULL);
|
_evry_matches_update(sel);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -910,20 +914,17 @@ _evry_browse_item(Evry_Selector *sel)
|
||||||
|
|
||||||
EINA_LIST_FOREACH(sel->plugins, l, p)
|
EINA_LIST_FOREACH(sel->plugins, l, p)
|
||||||
{
|
{
|
||||||
|
if (!p->browse) continue;
|
||||||
if (!strstr(p->type_in, it->plugin->type_out)) continue;
|
if (!strstr(p->type_in, it->plugin->type_out)) continue;
|
||||||
|
|
||||||
if (p->begin)
|
if (p->browse(p, it))
|
||||||
{
|
|
||||||
if (p->begin(p, it))
|
|
||||||
plugins = eina_list_append(plugins, p);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
plugins = eina_list_append(plugins, p);
|
plugins = eina_list_append(plugins, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugins)
|
if (plugins)
|
||||||
{
|
{
|
||||||
_evry_state_new(sel, plugins);
|
_evry_state_new(sel, plugins);
|
||||||
_evry_matches_update(sel, NULL);
|
_evry_matches_update(sel);
|
||||||
_evry_selector_update(sel);
|
_evry_selector_update(sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -973,7 +974,7 @@ _evry_selectors_switch(void)
|
||||||
if (!s->plugin->async_query)
|
if (!s->plugin->async_query)
|
||||||
{
|
{
|
||||||
_evry_list_clear_list(s);
|
_evry_list_clear_list(s);
|
||||||
_evry_matches_update(selector, s->plugin);
|
_evry_matches_update(selector);
|
||||||
_evry_selector_update(selector);
|
_evry_selector_update(selector);
|
||||||
}
|
}
|
||||||
ecore_timer_del(update_timer);
|
ecore_timer_del(update_timer);
|
||||||
|
@ -1071,6 +1072,7 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||||
((strlen(s->input) < (INPUTLEN - strlen(ev->compose)))))
|
((strlen(s->input) < (INPUTLEN - strlen(ev->compose)))))
|
||||||
{
|
{
|
||||||
strcat(s->input, ev->compose);
|
strcat(s->input, ev->compose);
|
||||||
|
/* _evry_update_timer(s); */
|
||||||
_evry_update(s);
|
_evry_update(s);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1089,6 +1091,7 @@ _evry_backspace(Evry_State *s)
|
||||||
{
|
{
|
||||||
s->input[pos] = 0;
|
s->input[pos] = 0;
|
||||||
_evry_update(s);
|
_evry_update(s);
|
||||||
|
/* _evry_update_timer(s); */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1121,7 +1124,7 @@ _evry_update_timer(void *data)
|
||||||
Evry_State *s = data;
|
Evry_State *s = data;
|
||||||
/* XXX pass selector as data? */
|
/* XXX pass selector as data? */
|
||||||
_evry_list_clear_list(s);
|
_evry_list_clear_list(s);
|
||||||
_evry_matches_update(selector, s->plugin);
|
_evry_matches_update(selector);
|
||||||
_evry_selector_update(selector);
|
_evry_selector_update(selector);
|
||||||
_evry_list_update(selector->state);
|
_evry_list_update(selector->state);
|
||||||
update_timer = NULL;
|
update_timer = NULL;
|
||||||
|
@ -1156,7 +1159,7 @@ _evry_plugin_action(Evry_Selector *sel, int finished)
|
||||||
/* XXX what if an async plugin is selected */
|
/* XXX what if an async plugin is selected */
|
||||||
if (!selector->state->plugin->async_query)
|
if (!selector->state->plugin->async_query)
|
||||||
{
|
{
|
||||||
_evry_matches_update(selector, selector->state->plugin);
|
_evry_matches_update(selector);
|
||||||
_evry_selector_update(selector);
|
_evry_selector_update(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1323,14 +1326,14 @@ _evry_list_item_idler(void *data)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_evry_matches_update(Evry_Selector *sel, Evry_Plugin *plugin)
|
_evry_matches_update(Evry_Selector *sel)
|
||||||
{
|
{
|
||||||
Evry_State *s = sel->state;
|
Evry_State *s = sel->state;
|
||||||
Evry_Plugin *p;
|
Evry_Plugin *p;
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
Eina_Bool has_items = EINA_FALSE;
|
Eina_Bool has_items = EINA_FALSE;
|
||||||
|
|
||||||
eina_list_free(s->cur_plugins);
|
if (s->cur_plugins) eina_list_free(s->cur_plugins);
|
||||||
s->cur_plugins = NULL;
|
s->cur_plugins = NULL;
|
||||||
s->sel_item = NULL;
|
s->sel_item = NULL;
|
||||||
|
|
||||||
|
@ -1850,7 +1853,7 @@ _evry_plug_actions_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_evry_plug_actions_begin(Evry_Plugin *p, Evry_Item *it)
|
_evry_plug_actions_begin(Evry_Plugin *p, const Evry_Item *it)
|
||||||
{
|
{
|
||||||
Evry_Action *act;
|
Evry_Action *act;
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
|
@ -1934,12 +1937,12 @@ _evry_plug_actions_cleanup(Evry_Plugin *p)
|
||||||
evry_item_free(it);
|
evry_item_free(it);
|
||||||
p->items = NULL;
|
p->items = NULL;
|
||||||
|
|
||||||
eina_list_free(sel->actions);
|
if (sel->actions) eina_list_free(sel->actions);
|
||||||
sel->actions = NULL;
|
sel->actions = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_evry_plug_actions_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
|
_evry_plug_actions_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
||||||
{
|
{
|
||||||
Evas_Object *o;
|
Evas_Object *o;
|
||||||
Evry_Action *act = it->data[0];
|
Evry_Action *act = it->data[0];
|
||||||
|
@ -1998,10 +2001,9 @@ _evry_plug_aggregator_fetch(Evry_Plugin *p, const char *input __UNUSED__)
|
||||||
int cnt;
|
int cnt;
|
||||||
|
|
||||||
if (p->items)
|
if (p->items)
|
||||||
{
|
eina_list_free(p->items);
|
||||||
eina_list_free(p->items);
|
p->items = NULL;
|
||||||
p->items = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
EINA_LIST_FOREACH(s->cur_plugins, l, plugin)
|
EINA_LIST_FOREACH(s->cur_plugins, l, plugin)
|
||||||
{
|
{
|
||||||
|
@ -2016,7 +2018,7 @@ _evry_plug_aggregator_fetch(Evry_Plugin *p, const char *input __UNUSED__)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_evry_plug_aggregator_action(Evry_Plugin *p, Evry_Item *it, const char *input)
|
_evry_plug_aggregator_action(Evry_Plugin *p, const Evry_Item *it, const char *input)
|
||||||
{
|
{
|
||||||
if (it->plugin && it->plugin->action)
|
if (it->plugin && it->plugin->action)
|
||||||
return it->plugin->action(it->plugin, it, input);
|
return it->plugin->action(it->plugin, it, input);
|
||||||
|
@ -2027,12 +2029,12 @@ _evry_plug_aggregator_action(Evry_Plugin *p, Evry_Item *it, const char *input)
|
||||||
static void
|
static void
|
||||||
_evry_plug_aggregator_cleanup(Evry_Plugin *p)
|
_evry_plug_aggregator_cleanup(Evry_Plugin *p)
|
||||||
{
|
{
|
||||||
eina_list_free(p->items);
|
if (p->items) eina_list_free(p->items);
|
||||||
p->items = NULL;
|
p->items = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_evry_plug_aggregator_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e)
|
_evry_plug_aggregator_item_icon_get(Evry_Plugin *p, const Evry_Item *it, Evas *e)
|
||||||
{
|
{
|
||||||
if (it->plugin && it->plugin->icon_get)
|
if (it->plugin && it->plugin->icon_get)
|
||||||
return it->plugin->icon_get(it->plugin, it, e);
|
return it->plugin->icon_get(it->plugin, it, e);
|
||||||
|
@ -2061,6 +2063,7 @@ evry_plugin_async_update(Evry_Plugin *p, int action)
|
||||||
|
|
||||||
if (p == s->plugin)
|
if (p == s->plugin)
|
||||||
{
|
{
|
||||||
|
s->plugin = NULL;
|
||||||
/* _evry_list_clear_list(s); */
|
/* _evry_list_clear_list(s); */
|
||||||
_evry_selector_update(selector);
|
_evry_selector_update(selector);
|
||||||
if (list->visible)
|
if (list->visible)
|
||||||
|
|
|
@ -8,7 +8,7 @@ struct _Inst
|
||||||
Eina_Hash *added;
|
Eina_Hash *added;
|
||||||
Eina_List *apps_mime;
|
Eina_List *apps_mime;
|
||||||
Eina_List *apps_all;
|
Eina_List *apps_all;
|
||||||
Evry_Item *candidate;
|
const Evry_Item *candidate;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Evry_Plugin *p1;
|
static Evry_Plugin *p1;
|
||||||
|
@ -21,7 +21,7 @@ static Eina_List *exe_path = NULL;
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_begin(Evry_Plugin *p, Evry_Item *it)
|
_begin(Evry_Plugin *p, const Evry_Item *it)
|
||||||
{
|
{
|
||||||
const char *mime;
|
const char *mime;
|
||||||
Inst *inst = NULL;
|
Inst *inst = NULL;
|
||||||
|
@ -367,7 +367,7 @@ _fetch(Evry_Plugin *p, const char *input)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
|
_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
||||||
{
|
{
|
||||||
Evas_Object *o = NULL;
|
Evas_Object *o = NULL;
|
||||||
Evry_App *app = it->data[0];
|
Evry_App *app = it->data[0];
|
||||||
|
@ -385,7 +385,7 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_exec_app_check_item(Evry_Action *act __UNUSED__, Evry_Item *it)
|
_exec_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
||||||
{
|
{
|
||||||
Evry_App *app = it->data[0];
|
Evry_App *app = it->data[0];
|
||||||
if (app->desktop)
|
if (app->desktop)
|
||||||
|
@ -398,7 +398,7 @@ _exec_app_check_item(Evry_Action *act __UNUSED__, Evry_Item *it)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_app_action(Evry_Item *it_app, Evry_Item *it_file)
|
_app_action(const Evry_Item *it_app, const Evry_Item *it_file)
|
||||||
{
|
{
|
||||||
E_Zone *zone;
|
E_Zone *zone;
|
||||||
Evry_App *app = NULL;
|
Evry_App *app = NULL;
|
||||||
|
@ -447,13 +447,13 @@ _app_action(Evry_Item *it_app, Evry_Item *it_file)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_exec_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input)
|
_exec_app_action(Evry_Action *act, const Evry_Item *it1, const Evry_Item *it2, const char *input)
|
||||||
{
|
{
|
||||||
return _app_action(it1, it2);
|
return _app_action(it1, it2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_open_with_action(Evry_Plugin *p, Evry_Item *it, const char *input __UNUSED__)
|
_open_with_action(Evry_Plugin *p, const Evry_Item *it, const char *input __UNUSED__)
|
||||||
{
|
{
|
||||||
Inst *inst = p->private;
|
Inst *inst = p->private;
|
||||||
if (inst->candidate)
|
if (inst->candidate)
|
||||||
|
@ -461,7 +461,7 @@ _open_with_action(Evry_Plugin *p, Evry_Item *it, const char *input __UNUSED__)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_edit_app_check_item(Evry_Action *act __UNUSED__, Evry_Item *it)
|
_edit_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
||||||
{
|
{
|
||||||
Evry_App *app = it->data[0];
|
Evry_App *app = it->data[0];
|
||||||
if (app->desktop)
|
if (app->desktop)
|
||||||
|
@ -472,7 +472,7 @@ _edit_app_check_item(Evry_Action *act __UNUSED__, Evry_Item *it)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_edit_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input)
|
_edit_app_action(Evry_Action *act, const Evry_Item *it1, const Evry_Item *it2, const char *input)
|
||||||
{
|
{
|
||||||
Evry_App *app;
|
Evry_App *app;
|
||||||
Efreet_Desktop *desktop;
|
Efreet_Desktop *desktop;
|
||||||
|
@ -499,7 +499,7 @@ _edit_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *i
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_new_app_check_item(Evry_Action *act __UNUSED__, Evry_Item *it)
|
_new_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
||||||
{
|
{
|
||||||
Evry_App *app = it->data[0];
|
Evry_App *app = it->data[0];
|
||||||
if (app->desktop)
|
if (app->desktop)
|
||||||
|
@ -513,7 +513,7 @@ _new_app_check_item(Evry_Action *act __UNUSED__, Evry_Item *it)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_new_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input)
|
_new_app_action(Evry_Action *act, const Evry_Item *it1, const Evry_Item *it2, const char *input)
|
||||||
{
|
{
|
||||||
Evry_App *app;
|
Evry_App *app;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
|
@ -202,7 +202,7 @@ _cb_del(void *data, int type __UNUSED__, void *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_begin(Evry_Plugin *plugin, Evry_Item *it __UNUSED__)
|
_begin(Evry_Plugin *plugin, const Evry_Item *it __UNUSED__)
|
||||||
{
|
{
|
||||||
Plugin *p = (Plugin *)plugin;
|
Plugin *p = (Plugin *)plugin;
|
||||||
|
|
||||||
|
|
|
@ -1,46 +1,34 @@
|
||||||
#include "e.h"
|
#include "e.h"
|
||||||
#include "e_mod_main.h"
|
#include "e_mod_main.h"
|
||||||
|
|
||||||
static int _fetch(Evry_Plugin *p, const char *input);
|
|
||||||
/* static int _action(Evry_Plugin *p, Evry_Item *item, const char *input); */
|
|
||||||
static void _cleanup(Evry_Plugin *p);
|
|
||||||
static void _item_add(Evry_Plugin *p, E_Border *bd, int prio);
|
|
||||||
static int _cb_sort(const void *data1, const void *data2);
|
|
||||||
static Evas_Object *_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
|
|
||||||
|
|
||||||
static Eina_Bool _init(void);
|
|
||||||
static void _shutdown(void);
|
|
||||||
EINA_MODULE_INIT(_init);
|
|
||||||
EINA_MODULE_SHUTDOWN(_shutdown);
|
|
||||||
|
|
||||||
static Evry_Plugin *p;
|
static Evry_Plugin *p;
|
||||||
|
|
||||||
|
|
||||||
static Eina_Bool
|
|
||||||
_init(void)
|
|
||||||
{
|
|
||||||
p = E_NEW(Evry_Plugin, 1);
|
|
||||||
p->name = "Windows";
|
|
||||||
p->type = type_subject;
|
|
||||||
p->type_in = "NONE";
|
|
||||||
p->type_out = "BORDER";
|
|
||||||
p->need_query = 0;
|
|
||||||
p->fetch = &_fetch;
|
|
||||||
/* p->action = &_action; */
|
|
||||||
p->cleanup = &_cleanup;
|
|
||||||
p->icon_get = &_item_icon_get;
|
|
||||||
evry_plugin_register(p);
|
|
||||||
|
|
||||||
return EINA_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_shutdown(void)
|
_item_add(Evry_Plugin *p, E_Border *bd, int prio)
|
||||||
{
|
{
|
||||||
evry_plugin_unregister(p);
|
Evry_Item *it;
|
||||||
E_FREE(p);
|
|
||||||
|
it = evry_item_new(p, e_border_name_get(bd));
|
||||||
|
|
||||||
|
/* e_object_ref(E_OBJECT(bd)); */
|
||||||
|
it->data[0] = bd;
|
||||||
|
it->priority = prio;
|
||||||
|
|
||||||
|
p->items = eina_list_append(p->items, it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO sort by focus history and name? */
|
||||||
|
static int
|
||||||
|
_cb_sort(const void *data1, const void *data2)
|
||||||
|
{
|
||||||
|
const Evry_Item *it1, *it2;
|
||||||
|
|
||||||
|
it1 = data1;
|
||||||
|
it2 = data2;
|
||||||
|
|
||||||
|
return (it1->priority - it2->priority);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cleanup(Evry_Plugin *p)
|
_cleanup(Evry_Plugin *p)
|
||||||
|
@ -118,7 +106,7 @@ _fetch(Evry_Plugin *p, const char *input)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
|
_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
||||||
{
|
{
|
||||||
Evas_Object *o = NULL;
|
Evas_Object *o = NULL;
|
||||||
E_Border *bd = it->data[0];
|
E_Border *bd = it->data[0];
|
||||||
|
@ -155,29 +143,30 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_init(void)
|
||||||
|
{
|
||||||
|
p = E_NEW(Evry_Plugin, 1);
|
||||||
|
p->name = "Windows";
|
||||||
|
p->type = type_subject;
|
||||||
|
p->type_in = "NONE";
|
||||||
|
p->type_out = "BORDER";
|
||||||
|
p->need_query = 0;
|
||||||
|
p->fetch = &_fetch;
|
||||||
|
/* p->action = &_action; */
|
||||||
|
p->cleanup = &_cleanup;
|
||||||
|
p->icon_get = &_item_icon_get;
|
||||||
|
evry_plugin_register(p);
|
||||||
|
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_item_add(Evry_Plugin *p, E_Border *bd, int prio)
|
_shutdown(void)
|
||||||
{
|
{
|
||||||
Evry_Item *it;
|
evry_plugin_unregister(p);
|
||||||
|
E_FREE(p);
|
||||||
it = evry_item_new(p, e_border_name_get(bd));
|
|
||||||
|
|
||||||
/* e_object_ref(E_OBJECT(bd)); */
|
|
||||||
it->data[0] = bd;
|
|
||||||
it->priority = prio;
|
|
||||||
|
|
||||||
p->items = eina_list_append(p->items, it);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO sort by focus history and name? */
|
|
||||||
static int
|
|
||||||
_cb_sort(const void *data1, const void *data2)
|
|
||||||
{
|
|
||||||
const Evry_Item *it1, *it2;
|
|
||||||
|
|
||||||
it1 = data1;
|
|
||||||
it2 = data2;
|
|
||||||
|
|
||||||
return (it1->priority - it2->priority);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EINA_MODULE_INIT(_init);
|
||||||
|
EINA_MODULE_SHUTDOWN(_shutdown);
|
||||||
|
|
|
@ -62,7 +62,7 @@ _act_cb_border_unminimize(E_Border *bd)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_begin(Evry_Plugin *p __UNUSED__, Evry_Item *item)
|
_begin(Evry_Plugin *p __UNUSED__, const Evry_Item *item)
|
||||||
{
|
{
|
||||||
E_Border *bd;
|
E_Border *bd;
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ _fetch(Evry_Plugin *p, const char *input __UNUSED__)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_action(Evry_Plugin *p __UNUSED__, Evry_Item *item, const char *input __UNUSED__)
|
_action(Evry_Plugin *p __UNUSED__, const Evry_Item *item, const char *input __UNUSED__)
|
||||||
{
|
{
|
||||||
void (*border_action) (E_Border *bd);
|
void (*border_action) (E_Border *bd);
|
||||||
border_action = item->data[0];
|
border_action = item->data[0];
|
||||||
|
@ -175,7 +175,7 @@ _action(Evry_Plugin *p __UNUSED__, Evry_Item *item, const char *input __UNUSED__
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
|
_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
||||||
{
|
{
|
||||||
Evas_Object *o;
|
Evas_Object *o;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ static int error = 0;
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_begin(Evry_Plugin *p, Evry_Item *it __UNUSED__)
|
_begin(Evry_Plugin *p, const Evry_Item *it __UNUSED__)
|
||||||
{
|
{
|
||||||
|
|
||||||
data_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _cb_data, p);
|
data_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _cb_data, p);
|
||||||
|
@ -54,7 +54,7 @@ _cleanup(Evry_Plugin *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_action(Evry_Plugin *p, Evry_Item *it, const char *input __UNUSED__)
|
_action(Evry_Plugin *p, const Evry_Item *it, const char *input __UNUSED__)
|
||||||
{
|
{
|
||||||
if (p->items)
|
if (p->items)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,14 +5,14 @@ static Evry_Action *act;
|
||||||
static Ecore_X_Window clipboard_win = 0;
|
static Ecore_X_Window clipboard_win = 0;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_action(Evry_Action *act __UNUSED__, Evry_Item *it, Evry_Item *it2 __UNUSED__, const char *input __UNUSED__)
|
_action(Evry_Action *act __UNUSED__, const Evry_Item *it, const Evry_Item *it2 __UNUSED__, const char *input __UNUSED__)
|
||||||
{
|
{
|
||||||
ecore_x_selection_primary_set(clipboard_win, it->label, strlen(it->label));
|
ecore_x_selection_primary_set(clipboard_win, it->label, strlen(it->label));
|
||||||
ecore_x_selection_clipboard_set(clipboard_win, it->label, strlen(it->label));
|
ecore_x_selection_clipboard_set(clipboard_win, it->label, strlen(it->label));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_check_item(Evry_Action *act __UNUSED__, Evry_Item *it)
|
_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
||||||
{
|
{
|
||||||
return (it && it->label && (strlen(it->label) > 0));
|
return (it && it->label && (strlen(it->label) > 0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ _fetch(Evry_Plugin *p, const char *input)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
|
_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
||||||
{
|
{
|
||||||
Evas_Object *o = NULL;
|
Evas_Object *o = NULL;
|
||||||
E_Configure_It *eci = it->data[0];
|
E_Configure_It *eci = it->data[0];
|
||||||
|
@ -102,7 +102,7 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_action(Evry_Action *act, Evry_Item *it, Evry_Item *it2 __UNUSED__, const char *input __UNUSED__)
|
_action(Evry_Action *act, const Evry_Item *it, const Evry_Item *it2 __UNUSED__, const char *input __UNUSED__)
|
||||||
{
|
{
|
||||||
E_Configure_It *eci, *eci2;
|
E_Configure_It *eci, *eci2;
|
||||||
E_Container *con;
|
E_Container *con;
|
||||||
|
|
|
@ -15,13 +15,13 @@ struct _State
|
||||||
Eina_Bool command;
|
Eina_Bool command;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Evry_Plugin *p;
|
static Evry_Plugin *p1;
|
||||||
static Evry_Plugin *p2;
|
static Evry_Plugin *p2;
|
||||||
static Ecore_Idler *idler = NULL;
|
static Ecore_Idler *idler = NULL;
|
||||||
|
|
||||||
|
|
||||||
static Evry_Item *
|
static Evry_Item *
|
||||||
_item_add(const char *directory, const char *file)
|
_item_add(Evry_Plugin *p, const char *directory, const char *file)
|
||||||
{
|
{
|
||||||
Evry_Item *it = NULL;
|
Evry_Item *it = NULL;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
@ -132,34 +132,16 @@ _dirbrowse_idler(void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_begin(Evry_Plugin *p, Evry_Item *it)
|
_begin(Evry_Plugin *p, const Evry_Item *it)
|
||||||
{
|
{
|
||||||
State *s;
|
State *s;
|
||||||
char *file;
|
char *file;
|
||||||
Eina_List *files;
|
Eina_List *files;
|
||||||
Eina_List *stack = p->private;
|
Eina_List *stack = p->private;
|
||||||
|
|
||||||
if (stack)
|
s = E_NEW(State, 1);
|
||||||
{
|
s->directory = eina_stringshare_add(e_user_homedir_get());
|
||||||
s = stack->data;
|
p->items = NULL;
|
||||||
/* if (s->command) evry_clear_input(); */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (it)
|
|
||||||
{
|
|
||||||
if (!it->uri || !ecore_file_is_dir(it->uri))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
s = E_NEW(State, 1);
|
|
||||||
s->directory = eina_stringshare_add(it->uri);
|
|
||||||
p->items = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
s = E_NEW(State, 1);
|
|
||||||
s->directory = eina_stringshare_add(e_user_homedir_get());
|
|
||||||
p->items = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
files = ecore_file_ls(s->directory);
|
files = ecore_file_ls(s->directory);
|
||||||
|
|
||||||
|
@ -173,7 +155,7 @@ _begin(Evry_Plugin *p, Evry_Item *it)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
it = _item_add(s->directory, file);
|
it = _item_add(p, s->directory, file);
|
||||||
|
|
||||||
if (it)
|
if (it)
|
||||||
s->items = eina_list_append(s->items, it);
|
s->items = eina_list_append(s->items, it);
|
||||||
|
@ -192,6 +174,52 @@ _begin(Evry_Plugin *p, Evry_Item *it)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_browse(Evry_Plugin *p, const Evry_Item *it_file)
|
||||||
|
{
|
||||||
|
State *s;
|
||||||
|
char *file;
|
||||||
|
Eina_List *files;
|
||||||
|
Evry_Item *it;
|
||||||
|
Eina_List *stack = p->private;
|
||||||
|
|
||||||
|
if (!it_file || !it_file->uri || !ecore_file_is_dir(it_file->uri))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
s = E_NEW(State, 1);
|
||||||
|
s->directory = eina_stringshare_add(it_file->uri);
|
||||||
|
/* previous states items are saved in s->items !*/
|
||||||
|
p->items = NULL;
|
||||||
|
|
||||||
|
files = ecore_file_ls(s->directory);
|
||||||
|
|
||||||
|
EINA_LIST_FREE(files, file)
|
||||||
|
{
|
||||||
|
it = NULL;
|
||||||
|
|
||||||
|
if (file[0] == '.')
|
||||||
|
{
|
||||||
|
free(file);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
it = _item_add(p, s->directory, file);
|
||||||
|
|
||||||
|
if (it)
|
||||||
|
s->items = eina_list_append(s->items, it);
|
||||||
|
|
||||||
|
free(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (idler)
|
||||||
|
ecore_idler_del(idler);
|
||||||
|
|
||||||
|
idler = ecore_idler_add(_dirbrowse_idler, p);
|
||||||
|
|
||||||
|
stack = eina_list_prepend(stack, s);
|
||||||
|
p->private = stack;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cleanup(Evry_Plugin *p)
|
_cleanup(Evry_Plugin *p)
|
||||||
{
|
{
|
||||||
|
@ -220,15 +248,15 @@ _cleanup(Evry_Plugin *p)
|
||||||
|
|
||||||
E_FREE(s);
|
E_FREE(s);
|
||||||
|
|
||||||
eina_list_free(p->items);
|
if (p->items) eina_list_free(p->items);
|
||||||
p->items = NULL;
|
p->items = NULL;
|
||||||
|
|
||||||
stack = eina_list_remove_list(stack, stack);
|
stack = eina_list_remove_list(stack, stack);
|
||||||
p->private = stack;
|
p->private = stack;
|
||||||
|
|
||||||
if (stack)
|
if (stack)
|
||||||
{
|
{
|
||||||
s = stack->data;
|
s = stack->data;
|
||||||
|
|
||||||
p->items = s->cur;
|
p->items = s->cur;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,6 +371,7 @@ _fetch(Evry_Plugin *p, const char *input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s->cur = p->items;
|
||||||
if (p->items)
|
if (p->items)
|
||||||
{
|
{
|
||||||
p->items = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort);
|
p->items = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort);
|
||||||
|
@ -354,13 +383,13 @@ _fetch(Evry_Plugin *p, const char *input)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
|
_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
||||||
{
|
{
|
||||||
Evas_Object *o = NULL;
|
Evas_Object *o = NULL;
|
||||||
char *icon_path;
|
char *icon_path;
|
||||||
|
|
||||||
if (!it->mime)
|
if (!it->mime)
|
||||||
_item_fill(it);
|
_item_fill((Evry_Item *)it);
|
||||||
|
|
||||||
if (!it->mime) return NULL;
|
if (!it->mime) return NULL;
|
||||||
|
|
||||||
|
@ -390,17 +419,18 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_init(void)
|
_init(void)
|
||||||
{
|
{
|
||||||
p = E_NEW(Evry_Plugin, 1);
|
p1 = E_NEW(Evry_Plugin, 1);
|
||||||
p->name = "Files";
|
p1->name = "Files";
|
||||||
p->type = type_subject;
|
p1->type = type_subject;
|
||||||
p->type_in = "NONE|FILE";
|
p1->type_in = "NONE|FILE";
|
||||||
p->type_out = "FILE";
|
p1->type_out = "FILE";
|
||||||
p->browseable = EINA_TRUE;
|
p1->browseable = EINA_TRUE;
|
||||||
p->begin = &_begin;
|
p1->begin = &_begin;
|
||||||
p->fetch = &_fetch;
|
p1->browse = &_browse;
|
||||||
p->cleanup = &_cleanup;
|
p1->fetch = &_fetch;
|
||||||
p->icon_get = &_item_icon_get;
|
p1->cleanup = &_cleanup;
|
||||||
evry_plugin_register(p);
|
p1->icon_get = &_item_icon_get;
|
||||||
|
evry_plugin_register(p1);
|
||||||
|
|
||||||
p2 = E_NEW(Evry_Plugin, 1);
|
p2 = E_NEW(Evry_Plugin, 1);
|
||||||
p2->name = "Files";
|
p2->name = "Files";
|
||||||
|
@ -409,6 +439,7 @@ _init(void)
|
||||||
p2->type_out = "FILE";
|
p2->type_out = "FILE";
|
||||||
p2->browseable = EINA_TRUE;
|
p2->browseable = EINA_TRUE;
|
||||||
p2->begin = &_begin;
|
p2->begin = &_begin;
|
||||||
|
p2->browse = &_browse;
|
||||||
p2->fetch = &_fetch;
|
p2->fetch = &_fetch;
|
||||||
p2->cleanup = &_cleanup;
|
p2->cleanup = &_cleanup;
|
||||||
p2->icon_get = &_item_icon_get;
|
p2->icon_get = &_item_icon_get;
|
||||||
|
@ -420,9 +451,9 @@ _init(void)
|
||||||
static void
|
static void
|
||||||
_shutdown(void)
|
_shutdown(void)
|
||||||
{
|
{
|
||||||
evry_plugin_unregister(p);
|
evry_plugin_unregister(p1);
|
||||||
evry_plugin_unregister(p2);
|
evry_plugin_unregister(p2);
|
||||||
E_FREE(p);
|
E_FREE(p1);
|
||||||
E_FREE(p2);
|
E_FREE(p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,19 +7,80 @@ typedef struct _Inst Inst;
|
||||||
|
|
||||||
struct _Inst
|
struct _Inst
|
||||||
{
|
{
|
||||||
E_DBus_Connection *conn;
|
int active;
|
||||||
|
char *condition;
|
||||||
|
char *service;
|
||||||
|
Eina_List *items;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Evry_Plugin *p1;
|
static E_DBus_Connection *conn = NULL;
|
||||||
static Evry_Plugin *p2;
|
|
||||||
static Inst *inst;
|
static Evry_Plugin *p1 = NULL;
|
||||||
static Eina_Bool active = EINA_FALSE;
|
static Evry_Plugin *p2 = NULL;
|
||||||
|
static Evry_Plugin *p3 = NULL;
|
||||||
|
static Evry_Plugin *p4 = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
_begin(Evry_Plugin *p, const Evry_Item *it)
|
||||||
|
{
|
||||||
|
Inst *inst = p->private;
|
||||||
|
|
||||||
|
inst->active = 0;
|
||||||
|
|
||||||
|
if (!strcmp(it->plugin->type_out, "APPLICATION"))
|
||||||
|
{
|
||||||
|
Efreet_Desktop *desktop;
|
||||||
|
Eina_List *l;
|
||||||
|
const char *mime;
|
||||||
|
Evry_App *app = it->data[0];
|
||||||
|
char mime_entry[256];
|
||||||
|
char rdf_query[32768];
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
|
inst->service = "Files";
|
||||||
|
if (inst->condition[0]) free (inst->condition);
|
||||||
|
inst->condition = "";
|
||||||
|
|
||||||
|
if (!app->desktop || !app->desktop->mime_types)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
rdf_query[0] = '\0';
|
||||||
|
strcat(rdf_query, "<rdfq:Condition><rdfq:or>");
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(app->desktop->mime_types, l, mime)
|
||||||
|
{
|
||||||
|
if (!strcmp(mime, "x-directory/normal"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
snprintf(mime_entry, 256,
|
||||||
|
"<rdfq:contains>"
|
||||||
|
"<rdfq:Property name=\"File:Mime\" />"
|
||||||
|
"<rdf:String>%s</rdf:String> "
|
||||||
|
"</rdfq:contains>",
|
||||||
|
mime);
|
||||||
|
|
||||||
|
strcat(rdf_query, mime_entry);
|
||||||
|
len += 256;
|
||||||
|
if (len > 32000) break;
|
||||||
|
}
|
||||||
|
strcat(rdf_query, "</rdfq:or></rdfq:Condition>");
|
||||||
|
|
||||||
|
inst->condition = strdup(rdf_query);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_item_add(Evry_Plugin *p, char *file, char *mime, int prio)
|
_item_add(Evry_Plugin *p, char *file, char *mime, int prio)
|
||||||
{
|
{
|
||||||
Evry_Item *it;
|
Evry_Item *it;
|
||||||
const char *filename;
|
const char *filename;
|
||||||
|
int folder = (!strcmp(mime, "Folder"));
|
||||||
|
|
||||||
|
/* folders are specifically searched by p2 and p4 ;) */
|
||||||
|
if (folder && ((p == p1) || (p == p3))) return;
|
||||||
|
|
||||||
filename = ecore_file_file_get(file);
|
filename = ecore_file_file_get(file);
|
||||||
|
|
||||||
|
@ -29,7 +90,7 @@ _item_add(Evry_Plugin *p, char *file, char *mime, int prio)
|
||||||
it->priority = prio;
|
it->priority = prio;
|
||||||
it->uri = eina_stringshare_add(file);
|
it->uri = eina_stringshare_add(file);
|
||||||
|
|
||||||
if (!strcmp(mime, "Folder"))
|
if (folder)
|
||||||
{
|
{
|
||||||
it->browseable = EINA_TRUE;
|
it->browseable = EINA_TRUE;
|
||||||
it->mime = eina_stringshare_add("x-directory/normal");
|
it->mime = eina_stringshare_add("x-directory/normal");
|
||||||
|
@ -40,15 +101,32 @@ _item_add(Evry_Plugin *p, char *file, char *mime, int prio)
|
||||||
p->items = eina_list_append(p->items, it);
|
p->items = eina_list_append(p->items, it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cleanup(Evry_Plugin *p)
|
||||||
|
{
|
||||||
|
Evry_Item *it;
|
||||||
|
Inst *inst = p->private;
|
||||||
|
|
||||||
|
EINA_LIST_FREE(p->items, it)
|
||||||
|
{
|
||||||
|
if (it->mime) eina_stringshare_del(it->mime);
|
||||||
|
if (it->uri) eina_stringshare_del(it->uri);
|
||||||
|
evry_item_free(it);
|
||||||
|
}
|
||||||
|
p->items = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error)
|
_dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error)
|
||||||
{
|
{
|
||||||
DBusMessageIter array, iter, item;
|
DBusMessageIter array, iter, item;
|
||||||
Evry_Plugin *p;
|
char *uri, *mime, *date;
|
||||||
|
Evry_Plugin *p = data;
|
||||||
|
Inst *inst = p->private;
|
||||||
|
|
||||||
if (!active) return;
|
if (inst->active) inst->active--;
|
||||||
|
if (inst->active) return;
|
||||||
p = data;
|
|
||||||
|
|
||||||
if (dbus_error_is_set(error))
|
if (dbus_error_is_set(error))
|
||||||
{
|
{
|
||||||
|
@ -56,14 +134,16 @@ _dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_CLEAR);
|
||||||
|
* _cleanup(p);
|
||||||
|
* */
|
||||||
|
|
||||||
dbus_message_iter_init(msg, &array);
|
dbus_message_iter_init(msg, &array);
|
||||||
if(dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_ARRAY)
|
if(dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_ARRAY)
|
||||||
{
|
{
|
||||||
dbus_message_iter_recurse(&array, &item);
|
dbus_message_iter_recurse(&array, &item);
|
||||||
while(dbus_message_iter_get_arg_type(&item) == DBUS_TYPE_ARRAY)
|
while(dbus_message_iter_get_arg_type(&item) == DBUS_TYPE_ARRAY)
|
||||||
{
|
{
|
||||||
char *uri, *mime;
|
|
||||||
|
|
||||||
dbus_message_iter_recurse(&item, &iter);
|
dbus_message_iter_recurse(&item, &iter);
|
||||||
|
|
||||||
if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING)
|
if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING)
|
||||||
|
@ -73,11 +153,11 @@ _dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error)
|
||||||
/* dbus_message_iter_get_basic(&iter, &service); */
|
/* dbus_message_iter_get_basic(&iter, &service); */
|
||||||
dbus_message_iter_next(&iter);
|
dbus_message_iter_next(&iter);
|
||||||
dbus_message_iter_get_basic(&iter, &mime);
|
dbus_message_iter_get_basic(&iter, &mime);
|
||||||
|
/* dbus_message_iter_next(&iter);
|
||||||
|
* dbus_message_iter_get_basic(&iter, &date); */
|
||||||
|
/* printf("date: %s\n",date); */
|
||||||
|
|
||||||
if (uri && mime)
|
if (uri && mime) _item_add(p, uri, mime, 1);
|
||||||
{
|
|
||||||
_item_add(p, uri, mime, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dbus_message_iter_next(&item);
|
dbus_message_iter_next(&item);
|
||||||
}
|
}
|
||||||
|
@ -86,62 +166,77 @@ _dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error)
|
||||||
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
|
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_cleanup(Evry_Plugin *p)
|
|
||||||
{
|
|
||||||
Evry_Item *it;
|
|
||||||
|
|
||||||
EINA_LIST_FREE(p->items, it)
|
|
||||||
{
|
|
||||||
if (it->mime) eina_stringshare_del(it->mime);
|
|
||||||
if (it->uri) eina_stringshare_del(it->uri);
|
|
||||||
evry_item_free(it);
|
|
||||||
}
|
|
||||||
p->items = NULL;
|
|
||||||
active = EINA_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_fetch(Evry_Plugin *p, const char *input)
|
_fetch(Evry_Plugin *p, const char *input)
|
||||||
{
|
{
|
||||||
|
Inst *inst = p->private;
|
||||||
DBusMessage *msg;
|
DBusMessage *msg;
|
||||||
DBusMessageIter iter;
|
DBusMessageIter iter;
|
||||||
int live_query_id = 0;
|
int live_query_id = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int max_hits = 50;
|
int max_hits = 100;
|
||||||
char *service = "Files";
|
int sort_descending = 1;
|
||||||
char *match;
|
int sort_by_service = 0;
|
||||||
|
char *search_text;
|
||||||
|
char *fields[2];
|
||||||
|
char *keywords[1];
|
||||||
|
char *sort_fields[1];
|
||||||
|
fields[0] = "File:Mime";
|
||||||
|
fields[1] = "File:Accessed";
|
||||||
|
keywords[0] = "";
|
||||||
|
sort_fields[0] = "";
|
||||||
|
|
||||||
|
char **_fields = fields;
|
||||||
|
char **_keywords = keywords;
|
||||||
|
char **_sort_fields = sort_fields;
|
||||||
|
|
||||||
_cleanup(p);
|
_cleanup(p);
|
||||||
|
|
||||||
if (!input || (strlen(input) < 3)) return 0;
|
if (!conn) return 0;
|
||||||
|
/* if (!input || (strlen(input) < 3)) return 0; */
|
||||||
|
|
||||||
active = EINA_TRUE;
|
if (input && (strlen(input) > 2))
|
||||||
|
{
|
||||||
|
search_text = malloc(sizeof(char) * strlen(input) + 3);
|
||||||
|
sprintf(search_text, "*%s*", input);
|
||||||
|
}
|
||||||
|
else if (p == p2 || p == p4)
|
||||||
|
{
|
||||||
|
search_text = "";
|
||||||
|
}
|
||||||
|
else return 0;
|
||||||
|
|
||||||
match = malloc(sizeof(char) * strlen(input) + 2);
|
inst->active++;
|
||||||
sprintf(match, "%s*", input);
|
|
||||||
|
|
||||||
msg = dbus_message_new_method_call("org.freedesktop.Tracker",
|
msg = dbus_message_new_method_call("org.freedesktop.Tracker",
|
||||||
"/org/freedesktop/Tracker/Search",
|
"/org/freedesktop/Tracker/Search",
|
||||||
"org.freedesktop.Tracker.Search",
|
"org.freedesktop.Tracker.Search",
|
||||||
"TextDetailed");
|
"Query");
|
||||||
|
dbus_message_append_args(msg,
|
||||||
|
DBUS_TYPE_INT32, &live_query_id,
|
||||||
|
DBUS_TYPE_STRING, &inst->service,
|
||||||
|
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &_fields, 1,
|
||||||
|
DBUS_TYPE_STRING, &search_text,
|
||||||
|
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &_keywords, 0,
|
||||||
|
DBUS_TYPE_STRING, &inst->condition,
|
||||||
|
DBUS_TYPE_BOOLEAN, &sort_by_service,
|
||||||
|
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &_sort_fields, 0,
|
||||||
|
DBUS_TYPE_BOOLEAN, &sort_descending,
|
||||||
|
DBUS_TYPE_INT32, &offset,
|
||||||
|
DBUS_TYPE_INT32, &max_hits,
|
||||||
|
DBUS_TYPE_INVALID);
|
||||||
|
|
||||||
dbus_message_iter_init_append(msg, &iter);
|
e_dbus_message_send(conn, msg, _dbus_cb_reply, -1, p);
|
||||||
dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &live_query_id);
|
|
||||||
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &service);
|
|
||||||
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &match);
|
|
||||||
dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &offset);
|
|
||||||
dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &max_hits);
|
|
||||||
e_dbus_message_send(inst->conn, msg, _dbus_cb_reply, -1, p);
|
|
||||||
dbus_message_unref(msg);
|
dbus_message_unref(msg);
|
||||||
|
|
||||||
free(match);
|
if (input && (strlen(input) > 2))
|
||||||
|
free(search_text);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
|
_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
||||||
{
|
{
|
||||||
char *icon_path;
|
char *icon_path;
|
||||||
Evas_Object *o = NULL;
|
Evas_Object *o = NULL;
|
||||||
|
@ -172,9 +267,10 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_init(void)
|
_init(void)
|
||||||
{
|
{
|
||||||
E_DBus_Connection *conn = e_dbus_bus_get(DBUS_BUS_SESSION);
|
Inst *inst;
|
||||||
|
conn = e_dbus_bus_get(DBUS_BUS_SESSION);
|
||||||
|
|
||||||
if (!conn) return 0;
|
if (!conn) return EINA_FALSE;
|
||||||
|
|
||||||
p1 = E_NEW(Evry_Plugin, 1);
|
p1 = E_NEW(Evry_Plugin, 1);
|
||||||
p1->name = "Find Files";
|
p1->name = "Find Files";
|
||||||
|
@ -185,21 +281,57 @@ _init(void)
|
||||||
p1->fetch = &_fetch;
|
p1->fetch = &_fetch;
|
||||||
p1->cleanup = &_cleanup;
|
p1->cleanup = &_cleanup;
|
||||||
p1->icon_get = &_item_icon_get;
|
p1->icon_get = &_item_icon_get;
|
||||||
|
inst = E_NEW(Inst, 1);
|
||||||
|
inst->condition = "";
|
||||||
|
inst->service = "Files";
|
||||||
|
p1->private = inst;
|
||||||
evry_plugin_register(p1);
|
evry_plugin_register(p1);
|
||||||
|
|
||||||
p2 = E_NEW(Evry_Plugin, 1);
|
p2 = E_NEW(Evry_Plugin, 1);
|
||||||
p2->name = "Find Files";
|
p2->name = "Folders";
|
||||||
p2->type = type_object;
|
p2->type = type_subject;
|
||||||
p2->type_in = "NONE";
|
p2->type_in = "NONE";
|
||||||
p2->type_out = "FILE";
|
p2->type_out = "FILE";
|
||||||
p2->async_query = 1;
|
p2->async_query = 1;
|
||||||
p2->fetch = &_fetch;
|
p2->fetch = &_fetch;
|
||||||
p2->cleanup = &_cleanup;
|
p2->cleanup = &_cleanup;
|
||||||
p2->icon_get = &_item_icon_get;
|
p2->icon_get = &_item_icon_get;
|
||||||
|
inst = E_NEW(Inst, 1);
|
||||||
|
inst->condition = "";
|
||||||
|
inst->service = "Folders";
|
||||||
|
p2->private = inst;
|
||||||
evry_plugin_register(p2);
|
evry_plugin_register(p2);
|
||||||
|
|
||||||
|
p3 = E_NEW(Evry_Plugin, 1);
|
||||||
|
p3->name = "Find Files";
|
||||||
|
p3->type = type_object;
|
||||||
|
p3->type_in = "NONE";
|
||||||
|
p3->type_out = "FILE";
|
||||||
|
p3->async_query = 1;
|
||||||
|
p3->begin = &_begin;
|
||||||
|
p3->fetch = &_fetch;
|
||||||
|
p3->cleanup = &_cleanup;
|
||||||
|
p3->icon_get = &_item_icon_get;
|
||||||
inst = E_NEW(Inst, 1);
|
inst = E_NEW(Inst, 1);
|
||||||
inst->conn = conn;
|
inst->condition = "";
|
||||||
|
inst->service = "Files";
|
||||||
|
p3->private = inst;
|
||||||
|
evry_plugin_register(p3);
|
||||||
|
|
||||||
|
p4 = E_NEW(Evry_Plugin, 1);
|
||||||
|
p4->name = "Folders";
|
||||||
|
p4->type = type_object;
|
||||||
|
p4->type_in = "NONE";
|
||||||
|
p4->type_out = "FILE";
|
||||||
|
p4->async_query = 1;
|
||||||
|
p4->fetch = &_fetch;
|
||||||
|
p4->cleanup = &_cleanup;
|
||||||
|
p4->icon_get = &_item_icon_get;
|
||||||
|
inst = E_NEW(Inst, 1);
|
||||||
|
inst->condition = "";
|
||||||
|
inst->service = "Folders";
|
||||||
|
p4->private = inst;
|
||||||
|
evry_plugin_register(p4);
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -207,17 +339,41 @@ _init(void)
|
||||||
static void
|
static void
|
||||||
_shutdown(void)
|
_shutdown(void)
|
||||||
{
|
{
|
||||||
evry_plugin_unregister(p1);
|
Inst *inst;
|
||||||
evry_plugin_unregister(p2);
|
|
||||||
|
|
||||||
if (p1) E_FREE(p1);
|
if (conn) e_dbus_connection_close(conn);
|
||||||
if (p2) E_FREE(p2);
|
|
||||||
|
|
||||||
if (inst)
|
if (p1)
|
||||||
{
|
{
|
||||||
if (inst->conn)
|
evry_plugin_unregister(p1);
|
||||||
e_dbus_connection_close(inst->conn);
|
inst = p1->private;
|
||||||
E_FREE(inst);
|
E_FREE(inst);
|
||||||
|
E_FREE(p1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p2)
|
||||||
|
{
|
||||||
|
evry_plugin_unregister(p2);
|
||||||
|
inst = p2->private;
|
||||||
|
E_FREE(inst);
|
||||||
|
E_FREE(p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p3)
|
||||||
|
{
|
||||||
|
evry_plugin_unregister(p3);
|
||||||
|
inst = p3->private;
|
||||||
|
if (inst->condition[0]) free(inst->condition);
|
||||||
|
E_FREE(inst);
|
||||||
|
E_FREE(p3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p4)
|
||||||
|
{
|
||||||
|
evry_plugin_unregister(p4);
|
||||||
|
inst = p4->private;
|
||||||
|
E_FREE(inst);
|
||||||
|
E_FREE(p4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue