From 8a77de83772994a21e1287d60e7225878697c61a Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 19 Dec 2009 15:57:53 +0000 Subject: Save favicon as part of icon for save_complete drawers and PDFs svn path=/trunk/netsurf/; revision=9744 --- amiga/download.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ amiga/download.h | 3 +- amiga/menu.c | 5 ++++ 3 files changed, 92 insertions(+), 1 deletion(-) (limited to 'amiga') diff --git a/amiga/download.c b/amiga/download.c index baba92bd3..07cdc2bf9 100644 --- a/amiga/download.c +++ b/amiga/download.c @@ -24,6 +24,7 @@ #include #include +#include #include #include "amiga/download.h" @@ -289,6 +290,7 @@ void gui_drag_save_object(gui_save_type type, struct content *c, gui_window_set_pointer(g,AMI_GUI_POINTER_DRAG); drag_save_data = c; + drag_save_gui = g; drag_save = type; } @@ -369,6 +371,8 @@ void ami_drag_save(struct Window *win) save_complete(c,path); SetComment(path,c->url); } + ami_superimpose_favicon(path, + drag_save_gui->favicon, NULL); } break; @@ -396,3 +400,84 @@ void ami_drag_save(struct Window *win) drag_save_data = NULL; ami_update_pointer(win,GUI_POINTER_DEFAULT); } + +void ami_superimpose_favicon(STRPTR path, struct content *icon, STRPTR type) +{ + struct DiskObject *dobj = NULL; + struct BitMap *bm = NULL; + ULONG *icondata1, *icondata2; + ULONG width, height; + long format = 0; + int err = 0; + + if(!type) + { + dobj = GetIconTags(NULL, + ICONGETA_GetDefaultType, WBDRAWER, + TAG_DONE); + } + else + { + dobj = GetIconTags(NULL, ICONGETA_GetDefaultName, type, + ICONGETA_GetDefaultType, WBPROJECT, + TAG_DONE); + } + + err = IconControl(dobj, + ICONCTRLA_GetImageDataFormat,&format, + ICONCTRLA_GetImageData1,&icondata1, + ICONCTRLA_GetImageData2,&icondata2, + ICONCTRLA_GetWidth,&width, + ICONCTRLA_GetHeight,&height, + TAG_DONE); + + /* Check icon is direct mapped (truecolour). + * Quite a bit more code is needed for palette mapped and planar icons, + * and OS4 default icons should all be truecolour anyway. */ + if(format == IDFMT_DIRECTMAPPED) + { + if ((icon != NULL) && (icon->type == CONTENT_ICO)) + { + nsico_set_bitmap_from_size(icon, 16, 16); + } + + if ((icon != NULL) && (icon->bitmap != NULL)) + { + bm = ami_getcachenativebm(icon->bitmap, 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); + } + } + + PutIconTags(path, dobj, + ICONPUTA_NotifyWorkbench, TRUE, TAG_DONE); +} diff --git a/amiga/download.h b/amiga/download.h index 8c5116a7b..425207e39 100755 --- a/amiga/download.h +++ b/amiga/download.h @@ -43,9 +43,10 @@ struct gui_download_window { int drag_save; void *drag_save_data; +struct gui_window *drag_save_gui; void ami_download_window_abort(struct gui_download_window *dw); void ami_drag_save(struct Window *win); void ami_free_download_list(struct List *dllist); - +void ami_superimpose_favicon(STRPTR path, struct content *icon, STRPTR type); #endif diff --git a/amiga/menu.c b/amiga/menu.c index 7ceb9191d..e3da503a0 100755 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -48,6 +48,7 @@ #include "content/fetch.h" #include "amiga/gui_options.h" #include "amiga/print.h" +#include "amiga/download.h" BOOL menualreadyinit; const char * const netsurf_version; @@ -514,6 +515,8 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item) UnLock(lock); save_complete(gwin->bw->current_content,fname); SetComment(fname,gwin->bw->current_content->url); + ami_superimpose_favicon(fname, + gwin->bw->window->favicon, NULL); } ami_update_pointer(gwin->win,GUI_POINTER_DEFAULT); } @@ -532,6 +535,8 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item) ami_update_pointer(gwin->win,GUI_POINTER_WAIT); save_as_pdf(gwin->bw->current_content,fname); SetComment(fname,gwin->bw->current_content->url); + ami_superimpose_favicon(fname, + gwin->bw->window->favicon, "pdf"); ami_update_pointer(gwin->win,GUI_POINTER_DEFAULT); } #endif -- cgit v1.2.3