2008-08-25 17:32:26 +04:00
|
|
|
/*
|
2009-01-11 00:26:22 +03:00
|
|
|
* Copyright 2008-9 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
2008-08-25 17:32:26 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "desktop/browser.h"
|
|
|
|
#include "amiga/menu.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "amiga/utf8.h"
|
|
|
|
#include <libraries/gadtools.h>
|
2008-09-04 02:02:41 +04:00
|
|
|
#include <proto/asl.h>
|
2008-10-05 17:17:18 +04:00
|
|
|
#include "amiga/options.h"
|
2008-09-04 02:02:41 +04:00
|
|
|
#include "desktop/gui.h"
|
|
|
|
#include "amiga/hotlist.h"
|
|
|
|
#include <proto/dos.h>
|
|
|
|
#include "amiga/gui.h"
|
|
|
|
#include "amiga/save_pdf.h"
|
|
|
|
#include "desktop/save_text.h"
|
|
|
|
#include "desktop/save_pdf/pdf_plotters.h"
|
|
|
|
#include <string.h>
|
2008-09-28 17:55:40 +04:00
|
|
|
#include "amiga/tree.h"
|
2008-10-12 01:38:04 +04:00
|
|
|
#include "amiga/history.h"
|
|
|
|
#include "amiga/cookies.h"
|
2008-10-26 15:25:26 +03:00
|
|
|
#include <proto/exec.h>
|
|
|
|
#include "amiga/arexx.h"
|
2008-11-09 02:08:55 +03:00
|
|
|
#include "amiga/save_complete.h"
|
2008-11-17 02:29:40 +03:00
|
|
|
#include "utils/url.h"
|
2008-12-14 02:23:24 +03:00
|
|
|
#include <dos/anchorpath.h>
|
|
|
|
|
2008-10-26 15:25:26 +03:00
|
|
|
|
|
|
|
BOOL menualreadyinit;
|
2008-11-16 02:54:09 +03:00
|
|
|
const char * const netsurf_version;
|
|
|
|
const char * const versvn;
|
|
|
|
const char * const verdate;
|
2008-12-14 02:23:24 +03:00
|
|
|
static struct Hook aslhookfunc;
|
2008-08-25 17:32:26 +04:00
|
|
|
|
2008-10-15 02:43:02 +04:00
|
|
|
void ami_menu_scan(struct tree *tree,struct NewMenu *menu);
|
|
|
|
void ami_menu_scan_2(struct tree *tree,struct node *root,WORD *gen,ULONG *item,struct NewMenu *menu);
|
2008-10-26 15:25:26 +03:00
|
|
|
void ami_menu_arexx_scan(struct NewMenu *menu);
|
2008-12-14 02:23:24 +03:00
|
|
|
static const ULONG ami_asl_mime_hook(struct Hook *mh,struct FileRequester *fr,struct AnchorPathOld *ap);
|
|
|
|
|
2008-10-15 02:43:02 +04:00
|
|
|
|
2008-08-25 17:32:26 +04:00
|
|
|
void ami_free_menulabs(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0;i<=AMI_MENU_MAX;i++)
|
|
|
|
{
|
2008-10-15 02:43:02 +04:00
|
|
|
if(menulab[i] && (menulab[i] != NM_BARLABEL)) ami_utf8_free(menulab[i]);
|
2008-08-25 17:32:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ami_init_menulabs(void)
|
|
|
|
{
|
|
|
|
menulab[0] = ami_utf8_easy((char *)messages_get("Project"));
|
2008-08-31 15:21:47 +04:00
|
|
|
menulab[1] = ami_utf8_easy((char *)messages_get("NewWindowNS"));
|
2008-10-05 03:29:17 +04:00
|
|
|
menulab[2] = ami_utf8_easy((char *)messages_get("NewTab"));
|
|
|
|
menulab[3] = NM_BARLABEL;
|
2008-11-15 18:28:17 +03:00
|
|
|
menulab[4] = ami_utf8_easy((char *)messages_get("OpenFile"));
|
|
|
|
menulab[5] = ami_utf8_easy((char *)messages_get("SaveAs"));
|
|
|
|
menulab[6] = ami_utf8_easy((char *)messages_get("Source"));
|
|
|
|
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("PDF"));
|
|
|
|
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("Paste"));
|
|
|
|
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"));
|
2008-12-14 02:23:24 +03:00
|
|
|
menulab[22] = ami_utf8_easy((char *)messages_get("FindTextNS"));
|
|
|
|
menulab[23] = ami_utf8_easy((char *)messages_get("size"));
|
|
|
|
menulab[24] = ami_utf8_easy((char *)messages_get("normal"));
|
|
|
|
menulab[25] = ami_utf8_easy((char *)messages_get("double"));
|
|
|
|
menulab[26] = NM_BARLABEL;
|
|
|
|
menulab[27] = ami_utf8_easy((char *)messages_get("HistGlobalNS"));
|
|
|
|
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;
|
2008-11-09 02:08:55 +03:00
|
|
|
|
|
|
|
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+2] = ami_utf8_easy((char *)messages_get("SettingsSave"));
|
|
|
|
menulab[AMI_MENU_HOTLIST_MAX+3] = ami_utf8_easy((char *)messages_get("ARexx"));
|
|
|
|
menulab[AMI_MENU_HOTLIST_MAX+4] = ami_utf8_easy((char *)messages_get("ARexxExecute"));
|
|
|
|
menulab[AMI_MENU_HOTLIST_MAX+5] = NM_BARLABEL;
|
2008-08-25 17:32:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct NewMenu *ami_create_menu(ULONG type)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
ULONG menuflags = 0;
|
|
|
|
STATIC struct NewMenu menu[] = {
|
|
|
|
{NM_TITLE,0,0,0,0,0,}, // project
|
|
|
|
{ NM_ITEM,0,"N",0,0,0,}, // new window
|
2008-10-05 03:29:17 +04:00
|
|
|
{ NM_ITEM,0,"T",0,0,0,}, // new tab
|
2008-08-25 17:32:26 +04:00
|
|
|
{ NM_ITEM,NM_BARLABEL,0,0,0,0,},
|
2008-11-15 18:28:17 +03:00
|
|
|
{ NM_ITEM,0,"O",0,0,0,}, // open local file
|
2008-08-26 05:20:01 +04:00
|
|
|
{ NM_ITEM,0,0,0,0,0,}, // save
|
2008-08-31 15:21:47 +04:00
|
|
|
{ NM_SUB,0,"S",0,0,0,}, // save as source
|
2008-08-26 05:20:01 +04:00
|
|
|
{ NM_SUB,0,0,0,0,0,}, // save as text
|
2008-11-09 02:08:55 +03:00
|
|
|
{ NM_SUB,0,0,0,0,0,}, // save as complete
|
2008-08-26 05:20:01 +04:00
|
|
|
{ NM_SUB,0,0,0,0,0,}, // save as pdf
|
|
|
|
{ NM_ITEM,NM_BARLABEL,0,0,0,0,},
|
2008-10-05 17:17:18 +04:00
|
|
|
{ NM_ITEM,0,"K",0,0,0,}, // close tab
|
|
|
|
{ NM_ITEM,0,0,0,0,0,}, // close window
|
2008-10-06 21:47:31 +04:00
|
|
|
{ NM_ITEM,NM_BARLABEL,0,0,0,0,},
|
2008-11-16 02:54:09 +03:00
|
|
|
{ NM_ITEM,0,"?",0,0,0,}, // about
|
2008-10-06 21:47:31 +04:00
|
|
|
{ NM_ITEM,0,"Q",0,0,0,}, // quit
|
2008-08-25 17:32:26 +04:00
|
|
|
{NM_TITLE,0,0,0,0,0,}, // edit
|
|
|
|
{ NM_ITEM,0,"C",0,0,0,}, // copy
|
|
|
|
{ NM_ITEM,0,"V",0,0,0,}, // paste
|
|
|
|
{ NM_ITEM,0,"A",0,0,0,}, // select all
|
|
|
|
{ NM_ITEM,0,"Z",0,0,0,}, // clear selection
|
2008-10-13 22:00:44 +04:00
|
|
|
{NM_TITLE,0,0,0,0,0,}, // browser
|
2008-12-14 02:23:24 +03:00
|
|
|
{ NM_ITEM,0,"F",0,0,0,}, // find in page
|
|
|
|
{ NM_ITEM,0,0,0,0,0,}, // size
|
|
|
|
{ NM_SUB,0,0,0,0,0,}, // normal
|
|
|
|
{ NM_SUB,0,0,0,0,0,}, // double
|
|
|
|
{ NM_ITEM,NM_BARLABEL,0,0,0,0,},
|
2008-10-13 22:00:44 +04:00
|
|
|
{ NM_ITEM,0,0,0,0,0,}, // global history
|
|
|
|
{ NM_ITEM,0,0,0,0,0,}, // cookies
|
2008-08-25 17:32:26 +04:00
|
|
|
{NM_TITLE,0,0,0,0,0,}, // hotlist
|
|
|
|
{ NM_ITEM,0,0,0,0,0,}, // add to hotlist
|
2008-09-28 17:55:40 +04:00
|
|
|
{ NM_ITEM,0,"H",0,0,0,}, // show hotlist (treeview)
|
2008-10-15 02:43:02 +04:00
|
|
|
{ NM_ITEM,NM_BARLABEL,0,0,0,0,},
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
|
2008-08-25 17:32:26 +04:00
|
|
|
{NM_TITLE,0,0,0,0,0,}, // settings
|
|
|
|
{ NM_ITEM,0,0,0,0,0,}, // snapshot window
|
|
|
|
{ NM_ITEM,0,0,0,0,0,}, // save settings
|
2008-10-26 15:25:26 +03:00
|
|
|
{NM_TITLE,0,0,0,0,0,}, // arexx
|
|
|
|
{ NM_ITEM,0,0,0,0,0,}, // execute arexx
|
|
|
|
{ NM_ITEM,NM_BARLABEL,0,0,0,0,},
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
|
|
|
{ NM_IGNORE,0,0,0,0,0,}, // ** arexx entry **
|
2008-08-25 17:32:26 +04:00
|
|
|
{ NM_END,0,0,0,0,0,},
|
|
|
|
};
|
|
|
|
|
|
|
|
if(type != BROWSER_WINDOW_NORMAL)
|
|
|
|
{
|
|
|
|
menuflags = NM_ITEMDISABLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0;i<=AMI_MENU_MAX;i++)
|
|
|
|
{
|
|
|
|
menu[i].nm_Label = menulab[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
menu[1].nm_Flags = menuflags;
|
2008-10-05 03:29:17 +04:00
|
|
|
menu[2].nm_Flags = menuflags;
|
|
|
|
menu[9].nm_Flags = menuflags;
|
2008-10-05 17:17:18 +04:00
|
|
|
menu[10].nm_Flags = menuflags;
|
2008-08-26 05:20:01 +04:00
|
|
|
|
|
|
|
#ifndef WITH_PDF_EXPORT
|
2008-10-05 03:29:17 +04:00
|
|
|
menu[7].nm_Flags = NM_ITEMDISABLED;
|
2008-08-26 05:20:01 +04:00
|
|
|
#endif
|
2008-08-25 17:32:26 +04:00
|
|
|
|
2008-10-26 15:25:26 +03:00
|
|
|
if(!menualreadyinit)
|
|
|
|
{
|
|
|
|
ami_menu_scan(hotlist,menu);
|
|
|
|
ami_menu_arexx_scan(menu);
|
2008-12-14 02:23:24 +03:00
|
|
|
|
|
|
|
aslhookfunc.h_Entry = &ami_asl_mime_hook;
|
|
|
|
aslhookfunc.h_SubEntry = NULL;
|
|
|
|
aslhookfunc.h_Data = NULL;
|
|
|
|
|
2008-10-26 15:25:26 +03:00
|
|
|
menualreadyinit = TRUE;
|
|
|
|
}
|
2008-10-15 02:43:02 +04:00
|
|
|
|
2008-08-25 17:32:26 +04:00
|
|
|
return(menu);
|
|
|
|
}
|
2008-09-04 02:02:41 +04:00
|
|
|
|
2008-10-26 15:25:26 +03:00
|
|
|
void ami_menu_arexx_scan(struct NewMenu *menu)
|
|
|
|
{
|
|
|
|
int item = AMI_MENU_AREXX;
|
|
|
|
BPTR lock = 0;
|
|
|
|
UBYTE *buffer;
|
|
|
|
struct ExAllControl *ctrl;
|
|
|
|
char matchpatt[16];
|
|
|
|
LONG cont;
|
|
|
|
struct ExAllData *ead;
|
|
|
|
|
|
|
|
if(lock = Lock(option_arexx_dir,SHARED_LOCK))
|
|
|
|
{
|
|
|
|
if(buffer = AllocVec(1024,MEMF_PRIVATE | MEMF_CLEAR))
|
|
|
|
{
|
|
|
|
if(ctrl = AllocDosObject(DOS_EXALLCONTROL,NULL))
|
|
|
|
{
|
|
|
|
ctrl->eac_LastKey = 0;
|
|
|
|
|
|
|
|
if(ParsePatternNoCase("#?.nsrx",(char *)&matchpatt,16) != -1)
|
|
|
|
{
|
|
|
|
ctrl->eac_MatchString = (char *)&matchpatt;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
cont = ExAll(lock,buffer,1024,ED_COMMENT,ctrl);
|
|
|
|
if((!cont) && (IoErr() != ERROR_NO_MORE_ENTRIES)) break;
|
|
|
|
if(!ctrl->eac_Entries) continue;
|
|
|
|
|
|
|
|
for(ead = (struct ExAllData *)buffer; ead; ead = ead->ed_Next)
|
|
|
|
{
|
|
|
|
if(item >= AMI_MENU_AREXX_MAX) continue;
|
|
|
|
if(EAD_IS_FILE(ead))
|
|
|
|
{
|
|
|
|
menu[item].nm_Type = NM_ITEM;
|
|
|
|
if(ead->ed_Comment[0] != '\0')
|
|
|
|
{
|
|
|
|
menulab[item] = (char *)strdup(ead->ed_Comment);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menulab[item] = (char *)strdup(ead->ed_Name);
|
|
|
|
}
|
|
|
|
|
|
|
|
menu[item].nm_Label = menulab[item];
|
|
|
|
menu[item].nm_UserData = (char *)strdup(ead->ed_Name);
|
|
|
|
|
|
|
|
item++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}while(cont);
|
|
|
|
FreeDosObject(DOS_EXALLCONTROL,ctrl);
|
|
|
|
}
|
|
|
|
FreeVec(buffer);
|
|
|
|
}
|
|
|
|
UnLock(lock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-15 02:43:02 +04:00
|
|
|
void ami_menu_scan(struct tree *tree,struct NewMenu *menu)
|
|
|
|
{
|
|
|
|
struct node *root = tree->root->child;
|
|
|
|
struct node_element *element=NULL;
|
|
|
|
struct node *node;
|
|
|
|
static WORD gen = 0;
|
2008-10-16 01:40:54 +04:00
|
|
|
static ULONG item;
|
|
|
|
|
|
|
|
item = AMI_MENU_HOTLIST;
|
2008-10-15 02:43:02 +04:00
|
|
|
|
|
|
|
for (node = root; node; node = node->next)
|
|
|
|
{
|
|
|
|
element = tree_find_element(node, TREE_ELEMENT_NAME);
|
|
|
|
if(!element) element = tree_find_element(node, TREE_ELEMENT_TITLE);
|
|
|
|
if(element && (strcmp(element->text,"Menu")==0))
|
|
|
|
{
|
|
|
|
// found menu
|
2008-11-26 01:43:23 +03:00
|
|
|
ami_menu_scan_2(tree,node->child,&gen,&item,menu);
|
2008-10-15 02:43:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ami_menu_scan_2(struct tree *tree,struct node *root,WORD *gen,ULONG *item,struct NewMenu *menu)
|
|
|
|
{
|
|
|
|
struct node *tempnode;
|
|
|
|
struct node_element *element=NULL;
|
|
|
|
struct node *node;
|
|
|
|
|
|
|
|
*gen = *gen + 1;
|
|
|
|
|
|
|
|
for (node = root; node; node = node->next)
|
|
|
|
{
|
|
|
|
element = tree_find_element(node, TREE_ELEMENT_TITLE);
|
|
|
|
|
2008-11-26 01:43:23 +03:00
|
|
|
if((*gen > 0) && (*gen < 3))
|
2008-10-15 02:43:02 +04:00
|
|
|
{
|
|
|
|
if(*item >= AMI_MENU_HOTLIST_MAX) return;
|
|
|
|
|
2008-11-26 01:43:23 +03:00
|
|
|
if(*gen == 1) menu[*item].nm_Type = NM_ITEM;
|
|
|
|
if(*gen == 2) menu[*item].nm_Type = NM_SUB;
|
2008-10-15 02:43:02 +04:00
|
|
|
|
2008-10-18 19:13:18 +04:00
|
|
|
if(strcmp(element->text,"--"))
|
|
|
|
{
|
2008-10-26 15:25:26 +03:00
|
|
|
menulab[*item] = ami_utf8_easy((char *)element->text);
|
2008-10-18 19:13:18 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menulab[*item] = NM_BARLABEL;
|
|
|
|
}
|
|
|
|
|
2008-10-16 01:40:54 +04:00
|
|
|
menu[*item].nm_Label = menulab[*item];
|
2008-10-15 02:43:02 +04:00
|
|
|
|
|
|
|
element = tree_find_element(node, TREE_ELEMENT_URL);
|
2008-10-26 15:25:26 +03:00
|
|
|
if(element && element->text) menu[*item].nm_UserData = (void *)element->text;
|
2008-10-18 19:13:18 +04:00
|
|
|
if(node->folder && (!node->child)) menu[*item].nm_Flags = NM_ITEMDISABLED;
|
2008-10-15 02:43:02 +04:00
|
|
|
|
|
|
|
*item = *item + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node->child)
|
|
|
|
{
|
|
|
|
ami_menu_scan_2(tree,node->child,gen,item,menu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*gen = *gen - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item)
|
2008-09-04 02:02:41 +04:00
|
|
|
{
|
2008-10-05 17:17:18 +04:00
|
|
|
struct browser_window *bw;
|
2008-10-05 03:29:17 +04:00
|
|
|
struct gui_window tgw;
|
2008-09-04 02:02:41 +04:00
|
|
|
ULONG menunum=0,itemnum=0,subnum=0;
|
|
|
|
menunum = MENUNUM(code);
|
|
|
|
itemnum = ITEMNUM(code);
|
|
|
|
subnum = SUBNUM(code);
|
2008-10-05 17:17:18 +04:00
|
|
|
bool openwin=false;
|
|
|
|
bool opentab=true;
|
2008-10-26 15:25:26 +03:00
|
|
|
char *temp;
|
2008-11-09 02:08:55 +03:00
|
|
|
BPTR lock = 0;
|
2008-10-05 17:17:18 +04:00
|
|
|
|
2008-10-05 03:29:17 +04:00
|
|
|
tgw.tab_node = NULL;
|
|
|
|
tgw.tab = 0;
|
|
|
|
tgw.shared = gwin;
|
|
|
|
|
2008-09-04 02:02:41 +04:00
|
|
|
switch(menunum)
|
|
|
|
{
|
|
|
|
case 0: // project
|
|
|
|
switch(itemnum)
|
|
|
|
{
|
|
|
|
case 0: // new window
|
2008-10-05 17:17:18 +04:00
|
|
|
bw = browser_window_create(gwin->bw->current_content->url,gwin->bw, 0, true, openwin);
|
2008-09-04 02:02:41 +04:00
|
|
|
break;
|
|
|
|
|
2008-10-05 03:29:17 +04:00
|
|
|
case 1: // new tab
|
2008-10-05 17:17:18 +04:00
|
|
|
bw = browser_window_create(gwin->bw->current_content->url,gwin->bw, 0, true, opentab);
|
2008-10-05 03:29:17 +04:00
|
|
|
break;
|
|
|
|
|
2008-11-15 18:28:17 +03:00
|
|
|
case 3: // open local file
|
|
|
|
if(AslRequestTags(filereq,
|
|
|
|
ASLFR_TitleText,messages_get("NetSurf"),
|
|
|
|
ASLFR_Screen,scrn,
|
|
|
|
ASLFR_DoSaveMode,FALSE,
|
2008-11-17 02:29:40 +03:00
|
|
|
ASLFR_RejectIcons,TRUE,
|
2008-12-14 02:23:24 +03:00
|
|
|
ASLFR_FilterFunc,&aslhookfunc,
|
|
|
|
// ASLFR_DoPatterns,TRUE,
|
2008-11-17 02:29:40 +03:00
|
|
|
// ASLFR_InitialPattern,"~(#?.info)",
|
2008-11-15 18:28:17 +03:00
|
|
|
TAG_DONE))
|
|
|
|
{
|
|
|
|
if(temp = AllocVec(1024,MEMF_PRIVATE | MEMF_CLEAR))
|
|
|
|
{
|
|
|
|
char *temp2;
|
|
|
|
strlcpy(temp,filereq->fr_Drawer,1024);
|
|
|
|
AddPart(temp,filereq->fr_File,1024);
|
|
|
|
temp2 = path_to_url(temp);
|
|
|
|
browser_window_go(gwin->bw,temp2,NULL, true);
|
|
|
|
free(temp2);
|
|
|
|
FreeVec(temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: // save
|
2008-09-04 02:02:41 +04:00
|
|
|
switch(subnum)
|
|
|
|
{
|
|
|
|
BPTR fh=0;
|
|
|
|
char fname[1024];
|
|
|
|
|
|
|
|
case 0:
|
2009-01-11 00:26:22 +03:00
|
|
|
if(AslRequestTags(savereq,
|
2008-09-04 02:02:41 +04:00
|
|
|
ASLFR_TitleText,messages_get("NetSurf"),
|
|
|
|
ASLFR_Screen,scrn,
|
|
|
|
ASLFR_InitialFile,FilePart(gwin->bw->current_content->url),
|
|
|
|
TAG_DONE))
|
|
|
|
{
|
2009-01-11 00:26:22 +03:00
|
|
|
strlcpy(&fname,savereq->fr_Drawer,1024);
|
|
|
|
AddPart(fname,savereq->fr_File,1024);
|
2008-10-05 03:29:17 +04:00
|
|
|
ami_update_pointer(gwin->win,GUI_POINTER_WAIT);
|
2008-09-04 02:02:41 +04:00
|
|
|
if(fh = FOpen(fname,MODE_NEWFILE,0))
|
|
|
|
{
|
|
|
|
FWrite(fh,gwin->bw->current_content->source_data,1,gwin->bw->current_content->source_size);
|
|
|
|
FClose(fh);
|
|
|
|
SetComment(fname,gwin->bw->current_content->url);
|
|
|
|
}
|
2008-10-05 03:29:17 +04:00
|
|
|
ami_update_pointer(gwin->win,GUI_POINTER_DEFAULT);
|
2008-09-04 02:02:41 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2009-01-11 00:26:22 +03:00
|
|
|
if(AslRequestTags(savereq,
|
2008-09-04 02:02:41 +04:00
|
|
|
ASLFR_TitleText,messages_get("NetSurf"),
|
|
|
|
ASLFR_Screen,scrn,
|
|
|
|
ASLFR_InitialFile,FilePart(gwin->bw->current_content->url),
|
|
|
|
TAG_DONE))
|
|
|
|
{
|
2009-01-11 00:26:22 +03:00
|
|
|
strlcpy(&fname,savereq->fr_Drawer,1024);
|
|
|
|
AddPart(fname,savereq->fr_File,1024);
|
2008-10-05 03:29:17 +04:00
|
|
|
ami_update_pointer(gwin->win,GUI_POINTER_WAIT);
|
2008-09-04 02:02:41 +04:00
|
|
|
save_as_text(gwin->bw->current_content,fname);
|
|
|
|
SetComment(fname,gwin->bw->current_content->url);
|
2008-10-05 03:29:17 +04:00
|
|
|
ami_update_pointer(gwin->win,GUI_POINTER_DEFAULT);
|
2008-09-04 02:02:41 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2009-01-11 00:26:22 +03:00
|
|
|
if(AslRequestTags(savereq,
|
2008-11-09 02:08:55 +03:00
|
|
|
ASLFR_TitleText,messages_get("NetSurf"),
|
|
|
|
ASLFR_Screen,scrn,
|
|
|
|
ASLFR_InitialFile,FilePart(gwin->bw->current_content->url),
|
|
|
|
TAG_DONE))
|
|
|
|
{
|
2009-01-11 00:26:22 +03:00
|
|
|
strlcpy(&fname,savereq->fr_Drawer,1024);
|
|
|
|
AddPart(fname,savereq->fr_File,1024);
|
2008-11-09 02:08:55 +03:00
|
|
|
ami_update_pointer(gwin->win,GUI_POINTER_WAIT);
|
|
|
|
if(lock = CreateDir(fname))
|
|
|
|
{
|
|
|
|
UnLock(lock);
|
|
|
|
save_complete(gwin->bw->current_content,fname);
|
|
|
|
SetComment(fname,gwin->bw->current_content->url);
|
|
|
|
}
|
|
|
|
ami_update_pointer(gwin->win,GUI_POINTER_DEFAULT);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2008-09-04 02:02:41 +04:00
|
|
|
#ifdef WITH_PDF_EXPORT
|
2009-01-11 00:26:22 +03:00
|
|
|
if(AslRequestTags(savereq,
|
2008-09-04 02:02:41 +04:00
|
|
|
ASLFR_TitleText,messages_get("NetSurf"),
|
|
|
|
ASLFR_Screen,scrn,
|
|
|
|
ASLFR_InitialFile,FilePart(gwin->bw->current_content->url),
|
|
|
|
TAG_DONE))
|
|
|
|
{
|
2009-01-11 00:26:22 +03:00
|
|
|
strlcpy(&fname,savereq->fr_Drawer,1024);
|
|
|
|
AddPart(fname,savereq->fr_File,1024);
|
2008-10-05 03:29:17 +04:00
|
|
|
ami_update_pointer(gwin->win,GUI_POINTER_WAIT);
|
2008-09-04 02:02:41 +04:00
|
|
|
pdf_set_scale(DEFAULT_EXPORT_SCALE);
|
|
|
|
save_as_pdf(gwin->bw->current_content,fname);
|
|
|
|
SetComment(fname,gwin->bw->current_content->url);
|
2008-10-05 03:29:17 +04:00
|
|
|
ami_update_pointer(gwin->win,GUI_POINTER_DEFAULT);
|
2008-09-04 02:02:41 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-11-15 18:28:17 +03:00
|
|
|
case 6: // close tab
|
2008-10-05 17:17:18 +04:00
|
|
|
browser_window_destroy(gwin->bw);
|
|
|
|
break;
|
|
|
|
|
2008-11-15 18:28:17 +03:00
|
|
|
case 7: // close window
|
2008-10-06 11:07:33 +04:00
|
|
|
ami_close_all_tabs(gwin);
|
2008-09-04 02:02:41 +04:00
|
|
|
break;
|
2008-10-06 21:47:31 +04:00
|
|
|
|
2008-11-15 18:28:17 +03:00
|
|
|
case 9: // about
|
2008-11-16 02:54:09 +03:00
|
|
|
ami_update_pointer(gwin->win,GUI_POINTER_WAIT);
|
|
|
|
|
|
|
|
TimedDosRequesterTags(
|
|
|
|
TDR_ImageType,TDRIMAGE_INFO,
|
|
|
|
TDR_TitleString,messages_get("NetSurf"),
|
|
|
|
TDR_Window,gwin->win,
|
|
|
|
TDR_GadgetString,messages_get("OK"),
|
|
|
|
TDR_FormatString,"NetSurf %s\n%s (%s)\n\nhttp://www.netsurf-browser.org",
|
|
|
|
TDR_Arg1,netsurf_version,
|
|
|
|
TDR_Arg2,versvn,
|
|
|
|
TDR_Arg3,verdate,
|
|
|
|
TAG_DONE);
|
|
|
|
|
|
|
|
ami_update_pointer(gwin->win,GUI_POINTER_DEFAULT);
|
2008-11-15 18:28:17 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 10: // quit
|
2008-10-06 21:47:31 +04:00
|
|
|
ami_quit_netsurf();
|
|
|
|
break;
|
2008-09-04 02:02:41 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // edit
|
|
|
|
switch(itemnum)
|
|
|
|
{
|
|
|
|
case 0: // copy
|
|
|
|
gui_copy_to_clipboard(gwin->bw->sel);
|
2008-09-28 17:55:40 +04:00
|
|
|
browser_window_key_press(gwin->bw, 26);
|
2008-09-04 02:02:41 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // paste
|
2008-10-05 03:29:17 +04:00
|
|
|
gui_paste_from_clipboard(&tgw,0,0);
|
2008-09-04 02:02:41 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // select all
|
|
|
|
browser_window_key_press(gwin->bw, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: // clear selection
|
|
|
|
browser_window_key_press(gwin->bw, 26);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-10-13 22:00:44 +04:00
|
|
|
case 2:
|
|
|
|
switch(itemnum)
|
|
|
|
{
|
2008-12-14 02:23:24 +03:00
|
|
|
case 0: // search
|
|
|
|
ami_search_open(gwin->bw->window);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // size
|
|
|
|
switch(subnum)
|
|
|
|
{
|
|
|
|
case 0: // normal
|
|
|
|
gwin->bw->scale = 1.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // double
|
|
|
|
gwin->bw->scale = 2.0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: // global history
|
2008-10-13 22:00:44 +04:00
|
|
|
ami_open_tree(global_history_tree,AMI_TREE_HISTORY);
|
|
|
|
break;
|
|
|
|
|
2008-12-14 02:23:24 +03:00
|
|
|
case 4: // cookies tree
|
2008-10-13 22:00:44 +04:00
|
|
|
ami_open_tree(cookies_tree,AMI_TREE_COOKIES);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: // hotlist
|
2008-09-04 02:02:41 +04:00
|
|
|
switch(itemnum)
|
|
|
|
{
|
|
|
|
case 0: // add
|
|
|
|
ami_hotlist_add(hotlist->root,gwin->bw->current_content);
|
2009-01-16 22:16:32 +03:00
|
|
|
options_save_tree(hotlist,option_hotlist_file,messages_get("TreeHotlist"));
|
2008-09-04 02:02:41 +04:00
|
|
|
break;
|
|
|
|
|
2008-09-28 17:55:40 +04:00
|
|
|
case 1: // show
|
2008-10-12 01:38:04 +04:00
|
|
|
ami_open_tree(hotlist,AMI_TREE_HOTLIST);
|
2008-09-28 17:55:40 +04:00
|
|
|
break;
|
2008-10-15 02:43:02 +04:00
|
|
|
|
|
|
|
default: // bookmarks
|
|
|
|
if(GTMENUITEM_USERDATA(item))
|
|
|
|
browser_window_go(gwin->bw,GTMENUITEM_USERDATA(item),NULL, true);
|
|
|
|
break;
|
2008-09-04 02:02:41 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-10-13 22:00:44 +04:00
|
|
|
case 4: // settings
|
2008-09-04 02:02:41 +04:00
|
|
|
switch(itemnum)
|
|
|
|
{
|
|
|
|
case 0: // snapshot
|
|
|
|
option_window_x = gwin->win->LeftEdge;
|
|
|
|
option_window_y = gwin->win->TopEdge;
|
|
|
|
option_window_width = gwin->win->Width;
|
|
|
|
option_window_height = gwin->win->Height;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // save settings
|
|
|
|
options_write("Resources/Options");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2008-10-26 15:25:26 +03:00
|
|
|
|
|
|
|
case 5: // arexx
|
|
|
|
switch(itemnum)
|
|
|
|
{
|
|
|
|
case 0: // execute arexx
|
|
|
|
if(AslRequestTags(filereq,
|
|
|
|
ASLFR_TitleText,messages_get("NetSurf"),
|
|
|
|
ASLFR_Screen,scrn,
|
|
|
|
ASLFR_DoSaveMode,FALSE,
|
|
|
|
ASLFR_InitialDrawer,option_arexx_dir,
|
|
|
|
ASLFR_InitialPattern,"#?.nsrx",
|
|
|
|
TAG_DONE))
|
|
|
|
{
|
|
|
|
if(temp = AllocVec(1024,MEMF_PRIVATE | MEMF_CLEAR))
|
|
|
|
{
|
|
|
|
strlcpy(temp,filereq->fr_Drawer,1024);
|
|
|
|
AddPart(temp,filereq->fr_File,1024);
|
|
|
|
ami_arexx_execute(temp);
|
|
|
|
FreeVec(temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: // arexx menu items
|
|
|
|
if(GTMENUITEM_USERDATA(item))
|
|
|
|
{
|
|
|
|
if(temp = AllocVec(1024,MEMF_PRIVATE | MEMF_CLEAR))
|
|
|
|
{
|
|
|
|
strcpy(temp,option_arexx_dir);
|
|
|
|
AddPart(temp,GTMENUITEM_USERDATA(item),1024);
|
|
|
|
ami_arexx_execute(temp);
|
|
|
|
FreeVec(temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2008-09-04 02:02:41 +04:00
|
|
|
}
|
|
|
|
}
|
2008-12-14 02:23:24 +03:00
|
|
|
|
|
|
|
static const ULONG ami_asl_mime_hook(struct Hook *mh,struct FileRequester *fr,struct AnchorPathOld *ap)
|
|
|
|
{
|
|
|
|
BPTR file = 0;
|
|
|
|
char buffer[10];
|
|
|
|
char fname[1024];
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
char *mt = NULL;
|
|
|
|
|
|
|
|
if(ap->ap_Info.fib_DirEntryType > 0) return(TRUE);
|
|
|
|
|
|
|
|
strcpy(fname,fr->fr_Drawer);
|
|
|
|
AddPart(fname,ap->ap_Info.fib_FileName,1024);
|
|
|
|
|
|
|
|
mt = fetch_mimetype(fname);
|
|
|
|
|
|
|
|
if(!strcmp(mt,"text/html")) ret = TRUE;
|
|
|
|
else if(!strcmp(mt,"text/plain")) ret = TRUE;
|
|
|
|
else if(!strcmp(mt,"image/jpeg")) ret = TRUE;
|
|
|
|
else if(!strcmp(mt,"image/gif")) ret = TRUE;
|
|
|
|
else if(!strcmp(mt,"image/png")) ret = TRUE;
|
|
|
|
else if(!strcmp(mt,"image/jng")) ret = TRUE;
|
|
|
|
else if(!strcmp(mt,"image/mng")) ret = TRUE;
|
|
|
|
else if(!strcmp(mt,"image/bmp")) ret = TRUE;
|
|
|
|
else if(!strcmp(mt,"image/ico")) ret = TRUE;
|
|
|
|
else if(!strcmp(mt,"image/x-riscos-sprite")) ret = TRUE;
|
|
|
|
#ifdef WITH_NS_SVG
|
|
|
|
else if(!strcmp(mt,"image/svg")) ret = TRUE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
free(mt);
|
|
|
|
return ret;
|
|
|
|
}
|