mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-27 00:40:15 +03:00
Added "view source" to context menu.
svn path=/trunk/netsurf/; revision=12826
This commit is contained in:
parent
8bb14fa569
commit
28a6e41174
@ -44,6 +44,7 @@
|
||||
#include "atari/browser_win.h"
|
||||
#include "atari/misc.h"
|
||||
#include "atari/clipboard.h"
|
||||
#include "atari/options.h"
|
||||
#include "atari/res/netsurf.rsh"
|
||||
#include "atari/ctxmenu.h"
|
||||
|
||||
@ -92,6 +93,7 @@ static struct s_context_info * get_context_info( struct gui_window * gw, short m
|
||||
}
|
||||
|
||||
ctxinfo.flags |= CNT_BROWSER;
|
||||
memset( &ctxinfo.ccdata, sizeof(struct contextual_content), 0 );
|
||||
browser_window_get_contextual_content(
|
||||
gw->browser->bw, mx, my,
|
||||
(struct contextual_content*)&ctxinfo.ccdata
|
||||
@ -99,10 +101,11 @@ static struct s_context_info * get_context_info( struct gui_window * gw, short m
|
||||
if( ctxinfo.ccdata.link_url ){
|
||||
ctxinfo.flags |= CNT_HREF;
|
||||
}
|
||||
if( ctxinfo.ccdata.object && (content_get_type(ccdata.object) == CONTENT_IMAGE)) {
|
||||
ctxinfo.flags |= CNT_IMG;
|
||||
if( ctxinfo.ccdata.object) {
|
||||
if( content_get_type(ctxinfo.ccdata.object) == CONTENT_IMAGE ){
|
||||
ctxinfo.flags |= CNT_IMG;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
box = html_get_box_tree(h);
|
||||
box_x = box->margin[LEFT];
|
||||
@ -138,6 +141,11 @@ void context_popup( struct gui_window * gw, short x, short y )
|
||||
OBJECT * pop;
|
||||
int choice;
|
||||
struct s_context_info * ctx;
|
||||
unsigned long size;
|
||||
char * data;
|
||||
FILE * fp_tmpfile;
|
||||
char * tempfile;
|
||||
int err = 0;
|
||||
|
||||
pop = get_tree( POP_CTX );
|
||||
if( pop == NULL )
|
||||
@ -196,6 +204,24 @@ void context_popup( struct gui_window * gw, short x, short y )
|
||||
browser_window_key_press( gw->browser->bw, KEY_SELECT_ALL );
|
||||
break;
|
||||
|
||||
case POP_CTX_SAVE_AS:
|
||||
if( content_get_url(ctx->ccdata.object) != NULL ){
|
||||
browser_window_download(
|
||||
gw->browser->bw,
|
||||
content_get_url(ctx->ccdata.object),
|
||||
content_get_url(gw->browser->bw->current_content)
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case POP_CTX_COPY_URL:
|
||||
if( (ctx->flags & CNT_IMG) && (ctx->ccdata.object != NULL) ){
|
||||
if( content_get_url(ctx->ccdata.object) != NULL ){
|
||||
scrap_txt_write(&app, (char*)content_get_url(ctx->ccdata.object) );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case POP_CTX_COPY_LINK:
|
||||
if( (ctx->flags & CNT_HREF) && ctx->ccdata.link_url != NULL ){
|
||||
scrap_txt_write(&app, (char*)ctx->ccdata.link_url);
|
||||
@ -203,7 +229,7 @@ void context_popup( struct gui_window * gw, short x, short y )
|
||||
break;
|
||||
|
||||
case POP_CTX_OPEN_NEW:
|
||||
if( (ctx->flags & CNT_HREF) && ctx->ccdata.link_url){
|
||||
if( (ctx->flags & CNT_HREF) && ctx->ccdata.link_url) {
|
||||
browser_window_create(
|
||||
ctx->ccdata.link_url,
|
||||
gw->browser->bw,
|
||||
@ -211,7 +237,22 @@ void context_popup( struct gui_window * gw, short x, short y )
|
||||
true, false
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case POP_CTX_VIEW_SOURCE:
|
||||
if( option_atari_editor != NULL ) {
|
||||
data = content_get_source_data( gw->browser->bw->current_content, &size );
|
||||
if( size > 0 && data != NULL ){
|
||||
tempfile = tmpnam( NULL );
|
||||
fp_tmpfile = fopen( tempfile, "w" );
|
||||
if( fp_tmpfile ){
|
||||
fwrite( data, size, 1, fp_tmpfile );
|
||||
fclose( fp_tmpfile );
|
||||
err = ShelWrite( option_atari_editor, tempfile , NULL, 1, 0);
|
||||
LOG(("launched: %s %s (%d)\n", option_atari_editor, tempfile, err ));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: break;
|
||||
|
@ -35,8 +35,9 @@ extern char *option_atari_face_monospace; /* monospace face */
|
||||
extern char *option_atari_face_monospace_bold; /* monospace face */
|
||||
extern char *option_atari_face_serif; /* serif face */
|
||||
extern char *option_atari_face_serif_bold; /* bold serif face */
|
||||
extern char *option_atari_face_cursive;
|
||||
extern char *option_atari_face_cursive;
|
||||
extern char *option_atari_face_fantasy;
|
||||
extern char *option_atari_editor;
|
||||
extern char *option_downloads_path;
|
||||
extern char *option_url_file;
|
||||
extern char *option_hotlist_file;
|
||||
@ -61,6 +62,7 @@ char *option_atari_face_serif;\
|
||||
char *option_atari_face_serif_bold; \
|
||||
char *option_atari_face_cursive; \
|
||||
char *option_atari_face_fantasy; \
|
||||
char *option_atari_editor;\
|
||||
char *option_downloads_path = (char*)"./"; \
|
||||
char *option_url_file = (char*)"url.db";\
|
||||
char *option_hotlist_file = (char*)"hotlist";\
|
||||
@ -74,6 +76,7 @@ char *option_tree_icons_path = (char*)"./res/icons";
|
||||
{ "atari_knockout", OPTION_INTEGER, &option_atari_knockout },\
|
||||
{ "atari_dither", OPTION_INTEGER, &option_atari_dither },\
|
||||
{ "atari_realtime_move", OPTION_INTEGER, &option_atari_realtime_move },\
|
||||
{ "atari_editor", OPTION_STRING, &option_atari_editor },\
|
||||
{ "font_face_sans_serif", OPTION_STRING, &option_atari_face_sans_serif },\
|
||||
{ "font_face_sans_serif_bold", OPTION_STRING, &option_atari_face_sans_serif_bold },\
|
||||
{ "font_face_sans_serif_italic", OPTION_STRING, &option_atari_face_sans_serif_italic },\
|
||||
|
Loading…
Reference in New Issue
Block a user