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 39516096528642b24afb268fcbae6d2d4319c1c0
Author: Samuel F. Baggen <[email protected]>
AuthorDate: Mon Aug 18 00:29:22 2025 -0500

    delete temporal files and other cleanups
    
    Signed-off-by: Thanatermesis <[email protected]>
---
 src/bin/termio.c | 66 ++++++++++++++++++++++++++------------------------------
 1 file changed, 30 insertions(+), 36 deletions(-)

diff --git a/src/bin/termio.c b/src/bin/termio.c
index 2e5a00de..7b8d017f 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -1234,6 +1234,8 @@ typedef struct _Save_Image_Data
    Evas_Object *popup;
    Evas_Object *entry;
    Evas_Object *img_obj;
+   char *orig_filepath;
+   char *temp_filepath;
 } Save_Image_Data;
 
 static void
@@ -1245,6 +1247,18 @@ _popup_save_del_cb(void *data,
    Save_Image_Data *sid = data;
    evas_object_data_del(sid->termio, "save_popup");
    evas_object_del(sid->img_obj);
+
+   /* Clean up temporary files if they exist */
+   if (sid->temp_filepath)
+     {
+        ecore_file_unlink(sid->temp_filepath);
+        free(sid->temp_filepath);
+     }
+   if (sid->orig_filepath)
+     {
+        free(sid->orig_filepath);
+     }
+
    free(sid);
 }
 
