'everything'

- cleanup api -> cleanup code :)
- Evry_Plugin now inherits Evry_Item
- Evry_Action has fetch method to realize menu interfaces easily. see wallpaper plugin
- Evry_App inherits Evry_Action


SVN revision: 48374
This commit is contained in:
Hannes Janetzek 2010-04-28 03:22:40 +00:00
parent 8d647d48cf
commit e2abaae2c6
19 changed files with 1132 additions and 1363 deletions

View File

@ -46,14 +46,8 @@ struct _Module_Config
static Module_Config *_conf; static Module_Config *_conf;
static Plugin *p1 = NULL; static Evry_Plugin *plug_apps = NULL;
static Plugin *p2 = NULL; static Evry_Plugin *plug_action = NULL;
static Evry_Action *act = NULL;
static Evry_Action *act1 = NULL;
static Evry_Action *act2 = NULL;
static Evry_Action *act3 = NULL;
static Evry_Action *act4 = NULL;
static Evry_Action *act5 = NULL;
static Eina_List *exe_path = NULL; static Eina_List *exe_path = NULL;
static Ecore_Idler *exe_scan_idler = NULL; static Ecore_Idler *exe_scan_idler = NULL;
@ -63,11 +57,13 @@ static DIR *exe_dir = NULL;
static Eina_List *exe_list = NULL; static Eina_List *exe_list = NULL;
static Eina_List *exe_list2 = NULL; static Eina_List *exe_list2 = NULL;
static Eina_List *_actions = NULL;
static int _scan_idler(void *data); static int _scan_idler(void *data);
static void _hash_free(void *data) static void _hash_free(void *data)
{ {
ITEM_APP(app, data); GET_APP(app, data);
evry_item_free(EVRY_ITEM(app)); evry_item_free(EVRY_ITEM(app));
} }
@ -75,13 +71,14 @@ static void _hash_free(void *data)
static Evry_Plugin * static Evry_Plugin *
_begin_open_with(Evry_Plugin *plugin, const Evry_Item *item) _begin_open_with(Evry_Plugin *plugin, const Evry_Item *item)
{ {
PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
const char *mime; const char *mime;
if (!item) return 0; if (!evry_item_type_check(item, "FILE", NULL))
return 0;
ITEM_FILE(file, item);
GET_FILE(file, item);
Efreet_Desktop *d, *d2; Efreet_Desktop *d, *d2;
if (!file->path) return NULL; if (!file->path) return NULL;
@ -132,7 +129,7 @@ _begin_open_with(Evry_Plugin *plugin, const Evry_Item *item)
static Evry_Plugin * static Evry_Plugin *
_begin(Evry_Plugin *plugin, const Evry_Item *item) _begin(Evry_Plugin *plugin, const Evry_Item *item)
{ {
PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
p->added = eina_hash_string_small_new(_hash_free); p->added = eina_hash_string_small_new(_hash_free);
@ -181,22 +178,9 @@ _begin(Evry_Plugin *plugin, const Evry_Item *item)
} }
static void static void
_item_free(Evry_Item *item) _finish(Evry_Plugin *plugin)
{ {
ITEM_APP(app, item); GET_PLUGIN(p, plugin);
if (app->desktop)
efreet_desktop_free(app->desktop);
if (app->file)
eina_stringshare_del(app->file);
E_FREE(app);
}
static void
_cleanup(Evry_Plugin *plugin)
{
PLUGIN(p, plugin);
Efreet_Desktop *desktop; Efreet_Desktop *desktop;
if (p->added) if (p->added)
@ -210,7 +194,7 @@ _cleanup(Evry_Plugin *plugin)
EINA_LIST_FREE(p->apps_hist, desktop) EINA_LIST_FREE(p->apps_hist, desktop)
efreet_desktop_free(desktop); efreet_desktop_free(desktop);
if (plugin->type == type_action) if (plugin == plug_action)
{ {
EINA_LIST_FREE(p->apps_mime, desktop) EINA_LIST_FREE(p->apps_mime, desktop)
efreet_desktop_free(desktop); efreet_desktop_free(desktop);
@ -243,6 +227,47 @@ _cleanup(Evry_Plugin *plugin)
} }
static int
_exec_open_file_action(Evry_Action *act)
{
printf("exec\n");
printf("exec %p %p\n", act, act->item1);
printf("exec %s\n", EVRY_ITEM(act)->label);
printf("exec %s\n", act->item1->label);
return evry_util_exec_app(EVRY_ITEM(act), act->item1);
}
static Evas_Object *
_icon_get(Evry_Item *it, Evas *e)
{
GET_APP(app, it);
Evas_Object *o = NULL;
if (app->desktop)
o = e_util_desktop_icon_add(app->desktop, 64, e);
if (!o)
o = evry_icon_theme_get("system-run", e);
return o;
}
static void
_item_free(Evry_Item *item)
{
GET_APP(app, item);
if (app->desktop)
efreet_desktop_free(app->desktop);
if (app->file)
eina_stringshare_del(app->file);
E_FREE(app);
}
static Evry_Item_App * static Evry_Item_App *
_item_add(Plugin *p, Efreet_Desktop *desktop, const char *file, int match) _item_add(Plugin *p, Efreet_Desktop *desktop, const char *file, int match)
{ {
@ -317,12 +342,14 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, const char *file, int match)
if (desktop && !already_refd) if (desktop && !already_refd)
efreet_desktop_ref(desktop); efreet_desktop_ref(desktop);
app = E_NEW(Evry_Item_App, 1);
if (desktop) if (desktop)
{ {
evry_item_new(EVRY_ITEM(app), EVRY_PLUGIN(p), desktop->name, _item_free); app = EVRY_ITEM_NEW(Evry_Item_App, p, desktop->name, _icon_get, _item_free);
EVRY_ACTN(app)->action = &_exec_open_file_action;
EVRY_ITEM(app)->id = eina_stringshare_add(desktop->exec); EVRY_ITEM(app)->id = eina_stringshare_add(desktop->exec);
EVRY_ITEM(app)->subtype = eina_stringshare_add("ACTION");
if (desktop->comment) if (desktop->comment)
EVRY_ITEM(app)->detail = eina_stringshare_add(desktop->comment); EVRY_ITEM(app)->detail = eina_stringshare_add(desktop->comment);
else if (desktop->generic_name) else if (desktop->generic_name)
@ -330,9 +357,10 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, const char *file, int match)
} }
else else
{ {
evry_item_new(EVRY_ITEM(app), EVRY_PLUGIN(p), file, _item_free); app = EVRY_ITEM_NEW(Evry_Item_App, p, file, _icon_get, _item_free);
EVRY_ITEM(app)->id = eina_stringshare_add(file); EVRY_ITEM(app)->id = eina_stringshare_add(file);
/* EVRY_ITEM(app)->detail = eina_stringshare_add(file); */ EVRY_ACTN(app)->action = &_exec_open_file_action;
EVRY_ITEM(app)->subtype = eina_stringshare_add("ACTION");
} }
app->desktop = desktop; app->desktop = desktop;
@ -614,19 +642,16 @@ _add_executables(Plugin *p, const char *input)
static int static int
_fetch(Evry_Plugin *plugin, const char *input) _fetch(Evry_Plugin *plugin, const char *input)
{ {
PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
Eina_List *l, *ll, *previous; Eina_List *l;
Efreet_Desktop *desktop; Efreet_Desktop *desktop;
Evry_Item *it; Evry_Item *it;
char *file; char *file;
plugin->changed = 0; EVRY_PLUGIN_ITEMS_CLEAR(p)
previous = plugin->items;
plugin->items = NULL;
/* add apps for a given mimetype */ /* add apps for a given mimetype */
if (plugin->type == type_action) if (plugin == plug_action)
_add_desktop_list(p, p->apps_mime, input); _add_desktop_list(p, p->apps_mime, input);
/* add apps matching input */ /* add apps matching input */
@ -669,14 +694,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
/* add executables */ /* add executables */
_add_executables(p, input); _add_executables(p, input);
if (!plugin->items) if (plugin == plug_action)
{
plugin->items = previous;
EVRY_PLUGIN_ITEMS_CLEAR(p);
return 0;
}
if (plugin->type == type_action)
{ {
EINA_LIST_FOREACH(plugin->items, l, it) EINA_LIST_FOREACH(plugin->items, l, it)
evry_history_item_usage_set(evry_hist->actions, it, input, NULL); evry_history_item_usage_set(evry_hist->actions, it, input, NULL);
@ -687,7 +705,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
evry_history_item_usage_set(evry_hist->subjects, it, input, NULL); evry_history_item_usage_set(evry_hist->subjects, it, input, NULL);
} }
if (!input && plugin->type != type_action) if (!input && plugin != plug_action)
{ {
EINA_LIST_FOREACH(e_exehist_list_get(), l, file) EINA_LIST_FOREACH(e_exehist_list_get(), l, file)
{ {
@ -702,20 +720,8 @@ _fetch(Evry_Plugin *plugin, const char *input)
} }
} }
if (plugin->type != type_action || input) if (plugin != plug_action || input)
EVRY_PLUGIN_ITEMS_SORT(plugin, _cb_sort); EVRY_PLUGIN_ITEMS_SORT(plugin, _cb_sort);
for (l = previous, ll = plugin->items; l && ll; l = l->next, ll = ll->next)
{
if (l->data != ll->data)
{
plugin->changed = 1;
break;
}
}
if (l || ll) plugin->changed = 1;
if (previous) eina_list_free(previous);
return 1; return 1;
} }
@ -724,7 +730,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
static int static int
_complete(Evry_Plugin *plugin, const Evry_Item *it, char **input) _complete(Evry_Plugin *plugin, const Evry_Item *it, char **input)
{ {
ITEM_APP(app, it); GET_APP(app, it);
char buf[128]; char buf[128];
@ -744,24 +750,11 @@ _complete(Evry_Plugin *plugin, const Evry_Item *it, char **input)
return EVRY_COMPLETE_INPUT; return EVRY_COMPLETE_INPUT;
} }
static Evas_Object *
_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
{
ITEM_APP(app, it);
Evas_Object *o = NULL;
if (app->desktop)
o = e_util_desktop_icon_add(app->desktop, 64, e);
if (!o)
o = evry_icon_theme_get("system-run", e);
return o;
}
static int static int
_exec_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it) _exec_app_check_item(Evry_Action *act, const Evry_Item *it)
{ {
/* if (!evry_item_type_check(it, "APPLICATION", NULL)) return 0; */
/* ITEM_APP(app, it); */ /* ITEM_APP(app, it); */
/* if (app->desktop) /* if (app->desktop)
@ -783,7 +776,7 @@ _exec_app_action(Evry_Action *act)
static int static int
_exec_term_action(Evry_Action *act) _exec_term_action(Evry_Action *act)
{ {
ITEM_APP(app, act->item1); GET_APP(app, act->item1);
Evry_Item_App *tmp; Evry_Item_App *tmp;
char buf[1024]; char buf[1024];
int ret; int ret;
@ -806,7 +799,9 @@ _exec_term_action(Evry_Action *act)
static int static int
_exec_term_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it) _exec_term_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
{ {
ITEM_APP(app, it); /* if (!evry_item_type_check(it, NULL, "APPLICATION")) return 0; */
GET_APP(app, it);
if (app->file) if (app->file)
return 1; return 1;
@ -817,7 +812,7 @@ _exec_term_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
static int static int
_exec_sudo_action(Evry_Action *act) _exec_sudo_action(Evry_Action *act)
{ {
ITEM_APP(app, act->item1); GET_APP(app, act->item1);
Evry_Item_App *tmp; Evry_Item_App *tmp;
char buf[1024]; char buf[1024];
int ret; int ret;
@ -835,18 +830,12 @@ _exec_sudo_action(Evry_Action *act)
return ret; return ret;
} }
static int
_open_with_action(Evry_Plugin *plugin, const Evry_Item *act, const Evry_Item *subj)
{
return evry_util_exec_app(act, subj);
return 0;
}
static int static int
_edit_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it) _edit_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
{ {
ITEM_APP(app, it); /* if (!evry_item_type_check(it, NULL, "APPLICATION")) return 0; */
GET_APP(app, it);
if (app->desktop) if (app->desktop)
return 1; return 1;
@ -858,7 +847,7 @@ static int
_edit_app_action(Evry_Action *act) _edit_app_action(Evry_Action *act)
{ {
Efreet_Desktop *desktop; Efreet_Desktop *desktop;
ITEM_APP(app, act->item1); GET_APP(app, act->item1);
if (app->desktop) if (app->desktop)
desktop = app->desktop; desktop = app->desktop;
@ -880,7 +869,9 @@ _edit_app_action(Evry_Action *act)
static int static int
_new_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it) _new_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
{ {
ITEM_APP(app, it); /* if (!evry_item_type_check(it, NULL, "APPLICATION")) return 0; */
GET_APP(app, it);
if (app->desktop) if (app->desktop)
return 1; return 1;
@ -900,7 +891,7 @@ _new_app_action(Evry_Action *act)
Efreet_Desktop *desktop; Efreet_Desktop *desktop;
int i; int i;
ITEM_APP(app, act->item1); GET_APP(app, act->item1);
if (app->desktop) if (app->desktop)
name = strdup(app->desktop->name); name = strdup(app->desktop->name);
@ -958,65 +949,54 @@ static Eina_Bool
_plugins_init(void) _plugins_init(void)
{ {
Evry_Plugin *p; Evry_Plugin *p;
int prio = 0;
Eina_List *l;
Evry_Action *act;
if (!evry_api_version_check(EVRY_API_VERSION)) if (!evry_api_version_check(EVRY_API_VERSION))
return EINA_FALSE; return EINA_FALSE;
p = EVRY_PLUGIN_NEW(Plugin, N_("Applications"), type_subject, "", "APPLICATION", p = EVRY_PLUGIN_NEW(Plugin, N_("Applications"), NULL, "APPLICATION",
_begin, _cleanup, _fetch, _icon_get, NULL); _begin, _finish, _fetch, NULL);
p->complete = &_complete; p->complete = &_complete;
p->config_path = "extensions/everything-apps"; p->config_path = "extensions/everything-apps";
evry_plugin_register(p, 1); evry_plugin_register(p, EVRY_PLUGIN_SUBJECT, 1);
p1 = (Plugin *) p; plug_apps = p;
p = EVRY_PLUGIN_NEW(Plugin, N_("Open With..."), type_action, "FILE", "", p = EVRY_PLUGIN_NEW(Plugin, N_("Open With..."), NULL, "APPLICATION",
_begin_open_with, _cleanup, _fetch, _begin_open_with, _finish, _fetch, NULL);
_icon_get, NULL);
p->action = &_open_with_action; /* p->action = &_open_with_action; */
p->config_path = "extensions/everything-apps"; p->config_path = "extensions/everything-apps";
evry_plugin_register(p, 1); evry_plugin_register(p, EVRY_PLUGIN_ACTION, 1);
p2 = (Plugin *) p; plug_action = p;
act = EVRY_ACTION_NEW(N_("Launch"), "APPLICATION", NULL, act = EVRY_ACTION_NEW(N_("Launch"), "APPLICATION", NULL,
"everything-launch", _exec_app_action, _exec_app_check_item); "everything-launch", _exec_app_action, _exec_app_check_item);
_actions = eina_list_append(_actions, act);
act1 = EVRY_ACTION_NEW(N_("Open File..."), "APPLICATION", "FILE", "document-open",
act = EVRY_ACTION_NEW(N_("Open File..."), "APPLICATION", "FILE", "document-open",
_exec_app_action, _exec_app_check_item); _exec_app_action, _exec_app_check_item);
_actions = eina_list_append(_actions, act);
act2 = EVRY_ACTION_NEW(N_("Run in Terminal"), "APPLICATION", NULL, "system-run",
act = EVRY_ACTION_NEW(N_("Run in Terminal"), "APPLICATION", NULL, "system-run",
_exec_term_action, _exec_term_check_item); _exec_term_action, _exec_term_check_item);
_actions = eina_list_append(_actions, act);
act3 = EVRY_ACTION_NEW(N_("Edit Application Entry"), "APPLICATION", NULL, "everything-launch",
act = EVRY_ACTION_NEW(N_("Edit Application Entry"), "APPLICATION", NULL, "everything-launch",
_edit_app_action, _edit_app_check_item); _edit_app_action, _edit_app_check_item);
_actions = eina_list_append(_actions, act);
act4 = EVRY_ACTION_NEW(N_("New Application Entry"), "APPLICATION", NULL, "everything-launch",
act = EVRY_ACTION_NEW(N_("New Application Entry"), "APPLICATION", NULL, "everything-launch",
_new_app_action, _new_app_check_item); _new_app_action, _new_app_check_item);
_actions = eina_list_append(_actions, act);
act5 = EVRY_ACTION_NEW(N_("Run with Sudo"), "APPLICATION", NULL, "system-run",
act = EVRY_ACTION_NEW(N_("Run with Sudo"), "APPLICATION", NULL, "system-run",
_exec_sudo_action, NULL); _exec_sudo_action, NULL);
_actions = eina_list_append(_actions, act);
evry_action_register(act, 0);
evry_action_register(act1, 1); EINA_LIST_FOREACH(_actions, l, act)
evry_action_register(act2, 2); evry_action_register(act, prio++);
evry_action_register(act3, 3);
evry_action_register(act4, 4);
evry_action_register(act5, 5);
/* taken from e_exebuf.c */
exelist_exe_edd = E_CONFIG_DD_NEW("E_Exe", E_Exe);
#undef T
#undef D
#define T E_Exe
#define D exelist_exe_edd
E_CONFIG_VAL(D, T, path, STR);
exelist_edd = E_CONFIG_DD_NEW("E_Exe_List", E_Exe_List);
#undef T
#undef D
#define T E_Exe_List
#define D exelist_edd
E_CONFIG_LIST(D, T, list, exelist_exe_edd);
return EINA_TRUE; return EINA_TRUE;
} }
@ -1024,134 +1004,15 @@ _plugins_init(void)
static void static void
_plugins_shutdown(void) _plugins_shutdown(void)
{ {
EVRY_PLUGIN_FREE(p1); Evry_Action *act;
EVRY_PLUGIN_FREE(p2);
EVRY_PLUGIN_FREE(plug_apps);
EVRY_PLUGIN_FREE(plug_action);
evry_action_free(act); EINA_LIST_FREE(_actions, act)
evry_action_free(act1); evry_action_free(act);
evry_action_free(act2);
evry_action_free(act3);
evry_action_free(act4);
evry_action_free(act5);
} }
/* taken from e_exebuf.c */
static int
_scan_idler(void *data)
{
struct stat st;
struct dirent *dp;
char *dir;
char buf[4096];
/* no more path items left - stop scanning */
if (!exe_path)
{
Eina_List *l, *l2;
E_Exe_List *el;
E_Exe *ee;
int different = 0;
/* FIXME: check wheter they match or not */
for (l = exe_list, l2 = exe_list2; l && l2; l = l->next, l2 = l2->next)
{
if (strcmp(l->data, l2->data))
{
different = 1;
break;
}
}
if ((l) || (l2)) different = 1;
if (exe_list2)
{
while (exe_list)
{
free(eina_list_data_get(exe_list));
exe_list = eina_list_remove_list(exe_list, exe_list);
}
exe_list = exe_list2;
exe_list2 = NULL;
}
if (different)
{
el = calloc(1, sizeof(E_Exe_List));
if (el)
{
el->list = NULL;
for (l = exe_list; l; l = l->next)
{
ee = malloc(sizeof(E_Exe));
if (ee)
{
ee->path = eina_stringshare_add(l->data);
el->list = eina_list_append(el->list, ee);
}
}
e_config_domain_save("exebuf_exelist_cache", exelist_edd, el);
while (el->list)
{
ee = eina_list_data_get(el->list);
eina_stringshare_del(ee->path);
free(ee);
el->list = eina_list_remove_list(el->list, el->list);
}
free(el);
}
}
exe_scan_idler = NULL;
return 0;
}
/* no dir is open - open the first path item */
if (!exe_dir)
{
dir = exe_path->data;
exe_dir = opendir(dir);
}
/* if we have an opened dir - scan the next item */
if (exe_dir)
{
dir = exe_path->data;
dp = readdir(exe_dir);
if (dp)
{
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
{
snprintf(buf, sizeof(buf), "%s/%s", dir, dp->d_name);
if ((stat(buf, &st) == 0) &&
((!S_ISDIR(st.st_mode)) &&
(!access(buf, X_OK))))
{
if (!exe_list)
exe_list = eina_list_append(exe_list, strdup(dp->d_name));
else
exe_list2 = eina_list_append(exe_list2, strdup(dp->d_name));
}
}
}
else
{
/* we reached the end of a dir - remove the dir at the head
* of the path list so we advance and next loop we will pick up
* the next item, or if null- abort
*/
closedir(exe_dir);
exe_dir = NULL;
free(eina_list_data_get(exe_path));
exe_path = eina_list_remove_list(exe_path, exe_path);
}
}
/* obviously the dir open failed - so remove the first path item */
else
{
free(eina_list_data_get(exe_path));
exe_path = eina_list_remove_list(exe_path, exe_path);
}
/* we have mroe scannign to do */
return 1;
}
/***************************************************************************/ /***************************************************************************/
static E_Config_DD *conf_edd = NULL; static E_Config_DD *conf_edd = NULL;
@ -1330,6 +1191,21 @@ e_modapi_init(E_Module *m)
active = _plugins_init(); active = _plugins_init();
_conf_init(m); _conf_init(m);
/* taken from e_exebuf.c */
exelist_exe_edd = E_CONFIG_DD_NEW("E_Exe", E_Exe);
#undef T
#undef D
#define T E_Exe
#define D exelist_exe_edd
E_CONFIG_VAL(D, T, path, STR);
exelist_edd = E_CONFIG_DD_NEW("E_Exe_List", E_Exe_List);
#undef T
#undef D
#define T E_Exe_List
#define D exelist_edd
E_CONFIG_LIST(D, T, list, exelist_exe_edd);
e_module_delayed_set(m, 1); e_module_delayed_set(m, 1);
@ -1360,3 +1236,119 @@ e_modapi_save(E_Module *m)
/**/ /**/
/***************************************************************************/ /***************************************************************************/
/* taken from e_exebuf.c */
static int
_scan_idler(void *data)
{
struct stat st;
struct dirent *dp;
char *dir;
char buf[4096];
/* no more path items left - stop scanning */
if (!exe_path)
{
Eina_List *l, *l2;
E_Exe_List *el;
E_Exe *ee;
int different = 0;
/* FIXME: check wheter they match or not */
for (l = exe_list, l2 = exe_list2; l && l2; l = l->next, l2 = l2->next)
{
if (strcmp(l->data, l2->data))
{
different = 1;
break;
}
}
if ((l) || (l2)) different = 1;
if (exe_list2)
{
while (exe_list)
{
free(eina_list_data_get(exe_list));
exe_list = eina_list_remove_list(exe_list, exe_list);
}
exe_list = exe_list2;
exe_list2 = NULL;
}
if (different)
{
el = calloc(1, sizeof(E_Exe_List));
if (el)
{
el->list = NULL;
for (l = exe_list; l; l = l->next)
{
ee = malloc(sizeof(E_Exe));
if (ee)
{
ee->path = eina_stringshare_add(l->data);
el->list = eina_list_append(el->list, ee);
}
}
e_config_domain_save("exebuf_exelist_cache", exelist_edd, el);
while (el->list)
{
ee = eina_list_data_get(el->list);
eina_stringshare_del(ee->path);
free(ee);
el->list = eina_list_remove_list(el->list, el->list);
}
free(el);
}
}
exe_scan_idler = NULL;
return 0;
}
/* no dir is open - open the first path item */
if (!exe_dir)
{
dir = exe_path->data;
exe_dir = opendir(dir);
}
/* if we have an opened dir - scan the next item */
if (exe_dir)
{
dir = exe_path->data;
dp = readdir(exe_dir);
if (dp)
{
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
{
snprintf(buf, sizeof(buf), "%s/%s", dir, dp->d_name);
if ((stat(buf, &st) == 0) &&
((!S_ISDIR(st.st_mode)) &&
(!access(buf, X_OK))))
{
if (!exe_list)
exe_list = eina_list_append(exe_list, strdup(dp->d_name));
else
exe_list2 = eina_list_append(exe_list2, strdup(dp->d_name));
}
}
}
else
{
/* we reached the end of a dir - remove the dir at the head
* of the path list so we advance and next loop we will pick up
* the next item, or if null- abort
*/
closedir(exe_dir);
exe_dir = NULL;
free(eina_list_data_get(exe_path));
exe_path = eina_list_remove_list(exe_path, exe_path);
}
}
/* obviously the dir open failed - so remove the first path item */
else
{
free(eina_list_data_get(exe_path));
exe_path = eina_list_remove_list(exe_path, exe_path);
}
/* we have mroe scannign to do */
return 1;
}

View File

@ -86,7 +86,7 @@ _item_add(Plugin *p, const char *word, int word_size, int prio)
{ {
Evry_Item *it; Evry_Item *it;
it = evry_item_new(NULL, EVRY_PLUGIN(p), NULL, NULL); it = EVRY_ITEM_NEW(Evry_Item, p, NULL, NULL, NULL);
if (!it) return; if (!it) return;
it->priority = prio; it->priority = prio;
it->label = eina_stringshare_add_length(word, word_size); it->label = eina_stringshare_add_length(word, word_size);
@ -131,7 +131,7 @@ _suggestions_add(Plugin *p, const char *line)
static int static int
_cb_data(void *data, int type __UNUSED__, void *event) _cb_data(void *data, int type __UNUSED__, void *event)
{ {
PLUGIN(p, data); GET_PLUGIN(p, data);
Ecore_Exe_Event_Data *e = event; Ecore_Exe_Event_Data *e = event;
Ecore_Exe_Event_Data_Line *l; Ecore_Exe_Event_Data_Line *l;
const char *word; const char *word;
@ -204,7 +204,7 @@ _cb_del(void *data, int type __UNUSED__, void *event)
static int static int
_begin(Evry_Plugin *plugin, const Evry_Item *it __UNUSED__) _begin(Evry_Plugin *plugin, const Evry_Item *it __UNUSED__)
{ {
PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
if (!p->handler.data) if (!p->handler.data)
p->handler.data = ecore_event_handler_add p->handler.data = ecore_event_handler_add
@ -219,7 +219,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it __UNUSED__)
static int static int
_fetch(Evry_Plugin *plugin, const char *input) _fetch(Evry_Plugin *plugin, const char *input)
{ {
PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
const char *s; const char *s;
int len; int len;
@ -289,15 +289,15 @@ _fetch(Evry_Plugin *plugin, const char *input)
static void static void
_cleanup(Evry_Plugin *plugin) _cleanup(Evry_Plugin *plugin)
{ {
PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
EVRY_PLUGIN_ITEMS_FREE(p) EVRY_PLUGIN_ITEMS_FREE(p);
if (p->handler.data) if (p->handler.data)
{ {
ecore_event_handler_del(p->handler.data); ecore_event_handler_del(p->handler.data);
p->handler.data = NULL; p->handler.data = NULL;
} }
if (p->handler.del) if (p->handler.del)
{ {
ecore_event_handler_del(p->handler.del); ecore_event_handler_del(p->handler.del);
@ -321,19 +321,6 @@ _cleanup(Evry_Plugin *plugin)
} }
} }
/* static int
* _action(Evry_Action *act)
* {
* const Evry_Item *it = act->item2;
* if (!it) return 0;
*
* 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 1;
* } */
static Eina_Bool static Eina_Bool
_plugins_init(void) _plugins_init(void)
{ {
@ -342,32 +329,16 @@ _plugins_init(void)
if (!evry_api_version_check(EVRY_API_VERSION)) if (!evry_api_version_check(EVRY_API_VERSION))
return EINA_FALSE; return EINA_FALSE;
p = EVRY_PLUGIN_NEW(Plugin, N_("Spell Checker"), type_subject, "", "TEXT", p = EVRY_PLUGIN_NEW(Plugin, N_("Spell Checker"), "accessories-dictionary", "TEXT",
NULL, _cleanup, _fetch, NULL, NULL); NULL, _cleanup, _fetch, NULL);
p->aggregate = EINA_FALSE; p->aggregate = EINA_FALSE;
p->history = EINA_FALSE; p->history = EINA_FALSE;
p->async_fetch = EINA_TRUE; p->async_fetch = EINA_TRUE;
p->icon = "accessories-dictionary";
p->trigger = TRIGGER; p->trigger = TRIGGER;
evry_plugin_register(p, 100);
_plug = (Plugin *) p;
/* TODO show spell check action for given text */ evry_plugin_register(p, EVRY_PLUGIN_SUBJECT, 100);
/* p = EVRY_PLUGIN_NEW2(Plugin, N_("Spell Checker"), type_object, "", "TEXT", _plug = (Plugin *) p;
* _begin, _cleanup, _fetch, NULL, NULL);
*
* p->aggregate = EINA_FALSE;
* p->history = EINA_FALSE;
* p->async_fetch = EINA_TRUE;
* p->icon = "accessories-dictionary";
* p->trigger = TRIGGER;
*
* evry_plugin_register(p, 100);
* _plug2 = (Plugin *) p;
*
* _act = EVRY_ACTION_NEW(N_("Spell Checker"), "TEXT", "ASPELL", _action, NULL); */
return EINA_TRUE; return EINA_TRUE;
} }
@ -379,16 +350,11 @@ _plugins_shutdown(void)
} }
/***************************************************************************/ /***************************************************************************/
/**/
/* actual module specifics */
static E_Module *module = NULL; static E_Module *module = NULL;
static Eina_Bool active = EINA_FALSE; static Eina_Bool active = EINA_FALSE;
/***************************************************************************/ EAPI E_Module_Api e_modapi =
/**/
/* module setup */
EAPI E_Module_Api e_modapi =
{ {
E_MODULE_API_VERSION, E_MODULE_API_VERSION,
"everything-aspell" "everything-aspell"
@ -401,8 +367,8 @@ e_modapi_init(E_Module *m)
if (e_datastore_get("everything_loaded")) if (e_datastore_get("everything_loaded"))
active = _plugins_init(); active = _plugins_init();
e_module_delayed_set(m, 1); e_module_delayed_set(m, 1);
return m; return m;
} }
@ -414,7 +380,7 @@ e_modapi_shutdown(E_Module *m)
_plugins_shutdown(); _plugins_shutdown();
module = NULL; module = NULL;
return 1; return 1;
} }
@ -424,6 +390,4 @@ e_modapi_save(E_Module *m)
return 1; return 1;
} }
/**/
/***************************************************************************/ /***************************************************************************/

View File

@ -30,15 +30,15 @@ _begin(Evry_Plugin *p, const Evry_Item *item __UNUSED__)
EINA_LIST_FREE(history, result) EINA_LIST_FREE(history, result)
{ {
it = evry_item_new(NULL, p, result, NULL); it = EVRY_ITEM_NEW(Evry_Item, p, result, NULL, NULL);
it->context = eina_stringshare_ref(p->name); it->context = eina_stringshare_ref(p->name);
p->items = eina_list_prepend(p->items, it); p->items = eina_list_prepend(p->items, it);
eina_stringshare_del(result); eina_stringshare_del(result);
} }
} }
it = evry_item_new(NULL, p, "0", NULL); it = EVRY_ITEM_NEW(Evry_Item, p, "0", NULL, NULL);
it->context = eina_stringshare_ref(p->name); it->context = eina_stringshare_ref(p->name);
p->items = eina_list_prepend(p->items, it); p->items = eina_list_prepend(p->items, it);
return p; return p;
@ -100,42 +100,42 @@ _cleanup(Evry_Plugin *p)
} }
} }
static int /* static int
_action(Evry_Plugin *p, const Evry_Item *act __UNUSED__, const Evry_Item *it) * _action(Evry_Plugin *p, const Evry_Item *act __UNUSED__, const Evry_Item *it)
{ * {
Eina_List *l; * Eina_List *l;
Evry_Item *it2, *it_old; * Evry_Item *it2, *it_old;
*
/* remove duplicates */ * /\* remove duplicates *\/
if (p->items->next) * if (p->items->next)
{ * {
it = p->items->data; * it = p->items->data;
*
EINA_LIST_FOREACH(p->items->next, l, it2) * EINA_LIST_FOREACH(p->items->next, l, it2)
{ * {
if (!strcmp(it->label, it2->label)) * if (!strcmp(it->label, it2->label))
break; * break;
it2 = NULL; * it2 = NULL;
} * }
*
if (it2) * if (it2)
{ * {
p->items = eina_list_remove(p->items, it2); * p->items = eina_list_remove(p->items, it2);
evry_item_free(it2); * evry_item_free(it2);
} * }
} * }
*
it_old = p->items->data; * it_old = p->items->data;
it_old->selected = EINA_FALSE; * it_old->selected = EINA_FALSE;
*
it2 = evry_item_new(NULL, p, it_old->label, NULL); * it2 = evry_item_new(NULL, p, it_old->label, NULL);
it2->context = eina_stringshare_ref(p->name); * it2->context = eina_stringshare_ref(p->name);
p->items = eina_list_prepend(p->items, it2); * p->items = eina_list_prepend(p->items, it2);
*
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD); * evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
*
return EVRY_ACTION_FINISHED; * return EVRY_ACTION_FINISHED;
} * } */
static int static int
_fetch(Evry_Plugin *p, const char *input) _fetch(Evry_Plugin *p, const char *input)
@ -180,21 +180,21 @@ _cb_data(void *data, int type __UNUSED__, void *event)
Ecore_Exe_Event_Data *ev = event; Ecore_Exe_Event_Data *ev = event;
Evry_Plugin *p = data; Evry_Plugin *p = data;
Evry_Item *it; Evry_Item *it;
if (ev->exe != exe) return 1; if (ev->exe != exe) return 1;
if (ev->lines) if (ev->lines)
{ {
it = p->items->data; it = p->items->data;
eina_stringshare_del(it->label); eina_stringshare_del(it->label);
it->label = eina_stringshare_add(ev->lines->line); it->label = eina_stringshare_add(ev->lines->line);
if (it) if (it)
{ {
Evry_Event_Item_Changed *ev = E_NEW(Evry_Event_Item_Changed, 1); Evry_Event_Item_Changed *ev = E_NEW(Evry_Event_Item_Changed, 1);
ev->item = it; ev->item = it;
evry_item_ref(it); evry_item_ref(it);
ecore_event_add(EVRY_EVENT_ITEM_CHANGED, ev, _cb_free_item_changed, NULL); ecore_event_add(EVRY_EVENT_ITEM_CHANGED, ev, _cb_free_item_changed, NULL);
} }
} }
@ -232,18 +232,16 @@ _plugins_init(void)
if (!evry_api_version_check(EVRY_API_VERSION)) if (!evry_api_version_check(EVRY_API_VERSION))
return EINA_FALSE; return EINA_FALSE;
p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Calculator"), type_subject, NULL, "TEXT", p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Calculator"), "accessories-calculator", "TEXT",
_begin, _cleanup, _fetch, NULL, NULL); _begin, _cleanup, _fetch, NULL);
p1->view_mode = VIEW_MODE_LIST; p1->view_mode = VIEW_MODE_LIST;
p1->aggregate = EINA_FALSE; p1->aggregate = EINA_FALSE;
p1->history = EINA_FALSE; p1->history = EINA_FALSE;
p1->async_fetch = EINA_TRUE; p1->async_fetch = EINA_TRUE;
p1->icon = "accessories-calculator";
p1->trigger = "="; p1->trigger = "=";
p1->action = &_action;
evry_plugin_register(p1, EVRY_PLUGIN_SUBJECT, 0);
evry_plugin_register(p1, 0);
return EINA_TRUE; return EINA_TRUE;
} }
@ -265,7 +263,7 @@ static Eina_Bool active = EINA_FALSE;
/***************************************************************************/ /***************************************************************************/
/**/ /**/
/* module setup */ /* module setup */
EAPI E_Module_Api e_modapi = EAPI E_Module_Api e_modapi =
{ {
E_MODULE_API_VERSION, E_MODULE_API_VERSION,
"everything-calc" "everything-calc"
@ -278,8 +276,8 @@ e_modapi_init(E_Module *m)
if (e_datastore_get("everything_loaded")) if (e_datastore_get("everything_loaded"))
active = _plugins_init(); active = _plugins_init();
e_module_delayed_set(m, 1); e_module_delayed_set(m, 1);
return m; return m;
} }
@ -288,7 +286,7 @@ EAPI int
e_modapi_shutdown(E_Module *m) e_modapi_shutdown(E_Module *m)
{ {
char *result; char *result;
if (active && e_datastore_get("everything_loaded")) if (active && e_datastore_get("everything_loaded"))
_plugins_shutdown(); _plugins_shutdown();
@ -296,7 +294,7 @@ e_modapi_shutdown(E_Module *m)
eina_stringshare_del(result); eina_stringshare_del(result);
module = NULL; module = NULL;
return 1; return 1;
} }
@ -308,4 +306,3 @@ e_modapi_save(E_Module *m)
/**/ /**/
/***************************************************************************/ /***************************************************************************/

