|
|
|
@ -115,6 +115,84 @@ e_fm_mime_icon_cache_flush(void) |
|
|
|
|
icon_map = NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static Evas_Hash *_mime_handlers = NULL; |
|
|
|
|
static Evas_Hash *_glob_handlers = NULL; |
|
|
|
|
|
|
|
|
|
/* create (allocate), set properties, and return a new mime handler */ |
|
|
|
|
EAPI E_Fm_Mime_Handler * |
|
|
|
|
e_fm_mime_handler_new(const char *label, const char *icon_group, void (*action_func) (Evas_Object *obj, const char *path, void *data), int (test_func) (Evas_Object *obj, const char *path, void *data)) |
|
|
|
|
{ |
|
|
|
|
E_Fm_Mime_Handler *handler; |
|
|
|
|
|
|
|
|
|
if (!label || !action_func) |
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
handler = E_NEW( E_Fm_Mime_Handler, 1); |
|
|
|
|
if (!handler) |
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
handler->label = strdup(label); |
|
|
|
|
handler->icon_group = icon_group ? strdup(icon_group) : NULL; |
|
|
|
|
handler->action_func = action_func; |
|
|
|
|
handler->test_func = test_func; |
|
|
|
|
|
|
|
|
|
/* TODO: add data for both action_cb and test_cb */ |
|
|
|
|
|
|
|
|
|
return handler; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* associate a certain mime type with a handler */ |
|
|
|
|
EAPI int |
|
|
|
|
e_fm_mime_handler_mime_add(E_Fm_Mime_Handler *handler, const char *mime) |
|
|
|
|
{ |
|
|
|
|
Evas_List *handlers; |
|
|
|
|
|
|
|
|
|
if (!handler || !mime) |
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
/* if there's an entry for this mime already, then append to its list */ |
|
|
|
|
if ((handlers = evas_hash_find(_mime_handlers, mime))) |
|
|
|
|
{ |
|
|
|
|
handlers = evas_list_append(handlers, handler); |
|
|
|
|
_mime_handlers = evas_hash_modify(_mime_handlers, mime, handlers); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
/* no previous entry for this mime, lets add one */ |
|
|
|
|
handlers = NULL; |
|
|
|
|
handlers = evas_list_append(handlers, handler); |
|
|
|
|
_mime_handlers = evas_hash_add(_mime_handlers, mime, handlers); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* associate a certain glob with a handler */ |
|
|
|
|
EAPI int |
|
|
|
|
e_fm_mime_handler_glob_add(E_Fm_Mime_Handler *handler, const char *glob) |
|
|
|
|
{ |
|
|
|
|
Evas_List *handlers; |
|
|
|
|
|
|
|
|
|
if (!handler || !glob) |
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
/* if there's an entry for this glob already, then append to its list */ |
|
|
|
|
if ((handlers = evas_hash_find(_glob_handlers, glob))) |
|
|
|
|
{ |
|
|
|
|
handlers = evas_list_append(handlers, handler); |
|
|
|
|
_glob_handlers = evas_hash_modify(_glob_handlers, glob, handlers); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
/* no previous entry for this mime, lets add one */ |
|
|
|
|
handlers = NULL; |
|
|
|
|
handlers = evas_list_append(handlers, handler); |
|
|
|
|
_glob_handlers = evas_hash_add(_mime_handlers, glob, handlers); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* local subsystem functions */ |
|
|
|
|
static Evas_Bool |
|
|
|
|
_e_fm_mime_icon_foreach(Evas_Hash *hash, const char *key, void *data, void *fdata) |
|
|
|
|