diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2009-03-23 22:22:30 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2009-03-23 22:22:30 +0000 |
commit | 0a7e10819b40d34ce5b13e582ac057e3fe1abfe6 (patch) | |
tree | 6a8fe7b430b372fe6c7ada538e897b459e49047e /desktop/browser.c | |
parent | 972cd147aa05f86a555641a74481404e4cc152db (diff) | |
download | netsurf-0a7e10819b40d34ce5b13e582ac057e3fe1abfe6.tar.gz netsurf-0a7e10819b40d34ce5b13e582ac057e3fe1abfe6.tar.bz2 |
Add functions for checking if back/forward/stop/reload actions are currently available for a given browser window.
svn path=/trunk/netsurf/; revision=6827
Diffstat (limited to 'desktop/browser.c')
-rw-r--r-- | desktop/browser.c | 64 |
1 files changed, 59 insertions, 5 deletions
diff --git a/desktop/browser.c b/desktop/browser.c index 4d4b4c05e..e433a927a 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -270,7 +270,7 @@ void browser_window_go_unverifiable(struct browser_window *bw, * * If post_urlenc and post_multipart are 0 the url is fetched using GET. * - * The page is not added to the window history if add_to_history is false. + * The page is not added to the window history if add_to_history is false. * This should be used when returning to a page in the window history. */ @@ -697,7 +697,7 @@ void browser_window_refresh(void *p) add_to_history = false; /* Treat an (almost) immediate refresh in a top-level browser window as - * if it were an HTTP redirect, and thus make the resulting fetch + * if it were an HTTP redirect, and thus make the resulting fetch * verifiable. * * See fetchcache.c for why redirected fetches should be verifiable at @@ -794,10 +794,10 @@ void browser_window_update(struct browser_window *bw) if (!history_get_current_scroll(bw->history, &sx, &sy)) sx = -1; - + /* if the page was scrolled before return to that position */ if (sx != -1) { - gui_window_set_scroll(bw->window, sx, sy); + gui_window_set_scroll(bw->window, sx, sy); /* if frag_id exists, then try to scroll to it */ } else if (bw->frag_id && bw->current_content->type == CONTENT_HTML) { if ((pos = box_find_by_id(bw->current_content->data.html.layout, bw->frag_id)) != 0) { @@ -805,7 +805,7 @@ void browser_window_update(struct browser_window *bw) gui_window_set_scroll(bw->window, x, y); } } else - gui_window_set_scroll(bw->window, 0, 0); + gui_window_set_scroll(bw->window, 0, 0); gui_window_redraw_window(bw->window); } @@ -2798,3 +2798,57 @@ void browser_window_page_drag_start(struct browser_window *bw, int x, int y) gui_window_scroll_start(bw->window); } + + +/** + * Check availability of Back action for a given browser window + * + * \param bw browser window + * \return true if Back action is available + */ + +bool browser_window_back_available(struct browser_window *bw) +{ + return (bw && bw->history && history_back_available(bw->history)); +} + + +/** + * Check availability of Forward action for a given browser window + * + * \param bw browser window + * \return true if Forward action is available + */ + +bool browser_window_forward_available(struct browser_window *bw) +{ + return (bw && bw->history && history_forward_available(bw->history)); +} + + +/** + * Check availability of Reload action for a given browser window + * + * \param bw browser window + * \return true if Reload action is available + */ + +bool browser_window_reload_available(struct browser_window *bw) +{ + return (bw && bw->current_content && !bw->loading_content); +} + + +/** + * Check availability of Stop action for a given browser window + * + * \param bw browser window + * \return true if Stop action is available + */ + +bool browser_window_stop_available(struct browser_window *bw) +{ + return (bw && (bw->loading_content || + (bw->current_content && + (bw->current_content->status != CONTENT_STATUS_DONE)))); +} |