2010-05-21 23:35:46 -07:00
|
|
|
/***************************************************
|
2011-11-29 19:32:54 -08:00
|
|
|
TODO option for maximum items to cache
|
|
|
|
TODO keep common list for recent file instances
|
|
|
|
FIXME
|
|
|
|
*/
|
2010-05-03 18:19:16 -07:00
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
#include "e.h"
|
|
|
|
#include "evry_api.h"
|
2010-04-25 09:26:13 -07:00
|
|
|
#include <Efreet_Trash.h>
|
2009-08-13 08:10:54 -07:00
|
|
|
|
2012-12-21 15:57:05 -08:00
|
|
|
/* Increment for Major Changes */
|
|
|
|
#define MOD_CONFIG_FILE_EPOCH 1
|
|
|
|
/* Increment for Minor Changes (ie: user doesn't need a new config) */
|
|
|
|
#define MOD_CONFIG_FILE_GENERATION 0
|
|
|
|
#define MOD_CONFIG_FILE_VERSION ((MOD_CONFIG_FILE_EPOCH * 1000000) + MOD_CONFIG_FILE_GENERATION)
|
2011-04-08 15:16:59 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
#define MAX_ITEMS 10
|
|
|
|
#define MAX_SHOWN 300
|
|
|
|
#define TERM_ACTION_DIR "%s"
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
#define CMD_NONE 0
|
|
|
|
#define CMD_SHOW_ROOT 1
|
|
|
|
#define CMD_SHOW_HIDDEN 2
|
|
|
|
#define CMD_SHOW_PARENT 3
|
2010-04-25 04:00:53 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
#define ACT_TRASH 1
|
|
|
|
#define ACT_DELETE 2
|
|
|
|
#define ACT_COPY 3
|
|
|
|
#define ACT_MOVE 4
|
|
|
|
#define ACT_SORT_DATE 5
|
|
|
|
#define ACT_SORT_NAME 6
|
2010-04-29 08:20:12 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
#define ONE_DAY 86400.0
|
|
|
|
#define SIX_DAYS_AGO (ecore_time_unix_get() - ONE_DAY * 6)
|
|
|
|
#define MIN_USAGE 0.0
|
2010-04-29 14:42:03 -07:00
|
|
|
|
2010-05-02 08:46:02 -07:00
|
|
|
/* #undef DBG
|
|
|
|
* #define DBG(...) ERR(__VA_ARGS__) */
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
typedef struct _Plugin Plugin;
|
|
|
|
typedef struct _Data Data;
|
2010-04-20 10:48:21 -07:00
|
|
|
typedef struct _Module_Config Module_Config;
|
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
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
Evry_Plugin base;
|
|
|
|
|
|
|
|
Eina_List *files;
|
|
|
|
const char *directory;
|
|
|
|
const char *input;
|
|
|
|
unsigned int command;
|
|
|
|
unsigned int min_query;
|
|
|
|
Eina_Bool parent;
|
|
|
|
Eina_Bool show_hidden;
|
|
|
|
Eina_Bool dirs_only;
|
|
|
|
Eina_Bool show_recent;
|
|
|
|
Eina_Bool sort_by_date;
|
|
|
|
|
|
|
|
Ecore_Thread *thread;
|
|
|
|
Ecore_File_Monitor *dir_mon;
|
|
|
|
int waiting_to_finish;
|
2009-08-27 15:58:34 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Data
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
Plugin *plugin;
|
|
|
|
char *directory;
|
|
|
|
long id;
|
|
|
|
int level;
|
|
|
|
int cnt;
|
|
|
|
Eina_List *files;
|
|
|
|
DIR *dirp;
|
|
|
|
int run_cnt;
|
2009-06-21 03:31:38 -07:00
|
|
|
};
|
|
|
|
|
2010-04-20 10:48:21 -07:00
|
|
|
struct _Module_Config
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
int version;
|
2010-04-20 10:48:21 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
unsigned char show_homedir;
|
|
|
|
unsigned char show_recent;
|
|
|
|
unsigned char search_recent;
|
|
|
|
unsigned char cache_dirs;
|
|
|
|
unsigned char search_cache;
|
2010-04-20 10:48:21 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
// TODO
|
|
|
|
int sort_by;
|
|
|
|
Eina_List *search_dirs;
|
2010-04-20 10:48:21 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
E_Config_Dialog *cfd;
|
|
|
|
E_Module *module;
|
2010-04-20 10:48:21 -07:00
|
|
|
};
|
|
|
|
|
2011-08-12 04:41:15 -07:00
|
|
|
static const Evry_API *evry = NULL;
|
2010-05-11 10:24:38 -07:00
|
|
|
static Evry_Module *evry_module = NULL;
|
|
|
|
|
2010-04-20 10:48:21 -07:00
|
|
|
static Module_Config *_conf;
|
2010-04-30 05:55:01 -07:00
|
|
|
static char _module_icon[] = "system-file-manager";
|
2010-05-06 06:09:14 -07:00
|
|
|
static Eina_List *_plugins = NULL;
|
2010-04-25 12:37:30 -07:00
|
|
|
static Eina_List *_actions = NULL;
|
2010-04-30 05:55:01 -07:00
|
|
|
static const char *_mime_dir;
|
2010-05-06 06:09:14 -07:00
|
|
|
static const char *_mime_mount;
|
2010-06-04 14:55:40 -07:00
|
|
|
static const char *_mime_unknown;
|
2010-05-01 16:03:14 -07:00
|
|
|
static Eina_Bool clear_cache = EINA_FALSE;
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
/***************************************************************************/
|
2010-04-15 06:58:44 -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
|
|
|
{
|
2010-05-06 06:09:14 -07:00
|
|
|
if (!file->mime)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
const char *mime = efreet_mime_type_get(file->path);
|
2010-04-20 10:48:21 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (mime)
|
|
|
|
file->mime = eina_stringshare_ref(mime);
|
|
|
|
else
|
|
|
|
file->mime = eina_stringshare_add("unknown");
|
2010-05-06 06:09:14 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2010-05-06 06:09:14 -07:00
|
|
|
if ((file->mime == _mime_dir) ||
|
|
|
|
(file->mime == _mime_mount))
|
|
|
|
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
2010-05-01 16:03:14 -07:00
|
|
|
|
2010-05-06 06:09:14 -07:00
|
|
|
EVRY_ITEM(file)->context = eina_stringshare_ref(file->mime);
|
2010-04-20 10:48:21 -07:00
|
|
|
|
2010-05-06 06:09:14 -07:00
|
|
|
if (!EVRY_ITEM(file)->detail)
|
2010-05-11 10:24:38 -07:00
|
|
|
evry->util_file_detail_set(file);
|
2009-08-27 15:58:34 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
evry->util_file_detail_set(file);
|
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)
|
2011-11-29 19:32:54 -08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-05-23 06:54:44 -07:00
|
|
|
static int
|
|
|
|
_cb_sort_date(const void *data1, const void *data2)
|
|
|
|
{
|
|
|
|
const Evry_Item_File *it1 = data1;
|
|
|
|
const Evry_Item_File *it2 = data2;
|
|
|
|
|
|
|
|
return it2->modified - it1->modified;
|
|
|
|
}
|
|
|
|
|
2009-08-12 12:14:45 -07:00
|
|
|
static void
|
2010-11-13 05:33:12 -08:00
|
|
|
_scan_func(void *data, Ecore_Thread *thread)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-27 15:58:34 -07:00
|
|
|
Data *d = data;
|
2010-11-13 05:33:12 -08:00
|
|
|
Eina_Iterator *ls;
|
|
|
|
Eina_File_Direct_Info *info;
|
2009-08-22 20:12:05 -07:00
|
|
|
Evry_Item_File *file;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2010-11-13 05:33:12 -08:00
|
|
|
if (!(ls = eina_file_stat_ls(d->directory)))
|
2010-10-13 19:57:35 -07:00
|
|
|
return;
|
2010-05-01 16:03:14 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_ITERATOR_FOREACH (ls, info)
|
2009-07-10 08:47:19 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if ((d->plugin->show_hidden) != (*(info->path + info->name_start) == '.'))
|
|
|
|
continue;
|
2010-04-29 14:42:03 -07:00
|
|
|
|
2011-11-29 20:00:51 -08:00
|
|
|
file = EVRY_ITEM_NEW(Evry_Item_File, d->plugin, NULL, NULL, evry_item_file_free);
|
2011-11-29 19:32:54 -08:00
|
|
|
file->path = strdup(info->path);
|
|
|
|
EVRY_ITEM(file)->label = strdup(info->path + info->name_start);
|
|
|
|
EVRY_ITEM(file)->browseable = (info->type == EINA_FILE_DIR);
|
2010-11-13 05:33:12 -08:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
d->files = eina_list_append(d->files, file);
|
|
|
|
/* TODO dont append files in thread, run mime scan
|
|
|
|
* simultaneously. ecore_thread_feedback(thread, file); */
|
2010-11-13 05:33:12 -08:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (ecore_thread_check(thread))
|
|
|
|
break;
|
2010-04-26 11:21:09 -07:00
|
|
|
}
|
2010-11-13 05:33:12 -08:00
|
|
|
|
|
|
|
eina_iterator_free(ls);
|
2010-05-01 16:03:14 -07:00
|
|
|
}
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-05-01 16:03:14 -07:00
|
|
|
static void
|
2010-11-13 05:33:12 -08:00
|
|
|
_scan_mime_func(void *data, Ecore_Thread *thread)
|
2010-05-01 16:03:14 -07:00
|
|
|
{
|
|
|
|
Data *d = data;
|
|
|
|
Evry_Item_File *file;
|
|
|
|
Eina_List *l;
|
|
|
|
int cnt = 0;
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (d->files, l, file)
|
2010-05-01 16:03:14 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (ecore_thread_check(thread))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if ((file->mime = efreet_mime_type_get(file->path)))
|
|
|
|
{
|
|
|
|
if (!strncmp(file->mime, "inode/", 6) &&
|
|
|
|
ecore_file_is_dir(file->path))
|
|
|
|
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
file->mime = _mime_unknown;
|
|
|
|
|
|
|
|
if (cnt++ > MAX_ITEMS * d->run_cnt) break;
|
2010-04-25 04:27:01 -07:00
|
|
|
}
|
2009-08-27 15:58:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-11-13 05:33:12 -08:00
|
|
|
_files_filter(Plugin *p)
|
2009-08-27 15:58:34 -07:00
|
|
|
{
|
|
|
|
int match;
|
2010-04-25 18:04:43 -07:00
|
|
|
int cnt = 0;
|
2010-05-02 13:40:21 -07:00
|
|
|
Evry_Item *it;
|
2010-04-25 18:04:43 -07:00
|
|
|
Eina_List *l;
|
2011-01-23 14:34:28 -08:00
|
|
|
unsigned int len = p->input ? strlen(p->input) : 0;
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-04-25 18:04:43 -07:00
|
|
|
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-05-06 06:09:14 -07:00
|
|
|
if (!p->command && p->min_query)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (!p->input)
|
|
|
|
return 0;
|
|
|
|
if (len < p->min_query)
|
|
|
|
return 0;
|
2010-05-06 06:09:14 -07:00
|
|
|
}
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (p->files, l, it)
|
2009-08-27 15:58:34 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (cnt >= MAX_SHOWN) break;
|
|
|
|
|
|
|
|
if (p->dirs_only && !it->browseable)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (len && (match = evry->fuzzy_match(it->label, p->input)))
|
|
|
|
{
|
|
|
|
it->fuzzy_match = match;
|
|
|
|
if (!it->browseable)
|
|
|
|
it->priority = 1;
|
|
|
|
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
else if (len == 0)
|
|
|
|
{
|
|
|
|
if (!it->browseable)
|
|
|
|
it->priority = 1;
|
|
|
|
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
|
|
|
cnt++;
|
|
|
|
}
|
2010-04-25 18:04:43 -07:00
|
|
|
}
|
|
|
|
return cnt;
|
2009-08-27 15:58:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-11-12 05:28:19 -08:00
|
|
|
_scan_cancel_func(void *data, Ecore_Thread *thread __UNUSED__)
|
2009-08-27 15:58:34 -07:00
|
|
|
{
|
|
|
|
Data *d = data;
|
|
|
|
Plugin *p = d->plugin;
|
2010-04-08 15:37:50 -07:00
|
|
|
Evry_Item_File *file;
|
2010-04-20 10:48:21 -07:00
|
|
|
|
2011-08-16 17:21:17 -07:00
|
|
|
/* EINA_LIST_FREE(p->files, file)
|
|
|
|
* EVRY_ITEM_FREE(file); */
|
2010-11-13 05:33:12 -08:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (d->files, file)
|
2010-05-01 16:03:14 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (file->base.label) free((char *)(file->base.label));
|
|
|
|
if (file->path) free((char *)file->path);
|
|
|
|
E_FREE(file);
|
2009-08-27 15:58:34 -07:00
|
|
|
}
|
2010-04-16 07:15:30 -07:00
|
|
|
|
2010-11-13 05:33:12 -08:00
|
|
|
p->thread = NULL;
|
|
|
|
|
2011-08-16 17:21:17 -07:00
|
|
|
if (p->waiting_to_finish)
|
2010-10-14 04:46:56 -07:00
|
|
|
E_FREE(p);
|
|
|
|
|
2010-04-26 11:21:09 -07:00
|
|
|
free(d->directory);
|
2010-04-08 15:37:50 -07:00
|
|
|
E_FREE(d);
|
2010-10-14 04:46:56 -07:00
|
|
|
}
|
2010-04-20 10:48:21 -07:00
|
|
|
|
2010-10-14 04:46:56 -07:00
|
|
|
static void
|
|
|
|
_cache_mime_get(History_Types *ht, Evry_Item_File *file)
|
|
|
|
{
|
|
|
|
History_Entry *he;
|
|
|
|
History_Item *hi;
|
|
|
|
Eina_List *l;
|
2010-11-13 05:33:12 -08:00
|
|
|
|
2010-10-28 16:07:59 -07:00
|
|
|
if ((he = eina_hash_find(ht->types, file->path)))
|
2010-10-14 04:46:56 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (he->items, l, hi)
|
|
|
|
{
|
|
|
|
if (!hi->data)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!file->mime)
|
|
|
|
file->mime = hi->data;
|
|
|
|
|
|
|
|
hi->transient = 0;
|
|
|
|
EVRY_ITEM(file)->hi = hi;
|
|
|
|
break;
|
|
|
|
}
|
2010-10-14 04:46:56 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cache_dir_add(Eina_List *files)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Evry_Item *item;
|
|
|
|
History_Item *hi;
|
|
|
|
int cnt = 0;
|
2010-11-13 05:33:12 -08:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_REVERSE_FOREACH (files, l, item)
|
2010-10-14 04:46:56 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
GET_FILE(file, item);
|
|
|
|
|
|
|
|
if (!(item->hi) &&
|
|
|
|
(hi = evry->history_item_add(item, NULL, NULL)))
|
|
|
|
{
|
|
|
|
hi->last_used = SIX_DAYS_AGO;
|
|
|
|
hi->usage = MIN_USAGE * (double)cnt++;
|
|
|
|
hi->data = eina_stringshare_ref(file->mime);
|
|
|
|
item->hi = hi;
|
|
|
|
}
|
|
|
|
else if (item->hi && (item->hi->count == 1) &&
|
|
|
|
(item->hi->last_used < SIX_DAYS_AGO))
|
|
|
|
{
|
|
|
|
item->hi->last_used = SIX_DAYS_AGO;
|
|
|
|
item->hi->usage = MIN_USAGE * (double)cnt++;
|
|
|
|
}
|
2010-10-14 04:46:56 -07:00
|
|
|
}
|
2010-04-08 15:37:50 -07:00
|
|
|
}
|
2009-08-12 05:17:43 -07:00
|
|
|
|
2010-04-08 15:37:50 -07:00
|
|
|
static void
|
2010-11-13 05:33:12 -08:00
|
|
|
_file_add(Plugin *p, Evry_Item *item)
|
|
|
|
{
|
|
|
|
GET_FILE(file, item);
|
|
|
|
|
|
|
|
char *filename = (char *)item->label;
|
2011-11-29 19:32:54 -08:00
|
|
|
char *path = (char *)file->path;
|
2010-11-13 05:33:12 -08:00
|
|
|
|
|
|
|
file->path = eina_stringshare_add(path);
|
|
|
|
file->mime = eina_stringshare_ref(file->mime);
|
|
|
|
|
|
|
|
item->label = eina_stringshare_add(filename);
|
|
|
|
item->id = eina_stringshare_ref(file->path);
|
|
|
|
item->context = eina_stringshare_ref(file->mime);
|
|
|
|
|
|
|
|
evry->util_file_detail_set(file);
|
|
|
|
|
|
|
|
p->files = eina_list_append(p->files, file);
|
|
|
|
|
|
|
|
E_FREE(filename);
|
|
|
|
E_FREE(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-23 14:34:28 -08:00
|
|
|
_scan_end_func(void *data, Ecore_Thread *thread __UNUSED__)
|
2010-04-08 15:37:50 -07:00
|
|
|
{
|
|
|
|
Data *d = data;
|
|
|
|
Plugin *p = d->plugin;
|
|
|
|
Evry_Item *item;
|
2010-11-13 05:33:12 -08:00
|
|
|
Evry_Item_File *file;
|
2010-10-14 04:46:56 -07:00
|
|
|
Eina_List *l, *ll;
|
2010-05-02 13:40:21 -07:00
|
|
|
History_Types *ht = NULL;
|
2010-04-20 10:48:21 -07:00
|
|
|
|
2010-05-02 13:40:21 -07:00
|
|
|
if (_conf->cache_dirs)
|
2010-05-11 10:24:38 -07:00
|
|
|
ht = evry->history_types_get(EVRY_TYPE_FILE);
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2010-10-14 04:46:56 -07:00
|
|
|
if (!d->run_cnt) /* _scan_func finished */
|
2009-08-27 15:58:34 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH_SAFE (d->files, l, ll, item)
|
|
|
|
{
|
2012-05-04 02:38:52 -07:00
|
|
|
GET_FILE(browse, item);
|
2011-11-29 19:32:54 -08:00
|
|
|
|
|
|
|
if (item->browseable)
|
2012-05-04 02:38:52 -07:00
|
|
|
browse->mime = _mime_dir;
|
2011-11-29 19:32:54 -08:00
|
|
|
else if (ht)
|
2012-05-04 02:38:52 -07:00
|
|
|
_cache_mime_get(ht, browse);
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2012-05-04 02:38:52 -07:00
|
|
|
if (browse->mime)
|
2011-11-29 19:32:54 -08:00
|
|
|
{
|
|
|
|
d->files = eina_list_remove_list(d->files, l);
|
|
|
|
_file_add(p, item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sort files by name for mimetypes scan */
|
|
|
|
if (d->files)
|
|
|
|
d->files = eina_list_sort(d->files, -1, _cb_sort);
|
2010-04-25 12:37:30 -07:00
|
|
|
}
|
2011-11-29 19:32:54 -08:00
|
|
|
else /* _scan_mime_func finished */
|
2010-05-01 16:03:14 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (d->files, file)
|
|
|
|
{
|
|
|
|
if (!file->mime) break;
|
|
|
|
_file_add(p, (Evry_Item *)file);
|
|
|
|
}
|
2010-05-01 16:03:14 -07:00
|
|
|
}
|
|
|
|
|
2010-10-14 04:46:56 -07:00
|
|
|
if (d->files) /* scan mimetypes */
|
2010-04-25 12:37:30 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
d->run_cnt++;
|
|
|
|
p->thread = ecore_thread_run(_scan_mime_func,
|
|
|
|
_scan_end_func,
|
|
|
|
_scan_cancel_func, d);
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
/* wait for first mime scan to finish */
|
|
|
|
if (d->run_cnt == 1) return;
|
2010-10-14 04:46:56 -07:00
|
|
|
}
|
|
|
|
else /* finished all file/mime scan */
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
free(d->directory);
|
|
|
|
E_FREE(d);
|
|
|
|
p->thread = NULL;
|
2010-10-14 04:46:56 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (_conf->cache_dirs && !(p->command == CMD_SHOW_HIDDEN))
|
|
|
|
_cache_dir_add(p->files);
|
2010-04-25 12:37:30 -07:00
|
|
|
}
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2010-10-14 04:46:56 -07:00
|
|
|
p->files = eina_list_sort(p->files, -1, _cb_sort);
|
2010-11-13 05:33:12 -08:00
|
|
|
|
|
|
|
_files_filter(p);
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-05-10 15:35:13 -07:00
|
|
|
EVRY_PLUGIN_UPDATE(p, EVRY_UPDATE_ADD);
|
2009-08-27 15:58:34 -07:00
|
|
|
}
|
|
|
|
|
2010-04-25 09:26:13 -07:00
|
|
|
static void
|
2011-01-23 14:34:28 -08:00
|
|
|
_dir_watcher(void *data, Ecore_File_Monitor *em __UNUSED__, Ecore_File_Event event, const char *path)
|
2010-04-25 09:26:13 -07:00
|
|
|
{
|
|
|
|
Plugin *p = data;
|
|
|
|
Evry_Item_File *file;
|
2010-04-25 18:04:43 -07:00
|
|
|
const char *label;
|
|
|
|
Eina_List *ll, *l;
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-04-25 18:04:43 -07:00
|
|
|
switch (event)
|
2010-04-25 09:26:13 -07:00
|
|
|
{
|
2010-04-25 18:04:43 -07:00
|
|
|
case ECORE_FILE_EVENT_DELETED_SELF:
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (p->files, file)
|
|
|
|
evry->item_free(EVRY_ITEM(file));
|
|
|
|
break;
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-04-25 18:04:43 -07:00
|
|
|
case ECORE_FILE_EVENT_CREATED_DIRECTORY:
|
|
|
|
case ECORE_FILE_EVENT_CREATED_FILE:
|
2011-11-29 19:32:54 -08:00
|
|
|
label = ecore_file_file_get(path);
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2011-11-29 20:00:51 -08:00
|
|
|
file = EVRY_ITEM_NEW(Evry_Item_File, p, label, NULL, evry_item_file_free);
|
2011-11-29 19:32:54 -08:00
|
|
|
file->path = eina_stringshare_add(path);
|
2010-04-25 18:04:43 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (event == ECORE_FILE_EVENT_CREATED_DIRECTORY)
|
|
|
|
file->mime = eina_stringshare_ref(_mime_dir);
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
_item_fill(file);
|
|
|
|
p->files = eina_list_append(p->files, file);
|
|
|
|
break;
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-04-25 18:04:43 -07:00
|
|
|
case ECORE_FILE_EVENT_DELETED_FILE:
|
|
|
|
case ECORE_FILE_EVENT_DELETED_DIRECTORY:
|
2011-11-29 19:32:54 -08:00
|
|
|
label = eina_stringshare_add(path);
|
2010-04-25 18:04:43 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH_SAFE (p->files, l, ll, file)
|
|
|
|
{
|
|
|
|
if (file->path != label) continue;
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
p->files = eina_list_remove_list(p->files, l);
|
2010-04-30 15:12:02 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EVRY_ITEM_FREE(file);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
eina_stringshare_del(label);
|
|
|
|
break;
|
2010-04-25 18:04:43 -07:00
|
|
|
|
|
|
|
default:
|
2011-11-29 19:32:54 -08:00
|
|
|
return;
|
2010-04-25 18:04:43 -07:00
|
|
|
}
|
|
|
|
|
2010-11-13 05:33:12 -08:00
|
|
|
_files_filter(p);
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-05-10 15:35:13 -07:00
|
|
|
EVRY_PLUGIN_UPDATE(p, EVRY_UPDATE_ADD);
|
2010-04-25 09:26:13 -07:00
|
|
|
}
|
|
|
|
|
2009-08-27 15:58:34 -07:00
|
|
|
static void
|
|
|
|
_read_directory(Plugin *p)
|
|
|
|
{
|
|
|
|
Data *d = E_NEW(Data, 1);
|
|
|
|
d->plugin = p;
|
2010-04-26 11:21:09 -07:00
|
|
|
d->directory = strdup(p->directory);
|
2010-10-14 04:46:56 -07:00
|
|
|
d->run_cnt = 0;
|
2010-11-13 05:33:12 -08:00
|
|
|
|
2010-04-08 15:37:50 -07:00
|
|
|
p->thread = ecore_thread_run(_scan_func, _scan_end_func, _scan_cancel_func, d);
|
2010-04-25 09:26:13 -07:00
|
|
|
|
|
|
|
if (p->dir_mon)
|
|
|
|
ecore_file_monitor_del(p->dir_mon);
|
|
|
|
|
2010-04-26 11:21:09 -07:00
|
|
|
p->dir_mon = ecore_file_monitor_add(p->directory, _dir_watcher, p);
|
2009-08-12 12:14:45 -07:00
|
|
|
}
|
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
static Evry_Plugin *
|
2010-05-03 12:19:42 -07:00
|
|
|
_browse(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;
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2010-05-19 07:47:12 -07:00
|
|
|
if (!it || !(CHECK_TYPE(it, EVRY_TYPE_FILE)))
|
2010-05-06 07:54:19 -07:00
|
|
|
return NULL;
|
2009-08-22 20:12:05 -07:00
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
GET_FILE(file, it);
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
if (!evry->file_path_get(file) ||
|
2010-05-06 07:54:19 -07:00
|
|
|
!ecore_file_is_dir(file->path))
|
|
|
|
return NULL;
|
2009-08-22 20:12:05 -07:00
|
|
|
|
2010-05-19 07:47:12 -07:00
|
|
|
EVRY_PLUGIN_INSTANCE(p, plugin);
|
2010-05-03 12:19:42 -07:00
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
p->directory = eina_stringshare_add(file->path);
|
|
|
|
p->parent = EINA_TRUE;
|
2010-05-03 12:19:42 -07:00
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
_read_directory(p);
|
2010-05-03 12:19:42 -07:00
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
return EVRY_PLUGIN(p);
|
2010-05-03 12:19:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evry_Plugin *
|
|
|
|
_begin(Evry_Plugin *plugin, const Evry_Item *it)
|
|
|
|
{
|
|
|
|
Plugin *p = NULL;
|
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
if (it)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
const char *dir = NULL;
|
|
|
|
|
|
|
|
if ((CHECK_TYPE(it, EVRY_TYPE_FILE)) ||
|
|
|
|
(CHECK_SUBTYPE(it, EVRY_TYPE_FILE)))
|
|
|
|
{
|
|
|
|
/* browse */
|
|
|
|
GET_FILE(file, it);
|
|
|
|
if (!evry->file_path_get(file))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!ecore_file_is_dir(file->path))
|
|
|
|
{
|
|
|
|
char *tmp = ecore_file_dir_get(file->path);
|
|
|
|
dir = eina_stringshare_add(tmp);
|
|
|
|
E_FREE(tmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dir = eina_stringshare_add(file->path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* provide object */
|
|
|
|
if (!CHECK_TYPE(it, EVRY_TYPE_ACTION))
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dir)
|
|
|
|
dir = eina_stringshare_add(e_user_homedir_get());
|
|
|
|
|
|
|
|
EVRY_PLUGIN_INSTANCE(p, plugin);
|
|
|
|
p->directory = dir;
|
|
|
|
p->parent = EINA_FALSE;
|
|
|
|
p->min_query = 0;
|
|
|
|
_read_directory(p);
|
|
|
|
|
|
|
|
return EVRY_PLUGIN(p);
|
2009-08-21 15:42:06 -07:00
|
|
|
}
|
2010-05-06 07:54:19 -07:00
|
|
|
else
|
2009-08-21 15:42:06 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
/* provide subject */
|
|
|
|
EVRY_PLUGIN_INSTANCE(p, plugin);
|
|
|
|
p->parent = EINA_FALSE;
|
|
|
|
p->directory = eina_stringshare_add(e_user_homedir_get());
|
|
|
|
p->min_query = plugin->config->min_query;
|
|
|
|
_read_directory(p);
|
|
|
|
|
|
|
|
return EVRY_PLUGIN(p);
|
2010-05-06 07:54:19 -07:00
|
|
|
}
|
|
|
|
|
2010-10-28 13:57:11 -07:00
|
|
|
return NULL;
|
2010-05-06 07:54:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-05-15 19:56:40 -07:00
|
|
|
_folder_item_add(Plugin *p, const char *path, int prio)
|
2010-05-06 07:54:19 -07:00
|
|
|
{
|
|
|
|
Evry_Item_File *file;
|
|
|
|
|
2011-11-29 20:00:51 -08:00
|
|
|
file = EVRY_ITEM_NEW(Evry_Item_File, p, path, NULL, evry_item_file_free);
|
2010-05-06 07:54:19 -07:00
|
|
|
file->path = eina_stringshare_add(path);
|
|
|
|
file->mime = eina_stringshare_ref(_mime_dir);
|
|
|
|
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
2010-05-15 19:56:40 -07:00
|
|
|
EVRY_ITEM(file)->priority = prio;
|
|
|
|
EVRY_ITEM(file)->usage = -1;
|
2010-05-06 07:54:19 -07:00
|
|
|
p->files = eina_list_append(p->files, file);
|
|
|
|
EVRY_PLUGIN_ITEM_APPEND(p, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_free_files(Plugin *p)
|
|
|
|
{
|
|
|
|
Evry_Item_File *file;
|
|
|
|
|
2010-05-14 21:22:12 -07:00
|
|
|
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
2010-05-15 12:19:05 -07:00
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
if (p->thread)
|
|
|
|
ecore_thread_cancel(p->thread);
|
|
|
|
p->thread = NULL;
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (p->files, file)
|
2010-05-06 07:54:19 -07:00
|
|
|
EVRY_ITEM_FREE(file);
|
|
|
|
|
|
|
|
if (p->dir_mon)
|
|
|
|
ecore_file_monitor_del(p->dir_mon);
|
|
|
|
p->dir_mon = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_finish(Evry_Plugin *plugin)
|
|
|
|
{
|
|
|
|
GET_PLUGIN(p, plugin);
|
|
|
|
|
|
|
|
IF_RELEASE(p->input);
|
|
|
|
IF_RELEASE(p->directory);
|
|
|
|
|
|
|
|
if (p->thread)
|
2011-08-16 17:21:17 -07:00
|
|
|
p->waiting_to_finish = 1;
|
2010-05-06 07:54:19 -07:00
|
|
|
|
|
|
|
_free_files(p);
|
|
|
|
|
2011-08-16 17:21:17 -07:00
|
|
|
if (!p->waiting_to_finish)
|
2010-05-06 07:54:19 -07:00
|
|
|
E_FREE(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_fetch(Evry_Plugin *plugin, const char *input)
|
|
|
|
{
|
|
|
|
GET_PLUGIN(p, plugin);
|
2011-01-23 14:34:28 -08:00
|
|
|
unsigned int len = (input ? strlen(input) : 0);
|
2010-05-06 07:54:19 -07:00
|
|
|
|
|
|
|
if (!p->command)
|
|
|
|
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
|
|
|
|
|
|
|
IF_RELEASE(p->input);
|
|
|
|
|
2014-04-04 11:32:01 -07:00
|
|
|
if (!p->parent && input && (input[0] == '/'))
|
2010-05-06 07:54:19 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (p->command != CMD_SHOW_ROOT)
|
|
|
|
{
|
|
|
|
_free_files(p);
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2014-04-04 11:32:01 -07:00
|
|
|
eina_stringshare_replace(&p->directory, input);
|
2010-05-06 07:54:19 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
_read_directory(p);
|
2010-05-06 07:54:19 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
p->command = CMD_SHOW_ROOT;
|
2010-05-06 07:54:19 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
return 0;
|
|
|
|
}
|
2012-05-04 02:38:52 -07:00
|
|
|
int lendir = p->directory ? strlen(p->directory) : 0;
|
|
|
|
lendir = (lendir <= 1) ? lendir : lendir + 1;
|
2009-08-22 20:12:05 -07:00
|
|
|
|
2012-05-04 02:38:52 -07:00
|
|
|
p->input = eina_stringshare_add(input + lendir);
|
2010-05-06 07:54:19 -07:00
|
|
|
}
|
|
|
|
else if (p->directory && input && !strncmp(input, "..", 2))
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (p->command != CMD_SHOW_PARENT)
|
|
|
|
{
|
|
|
|
char *dir;
|
2012-08-26 05:01:05 -07:00
|
|
|
char buf[PATH_MAX+1];
|
2011-11-29 19:32:54 -08:00
|
|
|
int prio = 0;
|
2010-05-06 07:54:19 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (strncmp(p->directory, "/", 1))
|
|
|
|
return 0;
|
2010-05-15 12:19:05 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
_free_files(p);
|
2010-05-06 07:54:19 -07:00
|
|
|
|
2012-10-04 16:30:35 -07:00
|
|
|
strncpy(buf, p->directory, sizeof(buf) - 1);
|
2010-05-06 07:54:19 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
_folder_item_add(p, p->directory, prio++);
|
2010-05-06 07:54:19 -07:00
|
|
|
|
2012-10-04 16:30:35 -07:00
|
|
|
buf[sizeof(buf) - 1] = 0;
|
2011-11-29 19:32:54 -08:00
|
|
|
while (strlen(buf) > 1)
|
|
|
|
{
|
|
|
|
dir = dirname(buf);
|
|
|
|
_folder_item_add(p, dir, prio++);
|
2012-10-04 16:27:01 -07:00
|
|
|
strcpy(buf, dir);
|
2011-11-29 19:32:54 -08:00
|
|
|
}
|
2010-05-06 07:54:19 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
p->command = CMD_SHOW_PARENT;
|
|
|
|
}
|
|
|
|
return 1;
|
2010-05-06 07:54:19 -07:00
|
|
|
}
|
|
|
|
else if (p->directory && input && !strncmp(input, ".", 1))
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (p->command != CMD_SHOW_HIDDEN)
|
|
|
|
{
|
|
|
|
_free_files(p);
|
2010-05-06 07:54:19 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
p->show_hidden = EINA_TRUE;
|
|
|
|
_read_directory(p);
|
2010-05-06 07:54:19 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
p->command = CMD_SHOW_HIDDEN;
|
2010-05-06 07:54:19 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
p->input = eina_stringshare_add(input);
|
2010-05-03 12:19:42 -07:00
|
|
|
}
|
2010-05-06 07:54:19 -07:00
|
|
|
else if (p->command)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
/* clear command items */
|
|
|
|
_free_files(p);
|
2009-08-12 13:26:27 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (p->command == CMD_SHOW_ROOT)
|
|
|
|
{
|
|
|
|
IF_RELEASE(p->directory);
|
|
|
|
p->directory = eina_stringshare_add(e_user_homedir_get());
|
|
|
|
}
|
2010-05-06 07:54:19 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
p->command = CMD_NONE;
|
|
|
|
p->show_hidden = EINA_FALSE;
|
2010-05-06 07:54:19 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
_read_directory(p);
|
2010-05-06 07:54:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (input && !p->command)
|
|
|
|
p->input = eina_stringshare_add(input);
|
|
|
|
|
|
|
|
if ((p->command) || (!p->min_query) || (len >= p->min_query))
|
2010-11-13 05:33:12 -08:00
|
|
|
_files_filter(p);
|
2010-05-06 07:54:19 -07:00
|
|
|
|
2011-08-21 08:41:37 -07:00
|
|
|
return EVRY_PLUGIN_HAS_ITEMS(p);
|
2010-05-06 07:54:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/* recent files */
|
|
|
|
|
2010-05-06 08:48:31 -07:00
|
|
|
static int
|
|
|
|
_cb_sort_recent(const void *data1, const void *data2)
|
|
|
|
{
|
|
|
|
const Evry_Item *it1 = data1;
|
|
|
|
const Evry_Item *it2 = data2;
|
|
|
|
|
|
|
|
if (it1->browseable && !it2->browseable)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (!it1->browseable && it2->browseable)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (it1->hi && it2->hi)
|
2011-11-29 19:32:54 -08:00
|
|
|
return it1->hi->last_used > it2->hi->last_used ? -1 : 1;
|
2010-05-06 08:48:31 -07:00
|
|
|
|
|
|
|
if (it1->fuzzy_match && it2->fuzzy_match)
|
|
|
|
if (it1->fuzzy_match - it2->fuzzy_match)
|
2011-11-29 19:32:54 -08:00
|
|
|
return it1->fuzzy_match - it2->fuzzy_match;
|
2010-05-06 08:48:31 -07:00
|
|
|
|
|
|
|
return strcasecmp(it1->label, it2->label);
|
|
|
|
}
|
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
static int
|
2010-11-13 05:33:12 -08:00
|
|
|
_recentf_files_filter(Plugin *p)
|
2010-05-06 07:54:19 -07:00
|
|
|
{
|
|
|
|
int match;
|
|
|
|
int cnt = 0;
|
|
|
|
Evry_Item *it;
|
2010-05-06 08:48:31 -07:00
|
|
|
Eina_List *l, *new = NULL;
|
2010-05-06 07:54:19 -07:00
|
|
|
|
|
|
|
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (p->files, l, it)
|
2010-05-06 07:54:19 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (p->dirs_only && !it->browseable)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!p->input)
|
|
|
|
{
|
|
|
|
if (!it->browseable)
|
|
|
|
it->priority = 1;
|
|
|
|
new = eina_list_append(new, it);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (it->fuzzy_match <= 0)
|
|
|
|
{
|
|
|
|
if ((match = evry->fuzzy_match(it->label, p->input)) ||
|
|
|
|
(match = evry->fuzzy_match(EVRY_FILE(it)->path, p->input)))
|
|
|
|
it->fuzzy_match = match;
|
|
|
|
else
|
|
|
|
it->fuzzy_match = 0;
|
|
|
|
|
|
|
|
DBG("check match %d %s", it->fuzzy_match, it->label);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (it->fuzzy_match)
|
|
|
|
{
|
|
|
|
if (!it->browseable)
|
|
|
|
it->priority = 1;
|
|
|
|
new = eina_list_append(new, it);
|
|
|
|
}
|
2010-05-06 07:54:19 -07:00
|
|
|
}
|
|
|
|
|
2010-05-06 08:48:31 -07:00
|
|
|
new = eina_list_sort(new, -1, _cb_sort_recent);
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (new, it)
|
2010-05-06 08:48:31 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (cnt++ < MAX_SHOWN)
|
|
|
|
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
2010-05-06 08:48:31 -07:00
|
|
|
}
|
2010-05-06 07:54:19 -07:00
|
|
|
|
|
|
|
return cnt;
|
2009-06-21 03:31:38 -07:00
|
|
|
}
|
|
|
|
|
2010-05-15 12:19:05 -07:00
|
|
|
#if 0
|
2010-04-25 12:37:30 -07:00
|
|
|
/* use thread only to not block ui for ecore_file_exists ... */
|
2010-05-15 12:19:05 -07:00
|
|
|
|
2010-04-26 11:21:09 -07:00
|
|
|
static void
|
2010-05-06 07:54:19 -07:00
|
|
|
_recentf_func(void *data)
|
2010-04-26 11:21:09 -07:00
|
|
|
{
|
2010-05-06 06:09:14 -07:00
|
|
|
Data *d = data;
|
2010-04-29 14:42:03 -07:00
|
|
|
Eina_List *l;
|
2010-04-26 11:21:09 -07:00
|
|
|
Evry_Item_File *file;
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (d->files, l, file)
|
2010-04-26 11:21:09 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if ((!evry->file_path_get(file)) ||
|
|
|
|
(!ecore_file_exists(file->path)))
|
|
|
|
{
|
|
|
|
EVRY_ITEM(file)->hi->last_used -= ONE_DAY;
|
|
|
|
EVRY_ITEM(file)->hi = NULL;
|
|
|
|
}
|
2010-04-26 11:21:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-05-06 07:54:19 -07:00
|
|
|
_recentf_cancel_func(void *data)
|
2010-04-26 11:21:09 -07:00
|
|
|
{
|
2010-05-06 06:09:14 -07:00
|
|
|
Data *d = data;
|
|
|
|
Plugin *p = d->plugin;
|
2010-04-26 11:21:09 -07:00
|
|
|
Evry_Item_File *file;
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (d->files, file)
|
2011-08-16 17:21:17 -07:00
|
|
|
EVRY_ITEM_FREE(file);
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-05-06 06:09:14 -07:00
|
|
|
E_FREE(d);
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2011-08-16 17:21:17 -07:00
|
|
|
if (p->waiting_to_finish)
|
2010-05-06 06:09:14 -07:00
|
|
|
E_FREE(p);
|
2010-04-26 11:21:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-05-06 07:54:19 -07:00
|
|
|
_recentf_end_func(void *data)
|
2010-04-26 11:21:09 -07:00
|
|
|
{
|
2010-05-06 06:09:14 -07:00
|
|
|
Data *d = data;
|
|
|
|
Plugin *p = d->plugin;
|
2010-04-29 14:42:03 -07:00
|
|
|
Evry_Item *it;
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (d->files, it)
|
2010-04-26 11:21:09 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
GET_FILE(file, it);
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (!it->hi)
|
|
|
|
{
|
|
|
|
evry->item_free(it);
|
|
|
|
continue;
|
|
|
|
}
|
2010-04-29 14:42:03 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
_item_fill(file);
|
2010-05-03 18:19:16 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (!it->hi->data)
|
|
|
|
it->hi->data = eina_stringshare_ref(file->mime);
|
2010-05-03 18:19:16 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
p->files = eina_list_append(p->files, it);
|
2010-04-26 11:21:09 -07:00
|
|
|
}
|
|
|
|
|
2010-11-13 05:33:12 -08:00
|
|
|
_recentf_files_filter(p);
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-05-10 15:35:13 -07:00
|
|
|
EVRY_PLUGIN_UPDATE(p, EVRY_UPDATE_ADD);
|
2010-05-06 06:09:14 -07:00
|
|
|
|
|
|
|
p->thread = NULL;
|
|
|
|
E_FREE(d);
|
2010-04-26 11:21:09 -07:00
|
|
|
}
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2010-05-15 12:19:05 -07:00
|
|
|
#endif
|
2010-04-25 12:37:30 -07:00
|
|
|
|
2010-04-16 07:15:30 -07:00
|
|
|
static Eina_Bool
|
2011-01-23 14:34:28 -08:00
|
|
|
_recentf_items_add_cb(const Eina_Hash *hash __UNUSED__, const void *key, void *data, void *fdata)
|
2009-08-27 15:58:34 -07:00
|
|
|
{
|
2010-04-16 07:15:30 -07:00
|
|
|
History_Entry *he = data;
|
2010-04-29 14:42:03 -07:00
|
|
|
History_Item *hi = NULL, *hi2;
|
2010-04-16 11:36:28 -07:00
|
|
|
Eina_List *l, *ll;
|
2010-04-16 07:15:30 -07:00
|
|
|
Evry_Item_File *file;
|
2010-04-29 14:42:03 -07:00
|
|
|
double last_used = 0.0;
|
2010-05-06 06:09:14 -07:00
|
|
|
Data *d = fdata;
|
|
|
|
Plugin *p = d->plugin;
|
|
|
|
const char *label;
|
|
|
|
const char *path;
|
2010-05-06 07:54:19 -07:00
|
|
|
int match = 0;
|
2010-04-20 10:48:21 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (he->items, l, hi2)
|
2010-05-15 12:19:05 -07:00
|
|
|
if (hi2->last_used > last_used)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
last_used = hi2->last_used;
|
|
|
|
hi = hi2;
|
2010-05-15 12:19:05 -07:00
|
|
|
}
|
2010-04-17 05:40:28 -07:00
|
|
|
|
2010-04-29 14:42:03 -07:00
|
|
|
if (!hi)
|
|
|
|
return EINA_TRUE;
|
2010-04-20 10:48:21 -07:00
|
|
|
|
2010-05-01 16:03:14 -07:00
|
|
|
if (clear_cache)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
DBG("clear %s", (char *)key);
|
2010-05-02 13:40:21 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
/* transient marks them for deletion */
|
|
|
|
if (hi->count == 1)
|
|
|
|
{
|
|
|
|
hi->usage = 0;
|
|
|
|
hi->count = 0;
|
|
|
|
hi->transient = 1;
|
|
|
|
}
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
return EINA_TRUE;
|
2010-05-01 16:03:14 -07:00
|
|
|
}
|
|
|
|
|
2010-05-06 06:09:14 -07:00
|
|
|
if (hi->transient)
|
2010-05-01 16:03:14 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
|
2010-05-01 18:09:49 -07:00
|
|
|
if (!_conf->search_cache)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if ((hi->count == 1) && (hi->last_used < SIX_DAYS_AGO))
|
|
|
|
return EINA_TRUE;
|
2010-05-01 18:09:49 -07:00
|
|
|
}
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
path = (const char *)key;
|
2010-05-06 06:09:14 -07:00
|
|
|
|
|
|
|
if (!(label = ecore_file_file_get(path)))
|
|
|
|
return EINA_TRUE;
|
2010-05-01 16:03:14 -07:00
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
path = eina_stringshare_add(path);
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (p->files, ll, file)
|
2010-05-06 07:54:19 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (file->path == path)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(path);
|
|
|
|
EVRY_ITEM(file)->fuzzy_match = -1;
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-05-06 07:54:19 -07:00
|
|
|
}
|
2010-04-16 07:15:30 -07:00
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
/* searching subdirs */
|
2010-05-06 09:12:34 -07:00
|
|
|
if (p->directory)
|
2010-05-06 07:54:19 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
/* dont show recent files from same dir */
|
|
|
|
int len = strlen(p->directory);
|
|
|
|
char *end = strrchr(path, '/');
|
|
|
|
if (strncmp(path, p->directory, len) ||
|
|
|
|
(end - path) <= len)
|
|
|
|
{
|
|
|
|
/* DBG("not in dir %s", path); */
|
|
|
|
eina_stringshare_del(path);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-05-06 07:54:19 -07:00
|
|
|
}
|
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
if (!(match = evry->fuzzy_match(label, p->input)) &&
|
|
|
|
!(match = evry->fuzzy_match(path, p->input)))
|
2010-05-06 07:54:19 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
eina_stringshare_del(path);
|
|
|
|
return EINA_TRUE;
|
2010-05-06 07:54:19 -07:00
|
|
|
}
|
|
|
|
|
2011-11-29 20:00:51 -08:00
|
|
|
file = EVRY_ITEM_NEW(Evry_Item_File, p, label, NULL, evry_item_file_free);
|
2010-05-06 07:54:19 -07:00
|
|
|
file->path = path;
|
2010-04-16 07:15:30 -07:00
|
|
|
|
2010-04-29 14:42:03 -07:00
|
|
|
if (hi->data)
|
2010-05-15 12:19:05 -07:00
|
|
|
file->mime = eina_stringshare_add(hi->data);
|
2010-04-29 14:42:03 -07:00
|
|
|
|
2010-05-03 18:19:16 -07:00
|
|
|
EVRY_ITEM(file)->hi = hi;
|
2010-05-06 07:54:19 -07:00
|
|
|
EVRY_ITEM(file)->fuzzy_match = match;
|
2010-04-29 14:42:03 -07:00
|
|
|
EVRY_ITEM(file)->id = eina_stringshare_ref(file->path);
|
|
|
|
|
2010-05-15 12:19:05 -07:00
|
|
|
_item_fill(file);
|
|
|
|
|
|
|
|
if (!hi->data)
|
|
|
|
hi->data = eina_stringshare_ref(file->mime);
|
|
|
|
|
2010-05-06 06:09:14 -07:00
|
|
|
d->files = eina_list_append(d->files, file);
|
2010-04-16 11:36:28 -07:00
|
|
|
|
2010-05-15 12:19:05 -07:00
|
|
|
if (eina_list_count(d->files) > 100)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2010-04-16 07:15:30 -07:00
|
|
|
return EINA_TRUE;
|
2009-08-27 15:58:34 -07:00
|
|
|
}
|
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
static Evry_Plugin *
|
|
|
|
_recentf_browse(Evry_Plugin *plugin, const Evry_Item *it)
|
2010-04-25 12:37:30 -07:00
|
|
|
{
|
2010-05-06 07:54:19 -07:00
|
|
|
Plugin *p = NULL;
|
2010-04-25 12:37:30 -07:00
|
|
|
|
2010-05-19 07:47:12 -07:00
|
|
|
if (!it || !CHECK_TYPE(it, EVRY_TYPE_FILE))
|
2010-05-06 07:54:19 -07:00
|
|
|
return NULL;
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
GET_FILE(file, it);
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
if (!evry->file_path_get(file) ||
|
2010-05-06 07:54:19 -07:00
|
|
|
!ecore_file_is_dir(file->path))
|
|
|
|
return NULL;
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2010-05-21 23:35:46 -07:00
|
|
|
EVRY_PLUGIN_INSTANCE(p, plugin);
|
2010-05-06 07:54:19 -07:00
|
|
|
p->directory = eina_stringshare_add(file->path);
|
|
|
|
p->parent = EINA_TRUE;
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
return EVRY_PLUGIN(p);
|
2010-05-06 06:09:14 -07:00
|
|
|
}
|
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
static Evry_Plugin *
|
|
|
|
_recentf_begin(Evry_Plugin *plugin, const Evry_Item *it)
|
2010-05-06 06:09:14 -07:00
|
|
|
{
|
2010-05-06 07:54:19 -07:00
|
|
|
Plugin *p;
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
if (it && !CHECK_TYPE(it, EVRY_TYPE_ACTION))
|
|
|
|
return NULL;
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2010-05-19 07:47:12 -07:00
|
|
|
EVRY_PLUGIN_INSTANCE(p, plugin);
|
2010-05-06 07:54:19 -07:00
|
|
|
p->parent = EINA_FALSE;
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
if (it)
|
2010-05-06 06:09:14 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
/* provide object */
|
2010-05-06 06:09:14 -07:00
|
|
|
}
|
2010-05-06 07:54:19 -07:00
|
|
|
else
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
/* provide subject */
|
|
|
|
p->min_query = plugin->config->min_query;
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (clear_cache)
|
|
|
|
{
|
|
|
|
History_Types *ht = evry->history_types_get(EVRY_TYPE_FILE);
|
|
|
|
if (ht)
|
|
|
|
eina_hash_foreach(ht->types, _recentf_items_add_cb, p);
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
clear_cache = EINA_FALSE;
|
|
|
|
}
|
2010-05-06 07:54:19 -07:00
|
|
|
}
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
return EVRY_PLUGIN(p);
|
2010-05-06 06:09:14 -07:00
|
|
|
}
|
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
static int
|
2010-05-06 07:54:19 -07:00
|
|
|
_recentf_fetch(Evry_Plugin *plugin, const char *input)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2010-04-27 20:22:40 -07:00
|
|
|
GET_PLUGIN(p, plugin);
|
2009-08-22 20:12:05 -07:00
|
|
|
Evry_Item_File *file;
|
2010-05-06 07:54:19 -07:00
|
|
|
History_Types *ht;
|
2012-05-04 02:38:52 -07:00
|
|
|
int len = (input ? strlen(input) : 0);
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-05-06 06:09:14 -07:00
|
|
|
IF_RELEASE(p->input);
|
2009-08-27 15:58:34 -07:00
|
|
|
|
2010-05-15 12:19:05 -07:00
|
|
|
/* if (p->thread)
|
|
|
|
* ecore_thread_cancel(p->thread);
|
|
|
|
* p->thread = NULL; */
|
2010-05-06 08:48:31 -07:00
|
|
|
|
|
|
|
if (input && isspace(input[len - 1]))
|
2011-08-21 08:41:37 -07:00
|
|
|
return EVRY_PLUGIN_HAS_ITEMS(p);
|
2010-05-06 08:48:31 -07:00
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
if (len >= plugin->config->min_query)
|
2009-07-10 07:08:06 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (input)
|
|
|
|
p->input = eina_stringshare_add(input);
|
|
|
|
|
|
|
|
if ((ht = evry->history_types_get(EVRY_TYPE_FILE)))
|
|
|
|
{
|
|
|
|
Data *d = E_NEW(Data, 1);
|
|
|
|
d->plugin = p;
|
|
|
|
eina_hash_foreach(ht->types, _recentf_items_add_cb, d);
|
|
|
|
EINA_LIST_FREE (d->files, file)
|
|
|
|
p->files = eina_list_append(p->files, file);
|
|
|
|
E_FREE(d);
|
|
|
|
|
|
|
|
_recentf_files_filter(p);
|
|
|
|
|
|
|
|
/* _recentf_end_func(d);
|
|
|
|
* p->thread = NULL; */
|
|
|
|
/* p->thread = ecore_thread_run(_recentf_func, _recentf_end_func,
|
|
|
|
* _recentf_cancel_func, d); */
|
|
|
|
}
|
|
|
|
return EVRY_PLUGIN_HAS_ITEMS(p);
|
2009-07-10 07:08:06 -07:00
|
|
|
}
|
2009-08-11 06:31:38 -07:00
|
|
|
|
2010-05-06 08:48:31 -07:00
|
|
|
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
return 0;
|
2009-06-21 03:31:38 -07:00
|
|
|
}
|
|
|
|
|
2010-05-06 07:54:19 -07:00
|
|
|
/***************************************************************************/
|
|
|
|
/* actions */
|
|
|
|
|
2009-08-15 21:08:35 -07:00
|
|
|
static int
|
|
|
|
_open_folder_check(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
|
|
|
{
|
2011-11-29 19:32:54 -08: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
|
|
|
{
|
2010-04-29 08:20:12 -07:00
|
|
|
E_Action *action;
|
2009-08-15 21:08:35 -07:00
|
|
|
Eina_List *m;
|
2010-04-29 08:20:12 -07:00
|
|
|
char *dir;
|
2010-04-29 14:42:03 -07:00
|
|
|
|
2010-04-29 08:20:12 -07:00
|
|
|
if (!(action = e_action_find("fileman")))
|
|
|
|
return 0;
|
2009-08-15 21:47:43 -07:00
|
|
|
|
2010-04-28 05:58:24 -07:00
|
|
|
GET_FILE(file, act->it1.item);
|
2010-04-29 14:42:03 -07:00
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
if (!(evry->file_path_get(file)))
|
2010-04-29 08:20:12 -07:00
|
|
|
return 0;
|
2010-04-29 14:42:03 -07:00
|
|
|
|
2010-04-29 08:20:12 -07:00
|
|
|
m = e_manager_list();
|
2009-08-22 20:12:05 -07:00
|
|
|
|
2010-04-29 08:20:12 -07:00
|
|
|
if (!IS_BROWSEABLE(file))
|
2009-08-15 21:47:43 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
dir = ecore_file_dir_get(file->path);
|
|
|
|
if (!dir) return 0;
|
|
|
|
action->func.go(E_OBJECT(m->data), dir);
|
|
|
|
free(dir);
|
2009-08-15 21:47:43 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
action->func.go(E_OBJECT(m->data), file->path);
|
2009-08-15 21:47:43 -07:00
|
|
|
}
|
2009-08-15 21:08:35 -07:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-04-25 09:26:13 -07:00
|
|
|
static int
|
|
|
|
_file_trash_action(Evry_Action *act)
|
|
|
|
{
|
2010-04-29 08:20:12 -07:00
|
|
|
Efreet_Uri *euri;
|
2010-04-26 11:21:09 -07:00
|
|
|
int ok = 0;
|
2010-04-27 20:22:40 -07:00
|
|
|
int force = (EVRY_ITEM_DATA_INT_GET(act) == ACT_DELETE);
|
2010-04-29 14:42:03 -07:00
|
|
|
|
2010-04-28 05:58:24 -07:00
|
|
|
GET_FILE(file, act->it1.item);
|
2010-04-25 09:26:13 -07:00
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
if (!(evry->file_url_get(file)))
|
2010-04-29 08:20:12 -07:00
|
|
|
return 0;
|
2010-04-25 18:04:43 -07:00
|
|
|
|
2010-04-29 08:20:12 -07:00
|
|
|
euri = efreet_uri_decode(file->url);
|
2010-04-29 14:42:03 -07:00
|
|
|
|
2010-04-29 08:20:12 -07:00
|
|
|
if (euri)
|
2010-04-25 09:26:13 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
ok = efreet_trash_delete_uri(euri, force);
|
|
|
|
efreet_uri_free(euri);
|
2010-04-25 09:26:13 -07:00
|
|
|
}
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
return ok > 0;
|
2010-04-25 09:26:13 -07:00
|
|
|
}
|
|
|
|
|
2010-04-25 12:37:30 -07:00
|
|
|
static int
|
|
|
|
_file_copy_action(Evry_Action *act)
|
|
|
|
{
|
2010-04-29 08:20:12 -07:00
|
|
|
GET_FILE(src, act->it1.item);
|
2010-04-28 05:58:24 -07:00
|
|
|
GET_FILE(dst, act->it2.item);
|
2010-04-25 12:37:30 -07:00
|
|
|
|
|
|
|
char buf[PATH_MAX];
|
2010-04-29 08:20:12 -07:00
|
|
|
char *ddst;
|
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
if (!(evry->file_path_get(src)))
|
2010-04-29 08:20:12 -07:00
|
|
|
return 0;
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
if (!(evry->file_path_get(dst)))
|
2010-04-29 08:20:12 -07:00
|
|
|
return 0;
|
2010-04-29 14:42:03 -07:00
|
|
|
|
2010-04-25 12:37:30 -07:00
|
|
|
if (!ecore_file_is_dir(dst->path))
|
2010-04-29 08:20:12 -07:00
|
|
|
ddst = ecore_file_dir_get(dst->path);
|
2010-04-25 12:37:30 -07:00
|
|
|
else
|
2010-04-29 08:20:12 -07:00
|
|
|
ddst = strdup(dst->path);
|
|
|
|
if (!ddst)
|
|
|
|
return 0;
|
2010-04-29 14:42:03 -07:00
|
|
|
|
2010-04-29 08:20:12 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", ddst, ecore_file_file_get(src->path));
|
|
|
|
free(ddst);
|
2010-04-25 12:37:30 -07:00
|
|
|
|
2010-04-29 08:20:12 -07:00
|
|
|
DBG(" %s -> %s\n", src->path, buf);
|
2010-04-29 14:42:03 -07:00
|
|
|
|
2010-04-27 20:22:40 -07:00
|
|
|
if (EVRY_ITEM_DATA_INT_GET(act) == ACT_COPY)
|
2010-04-25 12:37:30 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
return ecore_file_cp(src->path, buf);
|
2010-04-25 12:37:30 -07:00
|
|
|
}
|
2010-04-27 20:22:40 -07:00
|
|
|
else if (EVRY_ITEM_DATA_INT_GET(act) == ACT_MOVE)
|
2010-04-25 12:37:30 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
return ecore_file_mv(src->path, buf);
|
2010-04-25 12:37:30 -07:00
|
|
|
}
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-04-29 08:20:12 -07:00
|
|
|
return 0;
|
2010-04-25 12:37:30 -07:00
|
|
|
}
|
|
|
|
|
2010-05-24 05:27:10 -07:00
|
|
|
static void
|
|
|
|
_sort_by_date(Plugin *p)
|
2010-05-23 06:54:44 -07:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Evry_Item_File *file;
|
|
|
|
struct stat s;
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (p->files, l, file)
|
2010-05-23 06:54:44 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (file->modified)
|
|
|
|
continue;
|
2010-05-23 06:54:44 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
if (lstat(file->path, &s) == 0)
|
|
|
|
file->modified = s.st_mtime;
|
2010-05-23 06:54:44 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EVRY_ITEM(file)->usage = -1;
|
2010-05-24 05:27:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
p->files = eina_list_sort(p->files, -1, _cb_sort_date);
|
2010-11-13 05:33:12 -08:00
|
|
|
_files_filter(p);
|
2010-05-24 05:27:10 -07:00
|
|
|
|
|
|
|
EVRY_PLUGIN_UPDATE(p, EVRY_UPDATE_ADD);
|
|
|
|
}
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2010-05-24 05:27:10 -07:00
|
|
|
static void
|
|
|
|
_sort_by_name(Plugin *p)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Evry_Item *it;
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FOREACH (p->files, l, it)
|
2010-05-24 05:27:10 -07:00
|
|
|
it->usage = 0;
|
|
|
|
|
|
|
|
p->files = eina_list_sort(p->files, -1, _cb_sort);
|
2010-11-13 05:33:12 -08:00
|
|
|
_files_filter(p);
|
2010-05-24 05:27:10 -07:00
|
|
|
|
|
|
|
EVRY_PLUGIN_UPDATE(p, EVRY_UPDATE_ADD);
|
|
|
|
}
|
2010-05-23 06:54:44 -07:00
|
|
|
|
2010-05-24 05:27:10 -07:00
|
|
|
static int
|
|
|
|
_file_sort_action(Evry_Action *act)
|
|
|
|
{
|
|
|
|
GET_PLUGIN(p, act->it1.item);
|
|
|
|
if (!p) return 0;
|
|
|
|
|
|
|
|
if (EVRY_ITEM_DATA_INT_GET(act) == ACT_SORT_DATE)
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
_sort_by_date(p);
|
2010-05-23 06:54:44 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
_sort_by_name(p);
|
2010-05-24 05:27:10 -07:00
|
|
|
}
|
2010-05-23 06:54:44 -07:00
|
|
|
|
2010-05-24 05:27:10 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_cb_key_down(Evry_Plugin *plugin, const Ecore_Event_Key *ev)
|
|
|
|
{
|
|
|
|
GET_PLUGIN(p, plugin);
|
2010-05-23 06:54:44 -07:00
|
|
|
|
2010-05-24 05:27:10 -07:00
|
|
|
if (!strcmp(ev->key, "F1"))
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
_sort_by_name(p);
|
|
|
|
return 1;
|
2010-05-24 05:27:10 -07:00
|
|
|
}
|
|
|
|
if (!strcmp(ev->key, "F2"))
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
_sort_by_date(p);
|
|
|
|
return 1;
|
2010-05-23 06:54:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
static int
|
2011-08-12 04:41:15 -07:00
|
|
|
_plugins_init(const Evry_API *api)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2010-05-23 06:54:44 -07:00
|
|
|
Evry_Action *act, *act_sort_date, *act_sort_name;
|
2010-05-06 06:09:14 -07:00
|
|
|
Evry_Plugin *p;
|
|
|
|
int prio = 0;
|
2011-11-29 20:54:52 -08:00
|
|
|
const char *config_path;
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2011-08-12 04:41:15 -07:00
|
|
|
evry = api;
|
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
if (!evry->api_version_check(EVRY_API_VERSION))
|
2010-04-08 04:55:15 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
|
2011-11-29 20:54:52 -08:00
|
|
|
config_path = eina_stringshare_add("launcher/everything-files");
|
2011-11-29 19:32:54 -08:00
|
|
|
_mime_dir = eina_stringshare_add("inode/directory");
|
|
|
|
_mime_mount = eina_stringshare_add("inode/mountpoint");
|
2010-06-04 15:57:58 -07:00
|
|
|
_mime_unknown = eina_stringshare_add("unknown");
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
#define ACTION_NEW(_name, _type2, _icon, _act, _check, _register) \
|
|
|
|
act = EVRY_ACTION_NEW(_name, EVRY_TYPE_FILE, _type2, _icon, _act, _check); \
|
|
|
|
if (_register) evry->action_register(act, prio++); \
|
|
|
|
_actions = eina_list_append(_actions, act); \
|
2010-05-23 06:54:44 -07:00
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
ACTION_NEW(N_("Copy To ..."), EVRY_TYPE_FILE, "go-next",
|
2011-11-29 19:32:54 -08:00
|
|
|
_file_copy_action, NULL, 1);
|
2010-05-23 06:54:44 -07:00
|
|
|
act->it2.subtype = EVRY_TYPE_DIR;
|
|
|
|
EVRY_ITEM_DATA_INT_SET(act, ACT_COPY);
|
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
ACTION_NEW(N_("Move To ..."), EVRY_TYPE_FILE, "go-next",
|
2011-11-29 19:32:54 -08:00
|
|
|
_file_copy_action, NULL, 1);
|
2010-05-23 06:54:44 -07:00
|
|
|
act->it2.subtype = EVRY_TYPE_DIR;
|
|
|
|
EVRY_ITEM_DATA_INT_SET(act, ACT_MOVE);
|
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
ACTION_NEW(N_("Move to Trash"), 0, "user-trash",
|
2011-11-29 19:32:54 -08:00
|
|
|
_file_trash_action, NULL, 1);
|
2010-05-23 06:54:44 -07:00
|
|
|
EVRY_ITEM_DATA_INT_SET(act, ACT_TRASH);
|
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
ACTION_NEW(N_("Open Directory"), 0, "folder-open",
|
2011-11-29 19:32:54 -08:00
|
|
|
_open_folder_action, _open_folder_check, 1);
|
2010-05-23 06:54:44 -07:00
|
|
|
act->remember_context = EINA_TRUE;
|
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
ACTION_NEW(N_("Sort by Date"), 0, "go-up",
|
2011-11-29 19:32:54 -08:00
|
|
|
_file_sort_action, NULL, 0);
|
2010-05-23 06:54:44 -07:00
|
|
|
EVRY_ITEM_DATA_INT_SET(act, ACT_SORT_DATE);
|
|
|
|
act_sort_date = act;
|
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
ACTION_NEW(N_("Sort by Name"), 0, "go-up",
|
2011-11-29 19:32:54 -08:00
|
|
|
_file_sort_action, NULL, 0);
|
2010-05-23 06:54:44 -07:00
|
|
|
EVRY_ITEM_DATA_INT_SET(act, ACT_SORT_NAME);
|
|
|
|
act_sort_name = act;
|
|
|
|
|
|
|
|
#undef ACTION_NEW
|
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
p = EVRY_PLUGIN_BASE(N_("Files"), _module_icon, EVRY_TYPE_FILE,
|
2011-11-29 19:32:54 -08:00
|
|
|
_begin, _finish, _fetch);
|
2010-05-20 08:41:27 -07:00
|
|
|
p->input_type = EVRY_TYPE_FILE;
|
2010-05-24 05:27:10 -07:00
|
|
|
p->cb_key_down = &_cb_key_down;
|
2011-08-12 10:18:25 -07:00
|
|
|
p->browse = &_browse;
|
2011-11-29 20:54:52 -08:00
|
|
|
p->config_path = eina_stringshare_ref(config_path);
|
2010-05-23 06:54:44 -07:00
|
|
|
p->actions = eina_list_append(p->actions, act_sort_date);
|
|
|
|
p->actions = eina_list_append(p->actions, act_sort_name);
|
2011-08-12 10:18:25 -07:00
|
|
|
_plugins = eina_list_append(_plugins, p);
|
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
if (evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 2))
|
2010-05-06 06:09:14 -07:00
|
|
|
p->config->min_query = 1;
|
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
p = EVRY_PLUGIN_BASE(N_("Files"), _module_icon, EVRY_TYPE_FILE,
|
2011-11-29 19:32:54 -08:00
|
|
|
_begin, _finish, _fetch);
|
2010-05-24 05:27:10 -07:00
|
|
|
p->cb_key_down = &_cb_key_down;
|
2011-08-12 10:18:25 -07:00
|
|
|
p->browse = &_browse;
|
2011-11-29 20:54:52 -08:00
|
|
|
p->config_path = eina_stringshare_ref(config_path);
|
2010-05-23 06:54:44 -07:00
|
|
|
p->actions = eina_list_append(p->actions, act_sort_date);
|
|
|
|
p->actions = eina_list_append(p->actions, act_sort_name);
|
2011-08-12 10:18:25 -07:00
|
|
|
_plugins = eina_list_append(_plugins, p);
|
2010-05-11 10:24:38 -07:00
|
|
|
evry->plugin_register(p, EVRY_PLUGIN_OBJECT, 2);
|
2010-05-06 06:09:14 -07:00
|
|
|
|
2011-08-12 10:18:25 -07:00
|
|
|
if (!_conf->show_recent && !_conf->search_recent)
|
|
|
|
return EINA_TRUE;
|
2010-05-15 12:19:05 -07:00
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
p = EVRY_PLUGIN_BASE(N_("Recent Files"), _module_icon, EVRY_TYPE_FILE,
|
2011-11-29 19:32:54 -08:00
|
|
|
_recentf_begin, _finish, _recentf_fetch);
|
2011-08-12 10:18:25 -07:00
|
|
|
p->browse = &_recentf_browse;
|
2011-11-29 20:54:52 -08:00
|
|
|
p->config_path = eina_stringshare_ref(config_path);
|
2010-05-21 23:35:46 -07:00
|
|
|
|
2011-08-12 10:18:25 -07:00
|
|
|
if (evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 3))
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
p->config->top_level = EINA_FALSE;
|
|
|
|
p->config->min_query = 3;
|
2010-05-06 07:54:19 -07:00
|
|
|
}
|
2011-08-31 05:57:07 -07:00
|
|
|
_plugins = eina_list_append(_plugins, p);
|
2011-11-29 19:32:54 -08:00
|
|
|
|
2013-01-05 14:53:46 -08:00
|
|
|
p = EVRY_PLUGIN_BASE(N_("Recent Files"), _module_icon, EVRY_TYPE_FILE,
|
2011-11-29 19:32:54 -08:00
|
|
|
_recentf_begin, _finish, _recentf_fetch);
|
2011-08-12 10:18:25 -07:00
|
|
|
p->browse = &_recentf_browse;
|
2011-11-29 20:54:52 -08:00
|
|
|
p->config_path = eina_stringshare_ref(config_path);
|
2011-08-12 10:18:25 -07:00
|
|
|
|
|
|
|
if (evry->plugin_register(p, EVRY_PLUGIN_OBJECT, 3))
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
p->config->top_level = EINA_FALSE;
|
|
|
|
p->config->min_query = 3;
|
2011-08-12 10:18:25 -07:00
|
|
|
}
|
2011-08-31 05:57:07 -07:00
|
|
|
_plugins = eina_list_append(_plugins, p);
|
2011-11-29 20:54:52 -08:00
|
|
|
eina_stringshare_del(config_path);
|
2011-11-29 19:32:54 -08:00
|
|
|
|
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
|
2010-04-24 16:07:13 -07:00
|
|
|
_plugins_shutdown(void)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2010-04-25 12:37:30 -07:00
|
|
|
Evry_Action *act;
|
2010-05-06 06:09:14 -07:00
|
|
|
Evry_Plugin *p;
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-05-11 10:24:38 -07:00
|
|
|
eina_stringshare_del(_mime_dir);
|
|
|
|
eina_stringshare_del(_mime_mount);
|
2010-06-04 14:55:40 -07:00
|
|
|
eina_stringshare_del(_mime_unknown);
|
2010-05-11 10:24:38 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (_plugins, p)
|
2010-05-23 06:54:44 -07:00
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
if (p->actions)
|
|
|
|
eina_list_free(p->actions);
|
|
|
|
EVRY_PLUGIN_FREE(p);
|
2010-05-23 06:54:44 -07:00
|
|
|
}
|
2009-08-21 15:42:06 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
EINA_LIST_FREE (_actions, act)
|
2010-05-11 10:24:38 -07:00
|
|
|
evry->action_free(act);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2009-08-11 06:31:38 -07:00
|
|
|
|
2010-04-10 13:05:57 -07:00
|
|
|
/***************************************************************************/
|
2010-04-16 11:36:28 -07:00
|
|
|
|
2010-04-20 10:48:21 -07:00
|
|
|
static E_Config_DD *conf_edd = NULL;
|
|
|
|
|
|
|
|
struct _E_Config_Dialog_Data
|
|
|
|
{
|
2011-11-29 19:32:54 -08:00
|
|
|
int show_homedir;
|
|
|
|
int show_recent;
|
|
|
|
int search_recent;
|
|
|
|
int search_cache;
|
|
|
|
int cache_dirs;
|
2010-04-20 10:48:21 -07:00
|
|
|
};
|
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
static void *_create_data(E_Config_Dialog *cfd);
|
|
|
|
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
|
|
|
static void _fill_data(E_Config_Dialog_Data *cfdata);
|
2010-04-20 10:48:21 -07:00
|
|
|
static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
2011-11-29 19:32:54 -08:00
|
|
|
static int _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
2010-04-20 10:48:21 -07:00
|
|
|
|
|
|
|
static E_Config_Dialog *
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
_conf_dialog(E_Comp *comp, const char *params __UNUSED__)
|
2010-04-20 10:48:21 -07:00
|
|
|
{
|
|
|
|
E_Config_Dialog *cfd = NULL;
|
|
|
|
E_Config_Dialog_View *v = NULL;
|
|
|
|
|
|
|
|
if (e_config_dialog_find("everything-files", "extensions/everything-files")) return NULL;
|
|
|
|
|
|
|
|
v = E_NEW(E_Config_Dialog_View, 1);
|
|
|
|
if (!v) return NULL;
|
|
|
|
|
|
|
|
v->create_cfdata = _create_data;
|
|
|
|
v->free_cfdata = _free_data;
|
|
|
|
v->basic.create_widgets = _basic_create;
|
|
|
|
v->basic.apply_cfdata = _basic_apply;
|
|
|
|
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
cfd = e_config_dialog_new(comp, _("Everything Files"), "everything-files",
|
2011-11-29 19:32:54 -08:00
|
|
|
"extensions/everything-files", _module_icon, 0, v, NULL);
|
2010-04-20 10:48:21 -07:00
|
|
|
|
|
|
|
_conf->cfd = cfd;
|
|
|
|
return cfd;
|
|
|
|
}
|
|
|
|
|
2010-05-01 16:03:14 -07:00
|
|
|
static void
|
2011-01-23 14:34:28 -08:00
|
|
|
_clear_cache_cb(void *data __UNUSED__, void *data2 __UNUSED__)
|
2010-05-01 16:03:14 -07:00
|
|
|
{
|
|
|
|
clear_cache = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2010-04-20 10:48:21 -07:00
|
|
|
static Evas_Object *
|
2011-01-23 14:34:28 -08:00
|
|
|
_basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
|
2010-04-20 10:48:21 -07:00
|
|
|
{
|
|
|
|
Evas_Object *o = NULL, *of = NULL, *ow = NULL;
|
|
|
|
|
|
|
|
o = e_widget_list_add(evas, 0, 0);
|
|
|
|
|
|
|
|
of = e_widget_framelist_add(evas, _("General"), 0);
|
|
|
|
e_widget_framelist_content_align_set(of, 0.0, 0.0);
|
|
|
|
|
2010-10-14 07:25:12 -07:00
|
|
|
/* ow = e_widget_check_add(evas, _("Show home directory"),
|
2011-11-29 19:32:54 -08:00
|
|
|
* &(cfdata->show_homedir));
|
2010-10-14 07:25:12 -07:00
|
|
|
* e_widget_framelist_object_append(of, ow); */
|
2010-04-20 10:48:21 -07:00
|
|
|
|
2010-05-01 16:03:14 -07:00
|
|
|
ow = e_widget_check_add(evas, _("Show recent files"),
|
2011-11-29 19:32:54 -08:00
|
|
|
&(cfdata->show_recent));
|
2010-04-20 10:48:21 -07:00
|
|
|
e_widget_framelist_object_append(of, ow);
|
|
|
|
|
2010-05-01 16:03:14 -07:00
|
|
|
ow = e_widget_check_add(evas, _("Search recent files"),
|
2011-11-29 19:32:54 -08:00
|
|
|
&(cfdata->search_recent));
|
2010-04-20 10:48:21 -07:00
|
|
|
e_widget_framelist_object_append(of, ow);
|
|
|
|
|
2010-05-01 18:09:49 -07:00
|
|
|
ow = e_widget_check_add(evas, _("Search cached files"),
|
2011-11-29 19:32:54 -08:00
|
|
|
&(cfdata->search_cache));
|
2010-05-01 18:09:49 -07:00
|
|
|
e_widget_framelist_object_append(of, ow);
|
|
|
|
|
2010-05-01 16:03:14 -07:00
|
|
|
ow = e_widget_check_add(evas, _("Cache visited directories"),
|
2011-11-29 19:32:54 -08:00
|
|
|
&(cfdata->cache_dirs));
|
2010-05-01 16:03:14 -07:00
|
|
|
e_widget_framelist_object_append(of, ow);
|
|
|
|
|
|
|
|
ow = e_widget_button_add(evas, _("Clear cache"), NULL,
|
2011-11-29 19:32:54 -08:00
|
|
|
_clear_cache_cb,
|
|
|
|
NULL, NULL);
|
2010-05-01 16:03:14 -07:00
|
|
|
e_widget_framelist_object_append(of, ow);
|
|
|
|
|
2010-04-20 10:48:21 -07:00
|
|
|
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
2011-01-23 14:34:28 -08:00
|
|
|
_create_data(E_Config_Dialog *cfd __UNUSED__)
|
2011-11-29 19:32:54 -08:00
|
|
|
{
|
|
|
|
E_Config_Dialog_Data *cfdata = NULL;
|
2010-04-20 10:48:21 -07:00
|
|
|
|
2011-11-29 19:32:54 -08:00
|
|
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
|
|
|
_fill_data(cfdata);
|
|
|
|
return cfdata;
|
|
|
|
}
|
2010-04-20 10:48:21 -07:00
|
|
|
|
|
|
|
static void
|
2011-01-23 14:34:28 -08:00
|
|
|
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
2010-04-20 10:48:21 -07:00
|
|
|
{
|
|
|
|
_conf->cfd = NULL;
|
|
|
|
E_FREE(cfdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_fill_data(E_Config_Dialog_Data *cfdata)
|
|
|
|
{
|
|
|
|
#define C(_name) cfdata->_name = _conf->_name;
|
|
|
|
C(show_homedir);
|
|
|
|
C(show_recent);
|
|
|
|
C(search_recent);
|
2010-05-01 18:09:49 -07:00
|
|
|
C(search_cache);
|
2010-05-01 16:03:14 -07:00
|
|
|
C(cache_dirs);
|
2010-04-20 10:48:21 -07:00
|
|
|
#undef C
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-01-23 14:34:28 -08:00
|
|
|
_basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
2010-04-20 10:48:21 -07:00
|
|
|
{
|
|
|
|
#define C(_name) _conf->_name = cfdata->_name;
|
|
|
|
C(show_homedir);
|
|
|
|
C(show_recent);
|
|
|
|
C(search_recent);
|
2010-05-01 18:09:49 -07:00
|
|
|
C(search_cache);
|
2010-05-01 16:03:14 -07:00
|
|
|
C(cache_dirs);
|
2010-04-20 10:48:21 -07:00
|
|
|
#undef C
|
|
|
|
|
|
|
|
e_config_domain_save("module.everything-files", conf_edd, _conf);
|
|
|
|
e_config_save_queue();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_conf_new(void)
|
|
|
|
{
|
|
|
|
_conf = E_NEW(Module_Config, 1);
|
2012-12-21 15:57:05 -08:00
|
|
|
_conf->show_recent = 0;
|
|
|
|
_conf->show_homedir = 1;
|
|
|
|
_conf->search_recent = 1;
|
|
|
|
_conf->cache_dirs = 0;
|
|
|
|
_conf->search_cache = 0;
|
2010-04-20 10:48:21 -07:00
|
|
|
|
2012-12-21 15:57:05 -08:00
|
|
|
_conf->version = MOD_CONFIG_FILE_VERSION;
|
2010-04-20 10:48:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_conf_free(void)
|
|
|
|
{
|
|
|
|
E_FREE(_conf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_conf_init(E_Module *m)
|
|
|
|
{
|
2011-04-08 15:16:59 -07:00
|
|
|
char title[4096];
|
2010-04-20 10:48:21 -07:00
|
|
|
|
2011-04-08 15:16:59 -07:00
|
|
|
snprintf(title, sizeof(title), "%s: %s", _("Everything Plugin"), _("Files"));
|
|
|
|
|
2011-04-08 16:03:12 -07:00
|
|
|
e_configure_registry_item_add("launcher/everything-files", 110, title,
|
2011-11-29 19:32:54 -08:00
|
|
|
NULL, _module_icon, _conf_dialog);
|
2010-04-20 10:48:21 -07:00
|
|
|
|
|
|
|
conf_edd = E_CONFIG_DD_NEW("Module_Config", Module_Config);
|
2010-04-26 11:21:09 -07:00
|
|
|
|
2010-04-20 10:48:21 -07:00
|
|
|
#undef T
|
|
|
|
#undef D
|
|
|
|
#define T Module_Config
|
|
|
|
#define D conf_edd
|
|
|
|
E_CONFIG_VAL(D, T, version, INT);
|
|
|
|
E_CONFIG_VAL(D, T, show_homedir, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, show_recent, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, search_recent, UCHAR);
|
2010-05-01 18:09:49 -07:00
|
|
|
E_CONFIG_VAL(D, T, search_cache, UCHAR);
|
2010-05-01 16:03:14 -07:00
|
|
|
E_CONFIG_VAL(D, T, cache_dirs, UCHAR);
|
2010-04-20 10:48:21 -07:00
|
|
|
#undef T
|
|
|
|
#undef D
|
|
|
|
|
|
|
|
_conf = e_config_domain_load("module.everything-files", conf_edd);
|
|
|
|
|
2011-08-31 05:57:07 -07:00
|
|
|
if (_conf && !e_util_module_config_check(_("Everything Files"),
|
2011-11-29 19:32:54 -08:00
|
|
|
_conf->version,
|
|
|
|
MOD_CONFIG_FILE_VERSION))
|
|
|
|
_conf_free();
|
2010-04-20 10:48:21 -07:00
|
|
|
|
|
|
|
if (!_conf) _conf_new();
|
|
|
|
|
|
|
|
_conf->module = m;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_conf_shutdown(void)
|
|
|
|
{
|
2011-04-08 16:03:12 -07:00
|
|
|
e_configure_registry_item_del("launcher/everything-files");
|
2011-08-12 10:18:25 -07:00
|
|
|
|
2010-04-20 10:48:21 -07:00
|
|
|
E_FREE(_conf);
|
|
|
|
E_CONFIG_DD_FREE(conf_edd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2011-04-08 15:16:59 -07:00
|
|
|
Eina_Bool
|
|
|
|
evry_plug_files_init(E_Module *m)
|
|
|
|
{
|
|
|
|
_conf_init(m);
|
|
|
|
|
2011-08-12 04:41:15 -07:00
|
|
|
EVRY_MODULE_NEW(evry_module, evry, _plugins_init, _plugins_shutdown);
|
2011-04-08 15:16:59 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evry_plug_files_shutdown(void)
|
|
|
|
{
|
|
|
|
EVRY_MODULE_FREE(evry_module);
|
|
|
|
|
|
|
|
_conf_shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evry_plug_files_save(void)
|
|
|
|
{
|
|
|
|
e_config_domain_save("module.everything-files", conf_edd, _conf);
|
|
|
|
}
|
2011-11-29 19:32:54 -08:00
|
|
|
|