diff options
author | Sven Weidauer <sven.weidauer@gmail.com> | 2011-02-28 15:24:30 +0000 |
---|---|---|
committer | Sven Weidauer <sven.weidauer@gmail.com> | 2011-02-28 15:24:30 +0000 |
commit | 4b10485de13d5ba23ab496092184c15d4d4bc9a1 (patch) | |
tree | f95640edaa227b9140238e52bf3188b09baf0c57 /desktop | |
parent | 8eda3390daa58ac60b1e2b36dd227e37632a3225 (diff) | |
download | netsurf-4b10485de13d5ba23ab496092184c15d4d4bc9a1.tar.gz netsurf-4b10485de13d5ba23ab496092184c15d4d4bc9a1.tar.bz2 |
Publishing 'history_go' function and creating API to enumerate all history items reachable by the forward or back buttons.
svn path=/trunk/netsurf/; revision=11856
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/history_core.c | 44 | ||||
-rw-r--r-- | desktop/history_core.h | 31 |
2 files changed, 63 insertions, 12 deletions
diff --git a/desktop/history_core.c b/desktop/history_core.c index 347fe423a..581b072dc 100644 --- a/desktop/history_core.c +++ b/desktop/history_core.c @@ -83,8 +83,6 @@ struct history { static struct history_entry *history_clone_entry(struct history *history, struct history_entry *entry); static void history_free_entry(struct history_entry *entry); -static void history_go(struct browser_window *bw, struct history *history, - struct history_entry *entry, bool new_window); static void history_layout(struct history *history); static int history_layout_subtree(struct history *history, struct history_entry *entry, int x, int y, bool shuffle); @@ -421,15 +419,7 @@ bool history_forward_available(struct history *history) } -/** - * Open a history entry in the specified browser window - * - * \param bw browser window - * \param history history containing entry - * \param entry entry to open - * \param new_window open entry in new window - */ - +/* Documented in history_core.h */ void history_go(struct browser_window *bw, struct history *history, struct history_entry *entry, bool new_window) { @@ -770,6 +760,36 @@ struct history_entry *history_find_position(struct history_entry *entry, } /* Documented in history_core.h */ +void history_enumerate_forward(struct history *history, + history_enumerate_cb cb, void *user_data) +{ + struct history_entry *entry; + + if (history == NULL || history->current == NULL) return; + + for (entry = history->current->forward_pref; entry != NULL; entry = entry->forward_pref) { + if (!cb(history, entry->x, entry->y, entry->x + WIDTH, + entry->y + HEIGHT, entry, user_data)) + break; + } +} + +/* Documented in history_core.h */ +void history_enumerate_back(struct history *history, + history_enumerate_cb cb, void *user_data) +{ + struct history_entry *entry; + + if (history == NULL || history->current == NULL) return; + + for (entry = history->current->back; entry != NULL; entry = entry->back) { + if (!cb(history, entry->x, entry->y, entry->x + WIDTH, + entry->y + HEIGHT, entry, user_data)) + break; + } +} + +/* Documented in history_core.h */ void history_enumerate(const struct history *history, history_enumerate_cb cb, void *user_data) { @@ -818,4 +838,4 @@ const char *history_entry_get_fragment_id(const struct history_entry *entry) const char *history_entry_get_title(const struct history_entry *entry) { return entry->page.title; -}
\ No newline at end of file +} diff --git a/desktop/history_core.h b/desktop/history_core.h index 4f4cf0c2a..be09fb1cb 100644 --- a/desktop/history_core.h +++ b/desktop/history_core.h @@ -71,6 +71,26 @@ typedef bool (*history_enumerate_cb)(const struct history *history, int x0, int void history_enumerate(const struct history *history, history_enumerate_cb cb, void *user_data); /** + * Enumerate all entries that will be reached by the 'forward' button + * + * \param history The history object to enumerate in + * \param cb The callback function + * \param user_data Data passed to the callback + */ +void history_enumerate_forward( struct history *history, + history_enumerate_cb cb, void *user_data ); + +/** + * Enumerate all entries that will be reached by the 'back' button + * + * \param history The history object to enumerate in + * \param cb The callback function + * \param user_data Data passed to the callback + */ +void history_enumerate_back( struct history *history, + history_enumerate_cb cb, void *user_data ); + +/** * Returns the URL to a history entry * * \param entry the history entry to retrieve the URL from @@ -94,4 +114,15 @@ const char *history_entry_get_fragment_id(const struct history_entry *entry); */ const char *history_entry_get_title(const struct history_entry *entry); +/** + * Open a history entry in the specified browser window + * + * \param bw browser window + * \param history history containing entry + * \param entry entry to open + * \param new_window open entry in new window + */ +void history_go(struct browser_window *bw, struct history *history, + struct history_entry *entry, bool new_window); + #endif |