converted all modules to new api

SVN revision: 48758
This commit is contained in:
Hannes Janetzek 2010-05-11 17:24:38 +00:00
parent 75774581ca
commit db8fad47d1
18 changed files with 508 additions and 493 deletions

View File

@ -2,7 +2,9 @@
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/ */
#include "Evry.h" #include "e.h"
#include "e_mod_main.h"
#include "evry_api.h"
#include "e_mod_main.h" #include "e_mod_main.h"
typedef struct _Plugin Plugin; typedef struct _Plugin Plugin;
@ -33,14 +35,20 @@ struct _E_Exe_List
Eina_List *list; Eina_List *list;
}; };
struct _Module_Config struct _Module_Config
{ {
int version; int version;
unsigned char list_executables; unsigned char list_executables;
E_Config_Dialog *cfd; const char *cmd_terminal;
E_Module *module; const char *cmd_sudo;
E_Config_Dialog *cfd;
E_Module *module;
}; };
static const Evry_API *evry = NULL;
static Evry_Module *evry_module = NULL;
static Module_Config *_conf; static Module_Config *_conf;
static Evry_Plugin *plug_apps = NULL; static Evry_Plugin *plug_apps = NULL;
static Evry_Plugin *plug_apps2 = NULL; static Evry_Plugin *plug_apps2 = NULL;
@ -61,7 +69,7 @@ static void _scan_executables();
static void _hash_free(void *data) static void _hash_free(void *data)
{ {
GET_APP(app, data); GET_APP(app, data);
evry_item_free(EVRY_ITEM(app)); EVRY_ITEM_FREE(app);
} }
static Evry_Plugin * static Evry_Plugin *
@ -72,13 +80,13 @@ _begin_open_with(Evry_Plugin *plugin, const Evry_Item *item)
Efreet_Desktop *d, *d2; Efreet_Desktop *d, *d2;
const char *mime; const char *mime;
const char *path = NULL; const char *path = NULL;
if (CHECK_TYPE(item, EVRY_TYPE_ACTION)) if (CHECK_TYPE(item, EVRY_TYPE_ACTION))
{ {
GET_ACTION(act, item); GET_ACTION(act, item);
GET_FILE(file, act->it1.item); GET_FILE(file, act->it1.item);
if (!evry_file_path_get(file)) if (!evry->file_path_get(file))
return NULL; return NULL;
path = file->path; path = file->path;
@ -88,7 +96,7 @@ _begin_open_with(Evry_Plugin *plugin, const Evry_Item *item)
{ {
GET_FILE(file, item); GET_FILE(file, item);
if (!evry_file_path_get(file)) if (!evry->file_path_get(file))
return NULL; return NULL;
path = file->path; path = file->path;
@ -115,7 +123,7 @@ _begin_open_with(Evry_Plugin *plugin, const Evry_Item *item)
if (!eina_list_data_find_list(p->apps_mime, d)) if (!eina_list_data_find_list(p->apps_mime, d))
p->apps_mime = eina_list_append(p->apps_mime, d); p->apps_mime = eina_list_append(p->apps_mime, d);
else else
efreet_desktop_free(d); efreet_desktop_free(d);
} }
} }
@ -127,10 +135,10 @@ _begin_open_with(Evry_Plugin *plugin, const Evry_Item *item)
p->apps_mime = eina_list_remove(p->apps_mime, d2); p->apps_mime = eina_list_remove(p->apps_mime, d2);
efreet_desktop_free(d2); efreet_desktop_free(d2);
} }
p->apps_mime = eina_list_prepend(p->apps_mime, d); p->apps_mime = eina_list_prepend(p->apps_mime, d);
} }
p->added = eina_hash_string_small_new(_hash_free); p->added = eina_hash_string_small_new(_hash_free);
return plugin; return plugin;
@ -142,15 +150,15 @@ _begin(Evry_Plugin *plugin, const Evry_Item *item)
GET_PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
DBG("begin %p %p\n", item, _act_open_with); DBG("begin %p %p\n", item, _act_open_with);
if (item && (item != _act_open_with)) if (item && (item != _act_open_with))
return NULL; return NULL;
p->added = eina_hash_string_small_new(_hash_free); p->added = eina_hash_string_small_new(_hash_free);
if (_conf->list_executables) if (_conf->list_executables)
_scan_executables(); _scan_executables();
return plugin; return plugin;
} }
@ -161,7 +169,7 @@ _finish(Evry_Plugin *plugin)
GET_PLUGIN(p, plugin); GET_PLUGIN(p, plugin);
Efreet_Desktop *desktop; Efreet_Desktop *desktop;
char *str; char *str;
if (p->added) if (p->added)
eina_hash_free(p->added); eina_hash_free(p->added);
@ -196,7 +204,7 @@ _finish(Evry_Plugin *plugin)
EINA_LIST_FREE(exe_list2, str) EINA_LIST_FREE(exe_list2, str)
free(str); free(str);
} }
p->app_command = NULL; p->app_command = NULL;
p->app_parameter = NULL; p->app_parameter = NULL;
@ -220,7 +228,7 @@ _finish_mime(Evry_Plugin *plugin)
static int static int
_exec_open_file_action(Evry_Action *act) _exec_open_file_action(Evry_Action *act)
{ {
return evry_util_exec_app(EVRY_ITEM(act), act->it1.item); return evry->util_exec_app(EVRY_ITEM(act), act->it1.item);
} }
static Evas_Object * static Evas_Object *
@ -233,7 +241,7 @@ _icon_get(Evry_Item *it, Evas *e)
o = e_util_desktop_icon_add(app->desktop, 64, e); o = e_util_desktop_icon_add(app->desktop, 64, e);
if (!o) if (!o)
o = evry_icon_theme_get("system-run", e); o = evry->icon_theme_get("system-run", e);
return o; return o;
} }
@ -258,7 +266,7 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, const char *file, int match)
Efreet_Desktop *d2; Efreet_Desktop *d2;
int already_refd = 0; int already_refd = 0;
const char *exe; const char *exe;
if (file) if (file)
{ {
Eina_List *l; Eina_List *l;
@ -304,7 +312,7 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, const char *file, int match)
{ {
exe = file; exe = file;
} }
if (!exe) return NULL; if (!exe) return NULL;
if ((app = eina_hash_find(p->added, exe))) if ((app = eina_hash_find(p->added, exe)))
@ -333,7 +341,7 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, const char *file, int match)
EVRY_ACTN(app)->remember_context = EINA_TRUE; EVRY_ACTN(app)->remember_context = EINA_TRUE;
EVRY_ITEM(app)->id = eina_stringshare_add(desktop->exec); EVRY_ITEM(app)->id = eina_stringshare_add(desktop->exec);
EVRY_ITEM(app)->subtype = EVRY_TYPE_ACTION; EVRY_ITEM(app)->subtype = EVRY_TYPE_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)
@ -347,7 +355,7 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, const char *file, int match)
EVRY_ITEM(app)->id = eina_stringshare_add(file); EVRY_ITEM(app)->id = eina_stringshare_add(file);
EVRY_ITEM(app)->subtype = EVRY_TYPE_ACTION; EVRY_ITEM(app)->subtype = EVRY_TYPE_ACTION;
} }
app->desktop = desktop; app->desktop = desktop;
eina_hash_add(p->added, exe, app); eina_hash_add(p->added, exe, app);
@ -358,7 +366,7 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, const char *file, int match)
if (tmp && strcmp(exe, tmp)) if (tmp && strcmp(exe, tmp))
{ {
evry_item_ref(EVRY_ITEM(app)); EVRY_ITEM_REF(app);
eina_hash_add(p->added, tmp, app); eina_hash_add(p->added, tmp, app);
} }
} }
@ -369,11 +377,11 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, const char *file, int match)
if (strcmp(exe, file)) if (strcmp(exe, file))
{ {
evry_item_ref(EVRY_ITEM(app)); evry->item_ref(EVRY_ITEM(app));
eina_hash_add(p->added, file, app); eina_hash_add(p->added, file, app);
} }
} }
EVRY_ITEM(app)->fuzzy_match = match; EVRY_ITEM(app)->fuzzy_match = match;
EVRY_PLUGIN_ITEM_APPEND(p, app); EVRY_PLUGIN_ITEM_APPEND(p, app);
@ -397,13 +405,13 @@ _add_desktop_list(Plugin *p, Eina_List *apps, const char *input)
char *exec = strrchr(desktop->exec, '/'); char *exec = strrchr(desktop->exec, '/');
if (!exec++ || !exec) exec = desktop->exec; if (!exec++ || !exec) exec = desktop->exec;
m1 = evry_fuzzy_match(exec, input); m1 = evry->fuzzy_match(exec, input);
m2 = evry_fuzzy_match(desktop->name, input); m2 = evry->fuzzy_match(desktop->name, input);
if (!m1 || (m2 && m2 < m1)) if (!m1 || (m2 && m2 < m1))
m1 = m2; m1 = m2;
} }
if (!input || m1) _item_add(p, desktop, NULL, m1); if (!input || m1) _item_add(p, desktop, NULL, m1);
} }
} }
@ -432,7 +440,7 @@ _cb_sort(const void *data1, const void *data2)
if (it1->fuzzy_match - it2->fuzzy_match) if (it1->fuzzy_match - it2->fuzzy_match)
return (it1->fuzzy_match - it2->fuzzy_match); return (it1->fuzzy_match - it2->fuzzy_match);
} }
return 0; return 0;
} }
@ -453,18 +461,18 @@ _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fda
/* ignore executables for parameter */ /* ignore executables for parameter */
if (!strncmp(key, "_", 1)) if (!strncmp(key, "_", 1))
continue; continue;
if ((d = efreet_util_desktop_exec_find(key))) if ((d = efreet_util_desktop_exec_find(key)))
{ {
app = _item_add(p, d, NULL, 1); app = _item_add(p, d, NULL, 1);
} }
else else
{ {
app = _item_add(p, NULL, (char *) key, 1); app = _item_add(p, NULL, (char *) key, 1);
if (app && app->desktop) if (app && app->desktop)
efreet_desktop_ref(app->desktop); efreet_desktop_ref(app->desktop);
} }
if (app && app->desktop) if (app && app->desktop)
{ {
p->apps_hist = eina_list_append(p->apps_hist, app->desktop); p->apps_hist = eina_list_append(p->apps_hist, app->desktop);
@ -475,15 +483,6 @@ _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fda
return EINA_TRUE; return EINA_TRUE;
} }
static void
_cb_free_item_changed(void *data, void *event)
{
Evry_Event_Item_Changed *ev = event;
evry_item_free(ev->item);
E_FREE(ev);
}
/* TODO make this an option */ /* TODO make this an option */
static void static void
_add_executables(Plugin *p, const char *input) _add_executables(Plugin *p, const char *input)
@ -491,33 +490,32 @@ _add_executables(Plugin *p, const char *input)
Evry_Item_App *app; Evry_Item_App *app;
Evry_Item_App *app2; Evry_Item_App *app2;
Evry_Event_Item_Changed *ev;
Eina_List *l; Eina_List *l;
char buf[256]; char buf[256];
char *space, *file; char *space, *file;
int found_app = 0; int found_app = 0;
int found_cmd = 0; int found_cmd = 0;
int len; int len;
if (!input) goto end; if (!input) goto end;
if ((space = strchr(input, ' '))) if ((space = strchr(input, ' ')))
len = (space - input); len = (space - input);
else else
len = strlen(input); len = strlen(input);
if (len < 2) goto end; if (len < 2) goto end;
EINA_LIST_FOREACH(exe_list, l, file) EINA_LIST_FOREACH(exe_list, l, file)
{ {
if (strncmp(file, input, len)) continue; if (strncmp(file, input, len)) continue;
if (!(app = _item_add(p, NULL, file, 100))) if (!(app = _item_add(p, NULL, file, 100)))
continue; continue;
if ((space) && (app->desktop)) if ((space) && (app->desktop))
{ {
/* restore old desktop entry */ /* restore old desktop entry */
if (p->app_parameter) if (p->app_parameter)
{ {
@ -544,10 +542,7 @@ _add_executables(Plugin *p, const char *input)
if (!eina_list_data_find(p->base.items, app)) if (!eina_list_data_find(p->base.items, app))
EVRY_PLUGIN_ITEM_APPEND(p, app); EVRY_PLUGIN_ITEM_APPEND(p, app);
ev = E_NEW(Evry_Event_Item_Changed, 1); evry->item_changed(EVRY_ITEM(app), 0, 0);
evry_item_ref(EVRY_ITEM(app));
ev->item = EVRY_ITEM(app);
ecore_event_add(EVRY_EVENT_ITEM_CHANGED, ev, _cb_free_item_changed, NULL);
found_app = 1; found_app = 1;
} }
@ -556,7 +551,7 @@ _add_executables(Plugin *p, const char *input)
snprintf(buf, sizeof(buf), "_%s_", file); snprintf(buf, sizeof(buf), "_%s_", file);
app = _item_add(p, NULL, buf, 100); app = _item_add(p, NULL, buf, 100);
if (!app) continue; if (!app) continue;
eina_stringshare_del(EVRY_ITEM(app)->label); eina_stringshare_del(EVRY_ITEM(app)->label);
eina_stringshare_del(app->file); eina_stringshare_del(app->file);
@ -586,23 +581,20 @@ _add_executables(Plugin *p, const char *input)
snprintf(buf, sizeof(buf), "%s %s", file, space); snprintf(buf, sizeof(buf), "%s %s", file, space);
EVRY_ITEM(app)->label = eina_stringshare_add(buf); EVRY_ITEM(app)->label = eina_stringshare_add(buf);
app->file = eina_stringshare_add(buf); app->file = eina_stringshare_add(buf);
if (!eina_list_data_find(p->base.items, app)) if (!eina_list_data_find(p->base.items, app))
EVRY_PLUGIN_ITEM_APPEND(p, app); EVRY_PLUGIN_ITEM_APPEND(p, app);
ev = E_NEW(Evry_Event_Item_Changed, 1); evry->item_changed(EVRY_ITEM(app), 0, 0);
evry_item_ref(EVRY_ITEM(app));
ev->item = EVRY_ITEM(app);
ecore_event_add(EVRY_EVENT_ITEM_CHANGED, ev, _cb_free_item_changed, NULL);
found_cmd = 1; found_cmd = 1;
} }
} }
} }
end: end:
if (!found_app && p->app_parameter) if (!found_app && p->app_parameter)
{ {
/* restore old desktop entry */ /* restore old desktop entry */
@ -613,10 +605,10 @@ _add_executables(Plugin *p, const char *input)
EVRY_ITEM(app2)->label = eina_stringshare_add(app2->desktop->name); EVRY_ITEM(app2)->label = eina_stringshare_add(app2->desktop->name);
p->app_parameter = NULL; p->app_parameter = NULL;
} }
if (!found_cmd && p->app_command) if (!found_cmd && p->app_command)
{ {
eina_hash_del_by_data(p->added, p->app_command); eina_hash_del_by_data(p->added, p->app_command);
p->app_command = NULL; p->app_command = NULL;
} }
} }
@ -629,12 +621,12 @@ _fetch_mime(Evry_Plugin *plugin, const char *input)
Evry_Item *it; Evry_Item *it;
EVRY_PLUGIN_ITEMS_CLEAR(p); EVRY_PLUGIN_ITEMS_CLEAR(p);
/* add apps for a given mimetype */ /* add apps for a given mimetype */
_add_desktop_list(p, p->apps_mime, input); _add_desktop_list(p, p->apps_mime, input);
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(it, input, NULL);
if (input) if (input)
EVRY_PLUGIN_ITEMS_SORT(plugin, _cb_sort); EVRY_PLUGIN_ITEMS_SORT(plugin, _cb_sort);
@ -677,7 +669,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
if (input) if (input)
{ {
/* .desktop files */ /* .desktop files */
_add_desktop_list(p, p->apps_all, input); _add_desktop_list(p, p->apps_all, input);
/* add executables */ /* add executables */
@ -690,25 +682,25 @@ _fetch(Evry_Plugin *plugin, const char *input)
} }
EINA_LIST_FOREACH(plugin->items, l, it) EINA_LIST_FOREACH(plugin->items, l, it)
evry_history_item_usage_set(evry_hist->subjects, it, input, NULL); evry->history_item_usage_set(it, input, NULL);
EVRY_PLUGIN_ITEMS_SORT(plugin, _cb_sort); EVRY_PLUGIN_ITEMS_SORT(plugin, _cb_sort);
if (!input && !plugin->items) if (!input && !plugin->items)
{ {
/* add history items */ /* add history items */
if (!p->apps_hist) if (!p->apps_hist)
{ {
History_Types *ht; History_Types *ht;
ht = evry_history_types_get(evry_hist->subjects, EVRY_TYPE_APP); ht = evry->history_types_get(EVRY_TYPE_APP);
if (ht) if (ht)
eina_hash_foreach(ht->types, _hist_items_add_cb, p); eina_hash_foreach(ht->types, _hist_items_add_cb, p);
} }
else else
_add_desktop_list(p, p->apps_hist, NULL); _add_desktop_list(p, p->apps_hist, NULL);
} }
return !!(plugin->items); return !!(plugin->items);
} }
@ -716,13 +708,13 @@ static int
_complete(Evry_Plugin *plugin, const Evry_Item *it, char **input) _complete(Evry_Plugin *plugin, const Evry_Item *it, char **input)
{ {
GET_APP(app, it); GET_APP(app, it);
char buf[128]; char buf[128];
if (app->desktop) if (app->desktop)
{ {
char *space = strchr(app->desktop->exec, ' '); char *space = strchr(app->desktop->exec, ' ');
snprintf(buf, sizeof(buf), "%s ", app->desktop->exec); snprintf(buf, sizeof(buf), "%s ", app->desktop->exec);
if (space) if (space)
buf[1 + space - app->desktop->exec] = '\0'; buf[1 + space - app->desktop->exec] = '\0';
@ -731,7 +723,7 @@ _complete(Evry_Plugin *plugin, const Evry_Item *it, char **input)
snprintf(buf, sizeof(buf), "%s ", app->file); snprintf(buf, sizeof(buf), "%s ", app->file);
*input = strdup(buf); *input = strdup(buf);
return EVRY_COMPLETE_INPUT; return EVRY_COMPLETE_INPUT;
} }
@ -744,13 +736,13 @@ _exec_app_check_item(Evry_Action *act, const Evry_Item *it)
static int static int
_exec_app_action(Evry_Action *act) _exec_app_action(Evry_Action *act)
{ {
return evry_util_exec_app(act->it1.item, act->it2.item); return evry->util_exec_app(act->it1.item, act->it2.item);
} }
static int static int
_exec_file_action(Evry_Action *act) _exec_file_action(Evry_Action *act)
{ {
return evry_util_exec_app(act->it2.item, act->it1.item); return evry->util_exec_app(act->it2.item, act->it1.item);
} }
static int static int
@ -761,18 +753,18 @@ _exec_term_action(Evry_Action *act)
char buf[1024]; char buf[1024];
int ret; int ret;
char *escaped = ecore_file_escape_name(app->file); char *escaped = ecore_file_escape_name(app->file);
tmp = E_NEW(Evry_Item_App, 1); tmp = E_NEW(Evry_Item_App, 1);
snprintf(buf, sizeof(buf), "%s -hold -e %s", snprintf(buf, sizeof(buf), "%s -hold -e %s",
evry_conf->cmd_terminal, _conf->cmd_terminal,
(escaped ? escaped : app->file)); (escaped ? escaped : app->file));
tmp->file = buf; tmp->file = buf;
ret = evry_util_exec_app(EVRY_ITEM(tmp), NULL); ret = evry->util_exec_app(EVRY_ITEM(tmp), NULL);
E_FREE(tmp); E_FREE(tmp);
E_FREE(escaped); E_FREE(escaped);
return ret; return ret;
} }
@ -797,11 +789,11 @@ _exec_sudo_action(Evry_Action *act)
tmp = E_NEW(Evry_Item_App, 1); tmp = E_NEW(Evry_Item_App, 1);
snprintf(buf, sizeof(buf), "%s %s", snprintf(buf, sizeof(buf), "%s %s",
evry_conf->cmd_sudo, _conf->cmd_sudo,
(app->desktop ? app->desktop->exec : app->file)); (app->desktop ? app->desktop->exec : app->file));
tmp->file = buf; tmp->file = buf;
ret = evry_util_exec_app(EVRY_ITEM(tmp), NULL); ret = evry->util_exec_app(EVRY_ITEM(tmp), NULL);
E_FREE(tmp); E_FREE(tmp);
@ -913,7 +905,7 @@ _new_app_action(Evry_Action *act)
if (app->desktop->icon) if (app->desktop->icon)
desktop->icon = strdup(app->desktop->icon); desktop->icon = strdup(app->desktop->icon);
if (app->desktop->mime_types) if (app->desktop->mime_types)
desktop->mime_types = eina_list_clone(app->desktop->mime_types); desktop->mime_types = eina_list_clone(app->desktop->mime_types);
} }
if (desktop) if (desktop)
e_desktop_edit(e_container_current_get(e_manager_current_get()), desktop); e_desktop_edit(e_container_current_get(e_manager_current_get()), desktop);
@ -921,35 +913,79 @@ _new_app_action(Evry_Action *act)
return 1; return 1;
} }
static Eina_Bool static int
_plugins_init(void) _open_term_action(Evry_Action *act)
{
GET_FILE(file, act->it1.item);
Evry_Item_App *tmp;
char cwd[4096];
char *dir;
int ret = 0;
if (!(evry->file_path_get(file)))
return 0;
if (IS_BROWSEABLE(file))
dir = strdup(file->path);
else
dir = ecore_file_dir_get(file->path);
if (dir)
{
if (!getcwd(cwd, sizeof(cwd)))
return 0;
if (chdir(dir))
return 0;
tmp = E_NEW(Evry_Item_App, 1);
tmp->file = _conf->cmd_terminal;
ret = evry->util_exec_app(EVRY_ITEM(tmp), NULL);
E_FREE(tmp);
E_FREE(dir);
if (chdir(cwd))
return 0;
}
return ret;
}
static int
_plugins_init(const Evry_API *api)
{ {
Evry_Plugin *p; Evry_Plugin *p;
int prio = 0; int prio = 0;
Eina_List *l; Eina_List *l;
Evry_Action *act; Evry_Action *act;
if (!evry_api_version_check(EVRY_API_VERSION)) if (evry_module->active)
return EINA_TRUE;
evry = api;
if (!evry->api_version_check(EVRY_API_VERSION))
return EINA_FALSE; return EINA_FALSE;
evry_module->active = EINA_TRUE;
p = EVRY_PLUGIN_NEW(Plugin, N_("Applications"), NULL, EVRY_TYPE_APP, p = EVRY_PLUGIN_NEW(Plugin, N_("Applications"), NULL, EVRY_TYPE_APP,
_begin, _finish, _fetch, 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, EVRY_PLUGIN_SUBJECT, 1); evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 1);
plug_apps = p; plug_apps = p;
p = EVRY_PLUGIN_NEW(Plugin, N_("Applications"), NULL, EVRY_TYPE_APP, p = EVRY_PLUGIN_NEW(Plugin, N_("Applications"), NULL, EVRY_TYPE_APP,
_begin_open_with, _finish, _fetch, NULL); _begin_open_with, _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, EVRY_PLUGIN_OBJECT, 1); evry->plugin_register(p, EVRY_PLUGIN_OBJECT, 1);
plug_apps2 = p; plug_apps2 = p;
p = EVRY_PLUGIN_NEW(Plugin, N_("Open With..."), NULL, EVRY_TYPE_APP, p = EVRY_PLUGIN_NEW(Plugin, N_("Open With..."), NULL, EVRY_TYPE_APP,
_begin_open_with, _finish_mime, _fetch_mime, NULL); _begin_open_with, _finish_mime, _fetch_mime, NULL);
p->config_path = "extensions/everything-apps"; p->config_path = "extensions/everything-apps";
evry_plugin_register(p, EVRY_PLUGIN_ACTION, 1); evry->plugin_register(p, EVRY_PLUGIN_ACTION, 1);
plug_action = p; plug_action = p;
act = EVRY_ACTION_NEW(N_("Launch"), act = EVRY_ACTION_NEW(N_("Launch"),
@ -957,36 +993,36 @@ _plugins_init(void)
"everything-launch", "everything-launch",
_exec_app_action, _exec_app_action,
_exec_app_check_item); _exec_app_check_item);
_actions = eina_list_append(_actions, act); _actions = eina_list_append(_actions, act);
act = EVRY_ACTION_NEW(N_("Open File..."), act = EVRY_ACTION_NEW(N_("Open File..."),
EVRY_TYPE_APP, EVRY_TYPE_FILE, EVRY_TYPE_APP, EVRY_TYPE_FILE,
"document-open", "document-open",
_exec_app_action, _exec_app_action,
_exec_app_check_item); _exec_app_check_item);
_actions = eina_list_append(_actions, act); _actions = eina_list_append(_actions, act);
act = EVRY_ACTION_NEW(N_("Run in Terminal"), act = EVRY_ACTION_NEW(N_("Run in Terminal"),
EVRY_TYPE_APP, 0, EVRY_TYPE_APP, 0,
"system-run", "system-run",
_exec_term_action, _exec_term_action,
_exec_term_check_item); _exec_term_check_item);
_actions = eina_list_append(_actions, act); _actions = eina_list_append(_actions, act);
act = EVRY_ACTION_NEW(N_("Edit Application Entry"), act = EVRY_ACTION_NEW(N_("Edit Application Entry"),
EVRY_TYPE_APP, 0, EVRY_TYPE_APP, 0,
"everything-launch", "everything-launch",
_edit_app_action, _edit_app_action,
_edit_app_check_item); _edit_app_check_item);
_actions = eina_list_append(_actions, act); _actions = eina_list_append(_actions, act);
act = EVRY_ACTION_NEW(N_("New Application Entry"), act = EVRY_ACTION_NEW(N_("New Application Entry"),
EVRY_TYPE_APP, 0, EVRY_TYPE_APP, 0,
"everything-launch", "everything-launch",
_new_app_action, _new_app_action,
_new_app_check_item); _new_app_check_item);
_actions = eina_list_append(_actions, act); _actions = eina_list_append(_actions, act);
act = EVRY_ACTION_NEW(N_("Run with Sudo"), act = EVRY_ACTION_NEW(N_("Run with Sudo"),
EVRY_TYPE_APP, 0, EVRY_TYPE_APP, 0,
"system-run", "system-run",
@ -999,9 +1035,15 @@ _plugins_init(void)
_exec_file_action, NULL); _exec_file_action, NULL);
_act_open_with = EVRY_ITEM(act); _act_open_with = EVRY_ITEM(act);
_actions = eina_list_append(_actions, act); _actions = eina_list_append(_actions, act);
act = EVRY_ACTION_NEW(N_("Open Terminal here"),
EVRY_TYPE_FILE, 0,
"system-run",
_open_term_action, NULL);
_actions = eina_list_append(_actions, act);
EINA_LIST_FOREACH(_actions, l, act) EINA_LIST_FOREACH(_actions, l, act)
evry_action_register(act, prio++); evry->action_register(act, prio++);
return EINA_TRUE; return EINA_TRUE;
} }
@ -1010,22 +1052,29 @@ static void
_plugins_shutdown(void) _plugins_shutdown(void)
{ {
Evry_Action *act; Evry_Action *act;
if (!evry_module->active)
return;
EVRY_PLUGIN_FREE(plug_apps); EVRY_PLUGIN_FREE(plug_apps);
EVRY_PLUGIN_FREE(plug_apps2); EVRY_PLUGIN_FREE(plug_apps2);
EVRY_PLUGIN_FREE(plug_action); EVRY_PLUGIN_FREE(plug_action);
EINA_LIST_FREE(_actions, act) EINA_LIST_FREE(_actions, act)
evry_action_free(act); evry->action_free(act);
evry_module->active = EINA_FALSE;
} }
/***************************************************************************/ /***************************************************************************/
static E_Config_DD *conf_edd = NULL; static E_Config_DD *conf_edd = NULL;
struct _E_Config_Dialog_Data struct _E_Config_Dialog_Data
{ {
int list_executables; int list_executables;
char *cmd_terminal;
char *cmd_sudo;
}; };
static void *_create_data(E_Config_Dialog *cfd); static void *_create_data(E_Config_Dialog *cfd);
@ -1035,7 +1084,7 @@ static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dia
static int _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); static int _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static E_Config_Dialog * static E_Config_Dialog *
_conf_dialog(E_Container *con, const char *params) _conf_dialog(E_Container *con, const char *params)
{ {
E_Config_Dialog *cfd = NULL; E_Config_Dialog *cfd = NULL;
E_Config_Dialog_View *v = NULL; E_Config_Dialog_View *v = NULL;
@ -1053,8 +1102,8 @@ _conf_dialog(E_Container *con, const char *params)
snprintf(buf, sizeof(buf), "%s/e-module.edj", _conf->module->dir); snprintf(buf, sizeof(buf), "%s/e-module.edj", _conf->module->dir);
cfd = e_config_dialog_new(con, _("Everything Applications"), "everything-apps", cfd = e_config_dialog_new(con, _("Everything Applications"), "everything-apps",
"extensions/everything-apps", buf, 0, v, NULL); "extensions/everything-apps", buf, 0, v, NULL);
/* e_dialog_resizable_set(cfd->dia, 1); */ /* e_dialog_resizable_set(cfd->dia, 1); */
_conf->cfd = cfd; _conf->cfd = cfd;
@ -1063,7 +1112,7 @@ _conf_dialog(E_Container *con, const char *params)
/* Local Functions */ /* Local Functions */
static void * static void *
_create_data(E_Config_Dialog *cfd) _create_data(E_Config_Dialog *cfd)
{ {
E_Config_Dialog_Data *cfdata = NULL; E_Config_Dialog_Data *cfdata = NULL;
@ -1072,51 +1121,85 @@ _create_data(E_Config_Dialog *cfd)
return cfdata; return cfdata;
} }
static void static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{ {
_conf->cfd = NULL; _conf->cfd = NULL;
E_FREE(cfdata); E_FREE(cfdata);
} }
static void
_fill_data(E_Config_Dialog_Data *cfdata)
{
cfdata->list_executables = _conf->list_executables;
}
static Evas_Object * static Evas_Object *
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) _basic_create(E_Config_Dialog *cfd, Evas *e, E_Config_Dialog_Data *cfdata)
{ {
Evas_Object *o = NULL, *of = NULL, *ow = NULL; Evas_Object *o = NULL, *of = NULL, *ow = NULL;
o = e_widget_list_add(evas, 0, 0); o = e_widget_list_add(e, 0, 0);
of = e_widget_framelist_add(evas, _("General"), 0); of = e_widget_framelist_add(e, _("General"), 0);
e_widget_framelist_content_align_set(of, 0.0, 0.0); e_widget_framelist_content_align_set(of, 0.0, 0.0);
ow = e_widget_check_add(evas, _("Show Executables"), ow = e_widget_check_add(e, _("Show Executables"),
&(cfdata->list_executables)); &(cfdata->list_executables));
e_widget_framelist_object_append(of, ow); e_widget_framelist_object_append(of, ow);
e_widget_list_object_append(o, of, 1, 1, 0.5);
of = e_widget_framelist_add(e, _("Commands"), 0);
ow = e_widget_label_add(e, _("Terminal Command"));
e_widget_framelist_object_append(of, ow);
ow = e_widget_entry_add(e, &(cfdata->cmd_terminal), NULL, NULL, NULL);
e_widget_framelist_object_append(of, ow);
ow = e_widget_label_add(e, _("Sudo GUI"));
e_widget_framelist_object_append(of, ow);
ow = e_widget_entry_add(e, &(cfdata->cmd_sudo), NULL, NULL, NULL);
e_widget_framelist_object_append(of, ow);
e_widget_list_object_append(o, of, 1, 1, 0.5); e_widget_list_object_append(o, of, 1, 1, 0.5);
return o; return o;
} }
static int static void
_basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) _fill_data(E_Config_Dialog_Data *cfdata)
{ {
_conf->list_executables = cfdata->list_executables;
#define CP(_name) cfdata->_name = strdup(_conf->_name);
#define C(_name) cfdata->_name = _conf->_name;
C(list_executables);
CP(cmd_terminal);
CP(cmd_sudo);
#undef CP
#undef C
}
static int
_basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
#define CP(_name) \
if (_conf->_name) \
eina_stringshare_del(_conf->_name); \
_conf->_name = eina_stringshare_add(cfdata->_name);
#define C(_name) _conf->_name = cfdata->_name;
C(list_executables);
CP(cmd_terminal);
CP(cmd_sudo);
#undef CP
#undef C
e_config_domain_save("module.everything-apps", conf_edd, _conf); e_config_domain_save("module.everything-apps", conf_edd, _conf);
e_config_save_queue(); /* e_config_save_queue(); */
return 1; return 1;
} }
static void static void
_conf_new(void) _conf_new(void)
{ {
_conf = E_NEW(Module_Config, 1); if (!_conf)
_conf->version = (MOD_CONFIG_FILE_EPOCH << 16); {
_conf = E_NEW(Module_Config, 1);
_conf->version = (MOD_CONFIG_FILE_EPOCH << 16);
}
#define IFMODCFG(v) if ((_conf->version & 0xffff) < v) { #define IFMODCFG(v) if ((_conf->version & 0xffff) < v) {
#define IFMODCFGEND } #define IFMODCFGEND }
@ -1126,23 +1209,40 @@ _conf_new(void)
_conf->list_executables = 1; _conf->list_executables = 1;
IFMODCFGEND; IFMODCFGEND;
IFMODCFG(0x009d);
_conf->cmd_terminal = eina_stringshare_add("/usr/bin/xterm");
_conf->cmd_sudo = eina_stringshare_add("/usr/bin/gksudo --preserve-env");
IFMODCFGEND;
_conf->version = MOD_CONFIG_FILE_VERSION; _conf->version = MOD_CONFIG_FILE_VERSION;
e_config_save_queue(); /* e_config_save_queue(); */
}
static void
_conf_free(void)
{
if (!_conf) return;
IF_RELEASE(_conf->cmd_sudo);
IF_RELEASE(_conf->cmd_terminal);
E_FREE(_conf);
} }
static void static void
_conf_init(E_Module *m) _conf_init(E_Module *m)
{ {
char buf[4096]; char buf[4096];
snprintf(buf, sizeof(buf), "%s/e-module.edj", m->dir); snprintf(buf, sizeof(buf), "%s/e-module.edj", m->dir);
e_configure_registry_category_add("extensions", 80, _("Extensions"), e_configure_registry_category_add
NULL, "preferences-extensions"); ("extensions", 80, _("Extensions"), NULL,
"preferences-extensions");
e_configure_registry_item_add("extensions/everything-apps", 110, _("Everything Applications"), e_configure_registry_item_add
NULL, buf, _conf_dialog); ("extensions/everything-apps", 110,
_("Everything Applications"),
NULL, buf, _conf_dialog);
conf_edd = E_CONFIG_DD_NEW("Module_Config", Module_Config); conf_edd = E_CONFIG_DD_NEW("Module_Config", Module_Config);
@ -1152,30 +1252,27 @@ _conf_init(E_Module *m)
#define D conf_edd #define D conf_edd
E_CONFIG_VAL(D, T, version, INT); E_CONFIG_VAL(D, T, version, INT);
E_CONFIG_VAL(D, T, list_executables, UCHAR); E_CONFIG_VAL(D, T, list_executables, UCHAR);
E_CONFIG_VAL(D, T, cmd_terminal, STR);
E_CONFIG_VAL(D, T, cmd_sudo, STR);
#undef T #undef T
#undef D #undef D
_conf = e_config_domain_load("module.everything-apps", conf_edd); _conf = e_config_domain_load("module.everything-apps", conf_edd);
if (_conf)
{
if (!e_util_module_config_check
(_("Everything Applications"), _conf->version,
MOD_CONFIG_FILE_EPOCH, MOD_CONFIG_FILE_VERSION))
{
E_FREE(_conf);
}
}
if (!_conf) _conf_new(); if (_conf && !e_util_module_config_check
(_("Everything Applications"), _conf->version,
MOD_CONFIG_FILE_EPOCH, MOD_CONFIG_FILE_VERSION))
_conf_free();
_conf_new();
_conf->module = m; _conf->module = m;
} }
static void static void
_conf_shutdown(void) _conf_shutdown(void)
{ {
E_FREE(_conf); _conf_free();
E_CONFIG_DD_FREE(conf_edd); E_CONFIG_DD_FREE(conf_edd);
} }
@ -1184,7 +1281,7 @@ _conf_shutdown(void)
static Eina_Bool active = EINA_FALSE; static Eina_Bool active = EINA_FALSE;
EAPI E_Module_Api e_modapi = EAPI E_Module_Api e_modapi =
{ {
E_MODULE_API_VERSION, E_MODULE_API_VERSION,
"everything-apps" "everything-apps"
@ -1192,12 +1289,17 @@ EAPI E_Module_Api e_modapi =
EAPI void * EAPI void *
e_modapi_init(E_Module *m) e_modapi_init(E_Module *m)
{ {
if (e_datastore_get("everything_loaded"))
active = _plugins_init();
_conf_init(m); _conf_init(m);
evry_module = E_NEW(Evry_Module, 1);
evry_module->init = &_plugins_init;
evry_module->shutdown = &_plugins_shutdown;
EVRY_MODULE_REGISTER(evry_module);
if ((evry = e_datastore_get("everything_loaded")))
_plugins_init(evry);
/* taken from e_exebuf.c */ /* taken from e_exebuf.c */
exelist_exe_edd = E_CONFIG_DD_NEW("E_Exe", E_Exe); exelist_exe_edd = E_CONFIG_DD_NEW("E_Exe", E_Exe);
#undef T #undef T
@ -1212,8 +1314,8 @@ e_modapi_init(E_Module *m)
#define T E_Exe_List #define T E_Exe_List
#define D exelist_edd #define D exelist_edd
E_CONFIG_LIST(D, T, list, exelist_exe_edd); E_CONFIG_LIST(D, T, list, exelist_exe_edd);
e_module_delayed_set(m, 1); e_module_delayed_set(m, 1);
return m; return m;
} }
@ -1221,8 +1323,10 @@ e_modapi_init(E_Module *m)
EAPI int EAPI int
e_modapi_shutdown(E_Module *m) e_modapi_shutdown(E_Module *m)
{ {
if (active && e_datastore_get("everything_loaded")) _plugins_shutdown();
_plugins_shutdown();
EVRY_MODULE_UNREGISTER(evry_module);
E_FREE(evry_module);
_conf_shutdown(); _conf_shutdown();

View File

@ -5,7 +5,7 @@
#define E_MOD_MAIN_H #define E_MOD_MAIN_H
#define MOD_CONFIG_FILE_EPOCH 0x0001 #define MOD_CONFIG_FILE_EPOCH 0x0001
#define MOD_CONFIG_FILE_GENERATION 0x008d #define MOD_CONFIG_FILE_GENERATION 0x009d
#define MOD_CONFIG_FILE_VERSION \ #define MOD_CONFIG_FILE_VERSION \
((MOD_CONFIG_FILE_EPOCH << 16) | MOD_CONFIG_FILE_GENERATION) ((MOD_CONFIG_FILE_EPOCH << 16) | MOD_CONFIG_FILE_GENERATION)

View File

@ -15,7 +15,6 @@ typedef struct _Module_Config Module_Config;
static const Evry_API *evry = NULL; static const Evry_API *evry = NULL;
static Evry_Module *evry_module = NULL; static Evry_Module *evry_module = NULL;
static Eina_Bool active = EINA_FALSE;
static Module_Config *_conf; static Module_Config *_conf;
static char _config_path[] = "extensions/everthing-aspell"; static char _config_path[] = "extensions/everthing-aspell";
static char _config_domain[] = "module.everyhing-aspell"; static char _config_domain[] = "module.everyhing-aspell";
@ -394,7 +393,7 @@ _plugins_init(const Evry_API *_api)
{ {
Evry_Plugin *p; Evry_Plugin *p;
if (active) if (evry_module->active)
return EINA_TRUE; return EINA_TRUE;
evry = _api; evry = _api;
@ -423,7 +422,7 @@ _plugins_init(const Evry_API *_api)
_plug = (Plugin *) p; _plug = (Plugin *) p;
active = EINA_TRUE; evry_module->active = EINA_TRUE;
return EINA_TRUE; return EINA_TRUE;
} }
@ -431,11 +430,11 @@ _plugins_init(const Evry_API *_api)
static void static void
_plugins_shutdown(void) _plugins_shutdown(void)
{ {
if (!active) return; if (!evry_module->active) return;
EVRY_PLUGIN_FREE(_plug); EVRY_PLUGIN_FREE(_plug);
active = EINA_FALSE; evry_module->active = EINA_FALSE;
} }
/***************************************************************************/ /***************************************************************************/
@ -653,14 +652,14 @@ e_modapi_init(E_Module *m)
{ {
_conf_init(m); _conf_init(m);
if ((evry = e_datastore_get("everything_loaded")))
_plugins_init(evry);
evry_module = E_NEW(Evry_Module, 1); evry_module = E_NEW(Evry_Module, 1);
evry_module->init = &_plugins_init; evry_module->init = &_plugins_init;
evry_module->shutdown = &_plugins_shutdown; evry_module->shutdown = &_plugins_shutdown;
EVRY_MODULE_REGISTER(evry_module); EVRY_MODULE_REGISTER(evry_module);
if ((evry = e_datastore_get("everything_loaded")))
_plugins_init(evry);
e_module_delayed_set(m, 1); e_module_delayed_set(m, 1);
return m; return m;
@ -669,10 +668,11 @@ e_modapi_init(E_Module *m)
EAPI int EAPI int
e_modapi_shutdown(E_Module *m) e_modapi_shutdown(E_Module *m)
{ {
_plugins_shutdown();
EVRY_MODULE_UNREGISTER(evry_module); EVRY_MODULE_UNREGISTER(evry_module);
E_FREE(evry_module); E_FREE(evry_module);
_plugins_shutdown();
_conf_shutdown(); _conf_shutdown();
return 1; return 1;

View File

@ -13,7 +13,6 @@ static int _cb_del(void *data, int type, void *event);
static const Evry_API *evry = NULL; static const Evry_API *evry = NULL;
static Evry_Module *evry_module = NULL; static Evry_Module *evry_module = NULL;
static Eina_Bool active = EINA_FALSE;
static Evry_Plugin *p1; static Evry_Plugin *p1;
static Ecore_Exe *exe = NULL; static Ecore_Exe *exe = NULL;
@ -183,7 +182,7 @@ _cb_data(void *data, int type __UNUSED__, void *event)
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) evry->event_item_changed(it, 0, 0); if (it) evry->item_changed(it, 0, 0);
} }
return 1; return 1;
@ -217,7 +216,7 @@ _cb_del(void *data __UNUSED__, int type __UNUSED__, void *event)
static int static int
_plugins_init(const Evry_API *_api) _plugins_init(const Evry_API *_api)
{ {
if (active) if (evry_module->active)
return EINA_TRUE; return EINA_TRUE;
evry = _api; evry = _api;
@ -243,7 +242,7 @@ _plugins_init(const Evry_API *_api)
pc->trigger = eina_stringshare_add("="); pc->trigger = eina_stringshare_add("=");
} }
active = EINA_TRUE; evry_module->active = EINA_TRUE;
return EINA_TRUE; return EINA_TRUE;
} }
@ -251,12 +250,12 @@ _plugins_init(const Evry_API *_api)
static void static void
_plugins_shutdown(void) _plugins_shutdown(void)
{ {
if (!active) return; if (!evry_module->active) return;
printf("calc shut down\n"); printf("calc shut down\n");
EVRY_PLUGIN_FREE(p1); EVRY_PLUGIN_FREE(p1);
active = EINA_FALSE; evry_module->active = EINA_FALSE;
} }
/***************************************************************************/ /***************************************************************************/
@ -269,15 +268,15 @@ EAPI E_Module_Api e_modapi =
EAPI void * EAPI void *
e_modapi_init(E_Module *m) e_modapi_init(E_Module *m)
{ {
if ((evry = e_datastore_get("everything_loaded")))
_plugins_init(evry);
evry_module = E_NEW(Evry_Module, 1); evry_module = E_NEW(Evry_Module, 1);
evry_module->init = &_plugins_init; evry_module->init = &_plugins_init;
evry_module->shutdown = &_plugins_shutdown; evry_module->shutdown = &_plugins_shutdown;
EVRY_MODULE_REGISTER(evry_module); EVRY_MODULE_REGISTER(evry_module);
if ((evry = e_datastore_get("everything_loaded")))
_plugins_init(evry);
e_module_delayed_set(m, 1); e_module_delayed_set(m, 1);
return m; return m;
@ -286,11 +285,11 @@ e_modapi_init(E_Module *m)
EAPI int EAPI int
e_modapi_shutdown(E_Module *m) e_modapi_shutdown(E_Module *m)
{ {
_plugins_shutdown();
EVRY_MODULE_UNREGISTER(evry_module); EVRY_MODULE_UNREGISTER(evry_module);
E_FREE(evry_module); E_FREE(evry_module);
_plugins_shutdown();
return 1; return 1;
} }

View File

@ -4,8 +4,9 @@
/* TODO option for maximum items to cache */ /* TODO option for maximum items to cache */
#include "Evry.h" #include "e.h"
#include "e_mod_main.h" #include "e_mod_main.h"
#include "evry_api.h"
#include <Efreet_Trash.h> #include <Efreet_Trash.h>
#define MAX_ITEMS 10 #define MAX_ITEMS 10
@ -23,8 +24,8 @@
#define ACT_MOVE 4 #define ACT_MOVE 4
#define ONE_DAY 86400.0 #define ONE_DAY 86400.0
#define SIX_DAYS_AGO (ecore_time_get() - 518400.0) #define SIX_DAYS_AGO (ecore_time_get() - ONE_DAY * 6)
#define TIME_FACTOR(_now) (1.0 - (evry_hist->begin / _now)) / 1000000000000000.0 #define MIN_USAGE 0.000000000000000000001
/* #undef DBG /* #undef DBG
* #define DBG(...) ERR(__VA_ARGS__) */ * #define DBG(...) ERR(__VA_ARGS__) */
@ -83,6 +84,9 @@ struct _Module_Config
E_Module *module; E_Module *module;
}; };
static const Evry_API *evry = NULL;
static Evry_Module *evry_module = NULL;
static Module_Config *_conf; static Module_Config *_conf;
static char _module_icon[] = "system-file-manager"; static char _module_icon[] = "system-file-manager";
static Eina_List *_plugins = NULL; static Eina_List *_plugins = NULL;
@ -113,10 +117,10 @@ _item_fill(Evry_Item_File *file)
EVRY_ITEM(file)->context = eina_stringshare_ref(file->mime); EVRY_ITEM(file)->context = eina_stringshare_ref(file->mime);
if (!EVRY_ITEM(file)->detail) if (!EVRY_ITEM(file)->detail)
evry_util_file_detail_set(file); evry->util_file_detail_set(file);
evry_util_file_detail_set(file); evry->util_file_detail_set(file);
} }
static int static int
@ -278,7 +282,7 @@ _append_files(Plugin *p)
if (p->dirs_only && !it->browseable) if (p->dirs_only && !it->browseable)
continue; continue;
if (p->input && (match = evry_fuzzy_match(it->label, p->input))) if (p->input && (match = evry->fuzzy_match(it->label, p->input)))
{ {
it->fuzzy_match = match; it->fuzzy_match = match;
if (!it->browseable) if (!it->browseable)
@ -352,7 +356,7 @@ _scan_end_func(void *data)
int cnt = 0; int cnt = 0;
if (_conf->cache_dirs) if (_conf->cache_dirs)
ht = evry_history_types_get(evry_hist->subjects, EVRY_TYPE_FILE); ht = evry->history_types_get(EVRY_TYPE_FILE);
if (!d->run_cnt) if (!d->run_cnt)
{ {
@ -399,7 +403,7 @@ _scan_end_func(void *data)
item->id = eina_stringshare_ref(file->path); item->id = eina_stringshare_ref(file->path);
item->label = eina_stringshare_add(filename); item->label = eina_stringshare_add(filename);
evry_util_file_detail_set(file); evry->util_file_detail_set(file);
E_FREE(filename); E_FREE(filename);
E_FREE(path); E_FREE(path);
@ -457,10 +461,10 @@ _scan_end_func(void *data)
GET_FILE(file, item); GET_FILE(file, item);
if (!item->usage && if (!item->usage &&
(hi = evry_history_add(evry_hist->subjects, item, NULL, NULL))) (hi = evry->history_item_add(item, NULL, NULL)))
{ {
hi->last_used = SIX_DAYS_AGO - (0.001 * (double) cnt++); hi->last_used = SIX_DAYS_AGO - (0.001 * (double) cnt++);
hi->usage = TIME_FACTOR(hi->last_used); hi->usage = MIN_USAGE;
hi->data = eina_stringshare_ref(file->mime); hi->data = eina_stringshare_ref(file->mime);
item->hi = hi; item->hi = hi;
} }
@ -468,7 +472,7 @@ _scan_end_func(void *data)
(item->hi->last_used < SIX_DAYS_AGO)) (item->hi->last_used < SIX_DAYS_AGO))
{ {
item->hi->last_used = SIX_DAYS_AGO - (0.001 * (double) cnt++); item->hi->last_used = SIX_DAYS_AGO - (0.001 * (double) cnt++);
item->hi->usage = TIME_FACTOR(hi->last_used); item->hi->usage = MIN_USAGE;
} }
} }
} }
@ -497,7 +501,7 @@ _dir_watcher(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const c
{ {
case ECORE_FILE_EVENT_DELETED_SELF: case ECORE_FILE_EVENT_DELETED_SELF:
EINA_LIST_FREE(p->files, file) EINA_LIST_FREE(p->files, file)
evry_item_free(EVRY_ITEM(file)); evry->item_free(EVRY_ITEM(file));
break; break;
case ECORE_FILE_EVENT_CREATED_DIRECTORY: case ECORE_FILE_EVENT_CREATED_DIRECTORY:
@ -570,7 +574,7 @@ _browse(Evry_Plugin *plugin, const Evry_Item *it)
GET_PLUGIN(parent, plugin); GET_PLUGIN(parent, plugin);
GET_FILE(file, it); GET_FILE(file, it);
if (!evry_file_path_get(file) || if (!evry->file_path_get(file) ||
!ecore_file_is_dir(file->path)) !ecore_file_is_dir(file->path))
return NULL; return NULL;
@ -832,8 +836,8 @@ _recentf_append_files(Plugin *p)
if (it->fuzzy_match <= 0) if (it->fuzzy_match <= 0)
{ {
if ((match = evry_fuzzy_match(it->label, p->input)) || if ((match = evry->fuzzy_match(it->label, p->input)) ||
(match = evry_fuzzy_match(EVRY_FILE(it)->path, p->input))) (match = evry->fuzzy_match(EVRY_FILE(it)->path, p->input)))
it->fuzzy_match = match; it->fuzzy_match = match;
else else
it->fuzzy_match = 0; it->fuzzy_match = 0;
@ -872,7 +876,7 @@ _recentf_func(void *data)
EINA_LIST_FOREACH(d->files, l, file) EINA_LIST_FOREACH(d->files, l, file)
{ {
if ((!evry_file_path_get(file)) || if ((!evry->file_path_get(file)) ||
(!ecore_file_exists(file->path))) (!ecore_file_exists(file->path)))
{ {
EVRY_ITEM(file)->hi->last_used -= ONE_DAY; EVRY_ITEM(file)->hi->last_used -= ONE_DAY;
@ -914,7 +918,7 @@ _recentf_end_func(void *data)
if (!it->hi) if (!it->hi)
{ {
evry_item_free(it); evry->item_free(it);
continue; continue;
} }
@ -1012,8 +1016,8 @@ _recentf_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *
} }
} }
if (!(match = evry_fuzzy_match(label, p->input)) && if (!(match = evry->fuzzy_match(label, p->input)) &&
!(match = evry_fuzzy_match(path, p->input))) !(match = evry->fuzzy_match(path, p->input)))
{ {
/* DBG("not matched %s", path); */ /* DBG("not matched %s", path); */
eina_stringshare_del(path); eina_stringshare_del(path);
@ -1049,7 +1053,7 @@ _recentf_browse(Evry_Plugin *plugin, const Evry_Item *it)
GET_PLUGIN(parent, plugin); GET_PLUGIN(parent, plugin);
GET_FILE(file, it); GET_FILE(file, it);
if (!evry_file_path_get(file) || if (!evry->file_path_get(file) ||
!ecore_file_is_dir(file->path)) !ecore_file_is_dir(file->path))
return NULL; return NULL;
@ -1087,7 +1091,7 @@ _recentf_begin(Evry_Plugin *plugin, const Evry_Item *it)
if (clear_cache) if (clear_cache)
{ {
History_Types *ht = evry_history_types_get(evry_hist->subjects, EVRY_TYPE_FILE); History_Types *ht = evry->history_types_get(EVRY_TYPE_FILE);
if (ht) if (ht)
eina_hash_foreach(ht->types, _recentf_items_add_cb, p); eina_hash_foreach(ht->types, _recentf_items_add_cb, p);
@ -1126,7 +1130,7 @@ _recentf_fetch(Evry_Plugin *plugin, const char *input)
EINA_LIST_FOREACH(p->files, l, it) EINA_LIST_FOREACH(p->files, l, it)
it->fuzzy_match = -1; it->fuzzy_match = -1;
if ((ht = evry_history_types_get(evry_hist->subjects, EVRY_TYPE_FILE))) if ((ht = evry->history_types_get(EVRY_TYPE_FILE)))
{ {
Data *d = E_NEW(Data, 1); Data *d = E_NEW(Data, 1);
d->plugin = p; d->plugin = p;
@ -1163,7 +1167,7 @@ _open_folder_action(Evry_Action *act)
GET_FILE(file, act->it1.item); GET_FILE(file, act->it1.item);
if (!(evry_file_path_get(file))) if (!(evry->file_path_get(file)))
return 0; return 0;
m = e_manager_list(); m = e_manager_list();
@ -1183,44 +1187,6 @@ _open_folder_action(Evry_Action *act)
return 1; return 1;
} }
static int
_open_term_action(Evry_Action *act)
{
GET_FILE(file, act->it1.item);
Evry_Item_App *tmp;
char cwd[4096];
char *dir;
int ret = 0;
if (!(evry_file_path_get(file)))
return 0;
if (IS_BROWSEABLE(file))
dir = strdup(file->path);
else
dir = ecore_file_dir_get(file->path);
if (dir)
{
if (!getcwd(cwd, sizeof(cwd)))
return 0;
if (chdir(dir))
return 0;
tmp = E_NEW(Evry_Item_App, 1);
tmp->file = evry_conf->cmd_terminal;
ret = evry_util_exec_app(EVRY_ITEM(tmp), NULL);
E_FREE(tmp);
E_FREE(dir);
if (chdir(cwd))
return 0;
}
return ret;
}
static int static int
_file_trash_action(Evry_Action *act) _file_trash_action(Evry_Action *act)
{ {
@ -1230,7 +1196,7 @@ _file_trash_action(Evry_Action *act)
GET_FILE(file, act->it1.item); GET_FILE(file, act->it1.item);
if (!(evry_file_url_get(file))) if (!(evry->file_url_get(file)))
return 0; return 0;
euri = efreet_uri_decode(file->url); euri = efreet_uri_decode(file->url);
@ -1253,10 +1219,10 @@ _file_copy_action(Evry_Action *act)
char buf[PATH_MAX]; char buf[PATH_MAX];
char *ddst; char *ddst;
if (!(evry_file_path_get(src))) if (!(evry->file_path_get(src)))
return 0; return 0;
if (!(evry_file_path_get(dst))) if (!(evry->file_path_get(dst)))
return 0; return 0;
if (!ecore_file_is_dir(dst->path)) if (!ecore_file_is_dir(dst->path))
@ -1283,16 +1249,26 @@ _file_copy_action(Evry_Action *act)
return 0; return 0;
} }
static Eina_Bool static int
_plugins_init(void) _plugins_init(const Evry_API *api)
{ {
Evry_Action *act; Evry_Action *act;
Evry_Plugin *p; Evry_Plugin *p;
int prio = 0; int prio = 0;
if (!evry_api_version_check(EVRY_API_VERSION)) if (evry_module->active)
return EINA_TRUE;
evry = api;
if (!evry->api_version_check(EVRY_API_VERSION))
return EINA_FALSE; return EINA_FALSE;
_mime_dir = eina_stringshare_add("inode/directory");
_mime_mount = eina_stringshare_add("inode/mountpoint");
evry_module->active = EINA_TRUE;
#define PLUGIN_NEW(_name, _icon, _begin, _finish, _fetch) \ #define PLUGIN_NEW(_name, _icon, _begin, _finish, _fetch) \
p = EVRY_PLUGIN_NEW(Evry_Plugin, _name, _icon, EVRY_TYPE_FILE, \ p = EVRY_PLUGIN_NEW(Evry_Plugin, _name, _icon, EVRY_TYPE_FILE, \
_begin, _finish, _fetch, NULL); \ _begin, _finish, _fetch, NULL); \
@ -1303,26 +1279,26 @@ _plugins_init(void)
PLUGIN_NEW(N_("Files"), _module_icon, PLUGIN_NEW(N_("Files"), _module_icon,
_begin, _finish, _fetch); _begin, _finish, _fetch);
p->browse = &_browse; p->browse = &_browse;
if (evry_plugin_register(p, EVRY_PLUGIN_SUBJECT, 2)) if (evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 2))
p->config->min_query = 1; p->config->min_query = 1;
PLUGIN_NEW(N_("Files"), _module_icon, PLUGIN_NEW(N_("Files"), _module_icon,
_begin, _finish, _fetch); _begin, _finish, _fetch);
p->browse = &_browse; p->browse = &_browse;
evry_plugin_register(p, EVRY_PLUGIN_OBJECT, 2); evry->plugin_register(p, EVRY_PLUGIN_OBJECT, 2);
if (_conf->show_recent || _conf->search_recent) if (_conf->show_recent || _conf->search_recent)
{ {
PLUGIN_NEW(N_("Recent Files"), _module_icon, PLUGIN_NEW(N_("Recent Files"), _module_icon,
_recentf_begin, _finish, _recentf_fetch); _recentf_begin, _finish, _recentf_fetch);
p->browse = &_recentf_browse; p->browse = &_recentf_browse;
if (evry_plugin_register(p, EVRY_PLUGIN_SUBJECT, 3)) if (evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 3))
p->config->min_query = 3; p->config->min_query = 3;
PLUGIN_NEW(N_("Recent Files"), _module_icon, PLUGIN_NEW(N_("Recent Files"), _module_icon,
_recentf_begin, _finish, _recentf_fetch); _recentf_begin, _finish, _recentf_fetch);
p->browse = &_recentf_browse; p->browse = &_recentf_browse;
if (evry_plugin_register(p, EVRY_PLUGIN_OBJECT, 3)) if (evry->plugin_register(p, EVRY_PLUGIN_OBJECT, 3))
p->config->min_query = 3; p->config->min_query = 3;
} }
@ -1330,7 +1306,7 @@ _plugins_init(void)
#define ACTION_NEW(_name, _type2, _icon, _act, _check) \ #define ACTION_NEW(_name, _type2, _icon, _act, _check) \
act = EVRY_ACTION_NEW(_name, EVRY_TYPE_FILE, _type2, _icon, _act, _check); \ act = EVRY_ACTION_NEW(_name, EVRY_TYPE_FILE, _type2, _icon, _act, _check); \
evry_action_register(act, prio++); \ evry->action_register(act, prio++); \
_actions = eina_list_append(_actions, act); \ _actions = eina_list_append(_actions, act); \
ACTION_NEW(N_("Copy To ..."), EVRY_TYPE_FILE, "go-next", ACTION_NEW(N_("Copy To ..."), EVRY_TYPE_FILE, "go-next",
@ -1350,9 +1326,6 @@ _plugins_init(void)
ACTION_NEW(N_("Open Folder (EFM)"), 0, "folder-open", ACTION_NEW(N_("Open Folder (EFM)"), 0, "folder-open",
_open_folder_action, _open_folder_check); _open_folder_action, _open_folder_check);
act->remember_context = EINA_TRUE; act->remember_context = EINA_TRUE;
ACTION_NEW(N_("Open Terminal here"), 0, "system-run",
_open_term_action, NULL);
#undef ACTION_NEW #undef ACTION_NEW
return EINA_TRUE; return EINA_TRUE;
@ -1364,11 +1337,19 @@ _plugins_shutdown(void)
Evry_Action *act; Evry_Action *act;
Evry_Plugin *p; Evry_Plugin *p;
if (!evry_module->active)
return;
eina_stringshare_del(_mime_dir);
eina_stringshare_del(_mime_mount);
EINA_LIST_FREE(_plugins, p) EINA_LIST_FREE(_plugins, p)
evry_plugin_free(p); evry->plugin_free(p);
EINA_LIST_FREE(_actions, act) EINA_LIST_FREE(_actions, act)
evry_action_free(act); evry->action_free(act);
evry_module->active = EINA_FALSE;
} }
@ -1575,47 +1556,46 @@ static void
_conf_shutdown(void) _conf_shutdown(void)
{ {
E_FREE(_conf); E_FREE(_conf);
E_CONFIG_DD_FREE(conf_edd); E_CONFIG_DD_FREE(conf_edd);
} }
/***************************************************************************/ /***************************************************************************/
static Eina_Bool active = EINA_FALSE;
EAPI E_Module_Api e_modapi = EAPI E_Module_Api e_modapi =
{ {
E_MODULE_API_VERSION, E_MODULE_API_VERSION,
"everything-files" "everything-files"
}; };
EAPI void * EAPI void *
e_modapi_init(E_Module *m) e_modapi_init(E_Module *m)
{ {
_conf_init(m); _conf_init(m);
if (e_datastore_get("everything_loaded")) evry_module = E_NEW(Evry_Module, 1);
active = _plugins_init(); evry_module->init = &_plugins_init;
evry_module->shutdown = &_plugins_shutdown;
_mime_dir = eina_stringshare_add("inode/directory"); EVRY_MODULE_REGISTER(evry_module);
_mime_mount = eina_stringshare_add("inode/mountpoint");
if ((evry = e_datastore_get("everything_loaded")))
_plugins_init(evry);
e_module_delayed_set(m, 1); e_module_delayed_set(m, 1);
return m; return m;
} }
EAPI int EAPI int
e_modapi_shutdown(E_Module *m) e_modapi_shutdown(E_Module *m)
{ {
if (active && e_datastore_get("everything_loaded")) _plugins_shutdown();
_plugins_shutdown();
EVRY_MODULE_UNREGISTER(evry_module);
eina_stringshare_del(_mime_dir); E_FREE(evry_module);
eina_stringshare_del(_mime_mount);
_conf_shutdown(); _conf_shutdown();
return 1; return 1;
} }

View File

@ -19,7 +19,6 @@ struct _Settings_Item
static const Evry_API *evry = NULL; static const Evry_API *evry = NULL;
static Evry_Module *evry_module = NULL; static Evry_Module *evry_module = NULL;
static Eina_Bool active = EINA_FALSE;
static Evry_Plugin *p; static Evry_Plugin *p;
static Evry_Action *act; static Evry_Action *act;
static Eina_List *items = NULL; static Eina_List *items = NULL;
@ -105,7 +104,7 @@ _action(Evry_Action *act)
static int static int
_plugins_init(const Evry_API *_api) _plugins_init(const Evry_API *_api)
{ {
if (active) if (evry_module->active)
return EINA_TRUE; return EINA_TRUE;
evry = _api; evry = _api;
@ -125,7 +124,7 @@ _plugins_init(const Evry_API *_api)
evry->action_register(act, 0); evry->action_register(act, 0);
active = EINA_TRUE; evry_module->active = EINA_TRUE;
return EINA_TRUE; return EINA_TRUE;
} }
@ -133,13 +132,13 @@ _plugins_init(const Evry_API *_api)
static void static void
_plugins_shutdown(void) _plugins_shutdown(void)
{ {
if (!active) return; if (!evry_module->active) return;
EVRY_PLUGIN_FREE(p); EVRY_PLUGIN_FREE(p);
evry->action_free(act); evry->action_free(act);
active = EINA_FALSE; evry_module->active = EINA_FALSE;
} }
@ -153,15 +152,15 @@ EAPI E_Module_Api e_modapi =
EAPI void * EAPI void *
e_modapi_init(E_Module *m) e_modapi_init(E_Module *m)
{ {
if ((evry = e_datastore_get("everything_loaded")))
_plugins_init(evry);
evry_module = E_NEW(Evry_Module, 1); evry_module = E_NEW(Evry_Module, 1);
evry_module->init = &_plugins_init; evry_module->init = &_plugins_init;
evry_module->shutdown = &_plugins_shutdown; evry_module->shutdown = &_plugins_shutdown;
EVRY_MODULE_REGISTER(evry_module); EVRY_MODULE_REGISTER(evry_module);
if ((evry = e_datastore_get("everything_loaded")))
_plugins_init(evry);
e_module_delayed_set(m, 1); e_module_delayed_set(m, 1);
return m; return m;
@ -170,10 +169,10 @@ e_modapi_init(E_Module *m)
EAPI int EAPI int
e_modapi_shutdown(E_Module *m) e_modapi_shutdown(E_Module *m)
{ {
_plugins_shutdown();
EVRY_MODULE_UNREGISTER(evry_module); EVRY_MODULE_UNREGISTER(evry_module);
E_FREE(evry_module); E_FREE(evry_module);
_plugins_shutdown();
return 1; return 1;
} }

View File

@ -32,7 +32,6 @@ static int _import_cb_edje_cc_exit(void *data, int type, void *event);
static const Evry_API *evry = NULL; static const Evry_API *evry = NULL;
static Evry_Module *evry_module = NULL; static Evry_Module *evry_module = NULL;
static Eina_Bool active = EINA_FALSE;
static Import *import = NULL; static Import *import = NULL;
static Evry_Action *_act; static Evry_Action *_act;
@ -109,7 +108,7 @@ _plugins_init(const Evry_API *_api)
{ {
Evry_Plugin *p; Evry_Plugin *p;
if (active) if (evry_module->active)
return EINA_TRUE; return EINA_TRUE;
evry = _api; evry = _api;
@ -127,7 +126,7 @@ _plugins_init(const Evry_API *_api)
evry->action_register(_act, 2); evry->action_register(_act, 2);
active = EINA_TRUE; evry_module->active = EINA_TRUE;
return EINA_TRUE; return EINA_TRUE;
} }
@ -135,11 +134,11 @@ _plugins_init(const Evry_API *_api)
static void static void
_plugins_shutdown(void) _plugins_shutdown(void)
{ {
if (!active) return; if (!evry_module->active) return;
evry->action_free(_act); evry->action_free(_act);
active = EINA_FALSE; evry_module->active = EINA_FALSE;
} }
/* taken from e_int_config_wallpaper_import.c */ /* taken from e_int_config_wallpaper_import.c */
@ -373,16 +372,14 @@ EAPI E_Module_Api e_modapi =
EAPI void * EAPI void *
e_modapi_init(E_Module *m) e_modapi_init(E_Module *m)
{ {
Eina_List *l;
if ((evry = e_datastore_get("everything_loaded")))
_plugins_init(evry);
evry_module = E_NEW(Evry_Module, 1); evry_module = E_NEW(Evry_Module, 1);
evry_module->init = &_plugins_init; evry_module->init = &_plugins_init;
evry_module->shutdown = &_plugins_shutdown; evry_module->shutdown = &_plugins_shutdown;
EVRY_MODULE_REGISTER(evry_module); EVRY_MODULE_REGISTER(evry_module);
if ((evry = e_datastore_get("everything_loaded")))
_plugins_init(evry);
e_module_delayed_set(m, 1); e_module_delayed_set(m, 1);
return m; return m;
@ -391,12 +388,10 @@ e_modapi_init(E_Module *m)
EAPI int EAPI int
e_modapi_shutdown(E_Module *m) e_modapi_shutdown(E_Module *m)
{ {
Eina_List *l; _plugins_shutdown();
EVRY_MODULE_UNREGISTER(evry_module); EVRY_MODULE_UNREGISTER(evry_module);
E_FREE(evry_module); E_FREE(evry_module);
_plugins_shutdown();
return 1; return 1;
} }

View File

@ -14,7 +14,6 @@
static const Evry_API *evry = NULL; static const Evry_API *evry = NULL;
static Evry_Module *evry_module = NULL; static Evry_Module *evry_module = NULL;
static Eina_Bool active = EINA_FALSE;
static Evry_Plugin *p1; static Evry_Plugin *p1;
static Eina_List *handlers = NULL; static Eina_List *handlers = NULL;
@ -352,7 +351,7 @@ _plugins_init(const Evry_API *_api)
Evry_Plugin *p; Evry_Plugin *p;
Evry_Action *act; Evry_Action *act;
if (active) if (evry_module->active)
return EINA_TRUE; return EINA_TRUE;
evry = _api; evry = _api;
@ -403,7 +402,7 @@ _plugins_init(const Evry_API *_api)
_actions = eina_list_append(_actions, act); _actions = eina_list_append(_actions, act);
evry->action_register(act, 3); evry->action_register(act, 3);
active = EINA_TRUE; evry_module->active = EINA_TRUE;
return EINA_TRUE; return EINA_TRUE;
} }
@ -413,14 +412,14 @@ _plugins_shutdown(void)
{ {
Evry_Action *act; Evry_Action *act;
if (!active) return; if (!evry_module->active) return;
EVRY_PLUGIN_FREE(p1); EVRY_PLUGIN_FREE(p1);
EINA_LIST_FREE(_actions, act) EINA_LIST_FREE(_actions, act)
evry->action_free(act); evry->action_free(act);
active = EINA_FALSE; evry_module->active = EINA_FALSE;
} }
/***************************************************************************/ /***************************************************************************/
@ -435,14 +434,14 @@ EAPI E_Module_Api e_modapi =
EAPI void * EAPI void *
e_modapi_init(E_Module *m) e_modapi_init(E_Module *m)
{ {
if ((evry = e_datastore_get("everything_loaded")))
_plugins_init(evry);
evry_module = E_NEW(Evry_Module, 1); evry_module = E_NEW(Evry_Module, 1);
evry_module->init = &_plugins_init; evry_module->init = &_plugins_init;
evry_module->shutdown = &_plugins_shutdown; evry_module->shutdown = &_plugins_shutdown;
EVRY_MODULE_REGISTER(evry_module); EVRY_MODULE_REGISTER(evry_module);
if ((evry = e_datastore_get("everything_loaded")))
_plugins_init(evry);
e_module_delayed_set(m, 1); e_module_delayed_set(m, 1);
return m; return m;
@ -451,11 +450,11 @@ e_modapi_init(E_Module *m)
EAPI int EAPI int
e_modapi_shutdown(E_Module *m) e_modapi_shutdown(E_Module *m)
{ {
_plugins_shutdown();
EVRY_MODULE_UNREGISTER(evry_module); EVRY_MODULE_UNREGISTER(evry_module);
E_FREE(evry_module); E_FREE(evry_module);
_plugins_shutdown();
return 1; return 1;
} }

View File

@ -2,32 +2,9 @@
#define EVRY_H #define EVRY_H
#include "e.h" #include "e.h"
#include "evry_api.h"
#include "evry_types.h" #include "evry_types.h"
#define EVRY_API_VERSION 18
#define EVRY_ACTION_OTHER 0
#define EVRY_ACTION_FINISHED 1
#define EVRY_ACTION_CONTINUE 2
#define EVRY_UPDATE_ADD 0
#define EVRY_UPDATE_CLEAR 1
#define EVRY_UPDATE_REFRESH 2
#define EVRY_COMPLETE_NONE 0
#define EVRY_COMPLETE_INPUT 1
#define EVRY_COMPLETE_BROWSE 2
#define VIEW_MODE_NONE -1
#define VIEW_MODE_LIST 0
#define VIEW_MODE_DETAIL 1
#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
@ -47,8 +24,6 @@ extern int _e_module_evry_log_dom;
typedef struct _Evry_State Evry_State; typedef struct _Evry_State Evry_State;
typedef struct _Evry_View Evry_View; typedef struct _Evry_View Evry_View;
typedef struct _History Evry_History; typedef struct _History Evry_History;
typedef struct _History_Entry History_Entry;
typedef struct _History_Types History_Types;
typedef struct _Config Evry_Config; typedef struct _Config Evry_Config;
typedef struct _Evry_Event_Item_Changed Evry_Event_Item_Changed; typedef struct _Evry_Event_Item_Changed Evry_Event_Item_Changed;
@ -226,9 +201,6 @@ struct _Config
/* quick navigation mode */ /* quick navigation mode */
int quick_nav; int quick_nav;
const char *cmd_terminal;
const char *cmd_sudo;
/* default view mode */ /* default view mode */
int view_mode; int view_mode;
int view_zoom; int view_zoom;
@ -247,21 +219,10 @@ struct _Config
int min_w, min_h; int min_w, min_h;
}; };
struct _History_Entry
{
Eina_List *items;
};
struct _History_Types
{
Eina_Hash *types;
};
struct _History struct _History
{ {
int version; int version;
Eina_Hash *subjects; Eina_Hash *subjects;
Eina_Hash *actions;
double begin; double begin;
Eina_Bool changed; Eina_Bool changed;
@ -296,7 +257,7 @@ EAPI int evry_util_module_config_check(const char *module_name, int conf, int ep
EAPI Evas_Object *evry_util_icon_get(Evry_Item *it, Evas *e); EAPI Evas_Object *evry_util_icon_get(Evry_Item *it, Evas *e);
EAPI int evry_util_plugin_items_add(Evry_Plugin *p, Eina_List *items, const char *input, int match_detail, int set_usage); EAPI int evry_util_plugin_items_add(Evry_Plugin *p, Eina_List *items, const char *input, int match_detail, int set_usage);
EAPI int evry_items_sort_func(const void *data1, const void *data2); EAPI int evry_items_sort_func(const void *data1, const void *data2);
EAPI void evry_event_item_changed(Evry_Item *it, int change_icon, int change_selected); EAPI void evry_item_changed(Evry_Item *it, int change_icon, int change_selected);
EAPI char *evry_util_md5_sum(const char *str); EAPI char *evry_util_md5_sum(const char *str);
EAPI const char *evry_file_path_get(Evry_Item_File *file); EAPI const char *evry_file_path_get(Evry_Item_File *file);
@ -316,9 +277,9 @@ EAPI Evry_Action *evry_action_find(const char *name);
EAPI void evry_history_load(void); EAPI void evry_history_load(void);
EAPI void evry_history_unload(void); 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_item_add(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(Evry_Item *it, const char *input, const char *ctxt);
EAPI History_Types *evry_history_types_get(Eina_Hash *hist, Evry_Type type); EAPI History_Types *evry_history_types_get(Evry_Type type);
EAPI Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, const char *icon, EAPI Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, const char *icon,
Evry_Type item_type, Evry_Type item_type,
@ -342,18 +303,6 @@ EAPI int evry_api_version_check(int version);
EAPI Evry_Type evry_type_register(const char *type); EAPI Evry_Type evry_type_register(const char *type);
EAPI const char *evry_type_get(Evry_Type type); EAPI const char *evry_type_get(Evry_Type type);
EAPI extern int EVRY_EVENT_ITEM_SELECT;
EAPI extern int EVRY_EVENT_ITEM_CHANGED;
EAPI extern int EVRY_EVENT_ITEMS_UPDATE;
EAPI extern Evry_Type EVRY_TYPE_NONE;
EAPI extern Evry_Type EVRY_TYPE_FILE;
EAPI extern Evry_Type EVRY_TYPE_DIR;
EAPI extern Evry_Type EVRY_TYPE_APP;
EAPI extern Evry_Type EVRY_TYPE_ACTION;
EAPI extern Evry_Type EVRY_TYPE_PLUGIN;
EAPI extern Evry_Type EVRY_TYPE_BORDER;
EAPI extern Evry_Type EVRY_TYPE_TEXT;
EAPI extern Evry_History *evry_hist; EAPI extern Evry_History *evry_hist;
EAPI extern Evry_Config *evry_conf; EAPI extern Evry_Config *evry_conf;

View File

@ -8,7 +8,6 @@
*/ */
#include "e_mod_main.h" #include "e_mod_main.h"
#include "evry_api.h"
/* #undef DBG /* #undef DBG
* #define DBG(...) ERR(__VA_ARGS__) */ * #define DBG(...) ERR(__VA_ARGS__) */
@ -199,9 +198,12 @@ e_modapi_init(E_Module *m)
SET(util_md5_sum); SET(util_md5_sum);
SET(util_icon_get); SET(util_icon_get);
SET(items_sort_func); SET(items_sort_func);
SET(event_item_changed); SET(item_changed);
SET(file_path_get); SET(file_path_get);
SET(file_url_get); SET(file_url_get);
SET(history_item_add);
SET(history_types_get);
SET(history_item_usage_set);
#undef SET #undef SET
e_datastore_set("everything_loaded", _api); e_datastore_set("everything_loaded", _api);
@ -325,8 +327,6 @@ _config_init()
E_CONFIG_VAL(D, T, hide_input, INT); E_CONFIG_VAL(D, T, hide_input, INT);
E_CONFIG_VAL(D, T, hide_list, INT); E_CONFIG_VAL(D, T, hide_list, INT);
E_CONFIG_VAL(D, T, quick_nav, INT); E_CONFIG_VAL(D, T, quick_nav, INT);
E_CONFIG_VAL(D, T, cmd_terminal, STR);
E_CONFIG_VAL(D, T, cmd_sudo, STR);
E_CONFIG_VAL(D, T, view_mode, INT); E_CONFIG_VAL(D, T, view_mode, INT);
E_CONFIG_VAL(D, T, view_zoom, INT); E_CONFIG_VAL(D, T, view_zoom, INT);
E_CONFIG_VAL(D, T, cycle_mode, INT); E_CONFIG_VAL(D, T, cycle_mode, INT);
@ -395,8 +395,6 @@ _config_init()
evry_conf->hide_input = 0; evry_conf->hide_input = 0;
evry_conf->hide_list = 0; evry_conf->hide_list = 0;
evry_conf->quick_nav = 1; evry_conf->quick_nav = 1;
evry_conf->cmd_terminal = eina_stringshare_add("/usr/bin/xterm");
evry_conf->cmd_sudo = eina_stringshare_add("/usr/bin/gksudo --preserve-env");
evry_conf->view_mode = VIEW_MODE_DETAIL; evry_conf->view_mode = VIEW_MODE_DETAIL;
evry_conf->view_zoom = 0; evry_conf->view_zoom = 0;
evry_conf->cycle_mode = 0; evry_conf->cycle_mode = 0;
@ -438,11 +436,6 @@ _config_free(void)
{ {
_plugin_config_free(); _plugin_config_free();
if (evry_conf->cmd_terminal)
eina_stringshare_del(evry_conf->cmd_terminal);
if (evry_conf->cmd_sudo)
eina_stringshare_del(evry_conf->cmd_sudo);
E_FREE(evry_conf); E_FREE(evry_conf);
} }

View File

@ -35,8 +35,6 @@ struct _Evry_Selector
Evas_Object *o_thumb; Evas_Object *o_thumb;
Eina_Bool do_thumb; Eina_Bool do_thumb;
Eina_Hash *history;
Ecore_Timer *update_timer; Ecore_Timer *update_timer;
}; };

View File

@ -824,21 +824,18 @@ _evry_selector_new(int type)
if (type == EVRY_PLUGIN_SUBJECT) if (type == EVRY_PLUGIN_SUBJECT)
{ {
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 == EVRY_PLUGIN_ACTION) else if (type == EVRY_PLUGIN_ACTION)
{ {
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 == EVRY_PLUGIN_OBJECT) else if (type == EVRY_PLUGIN_OBJECT)
{ {
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);
pcs = evry_conf->conf_objects; pcs = evry_conf->conf_objects;
} }
@ -1333,7 +1330,7 @@ evry_browse_item(Evry_Selector *sel)
if (browse_aggregator) if (browse_aggregator)
{ {
evry_history_add(sel->history, s->cur_item, NULL, NULL); evry_history_item_add(s->cur_item, NULL, NULL);
snprintf(sel->state->input, INPUTLEN, "%s", s->input); snprintf(sel->state->input, INPUTLEN, "%s", s->input);
s = new_state; s = new_state;
@ -1344,7 +1341,7 @@ evry_browse_item(Evry_Selector *sel)
} }
else if (it->plugin->history) else if (it->plugin->history)
{ {
evry_history_add(sel->history, s->cur_item, NULL, s->input); evry_history_item_add(s->cur_item, NULL, s->input);
_evry_matches_update(sel, 1); _evry_matches_update(sel, 1);
s = new_state; s = new_state;
} }
@ -1604,8 +1601,7 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
Eina_List *l, *ll; Eina_List *l, *ll;
Evry_Item *it = s->cur_item; Evry_Item *it = s->cur_item;
if (!(he = eina_hash_find if (!(he = eina_hash_find(evry_hist->subjects, (it->id ? it->id : it->label))))
(selector->history, (it->id ? it->id : it->label))))
goto end; goto end;
EINA_LIST_FOREACH_SAFE(he->items, l, ll, hi) EINA_LIST_FOREACH_SAFE(he->items, l, ll, hi)
@ -1920,13 +1916,13 @@ _evry_plugin_action(Evry_Selector *sel, int finished)
else return; else return;
if (s_subj && it_subj && it_subj->plugin->history) if (s_subj && it_subj && it_subj->plugin->history)
evry_history_add(evry_hist->subjects, it_subj, NULL, s_subj->input); evry_history_item_add(it_subj, NULL, s_subj->input);
if (s_act && it_act && it_act->plugin->history) if (s_act && it_act && it_act->plugin->history)
evry_history_add(evry_hist->actions, it_act, it_subj->context, s_act->input); evry_history_item_add(it_act, it_subj->context, s_act->input);
if (s_obj && it_obj && it_obj->plugin->history) if (s_obj && it_obj && it_obj->plugin->history)
evry_history_add(evry_hist->subjects, it_obj, it_act->context, s_obj->input); evry_history_item_add(it_obj, it_act->context, s_obj->input);
if (finished) if (finished)
evry_hide(0); evry_hide(0);

View File

@ -1,10 +1,9 @@
#ifndef EVRY_API_H #ifndef EVRY_API_H
#define EVRY_API_H #define EVRY_API_H
#ifndef EVRY_H
#include "evry_types.h" #include "evry_types.h"
#define EVRY_API_VERSION 18 #define EVRY_API_VERSION 19
#define EVRY_ACTION_OTHER 0 #define EVRY_ACTION_OTHER 0
#define EVRY_ACTION_FINISHED 1 #define EVRY_ACTION_FINISHED 1
@ -36,28 +35,41 @@ EAPI extern Evry_Type EVRY_TYPE_PLUGIN;
EAPI extern Evry_Type EVRY_TYPE_BORDER; EAPI extern Evry_Type EVRY_TYPE_BORDER;
EAPI extern Evry_Type EVRY_TYPE_TEXT; EAPI extern Evry_Type EVRY_TYPE_TEXT;
#endif EAPI extern int EVRY_EVENT_ITEM_SELECT;
EAPI extern int EVRY_EVENT_ITEM_CHANGED;
EAPI extern int EVRY_EVENT_ITEMS_UPDATE;
typedef struct _Evry_API Evry_API; typedef struct _Evry_API Evry_API;
typedef struct _Evry_Module Evry_Module; typedef struct _Evry_Module Evry_Module;
/*************************************************** /***************************************************
register module struct:
Eina_List *l; static Evry_Module *evry_module;
Evry_Module *em; static const Evry_API evry;
in e_modapi_init do:
evry_module = E_NEW(Evry_Module, 1);
evry_module->init = &_plugins_init;
evry_module->shutdown = &_plugins_shutdown;
EVRY_MODULE_REGISTER(evry_module);
if ((evry = e_datastore_get("everything_loaded")))
_plugins_init(evry);
in e_modapi_shutdown:
_plugins_shutdown();
em = E_NEW(Evry_Module, 1); EVRY_MODULE_UNREGISTER(evry_module);
em->init = &_your_init_func; E_FREE(evry_module);
em->shutdown = &_your_shutdown_func;
l = e_datastore_get("everything_modules");
l = eina_list_append(l, em);
e_datastore_set("everything_modules", l);
***************************************************/ ***************************************************/
struct _Evry_Module struct _Evry_Module
{ {
Eina_Bool active;
int (*init)(const Evry_API *api); int (*init)(const Evry_API *api);
void (*shutdown)(void); void (*shutdown)(void);
}; };
@ -72,7 +84,9 @@ struct _Evry_API
void (*item_free)(Evry_Item *it); void (*item_free)(Evry_Item *it);
void (*item_ref)(Evry_Item *it); void (*item_ref)(Evry_Item *it);
/* send EVRY_EVENT_ITEM_CHANGED event */
void (*item_changed)(Evry_Item *it, int change_icon, int change_selected);
Evry_Plugin *(*plugin_new)(Evry_Plugin *base, const char *name, Evry_Plugin *(*plugin_new)(Evry_Plugin *base, const char *name,
const char *label, const char *icon, const char *label, const char *icon,
Evry_Type item_type, Evry_Type item_type,
@ -112,29 +126,27 @@ struct _Evry_API
char *(*util_md5_sum)(const char *str); char *(*util_md5_sum)(const char *str);
Evas_Object *(*util_icon_get)(Evry_Item *it, Evas *e); Evas_Object *(*util_icon_get)(Evry_Item *it, Evas *e);
int (*items_sort_func)(const void *data1, const void *data2); int (*items_sort_func)(const void *data1, const void *data2);
void (*event_item_changed)(Evry_Item *it, int change_icon, int change_selected);
const char *(*file_path_get)(Evry_Item_File *file); const char *(*file_path_get)(Evry_Item_File *file);
const char *(*file_url_get)(Evry_Item_File *file); const char *(*file_url_get)(Evry_Item_File *file);
History_Item *(*history_item_add)(Evry_Item *it, const char *ctxt, const char *input);
History_Types *(*history_types_get)(Evry_Type type);
int (*history_item_usage_set)(Evry_Item *it, const char *input, const char *ctxt);
int log_dom; int log_dom;
}; };
#ifndef EVRY_H #ifndef EVRY_H
/*** cast default types ***/
#define EVRY_ITEM(_item) ((Evry_Item *)_item) #define EVRY_ITEM(_item) ((Evry_Item *)_item)
#define EVRY_ACTN(_item) ((Evry_Action *) _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 EVRY_FILE(_it) ((Evry_Item_File *) _it) #define EVRY_FILE(_it) ((Evry_Item_File *) _it)
#define CHECK_TYPE(_item, _type) \
(((Evry_Item *)_item)->type && ((Evry_Item *)_item)->type == _type)
#define CHECK_SUBTYPE(_item, _type) \
(((Evry_Item *)_item)->subtype && ((Evry_Item *)_item)->subtype == _type)
#define IS_BROWSEABLE(_item) ((Evry_Item *)_item)->browseable
#define GET_APP(_app, _item) Evry_Item_App *_app = (Evry_Item_App *) _item #define GET_APP(_app, _item) Evry_Item_App *_app = (Evry_Item_App *) _item
#define GET_FILE(_file, _item) Evry_Item_File *_file = (Evry_Item_File *) _item #define GET_FILE(_file, _item) Evry_Item_File *_file = (Evry_Item_File *) _item
#define GET_EVRY_PLUGIN(_p, _plugin) Evry_Plugin *_p = (Evry_Plugin*) _plugin #define GET_EVRY_PLUGIN(_p, _plugin) Evry_Plugin *_p = (Evry_Plugin*) _plugin
@ -143,65 +155,82 @@ struct _Evry_API
#define GET_PLUGIN(_p, _plugin) Plugin *_p = (Plugin*) _plugin #define GET_PLUGIN(_p, _plugin) Plugin *_p = (Plugin*) _plugin
#define GET_ITEM(_it, _any) Evry_Item *_it = (Evry_Item *) _any #define GET_ITEM(_it, _any) Evry_Item *_it = (Evry_Item *) _any
/*** Evry_Item macros ***/
#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_ITEM_FREE(_item) evry->item_free((Evry_Item *)_item)
#define EVRY_ITEM_REF(_item) evry->item_ref((Evry_Item *)_item)
#define EVRY_ITEM_DATA_INT_SET(_item, _data) ((Evry_Item *)_item)->data = (void*)(long) _data #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_DATA_INT_GET(_item) (long) ((Evry_Item *)_item)->data
#define EVRY_ITEM_ICON_SET(_item, _icon) ((Evry_Item *)_item)->icon = _icon #define EVRY_ITEM_ICON_SET(_item, _icon) ((Evry_Item *)_item)->icon = _icon
#define EVRY_ITEM_DETAIL_SET(_it, _detail) \ #define EVRY_ITEM_DETAIL_SET(_it, _detail) \
if (EVRY_ITEM(_it)->detail) eina_stringshare_del(EVRY_ITEM(_it)->detail); \ if (EVRY_ITEM(_it)->detail) eina_stringshare_del(EVRY_ITEM(_it)->detail); \
EVRY_ITEM(_it)->detail = eina_stringshare_add(_detail); EVRY_ITEM(_it)->detail = eina_stringshare_add(_detail);
#define EVRY_ITEM_LABEL_SET(_it, _label) \ #define EVRY_ITEM_LABEL_SET(_it, _label) \
if (EVRY_ITEM(_it)->label) eina_stringshare_del(EVRY_ITEM(_it)->label); \ if (EVRY_ITEM(_it)->label) eina_stringshare_del(EVRY_ITEM(_it)->label); \
EVRY_ITEM(_it)->label = eina_stringshare_add(_label); EVRY_ITEM(_it)->label = eina_stringshare_add(_label);
#define EVRY_ITEM_CONTEXT_SET(_it, _context) \ #define EVRY_ITEM_CONTEXT_SET(_it, _context) \
if (EVRY_ITEM(_it)->context) eina_stringshare_del(EVRY_ITEM(_it)->context); \ if (EVRY_ITEM(_it)->context) eina_stringshare_del(EVRY_ITEM(_it)->context); \
EVRY_ITEM(_it)->context = eina_stringshare_add(_context); EVRY_ITEM(_it)->context = eina_stringshare_add(_context);
#define EVRY_ITEM_NEW(_base, _plugin, _label, _icon_get, _free) \ #define CHECK_TYPE(_item, _type) \
(_base *) evry->item_new(EVRY_ITEM(E_NEW(_base, 1)), EVRY_PLUGIN(_plugin), \ (((Evry_Item *)_item)->type && ((Evry_Item *)_item)->type == _type)
_label, _icon_get, _free)
#define EVRY_ITEM_FREE(_item) evry_item_free((Evry_Item *)_item) #define CHECK_SUBTYPE(_item, _type) \
(((Evry_Item *)_item)->subtype && ((Evry_Item *)_item)->subtype == _type)
#define IS_BROWSEABLE(_item) ((Evry_Item *)_item)->browseable
/*** Evry_Plugin macros ***/
#define EVRY_PLUGIN_NEW(_base, _name, _icon, _item_type, _begin, _cleanup, _fetch, _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, \ evry->plugin_new(EVRY_PLUGIN(E_NEW(_base, 1)), _name, _(_name), _icon, _item_type, \
_begin, _cleanup, _fetch, _free) _begin, _cleanup, _fetch, _free)
#define EVRY_PLUGIN_ITEMS_CLEAR(_p) { \
#define EVRY_ACTION_NEW(_name, _in1, _in2, _icon, _action, _check) \ Evry_Item *it; \
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) { \
Evry_Item *it; \
EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, it) \ EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, it) \
it->fuzzy_match = 0; } it->fuzzy_match = 0; }
#define EVRY_PLUGIN_ITEMS_FREE(_p) { \ #define EVRY_PLUGIN_ITEMS_FREE(_p) { \
Evry_Item *it; \ Evry_Item *it; \
EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, it) \ EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, it) \
evry->item_free(it); } evry->item_free(it); }
#define EVRY_PLUGIN_ITEMS_SORT(_p, _sortcb) \
#define EVRY_PLUGIN_ITEMS_SORT(_p, _sortcb) \ EVRY_PLUGIN(_p)->items = eina_list_sort \
EVRY_PLUGIN(_p)->items = eina_list_sort \
(EVRY_PLUGIN(_p)->items, eina_list_count(EVRY_PLUGIN(_p)->items), _sortcb) (EVRY_PLUGIN(_p)->items, eina_list_count(EVRY_PLUGIN(_p)->items), _sortcb)
#define EVRY_PLUGIN_ITEM_APPEND(_p, _item) \ #define EVRY_PLUGIN_ITEM_APPEND(_p, _item) \
EVRY_PLUGIN(_p)->items = eina_list_append(EVRY_PLUGIN(_p)->items, EVRY_ITEM(_item)) EVRY_PLUGIN(_p)->items = eina_list_append(EVRY_PLUGIN(_p)->items, EVRY_ITEM(_item))
// should be renamed to ITEMS_FILTER // should be renamed to ITEMS_FILTER
#define EVRY_PLUGIN_ITEMS_ADD(_plugin, _items, _input, _match_detail, _set_usage) \ #define EVRY_PLUGIN_ITEMS_ADD(_plugin, _items, _input, _match_detail, _set_usage) \
evry->util_plugin_items_add(EVRY_PLUGIN(_plugin), _items, _input, _match_detail, _set_usage) evry->util_plugin_items_add(EVRY_PLUGIN(_plugin), _items, _input, _match_detail, _set_usage)
#define EVRY_PLUGIN_UPDATE(_p, _action) \ #define EVRY_PLUGIN_UPDATE(_p, _action) \
if (_p) evry->plugin_update(EVRY_PLUGIN(_p), _action) if (_p) evry->plugin_update(EVRY_PLUGIN(_p), _action)
/*** Evry_Action macros ***/
#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))
/*** handy macros ***/
#define IF_RELEASE(x) do { \ #define IF_RELEASE(x) do { \
if (x) { \ if (x) { \
const char *__tmp; __tmp = (x); (x) = NULL; eina_stringshare_del(__tmp); \ const char *__tmp; __tmp = (x); (x) = NULL; eina_stringshare_del(__tmp); \

View File

@ -47,9 +47,6 @@ struct _E_Config_Dialog_Data
int scroll_animate; int scroll_animate;
double scroll_speed; double scroll_speed;
char *cmd_terminal;
char *cmd_sudo;
int view_mode; int view_mode;
int view_zoom; int view_zoom;
int cycle_mode; int cycle_mode;
@ -104,12 +101,6 @@ _fill_data(E_Config_Dialog_Data *cfdata)
cfdata->page[0].configs = eina_list_clone(evry_conf->conf_subjects); cfdata->page[0].configs = eina_list_clone(evry_conf->conf_subjects);
cfdata->page[1].configs = eina_list_clone(evry_conf->conf_actions); cfdata->page[1].configs = eina_list_clone(evry_conf->conf_actions);
cfdata->page[2].configs = eina_list_clone(evry_conf->conf_objects); cfdata->page[2].configs = eina_list_clone(evry_conf->conf_objects);
if (evry_conf->cmd_terminal)
cfdata->cmd_terminal = strdup(evry_conf->cmd_terminal);
if (evry_conf->cmd_sudo)
cfdata->cmd_sudo = strdup(evry_conf->cmd_sudo);
} }
static void * static void *
@ -129,8 +120,6 @@ _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
if (cfdata->page[1].configs) eina_list_free(cfdata->page[1].configs); if (cfdata->page[1].configs) eina_list_free(cfdata->page[1].configs);
if (cfdata->page[2].configs) eina_list_free(cfdata->page[2].configs); if (cfdata->page[2].configs) eina_list_free(cfdata->page[2].configs);
E_FREE(cfdata->cmd_terminal);
E_FREE(cfdata->cmd_sudo);
E_FREE(cfdata); E_FREE(cfdata);
} }
@ -187,13 +176,6 @@ _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
} }
} }
if (evry_conf->cmd_terminal)
eina_stringshare_del(evry_conf->cmd_terminal);
evry_conf->cmd_terminal = eina_stringshare_add(cfdata->cmd_terminal);
if (evry_conf->cmd_sudo)
eina_stringshare_del(evry_conf->cmd_sudo);
evry_conf->cmd_sudo = eina_stringshare_add(cfdata->cmd_sudo);
e_config_save_queue(); e_config_save_queue();
return 1; return 1;
} }
@ -510,18 +492,6 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *e, E_Config_Dialog_Data *cfdat
e_widget_table_object_append(o, of, 0, 1, 2, 1, 1, 0, 0, 0); e_widget_table_object_append(o, of, 0, 1, 2, 1, 1, 0, 0, 0);
of = e_widget_framelist_add(e, _("Commands"), 0);
ob = e_widget_label_add(e, _("Terminal Command"));
e_widget_framelist_object_append(of, ob);
ob = e_widget_entry_add(e, &(cfdata->cmd_terminal), NULL, NULL, NULL);
e_widget_framelist_object_append(of, ob);
ob = e_widget_label_add(e, _("Sudo GUI"));
e_widget_framelist_object_append(of, ob);
ob = e_widget_entry_add(e, &(cfdata->cmd_sudo), NULL, NULL, NULL);
e_widget_framelist_object_append(of, ob);
e_widget_table_object_append(o, of, 0, 2, 2, 1, 1, 0, 0, 0);
e_widget_toolbook_page_append(otb, NULL, _("General Settings"), e_widget_toolbook_page_append(otb, NULL, _("General Settings"),
o, 1, 0, 1, 0, 0.5, 0.0); o, 1, 0, 1, 0, 0.5, 0.0);

