aboutsummaryrefslogtreecommitdiffstats
path: root/embed/ephy-web-view.c
diff options
context:
space:
mode:
authorXan Lopez <xan@gnome.org>2009-05-31 00:21:03 +0800
committerXan Lopez <xan@gnome.org>2009-05-31 00:21:03 +0800
commit3191345e4aafa9ae92c676468e588b6d1df2862c (patch)
treef2cd7b8ab212fca19fa745966156ce58c1d31384 /embed/ephy-web-view.c
parentd94e4eca61821f956c67e6a519c36be083dd794d (diff)
downloadgsoc2013-epiphany-3191345e4aafa9ae92c676468e588b6d1df2862c.tar
gsoc2013-epiphany-3191345e4aafa9ae92c676468e588b6d1df2862c.tar.gz
gsoc2013-epiphany-3191345e4aafa9ae92c676468e588b6d1df2862c.tar.bz2
gsoc2013-epiphany-3191345e4aafa9ae92c676468e588b6d1df2862c.tar.lz
gsoc2013-epiphany-3191345e4aafa9ae92c676468e588b6d1df2862c.tar.xz
gsoc2013-epiphany-3191345e4aafa9ae92c676468e588b6d1df2862c.tar.zst
gsoc2013-epiphany-3191345e4aafa9ae92c676468e588b6d1df2862c.zip
Move method to copy history between embeds/views to EphyWebView from EphyEmbed.
Just part of the gradual progress to get rid of the Embed interface.
Diffstat (limited to 'embed/ephy-web-view.c')
-rw-r--r--embed/ephy-web-view.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 1aade87ee..cb98dacc7 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -22,6 +22,7 @@
#include "ephy-web-view.h"
#include "ephy-debug.h"
+#include "ephy-embed-utils.h"
#include <gtk/gtk.h>
#include <webkit/webkit.h>
@@ -74,3 +75,48 @@ ephy_web_view_load_request (EphyWebView *web_view,
main_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW(web_view));
webkit_web_frame_load_request(main_frame, request);
}
+
+/**
+ * ephy_web_view_copy_back_history:
+ * @source: the #EphyWebView from which to get the back history
+ * @dest: the #EphyWebView to copy the history to
+ *
+ * Sets the back history (up to the current item) of @source as the
+ * back history of @dest.
+ *
+ * Useful to keep the history when opening links in new tabs or
+ * windows.
+ **/
+void
+ephy_web_view_copy_back_history (EphyWebView *source,
+ EphyWebView *dest)
+{
+ WebKitWebView *source_view, *dest_view;
+ WebKitWebBackForwardList* source_bflist, *dest_bflist;
+ WebKitWebHistoryItem *item;
+ GList *items;
+
+ g_return_if_fail(EPHY_IS_WEB_VIEW(source));
+ g_return_if_fail(EPHY_IS_WEB_VIEW(dest));
+
+ source_view = WEBKIT_WEB_VIEW (source);
+ dest_view = WEBKIT_WEB_VIEW (dest);
+
+ source_bflist = webkit_web_view_get_back_forward_list (source_view);
+ dest_bflist = webkit_web_view_get_back_forward_list (dest_view);
+
+ items = webkit_web_back_forward_list_get_back_list_with_limit (source_bflist, EPHY_WEBKIT_BACK_FORWARD_LIMIT);
+ /* We want to add the items in the reverse order here, so the
+ history ends up the same */
+ items = g_list_reverse (items);
+ for (; items; items = items->next) {
+ item = (WebKitWebHistoryItem*)items->data;
+ webkit_web_back_forward_list_add_item (dest_bflist, g_object_ref (item));
+ }
+ g_list_free (items);
+
+ /* The ephy/gecko behavior is to add the current item of the source
+ embed at the end of the back history, so keep doing that */
+ item = webkit_web_back_forward_list_get_current_item (source_bflist);
+ webkit_web_back_forward_list_add_item (dest_bflist, g_object_ref (item));
+}