finished callback is always called now.

The ethumb_generate() function now just returns 0 if there is already a
generation in progress (and in that case, the callback isn't called).



SVN revision: 40738
This commit is contained in:
Rafael Antognolli 2009-05-19 11:58:29 +00:00
parent bfabdd2404
commit 16c574df94
7 changed files with 26 additions and 24 deletions

View File

@ -129,7 +129,7 @@ const Ecore_Getopt optdesc = {
}; };
static void static void
_finished_thumb(Ethumb *e, void *data) _finished_thumb(Ethumb *e, int result, void *data)
{ {
ecore_main_loop_quit(); ecore_main_loop_quit();
} }

View File

@ -794,7 +794,6 @@ _ethumb_plugin_generate(Ethumb *e)
{ {
const char *ext; const char *ext;
Ethumb_Plugin *plugin; Ethumb_Plugin *plugin;
int r;
ext = strrchr(e->src_path, '.'); ext = strrchr(e->src_path, '.');
if (!ext) if (!ext)
@ -815,9 +814,9 @@ _ethumb_plugin_generate(Ethumb *e)
else else
evas_object_hide(e->img); evas_object_hide(e->img);
r = plugin->generate_thumb(e); plugin->generate_thumb(e);
return r; return 1;
} }
int int
@ -955,7 +954,7 @@ _ethumb_finished_idler_cb(void *data)
{ {
Ethumb *e = data; Ethumb *e = data;
e->finished_cb(e, e->cb_data); e->finished_cb(e, e->cb_result, e->cb_data);
e->finished_idler = NULL; e->finished_idler = NULL;
e->finished_cb = NULL; e->finished_cb = NULL;
e->cb_data = NULL; e->cb_data = NULL;
@ -964,10 +963,11 @@ _ethumb_finished_idler_cb(void *data)
} }
void void
ethumb_finished_callback_call(Ethumb *e) ethumb_finished_callback_call(Ethumb *e, int result)
{ {
EINA_SAFETY_ON_NULL_RETURN(e); EINA_SAFETY_ON_NULL_RETURN(e);
e->cb_result = result;
if (e->finished_idler) if (e->finished_idler)
ecore_idler_del(e->finished_idler); ecore_idler_del(e->finished_idler);
e->finished_idler = ecore_idler_add(_ethumb_finished_idler_cb, e); e->finished_idler = ecore_idler_add(_ethumb_finished_idler_cb, e);
@ -992,19 +992,20 @@ ethumb_generate(Ethumb *e, ethumb_generate_callback_t finished_cb, void *data)
r = _ethumb_plugin_generate(e); r = _ethumb_plugin_generate(e);
if (r) if (r)
return r; return 1;
if (!_ethumb_image_load(e)) if (!_ethumb_image_load(e))
{ {
ERR("could not load input image.\n"); ERR("could not load input image.\n");
return 0; ethumb_finished_callback_call(e, 0);
return 1;
} }
r = ethumb_image_save(e); r = ethumb_image_save(e);
if (r && finished_cb)
ethumb_finished_callback_call(e);
return r; ethumb_finished_callback_call(e, r);
return 1;
} }
EAPI int EAPI int

View File

@ -66,7 +66,7 @@ typedef enum _Ethumb_Thumb_Aspect Ethumb_Thumb_Aspect;
typedef struct _Ethumb_Frame Ethumb_Frame; typedef struct _Ethumb_Frame Ethumb_Frame;
typedef struct _Ethumb Ethumb; typedef struct _Ethumb Ethumb;
typedef void (*ethumb_generate_callback_t)(Ethumb *e, void *data); typedef void (*ethumb_generate_callback_t)(Ethumb *e, int result, void *data);
EAPI int ethumb_init(void); EAPI int ethumb_init(void);
EAPI int ethumb_shutdown(void); EAPI int ethumb_shutdown(void);

View File

