[project @ 2004-02-26 17:52:10 by bursa]

Implement back and forward using history.

svn path=/import/netsurf/; revision=572
This commit is contained in:
James Bursa 2004-02-26 17:52:10 +00:00
parent 0a4caa5687
commit c05d6fdc8b
6 changed files with 51 additions and 17 deletions

View File

@ -425,16 +425,6 @@ void browser_window_destroy(struct browser_window *bw)
}
void browser_window_back(struct browser_window* bw)
{
}
void browser_window_forward(struct browser_window* bw)
{
}
/**
* Callback for fetchcache() for download window fetches.
*/

View File

@ -97,9 +97,6 @@ void browser_window_go_post(struct browser_window *bw, const char *url,
void browser_window_stop(struct browser_window *bw);
void browser_window_destroy(struct browser_window *bw);
void browser_window_back(struct browser_window* bw);
void browser_window_forward(struct browser_window* bw);
int browser_window_action(struct browser_window* bw, struct browser_action* act);
void box_under_area(struct box* box, unsigned long x, unsigned long y, unsigned long ox, unsigned long oy,
@ -119,5 +116,7 @@ struct history *history_create(void);
void history_add(struct history *history, struct content *content);
void history_update(struct history *history, struct content *content);
void history_destroy(struct history *history);
void history_back(struct browser_window *bw, struct history *history);
void history_forward(struct browser_window *bw, struct history *history);
#endif

View File

@ -331,6 +331,7 @@ void ro_gui_history_open(struct browser_window *bw,
state.visible.y0 = wy - height / 2;
state.visible.x1 = wx + width / 2;
state.visible.y1 = wy + height / 2;
state.next = wimp_TOP;
wimp_open_window((wimp_open *) &state);
}
@ -486,3 +487,34 @@ struct history_entry * ro_gui_history_click_find(struct history_entry *he,
return 0;
}
/**
* Go back in the history.
*
* \param bw browser window
* \param history history of the window
*/
void history_back(struct browser_window *bw, struct history *history)
{
if (!history || !history->current->back)
return;
history->current = history->current->back;
browser_window_go_post(bw, history->current->url, 0, 0, false);
}
/**
* Go forward in the history.
*
* \param bw browser window
* \param history history of the window
*/
void history_forward(struct browser_window *bw, struct history *history)
{
if (!history || !history->current->forward_pref)
return;
history->current = history->current->forward_pref;
browser_window_go_post(bw, history->current->url, 0, 0, false);
}

View File

@ -256,10 +256,12 @@ void ro_gui_menu_selection(wimp_selection *selection)
HOME_URL);
break;
case 2: /* Back */
browser_window_back(current_gui->data.browser.bw);
history_back(current_gui->data.browser.bw,
current_gui->data.browser.bw->history);
break;
case 3: /* Forward */
browser_window_forward(current_gui->data.browser.bw);
history_forward(current_gui->data.browser.bw,
current_gui->data.browser.bw->history);
break;
case 4: /* Reload */
break;

View File

@ -48,11 +48,11 @@ void ro_gui_mouse_action(gui_window *g) {
switch (ma) {
case mouseaction_BACK:
browser_window_back(g->data.browser.bw);
/* browser_window_back(g->data.browser.bw); */
break;
case mouseaction_FORWARD:
browser_window_forward(g->data.browser.bw);
/* browser_window_forward(g->data.browser.bw); */
break;
case mouseaction_RELOAD:

View File

@ -547,11 +547,22 @@ void ro_gui_window_mouse_at(wimp_pointer* pointer)
void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer)
{
switch (pointer->i) {
case ICON_TOOLBAR_BACK:
history_back(g->data.browser.bw,
g->data.browser.bw->history);
break;
case ICON_TOOLBAR_FORWARD:
history_forward(g->data.browser.bw,
g->data.browser.bw->history);
break;
case ICON_TOOLBAR_HISTORY:
ro_gui_history_open(g->data.browser.bw,
g->data.browser.bw->history,
pointer->pos.x, pointer->pos.y);
break;
case ICON_TOOLBAR_RELOAD:
/* browser_window_open_location_historical(g->data.browser.bw,
g->data.browser.bw->url