summaryrefslogtreecommitdiff
path: root/frontends/amiga/ctxmenu.c
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/amiga/ctxmenu.c')
-rw-r--r--frontends/amiga/ctxmenu.c84
1 files changed, 47 insertions, 37 deletions
diff --git a/frontends/amiga/ctxmenu.c b/frontends/amiga/ctxmenu.c
index 717096f52..42826a3a5 100644
--- a/frontends/amiga/ctxmenu.c
+++ b/frontends/amiga/ctxmenu.c
@@ -107,8 +107,8 @@ HOOKF(void, ami_ctxmenu_item_selcopy, APTR, window, struct IntuiMessage *)
{
struct gui_window_2 *gwin = (struct gui_window_2 *)hook->h_Data;
- browser_window_key_press(gwin->gw->bw, NS_KEY_COPY_SELECTION);
- browser_window_key_press(gwin->gw->bw, NS_KEY_CLEAR_SELECTION);
+ browser_window_key_press(ami_gui2_get_browser_window(gwin), NS_KEY_COPY_SELECTION);
+ browser_window_key_press(ami_gui2_get_browser_window(gwin), NS_KEY_CLEAR_SELECTION);
}
HOOKF(void, ami_ctxmenu_item_websearch, APTR, window, struct IntuiMessage *)
@@ -117,11 +117,11 @@ HOOKF(void, ami_ctxmenu_item_websearch, APTR, window, struct IntuiMessage *)
nsurl *url;
struct gui_window_2 *gwin = (struct gui_window_2 *)hook->h_Data;
- char *sel = browser_window_get_selection(gwin->gw->bw);
+ char *sel = browser_window_get_selection(ami_gui2_get_browser_window(gwin));
ret = search_web_omni(sel, SEARCH_WEB_OMNI_SEARCHONLY, &url);
if (ret == NSERROR_OK) {
- browser_window_navigate(gwin->gw->bw,
+ browser_window_navigate(ami_gui2_get_browser_window(gwin),
url,
NULL,
BW_NAVIGATE_HISTORY,
@@ -146,8 +146,8 @@ HOOKF(void, ami_ctxmenu_item_urlopentab, APTR, window, struct IntuiMessage *)
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
nserror error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY | BW_CREATE_TAB,
url,
- browser_window_get_url(gwin->gw->bw),
- gwin->gw->bw,
+ browser_window_access_url(ami_gui2_get_browser_window(gwin)),
+ ami_gui2_get_browser_window(gwin),
&bw);
if (error != NSERROR_OK)
@@ -163,8 +163,8 @@ HOOKF(void, ami_ctxmenu_item_urlopenwin, APTR, window, struct IntuiMessage *)
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
nserror error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY,
url,
- browser_window_get_url(gwin->gw->bw),
- gwin->gw->bw,
+ browser_window_access_url(ami_gui2_get_browser_window(gwin)),
+ ami_gui2_get_browser_window(gwin),
&bw);
if (error != NSERROR_OK)
@@ -178,9 +178,9 @@ HOOKF(void, ami_ctxmenu_item_urldownload, APTR, window, struct IntuiMessage *)
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
- browser_window_navigate(gwin->gw->bw,
+ browser_window_navigate(ami_gui2_get_browser_window(gwin),
url,
- browser_window_get_url(gwin->gw->bw),
+ browser_window_access_url(ami_gui2_get_browser_window(gwin)),
BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
@@ -198,9 +198,9 @@ HOOKF(void, ami_ctxmenu_item_objshow, APTR, window, struct IntuiMessage *)
struct gui_window_2 *gwin;
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
- browser_window_navigate(gwin->gw->bw,
+ browser_window_navigate(ami_gui2_get_browser_window(gwin),
hlcache_handle_get_url(hook->h_Data),
- browser_window_get_url(gwin->gw->bw),
+ browser_window_access_url(ami_gui2_get_browser_window(gwin)),
BW_NAVIGATE_HISTORY,
NULL,
NULL,
@@ -238,9 +238,9 @@ HOOKF(void, ami_ctxmenu_item_frameshow, APTR, window, struct IntuiMessage *)
struct gui_window_2 *gwin;
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
- browser_window_navigate(gwin->gw->bw,
+ browser_window_navigate(ami_gui2_get_browser_window(gwin),
hlcache_handle_get_url(hook->h_Data),
- browser_window_get_url(gwin->gw->bw),
+ browser_window_access_url(ami_gui2_get_browser_window(gwin)),
BW_NAVIGATE_HISTORY,
NULL,
NULL,
@@ -271,7 +271,8 @@ HOOKF(void, ami_ctxmenu_item_history, APTR, window, struct IntuiMessage *)
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
- browser_window_history_go(gwin->gw->bw, (struct history_entry *)hook->h_Data, false);
+ browser_window_history_go(ami_gui2_get_browser_window(gwin),
+ (struct history_entry *)hook->h_Data, false);
}
@@ -300,7 +301,7 @@ static uint32 ami_ctxmenu_hook_func(struct Hook *hook, struct Window *window, st
Object *root_menu;
bool ctxmenu_has_content = false;
struct gui_window_2 *gwin = hook->h_Data;
- struct hlcache_handle *cc = browser_window_get_content(gwin->gw->bw);
+ struct hlcache_handle *cc = browser_window_get_content(ami_gui2_get_browser_window(gwin));
struct browser_window_features ccdata;
int mx = window->MouseX;
int my = window->MouseY;
@@ -328,11 +329,11 @@ static uint32 ami_ctxmenu_hook_func(struct Hook *hook, struct Window *window, st
return 0;
}
- browser_window_get_features(gwin->gw->bw, x, y, &ccdata);
+ browser_window_get_features(ami_gui2_get_browser_window(gwin), x, y, &ccdata);
- if((browser_window_can_select(gwin->gw->bw)) &&
- ((browser_window_get_editor_flags(gwin->gw->bw) & BW_EDITOR_CAN_COPY)) &&
- (sel = browser_window_get_selection(gwin->gw->bw))) {
+ if((browser_window_can_select(ami_gui2_get_browser_window(gwin))) &&
+ ((browser_window_get_editor_flags(ami_gui2_get_browser_window(gwin)) & BW_EDITOR_CAN_COPY)) &&
+ (sel = browser_window_get_selection(ami_gui2_get_browser_window(gwin)))) {
ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_SELCOPY, gwin);
ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_WEBSEARCH, gwin);
@@ -401,7 +402,7 @@ static void ami_ctxmenu_alloc_item(int id, const char *label, const char *key, c
if(image != NULL) {
ctxmenu_item_image[id] = BitMapObj,
- BITMAP_Screen, scrn,
+ BITMAP_Screen, ami_gui_get_screen(),
BITMAP_SourceFile, image,
BITMAP_Masking, TRUE,
BitMapEnd;
@@ -498,25 +499,26 @@ void ami_ctxmenu_init(void)
static bool ami_ctxmenu_history(int direction, struct gui_window_2 *gwin, const struct history_entry *entry)
{
Object *history_root;
- int id = AMI_CTX_ID_HISTORY0 + gwin->temp;
+ int id = AMI_CTX_ID_HISTORY0 + ami_gui2_get_ctxmenu_history_tmp(gwin);
if(direction == AMI_CTXMENU_HISTORY_FORWARD) id += 10;
- if(gwin->temp >= 10) return false;
+ if(ami_gui2_get_ctxmenu_history_tmp(gwin) >= 10) return false;
ctxmenu_item_hook[id].h_Entry = (HOOKFUNC)ami_ctxmenu_item_history;
ctxmenu_item_hook[id].h_Data = (APTR)entry;
- history_root = (Object *)IDoMethod(gwin->history_ctxmenu[direction], MM_FINDID, 0, AMI_CTX_ID_HISTORY);
+ history_root = (Object *)IDoMethod(ami_gui2_get_ctxmenu_history(gwin, direction), MM_FINDID, 0, AMI_CTX_ID_HISTORY);
IDoMethod(history_root, OM_ADDMEMBER, MStrip,
MA_Type, T_ITEM,
+ /* TODO: MA_Label should be in local charset */
MA_Label, browser_window_history_entry_get_title(entry),
MA_ID, id,
MA_Image, NULL,
MA_UserData, &ctxmenu_item_hook[id],
MEnd);
- gwin->temp++;
+ ami_gui2_set_ctxmenu_history_tmp(gwin, ami_gui2_get_ctxmenu_history_tmp(gwin) + 1);
return true;
}
@@ -542,11 +544,11 @@ struct Menu *ami_ctxmenu_history_create(int direction, struct gui_window_2 *gwin
{
Object *obj;
- if(gwin->history_ctxmenu[direction] == NULL) {
+ if(ami_gui2_get_ctxmenu_history(gwin, direction) == NULL) {
if(ctxmenu_item_label[AMI_CTX_ID_HISTORY] == NULL)
ctxmenu_item_label[AMI_CTX_ID_HISTORY] = ami_utf8_easy(messages_get("History"));
- gwin->history_ctxmenu[direction] = MStrip,
+ obj = MStrip,
MA_Type, T_ROOT,
MA_AddChild, MStrip,
MA_Type, T_MENU,
@@ -556,23 +558,26 @@ struct Menu *ami_ctxmenu_history_create(int direction, struct gui_window_2 *gwin
//MA_FreeImage, FALSE,
MEnd,
MEnd;
+
+ ami_gui2_set_ctxmenu_history(gwin, direction, obj);
+
} else {
for (int i = 0; i < 20; i++) {
- obj = (Object *)IDoMethod(gwin->history_ctxmenu[direction],
+ obj = (Object *)IDoMethod(ami_gui2_get_ctxmenu_history(gwin, direction),
MM_FINDID, 0, AMI_CTX_ID_HISTORY0 + i);
- if(obj != NULL) IDoMethod(gwin->history_ctxmenu[direction], OM_REMMEMBER, obj);
+ if(obj != NULL) IDoMethod(ami_gui2_get_ctxmenu_history(gwin, direction), OM_REMMEMBER, obj);
}
- gwin->temp = 0;
+ ami_gui2_set_ctxmenu_history_tmp(gwin, 0);
if(direction == AMI_CTXMENU_HISTORY_BACK) {
- browser_window_history_enumerate_back(gwin->gw->bw, ami_ctxmenu_history_back, gwin);
+ browser_window_history_enumerate_back(ami_gui2_get_browser_window(gwin), ami_ctxmenu_history_back, gwin);
} else {
- browser_window_history_enumerate_forward(gwin->gw->bw, ami_ctxmenu_history_forward, gwin);
+ browser_window_history_enumerate_forward(ami_gui2_get_browser_window(gwin), ami_ctxmenu_history_forward, gwin);
}
}
- return (struct Menu *)gwin->history_ctxmenu[direction];
+ return (struct Menu *)ami_gui2_get_ctxmenu_history(gwin, direction);
}
@@ -581,13 +586,16 @@ struct Menu *ami_ctxmenu_history_create(int direction, struct gui_window_2 *gwin
**************************/
/** Exported interface documented in ctxmenu.h **/
-struct Menu *ami_ctxmenu_clicktab_create(struct gui_window_2 *gwin)
+struct Menu *ami_ctxmenu_clicktab_create(struct gui_window_2 *gwin, Object **clicktab_obj)
{
Object *root_menu;
+ Object *clicktab;
- if(gwin->clicktab_ctxmenu != NULL) return (struct Menu *)gwin->clicktab_ctxmenu;
+ if(*clicktab_obj != NULL) {
+ return (struct Menu *)*clicktab_obj;
+ }
- gwin->clicktab_ctxmenu = MStrip,
+ clicktab = MStrip,
MA_Type, T_ROOT,
MA_AddChild, root_menu = MStrip,
MA_Type, T_MENU,
@@ -596,10 +604,12 @@ struct Menu *ami_ctxmenu_clicktab_create(struct gui_window_2 *gwin)
MEnd,
MEnd;
+ *clicktab_obj = clicktab;
+
ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_TABNEW, gwin);
ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_TABCLOSE_OTHER, gwin);
- return (struct Menu *)gwin->clicktab_ctxmenu;
+ return (struct Menu *)clicktab;
}