2009-09-17 23:33:33 -07:00
|
|
|
#include "e_mod_main.h"
|
2009-08-13 08:10:54 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
#define MAX_ITEMS 100
|
2009-09-17 23:33:33 -07:00
|
|
|
#define TERM_ACTION_DIR "%s"
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
typedef struct _Plugin Plugin;
|
2009-08-27 15:58:34 -07:00
|
|
|
typedef struct _Data Data;
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
struct _Plugin
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-21 15:42:06 -07:00
|
|
|
Evry_Plugin base;
|
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
const char *directory;
|
2009-08-10 04:36:37 -07:00
|
|
|
/* all files of directory */
|
2009-08-22 20:12:05 -07:00
|
|
|
Eina_List *files;
|
2009-08-10 04:36:37 -07:00
|
|
|
/* current list of files */
|
|
|
|
Eina_List *cur;
|
2009-08-11 06:31:38 -07:00
|
|
|
Eina_Bool command;
|
2009-08-27 15:58:34 -07:00
|
|
|
|
|
|
|
const char *input;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Data
|
|
|
|
{
|
|
|
|
Plugin *plugin;
|
|
|
|
long id;
|
|
|
|
int level;
|
|
|
|
int cnt;
|
|
|
|
Eina_List *files;
|
2009-06-21 03:31:38 -07:00
|
|
|
};
|
|
|
|
|
2009-08-27 19:25:13 -07:00
|
|
|
static Evry_Plugin *p1 = NULL;
|
|
|
|
static Evry_Plugin *p2 = NULL;
|
|
|
|
static Evry_Action *act1 = NULL;
|
|
|
|
static Evry_Action *act2 = NULL;
|
2009-08-21 15:42:06 -07:00
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
static long thread_cnt = 0;
|
|
|
|
static long thread_last = 0;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
static const char *mime_folder;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-08-11 06:31:38 -07:00
|
|
|
static void
|
2009-08-22 20:12:05 -07:00
|
|
|
_item_fill(Evry_Item_File *file)
|
2009-08-11 06:31:38 -07:00
|
|
|
{
|
2009-08-17 18:00:18 -07:00
|
|
|
const char *mime;
|
2009-08-18 07:29:30 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
if (file->mime) return;
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
if ((mime = efreet_mime_type_get(file->uri)))
|
2009-08-11 06:31:38 -07:00
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
file->mime = eina_stringshare_add(mime);
|
2009-09-03 07:21:27 -07:00
|
|
|
EVRY_ITEM(file)->context = eina_stringshare_ref(file->mime);
|
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
if ((!strcmp(mime, "inode/directory")) ||
|
|
|
|
(!strcmp(mime, "inode/mount-point")))
|
|
|
|
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
|
|
|
|
2009-08-17 20:15:36 -07:00
|
|
|
return;
|
2009-08-11 06:31:38 -07:00
|
|
|
}
|
2009-08-17 20:15:36 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
file->mime = eina_stringshare_add("None");
|
2009-06-21 03:31:38 -07:00
|
|
|
}
|
|
|
|
|
2009-08-11 06:31:38 -07:00
|
|
|
static int
|
|
|
|
_cb_sort(const void *data1, const void *data2)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-14 07:44:18 -07:00
|
|
|
const Evry_Item *it1 = data1;
|
|
|
|
const Evry_Item *it2 = data2;
|
2009-08-11 06:31:38 -07:00
|
|
|
|
2009-08-14 07:44:18 -07:00
|
|
|
if (it1->browseable && !it2->browseable)
|
|
|
|
return -1;
|
2009-08-11 06:31:38 -07:00
|
|
|
|
2009-08-14 07:44:18 -07:00
|
|
|
if (!it1->browseable && it2->browseable)
|
|
|
|
return 1;
|
|
|
|
|
2009-08-25 20:12:00 -07:00
|
|
|
if (it1->fuzzy_match && it2->fuzzy_match)
|
|
|
|
if (it1->fuzzy_match - it2->fuzzy_match)
|
|
|
|
return (it1->fuzzy_match - it2->fuzzy_match);
|
2009-08-14 07:44:18 -07:00
|
|
|
|
|
|
|
return strcasecmp(it1->label, it2->label);
|
2009-08-11 06:31:38 -07:00
|
|
|
}
|
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
static void
|
|
|
|
_item_free(Evry_Item *it)
|
|
|
|
{
|
|
|
|
ITEM_FILE(file, it);
|
|
|
|
if (file->uri) eina_stringshare_del(file->uri);
|
|
|
|
if (file->mime) eina_stringshare_del(file->mime);
|
|
|
|
|
|
|
|
E_FREE(file);
|
|
|
|
}
|
|
|
|
|
2009-08-12 12:14:45 -07:00
|
|
|
static void
|
2009-08-27 15:58:34 -07:00
|
|
|
_scan_func(void *data)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-27 15:58:34 -07:00
|
|
|
Data *d = data;
|
|
|
|
Plugin *p = d->plugin;
|
2009-08-10 04:36:37 -07:00
|
|
|
Eina_List *files;
|
2009-08-27 15:58:34 -07:00
|
|
|
char *filename;
|
2009-08-22 20:12:05 -07:00
|
|
|
Evry_Item_File *file;
|
2009-08-27 15:58:34 -07:00
|
|
|
char buf[4096];
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
files = ecore_file_ls(p->directory);
|
2009-08-12 05:17:43 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
EINA_LIST_FREE(files, filename)
|
2009-07-10 08:47:19 -07:00
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
if (filename[0] == '.')
|
2009-08-12 05:17:43 -07:00
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
free(filename);
|
2009-08-12 05:17:43 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
file = E_NEW(Evry_Item_File, 1);
|
2009-08-27 15:58:34 -07:00
|
|
|
if (!file)
|
|
|
|
{
|
|
|
|
free(filename);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), NULL, _item_free);
|
2009-08-22 20:12:05 -07:00
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
EVRY_ITEM(file)->data = filename;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", p->directory, filename);
|
2009-08-27 15:58:34 -07:00
|
|
|
file->uri = strdup(buf);
|
2009-08-30 06:35:06 -07:00
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
if (ecore_file_is_dir(file->uri))
|
|
|
|
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
|
|
|
|
|
|
|
d->files = eina_list_append(d->files, file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_append_file(Plugin *p, Evry_Item_File *file)
|
|
|
|
{
|
|
|
|
int match;
|
|
|
|
|
|
|
|
if (p->input && (match = evry_fuzzy_match(EVRY_ITEM(file)->label, p->input)))
|
|
|
|
{
|
|
|
|
EVRY_ITEM(file)->fuzzy_match = match;
|
|
|
|
EVRY_PLUGIN_ITEM_APPEND(p, file);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (!p->input)
|
|
|
|
{
|
|
|
|
EVRY_PLUGIN_ITEM_APPEND(p, file);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-30 06:35:06 -07:00
|
|
|
static const char *
|
|
|
|
_item_id(const char *uri)
|
|
|
|
{
|
|
|
|
const char *s1, *s2, *s3;
|
|
|
|
s1 = s2 = s3 = uri;
|
|
|
|
|
|
|
|
while (s1 && ++s1 && (s1 = strchr(s1, '/')))
|
|
|
|
{
|
|
|
|
s3 = s2;
|
|
|
|
s2 = s1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return s3;
|
|
|
|
}
|
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
static void
|
|
|
|
_scan_end_func(void *data)
|
|
|
|
{
|
|
|
|
Data *d = data;
|
|
|
|
Plugin *p = d->plugin;
|
|
|
|
int cnt = 0;
|
|
|
|
Evry_Item *item;
|
|
|
|
char *filename, *uri;
|
|
|
|
|
|
|
|
if (d->id != thread_last)
|
|
|
|
{
|
|
|
|
EINA_LIST_FREE(d->files, item)
|
|
|
|
{
|
|
|
|
filename = item->data;
|
|
|
|
free(filename);
|
|
|
|
evry_item_free(item);
|
|
|
|
}
|
|
|
|
E_FREE(d);
|
|
|
|
return;
|
|
|
|
}
|
2009-08-12 05:17:43 -07:00
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
EINA_LIST_FREE(d->files, item)
|
|
|
|
{
|
|
|
|
ITEM_FILE(file, item);
|
2009-08-22 20:12:05 -07:00
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
filename = item->data;
|
|
|
|
uri = (char *) file->uri;
|
|
|
|
file->uri = eina_stringshare_add(uri);
|
2009-08-30 06:35:06 -07:00
|
|
|
item->id = eina_stringshare_add(_item_id(uri));
|
2009-08-27 15:58:34 -07:00
|
|
|
item->label = eina_stringshare_add(filename);
|
2009-08-22 20:12:05 -07:00
|
|
|
free(filename);
|
2009-08-27 15:58:34 -07:00
|
|
|
free(uri);
|
|
|
|
|
|
|
|
p->files = eina_list_append(p->files, file);
|
|
|
|
|
|
|
|
if (item->browseable)
|
2009-09-03 07:21:27 -07:00
|
|
|
{
|
|
|
|
file->mime = eina_stringshare_ref(mime_folder);
|
|
|
|
EVRY_ITEM(file)->context = eina_stringshare_ref(file->mime);
|
|
|
|
}
|
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
if (p->command || cnt >= MAX_ITEMS) continue;
|
|
|
|
cnt += _append_file(p, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p->command)
|
|
|
|
{
|
|
|
|
EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
|
|
|
|
evry_plugin_async_update(EVRY_PLUGIN(p), EVRY_ASYNC_UPDATE_ADD);
|
2009-07-10 08:47:19 -07:00
|
|
|
}
|
2009-08-12 05:17:43 -07:00
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
E_FREE(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_read_directory(Plugin *p)
|
|
|
|
{
|
|
|
|
thread_last = ++thread_cnt;
|
|
|
|
|
|
|
|
Data *d = E_NEW(Data, 1);
|
|
|
|
d->plugin = p;
|
|
|
|
d->id = thread_cnt;
|
2009-11-06 17:22:27 -08:00
|
|
|
ecore_thread_run(_scan_func, _scan_end_func, NULL, d);
|
2009-08-12 12:14:45 -07:00
|
|
|
}
|
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
static Evry_Plugin *
|
|
|
|
_begin(Evry_Plugin *plugin, const Evry_Item *it)
|
2009-08-12 12:14:45 -07:00
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
Plugin *p = NULL;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
/* is FILE ? */
|
|
|
|
if (it && (it->plugin->type_out == plugin->type_in))
|
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
ITEM_FILE(file, it);
|
|
|
|
|
|
|
|
if (!file->uri || !ecore_file_is_dir(file->uri))
|
2009-08-21 15:42:06 -07:00
|
|
|
return NULL;
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
p = E_NEW(Plugin, 1);
|
|
|
|
p->base = *plugin;
|
2009-08-22 14:22:38 -07:00
|
|
|
p->base.items = NULL;
|
2009-08-22 20:12:05 -07:00
|
|
|
|
|
|
|
p->directory = eina_stringshare_add(file->uri);
|
2009-08-21 15:42:06 -07:00
|
|
|
}
|
2009-08-22 20:12:05 -07:00
|
|
|
else
|
2009-08-21 15:42:06 -07:00
|
|
|
{
|
|
|
|
p = E_NEW(Plugin, 1);
|
|
|
|
p->base = *plugin;
|
2009-08-22 14:22:38 -07:00
|
|
|
p->base.items = NULL;
|
2009-08-21 15:42:06 -07:00
|
|
|
p->directory = eina_stringshare_add(e_user_homedir_get());
|
|
|
|
}
|
2009-08-22 20:12:05 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
_read_directory(p);
|
2009-08-12 13:26:27 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
return EVRY_PLUGIN(p);
|
2009-06-21 03:31:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-21 15:42:06 -07:00
|
|
|
_cleanup(Evry_Plugin *plugin)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
PLUGIN(p, plugin);
|
|
|
|
|
|
|
|
Evry_Item_File *file;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
/* if a thread for this plugin returns
|
|
|
|
it will free its data if its id is smaller
|
|
|
|
than thread_last */
|
|
|
|
thread_last = ++thread_cnt;
|
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
if (p->directory)
|
|
|
|
eina_stringshare_del(p->directory);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
EINA_LIST_FREE(p->files, file)
|
|
|
|
evry_item_free(EVRY_ITEM(file));
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
E_FREE(p);
|
2009-06-21 03:31:38 -07:00
|
|
|
}
|
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
static void
|
|
|
|
_folder_item_add(Plugin *p, const char *path)
|
|
|
|
{
|
|
|
|
Evry_Item_File *file = E_NEW(Evry_Item_File, 1);
|
|
|
|
|
|
|
|
if (!file) return;
|
|
|
|
|
|
|
|
evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), path, _item_free);
|
|
|
|
file->uri = eina_stringshare_add(path);
|
|
|
|
file->mime = eina_stringshare_ref(mime_folder);
|
|
|
|
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
|
|
|
EVRY_PLUGIN_ITEM_APPEND(p, file);
|
|
|
|
}
|
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
static int
|
2009-08-21 15:42:06 -07:00
|
|
|
_fetch(Evry_Plugin *plugin, const char *input)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
PLUGIN(p, plugin);
|
|
|
|
Evry_Item_File *file;
|
2009-08-10 04:36:37 -07:00
|
|
|
Eina_List *l;
|
|
|
|
int cnt = 0;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
if (!p->command)
|
2009-08-22 20:12:05 -07:00
|
|
|
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
2009-08-12 05:17:43 -07:00
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
p->input = input;
|
|
|
|
|
2009-07-10 07:08:06 -07:00
|
|
|
/* input is command ? */
|
|
|
|
if (input)
|
|
|
|
{
|
2009-08-21 15:42:06 -07:00
|
|
|
if (!strncmp(input, "/", 1))
|
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
if (p->command) return 1;
|
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
_folder_item_add(p, "/");
|
|
|
|
p->command = EINA_TRUE;
|
|
|
|
return 1;
|
2009-08-21 15:42:06 -07:00
|
|
|
}
|
|
|
|
else if (!strncmp(input, "..", 2))
|
|
|
|
{
|
|
|
|
char *end;
|
|
|
|
char dir[4096];
|
|
|
|
char *tmp;
|
|
|
|
int prio = 0;
|
|
|
|
|
|
|
|
if (p->command) return 1;
|
2009-08-28 21:42:17 -07:00
|
|
|
if (strncmp(p->directory, "/", 1)) return 0;
|
2009-08-21 15:42:06 -07:00
|
|
|
if (!strcmp(p->directory, "/")) return 0;
|
2009-08-28 21:42:17 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
snprintf(dir, 4096, "%s", p->directory);
|
|
|
|
end = strrchr(dir, '/');
|
|
|
|
|
|
|
|
while (end != dir)
|
|
|
|
{
|
|
|
|
tmp = strdup(dir);
|
|
|
|
snprintf(dir, (end - dir) + 1, "%s", tmp);
|
2009-08-22 20:12:05 -07:00
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
_folder_item_add(p, dir);
|
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
end = strrchr(dir, '/');
|
|
|
|
free(tmp);
|
|
|
|
prio--;
|
|
|
|
}
|
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
_folder_item_add(p, "/");
|
2009-08-22 20:12:05 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
p->command = EINA_TRUE;
|
|
|
|
return 1;
|
|
|
|
}
|
2009-07-10 07:08:06 -07:00
|
|
|
}
|
2009-08-11 06:31:38 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
if (p->command)
|
2009-08-11 06:31:38 -07:00
|
|
|
{
|
2009-08-21 15:42:06 -07:00
|
|
|
p->command = EINA_FALSE;
|
2009-08-22 20:12:05 -07:00
|
|
|
EVRY_PLUGIN_ITEMS_FREE(p);
|
2009-08-11 06:31:38 -07:00
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
EINA_LIST_FOREACH(p->files, l, file)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-27 15:58:34 -07:00
|
|
|
if (cnt >= MAX_ITEMS);
|
|
|
|
cnt += _append_file(p, file);
|
2009-06-21 03:31:38 -07:00
|
|
|
}
|
2009-06-21 16:25:39 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
if (!EVRY_PLUGIN(p)->items)
|
|
|
|
return 0;
|
2009-08-21 15:42:06 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
|
2009-08-28 21:42:17 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
return 1;
|
2009-06-21 03:31:38 -07:00
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static Evas_Object *
|
2009-08-17 20:15:36 -07:00
|
|
|
_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-12 12:00:25 -07:00
|
|
|
Evas_Object *o = NULL;
|
2009-08-22 20:12:05 -07:00
|
|
|
ITEM_FILE(file, it);
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
if (!file->mime)
|
|
|
|
_item_fill(file);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
if (!file->mime) return NULL;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-11 06:31:38 -07:00
|
|
|
if (it->browseable)
|
2009-08-18 07:29:30 -07:00
|
|
|
o = evry_icon_theme_get("folder", e);
|
2009-06-21 03:31:38 -07:00
|
|
|
else
|
2009-08-22 20:12:05 -07:00
|
|
|
o = evry_icon_mime_get(file->mime, e);
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-08-12 12:00:25 -07:00
|
|
|
return o;
|
2009-06-21 03:31:38 -07:00
|
|
|
}
|
|
|
|
|
2009-08-15 21:08:35 -07:00
|
|
|
|
|
|
|
static int
|
|
|
|
_open_folder_check(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
|
|
|
{
|
2009-08-16 09:26:49 -07:00
|
|
|
return (it->browseable && e_action_find("fileman"));
|
2009-08-15 21:08:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-08-21 18:15:21 -07:00
|
|
|
_open_folder_action(Evry_Action *act)
|
2009-08-15 21:47:43 -07:00
|
|
|
{
|
2009-08-15 21:08:35 -07:00
|
|
|
E_Action *action = e_action_find("fileman");
|
2009-08-15 21:47:43 -07:00
|
|
|
char *path;
|
2009-08-15 21:08:35 -07:00
|
|
|
Eina_List *m;
|
2009-08-15 21:47:43 -07:00
|
|
|
|
2009-08-15 21:08:35 -07:00
|
|
|
if (!action) return 0;
|
|
|
|
|
|
|
|
m = e_manager_list();
|
2009-08-15 21:47:43 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
ITEM_FILE(file, act->item1);
|
|
|
|
|
2009-08-21 18:15:21 -07:00
|
|
|
if (!act->item1->browseable)
|
2009-08-15 21:47:43 -07:00
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
path = ecore_file_dir_get(file->uri);
|
2009-08-15 21:47:43 -07:00
|
|
|
if (!path) return 0;
|
|
|
|
action->func.go(E_OBJECT(m->data), path);
|
|
|
|
free(path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
action->func.go(E_OBJECT(m->data), file->uri);
|
2009-08-15 21:47:43 -07:00
|
|
|
}
|
2009-08-15 21:08:35 -07:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-08-27 19:25:13 -07:00
|
|
|
static int
|
|
|
|
_open_term_action(Evry_Action *act)
|
|
|
|
{
|
|
|
|
ITEM_FILE(file, act->item1);
|
|
|
|
Evry_Item_App *tmp;
|
2009-09-17 23:33:33 -07:00
|
|
|
char cwd[4096];
|
|
|
|
char *dir;
|
2009-08-27 19:25:13 -07:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (act->item1->browseable)
|
2009-09-17 23:33:33 -07:00
|
|
|
dir = strdup(file->uri);
|
2009-08-27 19:25:13 -07:00
|
|
|
else
|
2009-09-17 23:33:33 -07:00
|
|
|
dir = ecore_file_dir_get(file->uri);
|
2009-08-27 19:25:13 -07:00
|
|
|
|
2009-09-17 23:33:33 -07:00
|
|
|
if (dir)
|
2009-08-27 19:25:13 -07:00
|
|
|
{
|
2009-09-17 23:33:33 -07:00
|
|
|
getcwd(cwd, sizeof(cwd));
|
|
|
|
chdir(dir);
|
|
|
|
|
2009-08-27 19:25:13 -07:00
|
|
|
tmp = E_NEW(Evry_Item_App, 1);
|
2009-09-17 23:33:33 -07:00
|
|
|
tmp->file = evry_conf->cmd_terminal;
|
|
|
|
|
2009-08-27 19:25:13 -07:00
|
|
|
ret = evry_util_exec_app(EVRY_ITEM(tmp), NULL);
|
|
|
|
E_FREE(tmp);
|
2009-09-17 23:33:33 -07:00
|
|
|
E_FREE(dir);
|
|
|
|
chdir(cwd);
|
2009-08-27 19:25:13 -07:00
|
|
|
}
|
2009-09-17 23:33:33 -07:00
|
|
|
|
2009-08-27 19:25:13 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-08-11 06:31:38 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_init(void)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-21 15:42:06 -07:00
|
|
|
p1 = evry_plugin_new(NULL, "Files", type_subject, "FILE", "FILE", 0, NULL, NULL,
|
|
|
|
_begin, _cleanup, _fetch, NULL, _icon_get,
|
2009-08-17 20:15:36 -07:00
|
|
|
NULL, NULL);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
p2 = evry_plugin_new(NULL, "Files", type_object, "FILE", "FILE", 0, NULL, NULL,
|
|
|
|
_begin, _cleanup, _fetch, NULL, _icon_get,
|
2009-08-17 20:15:36 -07:00
|
|
|
NULL, NULL);
|
2009-08-30 01:51:15 -07:00
|
|
|
|
2009-08-17 20:15:36 -07:00
|
|
|
evry_plugin_register(p1, 3);
|
2009-08-16 09:26:49 -07:00
|
|
|
evry_plugin_register(p2, 1);
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-08-27 19:25:13 -07:00
|
|
|
act1 = evry_action_new("Open Folder (EFM)", "FILE", NULL, NULL, "folder-open",
|
|
|
|
_open_folder_action, _open_folder_check, NULL, NULL, NULL);
|
|
|
|
evry_action_register(act1, 0);
|
|
|
|
|
|
|
|
act2 = evry_action_new("Open Terminal here", "FILE", NULL, NULL,
|
|
|
|
"system-run",
|
|
|
|
_open_term_action, NULL, NULL, NULL, NULL);
|
|
|
|
evry_action_register(act2, 2);
|
2009-08-18 07:29:30 -07:00
|
|
|
|
2009-08-15 21:47:43 -07:00
|
|
|
|
2009-08-27 19:25:13 -07:00
|
|
|
|
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
mime_folder = eina_stringshare_add("inode/directory");
|
|
|
|
|
2009-08-11 06:31:38 -07:00
|
|
|
return EINA_TRUE;
|
2009-06-21 03:31:38 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-08-11 06:31:38 -07:00
|
|
|
static void
|
|
|
|
_shutdown(void)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
EVRY_PLUGIN_FREE(p1);
|
|
|
|
EVRY_PLUGIN_FREE(p2);
|
2009-08-21 15:42:06 -07:00
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
eina_stringshare_del(mime_folder);
|
|
|
|
|
2009-08-27 19:25:13 -07:00
|
|
|
evry_action_free(act1);
|
|
|
|
evry_action_free(act2);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2009-08-11 06:31:38 -07:00
|
|
|
|
|
|
|
EINA_MODULE_INIT(_init);
|
|
|
|
EINA_MODULE_SHUTDOWN(_shutdown);
|