Skeleton code for upcoming context sensitive menus in EFM. This does nothing

and should be disregarded right now. (=


SVN revision: 32058
This commit is contained in:
codewarrior 2007-10-14 12:22:52 +00:00 committed by codewarrior
parent 548ab2f356
commit 7722513648
2 changed files with 92 additions and 1 deletions

View File

@ -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)

View File

@ -7,9 +7,22 @@
#ifndef E_FM_MIME_H
#define E_FM_MIME_H
typedef struct _E_Fm_Mime_Handler E_Fm_Mime_Handler;
struct _E_Fm_Mime_Handler
{
const char *label, *icon_group;
void (*action_func) (Evas_Object *obj, const char *path, void *data);
int (*test_func) (Evas_Object *obj, const char *path, void *data);
};
EAPI const char *e_fm_mime_filename_get(const char *fname);
EAPI const char *e_fm_mime_icon_get(const char *mime);
EAPI void e_fm_mime_icon_cache_flush(void);
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));
EAPI int e_fm_mime_handler_mime_add(E_Fm_Mime_Handler *handler, const char *mime);
EAPI int e_fm_mime_handler_glob_add(E_Fm_Mime_Handler *handler, const char *glob);
#endif
#endif