From f1fdd93ffda5181f325905c8509a2bea9d78eb41 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 28 May 2017 21:56:33 +0100 Subject: Add local history get url API --- desktop/local_history.c | 21 +++++++++++++++++++++ desktop/local_history.h | 30 ++++++++++++++++++++++-------- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/desktop/local_history.c b/desktop/local_history.c index 06f300245..6d07c8ad7 100644 --- a/desktop/local_history.c +++ b/desktop/local_history.c @@ -91,7 +91,10 @@ local_history_mouse_action(struct local_history_session *session, { if (mouse & BROWSER_MOUSE_PRESS_1) { browser_window_history_click(session->bw, x, y, false); + } else if (mouse & BROWSER_MOUSE_PRESS_2) { + browser_window_history_click(session->bw, x, y, true); } + } /* exported interface documented in desktop/local_history.h */ @@ -134,3 +137,21 @@ local_history_get_size(struct local_history_session *session, return NSERROR_OK; } + + +/* exported interface documented in desktop/local_history.h */ +nserror +local_history_get_url(struct local_history_session *session, + int x, int y, + const char **url_out) +{ + const char *url; + url = browser_window_history_position_url(session->bw, x, y); + if (url == NULL) { + return NSERROR_NOT_FOUND; + } + + *url_out = url; + + return NSERROR_OK; +} diff --git a/desktop/local_history.h b/desktop/local_history.h index 5425e700b..2ce2a5c22 100644 --- a/desktop/local_history.h +++ b/desktop/local_history.h @@ -33,9 +33,9 @@ struct local_history_session; struct browser_window; /** - * Initialise the global history. + * Initialise the local history. * - * This iterates through the URL database, generating the global history data, + * This iterates through the URL database, generating the local history data, * and creates a treeview. * * This must be called before any other local_history_* function. @@ -52,10 +52,10 @@ nserror local_history_init(struct core_window_callback_table *cw_t, struct local_history_session **session); /** - * Finalise the global history. + * Finalise the local history. * - * This destroys the global history treeview and the global history module's - * internal data. After calling this if global history is required again, + * This destroys the local history treeview and the local history module's + * internal data. After calling this if ocall history is required again, * local_history_init must be called. * * \param session The local history session to finalise. @@ -65,7 +65,7 @@ nserror local_history_fini(struct local_history_session *session); /** - * Redraw the global history. + * Redraw the local history. * * \param session The local history session context. * \param x X coordinate to render history at @@ -104,13 +104,27 @@ bool local_history_keypress(struct local_history_session *session, uint32_t key) nserror local_history_set(struct local_history_session *session, struct browser_window *bw); /** - * get size of local history content area + * get size of local history content area. * - * \param session The local history session context. + * \param[in] session The local history session context. * \param[out] width on sucessful return the width of the localhistory content * \param[out] height on sucessful return the height of the localhistory content * \return NSERROR_OK or appropriate error code. */ nserror local_history_get_size(struct local_history_session *session, int *width, int *height); +/** + * get url of entry at position in local history content area. + * + * \todo the returned url should be a referenced nsurl. + * + * \param[in] session The local history session context. + * \param[in] x The x coordinate to get url of. + * \param[in] y The y coordinate to get url of. + * \param[out] url_out string representation of the url at the coordinates. + * \return NSERROR_OK and url_out updated or NSERROR_NOT_FOUND if no url at + * location. + */ +nserror local_history_get_url(struct local_history_session *session, int x, int y, const char **url_out); + #endif -- cgit v1.2.3