add new functions evry_item_{app,file}_free for freeing standard file/app items

SVN revision: 65705
This commit is contained in:
Mike Blumenkrantz 2011-11-30 04:00:51 +00:00
parent 0cc0f8c658
commit abcc8f9ad3
5 changed files with 30 additions and 35 deletions

View File

@ -3058,3 +3058,21 @@ _evry_cb_selection_notify(void *data, int type __UNUSED__, void *event)
return ECORE_CALLBACK_PASS_ON;
}
void
evry_item_app_free(Evry_Item_App *app)
{
efreet_desktop_free(app->desktop);
eina_stringshare_del(app->file);
free(app);
}
void
evry_item_file_free(Evry_Item_File *file)
{
eina_stringshare_del(file->url);
eina_stringshare_del(file->path);
eina_stringshare_del(file->mime);
free(file);
}

View File

@ -50,6 +50,7 @@ typedef struct _Evry_Module Evry_Module;
typedef struct _Evry_Event_Item_Changed Evry_Event_Item_Changed;
typedef struct _Evry_Event_Item_Selected Evry_Event_Item_Selected;
typedef struct _Evry_Event_Action_Performed Evry_Event_Action_Performed;
typedef void (*Evry_Item_Free_Cb) (Evry_Item *it);
struct _Evry_Module
{
@ -65,7 +66,7 @@ struct _Evry_API
Evry_Item *(*item_new)(Evry_Item *base, Evry_Plugin *p, const char *label,
Evas_Object *(*icon_get) (Evry_Item *it, Evas *e),
void (*cb_free) (Evry_Item *item));
Evry_Item_Free_Cb item_free);
void (*item_free)(Evry_Item *it);
void (*item_ref)(Evry_Item *it);
@ -164,7 +165,7 @@ struct _Evry_Event_Action_Performed
#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)
_label, _icon_get, (Evry_Item_Free_Cb)_free)
#define EVRY_ITEM_FREE(_item) evry->item_free((Evry_Item *)_item)
#define EVRY_ITEM_REF(_item) evry->item_ref((Evry_Item *)_item)
@ -249,8 +250,6 @@ struct _Evry_Event_Action_Performed
if (!(EVRY_PLUGIN(_p)->config->min_query) || \
(_input && (strlen(_input) >= EVRY_PLUGIN(_p)->config->min_query)))
typedef void (*Evry_Item_Free_Cb) (Evry_Item *it);
#define EVRY_PLUGIN_ITEMS_CLEAR(_p) { \
Evry_Item *it; \
EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, it) \

View File

@ -98,25 +98,12 @@ _exec_open_file_action(Evry_Action *act)
return evry->util_exec_app(EVRY_ITEM(act), act->it1.item);
}
static void
_cb_item_free(Evry_Item *item)
{
GET_APP(app, item);
if (app->desktop)
efreet_desktop_free(app->desktop);
if (app->file)
eina_stringshare_del(app->file);
E_FREE(app);
}
static Evry_Item_App *
_item_new(Plugin *p, const char *label, const char *id)
{
Evry_Item_App *app;
app = EVRY_ITEM_NEW(Evry_Item_App, p, label, NULL, _cb_item_free);
app = EVRY_ITEM_NEW(Evry_Item_App, p, label, NULL, evry_item_app_free);
EVRY_ACTN(app)->action = &_exec_open_file_action;
EVRY_ACTN(app)->it1.type = EVRY_TYPE_FILE;
EVRY_ITEM(app)->id = eina_stringshare_add(id);
@ -330,7 +317,7 @@ _begin_exe(Evry_Plugin *plugin, const Evry_Item *item)
p->added = eina_hash_string_small_new(_hash_free);
app = EVRY_ITEM_NEW(Evry_Item_App, p, NULL, NULL, _cb_item_free);
app = EVRY_ITEM_NEW(Evry_Item_App, p, NULL, NULL, evry_item_app_free);
EVRY_ACTN(app)->action = &_exec_open_file_action;
EVRY_ACTN(app)->remember_context = EINA_TRUE;
EVRY_ITEM(app)->subtype = EVRY_TYPE_ACTION;

View File

@ -157,18 +157,6 @@ _cb_sort_date(const void *data1, const void *data2)
return it2->modified - it1->modified;
}
static void
_item_free(Evry_Item *it)
{
GET_FILE(file, it);
IF_RELEASE(file->url);
IF_RELEASE(file->path);
IF_RELEASE(file->mime);
E_FREE(file);
}
static void
_scan_func(void *data, Ecore_Thread *thread)
{
@ -185,7 +173,7 @@ _scan_func(void *data, Ecore_Thread *thread)
if ((d->plugin->show_hidden) != (*(info->path + info->name_start) == '.'))
continue;
file = EVRY_ITEM_NEW(Evry_Item_File, d->plugin, NULL, NULL, _item_free);
file = EVRY_ITEM_NEW(Evry_Item_File, d->plugin, NULL, NULL, evry_item_file_free);
file->path = strdup(info->path);
EVRY_ITEM(file)->label = strdup(info->path + info->name_start);
EVRY_ITEM(file)->browseable = (info->type == EINA_FILE_DIR);
@ -464,7 +452,7 @@ _dir_watcher(void *data, Ecore_File_Monitor *em __UNUSED__, Ecore_File_Event eve
case ECORE_FILE_EVENT_CREATED_FILE:
label = ecore_file_file_get(path);
file = EVRY_ITEM_NEW(Evry_Item_File, p, label, NULL, _item_free);
file = EVRY_ITEM_NEW(Evry_Item_File, p, label, NULL, evry_item_file_free);
file->path = eina_stringshare_add(path);
if (event == ECORE_FILE_EVENT_CREATED_DIRECTORY)
@ -605,7 +593,7 @@ _folder_item_add(Plugin *p, const char *path, int prio)
{
Evry_Item_File *file;
file = EVRY_ITEM_NEW(Evry_Item_File, p, path, NULL, _item_free);
file = EVRY_ITEM_NEW(Evry_Item_File, p, path, NULL, evry_item_file_free);
file->path = eina_stringshare_add(path);
file->mime = eina_stringshare_ref(_mime_dir);
EVRY_ITEM(file)->browseable = EINA_TRUE;
@ -1000,7 +988,7 @@ _recentf_items_add_cb(const Eina_Hash *hash __UNUSED__, const void *key, void *d
return EINA_TRUE;
}
file = EVRY_ITEM_NEW(Evry_Item_File, p, label, NULL, _item_free);
file = EVRY_ITEM_NEW(Evry_Item_File, p, label, NULL, evry_item_file_free);
file->path = path;
if (hi->data)

View File

@ -287,4 +287,7 @@ struct _History_Types
Eina_Hash *types;
};
void evry_item_app_free(Evry_Item_App *it);
void evry_item_file_free(Evry_Item_File *it);
#endif