diff --git a/src/Image.cc b/src/Image.cc index 2178093..58fa0ec 100644 --- a/src/Image.cc +++ b/src/Image.cc @@ -101,6 +101,28 @@ Image::SetOnload(Local, Local val, const AccessorInfo &info) { } } +/* + * Get onerror callback. + */ + +Handle +Image::GetOnerror(Local, const AccessorInfo &info) { + Image *img = ObjectWrap::Unwrap(info.This()); + return img->onerror; +} + +/* + * Set onerror callback. + */ + +void +Image::SetOnerror(Local, Local val, const AccessorInfo &info) { + if (val->IsFunction()) { + Image *img = ObjectWrap::Unwrap(info.This()); + img->onerror = Persistent::New(Handle::Cast(val)); + } +} + /* * Initialize a new Image. */ diff --git a/src/Image.h b/src/Image.h index 8bafafa..7388e14 100644 --- a/src/Image.h +++ b/src/Image.h @@ -16,13 +16,16 @@ class Image: public node::ObjectWrap { public: char *filename; Persistent onload; + Persistent onerror; static void Initialize(Handle target); static Handle New(const Arguments &args); static Handle Inspect(const Arguments &args); static Handle GetSrc(Local prop, const AccessorInfo &info); static Handle GetOnload(Local prop, const AccessorInfo &info); + static Handle GetOnerror(Local prop, const AccessorInfo &info); static void SetSrc(Local prop, Local val, const AccessorInfo &info); static void SetOnload(Local prop, Local val, const AccessorInfo &info); + static void SetOnerror(Local prop, Local val, const AccessorInfo &info); inline cairo_surface_t *surface(){ return _surface; } cairo_status_t loadSurface(); void loaded();