From c4ff8c664e3041c5b32b4983b4447341e3d3f878 Mon Sep 17 00:00:00 2001 From: "ramiro%netscape.com" Date: Sat, 17 Oct 1998 20:43:56 +0000 Subject: [PATCH] Someone in the wishlist suggested this and I though it was a good idea. Add an "Open Link In Frame" context menu item when appropriate. --- cmd/xfe/resources | 18 +++++------ cmd/xfe/src/HTMLView.cpp | 66 ++++++++++++++++++++++++++++++++++------ cmd/xfe/src/HTMLView.h | 4 +-- cmd/xfe/src/xfe_commands | 1 + 4 files changed, 68 insertions(+), 21 deletions(-) diff --git a/cmd/xfe/resources b/cmd/xfe/resources index 2312edaf458b..0f6f9e4efea7 100644 --- a/cmd/xfe/resources +++ b/cmd/xfe/resources @@ -3529,15 +3529,15 @@ by @NAME@'s plug-ins or @NAME@'s helper applications. !======================== *popup.title.labelString: @NAME@ Commands: -*popup.openURLNewWindow.labelString: Open Link in New Window -*popup.openURLNewWindow.mnemonic: O -*popup*openURLNewWindow.acceleratorText: Button2 -*popup.openFrameNew.labelString: Open Frame in New Window -*popup.openFrameNew.mnemonic: w -*popup.openFrameInWindow.labelString: Open Frame in Window -*popup.openFrameInWindow.mnemonic: i -*popup.editLink.labelString: Open Link in Composer -*popup.editLink.mnemonic: e +*popup.openURLNewWindow.labelString: Open Link in New Window +*popup.openURLNewWindow.mnemonic: O +*popup*openURLNewWindow.acceleratorText: Button2 +*popup.openFrameNew.labelString: Open Frame in New Window +*popup.openFrameNew.mnemonic: w +*popup.openFrameInWindow.labelString: Open Frame in Window +*popup.editLink.labelString: Open Link in Composer +*popup.editLink.mnemonic: e +*popup.openLinkInFrame.labelString: Open Link in Frame *popup.fileBookmarksSubmenu.labelString: File Bookmark *popup.fileBookmarksSubmenu.mnemonic: l diff --git a/cmd/xfe/src/HTMLView.cpp b/cmd/xfe/src/HTMLView.cpp index 904c5513b56e..c61d23ea29a7 100644 --- a/cmd/xfe/src/HTMLView.cpp +++ b/cmd/xfe/src/HTMLView.cpp @@ -36,9 +36,7 @@ #include "EditorFrame.h" #endif -#ifdef XFE_FILE_BOOKMARK_IN_LINK_CONTEXT_MENU #include "BookmarkMenu.h" // Need for file bookmark generate function -#endif #include "htrdf.h" #include "net.h" @@ -146,6 +144,10 @@ MenuSpec XFE_HTMLView::openLinkNew_spec[] = { { xfeCmdOpenLinkNew , PUSHBUTTON }, { NULL }, }; +MenuSpec XFE_HTMLView::openLinkInFrame_spec[] = { + { xfeCmdOpenLinkInFrame , PUSHBUTTON }, + { NULL }, +}; MenuSpec XFE_HTMLView::openFrameNew_spec[] = { { xfeCmdOpenFrameNew , PUSHBUTTON }, { xfeCmdOpenFrameInWindow , PUSHBUTTON }, @@ -221,7 +223,6 @@ MenuSpec XFE_HTMLView::copyImage_spec[] = { { NULL }, }; -#ifdef XFE_FILE_BOOKMARK_IN_LINK_CONTEXT_MENU MenuSpec XFE_HTMLView::fileBookmark_spec[] = { { @@ -235,7 +236,6 @@ MenuSpec XFE_HTMLView::fileBookmark_spec[] = }, { NULL }, }; -#endif extern Boolean fe_IsPageLoaded (MWContext *context); @@ -893,6 +893,31 @@ XFE_HTMLView::doCommand(CommandType cmd, void *callData, XFE_CommandInfo* info) m_urlUnderMouse = NULL; /* it will be freed in the exit routine. */ return; } + else if (IS_CMD(xfeCmdOpenLinkInFrame)) + { + fe_UserActivity (m_contextData); + + if (!m_urlUnderMouse) + { + return; + } + + // Find the context for the target frame + MWContext * grid_context = fe_GetFocusGridOfContext(m_contextData); + + if (!grid_context) + { + return; + } + + // Do it + fe_GetURL(grid_context,m_urlUnderMouse,False); + + // Freed by exit routine + m_urlUnderMouse = NULL; + + return; + } else if (IS_CMD(xfeCmdOpenFrameNew)) { fe_UserActivity (m_contextData); @@ -929,6 +954,11 @@ XFE_HTMLView::doCommand(CommandType cmd, void *callData, XFE_CommandInfo* info) URL_Struct * url = NET_CreateURLStruct(h->address,NET_DONT_RELOAD); fe_GetURL(top_context,url,False); + + // Freed by exit routine + m_urlUnderMouse = NULL; + + return; } #ifdef EDITOR else if (IS_CMD(xfeCmdOpenLinkEdit)) @@ -1287,6 +1317,10 @@ XFE_HTMLView::isCommandEnabled(CommandType cmd, void *calldata, XFE_CommandInfo* { return True; } + else if (IS_CMD(xfeCmdOpenLinkInFrame)) + { + return True; + } #ifdef EDITOR else if (IS_CMD(xfeCmdOpenLinkEdit)) { @@ -1399,6 +1433,7 @@ XFE_HTMLView::handlesCommand(CommandType cmd, void *calldata, XFE_CommandInfo*) // context menu items || IS_CMD(xfeCmdOpenLinkNew) + || IS_CMD(xfeCmdOpenLinkInFrame) || IS_CMD(xfeCmdOpenFrameNew) || IS_CMD(xfeCmdOpenFrameInWindow) #ifdef EDITOR @@ -2026,15 +2061,28 @@ XFE_HTMLView::doPopup(MWContext *context, CL_Layer *layer, if (isImage && image_delayed_p) ADD_SPEC ( showImage_spec ); if (isCommandEnabled(xfeCmdStopLoading)) ADD_SPEC ( stopLoading_spec ); ADD_MENU_SEPARATOR; - if (isBrowserLink) ADD_SPEC ( openLinkNew_spec ); - if (isFrame) ADD_SPEC ( openFrameNew_spec ); + + if (isBrowserLink) + { + ADD_SPEC ( openLinkNew_spec ); + #ifdef EDITOR - if (isBrowserLink) ADD_SPEC ( openLinkEdit_spec ); + ADD_SPEC ( openLinkEdit_spec ); #endif -#ifdef XFE_FILE_BOOKMARK_IN_LINK_CONTEXT_MENU + + if (isFrame) + { + ADD_SPEC ( openLinkInFrame_spec ); + } + + ADD_MENU_SEPARATOR; + } + + if (isFrame) ADD_SPEC ( openFrameNew_spec ); + ADD_MENU_SEPARATOR; if (isBrowserLink) ADD_SPEC ( fileBookmark_spec ); -#endif + ADD_MENU_SEPARATOR; if (isBrowser) ADD_SPEC ( page_details_spec ); if (isImage) ADD_SPEC ( openImage_spec ); diff --git a/cmd/xfe/src/HTMLView.h b/cmd/xfe/src/HTMLView.h index a581abe04fe2..0ec6860458d6 100644 --- a/cmd/xfe/src/HTMLView.h +++ b/cmd/xfe/src/HTMLView.h @@ -107,6 +107,7 @@ private: static MenuSpec separator_spec[]; static MenuSpec openLinkNew_spec[]; + static MenuSpec openLinkInFrame_spec[]; static MenuSpec openFrameNew_spec[]; static MenuSpec openLinkEdit_spec[]; static MenuSpec go_spec[]; @@ -124,10 +125,7 @@ private: static MenuSpec copy_spec[]; static MenuSpec copyLink_spec[]; static MenuSpec copyImage_spec[]; - -#ifdef XFE_FILE_BOOKMARK_IN_LINK_CONTEXT_MENU static MenuSpec fileBookmark_spec[]; -#endif URL_Struct *m_urlUnderMouse; URL_Struct *m_imageUnderMouse; diff --git a/cmd/xfe/src/xfe_commands b/cmd/xfe/src/xfe_commands index 1c23b661d68b..4633f5e2116b 100644 --- a/cmd/xfe/src/xfe_commands +++ b/cmd/xfe/src/xfe_commands @@ -117,6 +117,7 @@ xfeCmdOpenPage openPage xfeCmdOpenPageChooseFile openPageChooseFile xfeCmdOpenLinkNew openURLNewWindow xfeCmdOpenLinkEdit editLink +xfeCmdOpenLinkInFrame openLinkInFrame xfeCmdCopyLink copyLink xfeCmdCopyImage copyImage xfeCmdImageWallpaper imageWallpaper