@@ -1293,7 +1307,8 @@ _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)
+_popup_save_image_show(Termio *sd, Evas_Object *img_obj_from_sel,
+                       char *temp_filepath, const char *orig_filepath)
 {
    Evas_Object *prev_popup;
 
@@ -1358,12 +1373,12 @@ _popup_save_image_show(Termio *sd, Evas_Object *img_obj_from_sel)
    /* 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_weight_set(image_box, 0.3, 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_weight_set(new_img, 0.3, 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);
@@ -1371,7 +1386,7 @@ _popup_save_image_show(Termio *sd, Evas_Object *img_obj_from_sel)
    /* 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_weight_set(content_box, 0.7, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(content_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_show(content_box);
 
@@ -1436,6 +1451,11 @@ _popup_save_image_show(Termio *sd, Evas_Object *img_obj_from_sel)
    sid->popup = popup;
    sid->entry = entry;
    sid->img_obj = new_img;
+   sid->temp_filepath = temp_filepath;
+   if (orig_filepath)
+     sid->orig_filepath = strdup(orig_filepath);
+   else
+     sid->orig_filepath = NULL;
 
    evas_object_smart_callback_add(entry, "activated", _popup_save_ok_cb, sid);
    evas_object_smart_callback_add(ok_btn, "clicked", _popup_save_ok_cb, sid);
@@ -1453,12 +1473,10 @@ _getsel_cb(void *data,
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
 
-   printf("_getsel_cb: format=%d, len=%zd\n", ev->format, ev->len);
    if (ev->format == ELM_SEL_FORMAT_TEXT)
      {
         char *buf;
 
-        printf("_getsel_cb: Pasting text.\n");
         if (ev->len <= 0) return EINA_TRUE;
 
         buf = calloc(2, ev->len); /* twice in case the paste is only \n */
@@ -1503,15 +1521,13 @@ _getsel_cb(void *data,
      {
         Evas_Object *img_obj_from_sel;
 
-        printf("_getsel_cb: Pasting image. data="" ev->data ? (const char *)ev->data : "(null)");
         sscanf((const char *)ev->data, "%p", &img_obj_from_sel);
         if (img_obj_from_sel)
           {
-             _popup_save_image_show(sd, img_obj_from_sel);
+             _popup_save_image_show(sd, img_obj_from_sel, NULL, NULL);
           }
         else
           {
-             printf("_getsel_cb: could not get image object from selection.\n");
              WRN("could not get image object from selection");
           }
      }
@@ -1544,14 +1560,12 @@ _getsel_targets_cb(void *data,
    Termio *sd = evas_object_smart_data_get(data);
    EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
 
-   printf("_getsel_targets_cb: ev->data = "" len=%zd\n", ev->data ? (const char *)ev->data : "(null)", ev->len);
    if (ev->data &&
        ((strstr(ev->data, "application/x-elementary-image")) ||
         (strstr(ev->data, "image/")) ||
         (strstr(ev->data, "text/uri-list"))
        ))
      {
-        printf("_getsel_targets_cb: Found image target, getting image data.\n");
         elm_cnp_selection_get(sd->win, sd->sel_type, ELM_SEL_FORMAT_IMAGE,
                               _getsel_cb, data);
         return EINA_TRUE;
@@ -1563,7 +1577,6 @@ _getsel_targets_cb(void *data,
              strstr(ev->data, "STRING"))
             )
      {
-        printf("_getsel_targets_cb: Found text target, getting text data.\n");
         elm_cnp_selection_get(sd->win, sd->sel_type, ELM_SEL_FORMAT_TEXT,
                               _getsel_cb, data);
         return EINA_TRUE;
@@ -1585,7 +1598,6 @@ _getsel_targets_cb(void *data,
         orig_filepath = filepath;
 
         const char *mime = efreet_mime_type_get(orig_filepath);
-        printf("_getsel_targets_cb: mime type of '%s' is '%s'\n", orig_filepath, mime ? mime : "(null)");
         const char *ext = NULL;
 
         if (mime)
@@ -1601,14 +1613,11 @@ _getsel_targets_cb(void *data,
         if (!ext)
           {
              ext = _get_image_extension_from_file_content(orig_filepath);
-             printf("_getsel_targets_cb: fallback file content detection gave extension '%s'\n", ext ? ext : "(null)");
           }
 
         if (ext)
           {
-             printf("_getsel_targets_cb: determined extension is '%s'\n", ext);
              const char *current_ext = strrchr(orig_filepath, '.');
-             printf("_getsel_targets_cb: current extension is '%s'\n", current_ext ? current_ext : "(null)");
              if (!current_ext || strcasecmp(current_ext, ext) != 0)
                {
                   char temp_path[PATH_MAX];
@@ -1617,8 +1626,6 @@ _getsel_targets_cb(void *data,
                   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);
@@ -1630,24 +1637,17 @@ _getsel_targets_cb(void *data,
                        new_filepath = strdup(temp_path);
                        if (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 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);
-                    }
                }
           }
 
         type = media_src_type_get(filepath, strlen(filepath));
-        printf("_getsel_targets_cb: checking path '%s', type %d\n", filepath, type);
 
         if ((type == MEDIA_TYPE_IMG) || (type == MEDIA_TYPE_SCALE))
           {
@@ -1657,19 +1657,16 @@ _getsel_targets_cb(void *data,
              const Evas_Load_Error err = evas_object_image_load_error_get(img);
              if (err == EVAS_LOAD_ERROR_NONE)
                {
-                  printf("_getsel_targets_cb: loaded image from path '%s'\n", filepath);
-                  _popup_save_image_show(sd, img);
+                  _popup_save_image_show(sd, img, new_filepath,
+                                         new_filepath ? orig_filepath : NULL);
+                  new_filepath = NULL; /* ownership transferred */
                   evas_object_del(img);
-                  if (new_filepath)
-                    {
-                       ecore_file_mv(new_filepath, orig_filepath);
-                       free(new_filepath);
-                    }
                   return EINA_TRUE;
                }
-             printf("_getsel_targets_cb: failed to load image from path '%s', error: %d\n", filepath, err);
+             ERR("failed to load image from path '%s', error: %d", filepath, err);
              evas_object_del(img);
           }
+
         if (new_filepath)
           {
              ecore_file_mv(new_filepath, orig_filepath);
@@ -1677,8 +1674,6 @@ _getsel_targets_cb(void *data,
           }
      }
 
-   printf("_getsel_targets_cb: No supported target found. Available targets: '%s'\n",
-          ev->data ? (const char *)ev->data : "(null)");
    return EINA_TRUE;
 }
 
@@ -1692,7 +1687,6 @@ termio_paste_selection(Evas_Object *obj, Elm_Sel_Type type)
        return;
    sd->sel_type = type;
 
-   printf("termio_paste_selection: type=%d\n", type);
    if ((type == ELM_SEL_TYPE_PRIMARY) || (type == ELM_SEL_TYPE_SECONDARY))
      {
         elm_cnp_selection_get(sd->win, type, ELM_SEL_FORMAT_TEXT,

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

Reply via email to