summaryrefslogtreecommitdiff
path: root/desktop/history_core.c
diff options
context:
space:
mode:
authorSven Weidauer <sven.weidauer@gmail.com>2011-02-28 15:24:02 +0000
committerSven Weidauer <sven.weidauer@gmail.com>2011-02-28 15:24:02 +0000
commitf47026114173a51802e8915b1f49888eb4367b46 (patch)
treeb74048a9d0ecfd0d320a7da632a598cc8a3979ad /desktop/history_core.c
parente66c7f9313c27cdc65e34eaf1383b9c6bd70af1d (diff)
downloadnetsurf-f47026114173a51802e8915b1f49888eb4367b46.tar.gz
netsurf-f47026114173a51802e8915b1f49888eb4367b46.tar.bz2
Added API to enumerate entries in history tree.
svn path=/trunk/netsurf/; revision=11854
Diffstat (limited to 'desktop/history_core.c')
-rw-r--r--desktop/history_core.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/desktop/history_core.c b/desktop/history_core.c
index 0449a3d18..347fe423a 100644
--- a/desktop/history_core.c
+++ b/desktop/history_core.c
@@ -94,6 +94,8 @@ static bool history_redraw_entry(struct history *history,
int x, int y, bool clip);
static struct history_entry *history_find_position(struct history_entry *entry,
int x, int y);
+static bool history_enumerate_entry(const struct history *history,
+ const struct history_entry *entry, history_enumerate_cb cb, void *ud);
/**
@@ -766,3 +768,54 @@ struct history_entry *history_find_position(struct history_entry *entry,
return 0;
}
+
+/* Documented in history_core.h */
+void history_enumerate(const struct history *history, history_enumerate_cb cb,
+ void *user_data)
+{
+ history_enumerate_entry(history, history->start, cb, user_data);
+}
+
+/**
+ * Enumerate subentries in history
+ * See also history_enumerate()
+ *
+ * \param history history to enumerate
+ * \param entry entry to start enumeration at
+ * \param cb callback function
+ * \param ud context pointer passed to cb
+ * \return true to continue enumeration, false to cancel
+ */
+static bool history_enumerate_entry(const struct history *history,
+ const struct history_entry *entry, history_enumerate_cb cb, void *ud)
+{
+ const struct history_entry *child;
+
+ if (!cb(history, entry->x, entry->y, entry->x + WIDTH, entry->y + HEIGHT,
+ entry, ud)) return false;
+
+ for (child = entry->forward; child; child = child->next) {
+ if (!history_enumerate_entry(history, child, cb, ud))
+ return false;
+ }
+
+ return true;
+}
+
+/* Documented in history_core.h */
+const char *history_entry_get_url(const struct history_entry *entry)
+{
+ return entry->page.url;
+}
+
+/* Documented in history_core.h */
+const char *history_entry_get_fragment_id(const struct history_entry *entry)
+{
+ return entry->page.frag_id;
+}
+
+/* Documented in history_core.h */
+const char *history_entry_get_title(const struct history_entry *entry)
+{
+ return entry->page.title;
+} \ No newline at end of file