View File

@ -75,6 +75,7 @@ static Eina_List *_actions = NULL;
static void _cleanup(Evry_Plugin *plugin); static void _cleanup(Evry_Plugin *plugin);
static const char *_mime_dir; static const char *_mime_dir;
static const char *_type_file;
static void static void
@ -121,7 +122,7 @@ _cb_sort(const void *data1, const void *data2)
static void static void
_item_free(Evry_Item *it) _item_free(Evry_Item *it)
{ {
ITEM_FILE(file, it); GET_FILE(file, it);
if (file->path) eina_stringshare_del(file->path); if (file->path) eina_stringshare_del(file->path);
if (file->mime) eina_stringshare_del(file->mime); if (file->mime) eina_stringshare_del(file->mime);
@ -172,10 +173,8 @@ _scan_func(void *data)
continue; continue;
} }
file = E_NEW(Evry_Item_File, 1); file = EVRY_ITEM_NEW(Evry_Item_File, p, NULL, NULL, _item_free);
if (!file) break;
evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), NULL, _item_free);
filename = strdup(dp->d_name); filename = strdup(dp->d_name);
EVRY_ITEM(file)->label = filename; EVRY_ITEM(file)->label = filename;
d->files = eina_list_append(d->files, file); d->files = eina_list_append(d->files, file);
@ -296,7 +295,7 @@ _scan_end_func(void *data)
EINA_LIST_FREE(d->files, item) EINA_LIST_FREE(d->files, item)
{ {
ITEM_FILE(file, item); GET_FILE(file, item);
filename = (char *)item->label; filename = (char *)item->label;
path = (char *) file->path; path = (char *) file->path;
@ -376,12 +375,10 @@ _dir_watcher(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const c
case ECORE_FILE_EVENT_CREATED_DIRECTORY: case ECORE_FILE_EVENT_CREATED_DIRECTORY:
case ECORE_FILE_EVENT_CREATED_FILE: case ECORE_FILE_EVENT_CREATED_FILE:
file = E_NEW(Evry_Item_File, 1);
if (!file) break;
label = ecore_file_file_get(path); label = ecore_file_file_get(path);
evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), label, _item_free); file = EVRY_ITEM_NEW(Evry_Item_File, p, label, NULL, _item_free);
file->path = eina_stringshare_add(path); file->path = eina_stringshare_add(path);
evry_util_file_detail_set(file); evry_util_file_detail_set(file);
@ -444,9 +441,9 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
Plugin *p = NULL; Plugin *p = NULL;
/* is FILE ? */ /* is FILE ? */
if (it && (it->plugin->type_out == plugin->type_in)) if (it && evry_item_type_check(it, "FILE", NULL))
{ {
ITEM_FILE(file, it); GET_FILE(file, it);
if (!file->path || !ecore_file_is_dir(file->path)) if (!file->path || !ecore_file_is_dir(file->path))
return NULL; return NULL;
@ -458,7 +455,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
p->directory = eina_stringshare_add(file->path); p->directory = eina_stringshare_add(file->path);
p->parent = EINA_TRUE; p->parent = EINA_TRUE;
} }
else else if (!it)
{ {
p = E_NEW(Plugin, 1); p = E_NEW(Plugin, 1);
p->base = *plugin; p->base = *plugin;
@ -467,6 +464,10 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
p->directory = eina_stringshare_add(e_user_homedir_get()); p->directory = eina_stringshare_add(e_user_homedir_get());
p->parent = EINA_FALSE; p->parent = EINA_FALSE;
} }
else
{
return NULL;
}
if (p->directory) if (p->directory)
_read_directory(p); _read_directory(p);
@ -487,7 +488,7 @@ _hist_add(Evry_Plugin *plugin, Evry_Item_File *file)
EINA_LIST_FOREACH(he->items, l, hi) EINA_LIST_FOREACH(he->items, l, hi)
{ {
if (hi->type != plugin->type_out) if (hi->type != _type_file)
continue; continue;
if (hi->data) if (hi->data)
@ -502,7 +503,7 @@ _hist_add(Evry_Plugin *plugin, Evry_Item_File *file)
static void static void
_cleanup(Evry_Plugin *plugin) _cleanup(Evry_Plugin *plugin)
{ {
PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
Evry_Item_File *file; Evry_Item_File *file;
@ -554,6 +555,15 @@ _hist_func(void *data)
{ {
if (!ecore_file_exists(file->path)) if (!ecore_file_exists(file->path))
p->hist_added = eina_list_remove_list(p->hist_added, l); p->hist_added = eina_list_remove_list(p->hist_added, l);
if (!file->mime)
{
file->mime = eina_stringshare_add(efreet_mime_type_get(file->path));
if ((!strcmp(file->mime, "inode/directory")) ||
(!strcmp(file->mime, "inode/mount-point")))
EVRY_ITEM(file)->browseable = EINA_TRUE;
}
} }
} }
@ -612,7 +622,7 @@ _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fda
EINA_LIST_FOREACH(he->items, l, hi) EINA_LIST_FOREACH(he->items, l, hi)
{ {
if (hi->type != p->base.type_out) if (hi->type != _type_file)
continue; continue;
/* filter out files that we already have from history */ /* filter out files that we already have from history */
@ -620,19 +630,11 @@ _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fda
if (!strcmp(file->path, key)) if (!strcmp(file->path, key))
return EINA_TRUE; return EINA_TRUE;
/* XXX this blocks ui when drive is sleeping */
/* if (!ecore_file_exists(key))
* continue; */
label = ecore_file_file_get(key); label = ecore_file_file_get(key);
if (!label) if (!label)
continue; continue;
file = E_NEW(Evry_Item_File, 1); file = EVRY_ITEM_NEW(Evry_Item_File, p, label, NULL, _item_free);
if (!file)
continue;
evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), label, _item_free);
file->path = eina_stringshare_add(key); file->path = eina_stringshare_add(key);
if (hi->data) if (hi->data)
@ -651,7 +653,6 @@ _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fda
EVRY_ITEM(file)->browseable = EINA_TRUE; EVRY_ITEM(file)->browseable = EINA_TRUE;
} }
/* p->files = eina_list_append(p->files, file); */
p->hist_added = eina_list_append(p->hist_added, file); p->hist_added = eina_list_append(p->hist_added, file);
break; break;
} }
@ -661,11 +662,9 @@ _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fda
static void static void
_folder_item_add(Plugin *p, const char *path) _folder_item_add(Plugin *p, const char *path)
{ {
Evry_Item_File *file = E_NEW(Evry_Item_File, 1); Evry_Item_File *file;
if (!file) return; file = EVRY_ITEM_NEW(Evry_Item_File, p, path, NULL, _item_free);
evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), path, _item_free);
file->path = eina_stringshare_add(path); file->path = eina_stringshare_add(path);
file->mime = eina_stringshare_ref(_mime_dir); file->mime = eina_stringshare_ref(_mime_dir);
EVRY_ITEM(file)->browseable = EINA_TRUE; EVRY_ITEM(file)->browseable = EINA_TRUE;
@ -700,7 +699,7 @@ _free_files(Plugin *p)
static int static int
_fetch(Evry_Plugin *plugin, const char *input) _fetch(Evry_Plugin *plugin, const char *input)
{ {
PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
Evry_Item_File *file; Evry_Item_File *file;
if (!p->command) if (!p->command)
@ -712,18 +711,39 @@ _fetch(Evry_Plugin *plugin, const char *input)
if (!p->parent && input && !strncmp(input, "/", 1)) if (!p->parent && input && !strncmp(input, "/", 1))
{ {
if (p->command != CMD_SHOW_ROOT) char *path = NULL;
if ((p->command != CMD_SHOW_ROOT) ||
((ecore_file_is_dir(input) ? (path = strdup(input)) : 0) ||
((path = ecore_file_dir_get(input)) &&
(strcmp(p->directory, path)))))
{ {
_free_files(p); _free_files(p);
eina_stringshare_del(p->directory); eina_stringshare_del(p->directory);
p->directory = eina_stringshare_add("/");
printf("scan %s - %s\n", path, p->directory);
if (path)
{
p->directory = eina_stringshare_add(path);
free(path);
}
else
{
p->directory = eina_stringshare_add("/");
}
_read_directory(p); _read_directory(p);
p->command = CMD_SHOW_ROOT; p->command = CMD_SHOW_ROOT;
return 0; return 0;
} }
int len = strlen(p->directory);
len = (len == 1) ? len : len+1;
p->input = eina_stringshare_add(input + len);
} }
else if (p->directory && input && !strncmp(input, "..", 2)) else if (p->directory && input && !strncmp(input, "..", 2))
{ {
@ -763,6 +783,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
p->command = CMD_SHOW_HIDDEN; p->command = CMD_SHOW_HIDDEN;
return 0; return 0;
} }
p->input = eina_stringshare_add(input + 1);
} }
else if (p->command) else if (p->command)
{ {
@ -802,13 +823,8 @@ _fetch(Evry_Plugin *plugin, const char *input)
} }
} }
if (input) if (input && !p->command)
{ p->input = eina_stringshare_add(input);
if (p->command)
p->input = eina_stringshare_add(input + 1);
else
p->input = eina_stringshare_add(input);
}
_append_files(p); _append_files(p);
@ -821,27 +837,10 @@ _fetch(Evry_Plugin *plugin, const char *input)
return 1; return 1;
} }
static Evas_Object * #define ACT_TRASH 1
_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) #define ACT_DELETE 2
{ #define ACT_COPY 3
Evas_Object *o = NULL; #define ACT_MOVE 4
ITEM_FILE(file, it);
if (!file->mime)
_item_fill(file);
if (!file->mime) return NULL;
if (it->browseable)
o = evry_icon_theme_get("folder", e);
else
o = evry_icon_mime_get(file->mime, e);
if (!o)
o = evry_icon_mime_get("unknown", e);
return o;
}
static int static int
_open_folder_check(Evry_Action *act __UNUSED__, const Evry_Item *it) _open_folder_check(Evry_Action *act __UNUSED__, const Evry_Item *it)
@ -860,7 +859,7 @@ _open_folder_action(Evry_Action *act)
m = e_manager_list(); m = e_manager_list();
ITEM_FILE(file, act->item1); GET_FILE(file, act->item1);
if (!act->item1->browseable) if (!act->item1->browseable)
{ {
@ -880,7 +879,7 @@ _open_folder_action(Evry_Action *act)
static int static int
_open_term_action(Evry_Action *act) _open_term_action(Evry_Action *act)
{ {
ITEM_FILE(file, act->item1); GET_FILE(file, act->item1);
Evry_Item_App *tmp; Evry_Item_App *tmp;
char cwd[4096]; char cwd[4096];
char *dir; char *dir;
@ -918,9 +917,9 @@ _file_trash_action(Evry_Action *act)
Efreet_Uri *uri; Efreet_Uri *uri;
int ok = 0; int ok = 0;
char buf[PATH_MAX]; char buf[PATH_MAX];
int force = !strcmp(act->data, "delete"); int force = (EVRY_ITEM_DATA_INT_GET(act) == ACT_DELETE);
ITEM_FILE(file, act->item1); GET_FILE(file, act->item1);
if (!file->url) if (!file->url)
{ {
@ -949,8 +948,8 @@ _file_trash_action(Evry_Action *act)
static int static int
_file_copy_action(Evry_Action *act) _file_copy_action(Evry_Action *act)
{ {
ITEM_FILE(file, act->item1); GET_FILE(file, act->item1);
ITEM_FILE(dst, act->item2); GET_FILE(dst, act->item2);
char *path; char *path;
char buf[PATH_MAX]; char buf[PATH_MAX];
@ -966,11 +965,11 @@ _file_copy_action(Evry_Action *act)
snprintf(buf, sizeof(buf), "%s/%s", path, act->item1->label); snprintf(buf, sizeof(buf), "%s/%s", path, act->item1->label);
free(path); free(path);
if (!strcmp((char *)act->data, "cp")) if (EVRY_ITEM_DATA_INT_GET(act) == ACT_COPY)
{ {
ret = ecore_file_cp(file->path, buf); ret = ecore_file_cp(file->path, buf);
} }
else if (!strcmp((char *)act->data, "mv")) else if (EVRY_ITEM_DATA_INT_GET(act) == ACT_MOVE)
{ {
ret = ecore_file_mv(file->path, buf); ret = ecore_file_mv(file->path, buf);
} }
@ -978,6 +977,11 @@ _file_copy_action(Evry_Action *act)
return ret; return ret;
} }
/* static int
* _complete(Evry_Plugin *p, const Evry_Item *item, char **input)
* {
* return 0;
* } */
static Eina_Bool static Eina_Bool
_plugins_init(void) _plugins_init(void)
@ -987,15 +991,14 @@ _plugins_init(void)
if (!evry_api_version_check(EVRY_API_VERSION)) if (!evry_api_version_check(EVRY_API_VERSION))
return EINA_FALSE; return EINA_FALSE;
p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Files"), type_subject, "FILE", "FILE", p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Files"), NULL, "FILE", _begin, _cleanup, _fetch, NULL);
_begin, _cleanup, _fetch, _icon_get, NULL); p1->config_path = "extensions/everything-files";
EVRY_PLUGIN(p1)->config_path = "extensions/everything-files"; evry_plugin_register(p1, EVRY_PLUGIN_SUBJECT, 3);
evry_plugin_register(p1, 3); /* p1->complete = &_complete; */
p2 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Files"), type_object, "FILE", "FILE", p2 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Files"), NULL, "FILE", _begin, _cleanup, _fetch, NULL);
_begin, _cleanup, _fetch, _icon_get, NULL); p2->config_path = "extensions/everything-files";
EVRY_PLUGIN(p2)->config_path = "extensions/everything-files"; evry_plugin_register(p2, EVRY_PLUGIN_OBJECT, 1);
evry_plugin_register(p2, 1);
act = EVRY_ACTION_NEW(N_("Open Folder (EFM)"), "FILE", NULL, "folder-open", act = EVRY_ACTION_NEW(N_("Open Folder (EFM)"), "FILE", NULL, "folder-open",
_open_folder_action, _open_folder_check); _open_folder_action, _open_folder_check);
@ -1009,26 +1012,26 @@ _plugins_init(void)
act = EVRY_ACTION_NEW(N_("Move to Trash"), "FILE", NULL, "edit-delete", act = EVRY_ACTION_NEW(N_("Move to Trash"), "FILE", NULL, "edit-delete",
_file_trash_action, NULL); _file_trash_action, NULL);
act->data = "trash"; EVRY_ITEM_DATA_INT_SET(act, ACT_TRASH);
evry_action_register(act, 2); evry_action_register(act, 2);
_actions = eina_list_append(_actions, act); _actions = eina_list_append(_actions, act);
act = EVRY_ACTION_NEW(N_("Delete"), "FILE", NULL, "list-remove", act = EVRY_ACTION_NEW(N_("Delete"), "FILE", NULL, "list-remove",
_file_trash_action, NULL); _file_trash_action, NULL);
act->data = "delete"; EVRY_ITEM_DATA_INT_SET(act, ACT_DELETE);
evry_action_register(act, 2); evry_action_register(act, 2);
_actions = eina_list_append(_actions, act); _actions = eina_list_append(_actions, act);
act = EVRY_ACTION_NEW(N_("Copy To ..."), "FILE", "FILE", "go-next", act = EVRY_ACTION_NEW(N_("Copy To ..."), "FILE", "FILE", "go-next",
_file_copy_action, NULL); _file_copy_action, NULL);
act->data = "cp"; EVRY_ITEM_DATA_INT_SET(act, ACT_COPY);
evry_action_register(act, 2); evry_action_register(act, 2);
_actions = eina_list_append(_actions, act); _actions = eina_list_append(_actions, act);
act = EVRY_ACTION_NEW(N_("Move To ..."), "FILE", "FILE", "go-next", act = EVRY_ACTION_NEW(N_("Move To ..."), "FILE", "FILE", "go-next",
_file_copy_action, NULL); _file_copy_action, NULL);
act->data = "mv"; EVRY_ITEM_DATA_INT_SET(act, ACT_MOVE);
evry_action_register(act, 2); evry_action_register(act, 2);
_actions = eina_list_append(_actions, act); _actions = eina_list_append(_actions, act);
@ -1250,6 +1253,7 @@ e_modapi_init(E_Module *m)
_conf_init(m); _conf_init(m);
_mime_dir = eina_stringshare_add("inode/directory"); _mime_dir = eina_stringshare_add("inode/directory");
_type_file = eina_stringshare_add("FILE");
e_module_delayed_set(m, 1); e_module_delayed_set(m, 1);
@ -1263,6 +1267,7 @@ e_modapi_shutdown(E_Module *m)
_plugins_shutdown(); _plugins_shutdown();
eina_stringshare_del(_mime_dir); eina_stringshare_del(_mime_dir);
eina_stringshare_del(_type_file);
_conf_shutdown(); _conf_shutdown();

