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/>.
|
|
|
|
*/
|
|
|
|
|
2010-07-24 23:57:27 +04:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <proto/dos.h>
|
|
|
|
#include <proto/asl.h>
|
|
|
|
#include <proto/exec.h>
|
2011-03-16 22:23:24 +03:00
|
|
|
#include <proto/gadtools.h>
|
2010-07-24 23:57:27 +04:00
|
|
|
#include <proto/intuition.h>
|
2011-03-16 22:23:24 +03:00
|
|
|
#include <proto/utility.h>
|
2011-01-07 02:17:17 +03:00
|
|
|
#ifdef __amigaos4__
|
2010-07-24 23:57:27 +04:00
|
|
|
#include <dos/anchorpath.h>
|
2011-01-07 02:17:17 +03:00
|
|
|
#endif
|
2011-03-16 22:23:24 +03:00
|
|
|
|
2010-07-24 23:57:27 +04:00
|
|
|
#include <libraries/gadtools.h>
|
2011-02-24 02:15:12 +03:00
|
|
|
|
2011-03-16 22:23:24 +03:00
|
|
|
#include <classes/window.h>
|
2011-02-24 02:15:12 +03:00
|
|
|
#include <proto/label.h>
|
|
|
|
#include <images/label.h>
|
|
|
|
#include <proto/bitmap.h>
|
|
|
|
#include <images/bitmap.h>
|
|
|
|
|
|
|
|
#include <reaction/reaction_macros.h>
|
2010-07-24 23:57:27 +04:00
|
|
|
|
2008-10-26 15:25:26 +03:00
|
|
|
#include "amiga/arexx.h"
|
2009-05-17 13:55:28 +04:00
|
|
|
#include "amiga/bitmap.h"
|
|
|
|
#include "amiga/clipboard.h"
|
2011-03-16 22:23:24 +03:00
|
|
|
#include "amiga/cookies.h"
|
2011-10-15 18:09:35 +04:00
|
|
|
#include "amiga/file.h"
|
2011-07-23 18:05:08 +04:00
|
|
|
#include "amiga/filetype.h"
|
2011-03-16 22:23:24 +03:00
|
|
|
#include "amiga/gui.h"
|
2009-06-21 02:29:43 +04:00
|
|
|
#include "amiga/gui_options.h"
|
2011-03-16 22:23:24 +03:00
|
|
|
#include "amiga/history.h"
|
|
|
|
#include "amiga/history_local.h"
|
|
|
|
#include "amiga/hotlist.h"
|
|
|
|
#include "amiga/menu.h"
|
2012-03-22 13:34:34 +04:00
|
|
|
#include "desktop/options.h"
|
2009-08-23 19:59:41 +04:00
|
|
|
#include "amiga/print.h"
|
2011-03-16 22:23:24 +03:00
|
|
|
#include "amiga/search.h"
|
|
|
|
#include "amiga/theme.h"
|
|
|
|
#include "amiga/tree.h"
|
|
|
|
#include "amiga/utf8.h"
|
2011-02-24 02:15:12 +03:00
|
|
|
#include "desktop/tree_url_node.h"
|
|
|
|
#include "desktop/hotlist.h"
|
2010-07-24 23:57:27 +04:00
|
|
|
#include "desktop/browser.h"
|
|
|
|
#include "desktop/gui.h"
|
|
|
|
#include "desktop/selection.h"
|
|
|
|
#include "desktop/textinput.h"
|
|
|
|
#include "utils/messages.h"
|
2011-11-07 22:51:08 +04:00
|
|
|
#include "utils/schedule.h"
|
2008-10-26 15:25:26 +03:00
|
|
|
|
2011-02-24 02:15:12 +03:00
|
|
|
#define IMAGE_MENU_ITEM(n, i, t) \
|
|
|
|
gwin->menulab[n] = LabelObject, \
|
|
|
|
LABEL_DrawInfo, dri, \
|
|
|
|
LABEL_Image, BitMapObject, \
|
|
|
|
BITMAP_Screen, scrn, \
|
|
|
|
BITMAP_SourceFile, i, \
|
|
|
|
BitMapEnd, \
|
|
|
|
LABEL_Text, t, \
|
|
|
|
LabelEnd;
|
|
|
|
|
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-08-25 17:32:26 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
ULONG ami_menu_scan(struct tree *tree, bool count, struct gui_window_2 *gwin);
|
|
|
|
void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
|
|
|
|
ULONG *item, bool count, struct gui_window_2 *gwin);
|
|
|
|
void ami_menu_arexx_scan(struct gui_window_2 *gwin);
|
2008-12-14 02:23:24 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
/* Functions for menu selections */
|
|
|
|
static void ami_menu_item_project_newwin(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_project_newtab(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_project_open(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_project_save(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_project_closetab(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_project_closewin(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_project_print(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_project_about(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_project_quit(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_edit_cut(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_edit_copy(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_edit_paste(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_edit_selectall(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_edit_clearsel(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_browser_find(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_browser_localhistory(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_browser_globalhistory(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_browser_cookies(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_browser_scale_decrease(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_browser_scale_normal(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_browser_scale_increase(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_browser_redraw(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_hotlist_add(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_hotlist_show(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_hotlist_entries(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_settings_edit(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_settings_snapshot(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_settings_save(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_arexx_execute(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_arexx_entries(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
|
2008-10-15 02:43:02 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
void ami_free_menulabs(struct gui_window_2 *gwin)
|
2008-08-25 17:32:26 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
for(i=0;i<=AMI_MENU_AREXX_MAX;i++)
|
2008-08-25 17:32:26 +04:00
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
if(gwin->menulab[i] && (gwin->menulab[i] != NM_BARLABEL))
|
2011-02-24 02:15:12 +03:00
|
|
|
{
|
|
|
|
if(gwin->menutype[i] & MENU_IMAGE)
|
|
|
|
{
|
|
|
|
//TODO: Free image structure
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
ami_utf8_free(gwin->menulab[i]);
|
2011-02-24 02:15:12 +03:00
|
|
|
}
|
2012-04-29 19:59:37 +04:00
|
|
|
|
|
|
|
if(i >= AMI_MENU_AREXX)
|
|
|
|
{
|
|
|
|
if(gwin->menu_hook[i].h_Data) free(gwin->menu_hook[i].h_Data);
|
|
|
|
}
|
2011-02-24 02:15:12 +03:00
|
|
|
}
|
2010-10-05 23:14:46 +04:00
|
|
|
|
|
|
|
gwin->menulab[i] = NULL;
|
|
|
|
gwin->menukey[i] = 0;
|
2010-07-25 00:18:56 +04:00
|
|
|
}
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
FreeVec(gwin->menutype);
|
|
|
|
FreeVec(gwin->menu);
|
|
|
|
|
|
|
|
gwin->menutype = NULL;
|
|
|
|
gwin->menu = NULL;
|
|
|
|
}
|
|
|
|
|
2011-09-05 02:26:24 +04:00
|
|
|
void ami_init_menulabs(struct gui_window_2 *gwin)
|
2010-10-05 23:14:46 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
gwin->menutype = AllocVec(AMI_MENU_AREXX_MAX + 1, MEMF_PRIVATE | MEMF_CLEAR);
|
|
|
|
|
|
|
|
for(i=0;i <= AMI_MENU_AREXX_MAX;i++)
|
2010-07-25 00:18:56 +04:00
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[i] = NM_IGNORE;
|
|
|
|
gwin->menulab[i] = NULL;
|
2008-08-25 17:32:26 +04:00
|
|
|
}
|
2010-10-05 23:14:46 +04:00
|
|
|
|
|
|
|
gwin->menutype[0] = NM_TITLE;
|
|
|
|
gwin->menulab[0] = ami_utf8_easy((char *)messages_get("Project"));
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[1] = NM_ITEM;
|
|
|
|
gwin->menulab[1] = ami_utf8_easy((char *)messages_get("NewWindowNS"));
|
|
|
|
gwin->menukey[1] = 'N';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[1].h_Entry = (HOOKFUNC)ami_menu_item_project_newwin;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[2] = NM_ITEM;
|
|
|
|
gwin->menulab[2] = ami_utf8_easy((char *)messages_get("NewTab"));
|
2010-10-08 02:38:27 +04:00
|
|
|
gwin->menukey[2] = 'T';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[2].h_Entry = (HOOKFUNC)ami_menu_item_project_newtab;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[3] = NM_ITEM;
|
|
|
|
gwin->menulab[3] = NM_BARLABEL;
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[4] = NM_ITEM;
|
|
|
|
gwin->menulab[4] = ami_utf8_easy((char *)messages_get("OpenFile"));
|
|
|
|
gwin->menukey[4] = 'O';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[4].h_Entry = (HOOKFUNC)ami_menu_item_project_open;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[5] = NM_ITEM;
|
|
|
|
gwin->menulab[5] = ami_utf8_easy((char *)messages_get("SaveAsNS"));
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[6] = NM_SUB;
|
|
|
|
gwin->menulab[6] = ami_utf8_easy((char *)messages_get("Source"));
|
2010-10-08 02:38:27 +04:00
|
|
|
gwin->menukey[6] = 'S';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[6].h_Entry = (HOOKFUNC)ami_menu_item_project_save;
|
|
|
|
gwin->menu_hook[6].h_Data = AMINS_SAVE_SOURCE;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[7] = NM_SUB;
|
|
|
|
gwin->menulab[7] = ami_utf8_easy((char *)messages_get("TextNS"));
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[7].h_Entry = (HOOKFUNC)ami_menu_item_project_save;
|
|
|
|
gwin->menu_hook[7].h_Data = (void *)AMINS_SAVE_TEXT;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[8] = NM_SUB;
|
|
|
|
gwin->menulab[8] = ami_utf8_easy((char *)messages_get("SaveCompNS"));
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[8].h_Entry = (HOOKFUNC)ami_menu_item_project_save;
|
|
|
|
gwin->menu_hook[8].h_Data = (void *)AMINS_SAVE_COMPLETE;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[9] = NM_SUB;
|
|
|
|
gwin->menulab[9] = ami_utf8_easy((char *)messages_get("PDFNS"));
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[9].h_Entry = (HOOKFUNC)ami_menu_item_project_save;
|
|
|
|
gwin->menu_hook[9].h_Data = (void *)AMINS_SAVE_PDF;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[10] = NM_SUB;
|
|
|
|
gwin->menulab[10] = ami_utf8_easy((char *)messages_get("IFF"));
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[10].h_Entry = (HOOKFUNC)ami_menu_item_project_save;
|
|
|
|
gwin->menu_hook[10].h_Data = (void *)AMINS_SAVE_IFF;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[11] = NM_ITEM;
|
|
|
|
gwin->menulab[11] = NM_BARLABEL;
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[12] = NM_ITEM;
|
|
|
|
gwin->menulab[12] = ami_utf8_easy((char *)messages_get("CloseTab"));
|
|
|
|
gwin->menukey[12] = 'K';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[12].h_Entry = (HOOKFUNC)ami_menu_item_project_closetab;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[13] = NM_ITEM;
|
|
|
|
gwin->menulab[13] = ami_utf8_easy((char *)messages_get("CloseWindow"));
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[13].h_Entry = (HOOKFUNC)ami_menu_item_project_closewin;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[14] = NM_ITEM;
|
|
|
|
gwin->menulab[14] = NM_BARLABEL;
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[15] = NM_ITEM;
|
|
|
|
gwin->menulab[15] = ami_utf8_easy((char *)messages_get("PrintNS"));
|
|
|
|
gwin->menukey[15] = 'P';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[15].h_Entry = (HOOKFUNC)ami_menu_item_project_print;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[16] = NM_ITEM;
|
|
|
|
gwin->menulab[16] = NM_BARLABEL;
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[17] = NM_ITEM;
|
|
|
|
gwin->menulab[17] = ami_utf8_easy((char *)messages_get("About"));
|
|
|
|
gwin->menukey[17] = '?';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[17].h_Entry = (HOOKFUNC)ami_menu_item_project_about;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[18] = NM_ITEM;
|
|
|
|
gwin->menulab[18] = ami_utf8_easy((char *)messages_get("Quit"));
|
|
|
|
gwin->menukey[18] = 'Q';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[18].h_Entry = (HOOKFUNC)ami_menu_item_project_quit;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[19] = NM_TITLE;
|
|
|
|
gwin->menulab[19] = ami_utf8_easy((char *)messages_get("Edit"));
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[20] = NM_ITEM;
|
|
|
|
gwin->menulab[20] = ami_utf8_easy((char *)messages_get("CutNS"));
|
|
|
|
gwin->menukey[20] = 'X';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[20].h_Entry = (HOOKFUNC)ami_menu_item_edit_cut;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[21] = NM_ITEM;
|
|
|
|
gwin->menulab[21] = ami_utf8_easy((char *)messages_get("CopyNS"));
|
|
|
|
gwin->menukey[21] = 'C';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[21].h_Entry = (HOOKFUNC)ami_menu_item_edit_copy;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[22] = NM_ITEM;
|
|
|
|
gwin->menulab[22] = ami_utf8_easy((char *)messages_get("PasteNS"));
|
|
|
|
gwin->menukey[22] = 'V';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[22].h_Entry = (HOOKFUNC)ami_menu_item_edit_paste;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[23] = NM_ITEM;
|
|
|
|
gwin->menulab[23] = NM_BARLABEL;
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[24] = NM_ITEM;
|
|
|
|
gwin->menulab[24] = ami_utf8_easy((char *)messages_get("SelectAllNS"));
|
|
|
|
gwin->menukey[24] = 'A';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[24].h_Entry = (HOOKFUNC)ami_menu_item_edit_selectall;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[25] = NM_ITEM;
|
|
|
|
gwin->menulab[25] = ami_utf8_easy((char *)messages_get("ClearNS"));
|
|
|
|
gwin->menukey[25] = 'Z';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[25].h_Entry = (HOOKFUNC)ami_menu_item_edit_clearsel;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[26] = NM_TITLE;
|
|
|
|
gwin->menulab[26] = ami_utf8_easy((char *)messages_get("Browser"));
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[27] = NM_ITEM;
|
|
|
|
gwin->menulab[27] = ami_utf8_easy((char *)messages_get("FindTextNS"));
|
|
|
|
gwin->menukey[27] = 'F';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[27].h_Entry = (HOOKFUNC)ami_menu_item_browser_find;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[28] = NM_ITEM;
|
|
|
|
gwin->menulab[28] = NM_BARLABEL;
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[29] = NM_ITEM;
|
|
|
|
gwin->menulab[29] = ami_utf8_easy((char *)messages_get("HistLocalNS"));
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[29].h_Entry = (HOOKFUNC)ami_menu_item_browser_localhistory;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[30] = NM_ITEM;
|
|
|
|
gwin->menulab[30] = ami_utf8_easy((char *)messages_get("HistGlobalNS"));
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[30].h_Entry = (HOOKFUNC)ami_menu_item_browser_globalhistory;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[31] = NM_ITEM;
|
|
|
|
gwin->menulab[31] = NM_BARLABEL;
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[32] = NM_ITEM;
|
|
|
|
gwin->menulab[32] = ami_utf8_easy((char *)messages_get("ShowCookies"));
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[32].h_Entry = (HOOKFUNC)ami_menu_item_browser_cookies;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[33] = NM_ITEM;
|
|
|
|
gwin->menulab[33] = NM_BARLABEL;
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[34] = NM_ITEM;
|
|
|
|
gwin->menulab[34] = ami_utf8_easy((char *)messages_get("ScaleNS"));
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[35] = NM_SUB;
|
|
|
|
gwin->menulab[35] = ami_utf8_easy((char *)messages_get("ScaleDec"));
|
|
|
|
gwin->menukey[35] = '-';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[35].h_Entry = (HOOKFUNC)ami_menu_item_browser_scale_decrease;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[36] = NM_SUB;
|
|
|
|
gwin->menulab[36] = ami_utf8_easy((char *)messages_get("ScaleNorm"));
|
|
|
|
gwin->menukey[36] = '=';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[36].h_Entry = (HOOKFUNC)ami_menu_item_browser_scale_normal;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[37] = NM_SUB;
|
|
|
|
gwin->menulab[37] = ami_utf8_easy((char *)messages_get("ScaleInc"));
|
|
|
|
gwin->menukey[37] = '+';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[37].h_Entry = (HOOKFUNC)ami_menu_item_browser_scale_increase;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[38] = NM_ITEM;
|
|
|
|
gwin->menulab[38] = ami_utf8_easy((char *)messages_get("Redraw"));
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[38].h_Entry = (HOOKFUNC)ami_menu_item_browser_redraw;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[39] = NM_TITLE;
|
|
|
|
gwin->menulab[39] = ami_utf8_easy((char *)messages_get("Hotlist"));
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[40] = NM_ITEM;
|
|
|
|
gwin->menulab[40] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
|
2010-10-08 02:38:27 +04:00
|
|
|
gwin->menukey[40] = 'B';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[40].h_Entry = (HOOKFUNC)ami_menu_item_hotlist_add;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[41] = NM_ITEM;
|
|
|
|
gwin->menulab[41] = ami_utf8_easy((char *)messages_get("HotlistShowNS"));
|
2010-10-08 02:38:27 +04:00
|
|
|
gwin->menukey[41] = 'H';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[41].h_Entry = (HOOKFUNC)ami_menu_item_hotlist_show;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[42] = NM_ITEM;
|
|
|
|
gwin->menulab[42] = NM_BARLABEL;
|
|
|
|
|
|
|
|
gwin->menutype[AMI_MENU_HOTLIST_MAX + 1] = NM_TITLE;
|
|
|
|
gwin->menulab[AMI_MENU_HOTLIST_MAX + 1] = ami_utf8_easy((char *)messages_get("Settings"));
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[AMI_MENU_HOTLIST_MAX + 2] = NM_ITEM;
|
|
|
|
gwin->menulab[AMI_MENU_HOTLIST_MAX + 2] = ami_utf8_easy((char *)messages_get("SettingsEdit"));
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[AMI_MENU_HOTLIST_MAX + 2].h_Entry = (HOOKFUNC)ami_menu_item_settings_edit;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[AMI_MENU_HOTLIST_MAX + 3] = NM_ITEM;
|
|
|
|
gwin->menulab[AMI_MENU_HOTLIST_MAX + 3] = NM_BARLABEL;
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[AMI_MENU_HOTLIST_MAX + 4] = NM_ITEM;
|
|
|
|
gwin->menulab[AMI_MENU_HOTLIST_MAX + 4] = ami_utf8_easy((char *)messages_get("SnapshotWindow"));
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[AMI_MENU_HOTLIST_MAX + 4].h_Entry = (HOOKFUNC)ami_menu_item_settings_snapshot;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[AMI_MENU_HOTLIST_MAX + 5] = NM_ITEM;
|
|
|
|
gwin->menulab[AMI_MENU_HOTLIST_MAX + 5] = ami_utf8_easy((char *)messages_get("SettingsSave"));
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[AMI_MENU_HOTLIST_MAX + 5].h_Entry = (HOOKFUNC)ami_menu_item_settings_save;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[AMI_MENU_HOTLIST_MAX + 6] = NM_TITLE;
|
|
|
|
gwin->menulab[AMI_MENU_HOTLIST_MAX + 6] = ami_utf8_easy((char *)messages_get("ARexx"));
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[AMI_MENU_HOTLIST_MAX + 7] = NM_ITEM;
|
|
|
|
gwin->menulab[AMI_MENU_HOTLIST_MAX + 7] = ami_utf8_easy((char *)messages_get("ARexxExecute"));
|
2010-10-08 02:38:27 +04:00
|
|
|
gwin->menukey[AMI_MENU_HOTLIST_MAX + 7] = 'E';
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[AMI_MENU_HOTLIST_MAX + 7].h_Entry = (HOOKFUNC)ami_menu_item_arexx_execute;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menutype[AMI_MENU_HOTLIST_MAX + 8] = NM_ITEM;
|
|
|
|
gwin->menulab[AMI_MENU_HOTLIST_MAX + 8] = NM_BARLABEL;
|
|
|
|
|
|
|
|
gwin->menutype[AMI_MENU_AREXX_MAX] = NM_END;
|
2008-08-25 17:32:26 +04:00
|
|
|
}
|
|
|
|
|
2011-11-07 22:51:08 +04:00
|
|
|
/* Menu refresh for hotlist */
|
2010-10-05 23:14:46 +04:00
|
|
|
void ami_menu_refresh(struct gui_window_2 *gwin)
|
2008-08-25 17:32:26 +04:00
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
SetAttrs(gwin->objects[OID_MAIN],
|
|
|
|
WINDOW_NewMenu, NULL,
|
|
|
|
TAG_DONE);
|
|
|
|
|
|
|
|
ami_free_menulabs(gwin);
|
2011-09-05 02:26:24 +04:00
|
|
|
ami_create_menu(gwin);
|
2010-10-05 23:14:46 +04:00
|
|
|
|
|
|
|
SetAttrs(gwin->objects[OID_MAIN],
|
|
|
|
WINDOW_NewMenu, gwin->menu,
|
|
|
|
TAG_DONE);
|
2008-08-25 17:32:26 +04:00
|
|
|
}
|
|
|
|
|
2011-09-05 02:26:24 +04:00
|
|
|
struct NewMenu *ami_create_menu(struct gui_window_2 *gwin)
|
2008-08-25 17:32:26 +04:00
|
|
|
{
|
|
|
|
int i;
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2011-09-05 02:26:24 +04:00
|
|
|
ami_init_menulabs(gwin);
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menu = AllocVec(sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1), MEMF_CLEAR);
|
2008-08-25 17:32:26 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
for(i=0;i<=AMI_MENU_AREXX_MAX;i++)
|
2008-08-25 17:32:26 +04:00
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menu[i].nm_Type = gwin->menutype[i];
|
|
|
|
gwin->menu[i].nm_Label = gwin->menulab[i];
|
|
|
|
if(gwin->menukey[i]) gwin->menu[i].nm_CommKey = &gwin->menukey[i];
|
|
|
|
gwin->menu[i].nm_Flags = 0;
|
2012-04-29 19:59:37 +04:00
|
|
|
if(gwin->menu_hook[i].h_Entry) gwin->menu[i].nm_UserData = &gwin->menu_hook[i];
|
2008-08-25 17:32:26 +04:00
|
|
|
}
|
|
|
|
|
2011-09-05 02:26:24 +04:00
|
|
|
gwin->menu[1].nm_Flags = 0;
|
|
|
|
gwin->menu[2].nm_Flags = 0;
|
|
|
|
gwin->menu[12].nm_Flags = 0;
|
|
|
|
gwin->menu[13].nm_Flags = 0;
|
2008-08-26 05:20:01 +04:00
|
|
|
|
|
|
|
#ifndef WITH_PDF_EXPORT
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menu[9].nm_Flags = NM_ITEMDISABLED;
|
2008-08-26 05:20:01 +04:00
|
|
|
#endif
|
2008-08-25 17:32:26 +04:00
|
|
|
|
2012-02-28 22:51:26 +04:00
|
|
|
gwin->menu[15].nm_Flags = NM_ITEMDISABLED;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
ami_menu_scan(ami_tree_get_tree(hotlist_window), false, gwin);
|
|
|
|
ami_menu_arexx_scan(gwin);
|
|
|
|
|
2011-11-07 22:51:08 +04:00
|
|
|
/* Set up scheduler to refresh the hotlist menu */
|
2012-03-22 13:34:34 +04:00
|
|
|
if(nsoption_int(menu_refresh) > 0)
|
|
|
|
schedule(nsoption_int(menu_refresh), (void *)ami_menu_refresh, gwin);
|
2010-10-05 23:14:46 +04:00
|
|
|
|
|
|
|
return(gwin->menu);
|
2008-08-25 17:32:26 +04:00
|
|
|
}
|
2008-09-04 02:02:41 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
void ami_menu_arexx_scan(struct gui_window_2 *gwin)
|
2008-10-26 15:25:26 +03:00
|
|
|
{
|
|
|
|
int item = AMI_MENU_AREXX;
|
|
|
|
BPTR lock = 0;
|
|
|
|
UBYTE *buffer;
|
|
|
|
struct ExAllControl *ctrl;
|
|
|
|
char matchpatt[16];
|
|
|
|
LONG cont;
|
|
|
|
struct ExAllData *ead;
|
|
|
|
|
2012-03-22 13:34:34 +04:00
|
|
|
if(lock = Lock(nsoption_charp(arexx_dir), SHARED_LOCK))
|
2008-10-26 15:25:26 +03:00
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
2011-09-03 02:09:23 +04:00
|
|
|
cont = ExAll(lock,(struct ExAllData *)buffer,1024,ED_COMMENT,ctrl);
|
2008-10-26 15:25:26 +03:00
|
|
|
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))
|
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menu[item].nm_Type = NM_ITEM;
|
2008-10-26 15:25:26 +03:00
|
|
|
if(ead->ed_Comment[0] != '\0')
|
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menulab[item] = (char *)strdup(ead->ed_Comment);
|
2008-10-26 15:25:26 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menulab[item] = (char *)strdup(ead->ed_Name);
|
2008-10-26 15:25:26 +03:00
|
|
|
}
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menu[item].nm_Label = gwin->menulab[item];
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[item].h_Entry = (HOOKFUNC)ami_menu_item_arexx_entries;
|
|
|
|
gwin->menu_hook[item].h_Data = (char *)strdup(ead->ed_Name);
|
|
|
|
gwin->menu[item].nm_UserData = (HOOKFUNC)&gwin->menu_hook[item];
|
2008-10-26 15:25:26 +03:00
|
|
|
|
|
|
|
item++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}while(cont);
|
|
|
|
FreeDosObject(DOS_EXALLCONTROL,ctrl);
|
|
|
|
}
|
|
|
|
FreeVec(buffer);
|
|
|
|
}
|
|
|
|
UnLock(lock);
|
|
|
|
}
|
2010-10-05 23:14:46 +04:00
|
|
|
|
|
|
|
gwin->menu[item].nm_Type = NM_END;
|
|
|
|
gwin->menu[item].nm_Label = NULL;
|
2008-10-26 15:25:26 +03:00
|
|
|
}
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
ULONG ami_menu_scan(struct tree *tree, bool count, struct gui_window_2 *gwin)
|
2008-10-15 02:43:02 +04:00
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
struct node *root = tree_node_get_child(tree_get_root(tree));
|
2008-10-15 02:43:02 +04:00
|
|
|
struct node *node;
|
2010-10-05 23:14:46 +04:00
|
|
|
struct node_element *element;
|
2008-10-15 02:43:02 +04:00
|
|
|
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
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
for (node = root; node; node = tree_node_get_next(node))
|
2008-10-15 02:43:02 +04:00
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
|
|
|
|
if(!element) element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
|
|
|
|
if(element && (strcmp(tree_node_element_get_text(element),"Menu")==0))
|
2008-10-15 02:43:02 +04:00
|
|
|
{
|
|
|
|
// found menu
|
2010-10-05 23:14:46 +04:00
|
|
|
ami_menu_scan_2(tree,tree_node_get_child(node),&gen,&item,count,gwin);
|
2008-10-15 02:43:02 +04:00
|
|
|
}
|
|
|
|
}
|
2010-10-05 23:14:46 +04:00
|
|
|
|
|
|
|
return(item - AMI_MENU_HOTLIST);
|
2008-10-15 02:43:02 +04:00
|
|
|
}
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
void ami_menu_scan_2(struct tree *tree,struct node *root,WORD *gen,
|
|
|
|
ULONG *item, bool count, struct gui_window_2 *gwin)
|
2008-10-15 02:43:02 +04:00
|
|
|
{
|
|
|
|
struct node *tempnode;
|
|
|
|
struct node_element *element=NULL;
|
|
|
|
struct node *node;
|
|
|
|
|
|
|
|
*gen = *gen + 1;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
for (node = root; node; node = tree_node_get_next(node))
|
2008-10-15 02:43:02 +04:00
|
|
|
{
|
2008-11-26 01:43:23 +03:00
|
|
|
if((*gen > 0) && (*gen < 3))
|
2008-10-15 02:43:02 +04:00
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
// if(*item >= AMI_MENU_HOTLIST_MAX) return;
|
2008-10-15 02:43:02 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
if(!count)
|
2008-10-18 19:13:18 +04:00
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
if(*gen == 1) gwin->menu[*item].nm_Type = NM_ITEM;
|
|
|
|
if(*gen == 2) gwin->menu[*item].nm_Type = NM_SUB;
|
|
|
|
|
|
|
|
if(strcmp(tree_url_node_get_title(node),"--"))
|
|
|
|
{
|
|
|
|
gwin->menulab[*item] = ami_utf8_easy((char *)tree_url_node_get_title(node));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gwin->menulab[*item] = NM_BARLABEL;
|
|
|
|
}
|
2008-10-18 19:13:18 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menu[*item].nm_Label = gwin->menulab[*item];
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->menu_hook[*item].h_Entry = (HOOKFUNC)ami_menu_item_hotlist_entries;
|
|
|
|
gwin->menu_hook[*item].h_Data = (void *)tree_url_node_get_url(node);
|
|
|
|
gwin->menu[*item].nm_UserData = (HOOKFUNC)&gwin->menu_hook[*item];
|
2010-10-05 23:14:46 +04:00
|
|
|
if(tree_node_is_folder(node) && (!tree_node_get_child(node)))
|
|
|
|
gwin->menu[*item].nm_Flags = NM_ITEMDISABLED;
|
|
|
|
}
|
2008-10-15 02:43:02 +04:00
|
|
|
|
|
|
|
*item = *item + 1;
|
|
|
|
}
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
if (tree_node_get_child(node))
|
2008-10-15 02:43:02 +04:00
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
ami_menu_scan_2(tree,tree_node_get_child(node),gen,item,count,gwin);
|
2008-10-15 02:43:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*gen = *gen - 1;
|
|
|
|
}
|
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
void ami_menu_update_disabled(struct gui_window *g, hlcache_handle *c)
|
2008-09-04 02:02:41 +04:00
|
|
|
{
|
2012-04-29 19:59:37 +04:00
|
|
|
struct Window *win = g->shared->win;
|
|
|
|
|
|
|
|
if(nsoption_bool(kiosk_mode) == true) return;
|
|
|
|
|
|
|
|
OffMenu(win,AMI_MENU_CUT);
|
|
|
|
OffMenu(win,AMI_MENU_COPY);
|
|
|
|
OffMenu(win,AMI_MENU_PASTE);
|
|
|
|
OffMenu(win,AMI_MENU_CLEAR);
|
2008-10-05 03:29:17 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
if(content_get_type(c) <= CONTENT_CSS)
|
2008-09-04 02:02:41 +04:00
|
|
|
{
|
2012-04-29 19:59:37 +04:00
|
|
|
OnMenu(win,AMI_MENU_SAVEAS_TEXT);
|
|
|
|
OnMenu(win,AMI_MENU_SAVEAS_COMPLETE);
|
|
|
|
#ifdef WITH_PDF_EXPORT
|
|
|
|
OnMenu(win,AMI_MENU_SAVEAS_PDF);
|
|
|
|
#endif
|
|
|
|
if(browser_window_has_selection(g->shared->bw))
|
|
|
|
{
|
|
|
|
OnMenu(win,AMI_MENU_COPY);
|
|
|
|
OnMenu(win,AMI_MENU_CLEAR);
|
|
|
|
|
|
|
|
if(selection_read_only(browser_window_get_selection(g->shared->bw)) == false)
|
|
|
|
OnMenu(win,AMI_MENU_CUT);
|
|
|
|
}
|
|
|
|
if(g->c_h) OnMenu(win,AMI_MENU_PASTE);
|
|
|
|
OnMenu(win,AMI_MENU_SELECTALL);
|
|
|
|
OnMenu(win,AMI_MENU_FIND);
|
|
|
|
OffMenu(win,AMI_MENU_SAVEAS_IFF);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OffMenu(win,AMI_MENU_SAVEAS_TEXT);
|
|
|
|
OffMenu(win,AMI_MENU_SAVEAS_COMPLETE);
|
|
|
|
#ifdef WITH_PDF_EXPORT
|
|
|
|
OffMenu(win,AMI_MENU_SAVEAS_PDF);
|
|
|
|
#endif
|
|
|
|
OffMenu(win,AMI_MENU_PASTE);
|
|
|
|
OffMenu(win,AMI_MENU_SELECTALL);
|
|
|
|
OffMenu(win,AMI_MENU_CLEAR);
|
|
|
|
OffMenu(win,AMI_MENU_FIND);
|
|
|
|
|
|
|
|
#ifdef WITH_NS_SVG
|
|
|
|
if(content_get_bitmap(c) || (ami_mime_compare(c, "svg") == true))
|
|
|
|
#else
|
|
|
|
if(content_get_bitmap(c))
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
OnMenu(win,AMI_MENU_COPY);
|
|
|
|
OnMenu(win,AMI_MENU_SAVEAS_IFF);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OffMenu(win,AMI_MENU_COPY);
|
|
|
|
OffMenu(win,AMI_MENU_SAVEAS_IFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The below functions are called automatically by window.class when menu items are selected.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void ami_menu_item_project_newwin(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct browser_window *bw;
|
2008-09-04 02:02:41 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
bw = browser_window_create(nsoption_charp(homepage_url), NULL, 0, true, false);
|
|
|
|
}
|
2008-10-05 03:29:17 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_project_newtab(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct browser_window *bw;
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
2008-11-15 18:28:17 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
bw = browser_window_create(nsoption_charp(homepage_url), gwin->bw, 0, true, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_menu_item_project_open(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
|
|
|
|
|
|
|
ami_file_open(gwin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_menu_item_project_save(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
ULONG type = (ULONG)hook->h_Data;
|
|
|
|
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
|
|
|
|
|
|
|
ami_file_save_req(type, gwin, gwin->bw->current_content, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_menu_item_project_closetab(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
2008-09-04 02:02:41 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
browser_window_destroy(gwin->bw);
|
|
|
|
}
|
2008-10-05 17:17:18 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_project_closewin(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
2008-10-06 21:47:31 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
ami_close_all_tabs(gwin);
|
|
|
|
}
|
2009-08-23 19:59:41 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_project_print(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
2008-11-16 02:54:09 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
ami_update_pointer(gwin->win,GUI_POINTER_WAIT);
|
|
|
|
ami_print_ui(gwin->bw->current_content);
|
|
|
|
ami_update_pointer(gwin->win,GUI_POINTER_DEFAULT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_menu_item_project_about(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
char *temp, *temp2;
|
|
|
|
int sel;
|
|
|
|
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
|
|
|
|
|
|
|
ami_update_pointer(gwin->win,GUI_POINTER_WAIT);
|
|
|
|
|
|
|
|
temp = ASPrintf("%s|%s|%s", messages_get("OK"),
|
2011-03-16 22:23:24 +03:00
|
|
|
messages_get("HelpCredits"),
|
|
|
|
messages_get("HelpLicence"));
|
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
temp2 = ami_utf8_easy(temp);
|
|
|
|
FreeVec(temp);
|
2011-03-16 22:23:24 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
sel = TimedDosRequesterTags(TDR_ImageType,TDRIMAGE_INFO,
|
|
|
|
TDR_TitleString, messages_get("NetSurf"),
|
|
|
|
TDR_Window, gwin->win,
|
|
|
|
TDR_GadgetString, temp2,
|
2010-01-09 00:42:38 +03:00
|
|
|
#ifndef NDEBUG
|
2012-04-29 19:59:37 +04:00
|
|
|
TDR_FormatString,"NetSurf %s\n%s\n%s (%s)\n\nhttp://www.netsurf-browser.org",
|
2010-01-09 00:42:38 +03:00
|
|
|
#else
|
2012-04-29 19:59:37 +04:00
|
|
|
TDR_FormatString,"NetSurf %s\n%s\n\nhttp://www.netsurf-browser.org",
|
2010-01-09 00:42:38 +03:00
|
|
|
#endif
|
2012-04-29 19:59:37 +04:00
|
|
|
TDR_Arg1,netsurf_version,
|
2009-02-21 18:53:04 +03:00
|
|
|
#ifdef NS_AMIGA_CAIRO
|
2012-04-29 19:59:37 +04:00
|
|
|
TDR_Arg2,"Cairo (OS4.1+) SObjs build",
|
2009-02-21 18:53:04 +03:00
|
|
|
#else
|
2012-04-29 19:59:37 +04:00
|
|
|
TDR_Arg2,"graphics.library static build",
|
2009-02-21 18:53:04 +03:00
|
|
|
#endif
|
2012-04-29 19:59:37 +04:00
|
|
|
TDR_Arg3,versvn,
|
|
|
|
TDR_Arg4,verdate,
|
|
|
|
TAG_DONE);
|
2008-11-16 02:54:09 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
free(temp2);
|
2011-03-16 22:23:24 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
if(sel == 2)
|
|
|
|
browser_window_create("about:credits", NULL, 0, true, false);
|
|
|
|
else if(sel == 0)
|
|
|
|
browser_window_create("about:licence", NULL, 0, true, false);
|
2011-03-13 21:51:25 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
ami_update_pointer(gwin->win,GUI_POINTER_DEFAULT);
|
|
|
|
}
|
2008-11-15 18:28:17 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_project_quit(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
ami_quit_netsurf();
|
|
|
|
}
|
2008-09-04 02:02:41 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_edit_cut(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
2010-07-24 20:39:37 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
browser_window_key_press(gwin->bw, KEY_CUT_SELECTION);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_menu_item_edit_copy(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct bitmap *bm;
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
|
|
|
|
|
|
|
if(content_get_type(gwin->bw->current_content) <= CONTENT_CSS)
|
|
|
|
{
|
|
|
|
browser_window_key_press(gwin->bw, KEY_COPY_SELECTION);
|
|
|
|
browser_window_key_press(gwin->bw, KEY_CLEAR_SELECTION);
|
|
|
|
}
|
|
|
|
else if(bm = content_get_bitmap(gwin->bw->current_content))
|
|
|
|
{
|
|
|
|
bm->url = (char *)nsurl_access(hlcache_handle_get_url(gwin->bw->current_content));
|
|
|
|
bm->title = (char *)content_get_title(gwin->bw->current_content);
|
|
|
|
ami_easy_clipboard_bitmap(bm);
|
|
|
|
}
|
2009-05-19 11:23:56 +04:00
|
|
|
#ifdef WITH_NS_SVG
|
2012-04-29 19:59:37 +04:00
|
|
|
else if(ami_mime_compare(gwin->bw->current_content, "svg") == true)
|
|
|
|
{
|
|
|
|
ami_easy_clipboard_svg(gwin->bw->current_content);
|
|
|
|
}
|
2009-05-19 11:23:56 +04:00
|
|
|
#endif
|
2012-04-29 19:59:37 +04:00
|
|
|
}
|
2008-09-04 02:02:41 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_edit_paste(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
2008-09-04 02:02:41 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
browser_window_key_press(gwin->bw, KEY_PASTE);
|
|
|
|
}
|
2008-09-04 02:02:41 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_edit_selectall(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
2008-09-04 02:02:41 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
browser_window_key_press(gwin->bw, KEY_SELECT_ALL);
|
|
|
|
gui_start_selection(gwin->bw->window);
|
|
|
|
}
|
2008-12-14 02:23:24 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_edit_clearsel(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
2009-03-07 23:52:08 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
browser_window_key_press(gwin->bw, KEY_CLEAR_SELECTION);
|
|
|
|
}
|
2008-10-13 22:00:44 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_browser_find(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
2009-06-21 02:29:43 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
ami_search_open(gwin->bw->window);
|
|
|
|
}
|
2009-08-31 01:43:14 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_browser_localhistory(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
2008-10-13 22:00:44 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
if(gwin->bw && gwin->bw->history)
|
|
|
|
ami_history_open(gwin->bw, gwin->bw->history);
|
|
|
|
}
|
2011-03-24 22:34:59 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_browser_globalhistory(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
ami_tree_open(global_history_window,AMI_TREE_HISTORY);
|
|
|
|
}
|
2011-03-24 22:34:59 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_browser_cookies(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
ami_tree_open(cookies_window,AMI_TREE_COOKIES);
|
|
|
|
}
|
2008-09-04 02:02:41 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_browser_scale_decrease(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
2008-10-15 02:43:02 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
if(browser_window_get_scale(gwin->bw) > 0.1)
|
|
|
|
browser_window_set_scale(gwin->bw, browser_window_get_scale(gwin->bw) - 0.1, false);
|
|
|
|
}
|
2008-09-04 02:02:41 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_browser_scale_normal(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
2008-10-26 15:25:26 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
browser_window_set_scale(gwin->bw, 1.0, false);
|
|
|
|
}
|
2008-10-26 15:25:26 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_browser_scale_increase(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
|
|
|
|
|
|
|
browser_window_set_scale(gwin->bw, browser_window_get_scale(gwin->bw) + 0.1, false);
|
2008-09-04 02:02:41 +04:00
|
|
|
}
|
2008-12-14 02:23:24 +03:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_browser_redraw(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
2010-04-24 23:05:53 +04:00
|
|
|
{
|
2012-04-29 19:59:37 +04:00
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
2010-07-24 23:57:27 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
gwin->redraw_required = true;
|
|
|
|
gwin->new_content = true;
|
|
|
|
}
|
2010-09-28 22:03:03 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_hotlist_add(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct browser_window *bw;
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
2010-07-24 20:39:37 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
bw = gwin->bw;
|
|
|
|
|
|
|
|
if (bw == NULL || bw->current_content == NULL ||
|
|
|
|
nsurl_access(hlcache_handle_get_url(bw->current_content)) == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hotlist_add_page(nsurl_access(hlcache_handle_get_url(bw->current_content)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_menu_item_hotlist_show(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
ami_tree_open(hotlist_window, AMI_TREE_HOTLIST);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_menu_item_hotlist_entries(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
char *url = hook->h_Data;
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
|
|
|
|
|
|
|
if(url) browser_window_go(gwin->bw, url, NULL, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_menu_item_settings_edit(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
ami_gui_opts_open();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_menu_item_settings_snapshot(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
|
|
|
|
|
|
|
nsoption_set_int(window_x, gwin->win->LeftEdge);
|
|
|
|
nsoption_set_int(window_y, gwin->win->TopEdge);
|
|
|
|
nsoption_set_int(window_width, gwin->win->Width);
|
|
|
|
nsoption_set_int(window_height, gwin->win->Height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_menu_item_settings_save(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
nsoption_write(current_user_options);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_menu_item_arexx_execute(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
char *temp;
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
|
|
|
|
|
|
|
if(AslRequestTags(filereq,
|
|
|
|
ASLFR_TitleText, messages_get("NetSurf"),
|
|
|
|
ASLFR_Screen, scrn,
|
|
|
|
ASLFR_DoSaveMode, FALSE,
|
|
|
|
ASLFR_InitialDrawer, nsoption_charp(arexx_dir),
|
|
|
|
ASLFR_InitialPattern, "#?.nsrx",
|
|
|
|
TAG_DONE))
|
2010-04-24 23:05:53 +04:00
|
|
|
{
|
2012-04-29 19:59:37 +04:00
|
|
|
if(temp = AllocVec(1024,MEMF_PRIVATE | MEMF_CLEAR))
|
2010-07-24 23:57:27 +04:00
|
|
|
{
|
2012-04-29 19:59:37 +04:00
|
|
|
strlcpy(temp, filereq->fr_Drawer, 1024);
|
|
|
|
AddPart(temp, filereq->fr_File, 1024);
|
|
|
|
ami_arexx_execute(temp);
|
|
|
|
FreeVec(temp);
|
2010-07-24 23:57:27 +04:00
|
|
|
}
|
2010-04-24 23:05:53 +04:00
|
|
|
}
|
2012-04-29 19:59:37 +04:00
|
|
|
}
|
2010-04-24 23:05:53 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
static void ami_menu_item_arexx_entries(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
char *script = hook->h_Data;
|
|
|
|
char *temp;
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
|
|
|
|
|
|
|
if(script)
|
|
|
|
{
|
|
|
|
if(temp = AllocVec(1024, MEMF_PRIVATE | MEMF_CLEAR))
|
2010-04-24 23:05:53 +04:00
|
|
|
{
|
2012-04-29 19:59:37 +04:00
|
|
|
strcpy(temp, nsoption_charp(arexx_dir));
|
|
|
|
AddPart(temp, script, 1024);
|
|
|
|
ami_arexx_execute(temp);
|
|
|
|
FreeVec(temp);
|
2010-04-24 23:05:53 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|