mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-23 06:51:26 +03:00
Added context menu option to download the link target.
Added SAVEAS/K to OPEN ARexx command to download a URL instead of displaying it. svn path=/trunk/netsurf/; revision=6326
This commit is contained in:
parent
400ed91129
commit
4cf6935761
@ -54,7 +54,7 @@ STATIC VOID rx_save(struct ARexxCmd *, struct RexxMsg *);
|
||||
|
||||
STATIC struct ARexxCmd Commands[] =
|
||||
{
|
||||
{"OPEN",RX_OPEN,rx_open,"URL/A,NEW=NEWWINDOW/S", 0, NULL, 0, 0, NULL },
|
||||
{"OPEN",RX_OPEN,rx_open,"URL/A,NEW=NEWWINDOW/S,SAVEAS/K", 0, NULL, 0, 0, NULL },
|
||||
{"QUIT",RX_QUIT,rx_quit,NULL, 0, NULL, 0, 0, NULL },
|
||||
{"TOFRONT",RX_TOFRONT,rx_tofront,NULL, 0, NULL, 0, 0, NULL },
|
||||
{"GETURL",RX_GETURL,rx_geturl,NULL, 0, NULL, 0, 0, NULL },
|
||||
@ -79,7 +79,7 @@ BOOL ami_arexx_init(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Create a temporary ARexx port so will can send commands to the NetSurf which
|
||||
/* Create a temporary ARexx port so we can send commands to the NetSurf which
|
||||
* is already running */
|
||||
arexx_obj = ARexxObject,
|
||||
AREXX_HostName,"NETSURF",
|
||||
@ -109,7 +109,12 @@ void ami_arexx_cleanup(void)
|
||||
|
||||
STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
||||
{
|
||||
if(cmd->ac_ArgList[1])
|
||||
if(cmd->ac_ArgList[2])
|
||||
{
|
||||
curbw->window->dlfilename = strdup(cmd->ac_ArgList[2]);
|
||||
browser_window_download(curbw,(char *)cmd->ac_ArgList[0],NULL);
|
||||
}
|
||||
else if(cmd->ac_ArgList[1])
|
||||
{
|
||||
browser_window_create((char *)cmd->ac_ArgList[0],NULL,NULL,true,false);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ void ami_context_menu_init(void)
|
||||
ctxmenulab[CMID_SHOWOBJ] = ami_utf8_easy((char *)messages_get("ObjShow"));
|
||||
ctxmenulab[CMID_COPYOBJ] = ami_utf8_easy((char *)messages_get("CopyURL"));
|
||||
ctxmenulab[CMID_SAVEOBJ] = ami_utf8_easy((char *)messages_get("ObjSave"));
|
||||
|
||||
ctxmenulab[CMID_SAVEURL] = ami_utf8_easy((char *)messages_get("LinkDload"));
|
||||
ctxmenulab[CMID_URLOPENWIN] = ami_utf8_easy((char *)messages_get("LinkNewWin"));
|
||||
ctxmenulab[CMID_URLOPENTAB] = ami_utf8_easy((char *)messages_get("LinkNewTab"));
|
||||
|
||||
@ -108,6 +108,11 @@ void ami_context_menu_show(struct gui_window_2 *gwin,int x,int y)
|
||||
PMIA_ID,CMID_COPYURL,
|
||||
PMIA_UserData,curbox->href,
|
||||
TAG_DONE),
|
||||
PMA_AddItem,NewObject(POPUPMENU_GetItemClass(), NULL,
|
||||
PMIA_Title, (ULONG)ctxmenulab[CMID_SAVEURL],
|
||||
PMIA_ID,CMID_SAVEURL,
|
||||
PMIA_UserData,curbox->href,
|
||||
TAG_DONE),
|
||||
TAG_DONE),
|
||||
TAG_DONE),
|
||||
~0);
|
||||
@ -239,6 +244,10 @@ uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved)
|
||||
bw = browser_window_create(userdata,gwin->bw, gwin->bw->current_content->url, true, true);
|
||||
break;
|
||||
|
||||
case CMID_SAVEURL:
|
||||
browser_window_download(gwin->bw,userdata,gwin->bw->current_content->url);
|
||||
break;
|
||||
|
||||
case CMID_SHOWOBJ:
|
||||
browser_window_go(gwin->bw,userdata,gwin->bw->current_content->url,true);
|
||||
break;
|
||||
|
@ -25,6 +25,7 @@ enum {
|
||||
CMID_COPYURL,
|
||||
CMID_URLOPENWIN,
|
||||
CMID_URLOPENTAB,
|
||||
CMID_SAVEURL,
|
||||
CMID_SHOWOBJ,
|
||||
CMID_COPYOBJ,
|
||||
CMID_SAVEOBJ,
|
||||
|
2
amiga/dist/NetSurf.guide
vendored
2
amiga/dist/NetSurf.guide
vendored
@ -54,7 +54,7 @@ NetSurf's ARexx port is called NETSURF.
|
||||
|
||||
Commands are:
|
||||
|
||||
@{b}OPEN URL/A,NEW=NEWWINDOW/S@{ub} Opens URL in current window or a new window if NEWWINDOW is specified.
|
||||
@{b}OPEN URL/A,NEW=NEWWINDOW/S,SAVEAS/K@{ub} Opens URL in current window or a new window if NEWWINDOW is specified. Saves the location without displaying if SAVEAS and a filename is specified (SAVEAS available in 2.6325)
|
||||
@{b}SAVE FILENAME/A@{ub} (2.6027) Saves current page source to FILENAME
|
||||
@{b}QUIT@{ub} Quits NetSurf
|
||||
@{b}TOFRONT@{ub} Brings NetSurf's screen to the front
|
||||
|
82
amiga/gui.c
82
amiga/gui.c
@ -717,7 +717,7 @@ void ami_handle_msg(void)
|
||||
GetAttr(SPACE_AreaBox,gwin->gadgets[GID_BROWSER],(ULONG *)&bbox);
|
||||
|
||||
GetAttr(SCROLLER_Top,gwin->objects[OID_HSCROLL],(ULONG *)&xs);
|
||||
x = gwin->win->MouseX - bbox->Left +xs;
|
||||
x = gwin->win->MouseX - bbox->Left +xs; // mousex should be in intuimessage
|
||||
|
||||
GetAttr(SCROLLER_Top,gwin->objects[OID_VSCROLL],(ULONG *)&ys);
|
||||
y = gwin->win->MouseY - bbox->Top + ys;
|
||||
@ -1971,6 +1971,57 @@ void gui_window_set_title(struct gui_window *g, const char *title)
|
||||
void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1)
|
||||
{
|
||||
gui_window_redraw_window(g); // temporary
|
||||
#if 0
|
||||
this doesn't actually redraw the section as it should...
|
||||
struct content *c;
|
||||
ULONG hcurrent,vcurrent,xoffset,yoffset,width=800,height=600;
|
||||
struct IBox *bbox;
|
||||
ULONG cur_tab = 0;
|
||||
|
||||
if(!g) return;
|
||||
|
||||
if(g->tab_node) GetAttr(CLICKTAB_Current,g->shared->gadgets[GID_TABS],(ULONG *)&cur_tab);
|
||||
|
||||
if(!((cur_tab == g->tab) || (g->shared->tabs == 0)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GetAttr(SPACE_AreaBox,g->shared->gadgets[GID_BROWSER],(ULONG *)&bbox);
|
||||
GetAttr(SCROLLER_Top,g->shared->objects[OID_HSCROLL],(ULONG *)&hcurrent);
|
||||
GetAttr(SCROLLER_Top,g->shared->objects[OID_VSCROLL],(ULONG *)&vcurrent);
|
||||
|
||||
c = g->shared->bw->current_content;
|
||||
|
||||
if(!c) return;
|
||||
if (c->locked) return;
|
||||
|
||||
current_redraw_browser = g->shared->bw;
|
||||
|
||||
width=bbox->Width;
|
||||
height=bbox->Height;
|
||||
xoffset=bbox->Left+x0;
|
||||
yoffset=bbox->Top+y0;
|
||||
|
||||
plot=amiplot;
|
||||
|
||||
// if (c->type == CONTENT_HTML) scale = 1;
|
||||
|
||||
content_redraw(c,
|
||||
xoffset-hcurrent,
|
||||
yoffset-vcurrent,
|
||||
x1,
|
||||
y1,
|
||||
0,0,width,height,
|
||||
g->shared->bw->scale,
|
||||
0xFFFFFF);
|
||||
|
||||
current_redraw_browser = NULL;
|
||||
|
||||
ami_update_buttons(g->shared);
|
||||
|
||||
BltBitMapRastPort(glob.bm,0,0,g->shared->win->RPort,xoffset,yoffset,width,height,0x0C0); // this blit needs optimising
|
||||
#endif
|
||||
}
|
||||
|
||||
void gui_window_redraw_window(struct gui_window *g)
|
||||
@ -1994,7 +2045,7 @@ void gui_window_update_box(struct gui_window *g,
|
||||
struct content *c;
|
||||
ULONG hcurrent,vcurrent,xoffset,yoffset,width=800,height=600;
|
||||
struct IBox *bbox;
|
||||
ULONG cur_tab = 0;
|
||||
ULONG cur_tab = 0,x0,y0,x1,y1;
|
||||
|
||||
if(!g) return;
|
||||
|
||||
@ -2029,6 +2080,7 @@ void gui_window_update_box(struct gui_window *g,
|
||||
|
||||
// if (c->type == CONTENT_HTML) scale = 1;
|
||||
|
||||
/* this needs fixing as it appears to be redrawing the entire page */
|
||||
content_redraw(data->redraw.object,
|
||||
floorf((data->redraw.object_x *
|
||||
g->shared->bw->scale)-hcurrent),
|
||||
@ -2124,6 +2176,7 @@ void ami_do_redraw(struct gui_window_2 *g,bool scroll)
|
||||
else
|
||||
{
|
||||
*/
|
||||
|
||||
content_redraw(c, -hcurrent /* * g->bw->scale */,
|
||||
-vcurrent /* * g->bw->scale */,
|
||||
width-hcurrent /* * g->bw->scale */,
|
||||
@ -2597,16 +2650,25 @@ struct gui_download_window *gui_download_window_create(const char *url,
|
||||
struct gui_download_window *dw;
|
||||
APTR va[3];
|
||||
|
||||
if(AslRequestTags(savereq,
|
||||
ASLFR_TitleText,messages_get("NetSurf"),
|
||||
ASLFR_Screen,scrn,
|
||||
ASLFR_InitialFile,FilePart(url),
|
||||
TAG_DONE))
|
||||
if(gui->dlfilename)
|
||||
{
|
||||
strlcpy(&fname,savereq->fr_Drawer,1024);
|
||||
AddPart((STRPTR)&fname,savereq->fr_File,1024);
|
||||
strcpy(fname,gui->dlfilename);
|
||||
free(gui->dlfilename);
|
||||
gui->dlfilename = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(AslRequestTags(savereq,
|
||||
ASLFR_TitleText,messages_get("NetSurf"),
|
||||
ASLFR_Screen,scrn,
|
||||
ASLFR_InitialFile,FilePart(url),
|
||||
TAG_DONE))
|
||||
{
|
||||
strlcpy(&fname,savereq->fr_Drawer,1024);
|
||||
AddPart((STRPTR)&fname,savereq->fr_File,1024);
|
||||
}
|
||||
else return NULL;
|
||||
}
|
||||
else return NULL;
|
||||
|
||||
dw = AllocVec(sizeof(struct gui_download_window),MEMF_PRIVATE | MEMF_CLEAR);
|
||||
|
||||
|
@ -116,7 +116,8 @@ struct gui_window
|
||||
int c_h;
|
||||
int scrollx;
|
||||
int scrolly;
|
||||
struct browser_window *bw; // not used
|
||||
char *dlfilename;
|
||||
// struct browser_window *bw; // not used
|
||||
};
|
||||
|
||||
struct gui_globals
|
||||
|
Loading…
Reference in New Issue
Block a user