diff options
author | Mario Sanchez Prada <msanchez@igalia.com> | 2010-04-07 01:57:10 +0800 |
---|---|---|
committer | Xan Lopez <xan@gnome.org> | 2010-04-20 21:06:14 +0800 |
commit | 384588b86e68ea692a8f99db86b45ca0cc54f804 (patch) | |
tree | 728217ca375c3f379421f21c688c56a2cca16502 /embed/ephy-web-view.c | |
parent | bee24a63dcdbd0c974f04cd12c0ffbf352c7edc2 (diff) | |
download | gsoc2013-epiphany-384588b86e68ea692a8f99db86b45ca0cc54f804.tar.gz gsoc2013-epiphany-384588b86e68ea692a8f99db86b45ca0cc54f804.tar.zst gsoc2013-epiphany-384588b86e68ea692a8f99db86b45ca0cc54f804.zip |
Make sure WebKitWebHistory is cleared when cleared EphyHistory
Added new function in EphyWebView to clear the history from
WebKitWebView, and connect to the 'cleared' signal in EphyEmbed to call
to such a function when needed.
Bug #539716
Signed-off-by: Xan Lopez <xan@gnome.org>
Diffstat (limited to 'embed/ephy-web-view.c')
-rw-r--r-- | embed/ephy-web-view.c | 82 |
1 files changed, 56 insertions, 26 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index e7f47b448..2e084801e 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -2045,6 +2045,32 @@ normalize_or_autosearch_url (EphyWebView *view, const char *url) return effective_url; } +static void +update_navigation_flags (EphyWebView *view) +{ + EphyWebViewPrivate *priv = view->priv; + guint flags = 0; + WebKitWebView *web_view = WEBKIT_WEB_VIEW (view); + + if (ephy_web_view_can_go_up (view)) { + flags |= EPHY_WEB_VIEW_NAV_UP; + } + + if (webkit_web_view_can_go_back (web_view)) { + flags |= EPHY_WEB_VIEW_NAV_BACK; + } + + if (webkit_web_view_can_go_forward (web_view)) { + flags |= EPHY_WEB_VIEW_NAV_FORWARD; + } + + if (priv->nav_flags != (EphyWebViewNavigationFlags)flags) { + priv->nav_flags = (EphyWebViewNavigationFlags)flags; + + g_object_notify (G_OBJECT (view), "navigation"); + } +} + /** * ephy_web_view_load_request: * @view: the #EphyWebView in which to load the request @@ -2150,6 +2176,36 @@ ephy_web_view_copy_back_history (EphyWebView *source, } /** + * ephy_web_view_clear_history: + * @view: the #EphyWebView to clear the history from + * + * Clears history of @view. + **/ +void +ephy_web_view_clear_history (EphyWebView *view) +{ + WebKitWebBackForwardList *history_list; + + g_return_if_fail (EPHY_IS_WEB_VIEW (view)); + + history_list = webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view)); + if (history_list != NULL) { + WebKitWebHistoryItem *current_item; + + /* Save a ref to the first element to add it later */ + current_item = webkit_web_back_forward_list_get_current_item (history_list); + g_object_ref (current_item); + + /* Clear the history and add the first element once again */ + webkit_web_back_forward_list_clear (history_list); + webkit_web_back_forward_list_add_item (history_list, current_item); + g_object_unref (current_item); + + update_navigation_flags (view); + } +} + +/** * ephy_web_view_set_address: * @view: an #EphyWebView * @address: address to set @view to @@ -2330,32 +2386,6 @@ update_net_state_message (EphyWebView *view, const char *uri, EphyWebViewNetStat g_free (host); } -static void -update_navigation_flags (EphyWebView *view) -{ - EphyWebViewPrivate *priv = view->priv; - guint flags = 0; - WebKitWebView *web_view = WEBKIT_WEB_VIEW (view); - - if (ephy_web_view_can_go_up (view)) { - flags |= EPHY_WEB_VIEW_NAV_UP; - } - - if (webkit_web_view_can_go_back (web_view)) { - flags |= EPHY_WEB_VIEW_NAV_BACK; - } - - if (webkit_web_view_can_go_forward (web_view)) { - flags |= EPHY_WEB_VIEW_NAV_FORWARD; - } - - if (priv->nav_flags != (EphyWebViewNavigationFlags)flags) { - priv->nav_flags = (EphyWebViewNavigationFlags)flags; - - g_object_notify (G_OBJECT (view), "navigation"); - } -} - /** * ephy_web_view_update_from_net_state: * @view: an #EphyWebView |