Add Save as IFF to main menus

Disable menu items that aren't relevant for current content

svn path=/trunk/netsurf/; revision=7521
This commit is contained in:
Chris Young 2009-05-17 10:40:42 +00:00
parent a3c357f4e6
commit 47fa825ae0
8 changed files with 109 additions and 28 deletions

View File

@ -245,6 +245,7 @@ Source:Source...
TextNS:Text... TextNS:Text...
SaveCompNS:Complete... SaveCompNS:Complete...
PDFNS:PDF... PDFNS:PDF...
IFF:IFF...
OpenFile:Open local file... OpenFile:Open local file...
About:About... About:About...

View File

@ -245,6 +245,7 @@ Source:Source...
TextNS:Text... TextNS:Text...
SaveCompNS:Complete... SaveCompNS:Complete...
PDFNS:PDF... PDFNS:PDF...
IFF:IFF...
OpenFile:Open local file... OpenFile:Open local file...
About:About... About:About...

View File

@ -245,6 +245,7 @@ Source:Source...
TextNS:Text... TextNS:Text...
SaveCompNS:Complete... SaveCompNS:Complete...
PDFNS:PDF... PDFNS:PDF...
IFF:IFF...
OpenFile:Open local file... OpenFile:Open local file...
About:About... About:About...

View File

@ -247,6 +247,7 @@ Source:Sorgente...
TextNS:Testo... TextNS:Testo...
SaveCompNS:Completo... SaveCompNS:Completo...
PDFNS:PDF... PDFNS:PDF...
IFF:IFF...
OpenFile:Apri file locale... OpenFile:Apri file locale...
About:Informazioni... About:Informazioni...

View File

@ -245,6 +245,7 @@ Source:Source...
TextNS:Text... TextNS:Text...
SaveCompNS:Complete... SaveCompNS:Complete...
PDFNS:PDF... PDFNS:PDF...
IFF:IFF...
OpenFile:Open local file... OpenFile:Open local file...
About:About... About:About...

View File

@ -1537,7 +1537,15 @@ void ami_update_buttons(struct gui_window_2 *gwin)
if(!browser_window_reload_available(gwin->bw)) if(!browser_window_reload_available(gwin->bw))
reload=TRUE; 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, RefreshSetGadgetAttrs(gwin->gadgets[GID_BACK],gwin->win,NULL,
GA_Disabled,back, 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) 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) bool gui_window_scroll_start(struct gui_window *g)

View File

