This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efm2.
View the commit online.
commit b907dae636f455ed381668cf66e390060c181caa
Author: Carsten Haitzler (Rasterman) <[email protected]>
AuthorDate: Sun Dec 7 11:12:59 2025 +0000
file ordering - now works and saves if you have write perm
---
src/backends/default/open.c | 126 ++++++++++++++++++++++++++++++++++++--------
src/efm/efm_back_end.c | 8 ++-
src/efm/efm_dnd.c | 112 ++++++++++++++++++++++++++++++++++++++-
3 files changed, 221 insertions(+), 25 deletions(-)
diff --git a/src/backends/default/open.c b/src/backends/default/open.c
index f9e5425..b836837 100644
--- a/src/backends/default/open.c
+++ b/src/backends/default/open.c
@@ -19,6 +19,7 @@
#include "cmd.h"
#include "eina_hash.h"
+#include "eina_list.h"
#include "eina_strbuf.h"
#include "eina_types.h"
#include "sha.h"
@@ -1278,7 +1279,7 @@ _op_run(const char *op, Eina_List *files, const char *dst)
}
static void
-_handle_drop_paste(const char *over, const char *action, Eina_List *files)
+_handle_drop_paste(const char *over, const char *over_position, const char *action, Eina_List *files)
{
const char *path;
const char *mondir;
@@ -1290,20 +1291,31 @@ _handle_drop_paste(const char *over, const char *action, Eina_List *files)
if (over)
{ // if you are dropping over a dir then spin up a sub open and pass
// the dnd to it
- Eina_Strbuf *strbuf;
- Sub *sub;
-
- sub = _sub_find(over);
- if (!sub) sub = _sub_open(over, "default");
- strbuf = cmd_strbuf_new("dnd-drop");
- cmd_strbuf_append(strbuf, "action", action);
- EINA_LIST_FOREACH(files, l, path)
- {
- fprintf(stderr, "DND/PASTE in [%s] over=[%s] action="" > [%s]\n", mondir,
- over, action, path);
- cmd_strbuf_append(strbuf, "path", path);
- }
- _sub_cmd_send(sub, strbuf);
+ if (over_position)
+ { // over position - reordering so before or after this
+ // front-end wiill send a new order list instead so do nothing
+ }
+ else
+ { // no over_position - we dropped INTO this file (dir?)
+ Eina_Strbuf *strbuf = NULL;
+ Sub *sub = _sub_find(over); // sub open cmd for sub dir
+ if (!sub) sub = _sub_open(over, "default");
+ if (sub) strbuf = cmd_strbuf_new("dnd-drop");
+ if ((sub) && (strbuf))
+ { // we have a sub cmd and a buffer to append cmds to
+ cmd_strbuf_append(strbuf, "action", action);
+ // because we don't pass over the below else {} will trigger
+ // in the sub open cmd and do cp, mv or ln instead
+ EINA_LIST_FOREACH(files, l, path)
+ {
+ fprintf(stderr,
+ "DND/PASTE in [%s] over=[%s] action="" > [%s]\n",
+ mondir, over, action, path);
+ cmd_strbuf_append(strbuf, "path", path);
+ }
+ _sub_cmd_send(sub, strbuf);
+ }
+ }
}
else
{
@@ -1454,8 +1466,9 @@ do_handle_cmd(Cmd *c)
}
else if (!strcmp(c->command, "dnd-drop"))
{ // "over" key means dnd was on that dir
- const char *over = cmd_key_find(c, "over");
- const char *action = "" "action");
+ const char *over = cmd_key_find(c, "over");
+ const char *action = "" "action");
+ const char *over_position = cmd_key_find(c, "over-position");
Eina_List *files = NULL;
const char *s;
@@ -1474,7 +1487,7 @@ do_handle_cmd(Cmd *c)
KEY_WALK_END
if (files)
{
- _handle_drop_paste(over, action, files);
+ _handle_drop_paste(over, over_position, action, files);
EINA_LIST_FREE(files, s) eina_stringshare_del(s);
}
}
@@ -1506,8 +1519,8 @@ do_handle_cmd(Cmd *c)
if (files)
{
// handle like a dnd paste as it's the same thing...
- if (cut) _handle_drop_paste(NULL, "move", files);
- else _handle_drop_paste(NULL, "copy", files);
+ if (cut) _handle_drop_paste(NULL, NULL, "move", files);
+ else _handle_drop_paste(NULL, NULL, "copy", files);
EINA_LIST_FREE(files, s) eina_stringshare_del(s);
}
}
@@ -1545,12 +1558,80 @@ do_handle_cmd(Cmd *c)
KEY_WALK_END
if (files)
{
- // XXX: implement trash, but for now use rm
_op_run("trash", files, NULL);
EINA_LIST_FREE(files, s) eina_stringshare_del(s);
}
}
- // cmd_dump_sterr(c);
+ else if (!strcmp(c->command, "order-set"))
+ { // this is nice deletion - trashcan likely used
+ Eina_List *files = NULL;
+ const char *s;
+
+ KEY_WALK_BEGIN
+ {
+ if (!strcmp(key, "file"))
+ {
+ files = eina_list_append(files, eina_stringshare_add(data));
+ }
+ }
+ KEY_WALK_END
+ if (files)
+ {
+ const char *mondir = ecore_file_monitor_path_get(mon);
+
+ if (mondir)
+ {
+ Eina_Strbuf *strbuf = eina_strbuf_new();
+ Eina_Strbuf *strbuf2 = eina_strbuf_new();
+
+ if ((strbuf) && (strbuf2))
+ {
+ FILE *f;
+
+ // make the .efm meta dir
+ eina_strbuf_append(strbuf, mondir);
+ eina_strbuf_append(strbuf, "/.efm");
+ ecore_file_mkpath(eina_strbuf_string_get(strbuf));
+ // open .efm/order in the .efm dir for writing
+ eina_strbuf_append(strbuf, "/.efm.order.tmp");
+ f = fopen(eina_strbuf_string_get(strbuf), "w");
+ if (f)
+ {
+ Eina_List *l;
+
+ // write out files given in order list
+ EINA_LIST_FOREACH(files, l, s)
+ {
+ fprintf(f, "%s\n", s);
+ }
+ fclose(f);
+ // rtename tmp file over proper
+ eina_strbuf_append(strbuf2, mondir);
+ eina_strbuf_append(strbuf2, "/.efm/.efm.order");
+ if (rename(eina_strbuf_string_get(strbuf),
+ eina_strbuf_string_get(strbuf2))
+ == 0)
+ { // rename worked - tell front end to refresh
+ eina_strbuf_free(strbuf);
+ strbuf = cmd_strbuf_new("view-refresh");
+ cmd_strbuf_print_consume(strbuf);
+ }
+ else eina_strbuf_free(strbuf);
+ }
+ // file open fialed - free strbuf
+ else eina_strbuf_free(strbuf);
+ }
+ else
+ { // failed alloc - might have to free strbuf
+ if (strbuf) eina_strbuf_free(strbuf);
+ }
+ // will have ot free strbuf2
+ if (strbuf2) eina_strbuf_free(strbuf2);
+ }
+ EINA_LIST_FREE(files, s) eina_stringshare_del(s);
+ }
+ }
+// cmd_dump_sterr(c);
}
int
@@ -1615,3 +1696,4 @@ do_shutdown(void)
efreet_shutdown();
ecore_file_shutdown();
}
+;
\ No newline at end of file
diff --git a/src/efm/efm_back_end.c b/src/efm/efm_back_end.c
index 165da13..50df476 100644
--- a/src/efm/efm_back_end.c
+++ b/src/efm/efm_back_end.c
@@ -649,10 +649,15 @@ _cb_thread_notify(void *data, Ecore_Thread *th EINA_UNUSED, void *msg)
printf("XXX: dir del...\n");
CMD_DONE;
}
+ else if (!strcmp(c->command, "view-refresh"))
+ {
+ _reset(sd);
+ CMD_DONE;
+ }
// below commands all send a path for a specific file
path = file = cmd_key_find(c, "path");
- // printf("XXXXX [%s] [%s]\n", c->command, file);
+// printf("XXXXX [%s] [%s]\n", c->command, file);
if (file)
{
s = strrchr(file, '/');
@@ -739,7 +744,6 @@ _cb_thread_notify(void *data, Ecore_Thread *th EINA_UNUSED, void *msg)
}
else
{ // XXX: pop up dialog to ask what to open with...
-
}
EINA_LIST_FREE(files, file)
{
diff --git a/src/efm/efm_dnd.c b/src/efm/efm_dnd.c
index 2c9cfe1..3a5f71f 100644
--- a/src/efm/efm_dnd.c
+++ b/src/efm/efm_dnd.c
@@ -6,6 +6,7 @@
#include "efm_util.h"
#include "efm_dnd.h"
#include "efm_private.h"
+#include "eina_list.h"
#include "esc.h"
#define COORD_INVALID -999999
@@ -190,6 +191,94 @@ _cb_drop_pos(void *data, Evas_Object *o EINA_UNUSED, Evas_Coord x, Evas_Coord y,
_dnd_hovering(sd, dx, dy);
}
+static Eina_Bool
+_dnd_drop_file_in_list(const char *file, Eina_List *list)
+{
+ Eina_List *l;
+ const char *s;
+
+ EINA_LIST_FOREACH(list, l, s)
+ {
+ if (!strcmp(s, file)) return EINA_TRUE;
+ }
+ return EINA_FALSE;
+}
+
+static void
+_dnd_drop_reorder(Smart_Data *sd, const char *over, const char *urilist, int before_after)
+{
+ Eina_List *l, *ll, *dropfiles = NULL;
+ Icon *icon;
+ char **plist, **p, *esc, *s;
+ const char *fname;
+ Eina_Strbuf *buf = cmd_strbuf_new("order-set");
+
+ plist = eina_str_split(urilist, "\n", -1);
+ if (!plist) return; // nothing being dropped!
+ for (p = plist; *p != NULL; p++)
+ {
+ if (**p)
+ {
+ esc = unescape(*p);
+ if (!esc) continue;
+ fname = ecore_file_file_get(esc);
+ dropfiles = eina_list_append(dropfiles, strdup(fname));
+ free(esc);
+ }
+ }
+ free(*plist);
+ free(plist);
+ EINA_LIST_FOREACH(sd->icons, l, icon)
+ {
+ if (!strcmp(over, icon->info.file))
+ { // this file is the file we drop beforre or after
+ if ((over) && (before_after == 0))
+ { // insert dnd'd files BEFORE the over file
+ EINA_LIST_FOREACH(dropfiles, ll, s)
+ {
+ cmd_strbuf_append(buf, "file", s);
+ }
+ if (!_dnd_drop_file_in_list(icon->info.file, dropfiles))
+ {
+ cmd_strbuf_append(buf, "file", icon->info.file);
+ }
+ }
+ else if ((over) && (before_after == 2))
+ { // insert dnd'd files AFTER the over file
+ if (!_dnd_drop_file_in_list(icon->info.file, dropfiles))
+ {
+ cmd_strbuf_append(buf, "file", icon->info.file);
+ }
+ EINA_LIST_FOREACH(dropfiles, ll, s)
+ {
+ cmd_strbuf_append(buf, "file", s);
+ }
+ }
+ else if (before_after == -1)
+ { // we eventually insert at end so only output if not in droplist
+ if (!_dnd_drop_file_in_list(icon->info.file, dropfiles))
+ {
+ cmd_strbuf_append(buf, "file", icon->info.file);
+ }
+ }
+ }
+ else if (!_dnd_drop_file_in_list(icon->info.file, dropfiles))
+ {
+ cmd_strbuf_append(buf, "file", icon->info.file);
+ }
+ }
+ if (before_after == -1)
+ { // we are appending - so dump
+ EINA_LIST_FOREACH(dropfiles, l, s)
+ {
+ cmd_strbuf_append(buf, "file", s);
+ }
+ }
+ // free our tmp dropfiles list
+ EINA_LIST_FREE(dropfiles, s) free(s);
+ cmd_strbuf_exe_consume(buf, sd->exe_open); // send reorder cmd
+}
+
static void
_dnd_drop_handle(Smart_Data *sd, char *urilist, Elm_Xdnd_Action act)
{
@@ -234,8 +323,29 @@ _dnd_drop_handle(Smart_Data *sd, char *urilist, Elm_Xdnd_Action act)
{
printf("XXX: DND DROP OVER [%s]\n", sd->drop_over->info.file);
_icon_path_cmd_strbuf_append(buf, "over", sd, sd->drop_over);
+ // if we were reording we'd have beofre or after possibly set so pass through
+ if (sd->drop_over->over_before)
+ cmd_strbuf_append(buf, "over-position", "before");
+ else if (sd->drop_over->over_after)
+ cmd_strbuf_append(buf, "over-position", "after");
+ if (sd->config.sort_mode & EFM_SORT_MODE_ORDER)
+ { // we are ordering - generate an order list and send to backend
+ // with this file properly inserted before/after
+ if (sd->drop_over->over_before)
+ _dnd_drop_reorder(sd, sd->drop_over->info.file, urilist, 0);
+ else if (sd->drop_over->over_after)
+ _dnd_drop_reorder(sd, sd->drop_over->info.file, urilist, 2);
+ }
+ }
+ else
+ { //
+ printf("XXX: DND DROP ...\n");
+ if (sd->config.sort_mode & EFM_SORT_MODE_ORDER)
+ { // we are reordering - generate an order list and send to backend
+ // with this file appended at the end of the list
+ _dnd_drop_reorder(sd, NULL, urilist, -1);
+ }
}
- else printf("XXX: DND DROP ...\n");
plist = eina_str_split(urilist, "\n", -1);
for (p = plist; *p != NULL; p++)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.