1 /* 2 * Copyright 2006 James Bursa <bursa@users.sourceforge.net> 3 * 4 * This file is part of NetSurf, http://www.netsurf-browser.org/ 5 * 6 * NetSurf is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; version 2 of the License. 9 * 10 * NetSurf is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 /** 20 * \file 21 * Interface to browser history operations 22 * 23 * The are operations on a browsing contexts history. These interfaces 24 * allow navigation forward and backwards in the history as well as 25 * enumerating the entries. 26 * 27 * The local history viewing is distinct via corewindow defined in 28 * desktop/local_history.h 29 */ 30 31 #ifndef NETSURF_DESKTOP_BROWSER_HISTORY_H 32 #define NETSURF_DESKTOP_BROWSER_HISTORY_H 33 34 #include <stdbool.h> 35 36 #include "utils/errors.h" 37 38 #include "content/handlers/css/utils.h" 39 40 #define LOCAL_HISTORY_WIDTH \ 41 (FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(116)))) 42 #define LOCAL_HISTORY_HEIGHT \ 43 (FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(100)))) 44 #define LOCAL_HISTORY_RIGHT_MARGIN \ 45 (FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(50)))) 46 #define LOCAL_HISTORY_BOTTOM_MARGIN \ 47 (FIXTOINT(nscss_pixels_css_to_physical(INTTOFIX(30)))) 48 49 struct browser_window; 50 struct history_entry; 51 struct bitmap; 52 53 /** 54 * Go back in the history. 55 * 56 * \param bw A browser window to navigate the history in. 57 * \param new_window whether to open in new window. 58 * \return NSERROR_OK or error code on faliure. 59 */ 60 nserror browser_window_history_back(struct browser_window *bw, bool new_window); 61 62 63 /** 64 * Go forward in the history. 65 * 66 * \param bw A browser window to navigate the history in. 67 * \param new_window whether to open in new window. 68 * \return NSERROR_OK or error code on faliure. 69 */ 70 nserror browser_window_history_forward(struct browser_window *bw, bool new_window); 71 72 73 /** 74 * Check whether it is pssible to go back in the history. 75 * 76 * \param bw A browser window to check the history navigation in. 77 * \return true if the history can go back, false otherwise 78 */ 79 bool browser_window_history_back_available(struct browser_window *bw); 80 81 82 /** 83 * Check whether it is pssible to go forwards in the history. 84 * 85 * \param bw A browser window to check the history navigation in. 86 * \return true if the history can go forwards, false otherwise 87 */ 88 bool browser_window_history_forward_available(struct browser_window *bw); 89 90 /** 91 * Get the thumbnail bitmap for the current history entry 92 * 93 * \param bw The browser window 94 * \param bitmap The bitmat for the current history entry. 95 * \return NSERROR_OK or error code on faliure. 96 */ 97 nserror browser_window_history_get_thumbnail(struct browser_window *bw, struct bitmap **bitmap_out); 98 99 /** 100 * Callback function type for history enumeration 101 * 102 * \param bw The browser window with history being enumerated 103 * \param x0, y0, x1, y1 Coordinates of entry in history tree view 104 * \param entry Current history entry 105 * \return true to continue enumeration, false to cancel enumeration 106 */ 107 typedef bool (*browser_window_history_enumerate_cb)( 108 const struct browser_window *bw, 109 int x0, int y0, int x1, int y1, 110 const struct history_entry *entry, void *user_data); 111 112 113 /** 114 * Enumerate all entries in the history. 115 * Do not change the history while it is being enumerated. 116 * 117 * \param bw The browser window to enumerate history of 118 * \param cb callback function 119 * \param user_data context pointer passed to cb 120 */ 121 void browser_window_history_enumerate(const struct browser_window *bw, 122 browser_window_history_enumerate_cb cb, void *user_data); 123 124 125 /** 126 * Enumerate all entries that will be reached by the 'forward' button 127 * 128 * \param bw The browser window to enumerate history of 129 * \param cb The callback function 130 * \param user_data Data passed to the callback 131 */ 132 void browser_window_history_enumerate_forward(const struct browser_window *bw, 133 browser_window_history_enumerate_cb cb, void *user_data); 134 135 136 /** 137 * Enumerate all entries that will be reached by the 'back' button 138 * 139 * \param bw The browser window to enumerate history of 140 * \param cb The callback function 141 * \param user_data Data passed to the callback 142 */ 143 void browser_window_history_enumerate_back(const struct browser_window *bw, 144 browser_window_history_enumerate_cb cb, void *user_data); 145 146 147 /** 148 * Returns the URL to a history entry 149 * 150 * \param entry the history entry to retrieve the URL from 151 * \return A referenced nsurl URL 152 */ 153 struct nsurl *browser_window_history_entry_get_url(const struct history_entry *entry); 154 155 156 /** 157 * Returns the URL to a history entry 158 * 159 * \param entry the history entry to retrieve the fragment id from 160 * \return the fragment id 161 */ 162 const char *browser_window_history_entry_get_fragment_id(const struct history_entry *entry); 163 164 165 /** 166 * Returns the title of a history entry 167 * 168 * \param entry The history entry to retrieve the title from 169 * \return the title 170 */ 171 const char *browser_window_history_entry_get_title(const struct history_entry *entry); 172 173 174 /** 175 * Navigate to specified history entry, optionally in new window 176 * 177 * \param bw browser window 178 * \param entry entry to open 179 * \param new_window open entry in new window 180 * \return NSERROR_OK or error code on faliure. 181 */ 182 nserror browser_window_history_go(struct browser_window *bw, struct history_entry *entry, bool new_window); 183 184 #endif 185