'everything' module: results from valgrind session and some cleanups

SVN revision: 41692
This commit is contained in:
Hannes Janetzek 2009-08-11 16:07:30 +00:00
parent dd0c34e4c5
commit 01d1ae246e
4 changed files with 67 additions and 55 deletions

View File

@ -587,6 +587,7 @@ _evry_selector_free(Evry_Selector *sel)
if (p->tab) evas_object_del(p->tab);
p->tab = NULL;
}
E_FREE(s);
}
_evry_plug_aggregator_free(sel->aggregator);
@ -1020,8 +1021,10 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
if (ev->event_window != input_window) return 1;
if (!strcmp(ev->key, "Up"))
/* if (!strcmp(ev->key, "K")) */
_evry_list_item_prev(s);
else if (!strcmp(ev->key, "Down"))
/* else if (!strcmp(ev->key, "J")) */
_evry_list_item_next(s);
else if (!strcmp(ev->key, "Right") &&
(ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT))
@ -1030,8 +1033,10 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
(ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT))
_evry_list_plugin_prev(s);
else if (!strcmp(ev->key, "Right"))
/* else if (!strcmp(ev->key, "L")) */
_evry_browse_item(selector);
else if (!strcmp(ev->key, "Left"))
/* else if (!strcmp(ev->key, "H")) */
_evry_browse_back(selector);
else if ((!strcmp(ev->key, "Return")) &&
((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) ||
@ -1363,8 +1368,9 @@ _evry_matches_update(Evry_Selector *sel, Evry_Plugin *plugin)
}
if ((has_items && eina_list_count(p->items) > 0) ||
(sel->states->next) ||
(p->async_query)) /* XXX append in async_update instead?*/
(sel->states->next)
/* (p->async_query) */
) /* XXX append in async_update instead?*/
{
s->cur_plugins = eina_list_append(s->cur_plugins, p);
}

View File

