Am Samstag, den 14.01.2006, 13:43 +0200 schrieb Hisham Mardam Bey:
> On 1/14/06, mista <[EMAIL PROTECTED]> wrote:
> 
> > in this patch is the e_fm_file_has_mime() function and it now gets used
> > instead of the bunch of strcmps. Probably e_fm_file_is_regular() shouldn
> > ´t be exported. file->mime is now always lower case, so the programs
> > gets shown in open-with even if the extension has upper case.
> 
> all is good, except for one thing.
> 
> when you open something in gimp for example, then you right click on
> another image, and try to open it in gimp, it opens the old image.
> (same thing if you do gimp, then exhibit).
> 
This is now fixed. 
It didn´t work with the hashed menus, since the item-callback had the
same icon-data. By right click on an icon this icon gets selected, so
now I let file_menu_open use the pointer to the current selection.  

I added an E_App* to the Assoc to have icons in the menu. When the list
is initialized, it goes through the eapp list and looks if it finds the
same exe and adds it to the Assoc. This is then used when the open-with
menu gets generated to show the icon. 

But the best feature is the one you probably don´t like. Though you can
test it very compfortable and decide yourself. When you right click on
an eap (in .../all (a link from home to all is good for that)) like
file-roller, use eapp_edit and add "tar;gz;bz2;" as comment. restart efm
and right click on a file of that type entered before.
 Can we leave it temporaly? =) 

> your patch has been applied to cvs, but please try to submit a fix for that.
> 
> as others have also suggested, using unified diffs (-u) would be better.
> 
okay, now I know. But you told me to do so :) 
Another question is, if I can work further on my local code code before
the patch is applied, or could that make complications?  

> thank you for your great work!

it´s also fun to learn c on this code ;)

regards,
jeff


> 
> hisham.
> 
> 
> > regards,
> > jeff
> >
> >
> >
> >
> >
> 
> 
> --
> Hisham Mardam Bey
> MSc (Computer Science)
> http://hisham.cc/
> +9613609386
> Codito Ergo Sum (I Code Therefore I Am)
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
> _______________________________________________
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> 
Index: e_fileman_file.c
===================================================================
RCS file: /root/e17/apps/e/src/bin/e_fileman_file.c,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 e_fileman_file.c
--- e_fileman_file.c	10 Jan 2006 08:35:26 -0000	1.1.1.5
+++ e_fileman_file.c	14 Jan 2006 20:49:40 -0000
@@ -74,13 +74,17 @@
 
    if(!file->mime)
      {
-	ext = strrchr(file->name, '.');
-	if (ext)
-	  {
-	     file->mime = ext;
-	  }
-	else
-	  file->mime = "unknown";
+  ext = strrchr(file->name, '.');
+  if (ext)
+    {
+       char *ext2;
+       ext = strdup(ext);
+       ext2 = ext;
+       for (; *ext2; ext2++) *ext2 = tolower(*ext2);
+       file->mime = ext;
+    }
+  else
+    file->mime = "unknown";
      }
    D(("e_fm_file_new: %s\n", filename));
    return file;
@@ -105,17 +109,17 @@
 
    if (ecore_file_mv(file->path, path))
      {
-	free(file->path);
-	file->path = strdup(path);
-	free(file->name);
-	file->name = strdup(name);
-	D(("e_fm_file_rename: ok (%p) (%s)\n", file, name));
-	return 1;
+  free(file->path);
+  file->path = strdup(path);
+  free(file->name);
+  file->name = strdup(name);
+  D(("e_fm_file_rename: ok (%p) (%s)\n", file, name));
+  return 1;
      }
    else
      {
-	D(("e_fm_file_rename: fail (%p) (%s)\n", file, name));
-	return 0;
+  D(("e_fm_file_rename: fail (%p) (%s)\n", file, name));
+  return 0;
      }
 }
 
@@ -124,17 +128,17 @@
 {
    if (ecore_file_recursive_rm(file->path))
      {
-	free(file->path);
-	file->path = NULL;
-	free(file->name);
-	file->name = NULL;
-	D(("e_fm_file_delete: ok (%p) (%s)\n", file, file->name));
-	return 1;
+  free(file->path);
+  file->path = NULL;
+  free(file->name);
+  file->name = NULL;
+  D(("e_fm_file_delete: ok (%p) (%s)\n", file, file->name));
+  return 1;
      }
    else
      {
-	D(("e_fm_file_delete: fail (%p) (%s)\n", file, file->name));
-	return 0;
+  D(("e_fm_file_delete: fail (%p) (%s)\n", file, file->name));
+  return 0;
      }
 }
 
@@ -145,20 +149,36 @@
 
    if (ecore_file_cp(file->path, name))
      {
-	free(file->path);
-	file->path = strdup(name);
-	free(file->name);
-	file->name = strdup(ecore_file_get_file(name));
-	D(("e_fm_file_copy: ok (%p) (%s)\n", file, name));
-	return 1;
+  free(file->path);
+  file->path = strdup(name);
+  free(file->name);
+  file->name = strdup(ecore_file_get_file(name));
+  D(("e_fm_file_copy: ok (%p) (%s)\n", file, name));
+  return 1;
      }
    else
      {
-	D(("e_fm_file_copy: fail (%p) (%s)\n", file, name));
-	return 0;
+  D(("e_fm_file_copy: fail (%p) (%s)\n", file, name));
+  return 0;
      }
 }
 
+int
+e_fm_file_is_regular(E_Fm_File *file) /* TODO: find better name */
+{
+   return ((file->type == E_FM_FILE_TYPE_FILE) 
+        || (file->type == E_FM_FILE_TYPE_SYMLINK)); 
+}
+
+EAPI int
+e_fm_file_has_mime(E_Fm_File *file, char* mime)
+{
+   if (!file->mime) return 0;
+
+   D(("e_fm_file_has_mime: (%p) : %s\n", file,file->mime));
+   return (!strcasecmp(file->mime, mime));
+}
+
 EAPI int
 e_fm_file_can_preview(E_Fm_File *file)
 {
@@ -167,11 +187,11 @@
    D(("e_fm_file_can_preview: (%s) (%p)\n", file->name, file));
    for (i = 0; file->preview_funcs[i]; i++)
      {
-	E_Fm_File_Preview_Function func;
+  E_Fm_File_Preview_Function func;
 
-	func = file->preview_funcs[i];
-	if (func(file))
-	  return 1;
+  func = file->preview_funcs[i];
+  if (func(file))
+    return 1;
      }
    return 0;
 }
@@ -183,31 +203,22 @@
     * If it isn't supported by evas, we can't show it in the
     * canvas.
     */
-   char *ext;
-
-   if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0;
-
-   ext = strrchr(file->name, '.');
-   if (!ext) return 0;
-
-   D(("e_fm_file_is_image: (%p)\n", file));
-   return (!strcasecmp(ext, ".jpg")) || (!strcasecmp(ext, ".png")) ||
-     (!strcasecmp(ext, ".jpeg"));
+   
+   //D(("e_fm_file_is_image: (%p)\n", file));
+   
+   return e_fm_file_is_regular(file)
+        &&(e_fm_file_has_mime(file,".jpg") 
+        || e_fm_file_has_mime(file,".jpeg") 
+        || e_fm_file_has_mime(file,".png")); 
 }
 
 EAPI int
 e_fm_file_is_etheme(E_Fm_File *file)
 {
    int          val;
-   char        *ext;
    Evas_List   *groups, *l;
 
-   if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0;
-
-   ext = strrchr(file->name, '.');
-   if (!ext) return 0;
-
-   if (strcasecmp(ext, ".edj"))
+   if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".edj"))
      return 0;
 
    val = 0;
@@ -216,13 +227,13 @@
      return 0;
 
    for (l = groups; l; l = l->next)
-     {
-	if (!strcmp(l->data, "widgets/border/default/border"))
-	  {
-	     val = 1;
-	     break;
-	  }
-     }
+   {
+    if (!strcmp(l->data, "widgets/border/default/border"))
+    {
+       val = 1;
+       break;
+    }
+   }
    edje_file_collection_list_free(groups);
    return val;
 }
@@ -231,30 +242,24 @@
 e_fm_file_is_ebg(E_Fm_File *file)
 {
    int          val;
-   char        *ext;
    Evas_List   *groups, *l;
 
-   if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0;
-
-   ext = strrchr(file->name, '.');
-   if (!ext) return 0;
-
-   if (strcasecmp(ext, ".edj"))
+   if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".edj"))
      return 0;
-
+  
    val = 0;
    groups = edje_file_collection_list(file->path);
    if (!groups)
      return 0;
 
    for (l = groups; l; l = l->next)
