forked from enlightenment/enlightenment
add new functions evry_item_{app,file}_free for freeing standard file/app items
SVN revision: 65705
This commit is contained in:
parent
0cc0f8c658
commit
abcc8f9ad3
|
@ -3058,3 +3058,21 @@ _evry_cb_selection_notify(void *data, int type __UNUSED__, void *event)
|
||||||
return ECORE_CALLBACK_PASS_ON;
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -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_Changed Evry_Event_Item_Changed;
|
||||||
typedef struct _Evry_Event_Item_Selected Evry_Event_Item_Selected;
|
typedef struct _Evry_Event_Item_Selected Evry_Event_Item_Selected;
|
||||||
typedef struct _Evry_Event_Action_Performed Evry_Event_Action_Performed;
|
typedef struct _Evry_Event_Action_Performed Evry_Event_Action_Performed;
|
||||||
|
typedef void (*Evry_Item_Free_Cb) (Evry_Item *it);
|
||||||
|
|
||||||
struct _Evry_Module
|
struct _Evry_Module
|
||||||
{
|
{
|
||||||
|
@ -65,7 +66,7 @@ struct _Evry_API
|
||||||
|
|
||||||
Evry_Item *(*item_new)(Evry_Item *base, Evry_Plugin *p, const char *label,
|
Evry_Item *(*item_new)(Evry_Item *base, Evry_Plugin *p, const char *label,
|
||||||
Evas_Object *(*icon_get) (Evry_Item *it, Evas *e),
|
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_free)(Evry_Item *it);
|
||||||
void (*item_ref)(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) \
|
#define EVRY_ITEM_NEW(_base, _plugin, _label, _icon_get, _free) \
|
||||||
(_base *) evry->item_new(EVRY_ITEM(E_NEW(_base, 1)), \
|
(_base *) evry->item_new(EVRY_ITEM(E_NEW(_base, 1)), \
|
||||||
EVRY_PLUGIN(_plugin), \
|
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_FREE(_item) evry->item_free((Evry_Item *)_item)
|
||||||
#define EVRY_ITEM_REF(_item) evry->item_ref((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) || \
|
if (!(EVRY_PLUGIN(_p)->config->min_query) || \
|
||||||
(_input && (strlen(_input) >= 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) { \
|
#define EVRY_PLUGIN_ITEMS_CLEAR(_p) { \
|
||||||
Evry_Item *it; \
|
Evry_Item *it; \
|
||||||
EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, it) \
|
EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, it) \
|
||||||
|
|
|
@ -98,25 +98,12 @@ _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 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 *
|
static Evry_Item_App *
|
||||||
_item_new(Plugin *p, const char *label, const char *id)
|
_item_new(Plugin *p, const char *label, const char *id)
|
||||||
{
|
{
|
||||||
Evry_Item_App *app;
|
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)->action = &_exec_open_file_action;
|
||||||
EVRY_ACTN(app)->it1.type = EVRY_TYPE_FILE;
|
EVRY_ACTN(app)->it1.type = EVRY_TYPE_FILE;
|
||||||
EVRY_ITEM(app)->id = eina_stringshare_add(id);
|
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);
|
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)->action = &_exec_open_file_action;
|
||||||
EVRY_ACTN(app)->remember_context = EINA_TRUE;
|
EVRY_ACTN(app)->remember_context = EINA_TRUE;
|
||||||
EVRY_ITEM(app)->subtype = EVRY_TYPE_ACTION;
|
EVRY_ITEM(app)->subtype = EVRY_TYPE_ACTION;
|
||||||
|
|
|
@ -157,18 +157,6 @@ _cb_sort_date(const void *data1, const void *data2)
|
||||||
return it2->modified - it1->modified;
|
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
|
static void
|
||||||
_scan_func(void *data, Ecore_Thread *thread)
|
_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) == '.'))
|
if ((d->plugin->show_hidden) != (*(info->path + info->name_start) == '.'))
|
||||||
continue;
|
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);
|
file->path = strdup(info->path);
|
||||||
EVRY_ITEM(file)->label = strdup(info->path + info->name_start);
|
EVRY_ITEM(file)->label = strdup(info->path + info->name_start);
|
||||||
EVRY_ITEM(file)->browseable = (info->type == EINA_FILE_DIR);
|
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:
|
case ECORE_FILE_EVENT_CREATED_FILE:
|
||||||
label = ecore_file_file_get(path);
|
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);
|
file->path = eina_stringshare_add(path);
|
||||||
|
|
||||||
if (event == ECORE_FILE_EVENT_CREATED_DIRECTORY)
|
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;
|
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->path = eina_stringshare_add(path);
|
||||||
file->mime = eina_stringshare_ref(_mime_dir);
|
file->mime = eina_stringshare_ref(_mime_dir);
|
||||||
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
||||||
|
@ -1000,7 +988,7 @@ _recentf_items_add_cb(const Eina_Hash *hash __UNUSED__, const void *key, void *d
|
||||||
return EINA_TRUE;
|
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;
|
file->path = path;
|
||||||
|
|
||||||
if (hi->data)
|
if (hi->data)
|
||||||
|
|
|
@ -287,4 +287,7 @@ struct _History_Types
|
||||||
Eina_Hash *types;
|
Eina_Hash *types;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void evry_item_app_free(Evry_Item_App *it);
|
||||||
|
void evry_item_file_free(Evry_Item_File *it);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue