'everything'add free_cb for plugins and actions.
SVN revision: 47904
This commit is contained in:
parent
31ab8c471e
commit
a2dde82e7f
|
@ -734,6 +734,15 @@ _new_app_action(Evry_Action *act)
|
|||
|
||||
//#define TIME_FACTOR(_now) (1.0 - (evry_hist->begin / _now)) / 1000000000000000.0
|
||||
|
||||
static void
|
||||
_free_plugin(Evry_Plugin *plugin)
|
||||
{
|
||||
PLUGIN(p, plugin);
|
||||
|
||||
E_FREE(p);
|
||||
}
|
||||
|
||||
|
||||
static Eina_Bool
|
||||
module_init(void)
|
||||
{
|
||||
|
@ -742,12 +751,12 @@ module_init(void)
|
|||
|
||||
p1 = E_NEW(Plugin, 1);
|
||||
evry_plugin_new(EVRY_PLUGIN(p1), "Applications", type_subject, "", "APPLICATION", 0, NULL, NULL,
|
||||
_begin, _cleanup, _fetch, NULL, _icon_get, NULL, NULL);
|
||||
_begin, _cleanup, _fetch, NULL, _icon_get, _free_plugin);
|
||||
|
||||
p2 = E_NEW(Plugin, 1);
|
||||
evry_plugin_new(EVRY_PLUGIN(p2), "Open With...", type_action, "FILE", "", 0, NULL, NULL,
|
||||
_begin_open_with, _cleanup, _fetch, _open_with_action,
|
||||
_icon_get, NULL, NULL);
|
||||
_icon_get, _free_plugin);
|
||||
|
||||
evry_plugin_register(EVRY_PLUGIN(p1), 1);
|
||||
evry_plugin_register(EVRY_PLUGIN(p2), 1);
|
||||
|
@ -755,31 +764,31 @@ module_init(void)
|
|||
act = evry_action_new("Launch", "APPLICATION", NULL, NULL,
|
||||
"everything-launch",
|
||||
_exec_app_action, _exec_app_check_item,
|
||||
NULL, NULL,NULL);
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
act1 = evry_action_new("Open File...", "APPLICATION", "FILE", "APPLICATION",
|
||||
"document-open",
|
||||
_exec_app_action, _exec_app_check_item,
|
||||
NULL, NULL, NULL);
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
act2 = evry_action_new("Run in Terminal", "APPLICATION", NULL, NULL,
|
||||
"system-run",
|
||||
_exec_term_action, _exec_term_check_item,
|
||||
NULL, NULL, NULL);
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
act3 = evry_action_new("Edit Application Entry", "APPLICATION", NULL, NULL,
|
||||
"everything-launch",
|
||||
_edit_app_action, _edit_app_check_item,
|
||||
NULL, NULL, NULL);
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
act4 = evry_action_new("New Application Entry", "APPLICATION", NULL, NULL,
|
||||
"everything-launch",
|
||||
_new_app_action, _new_app_check_item,
|
||||
NULL, NULL, NULL);
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
act5 = evry_action_new("Run with Sudo", "APPLICATION", NULL, NULL,
|
||||
"system-run",
|
||||
_exec_sudo_action, NULL, NULL, NULL, NULL);
|
||||
_exec_sudo_action, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
evry_action_register(act, 0);
|
||||
evry_action_register(act1, 1);
|
||||
|
|
|
@ -321,6 +321,14 @@ _cleanup(Evry_Plugin *plugin)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_free_plugin(Evry_Plugin *plugin)
|
||||
{
|
||||
PLUGIN(p, plugin);
|
||||
|
||||
E_FREE(p);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
module_init(void)
|
||||
{
|
||||
|
@ -332,7 +340,7 @@ module_init(void)
|
|||
p = E_NEW(Plugin, 1);
|
||||
evry_plugin_new(EVRY_PLUGIN(p), "Spell Checker", type_subject, "", "TEXT", 1,
|
||||
"accessories-dictionary", TRIGGER,
|
||||
NULL, _cleanup, _fetch, NULL, NULL, NULL, NULL);
|
||||
NULL, _cleanup, _fetch, NULL, NULL, _free_plugin);
|
||||
|
||||
EVRY_PLUGIN(p)->aggregate = EINA_FALSE;
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ module_init(void)
|
|||
return EINA_FALSE;
|
||||
|
||||
p1 = evry_plugin_new(NULL, "Calculator", type_subject, NULL, "TEXT", 1, "accessories-calculator", "=",
|
||||
_begin, _cleanup, _fetch, _action, NULL, NULL, NULL);
|
||||
_begin, _cleanup, _fetch, _action, NULL, NULL);
|
||||
|
||||
p1->aggregate = EINA_FALSE;
|
||||
|
||||
|
|
|
@ -485,6 +485,14 @@ _open_term_action(Evry_Action *act)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
_free_plugin(Evry_Plugin *plugin)
|
||||
{
|
||||
PLUGIN(p, plugin);
|
||||
|
||||
E_FREE(p);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
module_init(void)
|
||||
{
|
||||
|
@ -492,23 +500,21 @@ module_init(void)
|
|||
return EINA_FALSE;
|
||||
|
||||
p1 = evry_plugin_new(NULL, "Files", type_subject, "FILE", "FILE", 0, NULL, NULL,
|
||||
_begin, _cleanup, _fetch, NULL, _icon_get,
|
||||
NULL, NULL);
|
||||
_begin, _cleanup, _fetch, NULL, _icon_get, _free_plugin);
|
||||
|
||||
p2 = evry_plugin_new(NULL, "Files", type_object, "FILE", "FILE", 0, NULL, NULL,
|
||||
_begin, _cleanup, _fetch, NULL, _icon_get,
|
||||
NULL, NULL);
|
||||
_begin, _cleanup, _fetch, NULL, _icon_get, _free_plugin);
|
||||
|
||||
evry_plugin_register(p1, 3);
|
||||
evry_plugin_register(p2, 1);
|
||||
|
||||
act1 = evry_action_new("Open Folder (EFM)", "FILE", NULL, NULL, "folder-open",
|
||||
_open_folder_action, _open_folder_check, NULL, NULL, NULL);
|
||||
_open_folder_action, _open_folder_check, NULL, NULL, NULL, NULL);
|
||||
evry_action_register(act1, 0);
|
||||
|
||||
act2 = evry_action_new("Open Terminal here", "FILE", NULL, NULL,
|
||||
"system-run",
|
||||
_open_term_action, NULL, NULL, NULL, NULL);
|
||||
_open_term_action, NULL, NULL, NULL, NULL, NULL);
|
||||
evry_action_register(act2, 2);
|
||||
|
||||
return EINA_TRUE;
|
||||
|
|
|
@ -124,10 +124,10 @@ module_init(void)
|
|||
return EINA_FALSE;
|
||||
|
||||
p = evry_plugin_new(NULL, "Settings", type_subject, NULL, "E_SETTINGS", 0, NULL, NULL,
|
||||
NULL, _cleanup, _fetch, NULL, _item_icon_get, NULL, NULL);
|
||||
NULL, _cleanup, _fetch, NULL, _item_icon_get, NULL);
|
||||
|
||||
act = evry_action_new("Show Dialog", "E_SETTINGS", NULL, NULL, "preferences-advanced",
|
||||
_action, NULL, NULL, NULL, NULL);
|
||||
_action, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
evry_plugin_register(p, 10);
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ module_init(void)
|
|||
plugin = evry_plugin_new(NULL, "Wallpaper", type_action, "FILE", "",
|
||||
0, "preferences-desktop-wallpaper", NULL,
|
||||
_begin, _cleanup, _fetch, _action, _icon_get,
|
||||
NULL, NULL);
|
||||
NULL);
|
||||
|
||||
evry_plugin_register(plugin, 10);
|
||||
|
||||
|
|
|
@ -489,18 +489,18 @@ module_init(void)
|
|||
return EINA_FALSE;
|
||||
|
||||
plugin = evry_plugin_new(NULL, "Windows", type_subject, NULL, "BORDER", 0, NULL, NULL,
|
||||
_begin, _cleanup, _fetch, NULL, _item_icon_get, NULL, NULL);
|
||||
_begin, _cleanup, _fetch, NULL, _item_icon_get, NULL);
|
||||
evry_plugin_register(plugin, 2);
|
||||
|
||||
|
||||
plugin2 = evry_plugin_new(NULL, "Window Action", type_action, "BORDER", NULL, 0, NULL, NULL,
|
||||
_act_begin, _act_cleanup, _act_fetch, _act_action, _act_item_icon_get, NULL, NULL);
|
||||
_act_begin, _act_cleanup, _act_fetch, _act_action, _act_item_icon_get, NULL);
|
||||
evry_plugin_register(plugin2, 1);
|
||||
|
||||
act = evry_action_new("Open File...", "BORDER", "FILE", "APPLICATION",
|
||||
"everything-launch",
|
||||
_exec_border_action, _exec_border_check_item,
|
||||
_exec_border_cleanup, _exec_border_intercept, NULL);
|
||||
_exec_border_cleanup, _exec_border_intercept, NULL, NULL);
|
||||
evry_action_register(act, 10);
|
||||
|
||||
return EINA_TRUE;
|
||||
|
|
|
@ -70,6 +70,9 @@ typedef struct _Config Evry_Config;
|
|||
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) \
|
||||
evry_plugin_free(EVRY_PLUGIN(_p), 0); \
|
||||
E_FREE(_p);
|
||||
|
@ -179,10 +182,10 @@ struct _Evry_Plugin
|
|||
/* only used when plugin is of type_action */
|
||||
int (*action) (Evry_Plugin *p, const Evry_Item *item);
|
||||
|
||||
Evas_Object *(*config_page) (Evry_Plugin *p);
|
||||
void (*config_apply) (Evry_Plugin *p);
|
||||
|
||||
int (*cb_key_down) (Evry_Plugin *p, const Ecore_Event_Key *ev);
|
||||
|
||||
/* optional: use this when you extend the plugin struct */
|
||||
void (*free) (Evry_Plugin *p);
|
||||
|
||||
/* show in aggregator. default is TRUE */
|
||||
Eina_Bool aggregate;
|
||||
|
@ -301,6 +304,9 @@ struct _Evry_Action
|
|||
Eina_List *(*actions) (Evry_Action *act);
|
||||
Evas_Object *(*icon_get) (Evry_Action *act, Evas *e);
|
||||
|
||||
/* optional: use this when you keep stuff in 'data' */
|
||||
void (*free) (Evry_Action *act);
|
||||
|
||||
/* use icon name from theme */
|
||||
const char *icon;
|
||||
|
||||
|
@ -375,8 +381,7 @@ EAPI Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, int type,
|
|||
int (*fetch) (Evry_Plugin *p, const char *input),
|
||||
int (*action) (Evry_Plugin *p, const Evry_Item *item),
|
||||
Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e),
|
||||
Evas_Object *(*config_page) (Evry_Plugin *p),
|
||||
void (*config_apply) (Evry_Plugin *p));
|
||||
void (*free) (Evry_Plugin *p));
|
||||
|
||||
EAPI void evry_plugin_free(Evry_Plugin *p, int free_pointer);
|
||||
|
||||
|
@ -388,7 +393,8 @@ EAPI Evry_Action *evry_action_new(const char *name, const char *type_in1,
|
|||
int (*check_item) (Evry_Action *act, const Evry_Item *it),
|
||||
void (*cleanup) (Evry_Action *act),
|
||||
int (*intercept) (Evry_Action *act),
|
||||
Evas_Object *(*icon_get) (Evry_Action *act, Evas *e));
|
||||
Evas_Object *(*icon_get) (Evry_Action *act, Evas *e),
|
||||
void (*free) (Evry_Action *p));
|
||||
|
||||
EAPI void evry_action_free(Evry_Action *act);
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
|
|||
{
|
||||
E_Config_Dialog *cfd;
|
||||
Evry_Plugin *p;
|
||||
Evry_Action *act;
|
||||
Evry_Action *a;
|
||||
|
||||
evry_shutdown();
|
||||
|
||||
|
@ -144,8 +144,8 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
|
|||
EINA_LIST_FREE(evry_conf->plugins, p)
|
||||
evry_plugin_free(p, 1);
|
||||
|
||||
EINA_LIST_FREE(evry_conf->actions, act)
|
||||
evry_action_free(act);
|
||||
EINA_LIST_FREE(evry_conf->actions, a)
|
||||
evry_action_free(a);
|
||||
|
||||
while ((cfd = e_config_dialog_get("E", "_config_everything_dialog")))
|
||||
e_object_del(E_OBJECT(cfd));
|
||||
|
@ -375,8 +375,7 @@ evry_plugin_new(Evry_Plugin *base, const char *name, int type,
|
|||
int (*fetch) (Evry_Plugin *p, const char *input),
|
||||
int (*action) (Evry_Plugin *p, const Evry_Item *item),
|
||||
Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e),
|
||||
Evas_Object *(*config_page) (Evry_Plugin *p),
|
||||
void (*config_apply) (Evry_Plugin *p))
|
||||
void (*cb_free) (Evry_Plugin *p))
|
||||
{
|
||||
Evry_Plugin *p;
|
||||
|
||||
|
@ -397,11 +396,10 @@ evry_plugin_new(Evry_Plugin *base, const char *name, int type,
|
|||
p->fetch = fetch;
|
||||
p->icon_get = icon_get;
|
||||
p->action = action;
|
||||
p->config_page = config_page;
|
||||
p->config_apply = config_apply;
|
||||
p->aggregate = EINA_TRUE;
|
||||
p->async_fetch = EINA_FALSE;
|
||||
|
||||
p->free = cb_free;
|
||||
|
||||
DBG("%s", p->name);
|
||||
|
||||
return p;
|
||||
|
@ -420,7 +418,11 @@ evry_plugin_free(Evry_Plugin *p, int free_pointer)
|
|||
if (p->trigger) eina_stringshare_del(p->trigger);
|
||||
if (p->icon) eina_stringshare_del(p->icon);
|
||||
|
||||
if (free_pointer)
|
||||
if (!free_pointer)
|
||||
return;
|
||||
else if (p->free)
|
||||
p->free(p);
|
||||
else
|
||||
E_FREE(p);
|
||||
}
|
||||
|
||||
|
@ -431,7 +433,8 @@ evry_action_new(const char *name, const char *type_in1, const char *type_in2,
|
|||
int (*check_item) (Evry_Action *act, const Evry_Item *it),
|
||||
void (*cleanup) (Evry_Action *act),
|
||||
int (*intercept) (Evry_Action *act),
|
||||
Evas_Object *(*icon_get) (Evry_Action *act, Evas *e))
|
||||
Evas_Object *(*icon_get) (Evry_Action *act, Evas *e),
|
||||
void (*cb_free) (Evry_Action *p))
|
||||
{
|
||||
Evry_Action *act = E_NEW(Evry_Action, 1);
|
||||
act->name = eina_stringshare_add(name);
|
||||
|
@ -442,6 +445,7 @@ evry_action_new(const char *name, const char *type_in1, const char *type_in2,
|
|||
act->check_item = check_item;
|
||||
act->intercept = intercept;
|
||||
act->cleanup = cleanup;
|
||||
act->free = cb_free;
|
||||
act->icon = (icon ? eina_stringshare_add(icon) : NULL);
|
||||
|
||||
DBG("%s", name);
|
||||
|
@ -460,7 +464,10 @@ evry_action_free(Evry_Action *act)
|
|||
if (act->type_out) eina_stringshare_del(act->type_out);
|
||||
if (act->icon) eina_stringshare_del(act->icon);
|
||||
|
||||
E_FREE(act);
|
||||
if (act->free)
|
||||
act->free(act);
|
||||
else
|
||||
E_FREE(act);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -755,11 +755,11 @@ _evry_selector_free(Evry_Selector *sel)
|
|||
if (list->visible && (sel == selector))
|
||||
_evry_view_clear(sel->state);
|
||||
|
||||
evry_plugin_free(sel->aggregator, 1);
|
||||
|
||||
while (sel->states)
|
||||
_evry_state_pop(sel);
|
||||
|
||||
evry_plug_aggregator_free(sel->aggregator);
|
||||
|
||||
if (sel->actions)
|
||||
evry_plug_actions_free(sel->actions);
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ evry_plug_actions_new(int type)
|
|||
Evry_Plugin *p;
|
||||
|
||||
p = evry_plugin_new(NULL, action_selector, type, "", "", 0, NULL, NULL,
|
||||
_begin, _cleanup, _fetch, NULL, _icon_get, NULL, NULL);
|
||||
_begin, _cleanup, _fetch, NULL, _icon_get, NULL);
|
||||
|
||||
evry_plugin_register(p, 2);
|
||||
|
||||
|
|
|
@ -252,6 +252,14 @@ _icon_get(Evry_Plugin *plugin, const Evry_Item *it, Evas *e)
|
|||
return o;
|
||||
}
|
||||
|
||||
static void
|
||||
_plugin_free(Evry_Plugin *plugin)
|
||||
{
|
||||
PLUGIN(p, plugin);
|
||||
|
||||
E_FREE(p);
|
||||
}
|
||||
|
||||
Evry_Plugin *
|
||||
evry_plug_aggregator_new(Evry_Selector *selector)
|
||||
{
|
||||
|
@ -260,8 +268,7 @@ evry_plug_aggregator_new(Evry_Selector *selector)
|
|||
|
||||
p = E_NEW(Plugin, 1);
|
||||
evry_plugin_new(EVRY_PLUGIN(p), "All", 0, "", "", 0, NULL, NULL,
|
||||
NULL, _cleanup, _fetch, _action, _icon_get,
|
||||
NULL, NULL);
|
||||
NULL, _cleanup, _fetch, _action, _icon_get, _plugin_free);
|
||||
|
||||
pc = E_NEW(Plugin_Config, 1);
|
||||
pc->enabled = 1;
|
||||
|
@ -272,10 +279,3 @@ evry_plug_aggregator_new(Evry_Selector *selector)
|
|||
|
||||
return EVRY_PLUGIN(p);
|
||||
}
|
||||
|
||||
void
|
||||
evry_plug_aggregator_free(Evry_Plugin *plugin)
|
||||
{
|
||||
PLUGIN(p, plugin);
|
||||
EVRY_PLUGIN_FREE(p);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ evry_plug_clipboard_init(void)
|
|||
if (!win) return EINA_FALSE;
|
||||
|
||||
act = evry_action_new("Copy to Clipboard", "TEXT", NULL, NULL, "edit-copy",
|
||||
_action, _check_item, NULL, NULL, NULL);
|
||||
_action, _check_item, NULL, NULL, NULL, NULL);
|
||||
|
||||
evry_action_register(act, 10);
|
||||
|
||||
|
|
Loading…
Reference in New Issue