-     {
-	if (!strcmp(l->data, "desktop/background"))
-	  {
-	     val = 1;
-	     break;
-	  }
-     }
+   {
+    if (!strcmp(l->data, "desktop/background"))
+    {
+       val = 1;
+       break;
+    }
+   }
    edje_file_collection_list_free(groups);
    return val;
 }
@@ -262,23 +267,18 @@
 EAPI int
 e_fm_file_is_eap(E_Fm_File *file)
 {
-   char *ext;
-   E_App *app;
-
-   if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0;
 
-   ext = strrchr(file->name, '.');
-   if (!ext) return 0;
+   E_App *app;
 
-   if (strcasecmp(ext, ".eap"))
+  if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".eap"))
      return 0;
-
+  
    app = e_app_new(file->path, 0);
    if (!app)
-     {
-	e_object_unref(E_OBJECT(app));
-	return 0;
-     }
+   {
+    e_object_unref(E_OBJECT(app));
+    return 0;
+   }
    e_object_unref(E_OBJECT(app));
    return 1;
 }
@@ -286,23 +286,17 @@
 EAPI int
 e_fm_file_can_exec(E_Fm_File *file)
 {
-   char *ext;
-
-   ext = strrchr(file->name, '.');
-   if (ext)
-     {
-	if (!strcasecmp(ext, ".eap"))
-	  {
-	     D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name));
-	     return 1;
-	  }
-     }
+   if (e_fm_file_has_mime(file,".eap"))
+   {
+     D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name));
+     return 1;
+   }
 
    if (ecore_file_can_exec(file->path))
-     {
-	D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name));
-	return 1;
-     }
+   {
+    D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name));
+    return 1;
+   }
 
    D(("e_fm_file_can_exec: false (%p) (%s)\n", file, file->name));
    return 0;
@@ -312,40 +306,35 @@
 e_fm_file_exec(E_Fm_File *file)
 {
    Ecore_Exe *exe;
-   char *ext;
 
-   ext = strrchr(file->name, '.');
-   if (ext)
-     {
-	if (!strcasecmp(ext, ".eap"))
-	  {
-	     E_App *e_app;
-	     Ecore_Exe *exe;
-
-	     e_app = e_app_new(file->path, 0);
-
-	     if (!e_app) return 0;
-
-	     exe = ecore_exe_run(e_app->exe, NULL);
-	     if (exe) ecore_exe_free(exe);
-	     e_object_unref(E_OBJECT(e_app));
-	     D(("e_fm_file_exec: eap (%p) (%s)\n", file, file->name));
-	     return 1;
-	  }
-     }
+   if(e_fm_file_has_mime(file,".eap"))
+   {
+       E_App *e_app;
+       Ecore_Exe *exe;
+
+       e_app = e_app_new(file->path, 0);
+
+       if (!e_app) return 0;
+
+       exe = ecore_exe_run(e_app->exe, NULL);
+       if (exe) ecore_exe_free(exe);
+       e_object_unref(E_OBJECT(e_app));
+       D(("e_fm_file_exec: eap (%p) (%s)\n", file, file->name));
+       return 1;
+    } 
 
    exe = ecore_exe_run(file->path, NULL);
    if (!exe)
-     {
-	e_error_dialog_show(_("Run Error"),
-			    _("Enlightenment was unable to fork a child process:\n"
-			      "\n"
-			      "%s\n"
-			      "\n"),
-			    file->path);
-	D(("e_fm_file_exec: fail (%p) (%s)\n", file, file->name));
-	return 0;
-     }
+   {
+    e_error_dialog_show(_("Run Error"),
+          _("Enlightenment was unable to fork a child process:\n"
+            "\n"
+            "%s\n"
+            "\n"),
+          file->path);
+    D(("e_fm_file_exec: fail (%p) (%s)\n", file, file->name));
+    return 0;
+   }
    /* E/app is the correct tag if the data is en E_App!
    ecore_exe_tag_set(exe, "E/app");
    */
@@ -371,15 +360,12 @@
    if (!assoc_apps) return 0;
 
    for (l = assoc_apps; l; l = l->next)
-     {
-	char *ext;
-
-	assoc = l->data;
-	ext = strrchr(file->path, '.');
-	if ((ext) && (!strcasecmp(ext, assoc->mime)))
-	  break;
-	assoc = NULL;
-     }
+   {
+    assoc = l->data;
+    if (e_fm_file_has_mime(file,assoc->mime))
+      break;
+    assoc = NULL;
+   }
 
    if (!assoc) return 0;
 
@@ -387,16 +373,16 @@
    exe = ecore_exe_run(app, NULL);
 
    if (!exe)
-     {
-	e_error_dialog_show(_("Run Error"),
-			    _("Enlightenment was unable to fork a child process:\n"
-			      "\n"
-			      "%s\n"
-			      "\n"),
-			    app);
-	D(("e_fm_assoc_exec: fail (%s)\n", app));
-	return 0;
-     }
+   {
+    e_error_dialog_show(_("Run Error"),
+          _("Enlightenment was unable to fork a child process:\n"
+            "\n"
+            "%s\n"
+            "\n"),
+          app);
+    D(("e_fm_assoc_exec: fail (%s)\n", app));
+    return 0;
+   }
    /*
     * ecore_exe_tag_set(exe, "E/app");
     */
@@ -415,15 +401,15 @@
    exe = ecore_exe_run(app, NULL);
 
    if (!exe)
-     {
-	e_error_dialog_show(_("Run Error"),
-			    _("3 Enlightenment was unable to fork a child process:\n"
-			      "\n"
-			      "%s\n"
-			      "\n"),
-			    app);
-	return 0;
-     }
+   {
+    e_error_dialog_show(_("Run Error"),
+          _("Enlightenment was unable to fork a child process:\n"
+            "\n"
+            "%s\n"
+            "\n"),
+          app);
+     return 0;
+   }
    return 1;
 }
 
