forked from enlightenment/enlightenment
'everything' faster dirbrowsing: use 'd_type' when available.
- added '.' trigger to show hidden files, '..' to show parent dirs - fixed plugin_autoselect - files: fix warning SVN revision: 48299
This commit is contained in:
parent
3942ec930d
commit
6a44bba411
|
@ -6,9 +6,14 @@
|
||||||
#include "e_mod_main.h"
|
#include "e_mod_main.h"
|
||||||
|
|
||||||
#define MAX_ITEMS 50
|
#define MAX_ITEMS 50
|
||||||
#define MAX_SHOWN 500
|
#define MAX_SHOWN 300
|
||||||
#define TERM_ACTION_DIR "%s"
|
#define TERM_ACTION_DIR "%s"
|
||||||
|
|
||||||
|
#define CMD_NONE 0
|
||||||
|
#define CMD_SHOW_ROOT 1
|
||||||
|
#define CMD_SHOW_HIDDEN 2
|
||||||
|
#define CMD_SHOW_PARENT 3
|
||||||
|
|
||||||
typedef struct _Plugin Plugin;
|
typedef struct _Plugin Plugin;
|
||||||
typedef struct _Data Data;
|
typedef struct _Data Data;
|
||||||
typedef struct _Module_Config Module_Config;
|
typedef struct _Module_Config Module_Config;
|
||||||
|
@ -23,6 +28,7 @@ struct _Plugin
|
||||||
Eina_Bool command;
|
Eina_Bool command;
|
||||||
Eina_Bool parent;
|
Eina_Bool parent;
|
||||||
Eina_List *hist_added;
|
Eina_List *hist_added;
|
||||||
|
Eina_Bool show_hidden;
|
||||||
|
|
||||||
Ecore_Thread *thread;
|
Ecore_Thread *thread;
|
||||||
Eina_Bool cleanup;
|
Eina_Bool cleanup;
|
||||||
|
@ -36,6 +42,9 @@ struct _Data
|
||||||
int cnt;
|
int cnt;
|
||||||
Eina_List *files;
|
Eina_List *files;
|
||||||
Eina_List *list;
|
Eina_List *list;
|
||||||
|
DIR *dirp;
|
||||||
|
Eina_Bool finished;
|
||||||
|
Eina_Bool scan_files;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Module_Config
|
struct _Module_Config
|
||||||
|
@ -65,6 +74,8 @@ static E_Module *module = NULL;
|
||||||
|
|
||||||
static void _cleanup(Evry_Plugin *plugin);
|
static void _cleanup(Evry_Plugin *plugin);
|
||||||
|
|
||||||
|
static const char *_mime_dir;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_item_fill(Evry_Item_File *file)
|
_item_fill(Evry_Item_File *file)
|
||||||
|
@ -124,53 +135,84 @@ _scan_func(void *data)
|
||||||
Plugin *p = d->plugin;
|
Plugin *p = d->plugin;
|
||||||
char *filename;
|
char *filename;
|
||||||
const char *mime;
|
const char *mime;
|
||||||
|
struct dirent *dp;
|
||||||
Evry_Item_File *file;
|
Evry_Item_File *file;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
|
||||||
if (!d->list)
|
if (!d->dirp)
|
||||||
d->list = ecore_file_ls(p->directory);
|
d->dirp = opendir(p->directory);
|
||||||
|
if (!d->dirp) return;
|
||||||
|
|
||||||
while(d->list)
|
while (dp = readdir(d->dirp))
|
||||||
{
|
{
|
||||||
filename = d->list->data;
|
if ((dp->d_name[0] == '.') &&
|
||||||
d->list = eina_list_remove_list(d->list, d->list);
|
((dp->d_name[1] == '\0') ||
|
||||||
|
((dp->d_name[1] == '.') &&
|
||||||
|
(dp->d_name[2] == '\0'))))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (filename[0] == '.')
|
#ifdef _DIRENT_HAVE_D_TYPE
|
||||||
|
if (dp->d_type == DT_FIFO ||
|
||||||
|
dp->d_type == DT_BLK ||
|
||||||
|
dp->d_type == DT_CHR ||
|
||||||
|
dp->d_type == DT_SOCK)
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
if (!p->show_hidden)
|
||||||
{
|
{
|
||||||
free(filename);
|
if (dp->d_name[0] == '.')
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (dp->d_name[0] != '.')
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
file = E_NEW(Evry_Item_File, 1);
|
file = E_NEW(Evry_Item_File, 1);
|
||||||
if (!file)
|
if (!file) break;
|
||||||
{
|
|
||||||
free(filename);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), NULL, _item_free);
|
evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), NULL, _item_free);
|
||||||
|
filename = strdup(dp->d_name);
|
||||||
|
|
||||||
EVRY_ITEM(file)->label = filename;
|
EVRY_ITEM(file)->label = filename;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s/%s", p->directory, filename);
|
snprintf(buf, sizeof(buf), "%s/%s", p->directory, filename);
|
||||||
file->path = strdup(buf);
|
file->path = strdup(buf);
|
||||||
|
#ifdef _DIRENT_HAVE_D_TYPE
|
||||||
if (ecore_file_is_dir(file->path))
|
if (dp->d_type & DT_UNKNOWN)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
if (ecore_file_is_dir(file->path))
|
||||||
|
{
|
||||||
|
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
||||||
|
}
|
||||||
|
else if ((mime = efreet_mime_type_get(file->path)))
|
||||||
|
{
|
||||||
|
file->mime = mime;
|
||||||
|
}
|
||||||
|
#ifdef _DIRENT_HAVE_D_TYPE
|
||||||
|
}
|
||||||
|
else if (dp->d_type & DT_DIR)
|
||||||
{
|
{
|
||||||
file->mime = "inode/directory";
|
|
||||||
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
||||||
}
|
}
|
||||||
else if ((mime = efreet_mime_type_get(file->path)))
|
else if (dp->d_type & DT_REG | DT_LNK)
|
||||||
{
|
{
|
||||||
file->mime = mime;
|
if ((mime = efreet_mime_type_get(file->path)))
|
||||||
|
{
|
||||||
|
file->mime = mime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
d->files = eina_list_append(d->files, file);
|
d->files = eina_list_append(d->files, file);
|
||||||
|
|
||||||
if (cnt++ > MAX_ITEMS) break;
|
if (cnt++ > MAX_ITEMS) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d->finished = EINA_TRUE;
|
||||||
|
closedir(d->dirp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -208,8 +250,8 @@ _scan_cancel_func(void *data)
|
||||||
free(file);
|
free(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
EINA_LIST_FREE(d->list, filename)
|
if (!d->finished)
|
||||||
free(filename);
|
closedir(d->dirp);
|
||||||
|
|
||||||
E_FREE(d);
|
E_FREE(d);
|
||||||
|
|
||||||
|
@ -234,7 +276,6 @@ _scan_end_func(void *data)
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
|
|
||||||
p->thread = NULL;
|
p->thread = NULL;
|
||||||
printf("scan end\n");
|
|
||||||
|
|
||||||
EINA_LIST_FREE(d->files, item)
|
EINA_LIST_FREE(d->files, item)
|
||||||
{
|
{
|
||||||
|
@ -260,10 +301,18 @@ _scan_end_func(void *data)
|
||||||
}
|
}
|
||||||
if (!file) continue;
|
if (!file) continue;
|
||||||
|
|
||||||
if (mime)
|
if (item->browseable)
|
||||||
file->mime = eina_stringshare_add(mime);
|
file->mime = eina_stringshare_ref(_mime_dir);
|
||||||
|
else if (mime)
|
||||||
|
{
|
||||||
|
file->mime = eina_stringshare_add(mime);
|
||||||
|
if (!strncmp(file->mime, "inode/", 6) &&
|
||||||
|
ecore_file_is_dir(file->path))
|
||||||
|
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
file->mime = eina_stringshare_add("None");
|
file->mime = eina_stringshare_add("unknown");
|
||||||
|
|
||||||
item->context = eina_stringshare_ref(file->mime);
|
item->context = eina_stringshare_ref(file->mime);
|
||||||
item->id = eina_stringshare_ref(file->path);
|
item->id = eina_stringshare_ref(file->path);
|
||||||
item->label = eina_stringshare_add(filename);
|
item->label = eina_stringshare_add(filename);
|
||||||
|
@ -274,12 +323,8 @@ _scan_end_func(void *data)
|
||||||
p->files = eina_list_append(p->files, file);
|
p->files = eina_list_append(p->files, file);
|
||||||
|
|
||||||
evry_util_file_detail_set(file);
|
evry_util_file_detail_set(file);
|
||||||
|
|
||||||
/* if (cnt >= MAX_ITEMS) continue;
|
|
||||||
* cnt += _append_file(p, file);
|
|
||||||
* item->priority = cnt; */
|
|
||||||
}
|
}
|
||||||
if (d->list)
|
if (!d->finished)
|
||||||
p->thread = ecore_thread_run(_scan_func, _scan_end_func, _scan_cancel_func, d);
|
p->thread = ecore_thread_run(_scan_func, _scan_end_func, _scan_cancel_func, d);
|
||||||
else
|
else
|
||||||
E_FREE(d);
|
E_FREE(d);
|
||||||
|
@ -496,8 +541,11 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
||||||
/* input is command ? */
|
/* input is command ? */
|
||||||
if (input && !strncmp(input, "/", 1))
|
if (input && !strncmp(input, "/", 1))
|
||||||
{
|
{
|
||||||
if (!p->command)
|
if (p->command != CMD_SHOW_ROOT)
|
||||||
{
|
{
|
||||||
|
if (p->thread)
|
||||||
|
ecore_thread_cancel(p->thread);
|
||||||
|
|
||||||
/* browse root */
|
/* browse root */
|
||||||
EINA_LIST_FREE(p->files, file)
|
EINA_LIST_FREE(p->files, file)
|
||||||
evry_item_free(EVRY_ITEM(file));
|
evry_item_free(EVRY_ITEM(file));
|
||||||
|
@ -506,7 +554,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
||||||
p->directory = eina_stringshare_add("/");
|
p->directory = eina_stringshare_add("/");
|
||||||
_read_directory(p);
|
_read_directory(p);
|
||||||
|
|
||||||
p->command = EINA_TRUE;
|
p->command = CMD_SHOW_ROOT;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -515,15 +563,18 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->directory && input && !strncmp(input, ".", 1))
|
if (p->directory && input && !strncmp(input, "..", 2))
|
||||||
{
|
{
|
||||||
if (!p->command)
|
if (p->command != CMD_SHOW_PARENT)
|
||||||
{
|
{
|
||||||
char *end;
|
char *end;
|
||||||
char dir[4096];
|
char dir[4096];
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int prio = 0;
|
int prio = 0;
|
||||||
|
|
||||||
|
if (p->thread)
|
||||||
|
ecore_thread_cancel(p->thread);
|
||||||
|
|
||||||
/* browse root */
|
/* browse root */
|
||||||
EINA_LIST_FREE(p->hist_added, file)
|
EINA_LIST_FREE(p->hist_added, file)
|
||||||
{
|
{
|
||||||
|
@ -552,25 +603,49 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
||||||
}
|
}
|
||||||
|
|
||||||
_folder_item_add(p, "/");
|
_folder_item_add(p, "/");
|
||||||
p->command = EINA_TRUE;
|
p->command = CMD_SHOW_PARENT;
|
||||||
}
|
}
|
||||||
cmd = 1;
|
cmd = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p->directory && input && !strncmp(input, ".", 1))
|
||||||
|
{
|
||||||
|
if (p->command != CMD_SHOW_HIDDEN)
|
||||||
|
{
|
||||||
|
if (p->thread)
|
||||||
|
ecore_thread_cancel(p->thread);
|
||||||
|
|
||||||
|
EINA_LIST_FREE(p->files, file)
|
||||||
|
evry_item_free(EVRY_ITEM(file));
|
||||||
|
|
||||||
|
p->show_hidden = EINA_TRUE;
|
||||||
|
_read_directory(p);
|
||||||
|
|
||||||
|
p->command = CMD_SHOW_HIDDEN;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
cmd = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* clear command items */
|
/* clear command items */
|
||||||
if (!cmd && p->command)
|
if (!cmd && p->command)
|
||||||
{
|
{
|
||||||
p->command = EINA_FALSE;
|
|
||||||
|
|
||||||
EINA_LIST_FREE(p->files, file)
|
EINA_LIST_FREE(p->files, file)
|
||||||
evry_item_free(EVRY_ITEM(file));
|
evry_item_free(EVRY_ITEM(file));
|
||||||
|
|
||||||
if (p->directory)
|
if (p->command == CMD_SHOW_ROOT)
|
||||||
eina_stringshare_del(p->directory);
|
{
|
||||||
|
p->directory = eina_stringshare_add(e_user_homedir_get());
|
||||||
|
if (p->directory)
|
||||||
|
eina_stringshare_del(p->directory);
|
||||||
|
}
|
||||||
|
|
||||||
p->directory = eina_stringshare_add(e_user_homedir_get());
|
|
||||||
|
p->show_hidden = EINA_FALSE;
|
||||||
_read_directory(p);
|
_read_directory(p);
|
||||||
|
|
||||||
|
p->command = CMD_NONE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,6 +705,9 @@ _icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
||||||
else
|
else
|
||||||
o = evry_icon_mime_get(file->mime, e);
|
o = evry_icon_mime_get(file->mime, e);
|
||||||
|
|
||||||
|
if (!o)
|
||||||
|
o = evry_icon_mime_get("unknown", e);
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -674,7 +752,7 @@ _open_term_action(Evry_Action *act)
|
||||||
Evry_Item_App *tmp;
|
Evry_Item_App *tmp;
|
||||||
char cwd[4096];
|
char cwd[4096];
|
||||||
char *dir;
|
char *dir;
|
||||||
int ret = 0;
|
int ret = 0, ok;
|
||||||
|
|
||||||
if (act->item1->browseable)
|
if (act->item1->browseable)
|
||||||
dir = strdup(file->path);
|
dir = strdup(file->path);
|
||||||
|
@ -683,8 +761,10 @@ _open_term_action(Evry_Action *act)
|
||||||
|
|
||||||
if (dir)
|
if (dir)
|
||||||
{
|
{
|
||||||
getcwd(cwd, sizeof(cwd));
|
if (!getcwd(cwd, sizeof(cwd)))
|
||||||
chdir(dir);
|
return 0;
|
||||||
|
if (chdir(dir))
|
||||||
|
return 0;
|
||||||
|
|
||||||
tmp = E_NEW(Evry_Item_App, 1);
|
tmp = E_NEW(Evry_Item_App, 1);
|
||||||
tmp->file = evry_conf->cmd_terminal;
|
tmp->file = evry_conf->cmd_terminal;
|
||||||
|
@ -692,7 +772,8 @@ _open_term_action(Evry_Action *act)
|
||||||
ret = evry_util_exec_app(EVRY_ITEM(tmp), NULL);
|
ret = evry_util_exec_app(EVRY_ITEM(tmp), NULL);
|
||||||
E_FREE(tmp);
|
E_FREE(tmp);
|
||||||
E_FREE(dir);
|
E_FREE(dir);
|
||||||
chdir(cwd);
|
if (chdir(cwd))
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -775,7 +856,6 @@ _conf_dialog(E_Container *con, const char *params)
|
||||||
cfd = e_config_dialog_new(con, _("Everything Files"), "everything-files",
|
cfd = e_config_dialog_new(con, _("Everything Files"), "everything-files",
|
||||||
"extensions/everything-files", buf, 0, v, NULL);
|
"extensions/everything-files", buf, 0, v, NULL);
|
||||||
|
|
||||||
/* e_dialog_resizable_set(cfd->dia, 1); */
|
|
||||||
_conf->cfd = cfd;
|
_conf->cfd = cfd;
|
||||||
return cfd;
|
return cfd;
|
||||||
}
|
}
|
||||||
|
@ -942,6 +1022,8 @@ e_modapi_init(E_Module *m)
|
||||||
|
|
||||||
_conf_init(m);
|
_conf_init(m);
|
||||||
|
|
||||||
|
_mime_dir = eina_stringshare_add("inode/directory");
|
||||||
|
|
||||||
e_module_delayed_set(m, 1);
|
e_module_delayed_set(m, 1);
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
|
@ -953,6 +1035,8 @@ e_modapi_shutdown(E_Module *m)
|
||||||
if (active && e_datastore_get("everything_loaded"))
|
if (active && e_datastore_get("everything_loaded"))
|
||||||
_plugins_shutdown();
|
_plugins_shutdown();
|
||||||
|
|
||||||
|
eina_stringshare_del(_mime_dir);
|
||||||
|
|
||||||
_conf_shutdown();
|
_conf_shutdown();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -2029,15 +2029,14 @@ _evry_plugin_select(Evry_State *s, Evry_Plugin *p)
|
||||||
{
|
{
|
||||||
if (!s || !s->cur_plugins) return;
|
if (!s || !s->cur_plugins) return;
|
||||||
|
|
||||||
|
if (p) s->plugin_auto_selected = EINA_FALSE;
|
||||||
|
|
||||||
if (!p && s->cur_plugins)
|
if (!p && s->cur_plugins)
|
||||||
{
|
{
|
||||||
p = s->cur_plugins->data;
|
p = s->cur_plugins->data;
|
||||||
s->plugin_auto_selected = EINA_TRUE;
|
s->plugin_auto_selected = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p)
|
|
||||||
s->plugin_auto_selected = EINA_FALSE;
|
|
||||||
|
|
||||||
if (s->plugin != p)
|
if (s->plugin != p)
|
||||||
_evry_item_desel(s, NULL);
|
_evry_item_desel(s, NULL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue