26#include <proto/exec.h>
27#include <proto/gadtools.h>
28#include <proto/intuition.h>
29#include <proto/utility.h>
31#include <dos/anchorpath.h>
32#include <dos/obsolete.h>
35#include <libraries/gadtools.h>
37#include <intuition/menuclass.h>
40#include <classes/window.h>
41#include <proto/label.h>
42#include <images/label.h>
43#include <proto/bitmap.h>
44#include <images/bitmap.h>
46#include <reaction/reaction_macros.h>
84static struct Menu *restrict gui_menu = NULL;
85static int gui_menu_count = 0;
102HOOKF(
void, ami_menu_item_project_newwin, APTR, window,
struct IntuiMessage *)
121HOOKF(
void, ami_menu_item_project_newtab, APTR, window,
struct IntuiMessage *)
125 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
129HOOKF(
void, ami_menu_item_project_open, APTR, window,
struct IntuiMessage *)
132 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
137HOOKF(
void, ami_menu_item_project_save, APTR, window,
struct IntuiMessage *)
140 ULONG
type = (ULONG)hook->h_Data;
142 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
147HOOKF(
void, ami_menu_item_project_closetab, APTR, window,
struct IntuiMessage *)
150 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
155HOOKF(
void, ami_menu_item_project_closewin, APTR, window,
struct IntuiMessage *)
158 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
163HOOKF(
void, ami_menu_item_project_print, APTR, window,
struct IntuiMessage *)
166 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
173HOOKF(
void, ami_menu_item_project_about, APTR, window,
struct IntuiMessage *)
181 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
192 sel = TimedDosRequesterTags(TDR_ImageType,TDRIMAGE_INFO,
195 TDR_GadgetString, temp2,
196 TDR_FormatString,
"NetSurf %s\nBuild date %s\n\nhttp://www.netsurf-browser.org",
201 struct EasyStruct about_req = {
202 sizeof(
struct EasyStruct),
205 "NetSurf %s\nBuild date %s\n\nhttp:
215 }
else if(sel == 0) {
236HOOKF(
void, ami_menu_item_project_quit, APTR, window,
struct IntuiMessage *)
241HOOKF(
void, ami_menu_item_edit_cut, APTR, window,
struct IntuiMessage *)
244 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
249HOOKF(
void, ami_menu_item_edit_copy, APTR, window,
struct IntuiMessage *)
253 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
275HOOKF(
void, ami_menu_item_edit_paste, APTR, window,
struct IntuiMessage *)
278 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
283HOOKF(
void, ami_menu_item_edit_selectall, APTR, window,
struct IntuiMessage *)
286 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
292HOOKF(
void, ami_menu_item_edit_clearsel, APTR, window,
struct IntuiMessage *)
295 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
300HOOKF(
void, ami_menu_item_edit_undo, APTR, window,
struct IntuiMessage *)
303 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
308HOOKF(
void, ami_menu_item_edit_redo, APTR, window,
struct IntuiMessage *)
311 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
316HOOKF(
void, ami_menu_item_browser_find, APTR, window,
struct IntuiMessage *)
319 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
324HOOKF(
void, ami_menu_item_browser_localhistory, APTR, window,
struct IntuiMessage *)
327 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
332HOOKF(
void, ami_menu_item_browser_globalhistory, APTR, window,
struct IntuiMessage *)
337HOOKF(
void, ami_menu_item_browser_cookies, APTR, window,
struct IntuiMessage *)
342HOOKF(
void, ami_menu_item_browser_foreimg, APTR, window,
struct IntuiMessage *)
344 struct Menu *menustrip;
345 bool checked =
false;
347 GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
354HOOKF(
void, ami_menu_item_browser_backimg, APTR, window,
struct IntuiMessage *)
356 struct Menu *menustrip;
357 bool checked =
false;
359 GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
366HOOKF(
void, ami_menu_item_browser_enablejs, APTR, window,
struct IntuiMessage *)
368 struct Menu *menustrip;
369 bool checked =
false;
371 GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
378HOOKF(
void, ami_menu_item_browser_enablecss, APTR, window,
struct IntuiMessage *)
380 struct Menu *menustrip;
381 bool checked =
false;
383 GetAttr(WINDOW_MenuStrip, (Object *)window, (ULONG *)&menustrip);
390HOOKF(
void, ami_menu_item_browser_scale_decrease, APTR, window,
struct IntuiMessage *)
393 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
398HOOKF(
void, ami_menu_item_browser_scale_normal, APTR, window,
struct IntuiMessage *)
401 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
406HOOKF(
void, ami_menu_item_browser_scale_increase, APTR, window,
struct IntuiMessage *)
409 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
414HOOKF(
void, ami_menu_item_browser_redraw, APTR, window,
struct IntuiMessage *)
417 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
423HOOKF(
void, ami_menu_item_hotlist_add, APTR, window,
struct IntuiMessage *)
427 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
438HOOKF(
void, ami_menu_item_hotlist_show, APTR, window,
struct IntuiMessage *)
443HOOKF(
void, ami_menu_item_hotlist_entries, APTR, window,
struct IntuiMessage *)
445 nsurl *url = hook->h_Data;
447 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
449 if(url == NULL)
return;
460HOOKF(
void, ami_menu_item_settings_edit, APTR, window,
struct IntuiMessage *)
465HOOKF(
void, ami_menu_item_settings_snapshot, APTR, window,
struct IntuiMessage *)
468 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
476HOOKF(
void, ami_menu_item_settings_save, APTR, window,
struct IntuiMessage *)
481HOOKF(
void, ami_menu_item_arexx_execute, APTR, window,
struct IntuiMessage *)
485 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
489 ASLFR_SleepWindow, TRUE,
492 ASLFR_DoSaveMode, FALSE,
494 ASLFR_InitialPattern,
"#?.nsrx",
496 if((
temp = malloc(1024))) {
505HOOKF(
void, ami_menu_item_arexx_entries, APTR, window,
struct IntuiMessage *)
507 char *script = hook->h_Data;
510 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
513 if((
temp = malloc(1024))) {
517 AddPart(
temp, script, 1024);
535 menu_num = FULLMENUNUM(0,4,1);
539 menu_num = FULLMENUNUM(0,4,2);
543 menu_num = FULLMENUNUM(0,4,3);
545#ifdef WITH_PDF_EXPORT
547 menu_num = FULLMENUNUM(0,4,4);
551 menu_num = FULLMENUNUM(0,8,0);
555 menu_num = FULLMENUNUM(1,0,0);
559 menu_num = FULLMENUNUM(1,1,0);
563 menu_num = FULLMENUNUM(1,2,0);
567 menu_num = FULLMENUNUM(1,4,0);
571 menu_num = FULLMENUNUM(1,5,0);
575 menu_num = FULLMENUNUM(1,8,0);
579 menu_num = FULLMENUNUM(1,9,0);
583 menu_num = FULLMENUNUM(2,0,0);
587 menu_num = FULLMENUNUM(2,8,0);
591 menu_num = FULLMENUNUM(2,8,1);
595 menu_num = FULLMENUNUM(2,9,0);
599 menu_num = FULLMENUNUM(2,10,0);
604 "WARNING: Unrecognised menu item %d", item);
613static void ami_gui_menu_set_checked_mc(
struct Menu *menu,
int item,
bool check)
615 ULONG check_state = MS_CHECKED;
625 IDoMethod((Object *)menu, MM_SETSTATE, 0, item, MS_CHECKED, check_state);
648 return ami_gui_menu_set_checked_mc(menu, item, check);
656static void ami_gui_menu_set_disabled_mc(
struct Window *
win,
struct Menu *menu,
int item,
bool disable)
658 ULONG disable_state = MS_DISABLED;
660 if(disable ==
false) {
664 IDoMethod((Object *)menu, MM_SETSTATE, 0, item, MS_DISABLED, disable_state);
672 if(disable ==
false) {
673 OnMenu(
win, menu_num);
675 OffMenu(
win, menu_num);
683 return ami_gui_menu_set_disabled_mc(
win, menu, item, disable);
698 struct Menu *menustrip;
701 if(!menustrip)
return;
745#ifdef WITH_PDF_EXPORT
750 OnMenu(win,AMI_MENU_COPY);
751 OnMenu(win,AMI_MENU_CLEAR);
753 OffMenu(win,AMI_MENU_COPY);
754 OffMenu(win,AMI_MENU_CLEAR);
758 OnMenu(win,AMI_MENU_CUT);
760 OffMenu(win,AMI_MENU_CUT);
763 OnMenu(win,AMI_MENU_PASTE);
765 OffMenu(win,AMI_MENU_PASTE);
784#ifdef WITH_PDF_EXPORT
827 return check_toggled;
836 struct ExAllControl *ctrl;
839 struct ExAllData *ead;
843 if((
buffer = malloc(1024))) {
844 if((ctrl = AllocDosObject(DOS_EXALLCONTROL,NULL))) {
845 ctrl->eac_LastKey = 0;
847 if(ParsePatternNoCase(
"#?.nsrx",(
char *)&matchpatt,16) != -1) {
848 ctrl->eac_MatchString = (
char *)&matchpatt;
852 cont = ExAll(lock,(
struct ExAllData *)
buffer,1024,ED_COMMENT,ctrl);
853 if((!cont) && (IoErr() != ERROR_NO_MORE_ENTRIES))
break;
854 if(!ctrl->eac_Entries)
continue;
856 for(ead = (
struct ExAllData *)
buffer; ead; ead = ead->ed_Next) {
859 if(ead->ed_Comment[0] !=
'\0')
860 menu_lab = ead->ed_Comment;
862 menu_lab = ead->ed_Name;
865 ami_menu_item_arexx_entries, (
void *)strdup(ead->ed_Name), 0);
871 FreeDosObject(DOS_EXALLCONTROL,ctrl);
899 type = NM_SUB + (level - 2);
907 if(is_folder ==
true) {
908 icon =
ASPrintf(
"icons/directory.png");
911 if (icon == NULL) icon =
ASPrintf(
"icons/content.png");
915 if((is_folder ==
true) && (
type == NM_SUB)) {
916 flags = NM_ITEMDISABLED;
921 NULL, icon, ami_menu_item_hotlist_entries, (
void *)url,
flags);
923 if(icon) FreeVec(icon);
931 ami_menu_item_hotlist_add, NULL, 0);
933 ami_menu_item_hotlist_show, NULL, 0);
941 UWORD js_flags = CHECKIT | MENUTOGGLE;
945 UWORD css_flags = CHECKIT | MENUTOGGLE;
947 css_flags |= CHECKED;
949 UWORD imgfore_flags = CHECKIT | MENUTOGGLE;
951 imgfore_flags |= CHECKED;
953 UWORD imgback_flags = CHECKIT | MENUTOGGLE;
955 imgback_flags |= CHECKED;
959 ami_menu_item_project_newwin, NULL, 0);
961 ami_menu_item_project_newtab, NULL, 0);
964 ami_menu_item_project_open, NULL, 0);
972#ifdef WITH_PDF_EXPORT
980 ami_menu_item_project_print, NULL, NM_ITEMDISABLED);
983 ami_menu_item_project_closetab, NULL, 0);
985 ami_menu_item_project_closewin, NULL, 0);
988 ami_menu_item_project_about, NULL, 0);
991 ami_menu_item_project_quit, NULL, 0);
995 ami_menu_item_edit_cut, NULL, 0);
997 ami_menu_item_edit_copy, NULL, 0);
999 ami_menu_item_edit_paste, NULL, 0);
1002 ami_menu_item_edit_selectall, NULL, 0);
1004 ami_menu_item_edit_clearsel, NULL, 0);
1007 ami_menu_item_edit_undo, NULL, 0);
1009 ami_menu_item_edit_redo, NULL, 0);
1013 ami_menu_item_browser_find, NULL, 0);
1016 ami_menu_item_browser_localhistory, NULL, 0);
1018 ami_menu_item_browser_globalhistory, NULL, 0);
1021 ami_menu_item_browser_cookies, NULL, 0);
1025 ami_menu_item_browser_scale_decrease, NULL, 0);
1027 ami_menu_item_browser_scale_normal, NULL, 0);
1029 ami_menu_item_browser_scale_increase, NULL, 0);
1032 ami_menu_item_browser_foreimg, NULL, imgfore_flags);
1034 ami_menu_item_browser_backimg, NULL, imgback_flags);
1036 ami_menu_item_browser_enablejs, NULL, js_flags);
1038 ami_menu_item_browser_enablecss, NULL, css_flags);
1041 ami_menu_item_browser_redraw, NULL, 0);
1048 ami_menu_item_settings_edit, NULL, 0);
1051 ami_menu_item_settings_snapshot, NULL, 0);
1053 ami_menu_item_settings_save, NULL, 0);
1057 ami_menu_item_arexx_execute, NULL, 0);
1066 if(gui_menu != NULL) {
1081 struct Menu *temp_menu;
1100 if(md[i] == NULL)
continue;
1102 (md[i]->
menulab != NM_BARLABEL) &&
1146 if(gui_menu_count == 0) {
1149 DisposeObject((Object *)gui_menu);
void gui_start_selection(struct gui_window *g)
bool ami_easy_clipboard_bitmap(struct bitmap *bitmap)
nserror ami_cookies_present(const char *search_term)
Open the cookie viewer.
bool ami_mime_compare(struct hlcache_handle *c, const char *type)
Compare the MIME type of an hlcache_handle to a DefIcons type.
struct Window * ami_gui_get_window(struct gui_window *gw)
Get window from gui_window.
struct Screen * ami_gui_get_screen(void)
Get a pointer to the screen NetSurf is running on.
void ami_gui2_set_new_content(struct gui_window_2 *gwin, bool new_content)
Set new_content in gui_window_2 Indicates the window needs redrawing.
struct Menu * ami_gui_get_menu(struct gui_window *gw)
Get imenu from gui_window.
void ami_set_pointer(struct gui_window_2 *gwin, gui_pointer_shape shape, bool update)
void ami_gui_adjust_scale(struct gui_window *gw, float adjustment)
Adjust scale by specified amount.
struct browser_window * ami_gui2_get_browser_window(struct gui_window_2 *gwin)
Get browser window from gui_window_2.
void ami_reset_pointer(struct gui_window_2 *gwin)
struct ami_menu_data ** ami_gui2_get_menu_data(struct gui_window_2 *gwin)
Get menu_data from gui_window_2.
nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin)
void ami_gui2_set_menu(struct gui_window_2 *gwin, struct Menu *menu)
Set imenu to gui_window_2.
void ami_gui2_set_closed(struct gui_window_2 *gwin, bool closed)
Set closed in gui_window_2.
Object * ami_gui2_get_object(struct gui_window_2 *gwin, int object_type)
Get object from gui_window.
struct gui_window * ami_gui2_get_gui_window(struct gui_window_2 *gwin)
Get gui_window from gui_window_2.
void ami_gui_set_scale(struct gui_window *gw, float scale)
Set the scale of a gui window.
void ami_gui_update_hotlist_button(struct gui_window_2 *gwin)
void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw)
Schedule a redraw of the browser window - Amiga-specific function.
struct Window * ami_gui2_get_window(struct gui_window_2 *gwin)
Get window from gui_window_2.
struct browser_window * ami_gui_get_browser_window(struct gui_window *gw)
Get browser window from gui_window.
char * ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail)
nserror ami_history_global_present(void)
Open the global history viewer.
nserror amiga_warn_user(const char *warning, const char *detail)
Warn the user of an event.
void ami_arexx_execute(char *script)
Browser window creation and manipulation interface.
bool browser_window_can_select(struct browser_window *bw)
Find out if given browser window content is selectable.
nserror browser_window_navigate(struct browser_window *bw, struct nsurl *url, struct nsurl *referrer, enum browser_window_nav_flags flags, char *post_urlenc, struct fetch_multipart_data *post_multipart, struct hlcache_handle *parent)
Start fetching a page in a browser window.
bool browser_window_has_content(struct browser_window *bw)
Find out if a browser window is currently showing a content.
void browser_window_destroy(struct browser_window *bw)
Close and destroy a browser window.
@ BW_EDITOR_CAN_PASTE
Can paste, input.
@ BW_EDITOR_CAN_CUT
Selection not read-only.
@ BW_EDITOR_CAN_COPY
Have selection.
struct nsurl * browser_window_access_url(const struct browser_window *bw)
Access a browser window's URL.
const char * browser_window_get_title(struct browser_window *bw)
Get the title of a browser_window.
nserror browser_window_create(enum browser_window_create_flags flags, struct nsurl *url, struct nsurl *referrer, struct browser_window *existing, struct browser_window **bw)
Create and open a new root browser window with the given page.
struct hlcache_handle * browser_window_get_content(struct browser_window *bw)
Get a cache handle for the content within a browser window.
browser_editor_flags browser_window_get_editor_flags(struct browser_window *bw)
Check whether browser window can accept a cut/copy/paste, or has a selection that could be saved.
@ BW_CREATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
@ BW_NAVIGATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
static osspriteop_area * buffer
The buffer characteristics.
@ CONTENT_CSS
content is CSS
nserror hotlist_add_url(nsurl *url)
Add an entry to the hotlist for given URL.
nserror
Enumeration of error codes.
void ami_bitmap_set_url(struct bitmap *bm, struct nsurl *url)
Set bitmap URL.
void ami_bitmap_set_title(struct bitmap *bm, const char *title)
Set bitmap title.
void ami_file_save_req(int type, struct gui_window_2 *gwin, struct hlcache_handle *object)
struct FileRequester * filereq
void ami_file_open(struct gui_window_2 *gwin)
nserror ami_hotlist_scan(void *userdata, int first_item, const char *folder, bool(*cb_add_item)(void *userdata, int level, int item, const char *title, nsurl *url, bool folder))
Scan the hotlist.
nserror ami_hotlist_present(void)
Open the hotlist viewer.
nserror ami_nsoption_write(void)
void ami_print_ui(struct hlcache_handle *c)
void ami_search_open(struct gui_window *gwin)
Change the displayed search status.
void ami_utf8_free(char *ptr)
char * ami_utf8_easy(const char *string)
void ami_gui_opts_open(void)
nserror ami_history_local_present(struct gui_window *gw)
Open the global history viewer.
Public content interface.
struct bitmap * content_get_bitmap(struct hlcache_handle *h)
Retrieve the bitmap contained in an image content.
content_type content_get_type(struct hlcache_handle *h)
Retrieve computed type of content.
Core mouse and pointer states.
Interface to platform-specific graphical user interface window operations.
Interface to key press operations.
bool browser_window_key_press(struct browser_window *bw, uint32_t key)
Handle key presses in a browser window.
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Localised message support (interface).
NetSurf URL handling (interface).
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
struct nsurl nsurl
NetSurf URL object.
char * ASPrintf(const char *fmt,...)
Minimal compatibility header for AmigaOS 3.
#define LIB_IS_AT_LEAST(B, V, R)
#define DevNameFromLock(A, B, C, D)
Interface to utility string handling.
RISC OS wimp toolkit bitmap.
struct browser_window * bw
first entry in window list
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
#define nsoption_set_int(OPTION, VALUE)
set an integer option in the default table
#define nsoption_set_bool(OPTION, VALUE)
set a boolean option in the default table
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Interface to a number of general purpose functionality.
Version information interface.