- added function to get path or url from Evry_File, so that sources dont have to...
authorHannes Janetzek <hannes.janetzek@gmail.com>
Thu, 29 Apr 2010 15:20:12 +0000 (15:20 +0000)
committerHannes Janetzek <hannes.janetzek@gmail.com>
Thu, 29 Apr 2010 15:20:12 +0000 (15:20 +0000)
  - check evry_file_path/uri_get() before using either. when return not NULL file->path/uri can b$
- make 'open with' plugin only show apps mathings the files mimetype
- added 'open with' action which takes any app as second argument
- sort actions that match item type before those matching subtype

SVN revision: 48418

src/modules/everything-apps/e_mod_main.c
src/modules/everything-files/e_mod_main.c
src/modules/everything-wallpaper/e_mod_main.c
src/modules/everything/Evry.h
src/modules/everything/evry.c
src/modules/everything/evry_plug_actions.c
src/modules/everything/evry_plug_view_thumb.c
src/modules/everything/evry_util.c

index f40115e..82fbbff 100644 (file)
@@ -12,12 +12,12 @@ typedef struct _E_Exe_List E_Exe_List;
 
 struct _Plugin
 {
-  Evry_Plugin base;
-  Eina_List *apps_mime;
-  Eina_List *apps_all;
-  Eina_List *apps_hist;
-  const Evry_Item *candidate;
-  Eina_Hash *added;
+  Evry_Plugin   base;
+  Eina_List    *apps_mime;
+  Eina_List    *apps_all;
+  Eina_List    *apps_hist;
+
+  Eina_Hash    *added;
 
   Evry_Item_App *app_command;
   Evry_Item_App *app_parameter;
@@ -25,41 +25,38 @@ struct _Plugin
 
 struct _E_Exe
 {
-  const char *path;
+  const char   *path;
 };
 
 struct _E_Exe_List
 {
-  Eina_List *list;
+  Eina_List    *list;
 };
 
-
 struct _Module_Config 
 {  
-  int version;
-
-  unsigned char list_executables;
-
-  E_Config_Dialog *cfd;
-  E_Module *module;
+  int                   version;
+  unsigned char                 list_executables;
+  E_Config_Dialog      *cfd;
+  E_Module             *module;
 };
 
-static Module_Config *_conf;
-
-static Evry_Plugin *plug_apps = NULL;
-static Evry_Plugin *plug_action = NULL;
-
-static Eina_List *exe_path = NULL;
-static Ecore_Idler *exe_scan_idler = NULL;
-static E_Config_DD *exelist_exe_edd = NULL;
-static E_Config_DD *exelist_edd = NULL;
-static DIR       *exe_dir = NULL;
-static Eina_List *exe_list = NULL;
-static Eina_List *exe_list2 = NULL;
+static Module_Config   *_conf;
+static Evry_Plugin     *plug_apps       = NULL;
+static Evry_Plugin     *plug_apps2      = NULL;
+static Evry_Plugin     *plug_action     = NULL;
+static Eina_List       *_actions        = NULL;
+static Evry_Item       *_act_open_with  = NULL;
+static Eina_List       *exe_path        = NULL;
+static Ecore_Idler     *exe_scan_idler  = NULL;
+static E_Config_DD     *exelist_exe_edd = NULL;
+static E_Config_DD     *exelist_edd     = NULL;
+static DIR             *exe_dir         = NULL;
+static Eina_List       *exe_list        = NULL;
+static Eina_List       *exe_list2       = NULL;
 
-static Eina_List *_actions = NULL;
+static void _scan_executables();
 
-static int _scan_idler(void *data);
 
 static void _hash_free(void *data)
 {
@@ -67,7 +64,6 @@ static void _hash_free(void *data)
    evry_item_free(EVRY_ITEM(app));
 }
 
-
 static Evry_Plugin *
 _begin_open_with(Evry_Plugin *plugin, const Evry_Item *item)
 {
@@ -75,23 +71,24 @@ _begin_open_with(Evry_Plugin *plugin, const Evry_Item *item)
 
    const char *mime;
 
-   if (!CHECK_TYPE(item, EVRY_TYPE_FILE))
+   if (!CHECK_TYPE(item, EVRY_TYPE_FILE) &&
+       !CHECK_SUBTYPE(item, EVRY_TYPE_FILE))
      return 0;
    
    GET_FILE(file, item);
    Efreet_Desktop *d, *d2;
 
-   if (!file->path) return NULL;
+   if (!evry_file_path_get(file))
+     return NULL;
 
    if (!file->mime)
      mime = efreet_mime_type_get(file->path);
    else
      mime = file->mime;
 
-   if (!mime) return NULL;
+   if (!mime)
+     return NULL;
 
-   p->candidate = item;
-   
    p->apps_mime = efreet_util_desktop_mime_list(mime);
 
    if (strcmp(mime, "text/plain") &&
@@ -131,58 +128,27 @@ _begin(Evry_Plugin *plugin, const Evry_Item *item)
 {
    GET_PLUGIN(p, plugin);
 
+   DBG("begin %p %p\n", item, _act_open_with);
+   
+   if (item && (item != _act_open_with))
+     return NULL;
+   
    p->added = eina_hash_string_small_new(_hash_free);
 
-   if (!_conf->list_executables)
-     return plugin;
+   if (_conf->list_executables)
+     _scan_executables();
    
-   /* taken from exebuf module */
-   char *path, *pp, *last;
-   E_Exe_List *el;
-
-   el = e_config_domain_load("exebuf_exelist_cache", exelist_edd);
-   if (el)
-     {
-       E_Exe *ee;
-
-       EINA_LIST_FREE(el->list, ee)
-         {
-            exe_list = eina_list_append(exe_list, strdup(ee->path));
-            eina_stringshare_del(ee->path);
-            free(ee);
-         }
-       free(el);
-     }
-   path = getenv("PATH");
-   if (path)
-     {
-       path = strdup(path);
-       last = path;
-       for (pp = path; pp[0]; pp++)
-         {
-            if (pp[0] == ':') pp[0] = '\0';
-            if (pp[0] == 0)
-              {
-                 exe_path = eina_list_append(exe_path, strdup(last));
-                 last = pp + 1;
-              }
-         }
-       if (pp > last)
-         exe_path = eina_list_append(exe_path, strdup(last));
-       free(path);
-     }
-
-   exe_scan_idler = ecore_idler_add(_scan_idler, NULL);
-
    return plugin;
 }
 
+
 static void
 _finish(Evry_Plugin *plugin)
 {
    GET_PLUGIN(p, plugin);
    Efreet_Desktop *desktop;
-
+   char *str;
+   
    if (p->added)
      eina_hash_free(p->added);
 
@@ -193,16 +159,9 @@ _finish(Evry_Plugin *plugin)
 
    EINA_LIST_FREE(p->apps_hist, desktop)
      efreet_desktop_free(desktop);
-   
-   if (plugin == plug_action)
-     {
-       EINA_LIST_FREE(p->apps_mime, desktop)
-         efreet_desktop_free(desktop);
-     }
-   else
+
+   if (_conf->list_executables)
      {
-       char *str;
-       
        if (exe_dir)
          {
             closedir(exe_dir);
@@ -227,6 +186,21 @@ _finish(Evry_Plugin *plugin)
 
 }
 
+static void
+_finish_mime(Evry_Plugin *plugin)
+{
+   GET_PLUGIN(p, plugin);
+   Efreet_Desktop *desktop;
+
+   if (p->added)
+     eina_hash_free(p->added);
+
+   EVRY_PLUGIN_ITEMS_CLEAR(p);
+
+   EINA_LIST_FREE(p->apps_mime, desktop)
+     efreet_desktop_free(desktop);
+}
+
 static int
 _exec_open_file_action(Evry_Action *act)
 {
@@ -631,91 +605,96 @@ _add_executables(Plugin *p, const char *input)
      }
 }
 
-
 static int
-_fetch(Evry_Plugin *plugin, const char *input)
+_fetch_mime(Evry_Plugin *plugin, const char *input)
 {
    GET_PLUGIN(p, plugin);
    Eina_List *l;
-   Efreet_Desktop *desktop;
    Evry_Item *it;
-   char *file;
 
-   EVRY_PLUGIN_ITEMS_CLEAR(p)
+   EVRY_PLUGIN_ITEMS_CLEAR(p);
    
    /* add apps for a given mimetype */
-   if (plugin == plug_action)
-     _add_desktop_list(p, p->apps_mime, input);
+   _add_desktop_list(p, p->apps_mime, input);
+
+   EINA_LIST_FOREACH(plugin->items, l, it)
+     evry_history_item_usage_set(evry_hist->actions, it, input, NULL);
 
-   /* add apps matching input */
    if (input)
+     EVRY_PLUGIN_ITEMS_SORT(plugin, _cb_sort);
+
+   return 1;
+}
+
+static int
+_fetch(Evry_Plugin *plugin, const char *input)
+{
+   GET_PLUGIN(p, plugin);
+   Eina_List *l;
+   Efreet_Desktop *desktop;
+   Evry_Item *it;
+   /* char *file; */
+
+   EVRY_PLUGIN_ITEMS_CLEAR(p);
+
+   if (input && !(p->apps_all))
      {
-       if (!p->apps_all)
-         {
-            Eina_List *apps = NULL;
-            Eina_List *cat_ss;
-            Eina_List *l, *ll;
+       Eina_List *apps = NULL;
+       Eina_List *cat_ss;
+       Eina_List *l, *ll;
 
-            apps = efreet_util_desktop_name_glob_list("*");
+       apps = efreet_util_desktop_name_glob_list("*");
 
-            /* remove screensaver */
-            cat_ss = efreet_util_desktop_category_list("Screensaver");
-            EINA_LIST_FOREACH(cat_ss, l, desktop)
+       /* remove screensaver */
+       cat_ss = efreet_util_desktop_category_list("Screensaver");
+       EINA_LIST_FOREACH(cat_ss, l, desktop)
+         {
+            if ((ll = eina_list_data_find_list(apps, desktop)))
               {
-                 if ((ll = eina_list_data_find_list(apps, desktop)))
-                   {
-                      efreet_desktop_free(desktop);
-                      apps = eina_list_remove_list(apps, ll);
-                   }
                  efreet_desktop_free(desktop);
+                 apps = eina_list_remove_list(apps, ll);
               }
-
-            p->apps_all = apps;
+            efreet_desktop_free(desktop);
          }
 
-       _add_desktop_list(p, p->apps_all, input);
+       p->apps_all = apps;
      }
+
+   /* .desktop files */
+   _add_desktop_list(p, p->apps_all, input);
+
+   /* add executables */
+   _add_executables(p, input);
+
+   /* FIXME update last used from exehist */
+   /* EINA_LIST_FOREACH(e_exehist_list_get(), l, file)
+    *   {
+    *  double last_used = e_exehist_newest_run_get(file);
+    *  History_Item *hi;
+    *  it = (Evry_Item *)_item_add(p, NULL, file, 1);
+    *  if (!eina_hash_find(evry_hist->subjects, it->id))
+    *    {
+    *       hi = evry_history_add(evry_hist->subjects, it, NULL, NULL);
+    *       if (hi) hi->last_used = last_used;
+    *    }
+    *   } */
+
    /* add exe history items */
-   else if (!plugin->items)
+   if (!plugin->items)
      {
        if (!p->apps_hist)
          eina_hash_foreach(evry_hist->subjects, _hist_items_add_cb, p);
        else
          _add_desktop_list(p, p->apps_hist, NULL);
      }
-   
-   /* add executables */
-   _add_executables(p, input);
-
-   if (plugin == plug_action)
-     {
-       EINA_LIST_FOREACH(plugin->items, l, it)
-         evry_history_item_usage_set(evry_hist->actions, it, input, NULL); 
-     }
    else
      {
        EINA_LIST_FOREACH(plugin->items, l, it)
          evry_history_item_usage_set(evry_hist->subjects, it, input, NULL);
-     }
 
-   if (!input && plugin != plug_action)
-     {
-       EINA_LIST_FOREACH(e_exehist_list_get(), l, file)
-         {
-            double last_used = e_exehist_newest_run_get(file);
-            History_Item *hi;
-            it = (Evry_Item *)_item_add(p, NULL, file, 1);
-            if (!eina_hash_find(evry_hist->subjects, it->id))
-              {
-                 hi = evry_history_add(evry_hist->subjects, it, NULL, NULL);
-                 if (hi) hi->last_used = last_used;
-              }
-         }
+       EVRY_PLUGIN_ITEMS_SORT(plugin, _cb_sort);
      }
    
-   if (plugin != plug_action || input)
-     EVRY_PLUGIN_ITEMS_SORT(plugin, _cb_sort);
-   
    return 1;
 }
 
@@ -767,6 +746,12 @@ _exec_app_action(Evry_Action *act)
 }
 
 static int
+_exec_file_action(Evry_Action *act)
+{
+   return evry_util_exec_app(act->it2.item, act->it1.item);
+}
+
+static int
 _exec_term_action(Evry_Action *act)
 {
    GET_APP(app, act->it1.item);
@@ -949,9 +934,16 @@ _plugins_init(void)
    p->config_path = "extensions/everything-apps";
    evry_plugin_register(p, EVRY_PLUGIN_SUBJECT, 1);
    plug_apps = p;
+
+   p = EVRY_PLUGIN_NEW(Plugin, N_("Applications"), NULL, EVRY_TYPE_APP,
+                      _begin, _finish, _fetch, NULL);
+   p->complete = &_complete;
+   p->config_path = "extensions/everything-apps";
+   evry_plugin_register(p, EVRY_PLUGIN_OBJECT, 1);
+   plug_apps2 = p;
    
    p = EVRY_PLUGIN_NEW(Plugin, N_("Open With..."), NULL, EVRY_TYPE_APP,
-                      _begin_open_with, _finish, _fetch, NULL);
+                      _begin_open_with, _finish_mime, _fetch_mime, NULL);
 
    p->config_path = "extensions/everything-apps";
    evry_plugin_register(p, EVRY_PLUGIN_ACTION, 1);
@@ -997,6 +989,13 @@ _plugins_init(void)
                         "system-run",
                         _exec_sudo_action, NULL);
    _actions = eina_list_append(_actions, act);
+
+   act = EVRY_ACTION_NEW(N_("Open with..."),
+                        EVRY_TYPE_FILE, EVRY_TYPE_APP,
+                        "everything-launch",
+                        _exec_file_action, NULL);
+   _act_open_with = EVRY_ITEM(act);
+   _actions = eina_list_append(_actions, act);
    
    EINA_LIST_FOREACH(_actions, l, act)
      evry_action_register(act,  prio++);
@@ -1010,6 +1009,7 @@ _plugins_shutdown(void)
    Evry_Action *act;
    
    EVRY_PLUGIN_FREE(plug_apps);
+   EVRY_PLUGIN_FREE(plug_apps2);
    EVRY_PLUGIN_FREE(plug_action);
 
    EINA_LIST_FREE(_actions, act)
@@ -1236,7 +1236,6 @@ e_modapi_save(E_Module *m)
    return 1;
 }
 
-/**/
 /***************************************************************************/
 
 
@@ -1355,3 +1354,45 @@ _scan_idler(void *data)
    /* we have mroe scannign to do */
    return 1;
 }
+
+static void
+_scan_executables()
+{
+   /* taken from exebuf module */
+   char *path, *pp, *last;
+   E_Exe_List *el;
+
+   el = e_config_domain_load("exebuf_exelist_cache", exelist_edd);
+   if (el)
+     {
+       E_Exe *ee;
+
+       EINA_LIST_FREE(el->list, ee)
+         {
+            exe_list = eina_list_append(exe_list, strdup(ee->path));
+            eina_stringshare_del(ee->path);
+            free(ee);
+         }
+       free(el);
+     }
+   path = getenv("PATH");
+   if (path)
+     {
+       path = strdup(path);
+       last = path;
+       for (pp = path; pp[0]; pp++)
+         {
+            if (pp[0] == ':') pp[0] = '\0';
+            if (pp[0] == 0)
+              {
+                 exe_path = eina_list_append(exe_path, strdup(last));
+                 last = pp + 1;
+              }
+         }
+       if (pp > last)
+         exe_path = eina_list_append(exe_path, strdup(last));
+       free(path);
+     }
+
+   exe_scan_idler = ecore_idler_add(_scan_idler, NULL);
+}
index 3119ac5..693c13e 100644 (file)
 #define CMD_SHOW_HIDDEN 2
 #define CMD_SHOW_PARENT 3
 
+#define ACT_TRASH      1
+#define ACT_DELETE     2
+#define ACT_COPY       3
+#define ACT_MOVE       4
+
 typedef struct _Plugin Plugin;
 typedef struct _Data Data;
 typedef struct _Module_Config Module_Config;
@@ -121,6 +126,7 @@ static void
 _item_free(Evry_Item *it)
 {
    GET_FILE(file, it);
+   if (file->url) eina_stringshare_del(file->url);
    if (file->path) eina_stringshare_del(file->path);
    if (file->mime) eina_stringshare_del(file->mime);
 
@@ -443,7 +449,8 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
      {
        GET_FILE(file, it);
 
-       if (!file->path || !ecore_file_is_dir(file->path))
+       if (!evry_file_path_get(file) ||
+           !ecore_file_is_dir(file->path))
          return NULL;
 
        p = E_NEW(Plugin, 1);
@@ -551,17 +558,34 @@ _hist_func(void *data)
 
    EINA_LIST_FOREACH_SAFE(p->hist_added, l, ll, file)
      {
+       if (!evry_file_path_get(file))
+         {
+            p->hist_added = eina_list_remove_list(p->hist_added, l);
+            continue;
+         }
+       
        if (!ecore_file_exists(file->path))
-         p->hist_added = eina_list_remove_list(p->hist_added, l);
-
+         {
+            p->hist_added = eina_list_remove_list(p->hist_added, l);
+            continue;
+         }
+       
        if (!file->mime)
          {
             file->mime = eina_stringshare_add(efreet_mime_type_get(file->path));
-
-            if ((!strcmp(file->mime, "inode/directory")) ||
-                (!strcmp(file->mime, "inode/mount-point")))
-              EVRY_ITEM(file)->browseable = EINA_TRUE;
          }
+       
+       if (!file->mime)
+         {
+            p->hist_added = eina_list_remove_list(p->hist_added, l);
+            continue;
+         }
+            
+       if ((!strcmp(file->mime, "inode/directory")) ||
+           (!strcmp(file->mime, "inode/mount-point")))
+         EVRY_ITEM(file)->browseable = EINA_TRUE;
+
+       evry_util_file_detail_set(file);
      }
 }
 
@@ -642,14 +666,12 @@ _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fda
 
        EVRY_ITEM(file)->id = eina_stringshare_ref(file->path);
 
-       evry_util_file_detail_set(file);
-
-       if (file->mime)
-         {
-            if ((!strcmp(file->mime, "inode/directory")) ||
-                (!strcmp(file->mime, "inode/mount-point")))
-              EVRY_ITEM(file)->browseable = EINA_TRUE;
-         }
+       /* if (file->mime)
+        *   {
+        *      if ((!strcmp(file->mime, "inode/directory")) ||
+        *       (!strcmp(file->mime, "inode/mount-point")))
+        *        EVRY_ITEM(file)->browseable = EINA_TRUE;
+        *   } */
 
        p->hist_added = eina_list_append(p->hist_added, file);
        break;
@@ -835,11 +857,6 @@ _fetch(Evry_Plugin *plugin, const char *input)
    return 1;
 }
 
-#define ACT_TRASH      1
-#define ACT_DELETE     2
-#define ACT_COPY       3
-#define ACT_MOVE       4
-
 static int
 _open_folder_check(Evry_Action *act __UNUSED__, const Evry_Item *it)
 {
@@ -849,22 +866,26 @@ _open_folder_check(Evry_Action *act __UNUSED__, const Evry_Item *it)
 static int
 _open_folder_action(Evry_Action *act)
 {
-   E_Action *action = e_action_find("fileman");
-   char *path;
+   E_Action *action;
    Eina_List *m;
-
-   if (!action) return 0;
-
-   m = e_manager_list();
+   char *dir;
+   
+   if (!(action = e_action_find("fileman")))
+     return 0;
 
    GET_FILE(file, act->it1.item);
+   
+   if (!(evry_file_path_get(file)))
+     return 0;
+   
+   m = e_manager_list();
 
-   if (!act->it1.item->browseable)
+   if (!IS_BROWSEABLE(file))
      {
-       path = ecore_file_dir_get(file->path);
-       if (!path) return 0;
-       action->func.go(E_OBJECT(m->data), path);
-       free(path);
+       dir = ecore_file_dir_get(file->path);
+       if (!dir) return 0;
+       action->func.go(E_OBJECT(m->data), dir);
+       free(dir);
      }
    else
      {
@@ -882,8 +903,11 @@ _open_term_action(Evry_Action *act)
    char cwd[4096];
    char *dir;
    int ret = 0;
+   
+   if (!(evry_file_path_get(file)))
+     return 0;
 
-   if (act->it1.item->browseable)
+   if (IS_BROWSEABLE(file))
      dir = strdup(file->path);
    else
      dir = ecore_file_dir_get(file->path);
@@ -912,75 +936,65 @@ _open_term_action(Evry_Action *act)
 static int
 _file_trash_action(Evry_Action *act)
 {
-   Efreet_Uri *uri;
+   Efreet_Uri *euri;
    int ok = 0;
-   char buf[PATH_MAX];
    int force = (EVRY_ITEM_DATA_INT_GET(act) == ACT_DELETE);
-
+   
    GET_FILE(file, act->it1.item);
 
-   if (!file->url)
-     {
-       /* efreet_uri_decode could be a litle less picky imo */
-       snprintf(buf, sizeof(buf), "file://%s", file->path);
-       uri = efreet_uri_decode(buf);
-
-       printf("delete %s %p\n", buf, uri);
-     }
-   else
-     {
-       uri = efreet_uri_decode(file->url);
-     }
-
+   if (!(evry_file_uri_get(file)))
+     return 0;
 
-   if (uri)
+   euri = efreet_uri_decode(file->url);
+   
+   if (euri)
      {
-       ok = efreet_trash_delete_uri(uri, force);
-       efreet_uri_free(uri);
-
+       ok = efreet_trash_delete_uri(euri, force);
+       efreet_uri_free(euri);
      }
 
-   return ok;
+   return (ok > 0);
 }
 
 static int
 _file_copy_action(Evry_Action *act)
 {
-   GET_FILE(file, act->it1.item);
+   GET_FILE(src, act->it1.item);
    GET_FILE(dst, act->it2.item);
 
-   char *path;
    char buf[PATH_MAX];
-   int ret;
+   char *ddst;
+
+   if (!(evry_file_path_get(src)))
+     return 0;
 
+   if (!(evry_file_path_get(dst)))
+     return 0;
+   
    if (!ecore_file_is_dir(dst->path))
-     path = ecore_file_dir_get(dst->path);
+     ddst = ecore_file_dir_get(dst->path);
    else
-     path = strdup(dst->path);
-
-   if (!path) return 0;
-
-   snprintf(buf, sizeof(buf), "%s/%s", path, act->it1.item->label);
-   free(path);
+     ddst = strdup(dst->path);
+   if (!ddst)
+     return 0;
+   
+   snprintf(buf, sizeof(buf), "%s/%s", ddst, ecore_file_file_get(src->path));
+   free(ddst);
 
+   DBG(" %s -> %s\n", src->path, buf);
+   
    if (EVRY_ITEM_DATA_INT_GET(act) == ACT_COPY)
      {
-       ret = ecore_file_cp(file->path, buf);
+       return ecore_file_cp(src->path, buf);
      }
    else if (EVRY_ITEM_DATA_INT_GET(act) == ACT_MOVE)
      {
-       ret = ecore_file_mv(file->path, buf);
+       return ecore_file_mv(src->path, buf);
      }
 
-   return ret;
+   return 0;
 }
 
-/* static int
- * _complete(Evry_Plugin *p, const Evry_Item *item, char **input)
- * {
- *    return 0;
- * } */
-
 static Eina_Bool
 _plugins_init(void)
 {
@@ -989,45 +1003,62 @@ _plugins_init(void)
    if (!evry_api_version_check(EVRY_API_VERSION))
      return EINA_FALSE;
 
-   p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Files"), NULL, EVRY_TYPE_FILE, _begin, _cleanup, _fetch, NULL);
+   p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Files"), NULL,
+                       EVRY_TYPE_FILE,
+                       _begin, _cleanup, _fetch, NULL);
    p1->config_path = "extensions/everything-files";
    evry_plugin_register(p1, EVRY_PLUGIN_SUBJECT, 3);
    /* p1->complete = &_complete; */
 
-   p2 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Files"), NULL, EVRY_TYPE_FILE, _begin, _cleanup, _fetch, NULL);
+   p2 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Files"), NULL,
+                       EVRY_TYPE_FILE,
+                       _begin, _cleanup, _fetch, NULL);
    p2->config_path = "extensions/everything-files";
    evry_plugin_register(p2, EVRY_PLUGIN_OBJECT, 1);
 
-   act = EVRY_ACTION_NEW(N_("Open Folder (EFM)"), EVRY_TYPE_FILE, 0, "folder-open",
-                         _open_folder_action, _open_folder_check);
+   act = EVRY_ACTION_NEW(N_("Open Folder (EFM)"),
+                        EVRY_TYPE_FILE, 0,
+                        "folder-open",
+                         _open_folder_action,
+                        _open_folder_check);
    evry_action_register(act, 0);
    _actions = eina_list_append(_actions, act);
 
-   act = EVRY_ACTION_NEW(N_("Open Terminal here"), EVRY_TYPE_FILE, 0, "system-run",
+   act = EVRY_ACTION_NEW(N_("Open Terminal here"),
+                        EVRY_TYPE_FILE, 0,
+                        "system-run",
                          _open_term_action, NULL);
    evry_action_register(act, 2);
    _actions = eina_list_append(_actions, act);
 
-   act = EVRY_ACTION_NEW(N_("Move to Trash"), EVRY_TYPE_FILE, 0, "edit-delete",
+   act = EVRY_ACTION_NEW(N_("Move to Trash"),
+                        EVRY_TYPE_FILE, 0,
+                        "edit-delete",
                          _file_trash_action, NULL);
    EVRY_ITEM_DATA_INT_SET(act, ACT_TRASH);
    evry_action_register(act, 2);
    _actions = eina_list_append(_actions, act);
 
-   act = EVRY_ACTION_NEW(N_("Delete"), EVRY_TYPE_FILE, 0, "list-remove",
+   act = EVRY_ACTION_NEW(N_("Delete"),
+                        EVRY_TYPE_FILE, 0,
+                        "list-remove",
                         _file_trash_action, NULL);
    EVRY_ITEM_DATA_INT_SET(act, ACT_DELETE);
    evry_action_register(act, 2);
 
    _actions = eina_list_append(_actions, act);
 
-   act = EVRY_ACTION_NEW(N_("Copy To ..."), EVRY_TYPE_FILE, EVRY_TYPE_FILE, "go-next",
+   act = EVRY_ACTION_NEW(N_("Copy To ..."),
+                        EVRY_TYPE_FILE, EVRY_TYPE_FILE,
+                        "go-next",
                         _file_copy_action, NULL);
    EVRY_ITEM_DATA_INT_SET(act, ACT_COPY);
    evry_action_register(act, 2);
    _actions = eina_list_append(_actions, act);
 
-   act = EVRY_ACTION_NEW(N_("Move To ..."), EVRY_TYPE_FILE, EVRY_TYPE_FILE, "go-next",
+   act = EVRY_ACTION_NEW(N_("Move To ..."),
+                        EVRY_TYPE_FILE, EVRY_TYPE_FILE,
+                        "go-next",
                         _file_copy_action, NULL);
    EVRY_ITEM_DATA_INT_SET(act, ACT_MOVE);
    evry_action_register(act, 2);
index 3559cdc..627c286 100644 (file)
@@ -41,6 +41,9 @@ _action(Evry_Action *act)
 
    GET_FILE(file, act->it1.item);
 
+   if (!(evry_file_path_get(file)))
+     return 0;
+   
    if (import)
      {
        if (import->exe_handler)
index e92b0b8..f8cf8e3 100644 (file)
@@ -58,7 +58,7 @@ typedef struct _Plugin_Config         Plugin_Config;
 typedef struct _Plugin_Setting         Plugin_Setting;
 typedef struct _Evry_Event_Item_Changed Evry_Event_Item_Changed;
 
-typedef int Evry_Type;
+typedef unsigned int Evry_Type;
 
 #define EVRY_ITEM(_item) ((Evry_Item *)_item)
 #define EVRY_ACTN(_item) ((Evry_Action *) _item)
@@ -72,6 +72,9 @@ typedef int Evry_Type;
 #define CHECK_SUBTYPE(_item, _type) \
   (((Evry_Item *)_item)->subtype && ((Evry_Item *)_item)->subtype == _type)
 
+#define IS_BROWSEABLE(_item) \
+  ((Evry_Item *)_item)->browseable
+
 #define GET_APP(_app, _item) Evry_Item_App *_app = (Evry_Item_App *) _item
 #define GET_FILE(_file, _item) Evry_Item_File *_file = (Evry_Item_File *) _item
 #define GET_EVRY_PLUGIN(_p, _plugin) Evry_Plugin *_p = (Evry_Plugin*) _plugin
@@ -439,7 +442,8 @@ EAPI char *evry_util_unescape(const char *string, int length);
 EAPI void evry_util_file_detail_set(Evry_Item_File *file);
 EAPI Eina_Bool evry_util_module_config_check(const char *module_name, int conf, int epoch, int version);
 EAPI Evas_Object *evry_util_icon_get(Evry_Item *it, Evas *e);
-EAPI const char *evry_file_path_get(Evry_Item *it);
+EAPI const char *evry_file_path_get(Evry_Item_File *file);
+EAPI const char *evry_file_uri_get(Evry_Item_File *file);
 
 /* e_mod_main.c */
 /* set plugin trigger and view mode first before register !*/
index a874302..95e7b95 100644 (file)
@@ -890,7 +890,7 @@ static int
 _evry_selector_thumb(Evry_Selector *sel, const Evry_Item *it)
 {
    Evas_Coord w, h;
-
+   
    if (sel->do_thumb)
      e_thumb_icon_end(sel->o_thumb);
 
@@ -902,7 +902,11 @@ _evry_selector_thumb(Evry_Selector *sel, const Evry_Item *it)
 
    GET_FILE(file, it);
 
-   if (!file->path || !file->mime) return 0;
+   if (!file->mime)
+     return 0;
+   
+   if (!(evry_file_path_get(file)))
+     return 0;
 
    if (!strncmp(file->mime, "image/", 6))
      {
@@ -1116,16 +1120,18 @@ _evry_selector_objects_get(Evry_Action *act)
    while (sel->state)
      _evry_state_pop(sel);
 
-   it = selectors[0]->state->cur_item;
+   it = selectors[1]->state->cur_item;
 
    EINA_LIST_FOREACH(sel->plugins, l, p)
      {
+       DBG("p %s %d %d\n", p->name, EVRY_ITEM(p)->subtype, act->it2.type);
+
        if (!CHECK_SUBTYPE(p, act->it2.type))
          continue;
 
        if (p->begin)
          {
-            if ((pp = p->begin(p, it)) || (pp = p->begin(p, NULL)))
+            if ((pp = p->begin(p, it)))
               plugins = eina_list_append(plugins, pp);
          }
        else
index 6b00a08..4374bec 100644 (file)
@@ -70,6 +70,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
 
             if (!eina_list_data_find_list(p->actions, act))
               {
+                 act->it1.item = it;
                  p->actions = eina_list_append(p->actions, act);
               }
             continue;
@@ -87,7 +88,22 @@ _cb_sort(const void *data1, const void *data2)
 {
    const Evry_Item *it1 = data1;
    const Evry_Item *it2 = data2;
+   const Evry_Action *act1 = data1;
+   const Evry_Action *act2 = data2;
 
+   if (act1->it1.item && act2->it1.item)
+     {
+       if ((act1->it1.type == act1->it1.item->type) &&
+           (act2->it1.type != act2->it1.item->type))
+         return -1;
+
+       if ((act1->it1.type != act1->it1.item->type) &&
+           (act2->it1.type == act2->it1.item->type))
+         return 1;
+     }
+   
+   if (it1->fuzzy_match || it2->fuzzy_match)
+   
    if (it1->fuzzy_match || it2->fuzzy_match)
      {
        if (it1->fuzzy_match && !it2->fuzzy_match)
index debcc99..c9e2fff 100644 (file)
@@ -107,7 +107,7 @@ _check_item(const Evry_Item *it)
 
    GET_FILE(file, it);
 
-   if (!file->path || !file->mime) return 0;
+   if (!evry_file_path_get(file) || !file->mime) return 0;
 
    if (!strncmp(file->mime, "image/", 6))
      return 1;
@@ -588,8 +588,8 @@ _pan_item_add(Evas_Object *obj, Evry_Item *item)
    it->item = item;
    it->changed = EINA_TRUE;
 
-   if (_check_item(item))
-     it->get_thumb = EINA_TRUE;
+   /* if (_check_item(item))
+    *   it->get_thumb = EINA_TRUE; */
 
    evry_item_ref(item);
 
@@ -1042,8 +1042,8 @@ _view_update(Evry_View *view, int slide)
          {
             v_items = eina_list_append(v_items, v_it->item);
 
-            if (_check_item(v_it->item))
-              v_it->get_thumb = EINA_TRUE;
+            /* if (_check_item(v_it->item))
+             *   v_it->get_thumb = EINA_TRUE; */
 
             if (v_it->visible && v_it->changed)
               update = EINA_TRUE;
index a9245f1..b30700e 100644 (file)
@@ -401,26 +401,30 @@ evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file)
    
    if (!it_app) return 0;
    GET_APP(app, it_app);
-
+   GET_FILE(file, it_file);
+   
    zone = e_util_zone_current_get(e_manager_current_get());
 
    if (app->desktop)
      {
-       if (it_file)
+       if (file && evry_file_path_get(file))
          {
-            GET_FILE(file, it_file);
-
             Eina_List *l;
             char *mime;
             int open_folder = 0;
 
-            if (!EVRY_ITEM(file)->browseable)
+            /* when the file is no a directory and the app
+               opens folders, pass only the dir */
+            if (!IS_BROWSEABLE(file))
               {
                  EINA_LIST_FOREACH(app->desktop->mime_types, l, mime)
                    {
                       if (!strcmp(mime, "x-directory/normal"))
+                        open_folder = 1;
+
+                      if (file->mime && !strcmp(mime, file->mime))
                         {
-                           open_folder = 1;
+                           open_folder = 0;
                            break;
                         }
                    }
@@ -459,10 +463,8 @@ evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file)
      }
    else if (app->file)
      {
-       if (it_file)
+       if (file && evry_file_path_get(file))
          {
-            GET_FILE(file, it_file);
-
             int len;
             tmp = eina_str_escape(file->path);
             len = strlen(app->file) + strlen(tmp) + 2;
@@ -611,6 +613,8 @@ _isalnum(unsigned char in)
   }
   return EINA_FALSE;
 }
+
+/* FIXME option to not escape '/' */
 EAPI char *
 evry_util_url_escape(const char *string, int inlength)
 {
@@ -660,25 +664,47 @@ evry_util_url_escape(const char *string, int inlength)
 }
 
 EAPI const char*
-evry_file_path_get(Evry_Item *it)
+evry_file_path_get(Evry_Item_File *file)
 {
    const char *tmp;
    char *path;
    
-   GET_FILE(file, it);
-
    if (file->path)
      return file->path;
-   
+
+   if (!file->url)
+     return NULL;
+
    if (!strncmp(file->url, "file://", 7))
      tmp = file->url + 7;
    else return NULL;
    
    if (!(path = evry_util_unescape(tmp, 0)))
      return NULL;
+   
    file->path = eina_stringshare_add(path);
 
    E_FREE(path);
    
    return file->path;
 }
+
+EAPI const char*
+evry_file_uri_get(Evry_Item_File *file)
+{
+   char buf[PATH_MAX];
+   
+   if (file->url)
+     return file->url;
+
+   if (!file->path)
+     return NULL;
+   
+   snprintf(buf, sizeof(buf), "file://%s", file->path);
+
+   /* FIXME escape ? */
+   
+   file->url = eina_stringshare_add(buf);
+
+   return file->url;
+}