Use new content message for saving of hyperlink target URL.

This commit is contained in:
Michael Drake 2012-08-16 23:26:05 +01:00
parent a548275fa2
commit 402de7572d
4 changed files with 29 additions and 5 deletions

View File

@ -75,7 +75,8 @@ typedef enum {
CONTENT_MSG_LINK, /**< RFC5988 link */
CONTENT_MSG_GETCTX, /**< Javascript context */
CONTENT_MSG_SCROLL, /**< Request to scroll content */
CONTENT_MSG_DRAGSAVE /**< Allow drag saving of content */
CONTENT_MSG_DRAGSAVE, /**< Allow drag saving of content */
CONTENT_MSG_SAVELINK /**< Allow URL to be saved */
} content_msg;
/** RFC5988 metadata link */
@ -139,6 +140,11 @@ union content_msg_data {
} type;
struct hlcache_handle *content;
} dragsave;
/** CONTENT_MSG_SAVELINK - Save a URL */
struct {
const char *url;
const char *title;
} savelink;
};
/** parameters to content redraw */

View File

@ -1473,6 +1473,16 @@ nserror browser_window_callback(hlcache_handle *c,
}
break;
case CONTENT_MSG_SAVELINK:
{
/* Content wants a link to be saved */
struct browser_window *root = browser_window_get_root(bw);
gui_window_save_link(root->window,
event->data.savelink.url,
event->data.savelink.title);
}
break;
default:
assert(0);
}

View File

@ -1247,6 +1247,11 @@ html_object_callback(hlcache_handle *object,
content_broadcast(&c->base, CONTENT_MSG_DRAGSAVE, event->data);
break;
case CONTENT_MSG_SAVELINK:
/* Pass it on */
content_broadcast(&c->base, CONTENT_MSG_SAVELINK, event->data);
break;
default:
assert(0);
}

View File

@ -696,16 +696,19 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
mouse & BROWSER_MOUSE_MOD_1) {
/* force download of link */
browser_window_go_post(bw, nsurl_access(url), 0, 0,
false, nsurl_access(hlcache_handle_get_url(h)),
false,
nsurl_access(hlcache_handle_get_url(h)),
true, true, 0);
} else if (mouse & BROWSER_MOUSE_CLICK_2 &&
mouse & BROWSER_MOUSE_MOD_1) {
gui_window_save_link(bw->window,
nsurl_access(url), title);
msg_data.savelink.url = nsurl_access(url);
msg_data.savelink.title = title;
content_broadcast(c, CONTENT_MSG_SAVELINK, msg_data);
} else if (mouse & (BROWSER_MOUSE_CLICK_1 |
BROWSER_MOUSE_CLICK_2))
action = ACTION_GO;
} else {
bool done = false;