@@ -435,7 +421,7 @@
    free(file->preview_funcs);
    if (file->path) free(file->path);
    if (file->name) free(file->name);
-   ///???  if (file->mime) free(file->mime);
+   ///???  if (file->mime) free(file->mime); 
    free(file);
 }
 
Index: e_fileman_file.h
===================================================================
RCS file: /root/e17/apps/e/src/bin/e_fileman_file.h,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 e_fileman_file.h
--- e_fileman_file.h	7 Jan 2006 00:06:12 -0000	1.1.1.2
+++ e_fileman_file.h	14 Jan 2006 20:49:40 -0000
@@ -37,7 +37,7 @@
 
    char     *path;            /* full name with path */
    char     *name;            /* file name without parent directories */
-   char     *mime;            /* mimetype (just the extension) */
+   char     *mime;            /* mimetype (just the extension, beginning with dot) */
 
    dev_t     device;          /* ID of device containing file */
    ino_t     inode;           /* inode number */
@@ -67,8 +67,9 @@
 EAPI int        e_fm_file_exec        (E_Fm_File *file);
 EAPI int        e_fm_file_assoc_set   (E_Fm_File *file, const char *assoc);
 EAPI int        e_fm_file_assoc_exec  (E_Fm_File *file);
-EAPI int	e_fm_file_exec_with   (E_Fm_File *file, char* exec_with);
-
+EAPI int				e_fm_file_exec_with   (E_Fm_File *file, char* exec_with);
+EAPI int				e_fm_file_has_mime    (E_Fm_File *file, char* mime);
+EAPI int        e_fm_file_is_regular  (E_Fm_File *file);
 #endif
 #endif
 
