2008-10-21 22:04:27 +04:00
|
|
|
/*
|
2011-09-25 22:44:10 +04:00
|
|
|
* Copyright 2008 - 2011 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
2008-10-21 22:04:27 +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/>.
|
|
|
|
*/
|
|
|
|
|
2011-01-07 02:17:17 +03:00
|
|
|
#ifdef __amigaos4__
|
2011-03-16 21:53:58 +03:00
|
|
|
|
2008-10-21 22:04:27 +04:00
|
|
|
#include <proto/popupmenu.h>
|
|
|
|
#include <proto/intuition.h>
|
2011-02-10 01:16:11 +03:00
|
|
|
#include <proto/asl.h>
|
|
|
|
#include <proto/dos.h>
|
|
|
|
#include <proto/exec.h>
|
|
|
|
|
2011-03-16 21:53:58 +03:00
|
|
|
#include <reaction/reaction_macros.h>
|
|
|
|
|
2011-02-10 01:16:11 +03:00
|
|
|
#include "amiga/context_menu.h"
|
2008-10-25 20:37:08 +04:00
|
|
|
#include "amiga/clipboard.h"
|
2009-05-16 18:50:30 +04:00
|
|
|
#include "amiga/bitmap.h"
|
2011-10-15 18:09:35 +04:00
|
|
|
#include "amiga/file.h"
|
2011-06-18 02:49:20 +04:00
|
|
|
#include "amiga/filetype.h"
|
2011-03-16 21:53:58 +03:00
|
|
|
#include "amiga/gui.h"
|
2011-03-01 02:33:03 +03:00
|
|
|
#include "amiga/history_local.h"
|
2009-05-19 11:23:56 +04:00
|
|
|
#include "amiga/iff_dr2d.h"
|
2013-05-26 01:46:27 +04:00
|
|
|
#include "utils/nsoption.h"
|
2011-05-11 22:33:31 +04:00
|
|
|
#include "amiga/plugin_hack.h"
|
2011-03-16 21:53:58 +03:00
|
|
|
#include "amiga/theme.h"
|
2011-12-17 22:47:35 +04:00
|
|
|
#include "amiga/tree.h"
|
2011-03-16 21:53:58 +03:00
|
|
|
#include "amiga/utf8.h"
|
2012-08-22 16:16:20 +04:00
|
|
|
#include "desktop/browser_private.h"
|
2013-07-10 14:55:42 +04:00
|
|
|
#include "desktop/local_history.h"
|
2013-09-03 01:41:04 +04:00
|
|
|
#include "desktop/hotlist.h"
|
2011-03-01 02:33:03 +03:00
|
|
|
#include "desktop/searchweb.h"
|
2011-10-23 17:15:44 +04:00
|
|
|
#include "desktop/textinput.h"
|
2012-08-21 02:23:22 +04:00
|
|
|
#include "render/form.h"
|
2011-02-10 01:16:11 +03:00
|
|
|
#include "utils/utf8.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/utils.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
2008-10-21 22:04:27 +04:00
|
|
|
|
2011-12-17 22:47:35 +04:00
|
|
|
static uint32 ami_context_menu_hook(struct Hook *hook, Object *item, APTR reserved);
|
|
|
|
static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR reserved);
|
2011-03-01 01:35:53 +03:00
|
|
|
static bool ami_context_menu_history(const struct history *history, int x0, int y0,
|
|
|
|
int x1, int y1, const struct history_entry *entry, void *user_data);
|
2008-10-21 22:04:27 +04:00
|
|
|
|
2011-06-23 21:35:35 +04:00
|
|
|
static uint32 ami_popup_hook(struct Hook *hook,Object *item,APTR reserved);
|
2011-03-16 21:53:58 +03:00
|
|
|
|
2011-02-28 22:31:35 +03:00
|
|
|
enum {
|
|
|
|
CMID_SELECTFILE,
|
|
|
|
CMID_COPYURL,
|
2011-10-09 21:37:57 +04:00
|
|
|
CMID_URLOPEN,
|
2011-02-28 22:31:35 +03:00
|
|
|
CMID_URLOPENWIN,
|
|
|
|
CMID_URLOPENTAB,
|
2011-10-23 17:15:44 +04:00
|
|
|
CMID_URLHOTLIST,
|
2011-02-28 22:31:35 +03:00
|
|
|
CMID_SAVEURL,
|
|
|
|
CMID_SHOWOBJ,
|
|
|
|
CMID_COPYOBJ,
|
|
|
|
CMID_CLIPOBJ,
|
|
|
|
CMID_SAVEOBJ,
|
|
|
|
CMID_SAVEIFFOBJ,
|
2011-09-25 22:44:10 +04:00
|
|
|
CMID_RELOADOBJ,
|
2011-02-28 22:31:35 +03:00
|
|
|
CMID_SELALL,
|
|
|
|
CMID_SELCLEAR,
|
|
|
|
CMID_SELCUT,
|
|
|
|
CMID_SELCOPY,
|
|
|
|
CMID_SELPASTE,
|
|
|
|
CMID_SELSEARCH,
|
2011-10-23 17:15:44 +04:00
|
|
|
CMID_SELSAVE,
|
2011-09-25 22:44:10 +04:00
|
|
|
CMID_FRAMEWIN,
|
|
|
|
CMID_FRAMETAB,
|
|
|
|
CMID_FRAMESHOW,
|
|
|
|
CMID_FRAMERELOAD,
|
|
|
|
CMID_FRAMECOPYURL,
|
|
|
|
CMID_FRAMESAVE,
|
2011-10-23 17:15:44 +04:00
|
|
|
CMID_FRAMESAVECOMPLETE,
|
2011-05-11 22:33:31 +04:00
|
|
|
CMID_PLUGINCMD,
|
2011-10-08 17:48:44 +04:00
|
|
|
CMID_NAVHOME,
|
|
|
|
CMID_NAVBACK,
|
|
|
|
CMID_NAVFORWARD,
|
|
|
|
CMID_NAVRELOAD,
|
|
|
|
CMID_NAVSTOP,
|
2011-10-09 21:37:57 +04:00
|
|
|
CMID_PAGEOPEN,
|
|
|
|
CMID_PAGESAVE,
|
|
|
|
CMID_PAGESAVECOMPLETE,
|
|
|
|
CMID_PAGEHOTLIST,
|
|
|
|
CMID_PAGECLOSE,
|
2011-10-08 17:48:44 +04:00
|
|
|
|
2011-12-16 16:33:05 +04:00
|
|
|
CMID_TREE_EXPAND,
|
|
|
|
CMID_TREE_COLLAPSE,
|
|
|
|
CMID_TREE_LAUNCH,
|
|
|
|
CMID_TREE_NEWFOLDER,
|
|
|
|
CMID_TREE_NEWITEM,
|
|
|
|
CMID_TREE_SETDEFAULT,
|
|
|
|
CMID_TREE_CLEARDEFAULT,
|
|
|
|
CMID_TREE_DELETE,
|
2011-12-17 22:47:35 +04:00
|
|
|
CMID_TREE_EDITTITLE,
|
2011-12-16 16:33:05 +04:00
|
|
|
CMID_TREE_EDITLINK,
|
|
|
|
CMID_TREE_EDITFOLDER,
|
|
|
|
CMID_TREE_ADDHOTLIST,
|
|
|
|
|
2011-02-28 22:31:35 +03:00
|
|
|
CMSUB_OBJECT,
|
|
|
|
CMSUB_URL,
|
|
|
|
CMSUB_SEL,
|
2011-09-25 22:44:10 +04:00
|
|
|
CMSUB_PAGE,
|
|
|
|
CMSUB_FRAME,
|
2011-10-08 17:48:44 +04:00
|
|
|
CMSUB_NAVIGATE,
|
2011-02-28 22:31:35 +03:00
|
|
|
CMID_HISTORY,
|
|
|
|
CMID_LAST
|
|
|
|
};
|
|
|
|
|
2012-08-21 01:59:47 +04:00
|
|
|
struct ami_file_input_menu_data {
|
|
|
|
int x;
|
|
|
|
int y;
|
2012-08-21 02:19:58 +04:00
|
|
|
struct browser_window *bw;
|
2012-08-21 02:15:22 +04:00
|
|
|
};
|
2012-08-21 01:59:47 +04:00
|
|
|
|
2011-03-16 21:53:58 +03:00
|
|
|
struct Library *PopupMenuBase = NULL;
|
|
|
|
struct PopupMenuIFace *IPopupMenu = NULL;
|
2011-06-23 21:35:35 +04:00
|
|
|
static char *ctxmenulab[CMID_LAST];
|
|
|
|
static Object *ctxmenuobj = NULL;
|
|
|
|
static struct Hook ctxmenuhook;
|
2008-10-25 20:37:08 +04:00
|
|
|
|
|
|
|
void ami_context_menu_init(void)
|
|
|
|
{
|
2011-03-16 21:53:58 +03:00
|
|
|
if(PopupMenuBase = OpenLibrary("popupmenu.class",0))
|
|
|
|
{
|
|
|
|
IPopupMenu = (struct PopupMenuIFace *)GetInterface(PopupMenuBase,"main",1,NULL);
|
|
|
|
}
|
|
|
|
|
2008-10-25 20:37:08 +04:00
|
|
|
ctxmenulab[CMID_SELECTFILE] = ami_utf8_easy((char *)messages_get("SelectFile"));
|
2011-10-23 17:15:44 +04:00
|
|
|
|
2008-10-25 20:37:08 +04:00
|
|
|
ctxmenulab[CMID_SHOWOBJ] = ami_utf8_easy((char *)messages_get("ObjShow"));
|
2011-09-25 22:44:10 +04:00
|
|
|
ctxmenulab[CMID_RELOADOBJ] = ami_utf8_easy((char *)messages_get("ObjReload"));
|
2008-10-25 20:37:08 +04:00
|
|
|
ctxmenulab[CMID_COPYOBJ] = ami_utf8_easy((char *)messages_get("CopyURL"));
|
2009-05-16 18:50:30 +04:00
|
|
|
ctxmenulab[CMID_CLIPOBJ] = ami_utf8_easy((char *)messages_get("CopyClip"));
|
|
|
|
ctxmenulab[CMID_SAVEOBJ] = ami_utf8_easy((char *)messages_get("SaveAs"));
|
|
|
|
ctxmenulab[CMID_SAVEIFFOBJ] = ami_utf8_easy((char *)messages_get("SaveIFF"));
|
|
|
|
|
2011-10-09 21:37:57 +04:00
|
|
|
ctxmenulab[CMID_PAGEOPEN] = ami_utf8_easy((char *)messages_get("OpenFile"));
|
|
|
|
ctxmenulab[CMID_PAGESAVE] = ami_utf8_easy((char *)messages_get("SaveAs"));
|
|
|
|
ctxmenulab[CMID_PAGESAVECOMPLETE] = ami_utf8_easy((char *)messages_get("SaveComplete"));
|
|
|
|
ctxmenulab[CMID_PAGEHOTLIST] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
|
|
|
|
ctxmenulab[CMID_PAGECLOSE] = ami_utf8_easy((char *)messages_get("Close"));
|
|
|
|
|
2011-09-25 22:44:10 +04:00
|
|
|
ctxmenulab[CMID_FRAMEWIN] = ami_utf8_easy((char *)messages_get("FrameNewWin"));
|
|
|
|
ctxmenulab[CMID_FRAMETAB] = ami_utf8_easy((char *)messages_get("FrameNewTab"));
|
|
|
|
ctxmenulab[CMID_FRAMESHOW] = ami_utf8_easy((char *)messages_get("FrameOnly"));
|
2011-10-23 17:15:44 +04:00
|
|
|
ctxmenulab[CMID_FRAMESAVE] = ami_utf8_easy((char *)messages_get("SaveAs"));
|
|
|
|
ctxmenulab[CMID_FRAMESAVECOMPLETE] = ami_utf8_easy((char *)messages_get("SaveComplete"));
|
|
|
|
ctxmenulab[CMID_FRAMECOPYURL] = ami_utf8_easy((char *)messages_get("CopyURL"));
|
|
|
|
ctxmenulab[CMID_FRAMERELOAD] = ami_utf8_easy((char *)messages_get("ObjReload"));
|
2011-09-25 22:44:10 +04:00
|
|
|
|
2009-02-01 02:45:25 +03:00
|
|
|
ctxmenulab[CMID_SAVEURL] = ami_utf8_easy((char *)messages_get("LinkDload"));
|
2011-10-09 21:37:57 +04:00
|
|
|
ctxmenulab[CMID_URLOPEN] = ami_utf8_easy((char *)messages_get("Open"));
|
2008-12-14 02:26:10 +03:00
|
|
|
ctxmenulab[CMID_URLOPENWIN] = ami_utf8_easy((char *)messages_get("LinkNewWin"));
|
|
|
|
ctxmenulab[CMID_URLOPENTAB] = ami_utf8_easy((char *)messages_get("LinkNewTab"));
|
2011-10-23 17:15:44 +04:00
|
|
|
ctxmenulab[CMID_URLHOTLIST] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
|
|
|
|
ctxmenulab[CMID_COPYURL] = ami_utf8_easy((char *)messages_get("CopyURL"));
|
2008-10-25 20:37:08 +04:00
|
|
|
|
2011-10-08 17:48:44 +04:00
|
|
|
ctxmenulab[CMID_NAVHOME] = ami_utf8_easy((char *)messages_get("Home"));
|
|
|
|
ctxmenulab[CMID_NAVBACK] = ami_utf8_easy((char *)messages_get("Back"));
|
|
|
|
ctxmenulab[CMID_NAVFORWARD] = ami_utf8_easy((char *)messages_get("Forward"));
|
|
|
|
ctxmenulab[CMID_NAVRELOAD] = ami_utf8_easy((char *)messages_get("ObjReload"));
|
|
|
|
ctxmenulab[CMID_NAVSTOP] = ami_utf8_easy((char *)messages_get("Stop"));
|
|
|
|
|
2010-07-24 20:39:37 +04:00
|
|
|
ctxmenulab[CMID_SELCUT] = ami_utf8_easy((char *)messages_get("CutNS"));
|
2009-01-16 22:13:07 +03:00
|
|
|
ctxmenulab[CMID_SELCOPY] = ami_utf8_easy((char *)messages_get("CopyNS"));
|
2010-07-24 20:39:37 +04:00
|
|
|
ctxmenulab[CMID_SELPASTE] = ami_utf8_easy((char *)messages_get("PasteNS"));
|
2009-01-16 22:13:07 +03:00
|
|
|
ctxmenulab[CMID_SELALL] = ami_utf8_easy((char *)messages_get("SelectAllNS"));
|
2010-07-24 20:39:37 +04:00
|
|
|
ctxmenulab[CMID_SELCLEAR] = ami_utf8_easy((char *)messages_get("ClearNS"));
|
2011-02-10 01:16:11 +03:00
|
|
|
ctxmenulab[CMID_SELSEARCH] = ami_utf8_easy((char *)messages_get("SearchWeb"));
|
2011-10-23 17:15:44 +04:00
|
|
|
ctxmenulab[CMID_SELSAVE] = ami_utf8_easy((char *)messages_get("SaveAs"));
|
2009-01-16 22:13:07 +03:00
|
|
|
|
2011-05-11 22:33:31 +04:00
|
|
|
ctxmenulab[CMID_PLUGINCMD] = ami_utf8_easy((char *)messages_get("ExternalApp"));
|
|
|
|
|
2011-10-09 21:37:57 +04:00
|
|
|
ctxmenulab[CMSUB_PAGE] = ami_utf8_easy((char *)messages_get("Page"));
|
2011-09-25 22:44:10 +04:00
|
|
|
ctxmenulab[CMSUB_FRAME] = ami_utf8_easy((char *)messages_get("Frame"));
|
2008-10-25 20:37:08 +04:00
|
|
|
ctxmenulab[CMSUB_OBJECT] = ami_utf8_easy((char *)messages_get("Object"));
|
2011-10-08 17:48:44 +04:00
|
|
|
ctxmenulab[CMSUB_NAVIGATE] = ami_utf8_easy((char *)messages_get("Navigate"));
|
2008-10-25 20:37:08 +04:00
|
|
|
ctxmenulab[CMSUB_URL] = ami_utf8_easy((char *)messages_get("Link"));
|
2009-01-16 22:13:07 +03:00
|
|
|
ctxmenulab[CMSUB_SEL] = ami_utf8_easy((char *)messages_get("Selection"));
|
2011-02-28 22:31:35 +03:00
|
|
|
|
|
|
|
/* Back button */
|
|
|
|
ctxmenulab[CMID_HISTORY] = ami_utf8_easy((char *)messages_get("HistLocalNS"));
|
2011-12-16 16:33:05 +04:00
|
|
|
|
|
|
|
/* treeviews */
|
|
|
|
ctxmenulab[CMID_TREE_EXPAND] = ami_utf8_easy((char *)messages_get("Expand"));
|
|
|
|
ctxmenulab[CMID_TREE_COLLAPSE] = ami_utf8_easy((char *)messages_get("Collapse"));
|
|
|
|
ctxmenulab[CMID_TREE_LAUNCH] = ami_utf8_easy((char *)messages_get("TreeLaunch"));
|
|
|
|
ctxmenulab[CMID_TREE_NEWFOLDER] = ami_utf8_easy((char *)messages_get("TreeNewFolder"));
|
2011-12-17 22:47:35 +04:00
|
|
|
ctxmenulab[CMID_TREE_NEWITEM] = ami_utf8_easy((char *)messages_get("TreeNewLink"));
|
2011-12-16 16:33:05 +04:00
|
|
|
ctxmenulab[CMID_TREE_SETDEFAULT] = ami_utf8_easy((char *)messages_get("TreeDefault"));
|
|
|
|
ctxmenulab[CMID_TREE_CLEARDEFAULT] = ami_utf8_easy((char *)messages_get("TreeClear"));
|
|
|
|
ctxmenulab[CMID_TREE_DELETE] = ami_utf8_easy((char *)messages_get("TreeDelete"));
|
2011-12-17 22:47:35 +04:00
|
|
|
ctxmenulab[CMID_TREE_EDITTITLE] = ami_utf8_easy((char *)messages_get("EditTitle"));
|
2011-12-16 16:33:05 +04:00
|
|
|
ctxmenulab[CMID_TREE_EDITLINK] = ami_utf8_easy((char *)messages_get("EditLink"));
|
|
|
|
ctxmenulab[CMID_TREE_EDITFOLDER] = ami_utf8_easy((char *)messages_get("EditFolder"));
|
|
|
|
ctxmenulab[CMID_TREE_ADDHOTLIST] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
|
|
|
|
|
2008-10-25 20:37:08 +04:00
|
|
|
}
|
|
|
|
|
2011-10-02 20:37:25 +04:00
|
|
|
void ami_context_menu_add_submenu(Object *ctxmenuobj, ULONG cmsub, void *userdata)
|
|
|
|
{
|
|
|
|
/*
|
2011-10-09 21:37:57 +04:00
|
|
|
* CMSUB_PAGE - userdata = hlcache_object *
|
2011-10-02 20:37:25 +04:00
|
|
|
* CMSUB_FRAME - userdata = hlcache_object *
|
|
|
|
* CMSUB_URL - userdata = char *
|
|
|
|
* CMSUB_OBJECT - userdata = hlcache_object *
|
|
|
|
* CMSUB_SEL - userdata = browser_window *
|
2011-10-08 17:48:44 +04:00
|
|
|
* CMSUB_NAVIGATE - userdata = browser_window * (only for menu construction)
|
2012-08-21 01:59:47 +04:00
|
|
|
* CMID_SELECTFILE - userdata = ami_file_input_menu_data *
|
2011-10-02 20:37:25 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct browser_window *bw = NULL;
|
|
|
|
|
|
|
|
switch(cmsub)
|
|
|
|
{
|
2011-10-09 21:37:57 +04:00
|
|
|
case CMSUB_PAGE:
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMSUB_PAGE],
|
|
|
|
PMSIMPLESUB,
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_PAGEOPEN],
|
|
|
|
PMIA_ID, CMID_PAGEOPEN,
|
|
|
|
PMIA_UserData, userdata,
|
2011-10-15 18:09:35 +04:00
|
|
|
PMIA_CommKey, "O",
|
2011-10-09 21:37:57 +04:00
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_PAGESAVE],
|
|
|
|
PMIA_ID, CMID_PAGESAVE,
|
|
|
|
PMIA_UserData, userdata,
|
2011-10-15 18:09:35 +04:00
|
|
|
PMIA_CommKey, "S",
|
2011-10-09 21:37:57 +04:00
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_PAGESAVECOMPLETE],
|
|
|
|
PMIA_ID, CMID_PAGESAVECOMPLETE,
|
|
|
|
PMIA_UserData, userdata,
|
2011-10-23 17:15:44 +04:00
|
|
|
PMIA_Disabled, (content_get_type(userdata) != CONTENT_HTML),
|
2011-10-09 21:37:57 +04:00
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_PAGECLOSE],
|
|
|
|
PMIA_ID, CMID_PAGECLOSE,
|
|
|
|
PMIA_UserData, userdata,
|
2011-10-15 18:09:35 +04:00
|
|
|
PMIA_CommKey, "K",
|
2011-10-09 21:37:57 +04:00
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_PAGEHOTLIST],
|
|
|
|
PMIA_ID, CMID_PAGEHOTLIST,
|
2011-12-04 18:55:23 +04:00
|
|
|
PMIA_UserData, nsurl_access(hlcache_handle_get_url(userdata)),
|
2011-10-15 18:09:35 +04:00
|
|
|
PMIA_CommKey, "B",
|
2011-10-09 21:37:57 +04:00
|
|
|
TAG_DONE),
|
|
|
|
TAG_DONE),
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
break;
|
|
|
|
|
2011-10-02 20:37:25 +04:00
|
|
|
case CMSUB_FRAME:
|
|
|
|
IDoMethod(ctxmenuobj,PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMSUB_FRAME],
|
|
|
|
PMSIMPLESUB,
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_FRAMEWIN],
|
|
|
|
PMIA_ID, CMID_FRAMEWIN,
|
2011-12-04 18:55:23 +04:00
|
|
|
PMIA_UserData, nsurl_access(hlcache_handle_get_url(userdata)),
|
2011-10-02 20:37:25 +04:00
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_FRAMETAB],
|
|
|
|
PMIA_ID, CMID_FRAMETAB,
|
2011-12-04 18:55:23 +04:00
|
|
|
PMIA_UserData, nsurl_access(hlcache_handle_get_url(userdata)),
|
2011-10-02 20:37:25 +04:00
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_FRAMESHOW],
|
|
|
|
PMIA_ID, CMID_FRAMESHOW,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
2011-10-23 17:15:44 +04:00
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_FRAMERELOAD],
|
2011-10-02 20:37:25 +04:00
|
|
|
PMIA_ID, CMID_FRAMERELOAD,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
2011-10-23 17:15:44 +04:00
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_FRAMECOPYURL],
|
2011-10-02 20:37:25 +04:00
|
|
|
PMIA_ID, CMID_FRAMECOPYURL,
|
2011-12-04 18:55:23 +04:00
|
|
|
PMIA_UserData, nsurl_access(hlcache_handle_get_url(userdata)),
|
2011-10-02 20:37:25 +04:00
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
2011-10-23 17:15:44 +04:00
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_FRAMESAVE],
|
2011-10-02 20:37:25 +04:00
|
|
|
PMIA_ID, CMID_FRAMESAVE,
|
2011-10-09 21:37:57 +04:00
|
|
|
PMIA_UserData, userdata,
|
2011-10-02 20:37:25 +04:00
|
|
|
TAG_DONE),
|
2011-10-23 17:15:44 +04:00
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_FRAMESAVECOMPLETE],
|
|
|
|
PMIA_ID, CMID_FRAMESAVECOMPLETE,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
PMIA_Disabled, (content_get_type(userdata) != CONTENT_HTML),
|
|
|
|
TAG_DONE),
|
2011-10-02 20:37:25 +04:00
|
|
|
TAG_DONE),
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
break;
|
|
|
|
|
2011-10-08 17:48:44 +04:00
|
|
|
case CMSUB_NAVIGATE:
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMSUB_NAVIGATE],
|
|
|
|
PMSIMPLESUB,
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_NAVHOME],
|
|
|
|
PMIA_ID, CMID_NAVHOME,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_NAVBACK],
|
|
|
|
PMIA_ID, CMID_NAVBACK,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
PMIA_Disabled, !browser_window_back_available(userdata),
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_NAVFORWARD],
|
|
|
|
PMIA_ID, CMID_NAVFORWARD,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
PMIA_Disabled, !browser_window_forward_available(userdata),
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_NAVRELOAD],
|
|
|
|
PMIA_ID, CMID_NAVRELOAD,
|
|
|
|
PMIA_UserData, userdata,
|
2011-10-08 19:48:58 +04:00
|
|
|
PMIA_CommKey, "R",
|
2011-10-08 17:48:44 +04:00
|
|
|
PMIA_Disabled, !browser_window_reload_available(userdata),
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_NAVSTOP],
|
|
|
|
PMIA_ID, CMID_NAVSTOP,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
PMIA_Disabled, !browser_window_stop_available(userdata),
|
|
|
|
TAG_DONE),
|
|
|
|
TAG_DONE),
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
break;
|
|
|
|
|
2011-10-02 20:37:25 +04:00
|
|
|
case CMSUB_URL:
|
|
|
|
IDoMethod(ctxmenuobj,PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMSUB_URL],
|
|
|
|
PMSIMPLESUB,
|
2011-10-09 21:37:57 +04:00
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_URLOPEN],
|
|
|
|
PMIA_ID, CMID_URLOPEN,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
TAG_DONE),
|
2011-10-02 20:37:25 +04:00
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_URLOPENWIN],
|
|
|
|
PMIA_ID, CMID_URLOPENWIN,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_URLOPENTAB],
|
|
|
|
PMIA_ID, CMID_URLOPENTAB,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_COPYURL],
|
|
|
|
PMIA_ID, CMID_COPYURL,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
TAG_DONE),
|
2011-10-23 17:15:44 +04:00
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_URLHOTLIST],
|
|
|
|
PMIA_ID, CMID_URLHOTLIST,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
TAG_DONE),
|
2011-10-02 20:37:25 +04:00
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_SAVEURL],
|
|
|
|
PMIA_ID, CMID_SAVEURL,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
TAG_DONE),
|
|
|
|
TAG_DONE),
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CMSUB_OBJECT:
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMSUB_OBJECT],
|
|
|
|
PMSIMPLESUB,
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_SHOWOBJ],
|
|
|
|
PMIA_ID, CMID_SHOWOBJ,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_RELOADOBJ],
|
|
|
|
PMIA_ID, CMID_RELOADOBJ,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_COPYOBJ],
|
|
|
|
PMIA_ID, CMID_COPYOBJ,
|
2011-12-04 18:55:23 +04:00
|
|
|
PMIA_UserData, nsurl_access(hlcache_handle_get_url(userdata)),
|
2011-10-02 20:37:25 +04:00
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_CLIPOBJ],
|
|
|
|
PMIA_ID, CMID_CLIPOBJ,
|
|
|
|
PMIA_UserData, userdata,
|
2011-10-08 18:55:15 +04:00
|
|
|
PMIA_Disabled, (content_get_type(userdata) != CONTENT_IMAGE),
|
2011-10-02 20:37:25 +04:00
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_SAVEOBJ],
|
|
|
|
PMIA_ID, CMID_SAVEOBJ,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_SAVEIFFOBJ],
|
|
|
|
PMIA_ID, CMID_SAVEIFFOBJ,
|
|
|
|
PMIA_UserData, userdata,
|
2011-10-08 18:55:15 +04:00
|
|
|
PMIA_Disabled, (content_get_type(userdata) != CONTENT_IMAGE),
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem, NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_PLUGINCMD],
|
|
|
|
PMIA_ID, CMID_PLUGINCMD,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
PMIA_Disabled, !ami_mime_content_to_cmd(userdata),
|
2011-10-02 20:37:25 +04:00
|
|
|
TAG_DONE),
|
|
|
|
TAG_DONE),
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CMSUB_SEL:
|
|
|
|
bw = userdata;
|
2013-03-19 03:06:06 +04:00
|
|
|
BOOL disabled_readonly = !(browser_window_get_editor_flags(bw) & BW_EDITOR_CAN_PASTE);
|
|
|
|
BOOL disabled_noselection = !(browser_window_get_editor_flags(bw) & BW_EDITOR_CAN_COPY);
|
2011-10-02 20:37:25 +04:00
|
|
|
|
|
|
|
IDoMethod(ctxmenuobj,PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMSUB_SEL],
|
|
|
|
PMIA_SubMenu, NewObject(POPUPMENU_GetClass(), NULL,
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_SELCUT],
|
|
|
|
PMIA_ID,CMID_SELCUT,
|
2013-05-12 23:14:29 +04:00
|
|
|
PMIA_Disabled, !(browser_window_get_editor_flags(bw) & BW_EDITOR_CAN_CUT),
|
2011-10-08 19:48:58 +04:00
|
|
|
PMIA_CommKey, "X",
|
2011-10-02 20:37:25 +04:00
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_SELCOPY],
|
|
|
|
PMIA_ID,CMID_SELCOPY,
|
|
|
|
PMIA_Disabled, disabled_noselection,
|
2011-10-08 19:48:58 +04:00
|
|
|
PMIA_CommKey, "C",
|
2011-10-02 20:37:25 +04:00
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_SELPASTE],
|
|
|
|
PMIA_ID,CMID_SELPASTE,
|
|
|
|
PMIA_Disabled, (bw->window->c_h == 0),
|
2011-10-08 19:48:58 +04:00
|
|
|
PMIA_CommKey, "V",
|
2011-10-02 20:37:25 +04:00
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_SELALL],
|
|
|
|
PMIA_ID,CMID_SELALL,
|
2011-10-08 19:48:58 +04:00
|
|
|
PMIA_CommKey, "A",
|
2011-10-02 20:37:25 +04:00
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_SELCLEAR],
|
|
|
|
PMIA_ID,CMID_SELCLEAR,
|
|
|
|
PMIA_Disabled, disabled_noselection,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_SELSEARCH],
|
|
|
|
PMIA_ID,CMID_SELSEARCH,
|
|
|
|
PMIA_Disabled, disabled_noselection,
|
|
|
|
TAG_DONE),
|
2011-10-23 17:15:44 +04:00
|
|
|
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_SELSAVE],
|
|
|
|
PMIA_ID,CMID_SELSAVE,
|
|
|
|
PMIA_Disabled, disabled_noselection,
|
|
|
|
TAG_DONE),
|
2011-10-02 20:37:25 +04:00
|
|
|
TAG_DONE),
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CMID_SELECTFILE:
|
|
|
|
IDoMethod(ctxmenuobj,PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_SELECTFILE],
|
|
|
|
PMIA_ID, CMID_SELECTFILE,
|
|
|
|
PMIA_UserData, userdata,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-25 20:37:08 +04:00
|
|
|
void ami_context_menu_free(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2011-06-23 21:35:35 +04:00
|
|
|
if(ctxmenuobj) DisposeObject(ctxmenuobj);
|
|
|
|
|
2008-10-25 20:37:08 +04:00
|
|
|
for(i=0;i<CMID_LAST;i++)
|
|
|
|
{
|
|
|
|
ami_utf8_free(ctxmenulab[i]);
|
|
|
|
}
|
2011-03-16 21:53:58 +03:00
|
|
|
|
|
|
|
if(IPopupMenu) DropInterface((struct Interface *)IPopupMenu);
|
|
|
|
if(PopupMenuBase) CloseLibrary(PopupMenuBase);
|
2008-10-25 20:37:08 +04:00
|
|
|
}
|
|
|
|
|
2011-02-28 22:31:35 +03:00
|
|
|
BOOL ami_context_menu_mouse_trap(struct gui_window_2 *gwin, BOOL trap)
|
|
|
|
{
|
|
|
|
int top, left, width, height;
|
|
|
|
|
2012-03-22 13:34:34 +04:00
|
|
|
if(nsoption_bool(context_menu) == false) return FALSE;
|
2011-02-28 22:31:35 +03:00
|
|
|
|
2012-03-22 13:34:34 +04:00
|
|
|
if((nsoption_bool(kiosk_mode) == false) && (trap == FALSE))
|
2011-02-28 22:31:35 +03:00
|
|
|
{
|
2011-03-01 23:27:49 +03:00
|
|
|
if(browser_window_back_available(gwin->bw) &&
|
|
|
|
ami_gadget_hit(gwin->objects[GID_BACK],
|
2011-02-28 22:31:35 +03:00
|
|
|
gwin->win->MouseX, gwin->win->MouseY))
|
|
|
|
trap = TRUE;
|
2011-03-01 02:33:03 +03:00
|
|
|
|
2011-03-01 23:27:49 +03:00
|
|
|
if(browser_window_forward_available(gwin->bw) &&
|
|
|
|
ami_gadget_hit(gwin->objects[GID_FORWARD],
|
2011-03-01 02:33:03 +03:00
|
|
|
gwin->win->MouseX, gwin->win->MouseY))
|
|
|
|
trap = TRUE;
|
2011-02-28 22:31:35 +03:00
|
|
|
}
|
|
|
|
|
2011-03-01 02:33:03 +03:00
|
|
|
if(gwin->rmbtrapped == trap) return trap;
|
2011-02-28 22:31:35 +03:00
|
|
|
|
2011-09-03 02:09:23 +04:00
|
|
|
SetWindowAttr(gwin->win, WA_RMBTrap, (APTR)(ULONG)trap, sizeof(BOOL));
|
2011-02-28 22:31:35 +03:00
|
|
|
gwin->rmbtrapped = trap;
|
|
|
|
|
|
|
|
return trap;
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:04:27 +04:00
|
|
|
void ami_context_menu_show(struct gui_window_2 *gwin,int x,int y)
|
|
|
|
{
|
2010-03-28 19:51:05 +04:00
|
|
|
struct hlcache_handle *cc = gwin->bw->current_content;
|
2008-10-21 22:04:27 +04:00
|
|
|
int box_x=0;
|
|
|
|
int box_y=0;
|
2011-10-23 17:15:44 +04:00
|
|
|
bool no_more_menus = false;
|
2009-04-01 21:26:39 +04:00
|
|
|
bool menuhascontent = false;
|
2011-09-02 21:31:47 +04:00
|
|
|
ULONG ret = 0;
|
2011-09-13 22:42:23 +04:00
|
|
|
struct contextual_content ccdata;
|
2008-10-21 22:04:27 +04:00
|
|
|
|
2010-03-21 22:29:33 +03:00
|
|
|
if(!cc) return;
|
2011-06-23 21:35:35 +04:00
|
|
|
if(ctxmenuobj) DisposeObject(ctxmenuobj);
|
2008-10-21 22:04:27 +04:00
|
|
|
|
2011-06-23 21:35:35 +04:00
|
|
|
ctxmenuhook.h_Entry = ami_context_menu_hook;
|
|
|
|
ctxmenuhook.h_SubEntry = NULL;
|
|
|
|
ctxmenuhook.h_Data = gwin;
|
2008-10-21 22:04:27 +04:00
|
|
|
|
2011-06-23 21:35:35 +04:00
|
|
|
ctxmenuobj = NewObject( POPUPMENU_GetClass(), NULL,
|
|
|
|
PMA_MenuHandler, &ctxmenuhook,
|
2008-10-21 22:04:27 +04:00
|
|
|
TAG_DONE);
|
|
|
|
|
2011-02-28 22:31:35 +03:00
|
|
|
if(gwin->bw && gwin->bw->history &&
|
|
|
|
ami_gadget_hit(gwin->objects[GID_BACK],
|
|
|
|
gwin->win->MouseX, gwin->win->MouseY))
|
|
|
|
{
|
2011-03-01 02:46:49 +03:00
|
|
|
gwin->temp = 0;
|
2011-03-01 01:35:53 +03:00
|
|
|
history_enumerate_back(gwin->bw->history, ami_context_menu_history, gwin);
|
|
|
|
|
2011-06-23 21:35:35 +04:00
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
2011-03-01 02:33:03 +03:00
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
|
2011-06-23 21:35:35 +04:00
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
2011-03-01 02:33:03 +03:00
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_HISTORY],
|
|
|
|
PMIA_ID, CMID_HISTORY,
|
|
|
|
PMIA_UserData, NULL,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
|
|
|
|
menuhascontent = true;
|
|
|
|
}
|
|
|
|
else if(gwin->bw && gwin->bw->history &&
|
|
|
|
ami_gadget_hit(gwin->objects[GID_FORWARD],
|
|
|
|
gwin->win->MouseX, gwin->win->MouseY))
|
|
|
|
{
|
2011-03-01 02:46:49 +03:00
|
|
|
gwin->temp = 0;
|
2011-03-01 02:33:03 +03:00
|
|
|
history_enumerate_forward(gwin->bw->history, ami_context_menu_history, gwin);
|
|
|
|
|
2011-06-23 21:35:35 +04:00
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
2011-03-01 02:33:03 +03:00
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
|
2011-06-23 21:35:35 +04:00
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
2011-02-28 22:31:35 +03:00
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_HISTORY],
|
|
|
|
PMIA_ID, CMID_HISTORY,
|
2011-03-01 01:35:53 +03:00
|
|
|
PMIA_UserData, NULL,
|
2011-02-28 22:31:35 +03:00
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
|
|
|
|
menuhascontent = true;
|
|
|
|
}
|
|
|
|
else
|
2008-10-21 22:04:27 +04:00
|
|
|
{
|
2011-10-23 17:15:44 +04:00
|
|
|
if(no_more_menus == false)
|
|
|
|
{
|
|
|
|
browser_window_get_contextual_content(gwin->bw, x, y, &ccdata);
|
|
|
|
|
|
|
|
ami_context_menu_add_submenu(ctxmenuobj, CMSUB_PAGE, cc);
|
|
|
|
menuhascontent = true;
|
|
|
|
|
|
|
|
if(ccdata.main && (ccdata.main != cc))
|
|
|
|
{
|
|
|
|
ami_context_menu_add_submenu(ctxmenuobj, CMSUB_FRAME, ccdata.main);
|
|
|
|
menuhascontent = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ccdata.link_url)
|
|
|
|
{
|
|
|
|
ami_context_menu_add_submenu(ctxmenuobj, CMSUB_URL, (char *)ccdata.link_url);
|
|
|
|
menuhascontent = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ccdata.object)
|
|
|
|
{
|
|
|
|
ami_context_menu_add_submenu(ctxmenuobj, CMSUB_OBJECT, ccdata.object);
|
|
|
|
menuhascontent = true;
|
|
|
|
}
|
|
|
|
|
2012-08-21 01:59:47 +04:00
|
|
|
if(ccdata.form_features == CTX_FORM_FILE)
|
|
|
|
{
|
|
|
|
struct ami_file_input_menu_data file_input = {
|
2012-08-21 02:19:58 +04:00
|
|
|
.x = x,
|
|
|
|
.y = y,
|
|
|
|
.bw = gwin->bw
|
|
|
|
};
|
2012-08-21 01:59:47 +04:00
|
|
|
ami_context_menu_add_submenu(ctxmenuobj, CMID_SELECTFILE, &file_input);
|
|
|
|
menuhascontent = true;
|
|
|
|
}
|
|
|
|
|
2011-10-23 17:15:44 +04:00
|
|
|
ami_context_menu_add_submenu(ctxmenuobj, CMSUB_NAVIGATE, gwin->bw);
|
|
|
|
menuhascontent = true;
|
|
|
|
|
|
|
|
if(content_get_type(cc) == CONTENT_HTML ||
|
|
|
|
content_get_type(cc) == CONTENT_TEXTPLAIN)
|
|
|
|
{
|
|
|
|
ami_context_menu_add_submenu(ctxmenuobj, CMSUB_SEL, gwin->bw);
|
|
|
|
menuhascontent = true;
|
|
|
|
}
|
|
|
|
}
|
2008-10-21 22:04:27 +04:00
|
|
|
}
|
|
|
|
|
2009-04-01 21:26:39 +04:00
|
|
|
if(!menuhascontent) return;
|
|
|
|
|
2011-10-23 17:15:44 +04:00
|
|
|
gui_window_set_pointer(gwin->bw->window, GUI_POINTER_DEFAULT);
|
2011-09-02 21:31:47 +04:00
|
|
|
|
2011-10-23 17:15:44 +04:00
|
|
|
IDoMethod(ctxmenuobj, PM_OPEN, gwin->win);
|
2008-10-21 22:04:27 +04:00
|
|
|
}
|
|
|
|
|
2011-03-01 01:35:53 +03:00
|
|
|
static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved)
|
2008-10-21 22:04:27 +04:00
|
|
|
{
|
|
|
|
int32 itemid = 0;
|
|
|
|
struct gui_window_2 *gwin = hook->h_Data;
|
|
|
|
APTR userdata = NULL;
|
2008-10-25 20:37:08 +04:00
|
|
|
struct browser_window *bw;
|
2010-03-28 19:51:05 +04:00
|
|
|
struct hlcache_handle *object;
|
2011-07-23 18:06:13 +04:00
|
|
|
const char *source_data;
|
2010-03-28 19:51:05 +04:00
|
|
|
ULONG source_size;
|
|
|
|
struct bitmap *bm;
|
2013-02-14 22:21:11 +04:00
|
|
|
nsurl *url;
|
|
|
|
nserror error;
|
2008-10-21 22:04:27 +04:00
|
|
|
|
|
|
|
if(GetAttrs(item,PMIA_ID,&itemid,
|
|
|
|
PMIA_UserData,&userdata,
|
|
|
|
TAG_DONE))
|
|
|
|
{
|
|
|
|
switch(itemid)
|
|
|
|
{
|
|
|
|
case CMID_SELECTFILE:
|
2008-10-25 20:37:08 +04:00
|
|
|
if(AslRequestTags(filereq,
|
2013-05-25 16:59:42 +04:00
|
|
|
ASLFR_Window, gwin->win,
|
|
|
|
ASLFR_SleepWindow, TRUE,
|
2008-10-25 20:37:08 +04:00
|
|
|
ASLFR_TitleText,messages_get("NetSurf"),
|
|
|
|
ASLFR_Screen,scrn,
|
|
|
|
ASLFR_DoSaveMode,FALSE,
|
|
|
|
TAG_DONE))
|
|
|
|
{
|
2012-08-21 01:59:47 +04:00
|
|
|
struct ami_file_input_menu_data
|
|
|
|
*file_input = userdata;
|
2008-10-25 20:37:08 +04:00
|
|
|
char *utf8_fn;
|
|
|
|
char fname[1024];
|
|
|
|
int x,y;
|
|
|
|
|
2011-07-23 18:06:13 +04:00
|
|
|
strlcpy(fname,filereq->fr_Drawer,1024);
|
2008-10-25 20:37:08 +04:00
|
|
|
AddPart(fname,filereq->fr_File,1024);
|
|
|
|
|
|
|
|
if(utf8_from_local_encoding(fname,0,&utf8_fn) != UTF8_CONVERT_OK)
|
|
|
|
{
|
|
|
|
warn_user("NoMemory","");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-08-21 01:59:47 +04:00
|
|
|
browser_window_drop_file_at_point(
|
|
|
|
file_input->bw,
|
|
|
|
file_input->x,
|
|
|
|
file_input->y,
|
|
|
|
utf8_fn);
|
2008-10-25 20:37:08 +04:00
|
|
|
}
|
2008-10-21 22:04:27 +04:00
|
|
|
break;
|
|
|
|
|
2011-10-15 18:09:35 +04:00
|
|
|
case CMID_PAGEOPEN:
|
|
|
|
ami_file_open(gwin);
|
|
|
|
break;
|
|
|
|
|
2011-10-23 17:15:44 +04:00
|
|
|
case CMID_PAGECLOSE:
|
|
|
|
browser_window_destroy(gwin->bw);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CMID_URLHOTLIST:
|
|
|
|
case CMID_PAGEHOTLIST:
|
2013-09-03 01:41:04 +04:00
|
|
|
{
|
2013-10-13 15:01:11 +04:00
|
|
|
if (nsurl_create(userdata, &url) != NSERROR_OK)
|
2013-09-03 01:41:04 +04:00
|
|
|
break;
|
|
|
|
|
2013-10-13 15:01:11 +04:00
|
|
|
hotlist_add_url(url);
|
|
|
|
nsurl_unref(url);
|
2013-11-23 16:23:56 +04:00
|
|
|
ami_gui_update_hotlist_button(gwin);
|
2013-09-03 01:41:04 +04:00
|
|
|
}
|
2011-10-23 17:15:44 +04:00
|
|
|
break;
|
|
|
|
|
2011-09-25 22:44:10 +04:00
|
|
|
case CMID_FRAMECOPYURL:
|
2008-10-21 22:04:27 +04:00
|
|
|
case CMID_COPYURL:
|
2008-10-25 20:37:08 +04:00
|
|
|
case CMID_COPYOBJ:
|
|
|
|
ami_easy_clipboard((char *)userdata);
|
2008-10-21 22:04:27 +04:00
|
|
|
break;
|
|
|
|
|
2011-09-25 22:44:10 +04:00
|
|
|
case CMID_FRAMEWIN:
|
2008-10-25 20:37:08 +04:00
|
|
|
case CMID_URLOPENWIN:
|
2013-02-14 22:21:11 +04:00
|
|
|
error = nsurl_create(userdata, &url);
|
|
|
|
if (error == NSERROR_OK) {
|
2013-02-18 15:51:42 +04:00
|
|
|
error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
|
|
|
|
BROWSER_WINDOW_HISTORY,
|
2013-02-14 22:21:11 +04:00
|
|
|
url,
|
|
|
|
hlcache_handle_get_url(gwin->bw->current_content),
|
|
|
|
gwin->bw,
|
|
|
|
&bw);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
warn_user(messages_get_errorcode(error), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-25 20:37:08 +04:00
|
|
|
break;
|
|
|
|
|
2011-09-25 22:44:10 +04:00
|
|
|
case CMID_FRAMETAB:
|
2008-10-25 20:37:08 +04:00
|
|
|
case CMID_URLOPENTAB:
|
2013-02-14 22:21:11 +04:00
|
|
|
error = nsurl_create(userdata, &url);
|
|
|
|
if (error == NSERROR_OK) {
|
2013-02-18 15:51:42 +04:00
|
|
|
error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
|
|
|
|
BROWSER_WINDOW_HISTORY |
|
|
|
|
BROWSER_WINDOW_TAB,
|
2013-02-14 22:21:11 +04:00
|
|
|
url,
|
|
|
|
hlcache_handle_get_url(gwin->bw->current_content),
|
|
|
|
gwin->bw,
|
|
|
|
&bw);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
warn_user(messages_get_errorcode(error), 0);
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:04:27 +04:00
|
|
|
break;
|
|
|
|
|
2011-09-25 22:44:10 +04:00
|
|
|
case CMID_FRAMESAVE:
|
2009-02-01 02:45:25 +03:00
|
|
|
case CMID_SAVEURL:
|
2013-02-14 19:09:28 +04:00
|
|
|
{
|
|
|
|
nsurl *url;
|
|
|
|
if (nsurl_create(userdata, &url) != NSERROR_OK) {
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
} else {
|
|
|
|
browser_window_navigate(gwin->bw,
|
|
|
|
url,
|
|
|
|
hlcache_handle_get_url(gwin->bw->current_content),
|
2013-02-18 15:51:42 +04:00
|
|
|
BROWSER_WINDOW_DOWNLOAD |
|
|
|
|
BROWSER_WINDOW_VERIFIABLE,
|
2013-02-14 19:09:28 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
}
|
2009-02-01 02:45:25 +03:00
|
|
|
break;
|
|
|
|
|
2011-09-25 22:44:10 +04:00
|
|
|
case CMID_FRAMESHOW:
|
2008-10-25 20:37:08 +04:00
|
|
|
case CMID_SHOWOBJ:
|
2013-02-14 19:09:28 +04:00
|
|
|
browser_window_navigate(gwin->bw,
|
|
|
|
hlcache_handle_get_url(userdata),
|
|
|
|
hlcache_handle_get_url(gwin->bw->current_content),
|
2013-02-18 15:51:42 +04:00
|
|
|
BROWSER_WINDOW_HISTORY |
|
|
|
|
BROWSER_WINDOW_VERIFIABLE,
|
2013-02-14 19:09:28 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
2008-10-21 22:04:27 +04:00
|
|
|
break;
|
2008-12-14 02:26:10 +03:00
|
|
|
|
2011-10-09 21:37:57 +04:00
|
|
|
case CMID_URLOPEN:
|
2013-02-14 19:09:28 +04:00
|
|
|
{
|
|
|
|
nsurl *url;
|
|
|
|
if (nsurl_create(userdata, &url) != NSERROR_OK) {
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
} else {
|
|
|
|
browser_window_navigate(gwin->bw,
|
|
|
|
url,
|
|
|
|
hlcache_handle_get_url(gwin->bw->current_content),
|
2013-02-18 15:51:42 +04:00
|
|
|
BROWSER_WINDOW_HISTORY |
|
|
|
|
BROWSER_WINDOW_VERIFIABLE,
|
2013-02-14 19:09:28 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
}
|
2011-10-09 21:37:57 +04:00
|
|
|
break;
|
|
|
|
|
2011-09-25 22:44:10 +04:00
|
|
|
case CMID_FRAMERELOAD:
|
|
|
|
case CMID_RELOADOBJ:
|
|
|
|
object = (struct hlcache_handle *)userdata;
|
|
|
|
content_invalidate_reuse_data(object);
|
|
|
|
browser_window_reload(gwin->bw, false);
|
|
|
|
break;
|
|
|
|
|
2009-05-16 18:50:30 +04:00
|
|
|
case CMID_CLIPOBJ:
|
2010-03-28 19:51:05 +04:00
|
|
|
object = (struct hlcache_handle *)userdata;
|
|
|
|
if((bm = content_get_bitmap(object)))
|
2009-05-19 11:23:56 +04:00
|
|
|
{
|
2011-12-04 18:55:23 +04:00
|
|
|
bm->url = (char *)nsurl_access(hlcache_handle_get_url(object));
|
2011-07-23 18:06:13 +04:00
|
|
|
bm->title = (char *)content_get_title(object);
|
2010-03-28 19:51:05 +04:00
|
|
|
ami_easy_clipboard_bitmap(bm);
|
2009-05-19 11:23:56 +04:00
|
|
|
}
|
|
|
|
#ifdef WITH_NS_SVG
|
2011-05-07 00:40:09 +04:00
|
|
|
else if(ami_mime_compare(object, "svg") == true)
|
2009-05-19 11:23:56 +04:00
|
|
|
{
|
|
|
|
ami_easy_clipboard_svg(object);
|
|
|
|
}
|
|
|
|
#endif
|
2009-05-16 18:50:30 +04:00
|
|
|
break;
|
|
|
|
|
2008-12-14 02:26:10 +03:00
|
|
|
case CMID_SAVEOBJ:
|
2011-10-09 21:37:57 +04:00
|
|
|
case CMID_PAGESAVE:
|
2011-10-23 17:15:44 +04:00
|
|
|
ami_file_save_req(AMINS_SAVE_SOURCE, gwin,
|
2013-02-22 23:02:58 +04:00
|
|
|
(struct hlcache_handle *)userdata);
|
2011-10-15 18:55:03 +04:00
|
|
|
break;
|
2010-03-28 19:51:05 +04:00
|
|
|
|
2011-10-15 18:55:03 +04:00
|
|
|
case CMID_PAGESAVECOMPLETE:
|
2011-10-23 17:15:44 +04:00
|
|
|
case CMID_FRAMESAVECOMPLETE:
|
|
|
|
ami_file_save_req(AMINS_SAVE_COMPLETE, gwin,
|
2013-02-22 23:02:58 +04:00
|
|
|
(struct hlcache_handle *)userdata);
|
2008-12-14 02:26:10 +03:00
|
|
|
break;
|
2009-01-16 22:13:07 +03:00
|
|
|
|
2009-05-16 18:50:30 +04:00
|
|
|
case CMID_SAVEIFFOBJ:
|
2011-10-23 17:15:44 +04:00
|
|
|
ami_file_save_req(AMINS_SAVE_IFF, gwin,
|
2013-02-22 23:02:58 +04:00
|
|
|
(struct hlcache_handle *)userdata);
|
2009-05-16 18:50:30 +04:00
|
|
|
break;
|
|
|
|
|
2011-05-11 22:33:31 +04:00
|
|
|
case CMID_PLUGINCMD:
|
|
|
|
amiga_plugin_hack_execute((struct hlcache_handle *)userdata);
|
|
|
|
break;
|
|
|
|
|
2011-02-28 22:31:35 +03:00
|
|
|
case CMID_HISTORY:
|
2011-03-01 01:35:53 +03:00
|
|
|
if(userdata == NULL)
|
|
|
|
{
|
|
|
|
ami_history_open(gwin->bw, gwin->bw->history);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
history_go(gwin->bw, gwin->bw->history,
|
|
|
|
(struct history_entry *)userdata, false);
|
|
|
|
}
|
2011-02-28 22:31:35 +03:00
|
|
|
break;
|
|
|
|
|
2011-10-08 17:48:44 +04:00
|
|
|
case CMID_NAVHOME:
|
2013-02-14 19:09:28 +04:00
|
|
|
{
|
|
|
|
nsurl *url;
|
|
|
|
|
|
|
|
if (nsurl_create(nsoption_charp(homepage_url), &url) != NSERROR_OK) {
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
} else {
|
|
|
|
browser_window_navigate(gwin->bw,
|
|
|
|
url,
|
|
|
|
NULL,
|
2013-02-18 15:51:42 +04:00
|
|
|
BROWSER_WINDOW_HISTORY |
|
|
|
|
BROWSER_WINDOW_VERIFIABLE,
|
2013-02-14 19:09:28 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2011-10-08 17:48:44 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CMID_NAVBACK:
|
|
|
|
ami_gui_history(gwin, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CMID_NAVFORWARD:
|
|
|
|
ami_gui_history(gwin, false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CMID_NAVSTOP:
|
|
|
|
if(browser_window_stop_available(gwin->bw))
|
|
|
|
browser_window_stop(gwin->bw);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CMID_NAVRELOAD:
|
|
|
|
if(browser_window_reload_available(gwin->bw))
|
|
|
|
browser_window_reload(gwin->bw, true);
|
|
|
|
break;
|
|
|
|
|
2010-07-24 20:39:37 +04:00
|
|
|
case CMID_SELCUT:
|
|
|
|
browser_window_key_press(gwin->bw, KEY_CUT_SELECTION);
|
|
|
|
break;
|
|
|
|
|
2009-01-16 22:13:07 +03:00
|
|
|
case CMID_SELCOPY:
|
2009-02-01 16:01:46 +03:00
|
|
|
browser_window_key_press(gwin->bw, KEY_COPY_SELECTION);
|
|
|
|
browser_window_key_press(gwin->bw, KEY_CLEAR_SELECTION);
|
2009-01-16 22:13:07 +03:00
|
|
|
break;
|
|
|
|
|
2010-07-24 20:39:37 +04:00
|
|
|
case CMID_SELPASTE:
|
|
|
|
browser_window_key_press(gwin->bw, KEY_PASTE);
|
|
|
|
break;
|
|
|
|
|
2009-01-16 22:13:07 +03:00
|
|
|
case CMID_SELALL:
|
2009-02-01 16:01:46 +03:00
|
|
|
browser_window_key_press(gwin->bw, KEY_SELECT_ALL);
|
2010-08-08 13:23:34 +04:00
|
|
|
gui_start_selection(gwin->bw->window);
|
2009-01-16 22:13:07 +03:00
|
|
|
break;
|
2010-07-24 20:39:37 +04:00
|
|
|
|
|
|
|
case CMID_SELCLEAR:
|
|
|
|
browser_window_key_press(gwin->bw, KEY_CLEAR_SELECTION);
|
|
|
|
break;
|
2011-02-10 01:16:11 +03:00
|
|
|
|
2011-10-23 17:15:44 +04:00
|
|
|
case CMID_SELSAVE:
|
2013-02-22 23:02:58 +04:00
|
|
|
ami_file_save_req(AMINS_SAVE_SELECTION, gwin, NULL);
|
2011-10-23 17:15:44 +04:00
|
|
|
break;
|
|
|
|
|
2011-02-10 01:16:11 +03:00
|
|
|
case CMID_SELSEARCH:
|
|
|
|
{
|
2013-02-22 23:06:13 +04:00
|
|
|
char *sel;
|
2013-02-14 19:09:28 +04:00
|
|
|
char *urltxt;
|
|
|
|
nsurl *url;
|
2011-02-10 01:16:11 +03:00
|
|
|
|
2013-02-22 23:06:13 +04:00
|
|
|
if(sel = browser_window_get_selection(gwin->bw))
|
2011-02-10 01:16:11 +03:00
|
|
|
{
|
2013-02-22 23:06:13 +04:00
|
|
|
urltxt = search_web_from_term(sel);
|
2013-02-14 19:09:28 +04:00
|
|
|
|
|
|
|
if (nsurl_create(urltxt, &url) != NSERROR_OK) {
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
} else {
|
|
|
|
browser_window_navigate(gwin->bw,
|
|
|
|
url,
|
|
|
|
NULL,
|
2013-02-18 15:51:42 +04:00
|
|
|
BROWSER_WINDOW_HISTORY |
|
|
|
|
BROWSER_WINDOW_VERIFIABLE,
|
2013-02-14 19:09:28 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
2013-02-22 23:06:13 +04:00
|
|
|
free(sel);
|
2011-02-10 01:16:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2008-10-21 22:04:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return itemid;
|
|
|
|
}
|
2011-02-10 01:16:11 +03:00
|
|
|
|
2011-12-17 22:47:35 +04:00
|
|
|
void ami_context_menu_show_tree(struct tree *tree, struct Window *win, int type)
|
|
|
|
{
|
2013-09-12 13:51:39 +04:00
|
|
|
#if 0
|
2011-12-17 22:47:35 +04:00
|
|
|
struct node *root = tree_get_root(tree);
|
|
|
|
struct node *sel_node = tree_get_selected_node(root);
|
|
|
|
bool has_selection = tree_node_has_selection(root);
|
2011-12-18 21:59:23 +04:00
|
|
|
bool menu_content = false;
|
2011-12-17 22:47:35 +04:00
|
|
|
|
|
|
|
if(ctxmenuobj) DisposeObject(ctxmenuobj);
|
|
|
|
|
|
|
|
ctxmenuhook.h_Entry = ami_context_menu_hook_tree;
|
|
|
|
ctxmenuhook.h_SubEntry = NULL;
|
|
|
|
ctxmenuhook.h_Data = tree;
|
|
|
|
|
|
|
|
ctxmenuobj = NewObject( POPUPMENU_GetClass(), NULL,
|
|
|
|
PMA_MenuHandler, &ctxmenuhook,
|
|
|
|
TAG_DONE);
|
|
|
|
|
|
|
|
if(has_selection && (type != AMI_TREE_COOKIES) &&
|
|
|
|
((sel_node == NULL) ||
|
|
|
|
(tree_node_is_folder(sel_node) == false))) {
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_TREE_LAUNCH],
|
|
|
|
PMIA_ID, CMID_TREE_LAUNCH,
|
|
|
|
PMIA_UserData, NULL,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
|
2011-12-18 21:59:23 +04:00
|
|
|
menu_content = true;
|
|
|
|
}
|
2011-12-17 22:47:35 +04:00
|
|
|
|
|
|
|
if(type == AMI_TREE_HOTLIST) {
|
2011-12-18 21:59:23 +04:00
|
|
|
if(menu_content == true) {
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
|
|
|
|
menu_content = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(has_selection && (sel_node != NULL)) {
|
|
|
|
if(tree_node_is_folder(sel_node) == true) {
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_TREE_EDITFOLDER],
|
|
|
|
PMIA_ID, CMID_TREE_EDITFOLDER,
|
|
|
|
PMIA_UserData, NULL,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_TREE_EDITTITLE],
|
|
|
|
PMIA_ID, CMID_TREE_EDITTITLE,
|
|
|
|
PMIA_UserData, sel_node,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_TREE_EDITLINK],
|
|
|
|
PMIA_ID, CMID_TREE_EDITLINK,
|
|
|
|
PMIA_UserData, sel_node,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
}
|
|
|
|
menu_content = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(menu_content == true) {
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
|
|
|
|
menu_content = false;
|
|
|
|
}
|
2011-12-17 22:47:35 +04:00
|
|
|
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_TREE_NEWFOLDER],
|
|
|
|
PMIA_ID, CMID_TREE_NEWFOLDER,
|
|
|
|
PMIA_UserData, NULL,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_TREE_NEWITEM],
|
|
|
|
PMIA_ID, CMID_TREE_NEWITEM,
|
|
|
|
PMIA_UserData, NULL,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
2011-12-18 21:59:23 +04:00
|
|
|
|
|
|
|
if(has_selection && (sel_node != NULL) &&
|
|
|
|
(tree_node_is_folder(sel_node) == true)) {
|
|
|
|
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
|
|
|
|
if(tree_node_is_default(sel_node) == true)
|
|
|
|
{
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_TREE_CLEARDEFAULT],
|
|
|
|
PMIA_ID, CMID_TREE_CLEARDEFAULT,
|
|
|
|
PMIA_UserData, NULL,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_TREE_SETDEFAULT],
|
|
|
|
PMIA_ID, CMID_TREE_SETDEFAULT,
|
|
|
|
PMIA_UserData, NULL,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
menu_content = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((type == AMI_TREE_HISTORY) && has_selection &&
|
|
|
|
(sel_node != NULL) && (tree_node_is_folder(sel_node) == false)) {
|
|
|
|
if(menu_content == true) {
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_TREE_ADDHOTLIST],
|
|
|
|
PMIA_ID, CMID_TREE_ADDHOTLIST,
|
|
|
|
PMIA_UserData, sel_node,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
|
|
|
|
menu_content = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(has_selection) {
|
|
|
|
if(menu_content == true) {
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, ~0,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ctxmenulab[CMID_TREE_DELETE],
|
|
|
|
PMIA_ID, CMID_TREE_DELETE,
|
|
|
|
PMIA_UserData, root,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
|
|
|
|
menu_content = true;
|
2011-12-17 22:47:35 +04:00
|
|
|
}
|
|
|
|
|
2011-12-18 21:59:23 +04:00
|
|
|
if(menu_content == true)
|
|
|
|
IDoMethod(ctxmenuobj, PM_OPEN, win);
|
2013-09-12 13:51:39 +04:00
|
|
|
#endif
|
2011-12-17 22:47:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR reserved)
|
|
|
|
{
|
|
|
|
int32 itemid = 0;
|
|
|
|
struct tree *tree = hook->h_Data;
|
|
|
|
APTR userdata = NULL;
|
|
|
|
|
|
|
|
if(GetAttrs(item,PMIA_ID, &itemid,
|
|
|
|
PMIA_UserData, &userdata,
|
|
|
|
TAG_DONE))
|
|
|
|
{
|
|
|
|
switch(itemid)
|
|
|
|
{
|
|
|
|
case CMID_TREE_LAUNCH:
|
2013-09-12 20:12:45 +04:00
|
|
|
tree_keypress(tree, KEY_CR);
|
2011-12-17 22:47:35 +04:00
|
|
|
break;
|
|
|
|
|
2011-12-18 21:59:23 +04:00
|
|
|
case CMID_TREE_EDITFOLDER:
|
2013-09-03 01:41:04 +04:00
|
|
|
hotlist_edit_selection();
|
2011-12-18 21:59:23 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CMID_TREE_EDITTITLE:
|
2013-09-02 17:17:09 +04:00
|
|
|
warn_user("TODO.", 0);
|
2011-12-18 21:59:23 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CMID_TREE_EDITLINK:
|
2013-09-02 17:17:09 +04:00
|
|
|
warn_user("TODO.", 0);
|
2011-12-18 21:59:23 +04:00
|
|
|
break;
|
|
|
|
|
2011-12-17 22:47:35 +04:00
|
|
|
case CMID_TREE_NEWFOLDER:
|
2013-09-03 01:41:04 +04:00
|
|
|
hotlist_add_folder(NULL, false, 0);
|
2011-12-17 22:47:35 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CMID_TREE_NEWITEM:
|
2013-09-03 01:41:04 +04:00
|
|
|
hotlist_add_entry(NULL, NULL, false, 0);
|
2011-12-17 22:47:35 +04:00
|
|
|
break;
|
2011-12-18 21:59:23 +04:00
|
|
|
|
|
|
|
case CMID_TREE_SETDEFAULT:
|
2013-09-02 17:17:09 +04:00
|
|
|
warn_user("TODO.", 0);
|
2011-12-18 21:59:23 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CMID_TREE_CLEARDEFAULT:
|
2013-09-02 17:17:09 +04:00
|
|
|
warn_user("TODO.", 0);
|
2011-12-18 21:59:23 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CMID_TREE_ADDHOTLIST:
|
2013-09-02 17:17:09 +04:00
|
|
|
warn_user("TODO.", 0);
|
2011-12-18 21:59:23 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CMID_TREE_DELETE:
|
2013-09-12 13:58:19 +04:00
|
|
|
tree_keypress(tree, KEY_DELETE_RIGHT);
|
2011-12-18 21:59:23 +04:00
|
|
|
break;
|
2011-12-17 22:47:35 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return itemid;
|
|
|
|
}
|
|
|
|
|
2011-03-01 01:35:53 +03:00
|
|
|
static bool ami_context_menu_history(const struct history *history, int x0, int y0,
|
|
|
|
int x1, int y1, const struct history_entry *entry, void *user_data)
|
|
|
|
{
|
|
|
|
struct gui_window_2 *gwin = (struct gui_window_2 *)user_data;
|
|
|
|
|
2011-03-01 02:46:49 +03:00
|
|
|
gwin->temp++;
|
|
|
|
if(gwin->temp > 10) return false;
|
|
|
|
|
2011-06-23 21:35:35 +04:00
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
2011-03-01 01:35:53 +03:00
|
|
|
NewObject(POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)history_entry_get_title(entry),
|
|
|
|
PMIA_ID, CMID_HISTORY,
|
|
|
|
PMIA_UserData, entry,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
2011-03-01 02:46:49 +03:00
|
|
|
|
|
|
|
return true;
|
2011-03-01 01:35:53 +03:00
|
|
|
}
|
2011-03-16 21:53:58 +03:00
|
|
|
|
2011-06-23 21:35:35 +04:00
|
|
|
static uint32 ami_popup_hook(struct Hook *hook,Object *item,APTR reserved)
|
2011-03-16 21:53:58 +03:00
|
|
|
{
|
|
|
|
int32 itemid = 0;
|
|
|
|
struct gui_window *gwin = hook->h_Data;
|
|
|
|
|
|
|
|
if(GetAttr(PMIA_ID, item, &itemid))
|
|
|
|
{
|
|
|
|
form_select_process_selection(gwin->shared->bw->current_content,gwin->shared->control,itemid);
|
|
|
|
}
|
|
|
|
|
|
|
|
return itemid;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_create_form_select_menu(struct browser_window *bw,
|
|
|
|
struct form_control *control)
|
|
|
|
{
|
|
|
|
/* TODO: PMIA_Title memory leaks as we don't free the strings.
|
|
|
|
* We use the core menu anyway, but in future when popupmenu.class
|
|
|
|
* improves we will probably start using this again.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct gui_window *gwin = bw->window;
|
|
|
|
struct form_option *opt = control->data.select.items;
|
|
|
|
ULONG i = 0;
|
|
|
|
|
2011-06-23 21:35:35 +04:00
|
|
|
if(ctxmenuobj) DisposeObject(ctxmenuobj);
|
2011-03-16 21:53:58 +03:00
|
|
|
|
2011-06-23 21:35:35 +04:00
|
|
|
ctxmenuhook.h_Entry = ami_popup_hook;
|
|
|
|
ctxmenuhook.h_SubEntry = NULL;
|
|
|
|
ctxmenuhook.h_Data = gwin;
|
2011-03-16 21:53:58 +03:00
|
|
|
|
|
|
|
gwin->shared->control = control;
|
|
|
|
|
2011-06-23 21:35:35 +04:00
|
|
|
ctxmenuobj = PMMENU(ami_utf8_easy(control->name)),
|
|
|
|
PMA_MenuHandler, &ctxmenuhook, End;
|
2011-03-16 21:53:58 +03:00
|
|
|
|
|
|
|
while(opt)
|
|
|
|
{
|
2011-06-23 21:35:35 +04:00
|
|
|
IDoMethod(ctxmenuobj, PM_INSERT,
|
2011-03-16 21:53:58 +03:00
|
|
|
NewObject( POPUPMENU_GetItemClass(), NULL,
|
|
|
|
PMIA_Title, (ULONG)ami_utf8_easy(opt->text),
|
|
|
|
PMIA_ID, i,
|
|
|
|
PMIA_CheckIt, TRUE,
|
|
|
|
PMIA_Checked, opt->selected,
|
|
|
|
TAG_DONE),
|
|
|
|
~0);
|
|
|
|
|
|
|
|
opt = opt->next;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
gui_window_set_pointer(gwin, GUI_POINTER_DEFAULT); // Clear the menu-style pointer
|
|
|
|
|
2011-06-23 21:35:35 +04:00
|
|
|
IDoMethod(ctxmenuobj, PM_OPEN, gwin->shared->win);
|
2011-03-16 21:53:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
void ami_context_menu_init(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ami_context_menu_free(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL ami_context_menu_mouse_trap(struct gui_window_2 *gwin, BOOL trap)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ami_context_menu_show(struct gui_window_2 *gwin, int x, int y)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_create_form_select_menu(struct browser_window *bw,
|
|
|
|
struct form_control *control)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|