Add data pointers to test / action callbacks.

Add function to call a handler.


SVN revision: 32061
devs/princeamd/enlightenment-0.17-elive
codewarrior 16 years ago committed by codewarrior
parent 3304ad77d4
commit 9ffb9ddab7
  1. 40
      src/bin/e_fm_mime.c
  2. 10
      src/bin/e_fm_mime.h

@ -121,8 +121,10 @@ 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))
void (*action_func) (Evas_Object *obj, const char *path, void *data),
void *action_data,
int (test_func) (Evas_Object *obj, const char *path, void *data),
void *test_data)
{
E_Fm_Mime_Handler *handler;
@ -134,10 +136,10 @@ e_fm_mime_handler_new(const char *label, const char *icon_group,
handler->label = evas_stringshare_add(label);
handler->icon_group = icon_group ? evas_stringshare_add(icon_group) : NULL;
handler->action_func = action_func;
handler->action_data = action_data;
handler->test_func = test_func;
/* TODO: add data for both action_cb and test_cb */
handler->test_data = test_data;
return handler;
}
@ -151,7 +153,7 @@ e_fm_mime_handler_free(E_Fm_Mime_Handler *handler)
}
/* associate a certain mime type with a handler */
EAPI int
EAPI Evas_Bool
e_fm_mime_handler_mime_add(E_Fm_Mime_Handler *handler, const char *mime)
{
Evas_List *handlers = NULL;
@ -175,7 +177,7 @@ e_fm_mime_handler_mime_add(E_Fm_Mime_Handler *handler, const char *mime)
}
/* associate a certain glob with a handler */
EAPI int
EAPI Evas_Bool
e_fm_mime_handler_glob_add(E_Fm_Mime_Handler *handler, const char *glob)
{
Evas_List *handlers = NULL;
@ -197,7 +199,29 @@ e_fm_mime_handler_glob_add(E_Fm_Mime_Handler *handler, const char *glob)
return 1;
}
/* call a certain handler */
EAPI Evas_Bool
e_fm_mime_handler_call(E_Fm_Mime_Handler *handler, Evas_Object *obj, const char *path)
{
if (!handler || !obj || !path || !handler->action_func)
return 0;
if (handler->test_func)
{
if (handler->test_func(obj, path, handler->test_data))
{
handler->action_func(obj, path, handler->action_data);
return 1;
}
else
return 0;
}
handler->action_func(obj, path, handler->action_data);
return 1;
}
/* local subsystem functions */
static Evas_Bool
_e_fm_mime_icon_foreach(Evas_Hash *hash, const char *key, void *data, void *fdata)

@ -14,16 +14,20 @@ 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);
void *action_data;
void *test_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 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), void *action_data, int (test_func) (Evas_Object *obj, const char *path, void *data), void *test_data);
EAPI void e_fm_mime_handler_free(E_Fm_Mime_Handler *handler);
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);
EAPI Evas_Bool e_fm_mime_handler_mime_add(E_Fm_Mime_Handler *handler, const char *mime);
EAPI Evas_Bool e_fm_mime_handler_glob_add(E_Fm_Mime_Handler *handler, const char *glob);
EAPI Evas_Bool e_fm_mime_handler_call(E_Fm_Mime_Handler *handler, Evas_Object *obj, const char *path);
#endif
#endif

Loading…
Cancel
Save