diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2009-12-19 15:57:53 +0000 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2009-12-19 15:57:53 +0000 |
commit | 8a77de83772994a21e1287d60e7225878697c61a (patch) | |
tree | 44dd48907ecf5c28979f619f10f4f4e9fccbe71c | |
parent | d9b17c8077e289c5462c013c74f505fb22fbc431 (diff) | |
download | netsurf-8a77de83772994a21e1287d60e7225878697c61a.tar.gz netsurf-8a77de83772994a21e1287d60e7225878697c61a.tar.bz2 |
Save favicon as part of icon for save_complete drawers and PDFs
svn path=/trunk/netsurf/; revision=9744
-rw-r--r-- | amiga/download.c | 85 | ||||
-rwxr-xr-x | amiga/download.h | 3 | ||||
-rwxr-xr-x | amiga/menu.c | 5 |
3 files changed, 92 insertions, 1 deletions
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 <proto/utility.h> #include <proto/icon.h> +#include <graphics/blitattr.h> #include <workbench/icon.h> #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 |