Make adjust-back/forwards/up open content in a new window (implement 1431600)

svn path=/trunk/netsurf/; revision=2717
This commit is contained in:
Richard Wilson 2006-07-05 16:50:35 +00:00
parent a102f34fa6
commit ea44d84833
4 changed files with 65 additions and 21 deletions

View File

@ -1907,7 +1907,7 @@ void browser_form_submit(struct browser_window *bw, struct form *form,
}
if (new_window) {
target = browser_window_create(NULL, bw, NULL, true);
target = browser_window_create(NULL, bw, NULL, false);
/* any error has already been reported */
if (!target)
return;

View File

@ -116,7 +116,8 @@ void ro_gui_download_drag_end(wimp_dragged *drag);
void ro_gui_download_datasave_ack(wimp_message *message);
bool ro_gui_download_window_destroy(struct gui_download_window *dw, bool quit);
bool ro_gui_download_prequit(void);
bool ro_gui_download_window_keypress(struct gui_download_window *dw, wimp_key *key);
bool ro_gui_download_window_keypress(struct gui_download_window *dw,
wimp_key *key);
/* in 401login.c */
#ifdef WITH_AUTH
@ -158,11 +159,14 @@ bool ro_gui_shift_pressed(void);
bool ro_gui_ctrl_pressed(void);
void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag);
void ro_gui_window_set_scale(struct gui_window *g, float scale);
void ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi);
void ro_gui_window_iconise(struct gui_window *g,
wimp_full_message_window_info *wi);
bool ro_gui_window_navigate_up(struct gui_window *g, const char *url);
/* in history.c */
void ro_gui_history_init(void);
void ro_gui_history_open(struct browser_window *bw, struct history *history, bool pointer);
void ro_gui_history_open(struct browser_window *bw, struct history *history,
bool pointer);
void ro_gui_history_mouse_at(wimp_pointer *pointer);
/* in hotlist.c */

View File

@ -1372,9 +1372,6 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action,
os_error *error;
char url[80];
const struct url_data *data;
char *parent;
url_func_result res;
bool compare;
ro_gui_menu_get_window_details(owner, &g, &bw, &c, &t, &tree);
@ -1526,14 +1523,7 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action,
case BROWSER_NAVIGATE_UP:
if ((!bw) || (!c))
return false;
res = url_parent(c->url, &parent);
if (res == URL_FUNC_OK) {
res = url_compare(c->url, parent, &compare);
if (!compare && (res == URL_FUNC_OK))
browser_window_go(g->bw, parent, 0, true);
free(parent);
}
return true;
return ro_gui_window_navigate_up(bw->window, c->url);
case BROWSER_NAVIGATE_RELOAD:
case BROWSER_NAVIGATE_RELOAD_ALL:
if (!bw)

View File

@ -1374,6 +1374,7 @@ void ro_gui_window_mouse_at(struct gui_window *g, wimp_pointer *pointer)
bool ro_gui_toolbar_click(wimp_pointer *pointer)
{
struct gui_window *g = ro_gui_toolbar_lookup(pointer->w);
struct browser_window *new_bw;
/* toolbars in the options window have no gui_window */
if (!g)
@ -1401,13 +1402,27 @@ bool ro_gui_toolbar_click(wimp_pointer *pointer)
*/
switch (pointer->i) {
case ICON_TOOLBAR_BACK:
if (pointer->buttons == wimp_CLICK_ADJUST) {
new_bw = browser_window_create(NULL,
g->bw, NULL, false);
ro_gui_menu_handle_action(new_bw->window->window,
BROWSER_NAVIGATE_BACK, true);
} else {
ro_gui_menu_handle_action(g->window,
BROWSER_NAVIGATE_BACK, true);
}
break;
case ICON_TOOLBAR_FORWARD:
if (pointer->buttons == wimp_CLICK_ADJUST) {
new_bw = browser_window_create(NULL,
g->bw, NULL, false);
ro_gui_menu_handle_action(new_bw->window->window,
BROWSER_NAVIGATE_FORWARD, true);
} else {
ro_gui_menu_handle_action(g->window,
BROWSER_NAVIGATE_FORWARD, true);
}
break;
case ICON_TOOLBAR_STOP:
@ -1469,8 +1484,18 @@ bool ro_gui_toolbar_click(wimp_pointer *pointer)
BROWSER_PRINT, true);
break;
case ICON_TOOLBAR_UP:
if (pointer->buttons == wimp_CLICK_ADJUST) {
if (g->bw && g->bw->current_content) {
new_bw = browser_window_create(NULL,
g->bw, NULL, false);
/* do it without loading the content into the new window */
ro_gui_window_navigate_up(new_bw->window,
g->bw->current_content->url);
}
} else {
ro_gui_menu_handle_action(g->window,
BROWSER_NAVIGATE_UP, true);
}
break;
case ICON_TOOLBAR_URL:
if (pointer->buttons & (wimp_DRAG_SELECT | wimp_DRAG_ADJUST)) {
@ -3064,3 +3089,28 @@ void ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *
free(area);
}
/**
* Navigate up one level
*
* \param g the gui_window to open the parent link in
* \param url the URL to open the parent of
*/
bool ro_gui_window_navigate_up(struct gui_window *g, const char *url) {
char *parent;
url_func_result res;
bool compare;
if (!g || (!g->bw))
return false;
res = url_parent(url, &parent);
if (res == URL_FUNC_OK) {
res = url_compare(url, parent, &compare);
if (!compare && (res == URL_FUNC_OK))
browser_window_go(g->bw, parent, 0, true);
free(parent);
}
return true;
}