Enlightenment CVS committal

Author  : codewarrior
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/bin


Modified Files:
        e_fm.c e_fm_mime.c e_fm_mime.h 


Log Message:
Add e_fm2_mime_handler_test() to run a mime handler's internal test funciton
When as right click an icon, we need to run the test function to determine of
context entries need to go into the menu or not. (previously, only the glob /
mime check was being done)

===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_fm.c,v
retrieving revision 1.218
retrieving revision 1.219
diff -u -3 -r1.218 -r1.219
--- e_fm.c      14 Oct 2007 17:31:27 -0000      1.218
+++ e_fm.c      15 Oct 2007 12:35:56 -0000      1.219
@@ -359,7 +359,7 @@
 static void _e_fm2_client_mount(const char *udi, const char *mountpoint);
 static void _e_fm2_client_unmount(const char *udi);
 static void _e_fm2_sel_rect_update(void *data);
-static inline void _e_fm2_context_menu_append(Evas_List *l, E_Menu *mn, 
E_Fm2_Icon *ic);
+static inline void _e_fm2_context_menu_append(Evas_Object *obj, const char 
*path, Evas_List *l, E_Menu *mn, E_Fm2_Icon *ic);
 static int _e_fm2_context_list_sort(void *data1, void *data2);
 
 static char *_e_fm2_meta_path = NULL;
@@ -6877,14 +6877,16 @@
          {
             /* see if we have any mime handlers registered for this file */
             l = e_fm2_mime_handler_mime_handlers_get(ic->info.mime);
-            _e_fm2_context_menu_append(l, mn, ic);
+            snprintf(buf, sizeof(buf), "%s/%s", sd->realpath, ic->info.file);
+            _e_fm2_context_menu_append(obj, buf, l, mn, ic);
             if (l) evas_list_free(l);
          }
 
        /* see if we have any glob handlers registered for this file */
        snprintf(buf, sizeof(buf), "*%s", strrchr(ic->info.file, '.'));
        l = e_fm2_mime_handler_glob_handlers_get(buf);
-       _e_fm2_context_menu_append(l, mn, ic);
+       snprintf(buf, sizeof(buf), "%s/%s", sd->realpath, ic->info.file);
+       _e_fm2_context_menu_append(obj, buf, l, mn, ic);
        if (l) evas_list_free(l);
 
        if (sd->icon_menu.end.func)
@@ -6918,7 +6920,7 @@
 }
 
 static inline void 
-_e_fm2_context_menu_append(Evas_List *l, E_Menu *mn, E_Fm2_Icon *ic) 
+_e_fm2_context_menu_append(Evas_Object *obj, const char *path, Evas_List *l, 
E_Menu *mn, E_Fm2_Icon *ic) 
 {
    Evas_List *ll = NULL;
    E_Menu_Item *mi;
@@ -6926,16 +6928,24 @@
    if (!l) return;
    
    l = evas_list_sort(l, -1, _e_fm2_context_list_sort);
-   mi = e_menu_item_new(mn);
-   e_menu_item_separator_set(mi, 1);
-
+   
    for (ll = l; ll; ll = ll->next) 
      {
        E_Fm2_Mime_Handler *handler = NULL;
        E_Fm2_Context_Menu_Data *md = NULL;
        
        handler = ll->data;
-       if (!handler) continue;
+       if ((!handler) || (!e_fm2_mime_handler_test(handler, obj, path))) 
continue;
+
+       if (ll == l)
+         {
+            /* only append the separator if this is the first item */
+            /* we do this in here because we dont want to add a separator
+             * when we have no context entries */
+            mi = e_menu_item_new(mn);
+            e_menu_item_separator_set(mi, 1);
+         }
+
        md = E_NEW(E_Fm2_Context_Menu_Data, 1);
        if (!md) continue;
        _e_fm2_menu_contexts = evas_list_append(_e_fm2_menu_contexts, md);
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_fm_mime.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- e_fm_mime.c 14 Oct 2007 18:20:49 -0000      1.24
+++ e_fm_mime.c 15 Oct 2007 12:35:56 -0000      1.25
@@ -342,6 +342,16 @@
      }
 }
 
+/* run a handlers test function */
+EAPI Evas_Bool
+e_fm2_mime_handler_test(E_Fm2_Mime_Handler *handler, Evas_Object *obj, const 
char *path)
+{
+   if ((!handler) || (!obj) || (!path)) return 0;
+   if (!handler->test_func) return 1;
+
+   return handler->test_func(obj, path, handler->test_data);
+}
+
 /* local subsystem functions */
 /* used to loop a glob hash and determine if the glob handler matches the 
filename */
 static Evas_Bool 
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_fm_mime.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- e_fm_mime.h 14 Oct 2007 15:17:32 -0000      1.10
+++ e_fm_mime.h 15 Oct 2007 12:35:56 -0000      1.11
@@ -27,6 +27,7 @@
 EAPI Evas_Bool e_fm2_mime_handler_mime_add(E_Fm2_Mime_Handler *handler, const 
char *mime);
 EAPI Evas_Bool e_fm2_mime_handler_glob_add(E_Fm2_Mime_Handler *handler, const 
char *glob);
 EAPI Evas_Bool e_fm2_mime_handler_call(E_Fm2_Mime_Handler *handler, 
Evas_Object *obj, const char *path);
+EAPI Evas_Bool e_fm2_mime_handler_test(E_Fm2_Mime_Handler *handler, 
Evas_Object *obj, const char *path);
 EAPI void e_fm2_mime_handler_mime_handlers_call_all(Evas_Object *obj, const 
char *path, const char *mime);
 EAPI void e_fm2_mime_handler_glob_handlers_call_all(Evas_Object *obj, const 
char *path, const char *glob);
 EAPI void e_fm2_mime_handler_mime_del(E_Fm2_Mime_Handler *handler, const char 
*mime);



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