@ -80,29 +80,30 @@ void ami_init_menulabs(void)
menulab[7] = ami_utf8_easy((char *)messages_get("TextNS")); menulab[7] = ami_utf8_easy((char *)messages_get("TextNS"));
menulab[8] = ami_utf8_easy((char *)messages_get("SaveCompNS")); menulab[8] = ami_utf8_easy((char *)messages_get("SaveCompNS"));
menulab[9] = ami_utf8_easy((char *)messages_get("PDFNS")); menulab[9] = ami_utf8_easy((char *)messages_get("PDFNS"));
menulab[10] = NM_BARLABEL; menulab[10] = ami_utf8_easy((char *)messages_get("IFF"));
menulab[11] = ami_utf8_easy((char *)messages_get("CloseTab")); menulab[11] = NM_BARLABEL;
menulab[12] = ami_utf8_easy((char *)messages_get("CloseWindow")); menulab[12] = ami_utf8_easy((char *)messages_get("CloseTab"));
menulab[13] = NM_BARLABEL; menulab[13] = ami_utf8_easy((char *)messages_get("CloseWindow"));
menulab[14] = ami_utf8_easy((char *)messages_get("About")); menulab[14] = NM_BARLABEL;
menulab[15] = ami_utf8_easy((char *)messages_get("Quit")); menulab[15] = ami_utf8_easy((char *)messages_get("About"));
menulab[16] = ami_utf8_easy((char *)messages_get("Edit")); menulab[16] = ami_utf8_easy((char *)messages_get("Quit"));
menulab[17] = ami_utf8_easy((char *)messages_get("CopyNS")); menulab[17] = ami_utf8_easy((char *)messages_get("Edit"));
menulab[18] = ami_utf8_easy((char *)messages_get("PasteNS")); menulab[18] = ami_utf8_easy((char *)messages_get("CopyNS"));
menulab[19] = ami_utf8_easy((char *)messages_get("SelectAllNS")); menulab[19] = ami_utf8_easy((char *)messages_get("PasteNS"));
menulab[20] = ami_utf8_easy((char *)messages_get("ClearNS")); menulab[20] = ami_utf8_easy((char *)messages_get("SelectAllNS"));
menulab[21] = ami_utf8_easy((char *)messages_get("Browser")); menulab[21] = ami_utf8_easy((char *)messages_get("ClearNS"));
menulab[22] = ami_utf8_easy((char *)messages_get("FindTextNS")); menulab[22] = ami_utf8_easy((char *)messages_get("Browser"));
menulab[23] = NM_BARLABEL; menulab[23] = ami_utf8_easy((char *)messages_get("FindTextNS"));
menulab[24] = ami_utf8_easy((char *)messages_get("normal")); menulab[24] = NM_BARLABEL;
menulab[25] = ami_utf8_easy((char *)messages_get("HistLocalNS")); menulab[25] = ami_utf8_easy((char *)messages_get("normal"));
menulab[26] = ami_utf8_easy((char *)messages_get("HistGlobalNS")); menulab[26] = ami_utf8_easy((char *)messages_get("HistLocalNS"));
menulab[27] = NM_BARLABEL; menulab[27] = ami_utf8_easy((char *)messages_get("HistGlobalNS"));
menulab[28] = ami_utf8_easy((char *)messages_get("ShowCookies")); menulab[28] = NM_BARLABEL;
menulab[29] = ami_utf8_easy((char *)messages_get("Hotlist")); menulab[29] = ami_utf8_easy((char *)messages_get("ShowCookies"));
menulab[30] = ami_utf8_easy((char *)messages_get("HotlistAdd")); menulab[30] = ami_utf8_easy((char *)messages_get("Hotlist"));
menulab[31] = ami_utf8_easy((char *)messages_get("HotlistShowNS")); menulab[31] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
menulab[32] = NM_BARLABEL; 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] = ami_utf8_easy((char *)messages_get("Settings"));
menulab[AMI_MENU_HOTLIST_MAX+1] = ami_utf8_easy((char *)messages_get("SnapshotWindow")); 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 text
{ NM_SUB,0,0,0,0,0,}, // save as complete { 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 pdf
{ NM_SUB,0,0,0,0,0,}, // save as iff
{ NM_ITEM,NM_BARLABEL,0,0,0,0,}, { NM_ITEM,NM_BARLABEL,0,0,0,0,},
{ NM_ITEM,0,"K",0,0,0,}, // close tab { NM_ITEM,0,"K",0,0,0,}, // close tab
{ NM_ITEM,0,0,0,0,0,}, // close window { 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 #endif
break; 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; break;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk> * Copyright 2008,2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
* *
* This file is part of NetSurf, http://www.netsurf-browser.org/ * 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 /* Maximum number of menu items - first value is number of static items
* (ie. everything not intially defined as NM_IGNORE) */ * (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 */ /* Where the hotlist entries start */
#define AMI_MENU_HOTLIST 33 #define AMI_MENU_HOTLIST 34
/* Where the hotlist entries end */ /* Where the hotlist entries end */
#define AMI_MENU_HOTLIST_MAX AMI_MENU_HOTLIST+AMI_HOTLIST_ITEMS #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) */ /* 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 #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]; char *menulab[AMI_MENU_MAX+1];
struct NewMenu *ami_create_menu(ULONG type); struct NewMenu *ami_create_menu(ULONG type);