Index: e_fileman_icon.c
===================================================================
RCS file: /root/e17/apps/e/src/bin/e_fileman_icon.c,v
retrieving revision 1.1.1.17
diff -u -r1.1.1.17 e_fileman_icon.c
--- e_fileman_icon.c	7 Jan 2006 18:05:40 -0000	1.1.1.17
+++ e_fileman_icon.c	14 Jan 2006 20:49:41 -0000
@@ -496,32 +496,22 @@
 static void
 _e_fm_icon_icon_mime_get(E_Smart_Data *sd)
 {
-   sd->image_object = edje_object_add(sd->evas);
-   if (sd->file->type ==  E_FM_FILE_TYPE_DIRECTORY)
-     e_theme_edje_object_set(sd->image_object, "base/theme/fileman",
-			     "icons/fileman/folder");
-   else
-     {
-	char *ext;
-
-	ext = strrchr(sd->file->name, '.');
-	if (ext)
-	  {
-	     char part[PATH_MAX];
-	     char *ext2;
-
-	     ext = strdup(ext);
-	     ext2 = ext;
-	     for (; *ext2; ext2++) *ext2 = tolower(*ext2);
-
-	     snprintf(part, PATH_MAX, "icons/fileman/%s", (ext + 1));
-	     if (!e_theme_edje_object_set(sd->image_object, "base/theme/fileman", part))
+  char part[PATH_MAX];
+	
+	sd->image_object = edje_object_add(sd->evas);
+	
+	// since a mime is set with every creation of an E_Fm_File its existence isn´t checked here
+	if(sd->file->type ==  E_FM_FILE_TYPE_DIRECTORY)
+		 	e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "icons/fileman/folder");
+  
+  else if(e_fm_file_has_mime(sd->file,"unknown"))
+   	  e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "icons/fileman/file");
+  else 
+  {
+   	  snprintf(part, PATH_MAX, "icons/fileman/%s", (sd->file->mime + 1)); 
+	    if (!e_theme_edje_object_set(sd->image_object, "base/theme/fileman", part))
 	       e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "icons/fileman/file");
-	     free(ext);
-	  }
-	else
-	  e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "icons/fileman/file");
-     }
+   }
    evas_object_show(sd->image_object);
    edje_extern_object_min_size_set(sd->image_object, sd->iw, sd->ih);
    edje_extern_object_max_size_set(sd->image_object, sd->iw, sd->ih);
@@ -529,19 +519,16 @@
 			    sd->image_object);
 }
 
