From 47fa825ae0c4ecffeae8bbac32b0a493ea5c19b1 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sun, 17 May 2009 10:40:42 +0000 Subject: [PATCH] Add Save as IFF to main menus Disable menu items that aren't relevant for current content svn path=/trunk/netsurf/; revision=7521 --- !NetSurf/Resources/de/Messages | 1 + !NetSurf/Resources/en/Messages | 1 + !NetSurf/Resources/fr/Messages | 1 + !NetSurf/Resources/it/Messages | 1 + !NetSurf/Resources/nl/Messages | 1 + amiga/gui.c | 48 +++++++++++++++++++++++-- amiga/menu.c | 66 ++++++++++++++++++++++------------ amiga/menu.h | 18 ++++++++-- 8 files changed, 109 insertions(+), 28 deletions(-) diff --git a/!NetSurf/Resources/de/Messages b/!NetSurf/Resources/de/Messages index 0ad5768f3..2291ac5fc 100644 --- a/!NetSurf/Resources/de/Messages +++ b/!NetSurf/Resources/de/Messages @@ -245,6 +245,7 @@ Source:Source... TextNS:Text... SaveCompNS:Complete... PDFNS:PDF... +IFF:IFF... OpenFile:Open local file... About:About... diff --git a/!NetSurf/Resources/en/Messages b/!NetSurf/Resources/en/Messages index 5efcb7704..2706b9e15 100644 --- a/!NetSurf/Resources/en/Messages +++ b/!NetSurf/Resources/en/Messages @@ -245,6 +245,7 @@ Source:Source... TextNS:Text... SaveCompNS:Complete... PDFNS:PDF... +IFF:IFF... OpenFile:Open local file... About:About... diff --git a/!NetSurf/Resources/fr/Messages b/!NetSurf/Resources/fr/Messages index 4d03d965b..2714df08c 100644 --- a/!NetSurf/Resources/fr/Messages +++ b/!NetSurf/Resources/fr/Messages @@ -245,6 +245,7 @@ Source:Source... TextNS:Text... SaveCompNS:Complete... PDFNS:PDF... +IFF:IFF... OpenFile:Open local file... About:About... diff --git a/!NetSurf/Resources/it/Messages b/!NetSurf/Resources/it/Messages index e0eb81f2c..ee883de62 100755 --- a/!NetSurf/Resources/it/Messages +++ b/!NetSurf/Resources/it/Messages @@ -247,6 +247,7 @@ Source:Sorgente... TextNS:Testo... SaveCompNS:Completo... PDFNS:PDF... +IFF:IFF... OpenFile:Apri file locale... About:Informazioni... diff --git a/!NetSurf/Resources/nl/Messages b/!NetSurf/Resources/nl/Messages index 49273ea6b..2a748bce2 100644 --- a/!NetSurf/Resources/nl/Messages +++ b/!NetSurf/Resources/nl/Messages @@ -245,6 +245,7 @@ Source:Source... TextNS:Text... SaveCompNS:Complete... PDFNS:PDF... +IFF:IFF... OpenFile:Open local file... About:About... diff --git a/amiga/gui.c b/amiga/gui.c index 402345151..e8b3743f2 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -1537,7 +1537,15 @@ void ami_update_buttons(struct gui_window_2 *gwin) if(!browser_window_reload_available(gwin->bw)) reload=TRUE; - if(gwin->tabs <= 1) tabclose=TRUE; + if(gwin->tabs <= 1) + { + tabclose=TRUE; + OffMenu(gwin->win,AMI_MENU_CLOSETAB); + } + else + { + OnMenu(gwin->win,AMI_MENU_CLOSETAB); + } RefreshSetGadgetAttrs(gwin->gadgets[GID_BACK],gwin->win,NULL, GA_Disabled,back, @@ -2765,7 +2773,43 @@ void gui_window_remove_caret(struct gui_window *g) void gui_window_new_content(struct gui_window *g) { -// DebugPrintF("new content\n"); + struct content *c = g->shared->bw->current_content; + + if(c->type <= CONTENT_CSS) + { + OnMenu(g->shared->win,AMI_MENU_SAVEAS_TEXT); + OnMenu(g->shared->win,AMI_MENU_SAVEAS_COMPLETE); + OnMenu(g->shared->win,AMI_MENU_SAVEAS_PDF); + OnMenu(g->shared->win,AMI_MENU_COPY); + OnMenu(g->shared->win,AMI_MENU_PASTE); + OnMenu(g->shared->win,AMI_MENU_SELECTALL); + OnMenu(g->shared->win,AMI_MENU_CLEAR); + OnMenu(g->shared->win,AMI_MENU_FIND); + OffMenu(g->shared->win,AMI_MENU_SAVEAS_IFF); + } + else + { + OffMenu(g->shared->win,AMI_MENU_SAVEAS_TEXT); + OffMenu(g->shared->win,AMI_MENU_SAVEAS_COMPLETE); + OffMenu(g->shared->win,AMI_MENU_SAVEAS_PDF); + OffMenu(g->shared->win,AMI_MENU_PASTE); + OffMenu(g->shared->win,AMI_MENU_SELECTALL); + OffMenu(g->shared->win,AMI_MENU_CLEAR); + OffMenu(g->shared->win,AMI_MENU_FIND); + + if(c->bitmap) + { + OnMenu(g->shared->win,AMI_MENU_COPY); + OnMenu(g->shared->win,AMI_MENU_SAVEAS_IFF); + } + else + { + OffMenu(g->shared->win,AMI_MENU_COPY); + OffMenu(g->shared->win,AMI_MENU_SAVEAS_IFF); + } + } + + ami_clearclipreg(currp); } bool gui_window_scroll_start(struct gui_window *g) diff --git a/amiga/menu.c b/amiga/menu.c index f7c7de80f..b25c861ea 100755 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -80,29 +80,30 @@ void ami_init_menulabs(void) menulab[7] = ami_utf8_easy((char *)messages_get("TextNS")); menulab[8] = ami_utf8_easy((char *)messages_get("SaveCompNS")); menulab[9] = ami_utf8_easy((char *)messages_get("PDFNS")); - menulab[10] = NM_BARLABEL; - menulab[11] = ami_utf8_easy((char *)messages_get("CloseTab")); - menulab[12] = ami_utf8_easy((char *)messages_get("CloseWindow")); - menulab[13] = NM_BARLABEL; - menulab[14] = ami_utf8_easy((char *)messages_get("About")); - menulab[15] = ami_utf8_easy((char *)messages_get("Quit")); - menulab[16] = ami_utf8_easy((char *)messages_get("Edit")); - menulab[17] = ami_utf8_easy((char *)messages_get("CopyNS")); - menulab[18] = ami_utf8_easy((char *)messages_get("PasteNS")); - menulab[19] = ami_utf8_easy((char *)messages_get("SelectAllNS")); - menulab[20] = ami_utf8_easy((char *)messages_get("ClearNS")); - menulab[21] = ami_utf8_easy((char *)messages_get("Browser")); - menulab[22] = ami_utf8_easy((char *)messages_get("FindTextNS")); - menulab[23] = NM_BARLABEL; - menulab[24] = ami_utf8_easy((char *)messages_get("normal")); - menulab[25] = ami_utf8_easy((char *)messages_get("HistLocalNS")); - menulab[26] = ami_utf8_easy((char *)messages_get("HistGlobalNS")); - menulab[27] = NM_BARLABEL; - menulab[28] = ami_utf8_easy((char *)messages_get("ShowCookies")); - menulab[29] = ami_utf8_easy((char *)messages_get("Hotlist")); - menulab[30] = ami_utf8_easy((char *)messages_get("HotlistAdd")); - menulab[31] = ami_utf8_easy((char *)messages_get("HotlistShowNS")); - menulab[32] = NM_BARLABEL; + menulab[10] = ami_utf8_easy((char *)messages_get("IFF")); + menulab[11] = NM_BARLABEL; + menulab[12] = ami_utf8_easy((char *)messages_get("CloseTab")); + menulab[13] = ami_utf8_easy((char *)messages_get("CloseWindow")); + menulab[14] = NM_BARLABEL; + menulab[15] = ami_utf8_easy((char *)messages_get("About")); + menulab[16] = ami_utf8_easy((char *)messages_get("Quit")); + menulab[17] = ami_utf8_easy((char *)messages_get("Edit")); + menulab[18] = ami_utf8_easy((char *)messages_get("CopyNS")); + menulab[19] = ami_utf8_easy((char *)messages_get("PasteNS")); + menulab[20] = ami_utf8_easy((char *)messages_get("SelectAllNS")); + menulab[21] = ami_utf8_easy((char *)messages_get("ClearNS")); + menulab[22] = ami_utf8_easy((char *)messages_get("Browser")); + menulab[23] = ami_utf8_easy((char *)messages_get("FindTextNS")); + menulab[24] = NM_BARLABEL; + menulab[25] = ami_utf8_easy((char *)messages_get("normal")); + menulab[26] = ami_utf8_easy((char *)messages_get("HistLocalNS")); + menulab[27] = ami_utf8_easy((char *)messages_get("HistGlobalNS")); + menulab[28] = NM_BARLABEL; + menulab[29] = ami_utf8_easy((char *)messages_get("ShowCookies")); + menulab[30] = ami_utf8_easy((char *)messages_get("Hotlist")); + menulab[31] = ami_utf8_easy((char *)messages_get("HotlistAdd")); + menulab[32] = ami_utf8_easy((char *)messages_get("HotlistShowNS")); + menulab[33] = NM_BARLABEL; menulab[AMI_MENU_HOTLIST_MAX] = ami_utf8_easy((char *)messages_get("Settings")); menulab[AMI_MENU_HOTLIST_MAX+1] = ami_utf8_easy((char *)messages_get("SnapshotWindow")); @@ -127,6 +128,7 @@ struct NewMenu *ami_create_menu(ULONG type) { NM_SUB,0,0,0,0,0,}, // save as text { NM_SUB,0,0,0,0,0,}, // save as complete { NM_SUB,0,0,0,0,0,}, // save as pdf + { NM_SUB,0,0,0,0,0,}, // save as iff { NM_ITEM,NM_BARLABEL,0,0,0,0,}, { NM_ITEM,0,"K",0,0,0,}, // close tab { NM_ITEM,0,0,0,0,0,}, // close window @@ -513,6 +515,24 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item) } #endif break; + + case 4: // iff + if(AslRequestTags(savereq, + ASLFR_TitleText,messages_get("NetSurf"), + ASLFR_Screen,scrn, + ASLFR_InitialFile,FilePart(gwin->bw->current_content->url), + TAG_DONE)) + { + strlcpy(&fname,savereq->fr_Drawer,1024); + AddPart(fname,savereq->fr_File,1024); + ami_update_pointer(gwin->win,GUI_POINTER_WAIT); + gwin->bw->current_content->bitmap->url = gwin->bw->current_content->url; + gwin->bw->current_content->bitmap->title = gwin->bw->current_content->title; + bitmap_save(gwin->bw->current_content->bitmap,fname,0); + SetComment(fname,gwin->bw->current_content->url); + ami_update_pointer(gwin->win,GUI_POINTER_DEFAULT); + } + break; } break; diff --git a/amiga/menu.h b/amiga/menu.h index 528c0461d..922791c69 100755 --- a/amiga/menu.h +++ b/amiga/menu.h @@ -1,5 +1,5 @@ /* - * Copyright 2008 Chris Young + * Copyright 2008,2009 Chris Young * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -28,10 +28,10 @@ /* Maximum number of menu items - first value is number of static items * (ie. everything not intially defined as NM_IGNORE) */ -#define AMI_MENU_MAX 39 + AMI_HOTLIST_ITEMS +#define AMI_MENU_MAX 40 + AMI_HOTLIST_ITEMS /* Where the hotlist entries start */ -#define AMI_MENU_HOTLIST 33 +#define AMI_MENU_HOTLIST 34 /* Where the hotlist entries end */ #define AMI_MENU_HOTLIST_MAX AMI_MENU_HOTLIST+AMI_HOTLIST_ITEMS @@ -48,6 +48,18 @@ /* Where the ARexx menu items end (incidentally this is the real AMI_MENU_MAX) */ #define AMI_MENU_AREXX_MAX AMI_MENU_AREXX+AMI_MENU_AREXX_ITEMS +/* The Intuition menu numbers of some menus we might need to modify */ +#define AMI_MENU_SAVEAS_TEXT FULLMENUNUM(0,4,1) +#define AMI_MENU_SAVEAS_COMPLETE FULLMENUNUM(0,4,2) +#define AMI_MENU_SAVEAS_PDF FULLMENUNUM(0,4,3) +#define AMI_MENU_SAVEAS_IFF FULLMENUNUM(0,4,4) +#define AMI_MENU_CLOSETAB FULLMENUNUM(0,6,0) +#define AMI_MENU_COPY FULLMENUNUM(1,0,0) +#define AMI_MENU_PASTE FULLMENUNUM(1,1,0) +#define AMI_MENU_SELECTALL FULLMENUNUM(1,2,0) +#define AMI_MENU_CLEAR FULLMENUNUM(1,3,0) +#define AMI_MENU_FIND FULLMENUNUM(2,0,0) + char *menulab[AMI_MENU_MAX+1]; struct NewMenu *ami_create_menu(ULONG type);