2008-08-25 17:32:26 +04:00
|
|
|
/*
|
2013-05-19 13:09:40 +04:00
|
|
|
* Copyright 2008-9,2013 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>
|
2013-08-20 22:39:18 +04:00
|
|
|
#include <proto/glyph.h>
|
|
|
|
#include <images/glyph.h>
|
2011-02-24 02:15:12 +03:00
|
|
|
|
|
|
|
#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"
|
2013-05-26 01:46:27 +04:00
|
|
|
#include "utils/nsoption.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"
|
2014-03-08 18:13:27 +04:00
|
|
|
#include "amiga/schedule.h"
|
2013-09-03 01:41:04 +04:00
|
|
|
#include "desktop/hotlist.h"
|
2012-08-22 16:16:20 +04:00
|
|
|
#include "desktop/browser_private.h"
|
2010-07-24 23:57:27 +04:00
|
|
|
#include "desktop/gui.h"
|
|
|
|
#include "desktop/textinput.h"
|
|
|
|
#include "utils/messages.h"
|
2014-03-08 18:13:27 +04:00
|
|
|
|
2008-10-26 15:25:26 +03:00
|
|
|
|
2013-08-20 22:39:18 +04:00
|
|
|
enum {
|
|
|
|
NSA_GLYPH_SUBMENU,
|
|
|
|
NSA_GLYPH_AMIGAKEY,
|
|
|
|
NSA_GLYPH_CHECKMARK,
|
|
|
|
NSA_GLYPH_MX,
|
|
|
|
NSA_GLYPH_MAX
|
|
|
|
};
|
|
|
|
|
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 verdate;
|
2013-08-20 22:39:18 +04:00
|
|
|
Object *menu_glyph[NSA_GLYPH_MAX];
|
|
|
|
int menu_glyph_width[NSA_GLYPH_MAX];
|
|
|
|
bool menu_glyphs_loaded = false;
|
2008-08-25 17:32:26 +04:00
|
|
|
|
2013-09-05 23:24:01 +04:00
|
|
|
static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin);
|
2010-10-05 23:14:46 +04:00
|
|
|
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);
|
2013-10-01 21:51:27 +04:00
|
|
|
static void ami_menu_item_edit_undo(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_edit_redo(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
2012-04-29 19:59:37 +04:00
|
|
|
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);
|
2012-12-15 18:21:15 +04:00
|
|
|
static void ami_menu_item_browser_foreimg(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_browser_backimg(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
|
|
|
static void ami_menu_item_browser_enablejs(struct Hook *hook, APTR window, struct IntuiMessage *msg);
|
2012-04-29 19:59:37 +04:00
|
|
|
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)
|
|
|
|
{
|
2013-05-18 18:34:25 +04:00
|
|
|
DisposeObject(gwin->menuobj[i]);
|
2011-02-24 02:15:12 +03:00
|
|
|
}
|
2012-04-29 19:59:37 +04:00
|
|
|
|
2013-05-18 18:34:25 +04:00
|
|
|
ami_utf8_free(gwin->menulab[i]);
|
|
|
|
|
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;
|
2013-05-18 18:34:25 +04:00
|
|
|
gwin->menuobj[i] = NULL;
|
2010-10-05 23:14:46 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-05-18 18:34:25 +04:00
|
|
|
static void ami_menu_alloc_item(struct gui_window_2 *gwin, int num, UBYTE type,
|
2013-08-15 23:10:55 +04:00
|
|
|
const char *label, char key, char *icon, void *func, void *hookdata)
|
2013-05-18 18:34:25 +04:00
|
|
|
{
|
2013-08-18 18:15:12 +04:00
|
|
|
char menu_icon[1024];
|
2013-08-18 18:20:39 +04:00
|
|
|
|
2013-05-18 18:34:25 +04:00
|
|
|
gwin->menutype[num] = type;
|
2013-05-18 19:11:49 +04:00
|
|
|
|
2013-05-18 19:28:10 +04:00
|
|
|
if((label == NM_BARLABEL) || (strcmp(label, "--") == 0)) {
|
2013-05-18 18:34:25 +04:00
|
|
|
gwin->menulab[num] = NM_BARLABEL;
|
2013-05-18 19:28:10 +04:00
|
|
|
} else {
|
|
|
|
if((num >= AMI_MENU_HOTLIST) && (num <= AMI_MENU_HOTLIST_MAX)) {
|
|
|
|
gwin->menulab[num] = ami_utf8_easy(label);
|
|
|
|
} else if((num >= AMI_MENU_AREXX) && (num <= AMI_MENU_AREXX_MAX)) {
|
|
|
|
gwin->menulab[num] = strdup(label);
|
|
|
|
} else {
|
|
|
|
gwin->menulab[num] = ami_utf8_easy(messages_get(label));
|
|
|
|
}
|
|
|
|
}
|
2013-08-15 23:10:55 +04:00
|
|
|
|
2013-08-18 18:15:12 +04:00
|
|
|
gwin->menuicon[num] = NULL;
|
2013-05-18 18:34:25 +04:00
|
|
|
if(key) gwin->menukey[num] = key;
|
|
|
|
if(func) gwin->menu_hook[num].h_Entry = (HOOKFUNC)func;
|
|
|
|
if(hookdata) gwin->menu_hook[num].h_Data = hookdata;
|
2013-08-18 18:15:12 +04:00
|
|
|
|
|
|
|
if(icon) {
|
|
|
|
if(ami_locate_resource(menu_icon, icon) == true)
|
|
|
|
gwin->menuicon[num] = (char *)strdup(menu_icon);
|
|
|
|
}
|
2013-05-18 18:34:25 +04:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2013-10-12 16:43:33 +04:00
|
|
|
gwin->menutype = AllocVecTags(AMI_MENU_AREXX_MAX + 1, AVT_ClearWithValue, 0, TAG_DONE);
|
2010-10-05 23:14:46 +04:00
|
|
|
|
|
|
|
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;
|
2013-05-18 18:34:25 +04:00
|
|
|
gwin->menuobj[i] = NULL;
|
2008-08-25 17:32:26 +04:00
|
|
|
}
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2013-05-18 18:34:25 +04:00
|
|
|
ami_menu_alloc_item(gwin, M_PROJECT, NM_TITLE, "Project", 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_NEWWIN, NM_ITEM, "NewWindowNS", 'N', NULL,
|
|
|
|
ami_menu_item_project_newwin, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_NEWTAB, NM_ITEM, "NewTab", 'T', NULL,
|
|
|
|
ami_menu_item_project_newtab, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_OPEN, NM_ITEM, "OpenFile", 'O', NULL,
|
|
|
|
ami_menu_item_project_open, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_SAVEAS, NM_ITEM, "SaveAsNS", 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_SAVESRC, NM_SUB, "Source", 'S', NULL,
|
|
|
|
ami_menu_item_project_save, (void *)AMINS_SAVE_SOURCE);
|
|
|
|
ami_menu_alloc_item(gwin, M_SAVETXT, NM_SUB, "TextNS", 0, NULL,
|
|
|
|
ami_menu_item_project_save, (void *)AMINS_SAVE_TEXT);
|
|
|
|
ami_menu_alloc_item(gwin, M_SAVECOMP, NM_SUB, "SaveCompNS", 0, NULL,
|
|
|
|
ami_menu_item_project_save, (void *)AMINS_SAVE_COMPLETE);
|
2013-06-08 20:10:30 +04:00
|
|
|
#ifdef WITH_PDF_EXPORT
|
2013-05-18 18:34:25 +04:00
|
|
|
ami_menu_alloc_item(gwin, M_SAVEPDF, NM_SUB, "PDFNS", 0, NULL,
|
|
|
|
ami_menu_item_project_save, (void *)AMINS_SAVE_PDF);
|
2013-06-08 20:10:30 +04:00
|
|
|
#endif
|
2013-05-18 18:34:25 +04:00
|
|
|
ami_menu_alloc_item(gwin, M_SAVEIFF, NM_SUB, "IFF", 0, NULL,
|
|
|
|
ami_menu_item_project_save, (void *)AMINS_SAVE_IFF);
|
|
|
|
ami_menu_alloc_item(gwin, M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
2013-07-19 20:42:25 +04:00
|
|
|
ami_menu_alloc_item(gwin, M_PRINT, NM_ITEM, "PrintNS", 'P', NULL,
|
|
|
|
ami_menu_item_project_print, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_BAR_P3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
2013-05-18 18:34:25 +04:00
|
|
|
ami_menu_alloc_item(gwin, M_CLOSETAB, NM_ITEM, "CloseTab", 'K', NULL,
|
|
|
|
ami_menu_item_project_closetab, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_CLOSEWIN, NM_ITEM, "CloseWindow", 0, NULL,
|
|
|
|
ami_menu_item_project_closewin, NULL);
|
2013-07-19 20:42:25 +04:00
|
|
|
ami_menu_alloc_item(gwin, M_BAR_P4, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
2013-05-18 18:34:25 +04:00
|
|
|
ami_menu_alloc_item(gwin, M_ABOUT, NM_ITEM, "About", '?', NULL,
|
|
|
|
ami_menu_item_project_about, NULL);
|
2013-07-19 20:42:25 +04:00
|
|
|
ami_menu_alloc_item(gwin, M_BAR_P5, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
2013-05-18 18:34:25 +04:00
|
|
|
ami_menu_alloc_item(gwin, M_QUIT, NM_ITEM, "Quit", 'Q', NULL,
|
|
|
|
ami_menu_item_project_quit, NULL);
|
|
|
|
|
|
|
|
ami_menu_alloc_item(gwin, M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_CUT, NM_ITEM, "CutNS", 'X', NULL,
|
|
|
|
ami_menu_item_edit_cut, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_COPY, NM_ITEM, "CopyNS", 'C', NULL,
|
|
|
|
ami_menu_item_edit_copy, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_PASTE, NM_ITEM, "PasteNS", 'V', NULL,
|
|
|
|
ami_menu_item_edit_paste, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_SELALL, NM_ITEM, "SelectAllNS", 'A', NULL,
|
|
|
|
ami_menu_item_edit_selectall, NULL);
|
2013-10-01 21:51:27 +04:00
|
|
|
ami_menu_alloc_item(gwin, M_CLEAR, NM_ITEM, "ClearNS", 0, NULL,
|
2013-05-18 18:34:25 +04:00
|
|
|
ami_menu_item_edit_clearsel, NULL);
|
2013-10-01 21:51:27 +04:00
|
|
|
ami_menu_alloc_item(gwin, M_BAR_E2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_UNDO, NM_ITEM, "Undo", 'Z', NULL,
|
|
|
|
ami_menu_item_edit_undo, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_REDO, NM_ITEM, "Redo", 'Y', NULL,
|
|
|
|
ami_menu_item_edit_redo, NULL);
|
2013-05-18 18:34:25 +04:00
|
|
|
|
|
|
|
ami_menu_alloc_item(gwin, M_BROWSER, NM_TITLE, "Browser", 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_FIND, NM_ITEM, "FindTextNS", 'F', NULL,
|
|
|
|
ami_menu_item_browser_find, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_BAR_B1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_HISTLOCL, NM_ITEM, "HistLocalNS", 0, NULL,
|
|
|
|
ami_menu_item_browser_localhistory, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_HISTGLBL, NM_ITEM, "HistGlobalNS", 0, NULL,
|
|
|
|
ami_menu_item_browser_globalhistory, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_BAR_B2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
2013-07-27 17:13:03 +04:00
|
|
|
ami_menu_alloc_item(gwin, M_COOKIES, NM_ITEM, "ShowCookiesNS", 0, NULL,
|
2013-05-18 18:34:25 +04:00
|
|
|
ami_menu_item_browser_cookies, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_BAR_B3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_SCALE, NM_ITEM, "ScaleNS", 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_SCALEDEC, NM_SUB, "ScaleDec", '-', NULL,
|
|
|
|
ami_menu_item_browser_scale_decrease, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_SCALENRM, NM_SUB, "ScaleNorm", '=', NULL,
|
|
|
|
ami_menu_item_browser_scale_normal, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_SCALEDEC, NM_SUB, "ScaleDec", '-', NULL,
|
|
|
|
ami_menu_item_browser_scale_decrease, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_SCALEINC, NM_SUB, "ScaleInc", '+', NULL,
|
|
|
|
ami_menu_item_browser_scale_increase, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_IMAGES, NM_ITEM, "Images", 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_IMGFORE, NM_SUB, "ForeImg", 0, NULL,
|
|
|
|
ami_menu_item_browser_foreimg, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_IMGBACK, NM_SUB, "BackImg", 0, NULL,
|
|
|
|
ami_menu_item_browser_backimg, NULL);
|
|
|
|
#if defined(WITH_JS) || defined(WITH_MOZJS)
|
|
|
|
ami_menu_alloc_item(gwin, M_JS, NM_ITEM, "EnableJS", 0, NULL,
|
|
|
|
ami_menu_item_browser_enablejs, NULL);
|
|
|
|
#endif
|
|
|
|
ami_menu_alloc_item(gwin, M_BAR_B4, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_REDRAW, NM_ITEM, "Redraw", 0, NULL,
|
|
|
|
ami_menu_item_browser_redraw, NULL);
|
|
|
|
|
|
|
|
ami_menu_alloc_item(gwin, M_HOTLIST, NM_TITLE, "Hotlist", 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_HLADD, NM_ITEM, "HotlistAdd", 'B', NULL,
|
|
|
|
ami_menu_item_hotlist_add, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_HLSHOW, NM_ITEM,"HotlistShowNS",'H', NULL,
|
|
|
|
ami_menu_item_hotlist_show, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_BAR_H1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
ami_menu_alloc_item(gwin, M_PREFS, NM_TITLE, "Settings", 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_PREDIT, NM_ITEM, "SettingsEdit", 0, NULL,
|
|
|
|
ami_menu_item_settings_edit, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_BAR_S1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_SNAPSHOT, NM_ITEM, "SnapshotWindow",0, NULL,
|
|
|
|
ami_menu_item_settings_snapshot, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_PRSAVE, NM_ITEM, "SettingsSave", 0, NULL,
|
|
|
|
ami_menu_item_settings_save, NULL);
|
|
|
|
|
|
|
|
ami_menu_alloc_item(gwin, M_AREXX, NM_TITLE, "ARexx", 0, NULL, NULL, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_AREXXEX, NM_ITEM, "ARexxExecute",'E', NULL,
|
|
|
|
ami_menu_item_arexx_execute, NULL);
|
|
|
|
ami_menu_alloc_item(gwin, M_BAR_A1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
2010-10-05 23:14:46 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-08-20 22:39:18 +04:00
|
|
|
static void ami_menu_load_glyphs(struct DrawInfo *dri)
|
|
|
|
{
|
2013-09-28 19:03:24 +04:00
|
|
|
for(int i = 0; i < NSA_GLYPH_MAX; i++)
|
|
|
|
menu_glyph[i] = NULL;
|
2013-09-28 18:37:09 +04:00
|
|
|
|
2013-08-20 22:39:18 +04:00
|
|
|
menu_glyph[NSA_GLYPH_SUBMENU] = NewObject(NULL, "sysiclass",
|
|
|
|
SYSIA_Which, MENUSUB,
|
|
|
|
SYSIA_DrawInfo, dri,
|
|
|
|
TAG_DONE);
|
|
|
|
menu_glyph[NSA_GLYPH_AMIGAKEY] = NewObject(NULL, "sysiclass",
|
|
|
|
SYSIA_Which, AMIGAKEY,
|
|
|
|
SYSIA_DrawInfo, dri,
|
|
|
|
TAG_DONE);
|
|
|
|
GetAttr(IA_Width, menu_glyph[NSA_GLYPH_SUBMENU],
|
|
|
|
(ULONG *)&menu_glyph_width[NSA_GLYPH_SUBMENU]);
|
|
|
|
GetAttr(IA_Width, menu_glyph[NSA_GLYPH_AMIGAKEY],
|
|
|
|
(ULONG *)&menu_glyph_width[NSA_GLYPH_AMIGAKEY]);
|
|
|
|
|
|
|
|
menu_glyphs_loaded = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ami_menu_free_glyphs(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
if(menu_glyphs_loaded == false) return;
|
|
|
|
|
2013-09-28 19:03:24 +04:00
|
|
|
for(i = 0; i < NSA_GLYPH_MAX; i++) {
|
2013-09-28 18:37:09 +04:00
|
|
|
if(menu_glyph[i]) DisposeObject(menu_glyph[i]);
|
2013-08-20 22:39:18 +04:00
|
|
|
menu_glyph[i] = NULL;
|
|
|
|
};
|
|
|
|
|
|
|
|
menu_glyphs_loaded = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
|
2008-08-25 17:32:26 +04:00
|
|
|
{
|
2013-08-18 18:15:12 +04:00
|
|
|
int i, j;
|
|
|
|
int txtlen = 0;
|
|
|
|
struct RastPort *rp = &scrn->RastPort;
|
|
|
|
struct DrawInfo *dri = GetScreenDrawInfo(scrn);
|
2013-08-20 22:39:18 +04:00
|
|
|
|
|
|
|
if(menu_glyphs_loaded == false)
|
|
|
|
ami_menu_load_glyphs(dri);
|
2008-08-25 17:32:26 +04:00
|
|
|
|
2013-08-18 18:15:12 +04:00
|
|
|
for(i=0; i <= AMI_MENU_AREXX_MAX; i++)
|
2008-08-25 17:32:26 +04:00
|
|
|
{
|
2013-08-18 18:15:12 +04:00
|
|
|
if(gwin->menutype[i] == NM_TITLE) {
|
|
|
|
j = i + 1;
|
|
|
|
txtlen = 0;
|
2013-08-20 22:39:18 +04:00
|
|
|
int item_size = 0;
|
2013-08-18 18:15:12 +04:00
|
|
|
do {
|
|
|
|
if(gwin->menulab[j] != NM_BARLABEL) {
|
|
|
|
if(gwin->menutype[j] == NM_ITEM) {
|
2013-08-20 22:39:18 +04:00
|
|
|
item_size = TextLength(rp, gwin->menulab[j], strlen(gwin->menulab[j]));
|
|
|
|
if(gwin->menukey[j]) {
|
|
|
|
item_size += TextLength(rp, &gwin->menukey[j], 1);
|
|
|
|
item_size += menu_glyph_width[NSA_GLYPH_AMIGAKEY];
|
|
|
|
/**TODO: take account of the size of other imagery too
|
2013-08-18 18:15:12 +04:00
|
|
|
*/
|
|
|
|
}
|
2013-08-20 22:39:18 +04:00
|
|
|
|
|
|
|
if(item_size > txtlen) {
|
|
|
|
txtlen = item_size;
|
|
|
|
}
|
2013-08-18 18:15:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
j++;
|
|
|
|
} while((gwin->menutype[j] != NM_TITLE) && (gwin->menutype[j] != 0));
|
|
|
|
}
|
|
|
|
|
2013-10-13 14:52:11 +04:00
|
|
|
if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 6)) {
|
2013-08-18 18:15:12 +04:00
|
|
|
/* GadTools 53.6+ only. For now we will only create the menu
|
|
|
|
using label.image if there's a bitmap associated with the item. */
|
|
|
|
if((gwin->menuicon[i] != NULL) && (gwin->menulab[i] != NM_BARLABEL)) {
|
2013-08-20 22:39:18 +04:00
|
|
|
int icon_width = 0;
|
2013-08-18 18:15:12 +04:00
|
|
|
Object *submenuarrow = NULL;
|
2013-08-20 22:39:18 +04:00
|
|
|
Object *icon = BitMapObject,
|
|
|
|
BITMAP_Screen, scrn,
|
|
|
|
BITMAP_SourceFile, gwin->menuicon[i],
|
|
|
|
BITMAP_Masking, TRUE,
|
|
|
|
BitMapEnd;
|
2014-06-30 01:35:52 +04:00
|
|
|
|
|
|
|
/* \todo make this scale the bitmap to these dimensions */
|
|
|
|
SetAttrs(icon,
|
|
|
|
BITMAP_Width, 16,
|
|
|
|
BITMAP_Height, 16,
|
|
|
|
TAG_DONE);
|
|
|
|
|
2013-08-20 22:39:18 +04:00
|
|
|
GetAttr(IA_Width, icon, (ULONG *)&icon_width);
|
|
|
|
|
2013-08-18 18:15:12 +04:00
|
|
|
if((gwin->menutype[i] == NM_ITEM) && (gwin->menutype[i+1] == NM_SUB)) {
|
|
|
|
submenuarrow = NewObject(NULL, "sysiclass",
|
2013-08-20 22:39:18 +04:00
|
|
|
SYSIA_Which, MENUSUB,
|
|
|
|
SYSIA_DrawInfo, dri,
|
|
|
|
IA_Left, txtlen - TextLength(rp, gwin->menulab[i], strlen(gwin->menulab[i])) -
|
|
|
|
menu_glyph_width[NSA_GLYPH_SUBMENU] - icon_width,
|
|
|
|
TAG_DONE);
|
2013-08-18 18:15:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**TODO: Checkmark/MX images and keyboard shortcuts
|
|
|
|
*/
|
|
|
|
|
|
|
|
gwin->menuobj[i] = LabelObject,
|
|
|
|
LABEL_DrawInfo, dri,
|
|
|
|
LABEL_DisposeImage, TRUE,
|
2013-08-20 22:39:18 +04:00
|
|
|
LABEL_Image, icon,
|
2013-08-18 18:15:12 +04:00
|
|
|
LABEL_Text, gwin->menulab[i],
|
|
|
|
LABEL_DisposeImage, TRUE,
|
|
|
|
LABEL_Image, submenuarrow,
|
|
|
|
LabelEnd;
|
|
|
|
|
|
|
|
if(gwin->menuobj[i]) gwin->menutype[i] |= MENU_IMAGE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
gwin->menu[i].nm_Type = gwin->menutype[i];
|
2013-08-18 18:15:12 +04:00
|
|
|
|
2013-05-18 19:11:49 +04:00
|
|
|
if(gwin->menuobj[i])
|
2013-05-18 19:28:10 +04:00
|
|
|
gwin->menu[i].nm_Label = (void *)gwin->menuobj[i];
|
2013-05-18 19:11:49 +04:00
|
|
|
else
|
|
|
|
gwin->menu[i].nm_Label = gwin->menulab[i];
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
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];
|
2013-08-18 18:15:12 +04:00
|
|
|
|
|
|
|
if(gwin->menuicon[i]) {
|
|
|
|
free(gwin->menuicon[i]);
|
|
|
|
gwin->menuicon[i] = NULL;
|
|
|
|
}
|
2008-08-25 17:32:26 +04:00
|
|
|
}
|
2013-08-18 18:15:12 +04:00
|
|
|
|
|
|
|
FreeScreenDrawInfo(scrn, dri);
|
|
|
|
|
|
|
|
return gwin;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct NewMenu *ami_create_menu(struct gui_window_2 *gwin)
|
|
|
|
{
|
2013-10-12 16:43:33 +04:00
|
|
|
gwin->menu = AllocVecTags(sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1),
|
|
|
|
AVT_ClearWithValue, 0, TAG_DONE);
|
2013-08-18 18:15:12 +04:00
|
|
|
ami_init_menulabs(gwin);
|
|
|
|
ami_menu_scan(ami_tree_get_tree(hotlist_window), gwin);
|
|
|
|
ami_menu_arexx_scan(gwin);
|
|
|
|
gwin = ami_menu_layout(gwin);
|
2008-08-25 17:32:26 +04:00
|
|
|
|
2013-05-18 18:34:25 +04:00
|
|
|
#if defined(WITH_JS) || defined(WITH_MOZJS)
|
|
|
|
gwin->menu[M_JS].nm_Flags = CHECKIT | MENUTOGGLE;
|
2012-12-15 18:21:15 +04:00
|
|
|
if(nsoption_bool(enable_javascript) == true)
|
2013-05-18 18:34:25 +04:00
|
|
|
gwin->menu[M_JS].nm_Flags |= CHECKED;
|
2012-12-15 18:21:15 +04:00
|
|
|
#endif
|
2008-08-25 17:32:26 +04:00
|
|
|
|
2013-05-18 18:34:25 +04:00
|
|
|
gwin->menu[M_PRINT].nm_Flags = NM_ITEMDISABLED;
|
2012-02-28 22:51:26 +04:00
|
|
|
|
2013-05-18 18:34:25 +04:00
|
|
|
gwin->menu[M_IMGFORE].nm_Flags = CHECKIT | MENUTOGGLE;
|
2012-12-15 18:21:15 +04:00
|
|
|
if(nsoption_bool(foreground_images) == true)
|
2013-05-18 18:34:25 +04:00
|
|
|
gwin->menu[M_IMGFORE].nm_Flags |= CHECKED;
|
|
|
|
gwin->menu[M_IMGBACK].nm_Flags = CHECKIT | MENUTOGGLE;
|
2012-12-15 18:21:15 +04:00
|
|
|
if(nsoption_bool(background_images) == true)
|
2013-05-18 18:34:25 +04:00
|
|
|
gwin->menu[M_IMGBACK].nm_Flags |= CHECKED;
|
2012-12-15 18:21:15 +04:00
|
|
|
|
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;
|
2013-05-18 19:28:10 +04:00
|
|
|
char *menu_lab;
|
2013-11-10 16:49:46 +04:00
|
|
|
|
|
|
|
if(lock = Lock(nsoption_charp(arexx_dir), SHARED_LOCK))
|
2008-10-26 15:25:26 +03:00
|
|
|
{
|
2013-10-12 16:11:13 +04:00
|
|
|
if(buffer = AllocVecTagList(1024, NULL))
|
2008-10-26 15:25:26 +03:00
|
|
|
{
|
|
|
|
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')
|
2013-05-18 19:28:10 +04:00
|
|
|
menu_lab = ead->ed_Comment;
|
2008-10-26 15:25:26 +03:00
|
|
|
else
|
2013-05-18 19:28:10 +04:00
|
|
|
menu_lab = ead->ed_Name;
|
|
|
|
|
|
|
|
ami_menu_alloc_item(gwin, item, NM_ITEM, menu_lab, 0, NULL,
|
|
|
|
ami_menu_item_arexx_entries, (void *)strdup(ead->ed_Name));
|
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
|
|
|
}
|
|
|
|
|
2013-09-12 15:15:00 +04:00
|
|
|
static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char *title, nsurl *url, bool is_folder)
|
2013-09-05 23:24:01 +04:00
|
|
|
{
|
|
|
|
UBYTE type;
|
2014-06-30 01:35:52 +04:00
|
|
|
STRPTR icon;
|
2013-09-12 15:15:00 +04:00
|
|
|
struct gui_window_2 *gw = (struct gui_window_2 *)userdata;
|
2013-09-05 23:24:01 +04:00
|
|
|
|
2013-09-12 15:08:50 +04:00
|
|
|
if(item >= AMI_MENU_HOTLIST_MAX) return false;
|
2013-09-05 23:24:01 +04:00
|
|
|
|
2013-09-12 15:08:50 +04:00
|
|
|
switch(level) {
|
2013-09-05 23:24:01 +04:00
|
|
|
case 1:
|
|
|
|
type = NM_ITEM;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
type = NM_SUB;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* entries not at level 1 or 2 are not able to be added */
|
2013-09-12 15:08:50 +04:00
|
|
|
return false;
|
2013-09-05 23:24:01 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(is_folder == true) {
|
2014-06-30 01:35:52 +04:00
|
|
|
icon = ASPrintf("icons/directory.png");
|
2013-09-05 23:24:01 +04:00
|
|
|
} else {
|
2014-06-30 01:35:52 +04:00
|
|
|
icon = ami_gui_get_cache_favicon_name(url, true);
|
|
|
|
if (icon == NULL) icon = ASPrintf("icons/content.png");
|
2013-09-05 23:24:01 +04:00
|
|
|
}
|
|
|
|
|
2013-09-12 15:08:50 +04:00
|
|
|
ami_menu_alloc_item(gw, item, type, title,
|
2013-09-05 23:24:01 +04:00
|
|
|
0, icon, ami_menu_item_hotlist_entries, (void *)url);
|
|
|
|
if((is_folder == true) && (type == NM_SUB))
|
2013-09-12 15:08:50 +04:00
|
|
|
gw->menu[item].nm_Flags = NM_ITEMDISABLED;
|
2013-09-05 23:24:01 +04:00
|
|
|
|
2014-06-30 01:35:52 +04:00
|
|
|
if(icon) FreeVec(icon);
|
|
|
|
|
2013-09-12 15:08:50 +04:00
|
|
|
return true;
|
2013-09-05 23:24:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
|
|
|
|
{
|
2013-09-12 15:15:00 +04:00
|
|
|
return ami_hotlist_scan((void *)gwin, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
|
2008-10-15 02:43:02 +04:00
|
|
|
}
|
|
|
|
|
2012-12-15 19:30:26 +04:00
|
|
|
void ami_menu_update_checked(struct gui_window_2 *gwin)
|
|
|
|
{
|
|
|
|
struct Menu *menustrip;
|
|
|
|
|
|
|
|
GetAttr(WINDOW_MenuStrip, gwin->objects[OID_MAIN], (ULONG *)&menustrip);
|
|
|
|
if(!menustrip) return;
|
2013-06-08 20:10:30 +04:00
|
|
|
#if defined(WITH_JS) || defined(WITH_MOZJS)
|
2012-12-15 19:30:26 +04:00
|
|
|
if(nsoption_bool(enable_javascript) == true) {
|
|
|
|
if((ItemAddress(menustrip, AMI_MENU_JS)->Flags & CHECKED) == 0)
|
|
|
|
ItemAddress(menustrip, AMI_MENU_JS)->Flags ^= CHECKED;
|
|
|
|
} else {
|
|
|
|
if(ItemAddress(menustrip, AMI_MENU_JS)->Flags & CHECKED)
|
|
|
|
ItemAddress(menustrip, AMI_MENU_JS)->Flags ^= CHECKED;
|
|
|
|
}
|
2013-06-08 20:10:30 +04:00
|
|
|
#endif
|
2012-12-15 19:30:26 +04:00
|
|
|
if(nsoption_bool(foreground_images) == true) {
|
|
|
|
if((ItemAddress(menustrip, AMI_MENU_FOREIMG)->Flags & CHECKED) == 0)
|
|
|
|
ItemAddress(menustrip, AMI_MENU_FOREIMG)->Flags ^= CHECKED;
|
|
|
|
} else {
|
|
|
|
if(ItemAddress(menustrip, AMI_MENU_FOREIMG)->Flags & CHECKED)
|
|
|
|
ItemAddress(menustrip, AMI_MENU_FOREIMG)->Flags ^= CHECKED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nsoption_bool(background_images) == true) {
|
|
|
|
if((ItemAddress(menustrip, AMI_MENU_BACKIMG)->Flags & CHECKED) == 0)
|
|
|
|
ItemAddress(menustrip, AMI_MENU_BACKIMG)->Flags ^= CHECKED;
|
|
|
|
} else {
|
|
|
|
if(ItemAddress(menustrip, AMI_MENU_BACKIMG)->Flags & CHECKED)
|
|
|
|
ItemAddress(menustrip, AMI_MENU_BACKIMG)->Flags ^= CHECKED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ResetMenuStrip(gwin->win, menustrip);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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
|
2013-02-22 18:08:24 +04:00
|
|
|
if(browser_window_get_editor_flags(g->shared->bw) & BW_EDITOR_CAN_COPY)
|
2012-04-29 19:59:37 +04:00
|
|
|
{
|
|
|
|
OnMenu(win,AMI_MENU_COPY);
|
|
|
|
OnMenu(win,AMI_MENU_CLEAR);
|
2013-05-12 23:33:06 +04:00
|
|
|
} else {
|
|
|
|
OffMenu(win,AMI_MENU_COPY);
|
|
|
|
OffMenu(win,AMI_MENU_CLEAR);
|
2012-04-29 19:59:37 +04:00
|
|
|
}
|
2013-05-12 22:56:37 +04:00
|
|
|
|
|
|
|
if(browser_window_get_editor_flags(g->shared->bw) & BW_EDITOR_CAN_CUT)
|
|
|
|
OnMenu(win,AMI_MENU_CUT);
|
2013-05-12 23:33:06 +04:00
|
|
|
else
|
|
|
|
OffMenu(win,AMI_MENU_CUT);
|
2013-05-12 22:56:37 +04:00
|
|
|
|
|
|
|
if(browser_window_get_editor_flags(g->shared->bw) & BW_EDITOR_CAN_PASTE)
|
|
|
|
OnMenu(win,AMI_MENU_PASTE);
|
2013-05-12 23:33:06 +04:00
|
|
|
else
|
|
|
|
OffMenu(win,AMI_MENU_PASTE);
|
2013-05-12 22:56:37 +04:00
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
OnMenu(win,AMI_MENU_SELECTALL);
|
|
|
|
OnMenu(win,AMI_MENU_FIND);
|
|
|
|
OffMenu(win,AMI_MENU_SAVEAS_IFF);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-12 23:33:06 +04:00
|
|
|
OffMenu(win,AMI_MENU_CUT);
|
|
|
|
OffMenu(win,AMI_MENU_PASTE);
|
|
|
|
OffMenu(win,AMI_MENU_CLEAR);
|
|
|
|
|
2012-04-29 19:59:37 +04:00
|
|
|
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_SELECTALL);
|
|
|
|
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
|
|
|
|
{
|
2013-05-12 23:33:06 +04:00
|
|
|
OffMenu(win,AMI_MENU_COPY);
|
2012-04-29 19:59:37 +04:00
|
|
|
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)
|
|
|
|
{
|
2013-02-14 22:21:11 +04:00
|
|
|
nsurl *url;
|
|
|
|
nserror error;
|
|
|
|
|
|
|
|
error = nsurl_create(nsoption_charp(homepage_url), &url);
|
|
|
|
if (error == NSERROR_OK) {
|
2014-02-10 18:08:45 +04:00
|
|
|
error = browser_window_create(BW_CREATE_HISTORY,
|
2013-02-14 22:21:11 +04:00
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
warn_user(messages_get_errorcode(error), 0);
|
|
|
|
}
|
2012-04-29 19:59:37 +04:00
|
|
|
}
|
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 gui_window_2 *gwin;
|
2013-02-14 22:21:11 +04:00
|
|
|
nserror error;
|
2008-11-15 18:28:17 +03:00
|
|
|
|
2014-01-03 22:17:25 +04:00
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
|
|
|
error = ami_gui_new_blank_tab(gwin);
|
2012-04-29 19:59:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2013-02-22 23:02:58 +04:00
|
|
|
ami_file_save_req(type, gwin, gwin->bw->current_content);
|
2012-04-29 19:59:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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-11-01 00:50:22 +04:00
|
|
|
ami_menu_window_close = gwin;
|
2012-04-29 19:59:37 +04:00
|
|
|
}
|
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
|
|
|
|
2013-01-06 04:21:15 +04:00
|
|
|
ami_set_pointer(gwin, GUI_POINTER_WAIT, false);
|
2012-04-29 19:59:37 +04:00
|
|
|
ami_print_ui(gwin->bw->current_content);
|
2013-01-06 04:21:15 +04:00
|
|
|
ami_reset_pointer(gwin);
|
2012-04-29 19:59:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2013-02-18 22:39:31 +04:00
|
|
|
nsurl *url = NULL;
|
2013-02-14 22:21:11 +04:00
|
|
|
nserror error;
|
2012-04-29 19:59:37 +04:00
|
|
|
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
|
|
|
|
2013-01-06 04:21:15 +04:00
|
|
|
ami_set_pointer(gwin, GUI_POINTER_WAIT, false);
|
2012-04-29 19:59:37 +04:00
|
|
|
|
|
|
|
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,
|
2014-05-03 19:38:58 +04:00
|
|
|
TDR_FormatString,"NetSurf %s\nBuild date %s\n\nhttp://www.netsurf-browser.org",
|
2012-04-29 19:59:37 +04:00
|
|
|
TDR_Arg1,netsurf_version,
|
2014-05-03 19:38:58 +04:00
|
|
|
TDR_Arg2,verdate,
|
2012-04-29 19:59:37 +04:00
|
|
|
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
|
|
|
|
2013-02-14 22:21:11 +04:00
|
|
|
if(sel == 2) {
|
|
|
|
error = nsurl_create("about:credits", &url);
|
|
|
|
} else if(sel == 0) {
|
|
|
|
error = nsurl_create("about:licence", &url);
|
|
|
|
}
|
|
|
|
|
2013-02-18 22:39:31 +04:00
|
|
|
if(url) {
|
|
|
|
if (error == NSERROR_OK) {
|
2014-02-10 18:08:45 +04:00
|
|
|
error = browser_window_create(BW_CREATE_HISTORY,
|
2013-02-18 22:39:31 +04:00
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
warn_user(messages_get_errorcode(error), 0);
|
|
|
|
}
|
2013-02-14 22:21:11 +04:00
|
|
|
}
|
2011-03-13 21:51:25 +03:00
|
|
|
|
2013-01-06 04:21:15 +04:00
|
|
|
ami_reset_pointer(gwin);
|
2012-04-29 19:59:37 +04:00
|
|
|
}
|
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)
|
|
|
|
{
|
2012-11-01 00:50:22 +04:00
|
|
|
ami_menu_window_close = AMI_MENU_WINDOW_CLOSE_ALL;
|
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_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
|
|
|
|
2013-10-01 21:51:27 +04:00
|
|
|
static void ami_menu_item_edit_undo(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
|
|
|
|
|
|
|
browser_window_key_press(gwin->bw, KEY_UNDO);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_menu_item_edit_redo(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
|
|
|
|
|
|
|
browser_window_key_press(gwin->bw, KEY_REDO);
|
|
|
|
}
|
|
|
|
|
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-12-15 18:21:15 +04:00
|
|
|
static void ami_menu_item_browser_foreimg(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
2012-12-15 18:39:01 +04:00
|
|
|
struct Menu *menustrip;
|
|
|
|
bool checked = false;
|
|
|
|
|
|
|
|
GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
|
|
|
|
if(ItemAddress(menustrip, msg->Code)->Flags & CHECKED) checked = true;
|
|
|
|
|
|
|
|
nsoption_set_bool(foreground_images, checked);
|
2012-12-15 19:39:09 +04:00
|
|
|
ami_menu_check_toggled = true;
|
2012-12-15 18:21:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_menu_item_browser_backimg(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
2012-12-15 18:39:01 +04:00
|
|
|
struct Menu *menustrip;
|
|
|
|
bool checked = false;
|
|
|
|
|
|
|
|
GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
|
|
|
|
if(ItemAddress(menustrip, msg->Code)->Flags & CHECKED) checked = true;
|
|
|
|
|
|
|
|
nsoption_set_bool(background_images, checked);
|
2012-12-15 19:39:09 +04:00
|
|
|
ami_menu_check_toggled = true;
|
2012-12-15 18:21:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ami_menu_item_browser_enablejs(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
|
|
|
{
|
2012-12-15 18:39:01 +04:00
|
|
|
struct Menu *menustrip;
|
|
|
|
bool checked = false;
|
|
|
|
|
|
|
|
GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
|
|
|
|
if(ItemAddress(menustrip, msg->Code)->Flags & CHECKED) checked = true;
|
|
|
|
|
|
|
|
nsoption_set_bool(enable_javascript, checked);
|
2012-12-15 19:39:09 +04:00
|
|
|
ami_menu_check_toggled = true;
|
2012-12-15 18:21:15 +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
|
|
|
|
2013-04-04 22:46:33 +04:00
|
|
|
ami_schedule_redraw(gwin, true);
|
2012-04-29 19:59:37 +04:00
|
|
|
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;
|
|
|
|
|
2013-09-03 01:41:04 +04:00
|
|
|
hotlist_add_url(hlcache_handle_get_url(bw->current_content));
|
2013-11-23 16:23:56 +04:00
|
|
|
ami_gui_update_hotlist_button(gwin);
|
2012-04-29 19:59:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2013-09-05 23:26:28 +04:00
|
|
|
nsurl *url = hook->h_Data;
|
2012-04-29 19:59:37 +04:00
|
|
|
struct gui_window_2 *gwin;
|
|
|
|
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
|
|
|
|
2013-09-05 23:26:28 +04:00
|
|
|
if(url == NULL) return;
|
2013-02-14 19:09:28 +04:00
|
|
|
|
2013-09-05 23:26:28 +04:00
|
|
|
browser_window_navigate(gwin->bw,
|
2013-02-14 19:09:28 +04:00
|
|
|
url,
|
|
|
|
NULL,
|
2014-02-11 02:40:04 +04:00
|
|
|
BW_NAVIGATE_HISTORY,
|
2013-02-14 19:09:28 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2012-04-29 19:59:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2013-05-28 19:44:46 +04:00
|
|
|
nsoption_write(current_user_options, NULL, NULL);
|
2012-04-29 19:59:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2013-05-25 16:59:42 +04:00
|
|
|
ASLFR_Window, gwin->win,
|
|
|
|
ASLFR_SleepWindow, TRUE,
|
2012-04-29 19:59:37 +04:00
|
|
|
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
|
|
|
{
|
2013-10-12 16:11:13 +04:00
|
|
|
if(temp = AllocVecTagList(1024, NULL))
|
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)
|
|
|
|
{
|
2013-10-12 16:11:13 +04:00
|
|
|
if(temp = AllocVecTagList(1024, NULL))
|
2010-04-24 23:05:53 +04:00
|
|
|
{
|
2014-04-06 02:34:51 +04:00
|
|
|
BPTR lock;
|
2013-11-10 16:49:46 +04:00
|
|
|
if(lock = Lock(nsoption_charp(arexx_dir), SHARED_LOCK)) {
|
|
|
|
DevNameFromLock(lock, temp, 1024, DN_FULLPATH);
|
|
|
|
AddPart(temp, script, 1024);
|
|
|
|
ami_arexx_execute(temp);
|
|
|
|
FreeVec(temp);
|
|
|
|
UnLock(lock);
|
|
|
|
}
|
2010-04-24 23:05:53 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 02:34:51 +04:00
|
|
|
|