This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository entice.
View the commit online.
commit 2d63b7fa5c6679303023fda057c3e0a9aca9b0a7
Author: Vincent Torri <vto...@outlook.fr>
AuthorDate: Sat Jun 21 06:02:23 2025 +0200
thumb generator: create .eet if it does not exist
---
src/bin/entice_thumb.c | 135 --------------------------
src/bin/entice_thumb.h | 12 ---
src/bin/entice_thumb_gen.c | 2 +-
src/bin/entice_winlist.c | 4 +-
src/bin/meson.build | 4 +-
src/bin/thumb_generator/entice_thumb_viewer.c | 132 ++++++++++++++++++-------
6 files changed, 103 insertions(+), 186 deletions(-)
diff --git a/src/bin/entice_thumb.c b/src/bin/entice_thumb.c
deleted file mode 100644
index 3fd10c5..0000000
--- a/src/bin/entice_thumb.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * SPDX-FileCopyrightText: Vincent Torri <vincent.to...@gmail.com>
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <config.h>
-
-#include <sys/stat.h>
-
-#include <Efreet.h>
-
-/*============================================================================*
- * Local *
- *============================================================================*/
-
-static void
-_entice_thumb_sha1_str(unsigned char sha[20], char shastr[41])
-{
- const char *chmap = "0123456789abcdef";
- int i;
-
- for (i = 0; i < 20; i++)
- {
- shastr[(i * 2) ] = chmap[(sha[i] >> 4) & 0xf];
- shastr[(i * 2) + 1] = chmap[ sha[i] & 0xf];
- }
- shastr[i * 2] = 0;
-}
-
-/*============================================================================*
- * Global *
- *============================================================================*/
-
-Eina_Bool
-entice_thumb_sha1(const char *file, unsigned char dst[20])
-{
- char buf[128];
-
-#ifdef _WIN32
- BY_HANDLE_FILE_INFORMATION info;
- HANDLE h;
- LARGE_INTEGER size;
- LARGE_INTEGER file_index;
- LARGE_INTEGER creation;
- LARGE_INTEGER last_write;
- BOOL res;
-
- h = CreateFile(file, GENERIC_READ, FILE_SHARE_READ,
- NULL, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (h == INVALID_HANDLE_VALUE)
- return EINA_FALSE;
-
- res = GetFileInformationByHandle(h, &info);
- CloseHandle(h);
- if (!res)
- return EINA_FALSE;
-
- size.LowPart = info.nFileSizeLow;
- size.HighPart = info.nFileSizeHigh;
- file_index.LowPart = info.nFileIndexLow;
- file_index.HighPart = info.nFileIndexHigh;
- creation.LowPart = info.ftCreationTime.dwLowDateTime;
- creation.HighPart = info.ftCreationTime.dwHighDateTime;
- last_write.LowPart = info.ftLastWriteTime.dwLowDateTime;
- last_write.HighPart = info.ftLastWriteTime.dwHighDateTime;
-
- snprintf(buf, sizeof(buf),
- "%llu %llu %llu %llu %llu %llu",
- (unsigned long long)(info.dwVolumeSerialNumber),
- (unsigned long long)(info.dwFileAttributes),
- (unsigned long long)(size.QuadPart),
- (unsigned long long)(file_index.QuadPart),
- (unsigned long long)(creation.QuadPart),
- (unsigned long long)(last_write.QuadPart));
-#else
-# ifdef STAT_NSEC
-# ifdef st_mtime
-# define STAT_NSEC_MTIME(st) (unsigned long long)((st).st_mtim.tv_nsec)
-# define STAT_NSEC_CTIME(st) (unsigned long long)((st).st_ctim.tv_nsec)
-# else
-# define STAT_NSEC_MTIME(st) (unsigned long long)((st).st_mtimensec)
-# define STAT_NSEC_CTIME(st) (unsigned long long)((st).st_ctimensec)
-# endif
-# else
-# define STAT_NSEC_MTIME(st) (unsigned long long)(0)
-# define STAT_NSEC_CTIME(st) (unsigned long long)(0)
-# endif
- struct stat st;
-
- if (stat(file, &st) != 0)
- return EINA_FALSE;
-
- snprintf(buf, sizeof(buf),
- "%llu %llu %llu %llu %llu %llu %llu %llu",
- (unsigned long long)(st.st_mode),
- (unsigned long long)(st.st_uid),
- (unsigned long long)(st.st_gid),
- (unsigned long long)(st.st_size),
- (unsigned long long)(st.st_mtime),
- (unsigned long long)(st.st_ctime),
- STAT_NSEC_MTIME(st),
- STAT_NSEC_CTIME(st));
-#endif
-
- eina_sha1((unsigned char *)buf, strlen(buf), dst);
-
- return EINA_TRUE;
-}
-
-Eina_Strbuf *
-entice_thumb_find(const char *path)
-{
- unsigned char sha[20];
- char sha_str[41];
- Eina_Strbuf *buf;
-
- buf = eina_strbuf_new();
- if (!buf)
- return NULL;
-
- eina_sha1((const unsigned char *)path, strlen(path), sha);
- _entice_thumb_sha1_str(sha, sha_str);
-
- eina_strbuf_append(buf, efreet_cache_home_get());
- eina_strbuf_append_length(buf, "/entice/thumbs/", sizeof("/entice/thumbs/") - 1);
- eina_strbuf_append_char(buf, sha_str[0]);
- eina_strbuf_append_char(buf, sha_str[1]);
- eina_strbuf_append_char(buf, '/');
- eina_strbuf_append_length(buf, sha_str, 40);
- eina_strbuf_append(buf, ".eet");
-
- return buf;
-}
diff --git a/src/bin/entice_thumb.h b/src/bin/entice_thumb.h
deleted file mode 100644
index 1908d52..0000000
--- a/src/bin/entice_thumb.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * SPDX-FileCopyrightText: Vincent Torri <vincent.to...@gmail.com>
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#ifndef ENTICE_THUMB_H
-#define ENTICE_THUMB_H
-
-Eina_Bool entice_thumb_sha1(const char *file, unsigned char dst[20]);
-Eina_Strbuf *entice_thumb_find(const char *path);
-
-#endif /* ENTICE_THUMB_H */
diff --git a/src/bin/entice_thumb_gen.c b/src/bin/entice_thumb_gen.c
index 1d7360d..a69374d 100644
--- a/src/bin/entice_thumb_gen.c
+++ b/src/bin/entice_thumb_gen.c
@@ -7,7 +7,7 @@
#include <Elementary.h>
-#include "entice_thumb.h"
+#include "entice_thumb_common.h"
#include "entice_thumb_gen.h"
Evas_Object *win = NULL;
diff --git a/src/bin/entice_winlist.c b/src/bin/entice_winlist.c
index aed7286..fe8acbc 100644
--- a/src/bin/entice_winlist.c
+++ b/src/bin/entice_winlist.c
@@ -10,7 +10,7 @@
#include "entice_private.h"
#include "entice_config.h"
#include "entice_image.h"
-#include "entice_thumb.h"
+#include "entice_thumb_common.h"
#include "entice_win.h"
#include "entice_winlist.h"
@@ -86,7 +86,7 @@ entice_winlist_genlist_content_get(void *data, Evas_Object *obj, const char *par
// TODO: check if d->path needs thumbnail (image, edje, ...)
- buf = entice_thumb_find(d->path);
+ buf = entice_thumb_path_get(d->path);
if (buf)
{
Eet_File *ef;
diff --git a/src/bin/meson.build b/src/bin/meson.build
index 38d2bfd..d0c23fa 100644
--- a/src/bin/meson.build
+++ b/src/bin/meson.build
@@ -4,7 +4,7 @@
# entice thumb generator executable
entice_thumb_gen_src = files([
- 'entice_thumb.c',
+ 'entice_thumb_common.c',
'entice_thumb_gen.c',
'entice_thumb_util_file.c',
'entice_thumb_util_img.c',
@@ -35,7 +35,7 @@ entice_bin_src = [
'entice_main.c',
'entice_settings.c',
'entice_theme.c',
- 'entice_thumb.c',
+ 'entice_thumb_common.c',
'entice_win.c',
'entice_winlist.c'
]
diff --git a/src/bin/thumb_generator/entice_thumb_viewer.c b/src/bin/thumb_generator/entice_thumb_viewer.c
index faff322..cd0328d 100644
--- a/src/bin/thumb_generator/entice_thumb_viewer.c
+++ b/src/bin/thumb_generator/entice_thumb_viewer.c
@@ -17,7 +17,16 @@
#define ENTICE_THUMB_VIEWER_COPYRIGHT "(C) 2025 Vincent Torri and others"
+typedef struct
+{
+ Eina_Strbuf *buf; /* path of .eet file */
+ Ecore_Exe *exe;
+ Eet_File *ef;
+ Evas_Object *vbox;
+} Data;
+
static int entice_thumb_log_dom_global = 1;
+static Ecore_Event_Handler *thumb_exe_del_handler = NULL;
static Ecore_Getopt options = {
PACKAGE_NAME,
@@ -36,6 +45,76 @@ static Ecore_Getopt options = {
}
};
+static void
+display_thumb(Data *d)
+{
+ int sizes[] = { 16, 32, 64, 128, 256, 512 };
+ Eina_Strbuf *buf;
+ size_t i;
+
+ buf = eina_strbuf_new();
+ if (!buf)
+ return;
+
+ for (i = 0; i < sizeof(sizes) / sizeof(int); i++)
+ {
+ Evas_Object *o;
+ unsigned int *thumb_img;
+ int size = 0;
+ Eina_Bool ret;
+
+ eina_strbuf_reset(buf);
+
+ if (!eina_strbuf_append_printf(buf, "image/thumb/%u", sizes[i]))
+ continue;
+
+ thumb_img = eet_read(d->ef, eina_strbuf_string_get(buf), &size);
+
+ o = elm_image_add(d->vbox);
+ ret = elm_image_memfile_set(o, thumb_img, size, "jpg", NULL);
+ if (!ret)
+ {
+ ERR("file '%s' is not an image file or format is not supported.",
+ eet_file_get(d->ef));
+ continue;
+ }
+
+ evas_object_size_hint_min_set(o, sizes[i], sizes[i]);
+ evas_object_size_hint_max_set(o, sizes[i], sizes[i]);
+
+ elm_box_pack_end(d->vbox, o);
+ evas_object_show(o);
+ }
+
+ eina_strbuf_free(buf);
+}
+
+static Eina_Bool
+_cb_thumb_exe_del(void *data, int ev_type EINA_UNUSED, void *event)
+{
+ Data *d = data;
+ Ecore_Exe_Event_Del *ev = event;
+
+ printf(" * exe cb : %d\n", ev->exit_code);
+ fflush(stdout);
+
+ if (d->exe != ev->exe)
+ return ECORE_CALLBACK_PASS_ON;
+
+ if (ev->exit_code == 0)
+ {
+ ERR("thumb generated");
+ d->ef = eet_open(eina_strbuf_string_get(d->buf), EET_FILE_MODE_READ);
+ if (!d->ef)
+ return ECORE_CALLBACK_PASS_ON;
+ display_thumb(d);
+ eet_close(d->ef);
+ eina_strbuf_free(d->buf);
+ }
+
+ return ECORE_CALLBACK_DONE;
+}
+
EAPI_MAIN int
elm_main(int argc, char **argv)
{
@@ -44,7 +123,6 @@ elm_main(int argc, char **argv)
Evas_Object *win;
Evas_Object *scroller;
Evas_Object *vbox;
- Evas_Object *image;
Evas_Object *o;
Eina_Strbuf *buf;
Eina_Bool quit_option = EINA_FALSE;
@@ -162,6 +240,7 @@ elm_main(int argc, char **argv)
if (ef)
{
unsigned char sha[20];
+ Data d;
/* thumb file exists - check meta data */
if (entice_thumb_sha1(argv[args], sha))
@@ -176,12 +255,22 @@ elm_main(int argc, char **argv)
ok = EINA_TRUE; // sha1 of stat data matches - ok
}
}
+
+ if (ok)
+ {
+ d.buf = NULL;
+ d.ef = ef;
+ d.vbox = vbox;
+ display_thumb(&d);
+ }
+
eet_close(ef);
}
if (!ok)
{
- /* need to regenerate */
+ /* need to generate */
+ Data d;
Eina_Strbuf *cmd;
cmd = entice_thumb_gen_cmd_get(argv[args]);
@@ -192,38 +281,13 @@ elm_main(int argc, char **argv)
}
eina_strbuf_append_buffer(cmd, buf);
exe = ecore_exe_run(eina_strbuf_string_get(cmd), NULL);
- }
-
- ef = eet_open(eina_strbuf_string_get(buf), EET_FILE_MODE_READ);
- if (ef)
- {
- int sizes[] = { 16, 32, 64, 128, 256, 512 };
- unsigned int *th;
- int size = 0;
- size_t i;
-
- for (i = 0; i < sizeof(sizes) / sizeof(int); i++)
- {
- char part[64];
- snprintf(part, sizeof(part), "image/thumb/%u", sizes[i]);
- th = eet_read(ef, part, &size);
-
- o = elm_image_add(vbox);
- ret = elm_image_memfile_set(o, th, size, "jpg", NULL);
- if (!ret)
- {
- ERR("file '%s' is not an image file or format is not supported.",
- argv[args]);
- goto unregister_log;
- }
- evas_object_size_hint_min_set(o, sizes[i], sizes[i]);
- evas_object_size_hint_max_set(o, sizes[i], sizes[i]);
-
- elm_box_pack_end(vbox, o);
- evas_object_show(o);
- }
-
- eet_close(ef);
+ d.buf = buf;
+ d.exe = exe;
+ d.ef = NULL;
+ d.vbox = vbox;
+ thumb_exe_del_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
+ _cb_thumb_exe_del,
+ &d);
}
win_w = 960;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.