This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch devs/thanatermesis/paste-media
in repository terminology.

View the commit online.

commit 3c9de693fe4101e70f648c6ea84980b00b762eed
Author: Samuel F. Baggen <thanaterme...@gmail.com>
AuthorDate: Mon Aug 18 00:04:15 2025 -0500

    improved modal window with preview, filename, and unique instance
    
    Signed-off-by: Thanatermesis <thanaterme...@gmail.com>
---
 src/bin/termio.c | 105 ++++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 85 insertions(+), 20 deletions(-)

diff --git a/src/bin/termio.c b/src/bin/termio.c
index 50968235..2e5a00de 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -1243,6 +1243,7 @@ _popup_save_del_cb(void *data,
                    void *event_info EINA_UNUSED)
 {
    Save_Image_Data *sid = data;
+   evas_object_data_del(sid->termio, "save_popup");
    evas_object_del(sid->img_obj);
    free(sid);
 }
@@ -1294,10 +1295,16 @@ _popup_save_keydown_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UN
 static void
 _popup_save_image_show(Termio *sd, Evas_Object *img_obj_from_sel)
 {
+   Evas_Object *prev_popup;
+
    if (!img_obj_from_sel) return;
 
+   if (sd->ctxpopup) evas_object_del(sd->ctxpopup);
+   prev_popup = evas_object_data_get(sd->self, "save_popup");
+   if (prev_popup) evas_object_del(prev_popup);
+
    Evas *e = evas_object_evas_get(sd->win);
-   Evas_Object *popup, *box, *entry, *btn_box, *ok_btn, *cancel_btn;
+   Evas_Object *popup, *main_box, *content_box, *image_box, *entry, *btn_box, *ok_btn, *cancel_btn;
    Evas_Object *new_img;
    int w, h;
    const void *img_data;
@@ -1335,27 +1342,66 @@ _popup_save_image_show(Termio *sd, Evas_Object *img_obj_from_sel)
      }
 
    popup = elm_popup_add(sd->win);
-   elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
+   evas_object_data_set(sd->self, "save_popup", popup);
+   elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP);
    evas_object_show(popup);
 
-   box = elm_box_add(popup);
-   elm_box_horizontal_set(box, EINA_FALSE);
-   evas_object_show(box);
+   main_box = elm_box_add(popup);
+   elm_box_horizontal_set(main_box, EINA_TRUE);
+   evas_object_show(main_box);
    elm_object_part_text_set(popup, "title,text", "Save image as...");
 
+   /* Make popup full width */
+   evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+   /* Create image box on the left */
+   image_box = elm_box_add(popup);
+   elm_box_horizontal_set(image_box, EINA_FALSE);
+   evas_object_size_hint_weight_set(image_box, 0.4, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(image_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_show(image_box);
+
+   /* Add the image to the image box */
+   evas_object_size_hint_weight_set(new_img, 0.4, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(new_img, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_show(new_img);
+   elm_box_pack_end(image_box, new_img);
+
+   /* Create content box for entry and buttons on the right */
+   content_box = elm_box_add(popup);
+   elm_box_horizontal_set(content_box, EINA_FALSE);
+   evas_object_size_hint_weight_set(content_box, 0.6, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(content_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_show(content_box);
+
    entry = elm_entry_add(popup);
    elm_entry_single_line_set(entry, EINA_TRUE);
    elm_entry_scrollable_set(entry, EINA_TRUE);
    {
-      char filename[256];
+      char filename[PATH_MAX];
+      const char *ext = ".png", *orig_file, *p;
+
+      evas_object_image_file_get(img_obj_from_sel, &orig_file, NULL);
+      if (orig_file)
+        {
+           p = strrchr(orig_file, '.');
+           if (p) ext = p;
+        }
+
       time_t t = time(NULL);
       struct tm *tm = localtime(&t);
-      strftime(filename, sizeof(filename), "pasted-image-%Y%m%d-%H%M%S.png", tm);
+      snprintf(filename, sizeof(filename), "pasted-image-");
+      size_t len = strlen(filename);
+      strftime(filename + len, sizeof(filename) - len, "%Y%m%d-%H%M%S", tm);
+      len = strlen(filename);
+      snprintf(filename + len, sizeof(filename) - len, "%s", ext);
+
       elm_object_text_set(entry, filename);
    }
    evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
-   elm_box_pack_end(box, entry);
+   elm_box_pack_end(content_box, entry);
    evas_object_show(entry);
 
    btn_box = elm_box_add(popup);
@@ -1375,9 +1421,14 @@ _popup_save_image_show(Termio *sd, Evas_Object *img_obj_from_sel)
    elm_box_pack_end(btn_box, cancel_btn);
    evas_object_show(cancel_btn);
 
-   elm_box_pack_end(box, btn_box);
+   elm_box_pack_end(content_box, btn_box);
    evas_object_show(btn_box);
-   elm_object_content_set(popup, box);
+
+   /* Pack image box and content box into main box */
+   elm_box_pack_end(main_box, image_box);
+   elm_box_pack_end(main_box, content_box);
+
+   elm_object_content_set(popup, main_box);
 
    elm_object_focus_set(ok_btn, EINA_TRUE);
 
@@ -1560,24 +1611,38 @@ _getsel_targets_cb(void *data,
              printf("_getsel_targets_cb: current extension is '%s'\n", current_ext ? current_ext : "(null)");
              if (!current_ext || strcasecmp(current_ext, ext) != 0)
                {
-                  printf("_getsel_targets_cb: attempting to rename file due to extension mismatch\n");
-                  size_t len = strlen(orig_filepath) + strlen(ext) + 1;
-                  new_filepath = malloc(len);
-                  if (new_filepath)
+                  char temp_path[PATH_MAX];
+                  const char *user = getenv("USER");
+                  if (!user) user = "nobody";
+                  time_t t = time(NULL);
+                  struct tm *tm = localtime(&t);
+
+                  printf("_getsel_targets_cb: attempting to move temp file due to extension mismatch\n");
+
+                  snprintf(temp_path, sizeof(temp_path), "/tmp/terminology-paste-%s-", user);
+                  size_t len = strlen(temp_path);
+                  strftime(temp_path + len, sizeof(temp_path) - len, "%Y%m%d-%H%M%S", tm);
+                  len = strlen(temp_path);
+                  snprintf(temp_path + len, sizeof(temp_path) - len, "%s", ext);
+
+                  if (ecore_file_mv(orig_filepath, temp_path))
                     {
-                       snprintf(new_filepath, len, "%s%s", orig_filepath, ext);
-                       if (ecore_file_mv(orig_filepath, new_filepath))
+                       new_filepath = strdup(temp_path);
+                       if (new_filepath)
                          {
-                            printf("_getsel_targets_cb: renamed '%s' to '%s'\n", orig_filepath, new_filepath);
+                            printf("_getsel_targets_cb: moved '%s' to '%s'\n", orig_filepath, new_filepath);
                             filepath = new_filepath;
                          }
                        else
                          {
-                            printf("_getsel_targets_cb: failed to rename '%s' to '%s'\n", orig_filepath, new_filepath);
-                            free(new_filepath);
-                            new_filepath = NULL;
+                            printf("_getsel_targets_cb: failed to allocate memory for temp path\n");
+                            ecore_file_mv(temp_path, orig_filepath);
                          }
                     }
+                  else
+                    {
+                       printf("_getsel_targets_cb: failed to move '%s' to '%s'\n", orig_filepath, temp_path);
+                    }
                }
           }
 

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

Reply via email to