Now ethumb read from and saves to eet files.

SVN revision: 40050
This commit is contained in:
Rafael Antognolli 2009-04-14 19:14:08 +00:00
parent cd8dd91b01
commit a95c0b221f
3 changed files with 35 additions and 13 deletions

View File

@ -113,6 +113,8 @@ const Ecore_Getopt optdesc = {
ECORE_GETOPT_CALLBACK_ARGS ECORE_GETOPT_CALLBACK_ARGS
('t', "theme", "path to theme file, group and swallow part.", ('t', "theme", "path to theme file, group and swallow part.",
"file:group:swallow_part", _ethumb_getopt_callback_frame_parse, NULL), "file:group:swallow_part", _ethumb_getopt_callback_frame_parse, NULL),
ECORE_GETOPT_STORE_STR
('k', "key", "key inside eet file to read image from."),
ECORE_GETOPT_LICENSE('L', "license"), ECORE_GETOPT_LICENSE('L', "license"),
ECORE_GETOPT_COPYRIGHT('C', "copyright"), ECORE_GETOPT_COPYRIGHT('C', "copyright"),
ECORE_GETOPT_VERSION('V', "version"), ECORE_GETOPT_VERSION('V', "version"),
@ -133,7 +135,10 @@ main(int argc, char *argv[])
char *aspect_str = NULL; char *aspect_str = NULL;
char *directory = NULL; char *directory = NULL;
char *category = NULL; char *category = NULL;
char *src_key = NULL;
struct frame frame = {NULL}; struct frame frame = {NULL};
const char *thumb_path = NULL;
const char *thumb_key = NULL;
int arg_index; int arg_index;
int i; int i;
@ -147,6 +152,7 @@ main(int argc, char *argv[])
ECORE_GETOPT_VALUE_STR(directory), ECORE_GETOPT_VALUE_STR(directory),
ECORE_GETOPT_VALUE_STR(category), ECORE_GETOPT_VALUE_STR(category),
ECORE_GETOPT_VALUE_PTR_CAST(frame), ECORE_GETOPT_VALUE_PTR_CAST(frame),
ECORE_GETOPT_VALUE_STR(src_key),
ECORE_GETOPT_VALUE_BOOL(quit_option), ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option), ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option), ECORE_GETOPT_VALUE_BOOL(quit_option),
@ -194,10 +200,13 @@ main(int argc, char *argv[])
} }
if (r && arg_index < argc) if (r && arg_index < argc)
ef = ethumb_file_new(e, argv[arg_index++]); ef = ethumb_file_new(e, argv[arg_index++], src_key);
if (ef && arg_index < argc) if (ef && arg_index < argc)
ethumb_file_thumb_path_set(ef, argv[arg_index++]); thumb_path = argv[arg_index++];
if (ef && arg_index < argc)
thumb_key = argv[arg_index];
ethumb_file_thumb_path_set(ef, thumb_path, thumb_key);
if (ef) if (ef)
ethumb_file_generate(ef); ethumb_file_generate(ef);

View File

