'everything' files: show root dir directly on /

- added ctrl|shift+Tab binding for browsing into items.


SVN revision: 48019
This commit is contained in:
Hannes Janetzek 2010-04-15 13:58:44 +00:00
parent 1ac2bb559a
commit 2baae5916b
4 changed files with 102 additions and 63 deletions

View File

@ -21,10 +21,12 @@ struct _Plugin
/* current list of files */
Eina_List *cur;
Eina_Bool command;
Eina_Bool parent;
const char *input;
Ecore_Thread *thread;
Eina_Bool cleanup;
};
struct _Data
@ -41,8 +43,12 @@ static Evry_Plugin *p2 = NULL;
static Evry_Action *act1 = NULL;
static Evry_Action *act2 = NULL;
static E_Module *module = NULL;
static Eina_Bool active = EINA_FALSE;
static const char *mime_folder = NULL;
static void _cleanup(Evry_Plugin *plugin);
static void
_item_fill(Evry_Item_File *file)
@ -191,12 +197,10 @@ _scan_cancel_func(void *data)
if (p->directory)
eina_stringshare_del(p->directory);
EINA_LIST_FREE(p->files, file)
evry_item_free(EVRY_ITEM(file));
EVRY_PLUGIN_ITEMS_CLEAR(p);
E_FREE(p);
p->thread = NULL;
if (p->cleanup)
_cleanup(EVRY_PLUGIN(p));
}
static void
@ -232,17 +236,15 @@ _scan_end_func(void *data)
evry_util_file_detail_set(file);
if (p->command || cnt >= MAX_ITEMS) continue;
if (!file->mime) _item_fill(file);
if (cnt >= MAX_ITEMS) continue;
/* delay fetching of mimetype */
if (cnt < 20 && !file->mime) _item_fill(file);
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);
}
EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
evry_plugin_async_update(EVRY_PLUGIN(p), EVRY_ASYNC_UPDATE_ADD);
E_FREE(d);
}
@ -274,6 +276,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
p->base.items = NULL;
p->directory = eina_stringshare_add(file->path);
p->parent = EINA_TRUE;
}
else
{
@ -281,6 +284,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
p->base = *plugin;
p->base.items = NULL;
p->directory = eina_stringshare_add(e_user_homedir_get());
p->parent = EINA_FALSE;
}
_read_directory(p);
@ -294,10 +298,11 @@ _cleanup(Evry_Plugin *plugin)
PLUGIN(p, plugin);
Evry_Item_File *file;
if (p->thread)
{
ecore_thread_cancel(p->thread);
p->cleanup = EINA_TRUE;
}
else
{
@ -309,6 +314,9 @@ _cleanup(Evry_Plugin *plugin)
EVRY_PLUGIN_ITEMS_CLEAR(p);
if (p->input)
eina_stringshare_del(p->input);
E_FREE(p);
}
}
@ -338,58 +346,81 @@ _fetch(Evry_Plugin *plugin, const char *input)
if (!p->command)
EVRY_PLUGIN_ITEMS_CLEAR(p);
p->input = input;
if (p->input)
eina_stringshare_del(p->input);
p->input = NULL;
/* input is command ? */
if (input)
if (!p->parent && input)
{
if (!strncmp(input, "/", 1))
if (!strcmp(input, "/"))
{
if (p->command) return 1;
EINA_LIST_FREE(p->files, file)
evry_item_free(EVRY_ITEM(file));
eina_stringshare_del(p->directory);
p->directory = eina_stringshare_add("/");
_read_directory(p);
_folder_item_add(p, "/");
p->command = EINA_TRUE;
return 1;
}
else if (!strncmp(input, "..", 2))
{
char *end;
char dir[4096];
char *tmp;
int prio = 0;
if (p->command) return 1;
if (strncmp(p->directory, "/", 1)) return 0;
if (!strcmp(p->directory, "/")) return 0;
snprintf(dir, 4096, "%s", p->directory);
end = strrchr(dir, '/');
while (end != dir)
{
tmp = strdup(dir);
snprintf(dir, (end - dir) + 1, "%s", tmp);
_folder_item_add(p, dir);
end = strrchr(dir, '/');
free(tmp);
prio--;
}
_folder_item_add(p, "/");
p->command = EINA_TRUE;
return 1;
return 0;
}
/* else if (!strncmp(input, "..", 2))
* {
* char *end;
* char dir[4096];
* char *tmp;
* int prio = 0;
*
* if (p->command) return 1;
* if (strncmp(p->directory, "/", 1)) return 0;
* if (!strcmp(p->directory, "/")) return 0;
*
* snprintf(dir, 4096, "%s", p->directory);
* end = strrchr(dir, '/');
*
* while (end != dir)
* {
* tmp = strdup(dir);
* snprintf(dir, (end - dir) + 1, "%s", tmp);
*
* _folder_item_add(p, dir);
*
* end = strrchr(dir, '/');
* free(tmp);
* prio--;
* }
*
* _folder_item_add(p, "/");
*
* p->command = EINA_TRUE;
* return 1;
* } */
}
if (p->command)
if (!p->parent && !input && p->command)
{
p->command = EINA_FALSE;
EVRY_PLUGIN_ITEMS_FREE(p);
EINA_LIST_FREE(p->files, file)
evry_item_free(EVRY_ITEM(file));
eina_stringshare_del(p->directory);
p->directory = eina_stringshare_add(e_user_homedir_get());
_read_directory(p);
return 0;
}
if (input)
{
if (p->command)
p->input = eina_stringshare_add(input + 1);
else
p->input = eina_stringshare_add(input);
}
EINA_LIST_FOREACH(p->files, l, file)
{
if (cnt >= MAX_ITEMS);
@ -526,12 +557,6 @@ module_shutdown(void)
evry_action_free(act2);
}
/***************************************************************************/
/**/
/* actual module specifics */
static E_Module *module = NULL;
static Eina_Bool active = EINA_FALSE;
/***************************************************************************/
/**/