View File

@ -15,12 +15,29 @@ _cleanup(Evry_Plugin *p)
EVRY_PLUGIN_ITEMS_FREE(p); EVRY_PLUGIN_ITEMS_FREE(p);
} }
static Evas_Object *
_icon_get(Evry_Item *it, Evas *e)
{
Evas_Object *o = NULL;
E_Configure_It *eci = it->data;
if (eci->icon)
{
if (!(o = evry_icon_theme_get(eci->icon, e)))
{
o = e_util_icon_add(eci->icon, e);
}
}
return o;
}
static void static void
_item_add(Evry_Plugin *p, E_Configure_It *eci, int match, int prio) _item_add(Evry_Plugin *p, E_Configure_It *eci, int match, int prio)
{ {
Evry_Item *it; Evry_Item *it;
it = evry_item_new(NULL, p, eci->label, NULL); it = EVRY_ITEM_NEW(Evry_Item, p, eci->label, _icon_get, NULL);
it->data = eci; it->data = eci;
it->priority = prio; it->priority = prio;
it->fuzzy_match = match; it->fuzzy_match = match;
@ -64,23 +81,6 @@ _fetch(Evry_Plugin *p, const char *input)
return 0; return 0;
} }
static Evas_Object *
_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
{
Evas_Object *o = NULL;
E_Configure_It *eci = it->data;
if (eci->icon)
{
if (!(o = evry_icon_theme_get(eci->icon, e)))
{
o = e_util_icon_add(eci->icon, e);
}
}
return o;
}
static int static int
_action(Evry_Action *act) _action(Evry_Action *act)
{ {
@ -123,11 +123,11 @@ _plugins_init(void)
if (!evry_api_version_check(EVRY_API_VERSION)) if (!evry_api_version_check(EVRY_API_VERSION))
return EINA_FALSE; return EINA_FALSE;
p = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Settings"), type_subject, NULL, "E_SETTINGS", p = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Settings"), NULL, "E_SETTINGS",
NULL, _cleanup, _fetch, _item_icon_get, NULL); NULL, _cleanup, _fetch, NULL);
evry_plugin_register(p, EVRY_PLUGIN_SUBJECT, 10);
evry_plugin_register(p, 10);
act = EVRY_ACTION_NEW(N_("Show Dialog"), "E_SETTINGS", NULL, act = EVRY_ACTION_NEW(N_("Show Dialog"), "E_SETTINGS", NULL,
"preferences-advanced", _action, NULL); "preferences-advanced", _action, NULL);
@ -146,16 +146,11 @@ _plugins_shutdown(void)
/***************************************************************************/ /***************************************************************************/
/**/
/* actual module specifics */
static E_Module *module = NULL; static E_Module *module = NULL;
static Eina_Bool active = EINA_FALSE; static Eina_Bool active = EINA_FALSE;
/***************************************************************************/ EAPI E_Module_Api e_modapi =
/**/
/* module setup */
EAPI E_Module_Api e_modapi =
{ {
E_MODULE_API_VERSION, E_MODULE_API_VERSION,
"everything-settings" "everything-settings"
@ -168,8 +163,8 @@ e_modapi_init(E_Module *m)
if (e_datastore_get("everything_loaded")) if (e_datastore_get("everything_loaded"))
active = _plugins_init(); active = _plugins_init();
e_module_delayed_set(m, 1); e_module_delayed_set(m, 1);
return m; return m;
} }
@ -181,7 +176,7 @@ e_modapi_shutdown(E_Module *m)
_plugins_shutdown(); _plugins_shutdown();
module = NULL; module = NULL;
return 1; return 1;
} }
@ -191,6 +186,4 @@ e_modapi_save(E_Module *m)
return 1; return 1;
} }
/**/
/***************************************************************************/ /***************************************************************************/

View File

