what about generating thumbnails that match the expected view size?
now generating thumbnails at 128, 256 and 512, the generation is delayed to avoid unnecessary work for ethumbd. SVN revision: 53217
This commit is contained in:
parent
2fd24ddbac
commit
e3a1481bb9
|
@ -25,7 +25,6 @@ main(int argc, char **argv)
|
||||||
r = 1;
|
r = 1;
|
||||||
goto end_log_domain;
|
goto end_log_domain;
|
||||||
}
|
}
|
||||||
ethumb_client_size_set(client, 100, 100);
|
|
||||||
ethumb_client_crop_align_set(client, 0.5, 0.5);
|
ethumb_client_crop_align_set(client, 0.5, 0.5);
|
||||||
ethumb_client_aspect_set(client, ETHUMB_THUMB_KEEP_ASPECT);
|
ethumb_client_aspect_set(client, ETHUMB_THUMB_KEEP_ASPECT);
|
||||||
ethumb_client_orientation_set(client, ETHUMB_THUMB_ORIENT_ORIGINAL);
|
ethumb_client_orientation_set(client, ETHUMB_THUMB_ORIENT_ORIGINAL);
|
||||||
|
|
|
@ -30,6 +30,9 @@ typedef enum _Ephoto_Orient Ephoto_Orient;
|
||||||
|
|
||||||
/*Main Functions*/
|
/*Main Functions*/
|
||||||
void ephoto_create_main_window(const char *directory, const char *image);
|
void ephoto_create_main_window(const char *directory, const char *image);
|
||||||
|
void ephoto_thumb_size_set(int size);
|
||||||
|
Evas_Object *ephoto_thumb_add(Evas_Object *parent, const char *path);
|
||||||
|
|
||||||
|
|
||||||
/* Configuration */
|
/* Configuration */
|
||||||
Eina_Bool ephoto_config_init(Ephoto *em);
|
Eina_Bool ephoto_config_init(Ephoto *em);
|
||||||
|
@ -85,6 +88,7 @@ struct _Ephoto_Config
|
||||||
int config_version;
|
int config_version;
|
||||||
|
|
||||||
int thumb_size;
|
int thumb_size;
|
||||||
|
int thumb_gen_size;
|
||||||
|
|
||||||
int remember_directory;
|
int remember_directory;
|
||||||
const char *directory;
|
const char *directory;
|
||||||
|
@ -122,6 +126,7 @@ extern Ephoto *em;
|
||||||
|
|
||||||
extern int __log_domain;
|
extern int __log_domain;
|
||||||
#define DBG(...) EINA_LOG_DOM_DBG(__log_domain, __VA_ARGS__)
|
#define DBG(...) EINA_LOG_DOM_DBG(__log_domain, __VA_ARGS__)
|
||||||
|
#define INF(...) EINA_LOG_DOM_INFO(__log_domain, __VA_ARGS__)
|
||||||
#define ERR(...) EINA_LOG_DOM_ERR(__log_domain, __VA_ARGS__)
|
#define ERR(...) EINA_LOG_DOM_ERR(__log_domain, __VA_ARGS__)
|
||||||
|
|
||||||
static inline Eina_Bool
|
static inline Eina_Bool
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "ephoto.h"
|
#include "ephoto.h"
|
||||||
|
|
||||||
#define CONFIG_VERSION 4
|
#define CONFIG_VERSION 5
|
||||||
|
|
||||||
static int _ephoto_config_load(Ephoto *em);
|
static int _ephoto_config_load(Ephoto *em);
|
||||||
static Eina_Bool _ephoto_on_config_save(void *data);
|
static Eina_Bool _ephoto_on_config_save(void *data);
|
||||||
|
@ -24,6 +24,7 @@ ephoto_config_init(Ephoto *em)
|
||||||
#define C_VAL(edd, type, member, dtype) EET_DATA_DESCRIPTOR_ADD_BASIC(edd, type, #member, member, dtype)
|
#define C_VAL(edd, type, member, dtype) EET_DATA_DESCRIPTOR_ADD_BASIC(edd, type, #member, member, dtype)
|
||||||
C_VAL(D, T, config_version, EET_T_INT);
|
C_VAL(D, T, config_version, EET_T_INT);
|
||||||
C_VAL(D, T, thumb_size, EET_T_INT);
|
C_VAL(D, T, thumb_size, EET_T_INT);
|
||||||
|
C_VAL(D, T, thumb_gen_size, EET_T_INT);
|
||||||
C_VAL(D, T, remember_directory, EET_T_INT);
|
C_VAL(D, T, remember_directory, EET_T_INT);
|
||||||
C_VAL(D, T, directory, EET_T_STRING);
|
C_VAL(D, T, directory, EET_T_STRING);
|
||||||
C_VAL(D, T, slideshow_timeout, EET_T_DOUBLE);
|
C_VAL(D, T, slideshow_timeout, EET_T_DOUBLE);
|
||||||
|
@ -37,6 +38,7 @@ ephoto_config_init(Ephoto *em)
|
||||||
/* Start a new config */
|
/* Start a new config */
|
||||||
em->config->config_version = CONFIG_VERSION;
|
em->config->config_version = CONFIG_VERSION;
|
||||||
em->config->thumb_size = 256;
|
em->config->thumb_size = 256;
|
||||||
|
em->config->thumb_gen_size = 256;
|
||||||
em->config->remember_directory = 1;
|
em->config->remember_directory = 1;
|
||||||
em->config->slideshow_timeout = 4.0;
|
em->config->slideshow_timeout = 4.0;
|
||||||
em->config->slideshow_transition =
|
em->config->slideshow_transition =
|
||||||
|
@ -59,6 +61,9 @@ ephoto_config_init(Ephoto *em)
|
||||||
if (em->config->config_version < 4)
|
if (em->config->config_version < 4)
|
||||||
em->config->sort_images = 1;
|
em->config->sort_images = 1;
|
||||||
|
|
||||||
|
if (em->config->config_version < 5)
|
||||||
|
em->config->thumb_gen_size = 256;
|
||||||
|
|
||||||
/* Incremental additions */
|
/* Incremental additions */
|
||||||
em->config->config_version = CONFIG_VERSION;
|
em->config->config_version = CONFIG_VERSION;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -69,8 +69,7 @@ _populate_main(void *data, const Eina_File_Direct_Info *info)
|
||||||
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
evas_object_show(frame);
|
evas_object_show(frame);
|
||||||
|
|
||||||
image = elm_thumb_add(frame);
|
image = ephoto_thumb_add(frame, info->path);
|
||||||
elm_thumb_file_set(image, info->path, NULL);
|
|
||||||
elm_object_style_set(image, "ephoto");
|
elm_object_style_set(image, "ephoto");
|
||||||
evas_object_size_hint_weight_set(image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
evas_object_size_hint_align_set(image, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
evas_object_size_hint_align_set(image, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
/*Ephoto Main Global*/
|
/*Ephoto Main Global*/
|
||||||
Ephoto *em;
|
Ephoto *em;
|
||||||
|
|
||||||
|
static Eina_List *_thumbs = NULL;
|
||||||
|
static Ecore_Timer *_thumb_gen_size_changed_timer = NULL;
|
||||||
|
|
||||||
/*Inline Callbacks*/
|
/*Inline Callbacks*/
|
||||||
static void _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event_info);
|
static void _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event_info);
|
||||||
static void _ephoto_flow_browser_delete_cb(void *data, Evas_Object *obj, void *event_info);
|
static void _ephoto_flow_browser_delete_cb(void *data, Evas_Object *obj, void *event_info);
|
||||||
|
@ -42,10 +45,22 @@ void
|
||||||
ephoto_create_main_window(const char *directory, const char *image)
|
ephoto_create_main_window(const char *directory, const char *image)
|
||||||
{
|
{
|
||||||
char current_directory[PATH_MAX];
|
char current_directory[PATH_MAX];
|
||||||
|
Ethumb_Client *client = elm_thumb_ethumb_client_get();
|
||||||
|
|
||||||
em = calloc(1, sizeof(Ephoto));
|
em = calloc(1, sizeof(Ephoto));
|
||||||
if (!ephoto_config_init(em))
|
if (!ephoto_config_init(em))
|
||||||
_ephoto_delete_main_window(NULL, NULL, NULL);
|
{
|
||||||
|
_ephoto_delete_main_window(NULL, NULL, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((em->config->thumb_gen_size != 128) &&
|
||||||
|
(em->config->thumb_gen_size != 256) &&
|
||||||
|
(em->config->thumb_gen_size != 512))
|
||||||
|
ephoto_thumb_size_set(em->config->thumb_size);
|
||||||
|
else
|
||||||
|
ethumb_client_size_set
|
||||||
|
(client, em->config->thumb_gen_size, em->config->thumb_gen_size);
|
||||||
|
|
||||||
/*Setup the main window*/
|
/*Setup the main window*/
|
||||||
em->win = elm_win_add(NULL, "ephoto", ELM_WIN_BASIC);
|
em->win = elm_win_add(NULL, "ephoto", ELM_WIN_BASIC);
|
||||||
|
@ -150,3 +165,71 @@ _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event_info)
|
||||||
elm_exit();
|
elm_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_thumb_gen_size_changed_timer_cb(void *data)
|
||||||
|
{
|
||||||
|
const int gen_size = (long)data;
|
||||||
|
Ethumb_Client *client;
|
||||||
|
const Eina_List *l;
|
||||||
|
Evas_Object *o;
|
||||||
|
|
||||||
|
if (em->config->thumb_gen_size == gen_size) goto end;
|
||||||
|
|
||||||
|
INF("thumbnail generation size changed from %d to %d",
|
||||||
|
em->config->thumb_gen_size, gen_size);
|
||||||
|
|
||||||
|
client = elm_thumb_ethumb_client_get();
|
||||||
|
em->config->thumb_gen_size = gen_size;
|
||||||
|
ethumb_client_size_set(client, gen_size, gen_size);
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(_thumbs, l, o)
|
||||||
|
elm_thumb_reload(o);
|
||||||
|
|
||||||
|
end:
|
||||||
|
_thumb_gen_size_changed_timer = NULL;
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ephoto_thumb_size_set(int size)
|
||||||
|
{
|
||||||
|
int gen_size;
|
||||||
|
|
||||||
|
if (em->config->thumb_size != size)
|
||||||
|
{
|
||||||
|
INF("thumbnail display size changed from %d to %d",
|
||||||
|
em->config->thumb_size, size);
|
||||||
|
em->config->thumb_size = size;
|
||||||
|
ephoto_config_save(em, EINA_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size <= 128) gen_size = 128;
|
||||||
|
else if (size <= 256) gen_size = 256;
|
||||||
|
else gen_size = 512;
|
||||||
|
|
||||||
|
if (_thumb_gen_size_changed_timer)
|
||||||
|
{
|
||||||
|
ecore_timer_del(_thumb_gen_size_changed_timer);
|
||||||
|
_thumb_gen_size_changed_timer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
_thumb_gen_size_changed_timer = ecore_timer_add
|
||||||
|
(0.1, _thumb_gen_size_changed_timer_cb, (void*)(long)gen_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_thumb_del(void *data, Evas *e, Evas_Object *o, void *event_info)
|
||||||
|
{
|
||||||
|
_thumbs = eina_list_remove(_thumbs, o);
|
||||||
|
}
|
||||||
|
|
||||||
|
Evas_Object *
|
||||||
|
ephoto_thumb_add(Evas_Object *parent, const char *path)
|
||||||
|
{
|
||||||
|
Evas_Object *o = elm_thumb_add(parent);
|
||||||
|
if (!o) return NULL;
|
||||||
|
elm_thumb_file_set(o, path, NULL);
|
||||||
|
_thumbs = eina_list_append(_thumbs, o);
|
||||||
|
evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _thumb_del, NULL);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
|
@ -394,14 +394,11 @@ _ephoto_zoom_regular_size(void *data, Evas_Object *obj, void *event)
|
||||||
static void
|
static void
|
||||||
_ephoto_slider_changed(void *data, Evas_Object *obj, void *event)
|
_ephoto_slider_changed(void *data, Evas_Object *obj, void *event)
|
||||||
{
|
{
|
||||||
int val;
|
Ephoto_Thumb_Browser *tb = data;
|
||||||
Ephoto_Thumb_Browser *tb = data;
|
int val = elm_slider_value_get(tb->thumb_slider);
|
||||||
|
elm_gengrid_item_size_set(tb->thumb_browser, val, val / THUMB_RATIO);
|
||||||
|
|
||||||
val = elm_slider_value_get(tb->thumb_slider);
|
ephoto_thumb_size_set(val);
|
||||||
elm_gengrid_item_size_set(tb->thumb_browser, val, val / THUMB_RATIO);
|
|
||||||
|
|
||||||
em->config->thumb_size = val;
|
|
||||||
ephoto_config_save(em, EINA_FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called when adding a directory or a file to elm_gengrid */
|
/* Called when adding a directory or a file to elm_gengrid */
|
||||||
|
@ -460,11 +457,8 @@ _ephoto_get_icon(void *data, Evas_Object *obj, const char *part)
|
||||||
o = ephoto_directory_thumb_add(thumb, etd->thumb_path);
|
o = ephoto_directory_thumb_add(thumb, etd->thumb_path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
o = ephoto_thumb_add(thumb, etd->thumb_path);
|
||||||
o = elm_thumb_add(thumb);
|
|
||||||
elm_thumb_file_set(o, etd->thumb_path, NULL);
|
|
||||||
}
|
|
||||||
evas_object_show(o);
|
|
||||||
elm_layout_content_set(thumb, "ephoto.swallow.content", o);
|
elm_layout_content_set(thumb, "ephoto.swallow.content", o);
|
||||||
|
|
||||||
return thumb;
|
return thumb;
|
||||||
|
|
Loading…
Reference in New Issue