Enlightenment CVS committal

Author  : codewarrior
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/bin


Modified Files:
        e_fm_mime.c e_fm_mime.h 


Log Message:
Add data pointers to test / action callbacks.
Add function to call a handler.


===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_fm_mime.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -3 -r1.17 -r1.18
--- e_fm_mime.c 14 Oct 2007 12:45:23 -0000      1.17
+++ e_fm_mime.c 14 Oct 2007 12:59:26 -0000      1.18
@@ -121,8 +121,10 @@
 /* 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 @@
    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 @@
 }
 
 /* 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 @@
 }
 
 /* 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 @@
 
    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)
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_fm_mime.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- e_fm_mime.h 14 Oct 2007 12:45:23 -0000      1.5
+++ e_fm_mime.h 14 Oct 2007 12:59:26 -0000      1.6
@@ -1,29 +1,33 @@
-/*

- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2

- */

-#ifdef E_TYPEDEFS

-

-#else

-#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 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);

-

-#endif

-#endif

+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
+#ifdef E_TYPEDEFS
+
+#else
+#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);
+   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), 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 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



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to