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 ad2647b84f2c30310792bd91e3e39e32e80e82e3
Author: Carsten Haitzler (Rasterman) <[email protected]>
AuthorDate: Sun Apr 5 12:45:09 2026 +0100

    make create dir work - with initial rename on and fix rename
    
    rename didnt DO the rename - just asked to do it to back-end. now do
    it. also new dirs now get created from the menu and an initial rename
    mode enabled for them etc. etc.
---
 src/backends/default/open.c | 99 ++++++++++++++++++++++++++++++++++++++++++---
 src/efm/efm_back_end.c      |  6 +++
 src/efm/efm_popup_menu.c    | 13 +++---
 src/efm/efm_structs.h       |  1 +
 src/efm/efm_util.c          | 17 +++++++-
 5 files changed, 122 insertions(+), 14 deletions(-)

diff --git a/src/backends/default/open.c b/src/backends/default/open.c
index 746e58d..abe7261 100644
--- a/src/backends/default/open.c
+++ b/src/backends/default/open.c
@@ -180,7 +180,8 @@ _sub_cmd_send(Sub *sub, Eina_Strbuf *buf)
 
 static void
 _sub_command(Sub *sub, const char *str)
-{
+{ // a sub efm backend command may ask this backend to do things like this
+  // one might ask the efm ui process to do things, so handle these here.
   Eina_Strbuf *buf;
   Cmd         *c = cmd_parse(str);
 
@@ -248,7 +249,7 @@ _sub_command(Sub *sub, const char *str)
 
 static Eina_Bool
 _cb_sub_exe_del(void *data, int ev_type EINA_UNUSED, void *event)
-{
+{ // sub backend command exited - handle it
   Sub                 *sub = data;
   Ecore_Exe_Event_Del *ev  = event;
 
@@ -259,7 +260,7 @@ _cb_sub_exe_del(void *data, int ev_type EINA_UNUSED, void *event)
 
 static Eina_Bool
 _cb_sub_exe_data(void *data, int ev_type EINA_UNUSED, void *event)
-{
+{ // command data coming in from sub efm backend command
   Sub                  *sub = data;
   Ecore_Exe_Event_Data *ev  = event;
   int                   i;
@@ -271,7 +272,7 @@ _cb_sub_exe_data(void *data, int ev_type EINA_UNUSED, void *event)
 
 static Sub *
 _sub_open(const char *path, const char *backend)
-{
+{ // we open a sub efm backend command to handle sub dir operations/work
   // XXX: this sub should exit on its own if its idle for some time
   Eina_Strbuf *buf;
   const char  *s;
@@ -1147,7 +1148,29 @@ _file_add(const char *path)
   cmd_strbuf_append(strbuf, "path", path);
   meta_path_sync(path);
   if (!_file_add_mod_info(strbuf, path, EINA_FALSE)) eina_strbuf_free(strbuf);
-  else cmd_strbuf_print_consume(strbuf);
+  else
+    { // if we have special rename-me file then set rename-mode to true for ui
+      Eina_Strbuf *strbuf2 = eina_strbuf_new();
+      char        *dir     = ecore_file_dir_get(path);
+      const char  *fname   = ecore_file_file_get(path);
+
+      if ((strbuf2) && (dir) && (fname))
+        {
+          eina_strbuf_append_printf(strbuf2, "%s/.efm/%s.efm.--rename-me", dir,
+                                    fname);
+          fprintf(stderr, "JJJ: [%s] exists...\n",
+                  eina_strbuf_string_get(strbuf2));
+          if (ecore_file_exists(eina_strbuf_string_get(strbuf2)))
+            {
+              fprintf(stderr, "JJJ: exists!!!\n");
+              ecore_file_unlink(eina_strbuf_string_get(strbuf2));
+              cmd_strbuf_append(strbuf, "rename-mode", "true");
+            }
+        }
+      free(dir);
+      if (strbuf2) eina_strbuf_free(strbuf2);
+      cmd_strbuf_print_consume(strbuf);
+    }
 }
 
 static void
@@ -1629,6 +1652,72 @@ do_handle_cmd(Cmd *c)
           EINA_LIST_FREE(files, s) eina_stringshare_del(s);
         }
     }
+  else if (!strcmp(c->command, "file-rename"))
+    { // rename file from src to new_file
+      const char *new_file = cmd_key_find(c, "new-name");
+      const char *src      = "" "path");
+
+      if ((src) && (new_file))
+        {
+          Eina_Strbuf *buf = eina_strbuf_new();
+
+          if (buf)
+            {
+              char *dir = ecore_file_dir_get(src);
+
+              if (dir)
+                {
+                  eina_strbuf_append_printf(buf, "%s/%s", dir, new_file);
+                  fprintf(stderr, "JJJ: [%s] -> [%s]\n", src,
+                          eina_strbuf_string_get(buf));
+                  ecore_file_mv(src, eina_strbuf_string_get(buf));
+                  free(dir);
+                }
+              eina_strbuf_free(buf);
+            }
+        }
+    }
+  else if (!strcmp(c->command, "file-new-dir"))
+    { // this creates a new dir with no specified name, then tells front end
+      // to begin renaming mode (and show the file/icon if not visible)
+      if (mon)
+        {
+          const char *mondir = ecore_file_monitor_path_get(mon);
+          if (mondir)
+            {
+              Eina_Strbuf *buf = eina_strbuf_new();
+              if (buf)
+                {
+                  Eina_Bool done = EINA_FALSE;
+                  int i = 1;
+
+                  do
+                    {
+                      eina_strbuf_reset(buf);
+                      eina_strbuf_append(buf, mondir);
+                      if (i == 0)
+                        eina_strbuf_append_printf(buf, "/new-directory");
+                      else
+                        eina_strbuf_append_printf(buf, "/new-directory-%i", i);
+                      if (ecore_file_mkdir(eina_strbuf_string_get(buf)))
+                        {
+                          eina_strbuf_reset(buf);
+                          eina_strbuf_append(buf, mondir);
+                          if (i == 0)
+                            eina_strbuf_append_printf(buf, "/.efm/new-directory.efm.--rename-me");
+                          else
+                            eina_strbuf_append_printf(buf, "/.efm/new-directory-%i.efm.--rename-me", i);
+                          ecore_file_mkdir(eina_strbuf_string_get(buf));
+                          done = EINA_TRUE;
+                        }
+                      i++;
+                    }
+                  while (!done);
+                  eina_strbuf_free(buf);
+                }
+            }
+        }
+    }
   else if (!strcmp(c->command, "order-set"))
     { // this is nice deletion - trashcan likely used
       Eina_List  *files = NULL;
diff --git a/src/efm/efm_back_end.c b/src/efm/efm_back_end.c
index f6d601d..760f5bd 100644
--- a/src/efm/efm_back_end.c
+++ b/src/efm/efm_back_end.c
@@ -931,6 +931,12 @@ _cb_thread_notify(void *data, Ecore_Thread *th EINA_UNUSED, void *msg)
               }
           }
         if (!il) sd->icons = eina_list_append(sd->icons, icon);
+        s = cmd_key_find(c, "rename-mode");
+        if (s)
+          {
+            printf("XXX: go into rename mode for [%s]\n", icon->info.file);
+            icon->rename_me = EINA_TRUE; // rename later once positioned
+          }
       }
     else if (!strcmp(c->command, "file-mod"))
       {
diff --git a/src/efm/efm_popup_menu.c b/src/efm/efm_popup_menu.c
index b64f061..75e8b9c 100644
--- a/src/efm/efm_popup_menu.c
+++ b/src/efm/efm_popup_menu.c
@@ -94,7 +94,6 @@ _cb_menu_item_open(void *data, void *data2,
   Efreet_Desktop *d   = data2;
   Eina_Strbuf    *strbuf;
 
-  printf("XXX: open\n");
   if (!d)
     {
       // XXX: if d == NULL then _cb_menu_item_open_all()
@@ -173,7 +172,6 @@ _cb_menu_item_trash(void *data, void *data2 EINA_UNUSED,
   Popup_Context *ctx = data;
   Eina_Strbuf   *strbuf;
 
-  printf("XXX: trash\n");
   // ask backed to file-trash
   strbuf = eina_strbuf_new();
   if (strbuf)
@@ -198,7 +196,6 @@ _cb_menu_item_delete(void *data, void *data2 EINA_UNUSED,
   Popup_Context *ctx = data;
   Eina_Strbuf   *strbuf;
 
-  printf("XXX: delete\n");
   // ask backed to file-unlink
   strbuf = eina_strbuf_new();
   if (strbuf)
@@ -293,11 +290,14 @@ _cb_menu_item_refresh(void *data, void *data2 EINA_UNUSED,
 }
 
 static void
-_cb_menu_item_mkdir(void *data, void *data2, Evas_Object *efm,
-                    const Efm_Menu_Item *menu_item)
+_cb_menu_item_mkdir(void *data, void *data2 EINA_UNUSED,
+                    Evas_Object *efm               EINA_UNUSED,
+                    const Efm_Menu_Item *menu_item EINA_UNUSED)
 {
   Popup_Context *ctx = data;
-  printf("XXX: mkdir\n");
+  Eina_Strbuf   *buf = cmd_strbuf_new("file-new-dir");
+
+  cmd_strbuf_exe_consume(buf, ctx->sd->exe_open);
 }
 
 static void
@@ -329,7 +329,6 @@ _efm_popup_icon_menu_add(Smart_Data *sd, Icon *ic, Evas_Coord x, Evas_Coord y)
   Eina_Bool       have_sel = EINA_FALSE; // have any selected icons
   Eina_Bool       have_nosel = EINA_FALSE; // have no icons selected at all
 
-  printf("POPUP MENU\n");
   if (_efm_sel_first_get(sd)) have_sel = EINA_TRUE;
   if (_efm_sel_not_count(sd) != 0) have_nosel = EINA_TRUE;
 
diff --git a/src/efm/efm_structs.h b/src/efm/efm_structs.h
index ef608ef..b286df5 100644
--- a/src/efm/efm_structs.h
+++ b/src/efm/efm_structs.h
@@ -232,6 +232,7 @@ struct _Icon
   Eina_Bool      over        : 1;
   Eina_Bool      over_before : 1;
   Eina_Bool      over_after  : 1;
+  Eina_Bool      rename_me   : 1;
 };
 
 typedef struct _Pending_Exe_Del Pending_Exe_Del;
diff --git a/src/efm/efm_util.c b/src/efm/efm_util.c
index 9b62365..906af00 100644
--- a/src/efm/efm_util.c
+++ b/src/efm/efm_util.c
@@ -693,7 +693,7 @@ _icon_rename_end(Icon *icon)
 {
   if (icon->sd->rename_icon != icon) return;
   icon->sd->rename_icon = NULL;
-  printf("end renaming icon %s\n", icon->info.file);
+  printf("XXX: end renaming icon [%s]\n", icon->info.file);
   icon->renaming = EINA_FALSE;
   evas_object_del(icon->o_entry);
   icon->o_entry = NULL;
@@ -758,6 +758,7 @@ _icon_rename_begin(Icon *icon)
   evas_object_smart_callback_add(o, "activated", _cb_entry_activated, icon);
   edje_object_part_swallow(icon->o_base, "e.swallow.entry", o);
   evas_object_show(o);
+  elm_entry_select_all(o);
   elm_object_focus_set(o, EINA_TRUE);
 }
 
@@ -2767,7 +2768,7 @@ _cb_reblock(void *data)
   // instead of everything
   Smart_Data *sd = data;
   Eina_List  *l;
-  Icon       *icon;
+  Icon       *icon, *icon_rename = NULL;
   Block      *block;
   Eina_Bool   listing_done_reblock = sd->listing_done_reblock;
 
@@ -2802,6 +2803,11 @@ _cb_reblock(void *data)
     // adjust block reslize num if icon is realized
     if (icon->realized) block->realized_num++;
     if (icon->selected) block->selected_num++;
+    if (icon->rename_me)
+      {
+        icon->rename_me = EINA_FALSE;
+        icon_rename = icon;
+      }
   }
   // flag the obj to have had our blocks re-done so we also then re-calc
   // which blocks are visible or not and unrealize/realize icons as
@@ -2816,6 +2822,13 @@ _cb_reblock(void *data)
                                sd->restore_region.h);
       sd->restore_region.w = 0;
     }
+  if (icon_rename)
+    {
+      _efm_sel_none(sd);
+      _icon_select(icon_rename);
+      _efm_icon_bring_in(icon_rename);
+      _efm_sel_rename(sd);
+    }
 }
 
 void

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to