@ -386,7 +386,7 @@ ethumb_thumb_category_get(Ethumb *e)
} }
EAPI Ethumb_File * EAPI Ethumb_File *
ethumb_file_new(Ethumb *e, const char *path) ethumb_file_new(Ethumb *e, const char *path, const char *key)
{ {
Ethumb_File *ef; Ethumb_File *ef;
@ -404,6 +404,9 @@ ethumb_file_new(Ethumb *e, const char *path)
ef->ethumb = e; ef->ethumb = e;
ef->src_path = eina_stringshare_add(path); ef->src_path = eina_stringshare_add(path);
if (key)
ef->src_key = eina_stringshare_add(key);
return ef; return ef;
} }
@ -539,24 +542,31 @@ ethumb_file_free(Ethumb_File *ef)
return; return;
eina_stringshare_del(ef->src_path); eina_stringshare_del(ef->src_path);
eina_stringshare_del(ef->src_key);
eina_stringshare_del(ef->thumb_path); eina_stringshare_del(ef->thumb_path);
eina_stringshare_del(ef->thumb_key);
free(ef); free(ef);
} }
EAPI void EAPI void
ethumb_file_thumb_path_set(Ethumb_File *ef, const char *path) ethumb_file_thumb_path_set(Ethumb_File *ef, const char *path, const char *key)
{ {
char *real_path; char *real_path;
char buf[PATH_MAX]; char buf[PATH_MAX];
EINA_SAFETY_ON_NULL_RETURN(ef); EINA_SAFETY_ON_NULL_RETURN(ef);
if (ef->thumb_path)
eina_stringshare_del(ef->thumb_path);
real_path = realpath(path, buf); real_path = realpath(path, buf);
if (errno == ENOENT || errno == ENOTDIR || real_path) if (!path)
ef->thumb_path = eina_stringshare_add(buf); {
eina_stringshare_replace(&ef->thumb_path, NULL);
eina_stringshare_replace(&ef->thumb_key, NULL);
}
else if (errno == ENOENT || errno == ENOTDIR || real_path)
{
eina_stringshare_replace(&ef->thumb_path, buf);
eina_stringshare_replace(&ef->thumb_key, key);
}
else else
ERR("could not set thumbnail path: %s\n", strerror(errno)); ERR("could not set thumbnail path: %s\n", strerror(errno));
} }
@ -630,7 +640,7 @@ _ethumb_image_load(Ethumb_File *ef)
evas_object_hide(img); evas_object_hide(img);
evas_object_image_file_set(img, NULL, NULL); evas_object_image_file_set(img, NULL, NULL);
evas_object_image_load_size_set(img, eth->tw, eth->th); evas_object_image_load_size_set(img, eth->tw, eth->th);
evas_object_image_file_set(img, ef->src_path, NULL); evas_object_image_file_set(img, ef->src_path, ef->src_key);
if (eth->frame) if (eth->frame)
evas_object_show(eth->frame->edje); evas_object_show(eth->frame->edje);
@ -714,7 +724,8 @@ ethumb_file_generate(Ethumb_File *ef)
return 0; return 0;
} }
r = evas_object_image_save(eth->o, ef->thumb_path, NULL, "quality=85"); r = evas_object_image_save(eth->o, ef->thumb_path, ef->thumb_key,
"quality=85");
if (!r) if (!r)
{ {

View File

@ -93,7 +93,9 @@ struct _Ethumb_File
{ {
Ethumb *ethumb; Ethumb *ethumb;
const char *src_path; const char *src_path;
const char *src_key;
const char *thumb_path; const char *thumb_path;
const char *thumb_key;
int w, h; int w, h;
}; };
@ -128,9 +130,9 @@ EAPI const char * ethumb_thumb_dir_path_get(Ethumb *e) EINA_WARN_UNUSED_RESULT E
EAPI void ethumb_thumb_category_set(Ethumb *e, const char *category) EINA_ARG_NONNULL(1); EAPI void ethumb_thumb_category_set(Ethumb *e, const char *category) EINA_ARG_NONNULL(1);
EAPI const char * ethumb_thumb_category_get(Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE; EAPI const char * ethumb_thumb_category_get(Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
EAPI Ethumb_File * ethumb_file_new(Ethumb *e, const char *path) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2); EAPI Ethumb_File * ethumb_file_new(Ethumb *e, const char *path, const char *key) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2);
EAPI void ethumb_file_free(Ethumb_File *ef); EAPI void ethumb_file_free(Ethumb_File *ef);
EAPI void ethumb_file_thumb_path_set(Ethumb_File *ef, const char *path) EINA_ARG_NONNULL(1); EAPI void ethumb_file_thumb_path_set(Ethumb_File *ef, const char *path, const char *key) EINA_ARG_NONNULL(1);
EAPI const char * ethumb_file_thumb_path_get(Ethumb_File *ef) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE; EAPI const char * ethumb_file_thumb_path_get(Ethumb_File *ef) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
EAPI int ethumb_file_generate(Ethumb_File *ef) EINA_ARG_NONNULL(1); EAPI int ethumb_file_generate(Ethumb_File *ef) EINA_ARG_NONNULL(1);