diff options
-rw-r--r-- | doc/dw-images-and-backgrounds.doc | 8 | ||||
-rw-r--r-- | src/dicache.c | 5 | ||||
-rw-r--r-- | src/image.cc | 20 | ||||
-rw-r--r-- | src/image.hh | 3 |
4 files changed, 26 insertions, 10 deletions
diff --git a/doc/dw-images-and-backgrounds.doc b/doc/dw-images-and-backgrounds.doc index 362037d9..6dfc7d79 100644 --- a/doc/dw-images-and-backgrounds.doc +++ b/doc/dw-images-and-backgrounds.doc @@ -187,14 +187,6 @@ Bugs and Things Needing Improvement High Priority ------------- -**Images as toplevel resource:** There seem to be problems when the -toplevel resource is an image. How to reproduce: Type <code>src/dillo -http://www.dillo.org/db1.png</code> with the version from the -background images branch; this will print the message "Content-Type -'image/png' not viewable." and show the "Save link as file" -dialog. The same works for the version from the main repository, with -which the background images branch has been synchronized. - **Configurability, security/privacy aspects, etc.,** which are currently available for image widgets, should be adopted. Perhaps some more configuration options specially for background images. diff --git a/src/dicache.c b/src/dicache.c index ec63df1f..db3b86b2 100644 --- a/src/dicache.c +++ b/src/dicache.c @@ -403,7 +403,8 @@ static void *Dicache_image(int ImgType, const char *MimeType, void *Ptr, dReturn_val_if_fail(MimeType && Ptr, NULL); if (!web->Image) { - web->Image = a_Image_new(NULL, NULL, web->bgColor); + web->Image = + a_Image_new_with_dw(web->bw->render_layout, NULL, web->bgColor); a_Image_ref(web->Image); } @@ -430,7 +431,7 @@ static void *Dicache_image(int ImgType, const char *MimeType, void *Ptr, *Data = DicEntry->DecoderData; *Call = (CA_Callback_t) a_Dicache_callback; - return (web->Image->img_rnd); + return (a_Image_get_dw (web->Image)); } /* diff --git a/src/image.cc b/src/image.cc index 04d89a82..7e6c27a4 100644 --- a/src/image.cc +++ b/src/image.cc @@ -50,6 +50,26 @@ DilloImage *a_Image_new(void *layout, void *img_rnd, int32_t bg_color) } /* + * Create and initialize a new image structure with an image widget. + */ +DilloImage *a_Image_new_with_dw(void *layout, const char *alt_text, + int32_t bg_color) +{ + dw::Image *dw = new dw::Image(alt_text); + return a_Image_new(layout, (void*)(dw::core::ImgRenderer*)dw, bg_color); +} + +/* + * Return the image renderer as a widget. This is somewhat tricky, + * since simple casting leads to wrong (and hard to debug) results, + * because of multiple inheritance. This function can be used from C + * code, where only access to void* is possible. + */ +void *a_Image_get_dw(DilloImage *Image) +{ + return (dw::Image*)(dw::core::ImgRenderer*)Image->img_rnd; +} +/* * Deallocate an Image structure */ static void Image_free(DilloImage *Image) diff --git a/src/image.hh b/src/image.hh index fd105a7e..52bd1cf1 100644 --- a/src/image.hh +++ b/src/image.hh @@ -63,6 +63,9 @@ struct _DilloImage { * Function prototypes */ DilloImage *a_Image_new(void *layout, void *img_rnd, int32_t bg_color); +DilloImage *a_Image_new_with_dw(void *layout, const char *alt_text, + int32_t bg_color); +void *a_Image_get_dw(DilloImage *Image); void a_Image_ref(DilloImage *Image); void a_Image_unref(DilloImage *Image); |