View File

@ -58,8 +58,7 @@ evry_history_init(void)
#define D hist_edd #define D hist_edd
E_CONFIG_VAL(D, T, version, INT); E_CONFIG_VAL(D, T, version, INT);
E_CONFIG_VAL(D, T, begin, DOUBLE); E_CONFIG_VAL(D, T, begin, DOUBLE);
E_CONFIG_HASH(D, T, subjects, hist_types_edd); E_CONFIG_HASH(D, T, subjects, hist_types_edd);
E_CONFIG_HASH(D, T, actions, hist_types_edd);
#undef T #undef T
#undef D #undef D
} }
@ -178,10 +177,6 @@ evry_history_free(void)
{ {
eina_hash_foreach(evry_hist->subjects, _hist_cleanup_cb, d); eina_hash_foreach(evry_hist->subjects, _hist_cleanup_cb, d);
} }
if (evry_hist->actions)
{
eina_hash_foreach(evry_hist->actions, _hist_cleanup_cb, d);
}
E_FREE(d); E_FREE(d);
evry_history_unload(); evry_history_unload();
@ -203,9 +198,7 @@ evry_history_load(void)
if (evry_hist && evry_hist->version != HISTORY_VERSION) if (evry_hist && evry_hist->version != HISTORY_VERSION)
{ {
eina_hash_foreach(evry_hist->subjects, _hist_free_cb, NULL); eina_hash_foreach(evry_hist->subjects, _hist_free_cb, NULL);
eina_hash_foreach(evry_hist->actions, _hist_free_cb, NULL);
eina_hash_free(evry_hist->subjects); eina_hash_free(evry_hist->subjects);
eina_hash_free(evry_hist->actions);
E_FREE(evry_hist); E_FREE(evry_hist);
evry_hist = NULL; evry_hist = NULL;
@ -219,8 +212,6 @@ evry_history_load(void)
} }
if (!evry_hist->subjects) if (!evry_hist->subjects)
evry_hist->subjects = eina_hash_string_superfast_new(NULL); evry_hist->subjects = eina_hash_string_superfast_new(NULL);
if (!evry_hist->actions)
evry_hist->actions = eina_hash_string_superfast_new(NULL);
} }
@ -232,29 +223,30 @@ evry_history_unload(void)
e_config_domain_save("module.everything.cache", hist_edd, evry_hist); e_config_domain_save("module.everything.cache", hist_edd, evry_hist);
eina_hash_foreach(evry_hist->subjects, _hist_free_cb, NULL); eina_hash_foreach(evry_hist->subjects, _hist_free_cb, NULL);
eina_hash_foreach(evry_hist->actions, _hist_free_cb, NULL);
eina_hash_free(evry_hist->subjects); eina_hash_free(evry_hist->subjects);
eina_hash_free(evry_hist->actions);
E_FREE(evry_hist); E_FREE(evry_hist);
evry_hist = NULL; evry_hist = NULL;
} }
EAPI History_Types * EAPI History_Types *
evry_history_types_get(Eina_Hash *hist, Evry_Type _type) evry_history_types_get(Evry_Type _type)
{ {
History_Types *ht; History_Types *ht;
const char *type = evry_type_get(_type); const char *type = evry_type_get(_type);
if (!evry_hist)
return NULL;
if (!type) if (!type)
return NULL; return NULL;
ht = eina_hash_find(hist, type); ht = eina_hash_find(evry_hist->subjects, type);
if (!ht) if (!ht)
{ {
ht = E_NEW(History_Types, 1); ht = E_NEW(History_Types, 1);
eina_hash_add(hist, type, ht); eina_hash_add(evry_hist->subjects, type, ht);
} }
if (!ht->types) if (!ht->types)
@ -264,7 +256,7 @@ evry_history_types_get(Eina_Hash *hist, Evry_Type _type)
} }
EAPI History_Item * EAPI History_Item *
evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *input) evry_history_item_add(Evry_Item *it, const char *ctxt, const char *input)
{ {
History_Entry *he; History_Entry *he;
History_Types *ht; History_Types *ht;
@ -275,7 +267,11 @@ evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *i
int rem_ctxt = 1; int rem_ctxt = 1;
if (!it) return NULL; if (!evry_hist)
return NULL;
if (!it)
return NULL;
if (it->type == EVRY_TYPE_ACTION) if (it->type == EVRY_TYPE_ACTION)
{ {
@ -295,7 +291,7 @@ evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *i
if (!hi) if (!hi)
{ {
id = (it->id ? it->id : it->label); id = (it->id ? it->id : it->label);
ht = evry_history_types_get(hist, it->type); ht = evry_history_types_get(it->type);
he = eina_hash_find(ht->types, id); he = eina_hash_find(ht->types, id);
if (!he) if (!he)
@ -355,7 +351,7 @@ evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *i
} }
EAPI int EAPI int
evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, const char *ctxt) evry_history_item_usage_set(Evry_Item *it, const char *input, const char *ctxt)
{ {
History_Entry *he; History_Entry *he;
History_Types *ht; History_Types *ht;
@ -378,7 +374,7 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, c
if (!hi) if (!hi)
{ {
ht = evry_history_types_get(hist, it->type); ht = evry_history_types_get(it->type);
if (!(he = eina_hash_find(ht->types, (it->id ? it->id : it->label)))) if (!(he = eina_hash_find(ht->types, (it->id ? it->id : it->label))))
return 0; return 0;

View File

@ -106,7 +106,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
it->fuzzy_match = evry_fuzzy_match(it->label, input); it->fuzzy_match = evry_fuzzy_match(it->label, input);
it->hi = NULL; it->hi = NULL;
evry_history_item_usage_set(sel->history, it, NULL, NULL); evry_history_item_usage_set(it, NULL, NULL);
snprintf(buf, sizeof(buf), "%d %s", eina_list_count(pp->items), _("Items")); snprintf(buf, sizeof(buf), "%d %s", eina_list_count(pp->items), _("Items"));
if (it->detail) if (it->detail)
@ -127,8 +127,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
EINA_LIST_FOREACH(pp->items, l, it) EINA_LIST_FOREACH(pp->items, l, it)
{ {
if (it->usage >= 0) if (it->usage >= 0)
evry_history_item_usage_set(sel->history, evry_history_item_usage_set(it, input, context);
it, input, context);
if (it->fuzzy_match == 0) if (it->fuzzy_match == 0)
it->fuzzy_match = evry_fuzzy_match(it->label, input); it->fuzzy_match = evry_fuzzy_match(it->label, input);
items = _add_item(p, items, it); items = _add_item(p, items, it);
@ -148,8 +147,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
if (it->fuzzy_match || sel == selectors[2]) if (it->fuzzy_match || sel == selectors[2])
{ {
if (it->usage >= 0) if (it->usage >= 0)
evry_history_item_usage_set(sel->history, evry_history_item_usage_set(it, input, context);
it, input, context);
items = _add_item(p, items, it); items = _add_item(p, items, it);
} }
@ -166,8 +164,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
EINA_LIST_FOREACH(pp->items, ll, it) EINA_LIST_FOREACH(pp->items, ll, it)
{ {
if (it->usage >= 0) if (it->usage >= 0)
evry_history_item_usage_set(sel->history, evry_history_item_usage_set(it, NULL, context);
it, NULL, context);
it->fuzzy_match = 0; it->fuzzy_match = 0;
items = _add_item(p, items, it); items = _add_item(p, items, it);
} }
@ -181,8 +178,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
EINA_LIST_FOREACH(pp->items, ll, it) EINA_LIST_FOREACH(pp->items, ll, it)
{ {
if ((it->usage >= 0) && if ((it->usage >= 0) &&
(evry_history_item_usage_set(sel->history, (evry_history_item_usage_set(it, input, context)) &&
it, input, context)) &&
(!eina_list_data_find_list(items, it))) (!eina_list_data_find_list(items, it)))
{ {
it->fuzzy_match = 0; it->fuzzy_match = 0;

View File

@ -8,6 +8,8 @@ typedef struct _Evry_Item_App Evry_Item_App;
typedef struct _Evry_Item_File Evry_Item_File; typedef struct _Evry_Item_File Evry_Item_File;
typedef struct _Evry_Action Evry_Action; typedef struct _Evry_Action Evry_Action;
typedef struct _History_Item History_Item; typedef struct _History_Item History_Item;
typedef struct _History_Entry History_Entry;
typedef struct _History_Types History_Types;
typedef unsigned int Evry_Type; typedef unsigned int Evry_Type;
@ -237,4 +239,14 @@ struct _History_Item
const char *data; const char *data;
}; };
struct _History_Entry
{
Eina_List *items;
};
struct _History_Types
{
Eina_Hash *types;
};
#endif #endif

View File

@ -368,7 +368,7 @@ evry_util_plugin_items_add(Evry_Plugin *p, Eina_List *items, const char *input,
if (it->fuzzy_match) if (it->fuzzy_match)
{ {
if (set_usage) if (set_usage)
evry_history_item_usage_set(evry_hist->subjects, it, input, NULL); evry_history_item_usage_set(it, input, NULL);
p->items = eina_list_append(p->items, it); p->items = eina_list_append(p->items, it);
} }
@ -798,7 +798,7 @@ _cb_free_item_changed(void *data, void *event)
EAPI void EAPI void
evry_event_item_changed(Evry_Item *it, int icon, int selected) evry_item_changed(Evry_Item *it, int icon, int selected)
{ {
Evry_Event_Item_Changed *ev; Evry_Event_Item_Changed *ev;
ev = E_NEW(Evry_Event_Item_Changed, 1); ev = E_NEW(Evry_Event_Item_Changed, 1);