[epiphany] Make sure WebKitWebHistory is cleared when cleared EphyHistory
- From: Xan Lopez <xan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Make sure WebKitWebHistory is cleared when cleared EphyHistory
- Date: Tue, 20 Apr 2010 13:14:42 +0000 (UTC)
commit 384588b86e68ea692a8f99db86b45ca0cc54f804
Author: Mario Sanchez Prada <msanchez igalia com>
Date: Tue Apr 6 19:57:10 2010 +0200
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>
embed/ephy-embed.c | 15 +++++++++
embed/ephy-web-view.c | 82 +++++++++++++++++++++++++++++++++---------------
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 46ed192..8f2c473 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 e7f47b4..2e08480 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 7b71625..5b6a28d 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]