From 39b490d1f0a5af4aa8ee98d72700abbc30822805 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 7 Oct 2011 23:12:12 +0000 Subject: Add favicon to iconification icon svn path=/trunk/netsurf/; revision=12995 --- amiga/drag.c | 3 +- amiga/gui.c | 2 ++ amiga/icon.c | 99 ++++++++++++++++++++++++++++++++++++------------------------ amiga/icon.h | 3 +- amiga/menu.c | 4 +-- 5 files changed, 67 insertions(+), 44 deletions(-) (limited to 'amiga') diff --git a/amiga/drag.c b/amiga/drag.c index b4089f6db..7d3be1e91 100644 --- a/amiga/drag.c +++ b/amiga/drag.c @@ -192,8 +192,7 @@ void ami_drag_save(struct Window *win) save_complete(c,path); SetComment(path, nsurl_access(content_get_url(c))); } - ami_superimpose_favicon(path, - drag_save_gui->favicon, NULL); + amiga_icon_superimpose_favicon(path, drag_save_gui->favicon, NULL); } break; diff --git a/amiga/gui.c b/amiga/gui.c index 0e1107047..5679b3b94 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -1619,6 +1619,8 @@ void ami_handle_msg(void) bm = urldb_get_thumbnail(nsurl_access(content_get_url(gwin->bw->current_content))); if(!bm) bm = content_get_bitmap(gwin->bw->current_content); gwin->dobj = amiga_icon_from_bitmap(bm); + amiga_icon_superimpose_favicon_internal(gwin->bw->window->favicon, + gwin->dobj); HideWindow(gwin->win); gwin->appicon = AddAppIcon((ULONG)gwin->objects[OID_MAIN], 0, gwin->win->Title, appport, 0, diff --git a/amiga/icon.c b/amiga/icon.c index a0dfae9f8..82105a24b 100644 --- a/amiga/icon.c +++ b/amiga/icon.c @@ -360,7 +360,65 @@ ULONG *amiga_icon_convertcolouricon32(UBYTE *icondata, ULONG width, ULONG height } -void ami_superimpose_favicon(char *path, struct hlcache_handle *icon, char *type) +void amiga_icon_superimpose_favicon_internal(struct hlcache_handle *icon, struct DiskObject *dobj) +{ + struct BitMap *bm = NULL; + ULONG *icondata1, *icondata2; + ULONG width, height; + long format = 0; + int err = 0; + + if(dobj == NULL) return; + + err = IconControl(dobj, + ICONCTRLA_GetImageDataFormat,&format, + ICONCTRLA_GetImageData1,&icondata1, + ICONCTRLA_GetImageData2,&icondata2, + ICONCTRLA_GetWidth,&width, + ICONCTRLA_GetHeight,&height, + TAG_DONE); + + if(format != IDFMT_DIRECTMAPPED) return; + { + if ((icon != NULL) && (content_get_bitmap(icon) != NULL)) + { + bm = ami_getcachenativebm(content_get_bitmap(icon), 16, 16, NULL); + } + + if(bm) + { + BltBitMapTags(BLITA_SrcX, 0, + BLITA_SrcY, 0, + BLITA_DestX, width - 16, + BLITA_DestY, height - 16, + BLITA_Width, 16, + BLITA_Height, 16, + BLITA_Source, bm, + BLITA_Dest, icondata1, + BLITA_SrcType, BLITT_BITMAP, + BLITA_DestType, BLITT_ARGB32, + BLITA_DestBytesPerRow, width * 4, + BLITA_UseSrcAlpha, TRUE, + TAG_DONE); + + BltBitMapTags(BLITA_SrcX, 0, + BLITA_SrcY, 0, + BLITA_DestX, width - 16, + BLITA_DestY, height - 16, + BLITA_Width, 16, + BLITA_Height, 16, + BLITA_Source, bm, + BLITA_Dest, icondata2, + BLITA_SrcType, BLITT_BITMAP, + BLITA_DestType, BLITT_ARGB32, + BLITA_DestBytesPerRow, width * 4, + BLITA_UseSrcAlpha, TRUE, + TAG_DONE); + } + } +} + +void amiga_icon_superimpose_favicon(char *path, struct hlcache_handle *icon, char *type) { struct DiskObject *dobj = NULL; struct BitMap *bm = NULL; @@ -421,43 +479,7 @@ void ami_superimpose_favicon(char *path, struct hlcache_handle *icon, char *type } if((format == IDFMT_DIRECTMAPPED) || (format == IDFMT_PALETTEMAPPED)) - { - if ((icon != NULL) && (content_get_bitmap(icon) != NULL)) - { - bm = ami_getcachenativebm(content_get_bitmap(icon), 16, 16, NULL); - } - - if(bm) - { - BltBitMapTags(BLITA_SrcX, 0, - BLITA_SrcY, 0, - BLITA_DestX, width - 16, - BLITA_DestY, height - 16, - BLITA_Width, 16, - BLITA_Height, 16, - BLITA_Source, bm, - BLITA_Dest, icondata1, - BLITA_SrcType, BLITT_BITMAP, - BLITA_DestType, BLITT_ARGB32, - BLITA_DestBytesPerRow, width * 4, - BLITA_UseSrcAlpha, TRUE, - TAG_DONE); - - BltBitMapTags(BLITA_SrcX, 0, - BLITA_SrcY, 0, - BLITA_DestX, width - 16, - BLITA_DestY, height - 16, - BLITA_Width, 16, - BLITA_Height, 16, - BLITA_Source, bm, - BLITA_Dest, icondata2, - BLITA_SrcType, BLITT_BITMAP, - BLITA_DestType, BLITT_ARGB32, - BLITA_DestBytesPerRow, width * 4, - BLITA_UseSrcAlpha, TRUE, - TAG_DONE); - } - } + amiga_icon_superimpose_favicon_internal(icon, dobj); PutIconTags(path, dobj, ICONPUTA_NotifyWorkbench, TRUE, TAG_DONE); @@ -470,7 +492,6 @@ void ami_superimpose_favicon(char *path, struct hlcache_handle *icon, char *type FreeVec(icondata1); FreeVec(icondata2); } - } struct DiskObject *amiga_icon_from_bitmap(struct bitmap *bm) diff --git a/amiga/icon.h b/amiga/icon.h index 695d179c9..e0ea5b734 100644 --- a/amiga/icon.h +++ b/amiga/icon.h @@ -40,7 +40,8 @@ void amiga_icon_fini(void); struct hlcache_handle; -void ami_superimpose_favicon(char *path, struct hlcache_handle *icon, char *type); +void amiga_icon_superimpose_favicon(char *path, struct hlcache_handle *icon, char *type); +void amiga_icon_superimpose_favicon_internal(struct hlcache_handle *icon, struct DiskObject *dobj); struct DiskObject *amiga_icon_from_bitmap(struct bitmap *bm); void amiga_icon_free(struct DiskObject *dobj); #endif diff --git a/amiga/menu.c b/amiga/menu.c index c421227f2..0671fb1b1 100755 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -581,7 +581,7 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item) UnLock(lock); save_complete(gwin->bw->current_content,fname); SetComment(fname,nsurl_access(content_get_url(gwin->bw->current_content))); - ami_superimpose_favicon(fname, + amiga_icon_superimpose_favicon(fname, gwin->bw->window->favicon, NULL); } } @@ -603,7 +603,7 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item) if(save_as_pdf(gwin->bw->current_content,fname)) { SetComment(fname, nsurl_access(content_get_url(gwin->bw->current_content))); - ami_superimpose_favicon(fname, + amiga_icon_superimpose_favicon(fname, gwin->bw->window->favicon, "pdf"); } ami_update_pointer(gwin->win,GUI_POINTER_DEFAULT); -- cgit v1.2.3