diff options
Diffstat (limited to 'embed')
-rw-r--r-- | embed/ephy-embed.c | 15 | ||||
-rw-r--r-- | embed/ephy-web-view.c | 82 | ||||
-rw-r--r-- | embed/ephy-web-view.h | 1 |
3 files changed, 72 insertions, 26 deletions
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 46ed19294..8f2c4738b 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -335,6 +335,13 @@ zoom_changed_cb (WebKitWebView *web_view, } static void +ephy_embed_history_cleared_cb (EphyHistory *history, + EphyEmbed *embed) +{ + ephy_web_view_clear_history (EPHY_WEB_VIEW (embed->priv->web_view)); +} + +static void ephy_embed_grab_focus (GtkWidget *widget) { GtkWidget *child; @@ -360,6 +367,10 @@ ephy_embed_finalize (GObject *object) } g_slist_free (embed->priv->destroy_on_transition_list); + g_signal_handlers_disconnect_by_func (embed->priv->history, + ephy_embed_history_cleared_cb, + embed); + G_OBJECT_CLASS (ephy_embed_parent_class)->finalize (object); } @@ -956,6 +967,10 @@ ephy_embed_constructed (GObject *object) ephy_embed_prefs_add_embed (embed); embed->priv->history = EPHY_HISTORY (ephy_embed_shell_get_global_history (ephy_embed_shell_get_default ())); + + g_signal_connect (embed->priv->history, + "cleared", G_CALLBACK (ephy_embed_history_cleared_cb), + embed); } static void 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 diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h index 7b7162590..5b6a28d4c 100644 --- a/embed/ephy-web-view.h +++ b/embed/ephy-web-view.h @@ -155,6 +155,7 @@ void ephy_web_view_load_url (EphyWebView const char *url); void ephy_web_view_copy_back_history (EphyWebView *source, EphyWebView *dest); +void ephy_web_view_clear_history (EphyWebView *view); gboolean ephy_web_view_is_loading (EphyWebView *view); const char * ephy_web_view_get_loading_title (EphyWebView *view); GdkPixbuf * ephy_web_view_get_icon (EphyWebView *view); |