@ -6,7 +6,8 @@ typedef struct _Inst Inst;
struct _Inst
{
Eina_Hash *added;
Eina_List *apps;
Eina_List *apps_mime;
Eina_List *apps_all;
Evry_Item *candidate;
};
@ -37,20 +38,27 @@ _begin(Evry_Plugin *p, Evry_Item *it)
else
mime = it->mime;
/* TODO show plugin for items without mimetype ? */
if (!mime) return 0;
inst = E_NEW(Inst, 1);
inst->candidate = it;
inst->apps = efreet_util_desktop_mime_list(mime);
inst->apps_mime = efreet_util_desktop_mime_list(mime);
desktop = e_exehist_mime_desktop_get(mime);
if (desktop)
{
efreet_desktop_ref(desktop);
inst->apps = eina_list_prepend(inst->apps, desktop);
inst->apps_mime = eina_list_prepend(inst->apps_mime, desktop);
}
}
else
{
inst = E_NEW(Inst, 1);
}
if (inst)
inst->apps_all = efreet_util_desktop_name_glob_list("*");
p->private = inst;
return 1;
@ -81,25 +89,31 @@ _cleanup(Evry_Plugin *p)
if (inst)
{
if (inst->apps) eina_list_free(inst->apps);
Efreet_Desktop *desktop;
EINA_LIST_FREE(inst->apps_mime, desktop)
efreet_desktop_free(desktop);
EINA_LIST_FREE(inst->apps_all, desktop)
efreet_desktop_free(desktop);
E_FREE(inst);
}
p->private = NULL;
}
static void
static int
_item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int prio)
{
Evry_Item *it;
Evry_App *app;
Efreet_Desktop *d2;
Inst *inst = p->private;
int already_refd = 0;
if (desktop)
file = desktop->exec;
if (!file) return;
if (!file) return 0;
if (!desktop)
{
@ -109,7 +123,7 @@ _item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int prio)
char *tmp;
if (eina_hash_find(inst->added, file))
return;
return 0;
len = strlen(file);
tmp = ecore_file_app_exe_get(file);
@ -121,6 +135,7 @@ _item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int prio)
if (!desktop && d2->exec && !strncmp(file, d2->exec, len))
{
desktop = d2;
already_refd = 1;
efreet_desktop_ref(desktop);
}
efreet_desktop_free(d2);
@ -137,9 +152,10 @@ _item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int prio)
if ((d2 = eina_hash_find(inst->added, file)) &&
((desktop == d2) ||
(!strcmp(desktop->exec, d2->exec))))
return;
return 0;
efreet_desktop_ref(desktop);
if (!already_refd)
efreet_desktop_ref(desktop);
eina_hash_add(inst->added, file, desktop);
file = NULL;
}
@ -156,6 +172,8 @@ _item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int prio)
it->priority = prio;
p->items = eina_list_append(p->items, it);
return 1;
}
static void
@ -191,8 +209,6 @@ _add_desktop_list(Evry_Plugin *p, Eina_List *apps, char *m1, char *m2)
* _item_add(p, desktop, NULL, 4);
* } */
}
EINA_LIST_FOREACH(apps, l, desktop)
efreet_desktop_free(desktop);
}
static int
@ -227,7 +243,6 @@ _cb_sort(const void *data1, const void *data2)
if ((int)(t2 - t1))
return (int)(t2 - t1);
// TODO compare exe strings?
else return 0;
@ -244,13 +259,8 @@ _fetch(Evry_Plugin *p, const char *input)
Evry_Item *it;
Evry_App *app;
Inst *inst = p->private;
if (!inst)
{
inst = E_NEW(Inst, 1);
p->private = inst;
}
inst->added = eina_hash_string_superfast_new(NULL);
inst->added = eina_hash_string_small_new(NULL);
_list_free(p);
@ -261,40 +271,34 @@ _fetch(Evry_Plugin *p, const char *input)
}
/* add apps for a given mimetype */
if (inst && inst->apps)
if (p->type == type_action)
{
if (!input)
if (input)
{
EINA_LIST_FOREACH(inst->apps, l, desktop)
{
_item_add(p, desktop, NULL, 1);
efreet_desktop_free(desktop);
}
_add_desktop_list(p, inst->apps_mime, match1, match2);
}
else
{
_add_desktop_list(p, inst->apps, match1, match2);
inst->apps = NULL;
EINA_LIST_FOREACH(inst->apps_mime, l, desktop)
_item_add(p, desktop, NULL, 1);
}
if (input)
EINA_LIST_FOREACH(p->items, l, it)
it->priority += 2;
}
/* add apps matching input */
if (!p->items && input)
{
l = efreet_util_desktop_name_glob_list("*");
if (l)
{
_add_desktop_list(p, l, match1, match2);
eina_list_free(l);
}
}
if (input)
_add_desktop_list(p, inst->apps_all, match1, match2);
/* add exe history items */
else if (!p->items)
{
l = e_exehist_list_get();
EINA_LIST_FREE(l, file)
_item_add(p, NULL, file, 1);
_item_add(p, NULL, file, 1);
}
/* show 'Run Command' item */
@ -351,11 +355,7 @@ _fetch(Evry_Plugin *p, const char *input)
}
}
if (inst->added)
{
eina_hash_free(inst->added);
inst->added = NULL;
}
eina_hash_free(inst->added);
if (p->items)
{

View File

@ -357,7 +357,7 @@ static Evas_Object *
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
{
Evas_Object *o = NULL;
char *item_path;
char *icon_path;
if (!it->mime)
_item_fill(it);
@ -371,11 +371,14 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
}
else
{
item_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 64);
icon_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 64);
if (item_path)
o = e_util_icon_add(item_path, e);
if (!o)
if (icon_path)
{
o = e_util_icon_add(icon_path, e);
free(icon_path);
}
if (!o)
{
o = e_icon_add(e);
evry_icon_theme_set(o, "none");

View File

@ -143,7 +143,7 @@ _fetch(Evry_Plugin *p, const char *input)
static Evas_Object *
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
{
char *item_path;
char *icon_path;
Evas_Object *o = NULL;
if (it->browseable)
@ -153,10 +153,13 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
}
else
{
item_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 64);
icon_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 64);
if (item_path)
o = e_util_icon_add(item_path, e);
if (icon_path)
{
o = e_util_icon_add(icon_path, e);
free(icon_path);
}
else
{
o = e_icon_add(e);