forked from enlightenment/enlightenment
added plugin specific actions p->actions which can be triggered in context of a plugin
- added sort action for files plugin. finally sort by date. one reason less for me to open a fm (= - added alt+(shift)+tab up/down, alt+q:exit, alt+w: enter shortcuts SVN revision: 49157
This commit is contained in:
parent
d30578f56e
commit
0e9f1d9e74
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
/***************************************************
|
||||
TODO option for maximum items to cache
|
||||
TODO option for maximum items to cache
|
||||
TODO keep common list for recent file instances
|
||||
*/
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
|||
#define ACT_DELETE 2
|
||||
#define ACT_COPY 3
|
||||
#define ACT_MOVE 4
|
||||
#define ACT_SORT_DATE 5
|
||||
#define ACT_SORT_NAME 6
|
||||
|
||||
#define ONE_DAY 86400.0
|
||||
#define SIX_DAYS_AGO (ecore_time_get() - ONE_DAY * 6)
|
||||
|
@ -50,6 +52,7 @@ struct _Plugin
|
|||
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;
|
||||
|
@ -145,6 +148,15 @@ _cb_sort(const void *data1, const void *data2)
|
|||
return strcasecmp(it1->label, it2->label);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static void
|
||||
_item_free(Evry_Item *it)
|
||||
{
|
||||
|
@ -1274,10 +1286,51 @@ _file_copy_action(Evry_Action *act)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_file_sort_action(Evry_Action *act)
|
||||
{
|
||||
Eina_List *l;
|
||||
Evry_Item_File *file;
|
||||
struct stat s;
|
||||
|
||||
if (EVRY_ITEM_DATA_INT_GET(act) == ACT_SORT_DATE)
|
||||
{
|
||||
GET_PLUGIN(p, act->it1.item);
|
||||
if (!p) return 0;
|
||||
|
||||
EINA_LIST_FOREACH(p->files, l, file)
|
||||
{
|
||||
if (file->modified)
|
||||
continue;
|
||||
|
||||
if (lstat(file->path, &s) == 0)
|
||||
file->modified = s.st_mtime;
|
||||
}
|
||||
|
||||
p->files = eina_list_sort(p->files, -1, _cb_sort_date);
|
||||
_append_files(p);
|
||||
|
||||
EVRY_PLUGIN_UPDATE(p, EVRY_UPDATE_ADD);
|
||||
}
|
||||
else
|
||||
{
|
||||
GET_PLUGIN(p, act->it1.item);
|
||||
if (!p) return 0;
|
||||
|
||||
p->files = eina_list_sort(p->files, -1, _cb_sort);
|
||||
_append_files(p);
|
||||
|
||||
EVRY_PLUGIN_UPDATE(p, EVRY_UPDATE_ADD);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
_plugins_init(const Evry_API *api)
|
||||
{
|
||||
Evry_Action *act;
|
||||
Evry_Action *act, *act_sort_date, *act_sort_name;
|
||||
Evry_Plugin *p;
|
||||
int prio = 0;
|
||||
|
||||
|
@ -1292,6 +1345,41 @@ _plugins_init(const Evry_API *api)
|
|||
_mime_dir = eina_stringshare_add("inode/directory");
|
||||
_mime_mount = eina_stringshare_add("inode/mountpoint");
|
||||
|
||||
#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); \
|
||||
|
||||
ACTION_NEW(N_("Copy To ..."), EVRY_TYPE_FILE, "go-next",
|
||||
_file_copy_action, NULL, 1);
|
||||
act->it2.subtype = EVRY_TYPE_DIR;
|
||||
EVRY_ITEM_DATA_INT_SET(act, ACT_COPY);
|
||||
|
||||
ACTION_NEW(N_("Move To ..."), EVRY_TYPE_FILE, "go-next",
|
||||
_file_copy_action, NULL, 1);
|
||||
act->it2.subtype = EVRY_TYPE_DIR;
|
||||
EVRY_ITEM_DATA_INT_SET(act, ACT_MOVE);
|
||||
|
||||
ACTION_NEW(N_("Move to Trash"), 0, "user-trash",
|
||||
_file_trash_action, NULL, 1);
|
||||
EVRY_ITEM_DATA_INT_SET(act, ACT_TRASH);
|
||||
|
||||
ACTION_NEW(N_("Open Folder (EFM)"), 0, "folder-open",
|
||||
_open_folder_action, _open_folder_check, 1);
|
||||
act->remember_context = EINA_TRUE;
|
||||
|
||||
ACTION_NEW(N_("Sort by Date"), 0, "go-up",
|
||||
_file_sort_action, NULL, 0);
|
||||
EVRY_ITEM_DATA_INT_SET(act, ACT_SORT_DATE);
|
||||
act_sort_date = act;
|
||||
|
||||
ACTION_NEW(N_("Sort by Name"), 0, "go-up",
|
||||
_file_sort_action, NULL, 0);
|
||||
EVRY_ITEM_DATA_INT_SET(act, ACT_SORT_NAME);
|
||||
act_sort_name = act;
|
||||
|
||||
#undef ACTION_NEW
|
||||
|
||||
#define PLUGIN_NEW(_name, _icon, _begin, _finish, _fetch, _browse) \
|
||||
p = EVRY_PLUGIN_NEW(Evry_Plugin, _name, _icon, EVRY_TYPE_FILE, \
|
||||
_begin, _finish, _fetch, NULL); \
|
||||
|
@ -1302,10 +1390,15 @@ _plugins_init(const Evry_API *api)
|
|||
|
||||
PLUGIN_NEW(N_("Files"), _module_icon, _begin, _finish, _fetch, _browse);
|
||||
p->input_type = EVRY_TYPE_FILE;
|
||||
p->actions = eina_list_append(p->actions, act_sort_date);
|
||||
p->actions = eina_list_append(p->actions, act_sort_name);
|
||||
if (evry->plugin_register(p, EVRY_PLUGIN_SUBJECT, 2))
|
||||
p->config->min_query = 1;
|
||||
|
||||
|
||||
PLUGIN_NEW(N_("Files"), _module_icon, _begin, _finish, _fetch, _browse);
|
||||
p->actions = eina_list_append(p->actions, act_sort_date);
|
||||
p->actions = eina_list_append(p->actions, act_sort_name);
|
||||
evry->plugin_register(p, EVRY_PLUGIN_OBJECT, 2);
|
||||
|
||||
if (_conf->show_recent || _conf->search_recent)
|
||||
|
@ -1331,35 +1424,6 @@ _plugins_init(const Evry_API *api)
|
|||
|
||||
#undef PLUGIN_NEW
|
||||
|
||||
#define ACTION_NEW(_name, _type2, _icon, _act, _check) \
|
||||
act = EVRY_ACTION_NEW(_name, EVRY_TYPE_FILE, _type2, _icon, _act, _check); \
|
||||
evry->action_register(act, prio++); \
|
||||
_actions = eina_list_append(_actions, act); \
|
||||
|
||||
ACTION_NEW(N_("Copy To ..."), EVRY_TYPE_FILE, "go-next",
|
||||
_file_copy_action, NULL);
|
||||
act->it2.subtype = EVRY_TYPE_DIR;
|
||||
EVRY_ITEM_DATA_INT_SET(act, ACT_COPY);
|
||||
|
||||
ACTION_NEW(N_("Move To ..."), EVRY_TYPE_FILE, "go-next",
|
||||
_file_copy_action, NULL);
|
||||
act->it2.subtype = EVRY_TYPE_DIR;
|
||||
EVRY_ITEM_DATA_INT_SET(act, ACT_MOVE);
|
||||
|
||||
ACTION_NEW(N_("Move to Trash"), 0, "user-trash",
|
||||
_file_trash_action, NULL);
|
||||
EVRY_ITEM_DATA_INT_SET(act, ACT_TRASH);
|
||||
|
||||
/* ACTION_NEW(N_("Delete File"), 0, "user-trash",
|
||||
* _file_trash_action, NULL);
|
||||
* EVRY_ITEM_DATA_INT_SET(act, ACT_DELETE); */
|
||||
|
||||
ACTION_NEW(N_("Open Folder (EFM)"), 0, "folder-open",
|
||||
_open_folder_action, _open_folder_check);
|
||||
act->remember_context = EINA_TRUE;
|
||||
|
||||
#undef ACTION_NEW
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1376,7 +1440,11 @@ _plugins_shutdown(void)
|
|||
eina_stringshare_del(_mime_mount);
|
||||
|
||||
EINA_LIST_FREE(_plugins, p)
|
||||
evry->plugin_free(p);
|
||||
{
|
||||
if (p->actions)
|
||||
eina_list_free(p->actions);
|
||||
EVRY_PLUGIN_FREE(p);
|
||||
}
|
||||
|
||||
EINA_LIST_FREE(_actions, act)
|
||||
evry->action_free(act);
|
||||
|
|
|
@ -368,7 +368,10 @@ _plugins_init(const Evry_API *_api)
|
|||
EVRY_TYPE_BORDER,
|
||||
NULL, _cleanup, _fetch, NULL);
|
||||
_plug->transient = EINA_TRUE;
|
||||
evry->plugin_register(_plug, EVRY_PLUGIN_SUBJECT, 2);
|
||||
if (evry->plugin_register(_plug, EVRY_PLUGIN_SUBJECT, 2))
|
||||
{
|
||||
_plug->config->top_level = EINA_FALSE;
|
||||
}
|
||||
|
||||
act = EVRY_ACTION_NEW(_("Switch to Window"),
|
||||
EVRY_TYPE_BORDER, 0, "go-next",
|
||||
|
|
|
@ -1874,41 +1874,61 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
|||
{
|
||||
ev->key = "Return";
|
||||
}
|
||||
else if (((evry_conf->quick_nav == 1) && (ev->modifiers & ECORE_EVENT_MODIFIER_ALT)) ||
|
||||
((evry_conf->quick_nav == 2) && (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL)))
|
||||
else if (ev->modifiers & ECORE_EVENT_MODIFIER_ALT)
|
||||
{
|
||||
if (!strcmp(ev->key, "k") || (!strcmp(ev->key, "K")))
|
||||
ev->key = "Up";
|
||||
else if (!strcmp(ev->key, "j") || (!strcmp(ev->key, "J")))
|
||||
ev->key = "Down";
|
||||
else if (!strcmp(ev->key, "n") || (!strcmp(ev->key, "N")))
|
||||
ev->key = "Next";
|
||||
else if (!strcmp(ev->key, "p") || (!strcmp(ev->key, "P")))
|
||||
ev->key = "Prior";
|
||||
else if (!strcmp(ev->key, "l") || (!strcmp(ev->key, "L")))
|
||||
ev->key = "Right";
|
||||
else if (!strcmp(ev->key, "h") || (!strcmp(ev->key, "H")))
|
||||
ev->key = "Left";
|
||||
else if (!strcmp(ev->key, "i") || (!strcmp(ev->key, "I")))
|
||||
ev->key = "Tab";
|
||||
else if (!strcmp(ev->key, "m") || (!strcmp(ev->key, "M")))
|
||||
ev->key = "Return";
|
||||
}
|
||||
else if (((evry_conf->quick_nav == 3) && (ev->modifiers & ECORE_EVENT_MODIFIER_ALT)) ||
|
||||
((evry_conf->quick_nav == 4) && (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL)))
|
||||
{
|
||||
if (!strcmp(ev->key, "p") || (!strcmp(ev->key, "P")))
|
||||
ev->key = "Up";
|
||||
else if (!strcmp(ev->key, "n") || (!strcmp(ev->key, "N")))
|
||||
ev->key = "Down";
|
||||
else if (!strcmp(ev->key, "f") || (!strcmp(ev->key, "F")))
|
||||
ev->key = "Right";
|
||||
else if (!strcmp(ev->key, "b") || (!strcmp(ev->key, "B")))
|
||||
ev->key = "Left";
|
||||
else if (!strcmp(ev->key, "i") || (!strcmp(ev->key, "I")))
|
||||
ev->key = "Tab";
|
||||
else if (!strcmp(ev->key, "m") || (!strcmp(ev->key, "M")))
|
||||
ev->key = "Return";
|
||||
if (!strcmp(ev->key, "Tab"))
|
||||
{
|
||||
ev->key = "Down";
|
||||
}
|
||||
else if (!strcmp(ev->key, "ISO_Left_Tab") || (!strcmp(ev->key, "Tab") &&
|
||||
(ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)))
|
||||
{
|
||||
ev->key = "Up";
|
||||
ev->modifiers = 0;
|
||||
}
|
||||
else if (!strcmp(ev->key, "q"))
|
||||
{
|
||||
evry_hide(0);
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp(ev->key, "w"))
|
||||
{
|
||||
ev->key = "Return";
|
||||
}
|
||||
else if (evry_conf->quick_nav == 1)
|
||||
{
|
||||
if (!strcmp(ev->key, "k") || (!strcmp(ev->key, "K")))
|
||||
ev->key = "Up";
|
||||
else if (!strcmp(ev->key, "j") || (!strcmp(ev->key, "J")))
|
||||
ev->key = "Down";
|
||||
else if (!strcmp(ev->key, "n") || (!strcmp(ev->key, "N")))
|
||||
ev->key = "Next";
|
||||
else if (!strcmp(ev->key, "p") || (!strcmp(ev->key, "P")))
|
||||
ev->key = "Prior";
|
||||
else if (!strcmp(ev->key, "l") || (!strcmp(ev->key, "L")))
|
||||
ev->key = "Right";
|
||||
else if (!strcmp(ev->key, "h") || (!strcmp(ev->key, "H")))
|
||||
ev->key = "Left";
|
||||
else if (!strcmp(ev->key, "i") || (!strcmp(ev->key, "I")))
|
||||
ev->key = "Tab";
|
||||
else if (!strcmp(ev->key, "m") || (!strcmp(ev->key, "M")))
|
||||
ev->key = "Return";
|
||||
}
|
||||
else if (evry_conf->quick_nav == 3)
|
||||
{
|
||||
if (!strcmp(ev->key, "p") || (!strcmp(ev->key, "P")))
|
||||
ev->key = "Up";
|
||||
else if (!strcmp(ev->key, "n") || (!strcmp(ev->key, "N")))
|
||||
ev->key = "Down";
|
||||
else if (!strcmp(ev->key, "f") || (!strcmp(ev->key, "F")))
|
||||
ev->key = "Right";
|
||||
else if (!strcmp(ev->key, "b") || (!strcmp(ev->key, "B")))
|
||||
ev->key = "Left";
|
||||
else if (!strcmp(ev->key, "i") || (!strcmp(ev->key, "I")))
|
||||
ev->key = "Tab";
|
||||
else if (!strcmp(ev->key, "m") || (!strcmp(ev->key, "M")))
|
||||
ev->key = "Return";
|
||||
}
|
||||
}
|
||||
|
||||
if (!win || !(sel = CUR_SEL))
|
||||
|
@ -2238,6 +2258,9 @@ _evry_plugin_action(Evry_Selector *sel, int finished)
|
|||
|
||||
if (s_obj && s_obj->sel_items && !(act->it2.accept_list))
|
||||
{
|
||||
if (!(act->it1.item && CHECK_TYPE(act->it1.item, EVRY_TYPE_PLUGIN)))
|
||||
act->it1.item = it_subj;
|
||||
|
||||
EINA_LIST_FOREACH(s_obj->sel_items, l, it)
|
||||
{
|
||||
if (it->type != act->it2.type)
|
||||
|
@ -2260,8 +2283,11 @@ _evry_plugin_action(Evry_Selector *sel, int finished)
|
|||
}
|
||||
else
|
||||
{
|
||||
act->it1.item = it_subj;
|
||||
act->it1.items = s_subj->sel_items;
|
||||
if (!(act->it1.item && CHECK_TYPE(act->it1.item, EVRY_TYPE_PLUGIN)))
|
||||
{
|
||||
act->it1.item = it_subj;
|
||||
act->it1.items = s_subj->sel_items;
|
||||
}
|
||||
|
||||
if (s_obj)
|
||||
act->it2.items = s_obj->sel_items;
|
||||
|
|
|
@ -86,6 +86,22 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
|
|||
p->actions = eina_list_remove(p->actions, act);
|
||||
}
|
||||
|
||||
/* FIXME this requires plugins to always provide an item..*/
|
||||
if (it->plugin)
|
||||
{
|
||||
EINA_LIST_FOREACH(it->plugin->actions, l, act)
|
||||
{
|
||||
act->base.plugin = plugin;
|
||||
|
||||
if (!eina_list_data_find_list(p->actions, act))
|
||||
{
|
||||
act->it1.item = EVRY_ITEM(it->plugin);
|
||||
EVRY_ITEM(act)->hi = NULL;
|
||||
p->actions = eina_list_append(p->actions, act);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!p->actions) return NULL;
|
||||
|
||||
return plugin;
|
||||
|
|
|
@ -191,7 +191,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
}
|
||||
|
||||
items = eina_list_sort(items, -1, evry_items_sort_func);
|
||||
|
||||
|
||||
EINA_LIST_FOREACH(items, l, it)
|
||||
{
|
||||
/* remove duplicates provided by different plugins */
|
||||
|
@ -211,7 +211,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
evry_item_ref(it);
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
||||
}
|
||||
|
||||
|
||||
if (cnt++ > MAX_ITEMS)
|
||||
break;
|
||||
|
||||
|
|
|
@ -109,6 +109,8 @@ struct _Evry_Action
|
|||
void (*free) (Evry_Action *act);
|
||||
/* optional: must be defined when action is browseable */
|
||||
Eina_List *(*fetch) (Evry_Action *act);
|
||||
|
||||
/* int method; */
|
||||
};
|
||||
|
||||
struct _Evry_Item_App
|
||||
|
@ -126,6 +128,8 @@ struct _Evry_Item_File
|
|||
const char *url;
|
||||
const char *path;
|
||||
const char *mime;
|
||||
|
||||
unsigned int modified;
|
||||
};
|
||||
|
||||
struct _Evry_Plugin
|
||||
|
|
Loading…
Reference in New Issue