@ -11,17 +11,7 @@
#define IMPORT_SCALE_ASPECT_IN 3 #define IMPORT_SCALE_ASPECT_IN 3
#define IMPORT_SCALE_ASPECT_OUT 4 #define IMPORT_SCALE_ASPECT_OUT 4
typedef struct _Plugin Plugin;
typedef struct _Import Import; typedef struct _Import Import;
typedef struct _Item Item;
struct _Plugin
{
Evry_Plugin base;
Plugin *prev;
Eina_List *items;
const Evry_Item_File *file;
};
struct _Import struct _Import
{ {
@ -36,197 +26,99 @@ struct _Import
char *fdest; char *fdest;
}; };
struct _Item
{
Evry_Item base;
const char *icon;
int method;
};
static void _import_edj_gen(Import *import); static void _import_edj_gen(Import *import);
static int _import_cb_edje_cc_exit(void *data, int type, void *event); static int _import_cb_edje_cc_exit(void *data, int type, void *event);
static Import *import = NULL; static Import *import = NULL;
static Evry_Plugin *_plug; static Evry_Action *_act;
static void
_item_free(Evry_Item *item)
{
Item *it = (Item*) item;
E_FREE(it);
}
static void
_item_add(Plugin *p, const char *name, int method, const char *icon)
{
Item *item = E_NEW(Item, 1);
evry_item_new(EVRY_ITEM(item), EVRY_PLUGIN(p), name, _item_free);
item->icon = icon;
item->method = method;
p->items = eina_list_append(p->items, EVRY_ITEM(item));
}
static Evas_Object *
_item_icon_get(Evry_Plugin *plugin, const Evry_Item *item, Evas *e)
{
return evry_icon_theme_get(((Item*)item)->icon, e);
}
static Evas_Object *
_icon_get(Evry_Plugin *plugin, const Evry_Item *it, Evas *e)
{
return evry_icon_theme_get("preferences-desktop-wallpaper", e);
}
static Evry_Plugin *
_begin(Evry_Plugin *plugin, const Evry_Item *item)
{
PLUGIN(p, plugin);
if (!item) return NULL;
/* is FILE ? */
if (item->plugin->type_out == plugin->type_in)
{
Evry_Item *it;
ITEM_FILE(file, item);
if (!file->mime || (strncmp(file->mime, "image/", 6)))
return NULL;
p = E_NEW(Plugin, 1);
p->base = *plugin;
p->base.items = NULL;
p->file = file;
it = evry_item_new(NULL, EVRY_PLUGIN(p), _("Set as Wallpaper"), NULL);
it->browseable = EINA_TRUE;
p->items = eina_list_append(p->items, it);
return EVRY_PLUGIN(p);
}
else if (item->plugin->type_out == plugin->type_out)
{
p = E_NEW(Plugin, 1);
p->base = *plugin;
p->base.items = NULL;
p->base.icon_get = &_item_icon_get;
p->prev = (Plugin*) item->plugin;
_item_add(p, _("Stretch"), IMPORT_STRETCH,
"enlightenment/wallpaper_stretch");
_item_add(p, _("Center"), IMPORT_CENTER,
"enlightenment/wallpaper_center");
_item_add(p, _("Tile"), IMPORT_TILE,
"enlightenment/wallpaper_tile");
_item_add(p, _("Within"), IMPORT_SCALE_ASPECT_IN,
"enlightenment/wallpaper_scale_aspect_in");
_item_add(p, _("Fill"), IMPORT_SCALE_ASPECT_OUT,
"enlightenment/wallpaper_stretch");
return EVRY_PLUGIN(p);
}
return NULL;
}
static void
_cleanup(Evry_Plugin *plugin)
{
PLUGIN(p, plugin);
Evry_Item *it;
EVRY_PLUGIN_ITEMS_CLEAR(p);
EINA_LIST_FREE(p->items, it)
evry_item_free(it);
E_FREE(p);
}
static int static int
_fetch(Evry_Plugin *plugin, const char *input) _action(Evry_Action *act)
{ {
PLUGIN(p, plugin); if (!evry_item_type_check(act->item1, "FILE", NULL))
Evry_Item *it = NULL; return 0;
Eina_List *l;
int match = 0;
EVRY_PLUGIN_ITEMS_CLEAR(p); GET_FILE(file, act->item1);
EINA_LIST_FOREACH(p->items, l, it) if (import)
if (!input || (match = evry_fuzzy_match(it->label, input))) {
{ if (import->exe_handler)
it->fuzzy_match = match; ecore_event_handler_del(import->exe_handler);
EVRY_PLUGIN_ITEM_APPEND(p, it); E_FREE(import);
} }
if (input) import = E_NEW(Import, 1);
plugin->items = evry_fuzzy_match_sort(plugin->items); import->method = EVRY_ITEM_DATA_INT_GET(act);
import->file = file->path;
import->quality = 100;
import->external = 0;
_import_edj_gen(import);
return 1; return 1;
} }
static int static int
_action(Evry_Plugin *plugin, const Evry_Item *act, const Evry_Item *item) _check(Evry_Action *act, const Evry_Item *it)
{ {
PLUGIN(p, plugin); GET_FILE(file, it);
if (p->prev && p->prev->file) if (file->mime && (!strncmp(file->mime, "image/", 6)))
{ return 1;
if (import)
{
if (import->exe_handler)
ecore_event_handler_del(import->exe_handler);
E_FREE(import);
}
Item *it = (Item*) item;
import = E_NEW(Import, 1);
import->method = it->method;
import->file = p->prev->file->path;
import->quality = 100;
import->external = 0;
_import_edj_gen(import);
return 1;
}
return 0; return 0;
} }
static void
_item_add(Evry_Item *it, const char *name, int method, const char *icon)
{
Evry_Action *act;
act = EVRY_ACTION_NEW(name, "FILE", NULL, icon, _action, NULL);
EVRY_ITEM_DATA_INT_SET(act, method);
EVRY_ITEM(act)->subtype = eina_stringshare_add("WALLPAPER");
it->items = eina_list_append(it->items, act);
}
static Eina_List *
_fetch(Evry_Action *act)
{
Evry_Item *it = (Evry_Item *) act;
it->items = NULL;
_item_add(it, _("Stretch"), IMPORT_STRETCH, "enlightenment/wallpaper_stretch");
_item_add(it, _("Center"), IMPORT_CENTER, "enlightenment/wallpaper_center");
_item_add(it, _("Tile"), IMPORT_TILE, "enlightenment/wallpaper_tile");
_item_add(it, _("Within"), IMPORT_SCALE_ASPECT_IN, "enlightenment/wallpaper_scale_aspect_in");
_item_add(it, _("Fill"), IMPORT_SCALE_ASPECT_OUT, "enlightenment/wallpaper_stretch");
return it->items;
}
static Eina_Bool static Eina_Bool
_plugins_init(void) _plugins_init(void)
{ {
if (!evry_api_version_check(EVRY_API_VERSION)) if (!evry_api_version_check(EVRY_API_VERSION))
return EINA_FALSE; return EINA_FALSE;
_plug = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Wallpaper"), type_action, "FILE", "", _act = EVRY_ACTION_NEW(_("Set as Wallpaper"),
_begin, _cleanup, _fetch, _icon_get, NULL); "FILE", NULL,
"preferences-desktop-wallpaper",
_plug->icon = "preferences-desktop-wallpaper"; NULL, _check);
_plug->action = &_action; _act->fetch = _fetch;
EVRY_ITEM(_act)->browseable = EINA_TRUE;
evry_plugin_register(_plug, 10);
evry_action_register(_act, 2);
return EINA_TRUE; return EINA_TRUE;
} }
static void static void
_plugins_shutdown(void) _plugins_shutdown(void)
{ {
EVRY_PLUGIN_FREE(_plug); evry_action_free(_act);
if (import)
{
if (import->exe_handler)
ecore_event_handler_del(import->exe_handler);
E_FREE(import);
}
} }
/* taken from e_int_config_wallpaper_import.c */ /* taken from e_int_config_wallpaper_import.c */
@ -288,7 +180,7 @@ _import_edj_gen(Import *import)
ecore_evas_free(ee); ecore_evas_free(ee);
printf("w%d h%d\n", w, h); printf("w%d h%d\n", w, h);
if (import->external) if (import->external)
{ {
fstrip = strdup(e_util_filename_escape(import->file)); fstrip = strdup(e_util_filename_escape(import->file));
@ -425,7 +317,7 @@ _import_cb_edje_cc_exit(void *data, int type, void *event)
import = data; import = data;
if (!ev->exe) return 1; if (!ev->exe) return 1;
if (ev->exe != import->exe) return 1; if (ev->exe != import->exe) return 1;
if (ev->exit_code != 0) if (ev->exit_code != 0)
@ -450,16 +342,11 @@ _import_cb_edje_cc_exit(void *data, int type, void *event)
} }
/***************************************************************************/ /***************************************************************************/
/**/
/* actual module specifics */
static E_Module *module = NULL; static E_Module *module = NULL;
static Eina_Bool active = EINA_FALSE; static Eina_Bool active = EINA_FALSE;
/***************************************************************************/ EAPI E_Module_Api e_modapi =
/**/
/* module setup */
EAPI E_Module_Api e_modapi =
{ {
E_MODULE_API_VERSION, E_MODULE_API_VERSION,
"everything-wallpaper" "everything-wallpaper"
@ -472,8 +359,8 @@ e_modapi_init(E_Module *m)
if (e_datastore_get("everything_loaded")) if (e_datastore_get("everything_loaded"))
active = _plugins_init(); active = _plugins_init();
e_module_delayed_set(m, 1); e_module_delayed_set(m, 1);
return m; return m;
} }
@ -484,8 +371,15 @@ e_modapi_shutdown(E_Module *m)
if (active && e_datastore_get("everything_loaded")) if (active && e_datastore_get("everything_loaded"))
_plugins_shutdown(); _plugins_shutdown();
if (import)
{
if (import->exe_handler)
ecore_event_handler_del(import->exe_handler);
E_FREE(import);
}
module = NULL; module = NULL;
return 1; return 1;
} }
@ -495,6 +389,4 @@ e_modapi_save(E_Module *m)
return 1; return 1;
} }
/**/
/***************************************************************************/ /***************************************************************************/

View File

@ -5,9 +5,16 @@
#include "Evry.h" #include "Evry.h"
#include "e_mod_main.h" #include "e_mod_main.h"
#define BORDER_SHOW 1
#define BORDER_HIDE 2
#define BORDER_FULLSCREEN 3
#define BORDER_TODESK 4
#define BORDER_CLOSE 5
static Evry_Plugin *p1; static Evry_Plugin *p1;
static Eina_List *handlers = NULL; static Eina_List *handlers = NULL;
static Eina_Hash *border_hash = NULL; static Eina_Hash *border_hash = NULL;
static Eina_List *_actions = NULL;
static int static int
_cb_border_remove(void *data, int type, void *event) _cb_border_remove(void *data, int type, void *event)
@ -21,7 +28,7 @@ _cb_border_remove(void *data, int type, void *event)
if (!it) return 1; if (!it) return 1;
p->items = eina_list_remove(p->items, it); p->items = eina_list_remove(p->items, it);
eina_hash_del_by_key(border_hash, &(ev->border)); eina_hash_del_by_key(border_hash, &(ev->border));
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD); evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
@ -41,8 +48,8 @@ _begin(Evry_Plugin *p, const Evry_Item *it)
(handlers, ecore_event_handler_add (handlers, ecore_event_handler_add
(E_EVENT_BORDER_REMOVE, _cb_border_remove, p)); (E_EVENT_BORDER_REMOVE, _cb_border_remove, p));
border_hash = eina_hash_pointer_new(_hash_free); border_hash = eina_hash_pointer_new(_hash_free);
return p; return p;
} }
@ -50,13 +57,13 @@ static void
_cleanup(Evry_Plugin *p) _cleanup(Evry_Plugin *p)
{ {
Ecore_Event_Handler *h; Ecore_Event_Handler *h;
EINA_LIST_FREE(handlers, h) EINA_LIST_FREE(handlers, h)
ecore_event_handler_del(h); ecore_event_handler_del(h);
if (border_hash) eina_hash_free(border_hash); if (border_hash) eina_hash_free(border_hash);
border_hash = NULL; border_hash = NULL;
EVRY_PLUGIN_ITEMS_CLEAR(p); EVRY_PLUGIN_ITEMS_CLEAR(p);
} }
@ -69,99 +76,8 @@ _item_free(Evry_Item *it)
E_FREE(it); E_FREE(it);
} }
static void
_item_add(Evry_Plugin *p, E_Border *bd, int match, int *prio)
{
Evry_Item *it = NULL;
if ((it = eina_hash_find(border_hash, &bd)))
{
it->priority = *prio;
EVRY_PLUGIN_ITEM_APPEND(p, it);
it->fuzzy_match = match;
*prio += 1;
return;
}
it = evry_item_new(NULL, p, e_border_name_get(bd), _item_free);
e_object_ref(E_OBJECT(bd));
it->data = bd;
it->fuzzy_match = match;
it->priority = *prio;
it->id = eina_stringshare_add(e_util_winid_str_get(bd->win));
*prio += 1;
eina_hash_add(border_hash, &bd, it);
EVRY_PLUGIN_ITEM_APPEND(p, it);
}
static int
_cb_sort(const void *data1, const void *data2)
{
const Evry_Item *it1 = data1;
const Evry_Item *it2 = data2;
if (it1->fuzzy_match - it2->fuzzy_match)
return (it1->fuzzy_match - it2->fuzzy_match);
return (it1->priority - it2->priority);
}
static int
_fetch(Evry_Plugin *p, const char *input)
{
E_Zone *zone;
E_Border *bd;
Eina_List *l;
int prio = 0;
int m1, m2;
EVRY_PLUGIN_ITEMS_CLEAR(p);
zone = e_util_zone_current_get(e_manager_current_get());
EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd)
{
if (zone == bd->zone)
{
if (!input)
_item_add(p, bd, 0, &prio);
else
{
m1 = evry_fuzzy_match(e_border_name_get(bd), input);
if (bd->client.icccm.name)
{
m2 = evry_fuzzy_match(bd->client.icccm.name, input);
if (!m1 || (m2 && m2 < m1))
m1 = m2;
}
if (bd->desktop)
{
m2 = evry_fuzzy_match(bd->desktop->name, input);
if (!m1 || (m2 && m2 < m1))
m1 = m2;
}
if (m1)
_item_add(p, bd, m1, &prio);
}
}
}
if (!p->items) return 0;
EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
return 1;
}
static Evas_Object * static Evas_Object *
_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) _icon_get(Evry_Item *it, Evas *e)
{ {
Evas_Object *o = NULL; Evas_Object *o = NULL;
E_Border *bd = it->data; E_Border *bd = it->data;
@ -235,280 +151,240 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
return o; return o;
} }
/********* border actions ********/
typedef struct _Inst Inst;
struct _Inst
{
E_Border *border;
};
static Evry_Plugin *p2 = NULL;
static Inst *inst = NULL;
static void static void
_act_cb_border_switch_to(E_Border *bd) _item_add(Evry_Plugin *p, E_Border *bd, int match, int *prio)
{ {
E_Zone *zone; Evry_Item *it = NULL;
zone = e_util_zone_current_get(e_manager_current_get()); if ((it = eina_hash_find(border_hash, &bd)))
{
it->priority = *prio;
EVRY_PLUGIN_ITEM_APPEND(p, it);
it->fuzzy_match = match;
*prio += 1;
return;
}
if (bd->desk != (e_desk_current_get(zone))) it = EVRY_ITEM_NEW(Evry_Item, p, e_border_name_get(bd), _icon_get, _item_free);
e_desk_show(bd->desk);
if (bd->shaded) e_object_ref(E_OBJECT(bd));
e_border_unshade(bd, E_DIRECTION_UP); it->data = bd;
it->fuzzy_match = match;
it->priority = *prio;
it->id = eina_stringshare_add(e_util_winid_str_get(bd->win));
if (bd->iconic) *prio += 1;
e_border_uniconify(bd);
else
e_border_raise(bd);
/* e_border_focus_set(bd, 1, 1); */ eina_hash_add(border_hash, &bd, it);
e_border_focus_set_with_pointer(bd);
}
static void EVRY_PLUGIN_ITEM_APPEND(p, it);
_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)
{
if (!bd->fullscreen)
e_border_fullscreen(bd, E_FULLSCREEN_RESIZE);
else
e_border_unfullscreen(bd);
}
static void
_act_cb_border_close(E_Border *bd)
{
if (!bd->lock_close) e_border_act_close_begin(bd);
}
static void
_act_cb_border_minimize(E_Border *bd)
{
if (!bd->lock_user_iconify) e_border_iconify(bd);
}
static void
_act_cb_border_unminimize(E_Border *bd)
{
if (!bd->lock_user_iconify) e_border_uniconify(bd);
}
static Evry_Plugin *
_act_begin(Evry_Plugin *p __UNUSED__, const Evry_Item *item)
{
E_Border *bd;
bd = item->data;
/* e_object_ref(E_OBJECT(bd)); */
inst->border = bd;
return p;
} }
static int static int
_act_cb_sort(const void *data1, const void *data2) _cb_sort(const void *data1, const void *data2)
{ {
const Evry_Item *it1 = data1; const Evry_Item *it1 = data1;
const Evry_Item *it2 = data2; const Evry_Item *it2 = data2;
return (it1->fuzzy_match - it2->fuzzy_match); if (it1->fuzzy_match - it2->fuzzy_match)
} return (it1->fuzzy_match - it2->fuzzy_match);
static void return (it1->priority - it2->priority);
_act_item_add(Evry_Plugin *p, const char *label, void (*action_cb) (E_Border *bd), const char *icon, const char *input)
{
Evry_Item *it;
int match = 1;
if (input)
match = evry_fuzzy_match(label, input);
if (!match) return;
it = evry_item_new(NULL, p, label, NULL);
it->icon = eina_stringshare_add(icon);
it->data = action_cb;
it->fuzzy_match = match;
p->items = eina_list_prepend(p->items, it);
}
static void
_act_cleanup(Evry_Plugin *p)
{
EVRY_PLUGIN_ITEMS_FREE(p);
} }
static int static int
_act_fetch(Evry_Plugin *p, const char *input) _fetch(Evry_Plugin *p, const char *input)
{ {
E_Zone *zone; E_Zone *zone;
E_Desk *desk; E_Border *bd;
Eina_List *l; Eina_List *l;
Evry_Item *it;
int prio = 0; int prio = 0;
int m1, m2;
EVRY_PLUGIN_ITEMS_CLEAR(p);
zone = e_util_zone_current_get(e_manager_current_get()); zone = e_util_zone_current_get(e_manager_current_get());
desk = e_desk_current_get(zone);
_act_cleanup(p); EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd)
{
if (zone == bd->zone)
{
if (!input)
_item_add(p, bd, 0, &prio);
else
{
m1 = evry_fuzzy_match(e_border_name_get(bd), input);
_act_item_add(p, _("Switch to Window"), if (bd->client.icccm.name)
_act_cb_border_switch_to, {
"go-next", input); m2 = evry_fuzzy_match(bd->client.icccm.name, input);
if (!m1 || (m2 && m2 < m1))
m1 = m2;
}
if (desk != inst->border->desk) if (bd->desktop)
_act_item_add(p, _("Send to Deskop"), {
_act_cb_border_to_desktop, m2 = evry_fuzzy_match(bd->desktop->name, input);
"go-previous", input); if (!m1 || (m2 && m2 < m1))
m1 = m2;
}
if (inst->border->iconic) if (m1)
_act_item_add(p, _("Uniconify"), _item_add(p, bd, m1, &prio);
_act_cb_border_unminimize, }
"window-minimize", input); }
else }
_act_item_add(p, _("Iconify"),
_act_cb_border_minimize,
"window-minimize", input);
if (!inst->border->fullscreen)
_act_item_add(p, _("Fullscreen"),
_act_cb_border_fullscreen,
"view-fullscreen", input);
else
_act_item_add(p, _("Unfullscreen"),
_act_cb_border_fullscreen,
"view-restore", input);
_act_item_add(p, _("Close"),
_act_cb_border_close,
"window-close", input);
if (!p->items) return 0; if (!p->items) return 0;
EVRY_PLUGIN_ITEMS_SORT(p, _act_cb_sort); EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
EINA_LIST_FOREACH(p->items, l, it)
it->priority = prio++;
return 1; return 1;
} }
static int static int
_act_action(Evry_Plugin *p __UNUSED__, const Evry_Item *act, const Evry_Item *item) _check_border(Evry_Action *act, const Evry_Item *it)
{ {
void (*border_action) (E_Border *bd); int action = EVRY_ITEM_DATA_INT_GET(act);
border_action = act->data;
border_action(((E_Border *)item->data));
return EVRY_ACTION_FINISHED; E_Border *bd = it->data;
E_Zone *zone = e_util_zone_current_get(e_manager_current_get());
switch (action)
{
case BORDER_CLOSE:
if (bd->lock_close)
return 0;
break;
case BORDER_SHOW:
if (bd->lock_focus_in)
return 0;
break;
case BORDER_HIDE:
if (bd->lock_user_iconify)
return 0;
break;
case BORDER_FULLSCREEN:
if (!bd->lock_user_fullscreen)
return 0;
break;
case BORDER_TODESK:
if (bd->desk == (e_desk_current_get(zone)))
return 0;
break;
}
return 1;
} }
static Evas_Object * static int
_act_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) _act_border(Evry_Action *act)
{ {
Evas_Object *o; int action = EVRY_ITEM_DATA_INT_GET(act);
o = evry_icon_theme_get(it->icon, e); E_Border *bd = act->item1->data;
E_Zone *zone = e_util_zone_current_get(e_manager_current_get());
return o; int focus = 0;
switch (action)
{
case BORDER_CLOSE:
e_border_act_close_begin(bd);
break;
case BORDER_SHOW:
if (bd->desk != (e_desk_current_get(zone)))
e_desk_show(bd->desk);
focus = 1;
break;
case BORDER_HIDE:
e_border_iconify(bd);
case BORDER_FULLSCREEN:
if (!bd->fullscreen)
e_border_fullscreen(bd, E_FULLSCREEN_RESIZE);
else
e_border_unfullscreen(bd);
case BORDER_TODESK:
if (bd->desk != (e_desk_current_get(zone)))
e_border_desk_set(bd, e_desk_current_get(zone));
focus = 1;
}
if (focus)
{
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_with_pointer(bd);
}
return 1;
} }
/* static int
* _exec_border_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
* {
* E_Border *bd = it->data;
* E_OBJECT_CHECK_RETURN(bd, 0);
* E_OBJECT_TYPE_CHECK_RETURN(bd, E_BORDER_TYPE, 0);
*
* if ((bd->desktop && bd->desktop->exec) &&
* ((strstr(bd->desktop->exec, "%u")) ||
* (strstr(bd->desktop->exec, "%U")) ||
* (strstr(bd->desktop->exec, "%f")) ||
* (strstr(bd->desktop->exec, "%F"))))
* return 1;
*
* return 0;
* }
*
* static int
* _exec_border_action(Evry_Action *act)
* {
* return evry_util_exec_app(act->item1, act->item2);
* }
*
* static int
* _exec_border_intercept(Evry_Action *act)
* {
* Evry_Item_App *app = E_NEW(Evry_Item_App, 1);
* E_Border *bd = act->item1->data;
*
* app->desktop = bd->desktop;
* act->item1 = EVRY_ITEM(app);
*
* return 1;
* }
*
*
* static void
* _exec_border_cleanup(Evry_Action *act)
* {
* ITEM_APP(app, act->item1);
* E_FREE(app);
* } */
static Eina_Bool static Eina_Bool
_plugins_init(void) _plugins_init(void)
{ {
Evry_Action *act;
if (!evry_api_version_check(EVRY_API_VERSION)) if (!evry_api_version_check(EVRY_API_VERSION))
return EINA_FALSE; return EINA_FALSE;
p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Windows"), type_subject, NULL, "BORDER", p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Windows"), NULL, "BORDER",
_begin, _cleanup, _fetch, _item_icon_get, NULL); _begin, _cleanup, _fetch, NULL);
p1->transient = EINA_TRUE; p1->transient = EINA_TRUE;
evry_plugin_register(p1, 2); evry_plugin_register(p1, EVRY_PLUGIN_SUBJECT, 2);
p2 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Window Action"), type_action, "BORDER", NULL,
_act_begin, _act_cleanup, _act_fetch, _act_item_icon_get, NULL);
EVRY_PLUGIN(p2)->action = &_act_action;
evry_plugin_register(p2, 1);
/* act = evry_action_new("Open File...", "BORDER", "FILE", "APPLICATION", act = EVRY_ACTION_NEW(_("Switch to Window"),
* "everything-launch", "BORDER", NULL, "go-next",
* _exec_border_action, _exec_border_check_item, _act_border, _check_border);
* _exec_border_cleanup, _exec_border_intercept, NULL, NULL); EVRY_ITEM_DATA_INT_SET(act, BORDER_SHOW);
* evry_action_register(act, 10); */ evry_action_register(act, 1);
_actions = eina_list_append(_actions, act);
act = EVRY_ACTION_NEW(_("Iconify"),
"BORDER", NULL, "iconic",
_act_border, _check_border);
EVRY_ITEM_DATA_INT_SET(act, BORDER_HIDE);
_actions = eina_list_append(_actions, act);
evry_action_register(act, 2);
act = EVRY_ACTION_NEW(_("Toggle Fullscreen"),
"BORDER", NULL, "view-fullscreen",
_act_border, _check_border);
EVRY_ITEM_DATA_INT_SET(act, BORDER_FULLSCREEN);
_actions = eina_list_append(_actions, act);
evry_action_register(act, 4);
act = EVRY_ACTION_NEW(_("Close"),
"BORDER", NULL, "view-fullscreen",
_act_border, _check_border);
EVRY_ITEM_DATA_INT_SET(act, BORDER_CLOSE);
_actions = eina_list_append(_actions, act);
evry_action_register(act, 3);
act = EVRY_ACTION_NEW(_("Send to Desktop"),
"BORDER", NULL, "go-previous",
_act_border, _check_border);
EVRY_ITEM_DATA_INT_SET(act, BORDER_TODESK);
_actions = eina_list_append(_actions, act);
evry_action_register(act, 3);
return EINA_TRUE; return EINA_TRUE;
} }
@ -516,23 +392,20 @@ _plugins_init(void)
static void static void
_plugins_shutdown(void) _plugins_shutdown(void)
{ {
EVRY_PLUGIN_FREE(p1); Evry_Action *act;
EVRY_PLUGIN_FREE(p2);
/* evry_action_free(act); */ EVRY_PLUGIN_FREE(p1);
EINA_LIST_FREE(_actions, act)
evry_action_free(act);
} }
/***************************************************************************/ /***************************************************************************/
/**/
/* actual module specifics */
static E_Module *module = NULL; static E_Module *module = NULL;
static Eina_Bool active = EINA_FALSE; static Eina_Bool active = EINA_FALSE;
/***************************************************************************/ EAPI E_Module_Api e_modapi =
/**/
/* module setup */
EAPI E_Module_Api e_modapi =
{ {
E_MODULE_API_VERSION, E_MODULE_API_VERSION,
"everything-windows" "everything-windows"
@ -545,11 +418,9 @@ e_modapi_init(E_Module *m)
if (e_datastore_get("everything_loaded")) if (e_datastore_get("everything_loaded"))
active = _plugins_init(); active = _plugins_init();
e_module_delayed_set(m, 1);
inst = E_NEW(Inst, 1); e_module_delayed_set(m, 1);
return m; return m;
} }
@ -559,10 +430,8 @@ e_modapi_shutdown(E_Module *m)
if (active && e_datastore_get("everything_loaded")) if (active && e_datastore_get("everything_loaded"))
_plugins_shutdown(); _plugins_shutdown();
E_FREE(inst);
module = NULL; module = NULL;
return 1; return 1;
} }
@ -572,6 +441,4 @@ e_modapi_save(E_Module *m)
return 1; return 1;
} }
/**/
/***************************************************************************/ /***************************************************************************/

