27#include <proto/exec.h>
28#include <proto/intuition.h>
30#include <proto/bitmap.h>
31#include <images/bitmap.h>
32#include <proto/window.h>
33#include <classes/window.h>
35#include <intuition/menuclass.h>
36#include <reaction/reaction_macros.h>
69 AMI_CTX_ID_URLOPENTAB,
70 AMI_CTX_ID_URLOPENWIN,
71 AMI_CTX_ID_URLDOWNLOAD,
85 AMI_CTX_ID_HISTORY9F = AMI_CTX_ID_HISTORY0 + 19,
89 AMI_CTX_ID_TABCLOSE_OTHER,
94static Object *ctxmenu_obj = NULL;
96static struct Hook ctxmenu_item_hook[AMI_CTX_ID_MAX];
97static char *ctxmenu_item_label[AMI_CTX_ID_MAX];
98static char *ctxmenu_item_shortcut[AMI_CTX_ID_MAX];
99static Object *ctxmenu_item_image[AMI_CTX_ID_MAX];
106HOOKF(
void, ami_ctxmenu_item_selcopy, APTR, window,
struct IntuiMessage *)
114HOOKF(
void, ami_ctxmenu_item_websearch, APTR, window,
struct IntuiMessage *)
140HOOKF(
void, ami_ctxmenu_item_urlopentab, APTR, window,
struct IntuiMessage *)
146 GetAttr(WINDOW_UserData, (Object *)
window, (ULONG *)&gwin);
157HOOKF(
void, ami_ctxmenu_item_urlopenwin, APTR,
window,
struct IntuiMessage *)
163 GetAttr(WINDOW_UserData, (Object *)
window, (ULONG *)&gwin);
174HOOKF(
void, ami_ctxmenu_item_urldownload, APTR,
window,
struct IntuiMessage *)
179 GetAttr(WINDOW_UserData, (Object *)
window, (ULONG *)&gwin);
190HOOKF(
void, ami_ctxmenu_item_urlcopy, APTR,
window,
struct IntuiMessage *)
196HOOKF(
void, ami_ctxmenu_item_objshow, APTR,
window,
struct IntuiMessage *)
199 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
210HOOKF(
void, ami_ctxmenu_item_objcopy, APTR, window,
struct IntuiMessage *)
214 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
226 ami_easy_clipboard_svg(
object);
231HOOKF(
void, ami_ctxmenu_item_objcmd, APTR, window,
struct IntuiMessage *)
236HOOKF(
void, ami_ctxmenu_item_frameshow, APTR, window,
struct IntuiMessage *)
239 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
251HOOKF(
void, ami_ctxmenu_item_tabnew, APTR, window,
struct IntuiMessage *)
255 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
259HOOKF(
void, ami_ctxmenu_item_tabclose_other, APTR, window,
struct IntuiMessage *)
263 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
268HOOKF(
void, ami_ctxmenu_item_history, APTR, window,
struct IntuiMessage *)
272 GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
284static void ami_ctxmenu_add_item(Object *root_menu,
int id, APTR data)
286 ctxmenu_item_hook[id].h_Data = data;
288 IDoMethod(root_menu, OM_ADDMEMBER, MStrip,
291 MA_Label, ctxmenu_item_label[
id],
292 MA_Key, ctxmenu_item_shortcut[
id],
293 MA_Image, ctxmenu_item_image[
id],
294 MA_UserData, &ctxmenu_item_hook[
id],
299static uint32 ami_ctxmenu_hook_func(
struct Hook *hook,
struct Window *window,
struct ContextMenuMsg *msg)
302 bool ctxmenu_has_content =
false;
306 int mx = window->MouseX;
307 int my = window->MouseY;
311 if(msg->State != CM_QUERY)
return 0;
315 if(ctxmenu_obj != NULL) DisposeObject(ctxmenu_obj);
317 ctxmenu_obj = MStrip,
319 MA_AddChild, root_menu = MStrip,
322 MA_EmbeddedKey, FALSE,
338 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_SELCOPY, gwin);
339 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_WEBSEARCH, gwin);
341 ctxmenu_has_content =
true;
346 if(ctxmenu_has_content ==
true)
347 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_NONE, NULL);
349 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_URLOPENTAB, ccdata.link);
350 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_URLOPENWIN, ccdata.link);
351 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_URLDOWNLOAD, ccdata.link);
352 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_URLCOPY, ccdata.link);
353 ctxmenu_has_content =
true;
357 if(ctxmenu_has_content ==
true)
358 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_NONE, NULL);
360 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_OBJSHOW, ccdata.object);
363 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_OBJCOPY, ccdata.object);
366 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_OBJCMD, ccdata.object);
368 ctxmenu_has_content =
true;
371 if(ccdata.main && (ccdata.main != cc)) {
372 if(ctxmenu_has_content ==
true)
373 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_NONE, NULL);
375 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_FRAMESHOW, ccdata.main);
377 ctxmenu_has_content =
true;
380 if(ctxmenu_has_content ==
true) {
381 msg->Menu = ctxmenu_obj;
389static void ami_ctxmenu_alloc_item(
int id,
const char *label,
const char *key,
const char *image,
void *func)
398 ctxmenu_item_shortcut[id] = strdup(key);
400 ctxmenu_item_shortcut[id] = NULL;
406 BITMAP_SourceFile, image,
407 BITMAP_Masking, TRUE,
410 SetAttrs(ctxmenu_item_image[
id],
416 ctxmenu_item_hook[id].h_Entry = func;
417 ctxmenu_item_hook[id].h_Data = 0;
424 ASOHOOK_Entry, (HOOKFUNC)ami_ctxmenu_hook_func,
438 for(
int i = 1; i < AMI_CTX_ID_MAX; i++) {
439 if((ctxmenu_item_label[i] != NULL) && (ctxmenu_item_label[i] !=
ML_SEPARATOR)) {
442 ctxmenu_item_label[i] = NULL;
444 if(ctxmenu_item_shortcut[i] != NULL) {
445 free(ctxmenu_item_shortcut[i]);
446 ctxmenu_item_shortcut[i] = NULL;
449 if(ctxmenu_item_image[i] != NULL) {
450 DisposeObject(ctxmenu_item_image[i]);
451 ctxmenu_item_image[i] = NULL;
455 if(ctxmenu_obj != NULL) DisposeObject(ctxmenu_obj);
462 ami_ctxmenu_alloc_item(AMI_CTX_ID_NONE,
ML_SEPARATOR, NULL, NULL, NULL);
464 ami_ctxmenu_alloc_item(AMI_CTX_ID_SELCOPY,
"CopyNS",
"C",
"TBImages:list_copy",
465 ami_ctxmenu_item_selcopy);
466 ami_ctxmenu_alloc_item(AMI_CTX_ID_WEBSEARCH,
"SearchWeb", NULL,
"TBImages:list_search",
467 ami_ctxmenu_item_websearch);
469 ami_ctxmenu_alloc_item(AMI_CTX_ID_URLOPENTAB,
"LinkNewTab", NULL,
"TBImages:list_tab",
470 ami_ctxmenu_item_urlopentab);
471 ami_ctxmenu_alloc_item(AMI_CTX_ID_URLOPENWIN,
"LinkNewWin", NULL,
"TBImages:list_app",
472 ami_ctxmenu_item_urlopenwin);
473 ami_ctxmenu_alloc_item(AMI_CTX_ID_URLDOWNLOAD,
"LinkDload", NULL,
"TBImages:list_save",
474 ami_ctxmenu_item_urldownload);
475 ami_ctxmenu_alloc_item(AMI_CTX_ID_URLCOPY,
"CopyURL", NULL,
"TBImages:list_copy",
476 ami_ctxmenu_item_urlcopy);
478 ami_ctxmenu_alloc_item(AMI_CTX_ID_OBJSHOW,
"ObjShow", NULL,
"TBImages:list_preview",
479 ami_ctxmenu_item_objshow);
480 ami_ctxmenu_alloc_item(AMI_CTX_ID_OBJCOPY,
"CopyClip", NULL,
"TBImages:list_copy",
481 ami_ctxmenu_item_objcopy);
482 ami_ctxmenu_alloc_item(AMI_CTX_ID_OBJCMD,
"ExternalApp", NULL,
"TBImages:list_tool",
483 ami_ctxmenu_item_objcmd);
485 ami_ctxmenu_alloc_item(AMI_CTX_ID_FRAMESHOW,
"FrameOnly", NULL,
"TBImages:list_preview",
486 ami_ctxmenu_item_frameshow);
488 ami_ctxmenu_alloc_item(AMI_CTX_ID_TABNEW,
"NewTab",
"T",
"TBImages:list_tab",
489 ami_ctxmenu_item_tabnew);
490 ami_ctxmenu_alloc_item(AMI_CTX_ID_TABCLOSE_OTHER,
"CloseInactive",
"K",
"TBImages:list_cancel",
491 ami_ctxmenu_item_tabclose_other);
501 Object *history_root;
507 ctxmenu_item_hook[id].h_Entry = (HOOKFUNC)ami_ctxmenu_item_history;
508 ctxmenu_item_hook[id].h_Data = (APTR)entry;
512 IDoMethod(history_root, OM_ADDMEMBER, MStrip,
518 MA_UserData, &ctxmenu_item_hook[
id],
527static bool ami_ctxmenu_history_back(
const struct browser_window *bw,
528 int x0,
int y0,
int x1,
int y1,
535static bool ami_ctxmenu_history_forward(
const struct browser_window *bw,
536 int x0,
int y0,
int x1,
int y1,
548 if(ctxmenu_item_label[AMI_CTX_ID_HISTORY] == NULL)
555 MA_ID, AMI_CTX_ID_HISTORY,
556 MA_Label, ctxmenu_item_label[AMI_CTX_ID_HISTORY],
557 MA_EmbeddedKey, FALSE,
565 for (
int i = 0; i < 20; i++) {
567 MM_FINDID, 0, AMI_CTX_ID_HISTORY0 + i);
594 if(*clicktab_obj != NULL) {
595 return (
struct Menu *)*clicktab_obj;
600 MA_AddChild, root_menu = MStrip,
603 MA_EmbeddedKey, FALSE,
607 *clicktab_obj = clicktab;
609 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_TABNEW, gwin);
610 ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_TABCLOSE_OTHER, gwin);
612 return (
struct Menu *)clicktab;
bool ami_easy_clipboard(const char *text)
bool ami_easy_clipboard_bitmap(struct bitmap *bitmap)
lwc_string * ami_mime_content_to_cmd(struct hlcache_handle *c)
bool ami_mime_compare(struct hlcache_handle *c, const char *type)
Compare the MIME type of an hlcache_handle to a DefIcons type.
int ami_gui2_get_ctxmenu_history_tmp(struct gui_window_2 *gwin)
Get ctxmenu history tmp from gui_window_2.
struct Screen * ami_gui_get_screen(void)
Get a pointer to the screen NetSurf is running on.
void ami_gui_close_inactive_tabs(struct gui_window_2 *gwin)
Close all tabs in a window except the active one.
void ami_gui2_set_ctxmenu_history_tmp(struct gui_window_2 *gwin, int temp)
Set ctxmenu history tmp in gui_window_2.
void ami_set_pointer(struct gui_window_2 *gwin, gui_pointer_shape shape, bool update)
struct browser_window * ami_gui2_get_browser_window(struct gui_window_2 *gwin)
Get browser window from gui_window_2.
void ami_gui2_set_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction, Object *ctx_hist)
Set ctxmenu history in gui_window_2.
nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin)
Object * ami_gui2_get_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction)
Get ctxmenu history from gui_window_2.
bool ami_mouse_to_ns_coords(struct gui_window_2 *gwin, int *restrict x, int *restrict y, int mouse_x, int mouse_y)
#define HOOKF(ret, func, type, ptr, msgtype)
nserror amiga_warn_user(const char *warning, const char *detail)
Warn the user of an event.
void browser_window_history_enumerate_back(const struct browser_window *bw, browser_window_history_enumerate_cb cb, void *user_data)
Enumerate all entries that will be reached by the 'back' button.
nserror browser_window_history_go(struct browser_window *bw, struct history_entry *entry, bool new_window)
Navigate to specified history entry, optionally in new window.
void browser_window_history_enumerate_forward(const struct browser_window *bw, browser_window_history_enumerate_cb cb, void *user_data)
Enumerate all entries that will be reached by the 'forward' button.
const char * browser_window_history_entry_get_title(const struct history_entry *entry)
Returns the title of a history entry.
Interface to browser history operations.
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_get_features(struct browser_window *bw, int x, int y, struct browser_window_features *data)
Get access to any page features at the given coordinates.
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.
@ BW_EDITOR_CAN_COPY
Have selection.
struct nsurl * browser_window_access_url(const struct browser_window *bw)
Access a browser window's URL.
char * browser_window_get_selection(struct browser_window *bw)
Get the current selection from a root browser window, ownership passed to caller, who must free() it.
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_CREATE_TAB
New gui_window to be tab in same window as "existing" gui_window.
@ BW_CREATE_CLONE
New gui_window to be clone of "existing" gui_window.
@ BW_NAVIGATE_DOWNLOAD
download rather than render the uri
@ BW_NAVIGATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
@ CONTENT_IMAGE
All images.
nserror search_web_omni(const char *term, enum search_web_omni_flags flags, struct nsurl **url_out)
Generate a nsurl from a search term.
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_utf8_free(char *ptr)
char * ami_utf8_easy(const char *string)
Public content interface.
struct nsurl * hlcache_handle_get_url(const struct hlcache_handle *handle)
Retrieve the URL associated with a high level cache handle.
const char * content_get_title(struct hlcache_handle *h)
Retrieve title associated with content.
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 key press operations.
bool browser_window_key_press(struct browser_window *bw, uint32_t key)
Handle key presses in a browser window.
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).
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
struct nsurl nsurl
NetSurf URL object.
void FreeSysObject(ULONG type, APTR obj)
#define AllocSysObjectTags(A, B, C, D)
void amiga_plugin_hack_execute(struct hlcache_handle *c)
core web search facilities interface.
@ SEARCH_WEB_OMNI_SEARCHONLY
The search does not attempt to interpret the url as a url before using it as a search term.
Interface to utility string handling.
RISC OS wimp toolkit bitmap.
Page features at a specific spatial location.
struct browser_window * bw
struct gui_window * window
Platform specific window data only valid at top level.
A node in the history tree.
Option reading and saving interface.
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Interface to a number of general purpose functionality.