View File

@ -184,6 +184,8 @@ struct _Evry_Plugin
/* only used when plugin is of type_action */
int (*action) (Evry_Plugin *p, const Evry_Item *item);
/* int (*complete) (Evry_Plugin *p, const Evry_Item *item, char *input); */
/* handle key events: return 1 when key is handled by plugin */
int (*cb_key_down) (Evry_Plugin *p, const Ecore_Event_Key *ev);

View File

@ -1368,6 +1368,17 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
if (!list->visible && (!strcmp(key, "Down")))
_evry_list_win_show();
else if ((!strcmp(key, "ISO_Left_Tab") ||
(((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) ||
(ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)) &&
(!strcmp(key, "Tab")))))
{
/* int action = 0;
* if (s->plugin->complete)
* action = s->plugin->complete(s->plugin, s->cur_item, &s->input); */
evry_browse_item(selector);
}
else if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
(!strcmp(key, "Delete") || !strcmp(key, "Insert")))
{
@ -1392,8 +1403,6 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
if (delete)
{
printf("free %s,\n", it->label);
if (hi->input)
eina_stringshare_del(hi->input);
if (hi->plugin)
@ -1406,12 +1415,11 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
}
else if (promote)
{
printf("promote %s\n", it->label);
hi->count += 5;
hi->last_used = ecore_time_get();
}
else
{
printf("demote %s\n", it->label);
hi->count -= 5;
if (hi->count < 0) hi->count = 1;
}

View File

@ -29,7 +29,11 @@ evry_util_file_detail_set(Evry_Item_File *file)
EVRY_ITEM(file)->detail = eina_stringshare_add(dir_buf);
}
else
EVRY_ITEM(file)->detail = eina_stringshare_add(path);
{
if (!strncmp(path, "//", 2)) path++;
EVRY_ITEM(file)->detail = eina_stringshare_add(path);
}
}
EAPI int