@ -10,14 +10,14 @@ typedef struct _Ethumb_Plugin Ethumb_Plugin;
struct _Ethumb_Plugin struct _Ethumb_Plugin
{ {
const char **extensions; const char **extensions;
int (*generate_thumb)(Ethumb *); void (*generate_thumb)(Ethumb *);
}; };
void ethumb_calculate_aspect(Ethumb *e, int iw, int ih, int *w, int *h); void ethumb_calculate_aspect(Ethumb *e, int iw, int ih, int *w, int *h);
void ethumb_calculate_fill(Ethumb *e, int iw, int ih, int *fx, int *fy, int *fw, int *fh); void ethumb_calculate_fill(Ethumb *e, int iw, int ih, int *fx, int *fy, int *fw, int *fh);
int ethumb_plugin_image_resize(Ethumb *e, int w, int h); int ethumb_plugin_image_resize(Ethumb *e, int w, int h);
int ethumb_image_save(Ethumb *e); int ethumb_image_save(Ethumb *e);
void ethumb_finished_callback_call(Ethumb *e); void ethumb_finished_callback_call(Ethumb *e, int result);
Evas * ethumb_evas_get(const Ethumb *e); Evas * ethumb_evas_get(const Ethumb *e);
#endif /* _ETHUMB_PLUGIN_H_ */ #endif /* _ETHUMB_PLUGIN_H_ */

View File

@ -39,6 +39,7 @@ struct _Ethumb
Ecore_Idler *finished_idler; Ecore_Idler *finished_idler;
ethumb_generate_callback_t finished_cb; ethumb_generate_callback_t finished_cb;
void *cb_data; void *cb_data;
int cb_result;
}; };
#endif /* __ETHUMB_PRIVATE_H__ */ #endif /* __ETHUMB_PRIVATE_H__ */

View File

@ -29,10 +29,10 @@ _frame_resized_cb(void *data, Evas_Object *o, void *event_info)
evas_object_smart_callback_del(o, "frame_resize", _frame_resized_cb); evas_object_smart_callback_del(o, "frame_resize", _frame_resized_cb);
emotion_object_play_set(o, 0); emotion_object_play_set(o, 0);
evas_object_del(o); evas_object_del(o);
ethumb_finished_callback_call(e); ethumb_finished_callback_call(e, 1);
} }
static int static void
_generate_thumb(Ethumb *e) _generate_thumb(Ethumb *e)
{ {
Evas_Object *o; Evas_Object *o;
@ -47,7 +47,8 @@ _generate_thumb(Ethumb *e)
fprintf(stderr, "ERROR: could not start emotion using gstreamer" fprintf(stderr, "ERROR: could not start emotion using gstreamer"
" plugin.\n"); " plugin.\n");
evas_object_del(o); evas_object_del(o);
return r; ethumb_finished_callback_call(e, 0);
return;
} }
ethumb_file_get(e, &file, NULL); ethumb_file_get(e, &file, NULL);
@ -63,7 +64,6 @@ _generate_thumb(Ethumb *e)
_emotion = o; _emotion = o;
return 1;
} }
EAPI Ethumb_Plugin * EAPI Ethumb_Plugin *

View File

@ -8,7 +8,7 @@
#include <Evas.h> #include <Evas.h>
#include <Epdf.h> #include <Epdf.h>
static int static void
_generate_thumb(Ethumb *e) _generate_thumb(Ethumb *e)
{ {
Epdf_Document *document; Epdf_Document *document;
@ -23,7 +23,8 @@ _generate_thumb(Ethumb *e)
if (!document) if (!document)
{ {
fprintf(stderr, "ERROR: could not read document: %s\n", e->src_path); fprintf(stderr, "ERROR: could not read document: %s\n", e->src_path);
return 0; ethumb_finished_callback_call(e, 0);
return;
} }
page = epdf_page_new(document); page = epdf_page_new(document);
@ -31,7 +32,8 @@ _generate_thumb(Ethumb *e)
{ {
fprintf(stderr, "ERROR: could not read document: %s\n", e->src_path); fprintf(stderr, "ERROR: could not read document: %s\n", e->src_path);
epdf_document_delete(document); epdf_document_delete(document);
return 0; ethumb_finished_callback_call(e, 0);
return;
} }
npages = epdf_document_page_count_get(document); npages = epdf_document_page_count_get(document);
@ -57,9 +59,7 @@ _generate_thumb(Ethumb *e)
epdf_page_delete(page); epdf_page_delete(page);
epdf_document_delete(document); epdf_document_delete(document);
ethumb_finished_callback_call(e); ethumb_finished_callback_call(e, 1);
return 1;
} }
Ethumb_Plugin * Ethumb_Plugin *