+
+
 void
 _e_fm_icon_thumb_generate_cb(Evas_Object *obj, void *data)
 {
    E_Smart_Data         *sd;
-   char                 *ext;
 
    sd = data;
 
-   ext = strrchr(sd->file->name, '.');
-   if ((ext) && (strcasecmp(ext, ".eap")))
-     ext = NULL;
-
-   if ((ext) || (ecore_file_exists(sd->thumb_path)))
+   if (e_fm_file_has_mime(sd->file,".eap") || (ecore_file_exists(sd->thumb_path)))
      {
 	Evas_Coord icon_w, icon_h;
 
Index: e_fileman_smart.c
===================================================================
RCS file: /root/e17/apps/e/src/bin/e_fileman_smart.c,v
retrieving revision 1.1.1.44
diff -u -r1.1.1.44 e_fileman_smart.c
--- e_fileman_smart.c	7 Jan 2006 18:05:40 -0000	1.1.1.44
+++ e_fileman_smart.c	14 Jan 2006 20:49:45 -0000
@@ -463,35 +463,35 @@
 /* local subsystem functions */
 
 int
-_e_fm_init_assoc(E_Fm_Smart_Data *sd)
+_e_fm_init_assoc(E_Fm_Smart_Data *sd) /* TODO: check if this gets freed correctly*/
 {
    E_Fm_Assoc_App *assoc;
 
    assoc = E_NEW(E_Fm_Assoc_App, 1);
    assoc->mime = (char*)E_NEW(char *, 5);
    snprintf(assoc->mime, 5, "%s", ".jpg");
-   assoc->app = (char*)E_NEW(char *, 7);
-   snprintf(assoc->app, 5, "gimp-remote");
+   assoc->app = (char*)E_NEW(char *, 12);
+   snprintf(assoc->app, 12, "gimp-remote");
    sd->conf.main->apps = evas_list_append(sd->conf.main->apps, assoc);
 
    assoc = E_NEW(E_Fm_Assoc_App, 1);
    assoc->mime = (char*)E_NEW(char *, 5);
    snprintf(assoc->mime, 5, "%s", ".jpg");
-   assoc->app = (char*)E_NEW(char *, 7);
+   assoc->app = (char*)E_NEW(char *, 8);
    snprintf(assoc->app, 8, "exhibit");
    sd->conf.main->apps = evas_list_append(sd->conf.main->apps, assoc);
 
    assoc = E_NEW(E_Fm_Assoc_App, 1);
    assoc->mime = (char*)E_NEW(char *, 5);
    snprintf(assoc->mime, 5, "%s", ".png");
-   assoc->app = (char*)E_NEW(char *, 7);
-   snprintf(assoc->app, 5, "gimp-remote");
+   assoc->app = (char*)E_NEW(char *, 12);
+   snprintf(assoc->app, 12, "gimp-remote");
    sd->conf.main->apps = evas_list_append(sd->conf.main->apps, assoc);
 
    assoc = E_NEW(E_Fm_Assoc_App, 1);
    assoc->mime = (char*)E_NEW(char *, 5);
    snprintf(assoc->mime, 5, "%s", ".png");
-   assoc->app = (char*)E_NEW(char *, 7);
+   assoc->app = (char*)E_NEW(char *, 8);
    snprintf(assoc->app, 8, "exhibit");
    sd->conf.main->apps = evas_list_append(sd->conf.main->apps, assoc);
 
@@ -505,10 +505,80 @@
    assoc = E_NEW(E_Fm_Assoc_App, 1);
    assoc->mime = (char*)E_NEW(char *, 5);
    snprintf(assoc->mime, 5, "%s", ".mp3");
-   assoc->app = (char*)E_NEW(char *, 7);
+   assoc->app = (char*)E_NEW(char *, 8);
    snprintf(assoc->app, 8, "xmms -Q");
    sd->conf.main->apps = evas_list_append(sd->conf.main->apps, assoc);
 
+   assoc = E_NEW(E_Fm_Assoc_App, 1);
+   assoc->mime = (char*)E_NEW(char *, 10);
+   snprintf(assoc->mime, 10, "%s", "directory");
+   assoc->app = (char*)E_NEW(char *, 8);
+   snprintf(assoc->app, 8, "entropy");
+   sd->conf.main->apps = evas_list_append(sd->conf.main->apps, assoc);
+
+   assoc = E_NEW(E_Fm_Assoc_App, 1);
+   assoc->mime = (char*)E_NEW(char *, 5);
+   snprintf(assoc->mime, 5, "%s", ".eap");
+   assoc->app = (char*)E_NEW(char *, 17);
+   snprintf(assoc->app, 17, "e_util_eapp_edit");
+   sd->conf.main->apps = evas_list_append(sd->conf.main->apps, assoc);
+ 
+	Evas_List *l, *list, *apps;
+
+
+	list = e_app_name_glob_list("*");
+	for (apps = sd->conf.main->apps; apps; apps = apps->next)
+	{
+		assoc = apps->data;
+		assoc->eap = NULL;
+		for (l = list; l; l = l->next)
+		{
+			E_App *a;
+			a = l->data; 
+			
+			if((a->exe) && !strncmp(a->exe, assoc->app, strlen(assoc->app)))
+			{
+				assoc->eap = a;		
+				break;
+			}
+		}
+	}
+	
+	
+	
+	/* THIS IS THE HACK */
+  char *token,*mime;
+  char dot[PATH_MAX]; 
+	for (l = list; l; l = l->next)
+	{
+		E_App *a;
+		a = l->data; 
+		if (a->exe && a->comment && strlen(a->comment) > 1)
+		{
+			mime = strdup(a->comment); 
+			if(token = strtok(mime, ";"))
+			{	
+				assoc = E_NEW(E_Fm_Assoc_App, 1);
+	   		snprintf(dot, PATH_MAX , _(".%s"), token);
+	   		assoc->mime = strdup(dot);
+	   		assoc->app = a->exe;
+	   		assoc->eap = a;
+	   		sd->conf.main->apps = evas_list_append(sd->conf.main->apps, assoc);
+				while(token = strtok(NULL, ";")) // take next token of mime
+				{
+					assoc = E_NEW(E_Fm_Assoc_App, 1);
+	   			snprintf(dot, PATH_MAX , _(".%s"), token);
+	   			assoc->mime = strdup(dot);
+	   			assoc->app = a->exe;
+	   			assoc->eap = a; 	   			
+	   			sd->conf.main->apps = evas_list_append(sd->conf.main->apps, assoc);			
+				}
+	 		}
+	  }	
+  } 
+ evas_list_free(list);
+ free(token);
+ free(mime);
    return 1;
 }
 
@@ -871,12 +941,15 @@
 static void
 _e_fm_file_menu_open(void *data, E_Menu *m, E_Menu_Item *mi)
 {
+   E_Fm_Smart_Data *sd;
    E_Fm_Icon *icon;
    E_Fm_Assoc_App *assoc;
    Evas_List *l;
-   icon = data;
+   
+   sd = data;
+   icon = sd->selection.current.file;
 
-   for (l = icon->sd->conf.main->apps; l; l = l->next)
+   for (l = sd->conf.main->apps; l; l = l->next)
      {
 	assoc = l->data;
 	if(!strcmp(assoc->app,mi->label)){
@@ -888,7 +961,7 @@
    switch (icon->file->type)
      {
       case E_FM_FILE_TYPE_DIRECTORY:
-	_e_fm_dir_set(icon->sd, icon->file->path);
+	_e_fm_dir_set(sd, icon->file->path);
 	break;
       case E_FM_FILE_TYPE_FILE:
 	if ((!e_fm_file_assoc_exec(icon->file) && (e_fm_file_can_exec(icon->file))))
@@ -1211,7 +1284,7 @@
    e_widget_frametable_object_append(o, e_widget_label_add(evas, text),
 				     0, 2, 1, 1,
 				     1, 1, 1, 1);
-   snprintf(text, 512, "%s", "An Image");
+   snprintf(text, 512, "%s", icon->file->mime);
    e_widget_frametable_object_append(o, e_widget_label_add(evas, text),
 				     1, 2, 1, 1,
 				     1, 1, 1, 1);
@@ -2120,7 +2193,7 @@
 	     if(icon->sd->win)
 	       icon->sd->drag.start = 0;
 
-	     if (!strcmp(icon->file->name, ".")) return;
+	     if (!strcmp(icon->file->name, ".")) return; /* this case cant happen!? */
 
 	     if (!strcmp(icon->file->name, ".."))
 	       {
@@ -2208,14 +2281,13 @@
 
 	mi = NULL;
 	if((mo = evas_hash_find(icon->sd->mime_menu_hash,icon->file->mime)) == NULL)
-	  {
-	     /*- Arrange -*/
-	     mo = e_menu_new();
+			{
 
+	     mo = e_menu_new();
 	     for (l = icon->sd->conf.main->apps; l; l = l->next)
 	       {
 		  assoc = l->data;
-		  if (strcmp(icon->file->mime, assoc->mime) == 0)
+		  if (e_fm_file_has_mime(icon->file, assoc->mime))
 		    {
 
 		       mi = e_menu_item_new(mo);
@@ -2223,13 +2295,13 @@
 		       e_menu_item_radio_set(mi, 1);
 		       e_menu_item_radio_group_set(mi, 2);
 
-		       /*
-		       if (!((assoc->app->icon_class) &&
-			     (e_util_menu_item_edje_icon_list_set(mi, assoc->app->icon_class))))
-			 e_menu_item_icon_edje_set(mi, assoc->app->path, "item");
-		       */
+		       if(assoc->eap)
+		       {
+		       	if (!e_util_menu_item_edje_icon_list_set(mi, assoc->eap->icon_class))
+							 e_menu_item_icon_edje_set(mi, assoc->eap->path, "icon");
+		       }
 
-		       e_menu_item_callback_set(mi, _e_fm_file_menu_open, icon);
+		       e_menu_item_callback_set(mi, _e_fm_file_menu_open, icon->sd);
 		    }
 		  assoc = NULL;
 	       }
@@ -2244,17 +2316,19 @@
 									  "fileman/button/open"),
 					    "fileman/button/open");
 	       }
-	  }
-	else
-	  {
-	     mi = e_menu_item_new(mn);
-	     e_menu_item_label_set(mi, _("Open with"));
-	     e_menu_item_icon_edje_set(mi,
-				       (char *)e_theme_edje_file_get("base/theme/fileman",
-								     "fileman/button/open"),
-				       "fileman/button/open");
-	     e_menu_item_submenu_set(mi, mo);
-	  }
+			}
+	     else
+   		{
+      mi = e_menu_item_new(mn);
+		  e_menu_item_submenu_set(mi, mo);
+		  e_menu_item_label_set(mi, _("Open with"));
+		  e_menu_item_icon_edje_set(mi,
+					    (char *)e_theme_edje_file_get("base/theme/fileman",
+									  "fileman/button/open"),
+					    "fileman/button/open");
+   		} 
+
+
 
 	mi = e_menu_item_new(mn);
 	e_menu_item_label_set(mi, _("Open"));
Index: e_fileman_smart.h
===================================================================
RCS file: /root/e17/apps/e/src/bin/e_fileman_smart.h,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 e_fileman_smart.h
--- e_fileman_smart.h	7 Jan 2006 00:06:11 -0000	1.1.1.5
+++ e_fileman_smart.h	14 Jan 2006 20:49:45 -0000
@@ -193,6 +193,7 @@
 {
    char *mime;
    char *app;
+   E_App *eap;
 };
 
 EAPI int                   e_fm_init(void);

Reply via email to