View File

@ -3,7 +3,7 @@
#include "e.h" #include "e.h"
#define EVRY_API_VERSION 5 #define EVRY_API_VERSION 7
#define EVRY_ACTION_OTHER 0 #define EVRY_ACTION_OTHER 0
#define EVRY_ACTION_FINISHED 1 #define EVRY_ACTION_FINISHED 1
@ -22,6 +22,11 @@
#define VIEW_MODE_DETAIL 1 #define VIEW_MODE_DETAIL 1
#define VIEW_MODE_THUMB 2 #define VIEW_MODE_THUMB 2
#define EVRY_PLUGIN_SUBJECT 0
#define EVRY_PLUGIN_ACTION 1
#define EVRY_PLUGIN_OBJECT 2
extern int _e_module_evry_log_dom; extern int _e_module_evry_log_dom;
#ifndef EINA_LOG_DEFAULT_COLOR #ifndef EINA_LOG_DEFAULT_COLOR
@ -54,39 +59,58 @@ typedef struct _Plugin_Setting Plugin_Setting;
#define EVRY_ITEM(_item) ((Evry_Item *)_item) #define EVRY_ITEM(_item) ((Evry_Item *)_item)
#define EVRY_ACTN(_item) ((Evry_Action *) _item)
#define EVRY_PLUGIN(_plugin) ((Evry_Plugin *) _plugin) #define EVRY_PLUGIN(_plugin) ((Evry_Plugin *) _plugin)
#define EVRY_VIEW(_view) ((Evry_View *) _view) #define EVRY_VIEW(_view) ((Evry_View *) _view)
#define ITEM_FILE(_file, _item) Evry_Item_File *_file = (Evry_Item_File *) _item
#define ACTION_GET(_act, _item) Evry_Action *_act = (Evry_Action *) _item
#define ITEM_APP(_app, _item) Evry_Item_App *_app = (Evry_Item_App *) _item
#define PLUGIN(_p, _plugin) Plugin *_p = (Plugin*) _plugin
#define VIEW(_v, _view) View *_v = (View*) _view
#define EVRY_PLUGIN_ITEMS_CLEAR(_p) \ #define GET_APP(_app, _item) Evry_Item_App *_app = (Evry_Item_App *) _item
if (EVRY_PLUGIN(_p)->items) \ #define GET_FILE(_file, _item) Evry_Item_File *_file = (Evry_Item_File *) _item
eina_list_free(EVRY_PLUGIN(_p)->items); \ #define GET_EVRY_PLUGIN(_p, _plugin) Evry_Plugin *_p = (Evry_Plugin*) _plugin
#define GET_VIEW(_v, _view) View *_v = (View*) _view
#define GET_ACTION(_act, _item) Evry_Action *_act = (Evry_Action *) _item
#define GET_PLUGIN(_p, _plugin) Plugin *_p = (Plugin*) _plugin
#define EVRY_ITEM_DATA_INT_SET(_item, _data) ((Evry_Item *)_item)->data = (void*)(long) _data
#define EVRY_ITEM_DATA_INT_GET(_item) (long) ((Evry_Item *)_item)->data
#define EVRY_ITEM_ICON_SET(_item, _icon) ((Evry_Item *)_item)->icon = _icon
#define EVRY_ITEM_NEW(_base, _plugin, _label, _icon_get, _free) \
(_base *) evry_item_new(EVRY_ITEM(E_NEW(_base, 1)), EVRY_PLUGIN(_plugin), _label, _icon_get, _free);
#define EVRY_PLUGIN_NEW(_base, _name, _icon, _item_type, _begin, _cleanup, _fetch, _free) \
evry_plugin_new(EVRY_PLUGIN(E_NEW(_base, 1)), _name, _(_name), _icon, _item_type, _begin, _cleanup, _fetch, _free) \
#define EVRY_ACTION_NEW(_name, _in1, _in2, _icon, _action, _check) \
evry_action_new(_name, _(_name), _in1, _in2, _icon, _action, _check)
#define EVRY_PLUGIN_FREE(_p) \
if (_p) evry_plugin_free(EVRY_PLUGIN(_p));
#define EVRY_PLUGIN_ITEMS_CLEAR(_p) \
if (EVRY_PLUGIN(_p)->items) \
eina_list_free(EVRY_PLUGIN(_p)->items); \
EVRY_PLUGIN(_p)->items = NULL; EVRY_PLUGIN(_p)->items = NULL;
#define EVRY_PLUGIN_ITEMS_FREE(_p) \
Evry_Item *evryitem; \
EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, evryitem) \
evry_item_free(evryitem);
#define EVRY_PLUGIN_ITEMS_SORT(_p, _sortcb) \ #define EVRY_PLUGIN_ITEMS_FREE(_p) \
EVRY_PLUGIN(_p)->items = eina_list_sort \ Evry_Item *evryitem; \
(EVRY_PLUGIN(_p)->items, \ EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, evryitem) \
eina_list_count(EVRY_PLUGIN(_p)->items), _sortcb); \ evry_item_free(evryitem)
#define EVRY_PLUGIN_ITEMS_SORT(_p, _sortcb) \
EVRY_PLUGIN(_p)->items = eina_list_sort \
(EVRY_PLUGIN(_p)->items, eina_list_count(EVRY_PLUGIN(_p)->items), _sortcb)
#define EVRY_PLUGIN_ITEM_APPEND(_p, _item) \
EVRY_PLUGIN(_p)->items = eina_list_append(EVRY_PLUGIN(_p)->items, EVRY_ITEM(_item))
#define EVRY_PLUGIN_ITEM_APPEND(_p, _item) \
EVRY_PLUGIN(_p)->items = \
eina_list_append(EVRY_PLUGIN(_p)->items, EVRY_ITEM(_item)) \
/* if you extended a plugin struct and you are sure
not to have any data lying around after cleanup you
can use this */
#define EVRY_PLUGIN_FREE(_p) \
if (_p) evry_plugin_free(EVRY_PLUGIN(_p), 0); \
E_FREE(_p);
struct _Evry_Item struct _Evry_Item
{ {
@ -119,16 +143,21 @@ struct _Evry_Item
* was performed on a file with a specific mimetype */ * was performed on a file with a specific mimetype */
const char *context; const char *context;
const char *type;
/* optional */ /* optional */
const char *subtype; const char *subtype;
Eina_List *items;
Evas_Object *(*icon_get) (Evry_Item *it, Evas *e);
void (*free) (Evry_Item *item);
/* do not set by plugin! */ /* do not set by plugin! */
Evry_Item *next;
Eina_Bool selected; Eina_Bool selected;
Eina_Bool marked; Eina_Bool marked;
Evry_Plugin *plugin; Evry_Plugin *plugin;
int ref; int ref;
void (*free) (Evry_Item *item);
double usage; double usage;
}; };
@ -147,17 +176,14 @@ struct _Evry_Action
int (*action) (Evry_Action *act); int (*action) (Evry_Action *act);
int (*check_item) (Evry_Action *act, const Evry_Item *it); int (*check_item) (Evry_Action *act, const Evry_Item *it);
int (*intercept) (Evry_Action *act); void (*free) (Evry_Action *act);
void (*cleanup) (Evry_Action *act); /* when action is browseable */
Eina_List *(*actions) (Evry_Action *act); Eina_List *(*fetch) (Evry_Action *act);
Evas_Object *(*icon_get) (Evry_Action *act, Evas *e);
void *data;
}; };
struct _Evry_Item_App struct _Evry_Item_App
{ {
Evry_Item base; Evry_Action base;
const char *file; const char *file;
Efreet_Desktop *desktop; Efreet_Desktop *desktop;
}; };
@ -172,32 +198,18 @@ struct _Evry_Item_File
struct _Evry_Plugin struct _Evry_Plugin
{ {
Evry_Item base;
/* identifier */ /* identifier */
const char *name; const char *name;
/* shown title */
const char *label;
/* provide default icon */
const char *icon;
/* use plugin for first second or third part of an action
if actions are no dynamical lists better use Evry_Action */
enum { type_subject, type_action, type_object } type;
/* plugin provides items of this type */
const char *type_out;
/* plugin accepts this type in begin function */
const char *type_in;
/* show this plugin only when triggered */ /* show this plugin only when triggered */
const char *trigger; const char *trigger;
/* list of items visible for everything */ /* list of items visible for everything after fetch */
Eina_List *items; Eina_List *items;
/* run when plugin is activated. when returns positve it is added /* run when plugin is activated. when returns plugin it is added
to the list of current plugins and queried for results */ to the list of current plugins and queried for results */
Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item); Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item);
@ -205,13 +217,7 @@ struct _Evry_Plugin
int (*fetch) (Evry_Plugin *p, const char *input); int (*fetch) (Evry_Plugin *p, const char *input);
/* run when state is removed in which this plugin is active */ /* run when state is removed in which this plugin is active */
void (*cleanup) (Evry_Plugin *p); void (*finish) (Evry_Plugin *p);
/* get an icon for an item. will be freed automatically */
Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e);
/* only used when plugin is of type_action */
int (*action) (Evry_Plugin *p, const Evry_Item *act, const Evry_Item *subj);
/* try to complete current item: /* try to complete current item:
return: EVRY_COMPLETE_INPUT when input was changed return: EVRY_COMPLETE_INPUT when input was changed
@ -224,9 +230,6 @@ struct _Evry_Plugin
/* optional: use this when you extend the plugin struct */ /* optional: use this when you extend the plugin struct */
void (*free) (Evry_Plugin *p); void (*free) (Evry_Plugin *p);
/* return an object to be embedded in list view */
/* Evas_Object *(*info_get) (Evry_Plugin *p, Evas *e); */
/* show in aggregator */ /* show in aggregator */
/* default TRUE */ /* default TRUE */
Eina_Bool aggregate; Eina_Bool aggregate;
@ -249,8 +252,6 @@ struct _Evry_Plugin
/* not to be set by plugin! */ /* not to be set by plugin! */
Plugin_Config *config; Plugin_Config *config;
Eina_Bool changed;
/* config path registered for the module */ /* config path registered for the module */
const char *config_path; const char *config_path;
}; };
@ -389,11 +390,6 @@ struct _History_Item
const char *data; const char *data;
}; };
#define EVRY_PLUGIN_NEW(_base, _name, _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \
evry_plugin_new(EVRY_PLUGIN(E_NEW(_base, 1)), _name, _(_name), _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \
#define EVRY_ACTION_NEW(_name, _in1, _in2, _icon, _action, _check) \
evry_action_new(_name, _(_name), _in1, _in2, _icon, _action, _check)
/* evry.c */ /* evry.c */
EAPI void evry_item_select(const Evry_State *s, Evry_Item *it); EAPI void evry_item_select(const Evry_State *s, Evry_Item *it);
@ -401,12 +397,14 @@ EAPI void evry_item_mark(const Evry_State *state, Evry_Item *it, Eina_Bool mark)
EAPI void evry_plugin_select(const Evry_State *s, Evry_Plugin *p); EAPI void evry_plugin_select(const Evry_State *s, Evry_Plugin *p);
EAPI int evry_list_win_show(void); EAPI int evry_list_win_show(void);
EAPI void evry_list_win_hide(void); EAPI void evry_list_win_hide(void);
EAPI Evry_Item *evry_item_new(Evry_Item *base, Evry_Plugin *p, const char *label, void (*cb_free) (Evry_Item *item)); EAPI Evry_Item *evry_item_new(Evry_Item *base, Evry_Plugin *p, const char *label,
Evas_Object *(*icon_get) (Evry_Item *it, Evas *e),
void (*cb_free) (Evry_Item *item));
EAPI void evry_item_free(Evry_Item *it); EAPI void evry_item_free(Evry_Item *it);
EAPI void evry_item_ref(Evry_Item *it); EAPI void evry_item_ref(Evry_Item *it);
EAPI int evry_item_type_check(const Evry_Item *it, const char *type); EAPI int evry_item_type_check(const Evry_Item *it, const char *type, const char *subtype);
EAPI void evry_plugin_async_update(Evry_Plugin *plugin, int state); EAPI void evry_plugin_async_update(Evry_Plugin *plugin, int state);
EAPI void evry_clear_input(void); EAPI void evry_clear_input(Evry_Plugin *p);
/* evry_util.c */ /* evry_util.c */
EAPI Evas_Object *evry_icon_mime_get(const char *mime, Evas *e); EAPI Evas_Object *evry_icon_mime_get(const char *mime, Evas *e);
@ -418,11 +416,11 @@ EAPI char *evry_util_url_escape(const char *string, int inlength);
EAPI char *evry_util_unescape(const char *string, int length); EAPI char *evry_util_unescape(const char *string, int length);
EAPI void evry_util_file_detail_set(Evry_Item_File *file); EAPI void evry_util_file_detail_set(Evry_Item_File *file);
EAPI Eina_Bool evry_util_module_config_check(const char *module_name, int conf, int epoch, int version); EAPI Eina_Bool evry_util_module_config_check(const char *module_name, int conf, int epoch, int version);
EAPI Evas_Object *evry_util_icon_get(Evry_Item *it, Evas *e);
/* e_mod_main.c */ /* e_mod_main.c */
/* set plugin trigger and view mode first before register !*/ /* set plugin trigger and view mode first before register !*/
EAPI void evry_plugin_register(Evry_Plugin *p, int priority); EAPI void evry_plugin_register(Evry_Plugin *p, int type, int priority);
EAPI void evry_plugin_unregister(Evry_Plugin *p); EAPI void evry_plugin_unregister(Evry_Plugin *p);
EAPI void evry_action_register(Evry_Action *act, int priority); EAPI void evry_action_register(Evry_Action *act, int priority);
EAPI void evry_action_unregister(Evry_Action *act); EAPI void evry_action_unregister(Evry_Action *act);
@ -434,15 +432,14 @@ EAPI void evry_history_unload(void);
EAPI History_Item *evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *input); EAPI History_Item *evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *input);
EAPI int evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, const char *ctxt); EAPI int evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, const char *ctxt);
EAPI Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, int type, EAPI Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, const char *icon,
const char *type_in, const char *type_out, const char *item_type,
Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item), Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item),
void (*cleanup) (Evry_Plugin *p), void (*cleanup) (Evry_Plugin *p),
int (*fetch) (Evry_Plugin *p, const char *input), int (*fetch) (Evry_Plugin *p, const char *input),
Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e),
void (*free) (Evry_Plugin *p)); void (*free) (Evry_Plugin *p));
EAPI void evry_plugin_free(Evry_Plugin *p, int free_pointer); EAPI void evry_plugin_free(Evry_Plugin *p);
EAPI Evry_Action *evry_action_new(const char *name, const char *label, EAPI Evry_Action *evry_action_new(const char *name, const char *label,
const char *type_in1, const char *type_in2, const char *type_in1, const char *type_in2,

View File

@ -62,6 +62,7 @@ e_modapi_init(E_Module *m)
_config_init(); _config_init();
evry_history_init(); evry_history_init();
evry_plug_actions_init();
view_thumb_init(); view_thumb_init();
view_help_init(); view_help_init();
evry_plug_clipboard_init(); evry_plug_clipboard_init();
@ -132,7 +133,7 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
view_help_shutdown(); view_help_shutdown();
evry_plug_clipboard_shutdown(); evry_plug_clipboard_shutdown();
evry_plug_text_shutdown(); evry_plug_text_shutdown();
evry_plug_actions_shutdown();
/* EINA_LIST_FREE(evry_conf->plugins, p) /* EINA_LIST_FREE(evry_conf->plugins, p)
* evry_plugin_free(p, 1); */ * evry_plugin_free(p, 1); */
@ -260,7 +261,7 @@ _config_init()
evry_conf->hide_list = 0; evry_conf->hide_list = 0;
evry_conf->version = CONFIG_VERSION; evry_conf->version = CONFIG_VERSION;
} }
if (evry_conf && evry_conf->version != CONFIG_VERSION) if (evry_conf && evry_conf->version != CONFIG_VERSION)
{ {
_config_free(); _config_free();
@ -308,7 +309,7 @@ _config_free(void)
{ {
if (pc->name) eina_stringshare_del(pc->name); if (pc->name) eina_stringshare_del(pc->name);
if (pc->trigger) eina_stringshare_del(pc->trigger); if (pc->trigger) eina_stringshare_del(pc->trigger);
if (pc->plugin) evry_plugin_free(pc->plugin, 1); if (pc->plugin) evry_plugin_free(pc->plugin);
E_FREE(pc); E_FREE(pc);
} }
} }
@ -405,13 +406,29 @@ _evry_cb_plugin_sort(const void *data1, const void *data2)
return pc1->priority - pc2->priority; return pc1->priority - pc2->priority;
} }
void
_evry_plugin_free(Evry_Item *it)
{
GET_EVRY_PLUGIN(p, it);
evry_plugin_unregister(p);
DBG("%s", p->name);
if (p->config) p->config->plugin = NULL;
if (p->name) eina_stringshare_del(p->name);
if (p->free)
p->free(p);
else
E_FREE(p);
}
Evry_Plugin * Evry_Plugin *
evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, int type, evry_plugin_new(Evry_Plugin *base, const char *name, const char *label,
const char *type_in, const char *type_out, const char *icon, const char *item_type,
Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item), Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item),
void (*cleanup) (Evry_Plugin *p), void (*finish) (Evry_Plugin *p),
int (*fetch) (Evry_Plugin *p, const char *input), int (*fetch) (Evry_Plugin *p, const char *input),
Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e),
void (*cb_free) (Evry_Plugin *p)) void (*cb_free) (Evry_Plugin *p))
{ {
Evry_Plugin *p; Evry_Plugin *p;
@ -421,59 +438,54 @@ evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, int type
else else
p = E_NEW(Evry_Plugin, 1); p = E_NEW(Evry_Plugin, 1);
p->name = eina_stringshare_add(name); evry_item_new(EVRY_ITEM(p), NULL, label, NULL, _evry_plugin_free);
p->label = eina_stringshare_add(label);
p->type = type;
p->type_in = (type_in ? eina_stringshare_add(type_in) : NULL);
p->type_out = (type_out ? eina_stringshare_add(type_out) : NULL);
p->begin = begin;
p->cleanup = cleanup;
p->fetch = fetch;
p->icon_get = icon_get;
p->aggregate = EINA_TRUE;
p->async_fetch = EINA_FALSE;
p->free = cb_free;
p->history = EINA_TRUE; p->base.icon = icon;
p->view_mode = VIEW_MODE_NONE; p->base.type = eina_stringshare_add("PLUGIN");
if (item_type)
p->base.subtype = eina_stringshare_add(item_type);
p->name = eina_stringshare_add(name);
p->begin = begin;
p->finish = finish;
p->fetch = fetch;
p->aggregate = EINA_TRUE;
p->async_fetch = EINA_FALSE;
p->history = EINA_TRUE;
p->view_mode = VIEW_MODE_NONE;
p->free = cb_free;
return p; return p;
} }
void void
evry_plugin_free(Evry_Plugin *p, int free_pointer) evry_plugin_free(Evry_Plugin *p)
{ {
evry_plugin_unregister(p); evry_plugin_unregister(p);
DBG("%s", p->name); evry_item_free(EVRY_ITEM(p));
if (p->config) p->config->plugin = NULL;
if (p->name) eina_stringshare_del(p->name);
if (p->label) eina_stringshare_del(p->label);
if (p->type_in) eina_stringshare_del(p->type_in);
if (p->type_out) eina_stringshare_del(p->type_out);
if (p->free)
p->free(p);
else if (!free_pointer)
return;
else
E_FREE(p);
} }
/* TODO make int return */ /* TODO make int return */
void void
evry_plugin_register(Evry_Plugin *p, int priority) evry_plugin_register(Evry_Plugin *p, int type, int priority)
{ {
Eina_List *l; Eina_List *l;
Plugin_Config *pc; Plugin_Config *pc;
Eina_List *conf[3]; Eina_List *conf[3];
int i = 0; int i = 0;
if (type < 0 || type > 2)
return;
conf[0] = evry_conf->conf_subjects; conf[0] = evry_conf->conf_subjects;
conf[1] = evry_conf->conf_actions; conf[1] = evry_conf->conf_actions;
conf[2] = evry_conf->conf_objects; conf[2] = evry_conf->conf_objects;
EINA_LIST_FOREACH(conf[p->type], l, pc) EINA_LIST_FOREACH(conf[type], l, pc)
if (pc->name && p->name && !strcmp(pc->name, p->name)) if (pc->name && p->name && !strcmp(pc->name, p->name))
break; break;
@ -489,22 +501,22 @@ evry_plugin_register(Evry_Plugin *p, int priority)
pc->trigger = eina_stringshare_add(p->trigger); pc->trigger = eina_stringshare_add(p->trigger);
pc->trigger_only = 1; pc->trigger_only = 1;
} }
conf[p->type] = eina_list_append(conf[p->type], pc); conf[type] = eina_list_append(conf[type], pc);
} }
p->config = pc; p->config = pc;
pc->plugin = p; pc->plugin = p;
conf[p->type] = eina_list_sort(conf[p->type], -1, _evry_cb_plugin_sort); conf[type] = eina_list_sort(conf[type], -1, _evry_cb_plugin_sort);
EINA_LIST_FOREACH(conf[p->type], l, pc) EINA_LIST_FOREACH(conf[type], l, pc)
pc->priority = i++; pc->priority = i++;
evry_conf->conf_subjects = conf[0]; evry_conf->conf_subjects = conf[0];
evry_conf->conf_actions = conf[1]; evry_conf->conf_actions = conf[1];
evry_conf->conf_objects = conf[2]; evry_conf->conf_objects = conf[2];
if (p->type == type_subject && !p->type_in) if (type == EVRY_PLUGIN_SUBJECT)
{ {
char buf[256]; char buf[256];
snprintf(buf, sizeof(buf), _("Show %s Plugin"), p->name); snprintf(buf, sizeof(buf), _("Show %s Plugin"), p->name);
@ -519,7 +531,7 @@ evry_plugin_unregister(Evry_Plugin *p)
{ {
DBG("%s", p->name); DBG("%s", p->name);
if (p->type == type_subject) if (eina_list_data_find_list(evry_conf->conf_subjects, p->config))
{ {
char buf[256]; char buf[256];
snprintf(buf, sizeof(buf), _("Show %s Plugin"), p->name); snprintf(buf, sizeof(buf), _("Show %s Plugin"), p->name);

View File

@ -91,6 +91,9 @@ int evry_show(E_Zone *zone, const char *params);
void evry_hide(void); void evry_hide(void);
Evry_Plugin *evry_plug_aggregator_new(Evry_Selector *selector, int type); Evry_Plugin *evry_plug_aggregator_new(Evry_Selector *selector, int type);
int evry_plug_actions_init();
void evry_plug_actions_shutdown();
Evry_Plugin *evry_plug_actions_new(Evry_Selector *selector, int type); Evry_Plugin *evry_plug_actions_new(Evry_Selector *selector, int type);
void evry_history_init(void); void evry_history_init(void);

View File

@ -57,6 +57,7 @@ static int _evry_selector_subjects_get(const char *plugin_name);
static int _evry_selector_actions_get(Evry_Item *it); static int _evry_selector_actions_get(Evry_Item *it);
static int _evry_selector_objects_get(Evry_Action *act); static int _evry_selector_objects_get(Evry_Action *act);
static void _evry_selector_update_actions(Evry_Selector *sel); static void _evry_selector_update_actions(Evry_Selector *sel);
static Evry_Selector *_evry_selector_for_plugin_get(Evry_Plugin *p);
static Evry_Window *_evry_window_new(E_Zone *zone); static Evry_Window *_evry_window_new(E_Zone *zone);
static void _evry_window_free(Evry_Window *win); static void _evry_window_free(Evry_Window *win);
@ -196,9 +197,9 @@ evry_show(E_Zone *zone, const char *params)
win->plugin_dedicated = EINA_TRUE; win->plugin_dedicated = EINA_TRUE;
selectors = E_NEW(Evry_Selector*, 3); selectors = E_NEW(Evry_Selector*, 3);
selectors[0] = _evry_selector_new(type_subject); selectors[0] = _evry_selector_new(EVRY_PLUGIN_SUBJECT);
selectors[1] = _evry_selector_new(type_action); selectors[1] = _evry_selector_new(EVRY_PLUGIN_ACTION);
selectors[2] = _evry_selector_new(type_object); selectors[2] = _evry_selector_new(EVRY_PLUGIN_OBJECT);
handlers = eina_list_append handlers = eina_list_append
(handlers, ecore_event_handler_add (handlers, ecore_event_handler_add
@ -286,15 +287,23 @@ evry_hide(void)
} }
EAPI void EAPI void
evry_clear_input(void) evry_clear_input(Evry_Plugin *p)
{ {
Evry_State *s = selector->state; Evry_Selector *sel = _evry_selector_for_plugin_get(p);
if (sel != selector) return;
Evry_State *s = sel->state;
if (!s) return;
if (s->inp[0] != 0) if (s->inp[0] != 0)
{ {
s->inp[0] = 0; s->inp[0] = 0;
} }
s->input = s->inp; s->input = s->inp;
_evry_update_text_label(s);
} }
//#define CHECK_REFS 1 //#define CHECK_REFS 1
@ -304,7 +313,9 @@ static int item_cnt = 0;
#endif #endif
EAPI Evry_Item * EAPI Evry_Item *
evry_item_new(Evry_Item *base, Evry_Plugin *p, const char *label, void (*cb_free) (Evry_Item *item)) evry_item_new(Evry_Item *base, Evry_Plugin *p, const char *label,
Evas_Object *(*icon_get) (Evry_Item *it, Evas *e),
void (*cb_free) (Evry_Item *item))
{ {
Evry_Item *it; Evry_Item *it;
if (base) if (base)
@ -317,9 +328,13 @@ evry_item_new(Evry_Item *base, Evry_Plugin *p, const char *label, void (*cb_free
if (!it) return NULL; if (!it) return NULL;
} }
if (p && EVRY_ITEM(p)->subtype)
it->type = eina_stringshare_ref(EVRY_ITEM(p)->subtype);
it->plugin = p; it->plugin = p;
if (label) it->label = eina_stringshare_add(label); if (label) it->label = eina_stringshare_add(label);
it->free = cb_free; it->free = cb_free;
it->icon_get = icon_get;
it->ref = 1; it->ref = 1;
/* it->usage = -1; */ /* it->usage = -1; */
@ -352,6 +367,7 @@ evry_item_free(Evry_Item *it)
if (it->id) eina_stringshare_del(it->id); if (it->id) eina_stringshare_del(it->id);
if (it->context) eina_stringshare_del(it->context); if (it->context) eina_stringshare_del(it->context);
if (it->detail) eina_stringshare_del(it->detail); if (it->detail) eina_stringshare_del(it->detail);
if (it->type) eina_stringshare_del(it->type);
if (it->free) if (it->free)
it->free(it); it->free(it);
@ -360,12 +376,26 @@ evry_item_free(Evry_Item *it)
} }
EAPI int EAPI int
evry_item_type_check(const Evry_Item *it, const char *type) evry_item_type_check(const Evry_Item *it, const char *type, const char *subtype)
{ {
if (it && it->plugin && it->plugin->type_out) int ok = 0;
return (!strcmp(it->plugin->type_out, type));
return 0; if (it)
{
if (type)
{
if (it->type && type)
ok = (!strcmp(it->type, type));
}
if (!(type && !ok) || subtype)
{
if (it->subtype && subtype)
ok = (!strcmp(it->subtype, subtype));
}
}
return ok;
} }
static Evry_Selector * static Evry_Selector *
@ -410,12 +440,14 @@ _evry_timer_cb_actions_get(void *data)
static void static void
_evry_selector_update_actions(Evry_Selector *sel) _evry_selector_update_actions(Evry_Selector *sel)
{ {
Evry_Item *it = sel->state->cur_item; Evry_Item *it = sel->state->cur_item;
sel = selectors[1]; sel = selectors[1];
if (sel->update_timer) if (sel->update_timer)
ecore_timer_del(sel->update_timer); ecore_timer_del(sel->update_timer);
sel->update_timer = ecore_timer_add(0.1, _evry_timer_cb_actions_get, it);
_evry_timer_cb_actions_get(it);
/* sel->update_timer = ecore_timer_add(0.1, _evry_timer_cb_actions_get, it); */
} }
EAPI void EAPI void
@ -427,17 +459,17 @@ evry_item_select(const Evry_State *state, Evry_Item *it)
if (!s && it) if (!s && it)
{ {
sel = _evry_selector_for_plugin_get(it->plugin); sel = _evry_selector_for_plugin_get(it->plugin);
s = sel->state; s = sel->state;
} }
if (!s) return; if (!s) return;
s->plugin_auto_selected = EINA_FALSE; s->plugin_auto_selected = EINA_FALSE;
s->item_auto_selected = EINA_FALSE; s->item_auto_selected = EINA_FALSE;
_evry_item_sel(s, it); _evry_item_sel(s, it);
if (s == sel->state) if (s == sel->state)
{ {
_evry_selector_update(sel); _evry_selector_update(sel);
if (selector == selectors[0]) if (selector == selectors[0])
_evry_selector_update_actions(sel); _evry_selector_update_actions(sel);
@ -540,7 +572,7 @@ evry_plugin_async_update(Evry_Plugin *p, int action)
{ {
if (s->cur_plugins && s->cur_plugins->data == agg) if (s->cur_plugins && s->cur_plugins->data == agg)
{ {
agg->cleanup(agg); agg->finish(agg);
s->cur_plugins = eina_list_remove(s->cur_plugins, agg); s->cur_plugins = eina_list_remove(s->cur_plugins, agg);
} }
} }
@ -548,7 +580,7 @@ evry_plugin_async_update(Evry_Plugin *p, int action)
if (s->sel_items) if (s->sel_items)
eina_list_free(s->sel_items); eina_list_free(s->sel_items);
s->sel_items = NULL; s->sel_items = NULL;
/* plugin is visible */ /* plugin is visible */
if ((s->plugin == p) || (s->plugin == agg)) if ((s->plugin == p) || (s->plugin == agg))
{ {
@ -764,21 +796,21 @@ _evry_selector_new(int type)
sel->aggregator = evry_plug_aggregator_new(sel, type); sel->aggregator = evry_plug_aggregator_new(sel, type);
if (type == type_subject) if (type == EVRY_PLUGIN_SUBJECT)
{ {
sel->history = evry_hist->subjects; sel->history = evry_hist->subjects;
sel->actions = evry_plug_actions_new(sel, type); sel->actions = evry_plug_actions_new(sel, type);
edje_object_part_swallow(win->o_main, "e.swallow.subject_selector", o); edje_object_part_swallow(win->o_main, "e.swallow.subject_selector", o);
pcs = evry_conf->conf_subjects; pcs = evry_conf->conf_subjects;
} }
else if (type == type_action) else if (type == EVRY_PLUGIN_ACTION)
{ {
sel->history = evry_hist->actions; sel->history = evry_hist->actions;
sel->actions = evry_plug_actions_new(sel, type); sel->actions = evry_plug_actions_new(sel, type);
edje_object_part_swallow(win->o_main, "e.swallow.action_selector", o); edje_object_part_swallow(win->o_main, "e.swallow.action_selector", o);
pcs = evry_conf->conf_actions; pcs = evry_conf->conf_actions;
} }
else if (type == type_object) else if (type == EVRY_PLUGIN_OBJECT)
{ {
sel->history = evry_hist->subjects; sel->history = evry_hist->subjects;
edje_object_part_swallow(win->o_main, "e.swallow.object_selector", o); edje_object_part_swallow(win->o_main, "e.swallow.object_selector", o);
@ -857,7 +889,7 @@ _evry_selector_activate(Evry_Selector *sel)
if (sel->state->cur_item) if (sel->state->cur_item)
edje_object_part_text_set(sel->o_main, "e.text.plugin", edje_object_part_text_set(sel->o_main, "e.text.plugin",
s->cur_item->plugin->label); EVRY_ITEM(s->cur_item->plugin)->label);
_evry_view_show(s->view); _evry_view_show(s->view);
_evry_list_win_update(s); _evry_list_win_update(s);
@ -896,9 +928,9 @@ _evry_selector_thumb(Evry_Selector *sel, const Evry_Item *it)
evas_object_del(sel->o_thumb); evas_object_del(sel->o_thumb);
sel->o_thumb = NULL; sel->o_thumb = NULL;
if (it->plugin->type_out != thumb_types) return 0; if (it->type != thumb_types) return 0;
ITEM_FILE(file, it); GET_FILE(file, it);
if (!file->path || !file->mime) return 0; if (!file->path || !file->mime) return 0;
@ -936,11 +968,15 @@ _evry_selector_icon_set(Evry_Selector *sel)
it = s->cur_item; it = s->cur_item;
if (it && s->plugin && s->plugin->icon_get) if (it)
{ {
if (!_evry_selector_thumb(sel, it)) if (!_evry_selector_thumb(sel, it))
{ {
o = s->plugin->icon_get(it->plugin, it, win->popup->evas); o = evry_util_icon_get(it, win->popup->evas);
if (!o && it->plugin)
o = evry_util_icon_get(EVRY_ITEM(it->plugin), win->popup->evas);
if (o) if (o)
{ {
edje_object_part_swallow(sel->o_main, "e.swallow.icons", o); edje_object_part_swallow(sel->o_main, "e.swallow.icons", o);
@ -954,9 +990,9 @@ _evry_selector_icon_set(Evry_Selector *sel)
_evry_selector_thumb(sel, it); _evry_selector_thumb(sel, it);
} }
if (!sel->o_icon && s->plugin && s->plugin->icon) if (!sel->o_icon && s->plugin && EVRY_ITEM(s->plugin)->icon)
{ {
o = evry_icon_theme_get(s->plugin->icon, win->popup->evas); o = evry_icon_theme_get(EVRY_ITEM(s->plugin)->icon, win->popup->evas);
if (o) if (o)
{ {
edje_object_part_swallow(sel->o_main, "e.swallow.icons", o); edje_object_part_swallow(sel->o_main, "e.swallow.icons", o);
@ -972,7 +1008,7 @@ _evry_selector_update(Evry_Selector *sel)
Evry_State *s = sel->state; Evry_State *s = sel->state;
Evry_Item *it = NULL; Evry_Item *it = NULL;
Eina_Bool item_changed = EINA_FALSE; Eina_Bool item_changed = EINA_FALSE;
if (s) if (s)
{ {
it = s->cur_item; it = s->cur_item;
@ -981,13 +1017,13 @@ _evry_selector_update(Evry_Selector *sel)
_evry_item_desel(s, NULL); _evry_item_desel(s, NULL);
else if (it && !eina_list_data_find_list(s->plugin->items, it)) else if (it && !eina_list_data_find_list(s->plugin->items, it))
_evry_item_desel(s, NULL); _evry_item_desel(s, NULL);
it = s->cur_item; it = s->cur_item;
if (s->plugin && (!it || s->item_auto_selected)) if (s->plugin && (!it || s->item_auto_selected))
{ {
it = NULL; it = NULL;
/* get first item */ /* get first item */
if (!it && s->plugin->items) if (!it && s->plugin->items)
{ {
@ -1010,7 +1046,7 @@ _evry_selector_update(Evry_Selector *sel)
edje_object_part_text_set(sel->o_main, "e.text.label", it->label); edje_object_part_text_set(sel->o_main, "e.text.label", it->label);
if (sel == selector) if (sel == selector)
edje_object_part_text_set(sel->o_main, "e.text.plugin", it->plugin->label); edje_object_part_text_set(sel->o_main, "e.text.plugin", EVRY_ITEM(it->plugin)->label);
else else
edje_object_part_text_set(sel->o_main, "e.text.plugin", ""); edje_object_part_text_set(sel->o_main, "e.text.plugin", "");
} }
@ -1019,7 +1055,7 @@ _evry_selector_update(Evry_Selector *sel)
/* no items for this state - clear selector */ /* no items for this state - clear selector */
edje_object_part_text_set(sel->o_main, "e.text.label", ""); edje_object_part_text_set(sel->o_main, "e.text.label", "");
if (sel == selector && s && s->plugin) if (sel == selector && s && s->plugin)
edje_object_part_text_set(sel->o_main, "e.text.plugin", s->plugin->label); edje_object_part_text_set(sel->o_main, "e.text.plugin", EVRY_ITEM(s->plugin)->label);
else else
edje_object_part_text_set(sel->o_main, "e.text.plugin", ""); edje_object_part_text_set(sel->o_main, "e.text.plugin", "");
} }
@ -1073,29 +1109,20 @@ static int
_evry_selector_actions_get(Evry_Item *it) _evry_selector_actions_get(Evry_Item *it)
{ {
Eina_List *l, *plugins = NULL; Eina_List *l, *plugins = NULL;
Evry_Plugin *p, *plugin; Evry_Plugin *p, *pp;
Evry_Selector *sel = selectors[1]; Evry_Selector *sel = selectors[1];
const char *type_out;
while (sel->state) while (sel->state)
_evry_state_pop(sel); _evry_state_pop(sel);
if (!it) return 0; if (!it) return 0;
type_out = it->plugin->type_out; EINA_LIST_FOREACH(sel->plugins, l, p)
EINA_LIST_FOREACH(sel->plugins, l, plugin)
{ {
if ((plugin == sel->actions) || if (p->begin)
(plugin->type_in && type_out && plugin->type_in == type_out))
{ {
if (plugin->begin) if ((pp = p->begin(p, it)))
{ plugins = eina_list_append(plugins, pp);
if ((p = plugin->begin(plugin, it)))
plugins = eina_list_append(plugins, p);
}
else
plugins = eina_list_append(plugins, plugin);
} }
} }
@ -1112,35 +1139,33 @@ static int
_evry_selector_objects_get(Evry_Action *act) _evry_selector_objects_get(Evry_Action *act)
{ {
Eina_List *l, *plugins = NULL; Eina_List *l, *plugins = NULL;
Evry_Plugin *p, *plugin; Evry_Plugin *p, *pp;
Evry_Selector *sel = selectors[2]; Evry_Selector *sel = selectors[2];
Evry_Item *it; Evry_Item *it;
/* required type */ /* required type */
const char *type_in = act->type_in2; /* const char *type_in = act->type_in2; */
while (sel->state) while (sel->state)
_evry_state_pop(sel); _evry_state_pop(sel);
it = selectors[0]->state->cur_item; it = selectors[0]->state->cur_item;
EINA_LIST_FOREACH(sel->plugins, l, plugin) EINA_LIST_FOREACH(sel->plugins, l, p)
{ {
/* plugin doesnt provide reuired type */ printf("check %s %s\n", EVRY_ITEM(p)->subtype, act->type_in2);
if ((plugin->type_out != type_in) &&
(plugin != sel->aggregator)) if (!evry_item_type_check(EVRY_ITEM(p), NULL, act->type_in2))
continue; continue;
if (plugin->begin) if (p->begin)
{ {
/* plugins' begin method might require an item */ if ((pp = p->begin(p, it)) || (pp = p->begin(p, NULL)))
/* like tracker searches files that match mimetype plugins = eina_list_append(plugins, pp);
* of an application (item1) */
if (((p = plugin->begin(plugin, it))) ||
((p = plugin->begin(plugin, NULL))))
plugins = eina_list_append(plugins, p);
} }
else else
plugins = eina_list_append(plugins, plugin); {
plugins = eina_list_append(plugins, pp);
}
} }
if (!plugins) return 0; if (!plugins) return 0;
@ -1183,13 +1208,13 @@ _evry_state_pop(Evry_Selector *sel)
s->view->destroy(s->view); s->view->destroy(s->view);
EINA_LIST_FREE(s->plugins, p) EINA_LIST_FREE(s->plugins, p)
p->cleanup(p); p->finish(p);
sel->aggregator->cleanup(sel->aggregator); /* sel->aggregator->finish(sel->aggregator); */
if (s->sel_items) if (s->sel_items)
eina_list_free(s->sel_items); eina_list_free(s->sel_items);
E_FREE(s); E_FREE(s);
sel->states = eina_list_remove_list(sel->states, sel->states); sel->states = eina_list_remove_list(sel->states, sel->states);
@ -1207,9 +1232,8 @@ evry_browse_item(Evry_Selector *sel)
Evry_State *s = sel->state; Evry_State *s = sel->state;
Evry_Item *it; Evry_Item *it;
Eina_List *l, *plugins = NULL; Eina_List *l, *plugins = NULL;
Evry_Plugin *p, *plugin; Evry_Plugin *p, *pp;
Evry_View *view = NULL; Evry_View *view = NULL;
const char *type_out;
if (!s) if (!s)
return 0; return 0;
@ -1219,30 +1243,26 @@ evry_browse_item(Evry_Selector *sel)
if (!it || !it->browseable) if (!it || !it->browseable)
return 0; return 0;
type_out = it->plugin->type_out; if (it->plugin->begin && (pp = it->plugin->begin(it->plugin, it)))
plugins = eina_list_append(plugins, pp);
if (!type_out)
return 1;
if (it->plugin->begin &&
(p = it->plugin->begin(it->plugin, it)))
plugins = eina_list_append(plugins, p);
if (!plugins) if (!plugins)
{ {
EINA_LIST_FOREACH(sel->plugins, l, plugin) EINA_LIST_FOREACH(sel->plugins, l, p)
{ {
if ((!plugin->begin || !plugin->type_in) || if (p == it->plugin)
(plugin->type_in != type_out))
continue; continue;
if ((p = plugin->begin(plugin, it))) if (!p->begin)
plugins = eina_list_append(plugins, p); continue;
if ((pp = p->begin(p, it)))
plugins = eina_list_append(plugins, pp);
} }
} }
if (!plugins) if (!plugins)
return 1; return 0;
evry_history_add(sel->history, s->cur_item, NULL, s->input); evry_history_add(sel->history, s->cur_item, NULL, s->input);
@ -1319,11 +1339,11 @@ _evry_selectors_switch(int dir)
{ {
int next_selector = 0; int next_selector = 0;
Evry_Item *it; Evry_Item *it;
if ((it = s->cur_item) && if ((it = s->cur_item) &&
(it->plugin == selector->actions)) (it->plugin == selector->actions))
{ {
ACTION_GET(act,it); GET_ACTION(act,it);
if (act->type_in2) if (act->type_in2)
{ {
_evry_selector_objects_get(act); _evry_selector_objects_get(act);
@ -1600,7 +1620,7 @@ _evry_backspace(Evry_Selector *sel)
val = *(s->inp + pos); val = *(s->inp + pos);
s->inp[pos] = 0; s->inp[pos] = 0;
if (s->trigger_active && s->inp[0] != 0) if (s->trigger_active && s->inp[0] != 0)
s->input = s->inp + 1; s->input = s->inp + 1;
else else
@ -1681,7 +1701,7 @@ _evry_clear(Evry_Selector *sel)
s->inp[0] = 0; s->inp[0] = 0;
s->input = s->inp; s->input = s->inp;
} }
_evry_update(sel, 1); _evry_update(sel, 1);
if (!list->visible && evry_conf->hide_input) if (!list->visible && evry_conf->hide_input)
edje_object_signal_emit(list->o_main, "e,state,entry_hide", "e"); edje_object_signal_emit(list->o_main, "e,state,entry_hide", "e");
@ -1696,7 +1716,7 @@ _evry_plugin_action(Evry_Selector *sel, int finished)
Evry_State *s_subj, *s_act, *s_obj = NULL; Evry_State *s_subj, *s_act, *s_obj = NULL;
Evry_Item *it_subj, *it_act, *it_obj, *it; Evry_Item *it_subj, *it_act, *it_obj, *it;
Eina_List *l; Eina_List *l;
if (selectors[0]->update_timer) if (selectors[0]->update_timer)
{ {
_evry_matches_update(selectors[0], 0); _evry_matches_update(selectors[0], 0);
@ -1725,11 +1745,15 @@ _evry_plugin_action(Evry_Selector *sel, int finished)
if (!(it_act = s_act->cur_item)) if (!(it_act = s_act->cur_item))
return; return;
if (it_act->plugin == selectors[1]->actions) if (evry_item_type_check(it_act, "ACTION", NULL) ||
evry_item_type_check(it_act, NULL, "ACTION"))
{ {
ACTION_GET(act, it_act); GET_ACTION(act, it_act);
if (!act->action)
return;
/* get object item for action, when required */ /* get object item for action, when required */
if (act->type_in2) if (act->type_in2)
{ {
@ -1739,22 +1763,22 @@ _evry_plugin_action(Evry_Selector *sel, int finished)
s_obj = selectors[2]->state; s_obj = selectors[2]->state;
it_obj = s_obj->cur_item; it_obj = s_obj->cur_item;
} }
if (!it_obj) if (!it_obj)
{ {
if (selectors[1] == selector) if (selectors[1] == selector)
_evry_selectors_switch(1); _evry_selectors_switch(1);
return; return;
} }
act->item2 = it_obj; act->item2 = it_obj;
} }
if (s_subj->sel_items) if (s_subj->sel_items)
{ {
EINA_LIST_REVERSE_FOREACH(s_subj->sel_items, l, it) EINA_LIST_REVERSE_FOREACH(s_subj->sel_items, l, it)
{ {
if (it->plugin->type_out != act->type_in1) if (it->type != act->type_in1)
continue; continue;
act->item1 = it; act->item1 = it;
act->action(act); act->action(act);
@ -1764,7 +1788,7 @@ _evry_plugin_action(Evry_Selector *sel, int finished)
{ {
EINA_LIST_FOREACH(s_obj->sel_items, l, it) EINA_LIST_FOREACH(s_obj->sel_items, l, it)
{ {
if (it->plugin->type_out != act->type_in2) if (it->type != act->type_in2)
continue; continue;
act->item2 = it; act->item2 = it;
act->action(act); act->action(act);
@ -1772,27 +1796,28 @@ _evry_plugin_action(Evry_Selector *sel, int finished)
} }
else else
{ {
act->item1 = it_subj;
if (!act->action(act)) if (!act->action(act))
return; return;
} }
} }
else if (s_act->plugin->action) /* else if (s_act->plugin->action)
{ * {
if (s_subj->sel_items) * if (s_subj->sel_items)
{ * {
EINA_LIST_REVERSE_FOREACH(s_subj->sel_items, l, it) * EINA_LIST_REVERSE_FOREACH(s_subj->sel_items, l, it)
{ * {
if (it->plugin->type_out != it_act->plugin->type_in) * if (it->plugin->type_out != it_act->plugin->type_in)
continue; * continue;
s_act->plugin->action(s_act->plugin, it_act, it); * s_act->plugin->action(s_act->plugin, it_act, it);
} * }
} * }
else * else
{ * {
if (!s_act->plugin->action(s_act->plugin, it_act, it_subj)) * if (!s_act->plugin->action(s_act->plugin, it_act, it_subj))
return; * return;
} * }
} * } */
else return; else return;
if (s_subj && it_subj) if (s_subj && it_subj)
@ -1973,7 +1998,7 @@ _evry_matches_update(Evry_Selector *sel, int async)
if (s->sel_items) if (s->sel_items)
eina_list_free(s->sel_items); eina_list_free(s->sel_items);
s->sel_items = NULL; s->sel_items = NULL;
if (!input || !s->trigger_active) if (!input || !s->trigger_active)
{ {
EINA_LIST_FREE(s->cur_plugins, p); EINA_LIST_FREE(s->cur_plugins, p);
@ -2106,7 +2131,7 @@ _evry_plugin_select(Evry_State *s, Evry_Plugin *p)
if (!s || !s->cur_plugins) return; if (!s || !s->cur_plugins) return;
if (p) s->plugin_auto_selected = EINA_FALSE; if (p) s->plugin_auto_selected = EINA_FALSE;
if (!p && s->cur_plugins) if (!p && s->cur_plugins)
{ {
p = s->cur_plugins->data; p = s->cur_plugins->data;

View File

@ -19,14 +19,14 @@ struct _Plugin_Page
Evas_Object *o_view_thumb; Evas_Object *o_view_thumb;
Evas_Object *o_enabled; Evas_Object *o_enabled;
Evas_Object *o_cfg_btn; Evas_Object *o_cfg_btn;
Eina_List *configs; Eina_List *configs;
char *trigger; char *trigger;
int trigger_only; int trigger_only;
int view_mode; int view_mode;
int enabled; int enabled;
Plugin_Config *cur; Plugin_Config *cur;
} ; } ;
@ -134,7 +134,7 @@ _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{ {
int i; int i;
Plugin_Config *pc; Plugin_Config *pc;
#define C(_name) evry_conf->_name = cfdata->_name #define C(_name) evry_conf->_name = cfdata->_name
C(height); C(height);
C(width); C(width);
@ -162,7 +162,7 @@ _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
pc = cfdata->page[i].cur; pc = cfdata->page[i].cur;
if (pc) if (pc)
{ {
if (pc->trigger) if (pc->trigger)
@ -299,7 +299,7 @@ _list_select_cb (void *data, Evas_Object *obj)
{ {
e_widget_disabled_set(page->o_cfg_btn, 1); e_widget_disabled_set(page->o_cfg_btn, 1);
} }
page->cur = pc; page->cur = pc;
} }
else else
@ -324,7 +324,7 @@ _plugin_config_cb(void *data, void *data2)
Plugin_Page *page = data; Plugin_Page *page = data;
if (!page->cur->plugin) if (!page->cur->plugin)
return; return;
e_configure_registry_call(page->cur->plugin->config_path, e_configure_registry_call(page->cur->plugin->config_path,
e_container_current_get(e_manager_current_get()), e_container_current_get(e_manager_current_get()),
NULL); NULL);

View File

@ -244,8 +244,8 @@ evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *i
{ {
hi = E_NEW(History_Item, 1); hi = E_NEW(History_Item, 1);
hi->plugin = eina_stringshare_ref(it->plugin->name); hi->plugin = eina_stringshare_ref(it->plugin->name);
if (it->plugin->type_out) if (it->type)
hi->type = eina_stringshare_ref(it->plugin->type_out); hi->type = eina_stringshare_ref(it->type);
he->items = eina_list_append(he->items, hi); he->items = eina_list_append(he->items, hi);
} }
@ -258,8 +258,8 @@ evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *i
hi->count += (hi->transient ? 2:1); hi->count += (hi->transient ? 2:1);
/* XXX can be remove just for update */ /* XXX can be remove just for update */
if (it->plugin->type_out && !hi->type) if (it->type && !hi->type)
hi->type = eina_stringshare_ref(it->plugin->type_out); hi->type = eina_stringshare_ref(it->type);
if (ctxt && !hi->context) if (ctxt && !hi->context)
hi->context = eina_stringshare_ref(ctxt); hi->context = eina_stringshare_ref(ctxt);

View File

@ -10,57 +10,79 @@ struct _Plugin
Evry_Plugin base; Evry_Plugin base;
Evry_Selector *selector; Evry_Selector *selector;
Eina_List *actions; Eina_List *actions;
Eina_Bool parent;
Evry_Action *action;
}; };
static Evry_Plugin *_base_plug = NULL;
static void static void
_cleanup(Evry_Plugin *plugin) _finish(Evry_Plugin *plugin)
{ {
PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
Evry_Action *act; Evry_Action *act;
EINA_LIST_FREE(p->actions, act) if (p->parent)
if (act->cleanup) act->cleanup(act); {
EINA_LIST_FREE(p->actions, act);
E_FREE(p);
}
else
{
EINA_LIST_FREE(p->actions, act);
}
} }
static Evry_Plugin * static Evry_Plugin *
_begin(Evry_Plugin *plugin, const Evry_Item *it) _begin(Evry_Plugin *plugin, const Evry_Item *it)
{ {
PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
Evry_Action *act; Evry_Action *act;
Eina_List *l; Eina_List *l;
const char *type; const char *type;
int changed = 0;
if (!it || !it->type) return NULL;
if (plugin->type == type_action)
type = it->type;
if (it->browseable)
{ {
if (!it) return NULL; EINA_LIST_FOREACH(evry_conf->actions, l, act)
type = it->plugin->type_out; {
if (!type) return NULL; if (act == EVRY_ACTN(it))
{
p = E_NEW(Plugin, 1);
p->base = *plugin;
p->base.items = NULL;
p->actions = act->fetch(act);
p->parent = EINA_TRUE;
p->action = act;
return EVRY_PLUGIN(p);
}
}
} }
EINA_LIST_FOREACH(evry_conf->actions, l, act) EINA_LIST_FOREACH(evry_conf->actions, l, act)
{ {
if ((!act->type_in1) || ((act->type_in1 == type) && if ((!act->type_in1) ||
(!act->check_item || act->check_item(act, it)))) ((act->type_in1 == type) &&
(!act->check_item || act->check_item(act, it))))
{ {
act->item1 = it;
act->base.plugin = plugin; act->base.plugin = plugin;
if (!eina_list_data_find_list(p->actions, act)) if (!eina_list_data_find_list(p->actions, act))
{ {
changed = 1;
p->actions = eina_list_append(p->actions, act); p->actions = eina_list_append(p->actions, act);
} }
continue; continue;
} }
changed = 1;
p->actions = eina_list_remove(p->actions, act); p->actions = eina_list_remove(p->actions, act);
} }
if (!p->actions) return NULL; if (!p->actions) return NULL;
return plugin; return plugin;
} }
@ -91,7 +113,7 @@ _cb_sort(const void *data1, const void *data2)
static int static int
_fetch(Evry_Plugin *plugin, const char *input) _fetch(Evry_Plugin *plugin, const char *input)
{ {
PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
Eina_List *l; Eina_List *l;
Evry_Item *it; Evry_Item *it;
int match; int match;
@ -116,42 +138,35 @@ _fetch(Evry_Plugin *plugin, const char *input)
return 1; return 1;
} }
static Evas_Object *
_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
{
ACTION_GET(act, it);
Evas_Object *o = NULL;
if (act->icon_get)
{
o = act->icon_get(act, e);
}
if ((!o) && it->icon)
{
o = evry_icon_theme_get(it->icon, e);
}
return o;
}
Evry_Plugin * Evry_Plugin *
evry_plug_actions_new(Evry_Selector *sel, int type) evry_plug_actions_new(Evry_Selector *sel, int type)
{ {
Evry_Plugin *plugin; Evry_Plugin *plugin;
plugin = EVRY_PLUGIN_NEW(Plugin, N_("Actions"), type, "", "", plugin = EVRY_PLUGIN_NEW(Plugin, N_("Actions"), NULL, NULL, _begin, _finish, _fetch, NULL);
_begin, _cleanup, _fetch, _icon_get, NULL);
PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
p->selector = sel; p->selector = sel;
evry_plugin_register(plugin, 2); evry_plugin_register(plugin, type, 2);
return plugin; return plugin;
} }
/***************************************************************************/ /***************************************************************************/
int evry_plug_actions_init()
{
_base_plug = evry_plugin_new(NULL, _("Actions"), NULL, NULL, NULL, NULL, NULL, NULL, NULL);
return 1;
}
void evry_plug_actions_shutdown()
{
evry_plugin_free(_base_plug);
}
EAPI void EAPI void
evry_action_register(Evry_Action *act, int priority) evry_action_register(Evry_Action *act, int priority)
{ {
@ -165,14 +180,14 @@ EAPI void
evry_action_unregister(Evry_Action *act) evry_action_unregister(Evry_Action *act)
{ {
evry_conf->actions = eina_list_remove(evry_conf->actions, act); evry_conf->actions = eina_list_remove(evry_conf->actions, act);
/* cleanup */ /* finish */
} }
static void static void
_action_free_cb(Evry_Item *it) _action_free_cb(Evry_Item *it)
{ {
ACTION_GET(act, it); GET_ACTION(act, it);
if (act->name) eina_stringshare_del(act->name); if (act->name) eina_stringshare_del(act->name);
if (act->type_in1) eina_stringshare_del(act->type_in1); if (act->type_in1) eina_stringshare_del(act->type_in1);
if (act->type_in2) eina_stringshare_del(act->type_in2); if (act->type_in2) eina_stringshare_del(act->type_in2);
@ -189,11 +204,14 @@ evry_action_new(const char *name, const char *label,
{ {
Evry_Action *act = E_NEW(Evry_Action, 1); Evry_Action *act = E_NEW(Evry_Action, 1);
evry_item_new(EVRY_ITEM(act), NULL, label, _action_free_cb); evry_item_new(EVRY_ITEM(act), _base_plug, label, NULL, _action_free_cb);
act->base.icon = icon; act->base.icon = icon;
act->base.type = eina_stringshare_add("ACTION");
printf("icon %s\n", act->base.icon);
act->name = eina_stringshare_add(name); act->name = eina_stringshare_add(name);
act->type_in1 = (type_in1 ? eina_stringshare_add(type_in1) : NULL); act->type_in1 = (type_in1 ? eina_stringshare_add(type_in1) : NULL);
act->type_in2 = (type_in2 ? eina_stringshare_add(type_in2) : NULL); act->type_in2 = (type_in2 ? eina_stringshare_add(type_in2) : NULL);

View File

@ -98,7 +98,7 @@ _cb_sort(const void *data1, const void *data2)
static inline Eina_List * static inline Eina_List *
_add_item(Plugin *p, Eina_List *items, Evry_Item *it) _add_item(Plugin *p, Eina_List *items, Evry_Item *it)
{ {
/* remove duplicates provided by different plugins */ /* remove duplicates provided by different plugins */
if (it->id) if (it->id)
{ {
@ -108,12 +108,12 @@ _add_item(Plugin *p, Eina_List *items, Evry_Item *it)
EINA_LIST_FOREACH(p->base.items, _l, _it) EINA_LIST_FOREACH(p->base.items, _l, _it)
{ {
if ((it->plugin->name != _it->plugin->name) && if ((it->plugin->name != _it->plugin->name) &&
(it->plugin->type_out == _it->plugin->type_out) && (it->type == _it->type) &&
(it->id == _it->id)) (it->id == _it->id))
return items; return items;
} }
} }
evry_item_ref(it); evry_item_ref(it);
items = eina_list_append(items, it); items = eina_list_append(items, it);
EVRY_PLUGIN_ITEM_APPEND(p, it); EVRY_PLUGIN_ITEM_APPEND(p, it);
@ -134,8 +134,6 @@ _fetch(Evry_Plugin *plugin, const char *input)
const char *context = NULL; const char *context = NULL;
if (input && !input[0]) input = NULL; if (input && !input[0]) input = NULL;
plugin->changed = 1;
EVRY_PLUGIN_ITEMS_FREE(p); EVRY_PLUGIN_ITEMS_FREE(p);
s = p->selector->state; s = p->selector->state;
@ -160,12 +158,12 @@ _fetch(Evry_Plugin *plugin, const char *input)
} }
if (!lp) return 0; if (!lp) return 0;
/* if there is only one plugin append all items */ /* if there is only one plugin append all items */
if (!lp->next) if (!lp->next)
{ {
pp = lp->data; pp = lp->data;
EINA_LIST_FOREACH(pp->items, l, it) EINA_LIST_FOREACH(pp->items, l, it)
{ {
evry_history_item_usage_set(p->selector->history, it, input, context); evry_history_item_usage_set(p->selector->history, it, input, context);
@ -234,8 +232,8 @@ _fetch(Evry_Plugin *plugin, const char *input)
} }
} }
} }
if (items) eina_list_free(items); if (items) eina_list_free(items);
if (input) if (input)
@ -258,52 +256,25 @@ _fetch(Evry_Plugin *plugin, const char *input)
return 1; return 1;
} }
static int
_action(Evry_Plugin *plugin, const Evry_Item *act, const Evry_Item *subj)
{
if (act->plugin && act->plugin->action)
return act->plugin->action(act->plugin, act, subj);
return 0;
}
static void static void
_cleanup(Evry_Plugin *plugin) _finish(Evry_Plugin *plugin)
{ {
Evry_Item *it; Evry_Item *it;
EINA_LIST_FREE(plugin->items, it) EINA_LIST_FREE(plugin->items, it)
evry_item_free(it); evry_item_free(it);
} }
static Evas_Object *
_icon_get(Evry_Plugin *plugin, const Evry_Item *it, Evas *e)
{
Evas_Object *o = NULL;
if (it->plugin)
{
if (it->plugin->icon_get)
o = it->plugin->icon_get(it->plugin, it, e);
else if (it->plugin->icon)
o = evry_icon_theme_get(it->plugin->icon, e);
}
return o;
}
Evry_Plugin * Evry_Plugin *
evry_plug_aggregator_new(Evry_Selector *sel, int type) evry_plug_aggregator_new(Evry_Selector *sel, int type)
{ {
Evry_Plugin *p; Evry_Plugin *p;
p = EVRY_PLUGIN_NEW(Plugin, N_("All"), type, "", "", p = EVRY_PLUGIN_NEW(Plugin, N_("All"), NULL, NULL, NULL, _finish, _fetch, NULL);
NULL, _cleanup, _fetch, _icon_get, NULL);
p->action = &_action;
p->history = EINA_FALSE; p->history = EINA_FALSE;
evry_plugin_register(p, -1); evry_plugin_register(p, type, -1);
PLUGIN(pa, p); GET_PLUGIN(pa, p);
pa->selector = sel; pa->selector = sel;
return p; return p;

View File

@ -19,7 +19,7 @@ _fetch(Evry_Plugin *p, const char *input)
if (input) if (input)
{ {
it = evry_item_new(NULL, p, input, NULL); it = evry_item_new(NULL, p, input, NULL, NULL);
it->fuzzy_match = 999; it->fuzzy_match = 999;
EVRY_PLUGIN_ITEM_APPEND(p, it); EVRY_PLUGIN_ITEM_APPEND(p, it);
@ -32,21 +32,20 @@ _fetch(Evry_Plugin *p, const char *input)
Eina_Bool Eina_Bool
evry_plug_text_init(void) evry_plug_text_init(void)
{ {
p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Text"), type_subject, NULL, "TEXT", p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Text"),
NULL, _cleanup, _fetch, NULL, NULL); "accessories-text-editor", "TEXT",
NULL, _cleanup, _fetch, NULL);
p2 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Text"), type_object, NULL, "TEXT", p2 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Text"),
NULL, _cleanup, _fetch, NULL, NULL); "accessories-text-editor", "TEXT",
NULL, _cleanup, _fetch, NULL);
p1->trigger = " ";
p2->trigger = " ";
p1->icon = "accessories-text-editor"; evry_plugin_register(p1, EVRY_PLUGIN_OBJECT,999);
p2->icon = "accessories-text-editor"; evry_plugin_register(p2, EVRY_PLUGIN_SUBJECT, 999);
p1->trigger = " ";
p2->trigger = " ";
evry_plugin_register(p1, 999); return EINA_TRUE;
evry_plugin_register(p2, 999);
return EINA_TRUE;
} }
void void

View File

@ -105,9 +105,9 @@ _thumb_gen(void *data, Evas_Object *obj, void *event_info)
static int static int
_check_item(const Evry_Item *it) _check_item(const Evry_Item *it)
{ {
if (it->plugin->type_out != view_types) return 0; if (it->type != view_types) return 0;
ITEM_FILE(file, it); GET_FILE(file, it);
if (!file->path || !file->mime) return 0; if (!file->path || !file->mime) return 0;
@ -126,12 +126,9 @@ _thumb_idler(void *data)
EINA_LIST_FOREACH_SAFE(sd->queue, l, ll, it) EINA_LIST_FOREACH_SAFE(sd->queue, l, ll, it)
{ {
if (!it->image && !it->have_thumb && if (!it->image && !it->have_thumb)
sd->view->state->plugin &&
sd->view->state->plugin->icon_get)
{ {
it->image = sd->view->state->plugin->icon_get it->image = evry_util_icon_get(it->item, sd->view->evas);
(it->item->plugin, it->item, sd->view->evas);
if (it->image) if (it->image)
{ {
@ -149,7 +146,7 @@ _thumb_idler(void *data)
{ {
it->thumb = e_thumb_icon_add(sd->view->evas); it->thumb = e_thumb_icon_add(sd->view->evas);
ITEM_FILE(file, it->item); GET_FILE(file, it->item);
evas_object_smart_callback_add(it->thumb, "e_thumb_gen", _thumb_gen, it); evas_object_smart_callback_add(it->thumb, "e_thumb_gen", _thumb_gen, it);
@ -968,7 +965,7 @@ _update_frame(Evas_Object *obj)
static int static int
_view_update(Evry_View *view, int slide) _view_update(Evry_View *view, int slide)
{ {
VIEW(v, view); GET_VIEW(v, view);
Smart_Data *sd = evas_object_smart_data_get(v->span); Smart_Data *sd = evas_object_smart_data_get(v->span);
Item *v_it; Item *v_it;
Evry_Item *p_it; Evry_Item *p_it;
@ -1400,7 +1397,7 @@ _cb_item_changed(void *data, int type, void *event)
static Evry_View * static Evry_View *
_view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow) _view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow)
{ {
VIEW(parent, view); GET_VIEW(parent, view);
View *v; View *v;
Ecore_Event_Handler *h; Ecore_Event_Handler *h;
@ -1455,7 +1452,7 @@ _view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow)
static void static void
_view_destroy(Evry_View *view) _view_destroy(Evry_View *view)
{ {
VIEW(v, view); GET_VIEW(v, view);
Ecore_Event_Handler *h; Ecore_Event_Handler *h;

View File

@ -354,6 +354,43 @@ evry_icon_mime_get(const char *mime, Evas *e)
return _evry_icon_mime_theme_get(mime, e); return _evry_icon_mime_theme_get(mime, e);
} }
static Evas_Object *
_file_icon_get(const Evry_Item *it, Evas *e)
{
Evas_Object *o = NULL;
GET_FILE(file, it);
if (it->browseable)
o = evry_icon_theme_get("folder", e);
else if (file->mime)
o = evry_icon_mime_get(file->mime, e);
if (!o)
o = evry_icon_mime_get("unknown", e);
return o;
}
Evas_Object *
evry_util_icon_get(Evry_Item *it, Evas *e)
{
Evas_Object *o = NULL;
if (it->icon_get)
o = it->icon_get(it, e);
if (!o && it->icon)
o = evry_icon_theme_get(it->icon, e);
if (evry_item_type_check(it, "FILE", NULL))
o = _file_icon_get(it, e);
/* TODO default type: files, apps */
return o;
}
EAPI int EAPI int
evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file) evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file)
{ {
@ -363,7 +400,7 @@ evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file)
char *tmp = NULL; char *tmp = NULL;
if (!it_app) return 0; if (!it_app) return 0;
ITEM_APP(app, it_app); GET_APP(app, it_app);
zone = e_util_zone_current_get(e_manager_current_get()); zone = e_util_zone_current_get(e_manager_current_get());
@ -371,7 +408,7 @@ evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file)
{ {
if (it_file) if (it_file)
{ {
ITEM_FILE(file, it_file); GET_FILE(file, it_file);
Eina_List *l; Eina_List *l;
char *mime; char *mime;
@ -424,7 +461,7 @@ evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file)
{ {
if (it_file) if (it_file)
{ {
ITEM_FILE(file, it_file); GET_FILE(file, it_file);
int len; int len;
tmp = eina_str_escape(file->path); tmp = eina_str_escape(file->path);

View File

@ -139,7 +139,7 @@ _tabs_update(Tab_View *v)
o = edje_object_add(v->evas); o = edje_object_add(v->evas);
e_theme_edje_object_set(o, "base/theme/everything", e_theme_edje_object_set(o, "base/theme/everything",
"e/modules/everything/tab_item"); "e/modules/everything/tab_item");
edje_object_part_text_set(o, "e.text.label", p->label); edje_object_part_text_set(o, "e.text.label", EVRY_ITEM(p)->label);
tab->o_tab = o; tab->o_tab = o;
@ -237,7 +237,7 @@ _plugin_next_by_name(Tab_View *v, const char *key)
EINA_LIST_FOREACH(s->cur_plugins, l, p) EINA_LIST_FOREACH(s->cur_plugins, l, p)
{ {
if (p->label && (!strncasecmp(p->label, key, 1))) if (EVRY_ITEM(p)->label && (!strncasecmp(EVRY_ITEM(p)->label, key, 1)))
{ {
if (!first) first = p; if (!first) first = p;