[epiphany] Move method to copy history between embeds/views to EphyWebView from EphyEmbed.



commit 3191345e4aafa9ae92c676468e588b6d1df2862c
Author: Xan Lopez <xan gnome org>
Date:   Sat May 30 19:21:03 2009 +0300

    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.
---
 doc/reference/epiphany-sections.txt     |    4 ---
 doc/reference/tmpl/ephy-embed.sgml      |    1 -
 doc/reference/tmpl/epiphany-unused.sgml |   35 -----------------------
 embed/ephy-embed.c                      |   22 ---------------
 embed/ephy-embed.h                      |   11 -------
 embed/ephy-web-view.c                   |   46 +++++++++++++++++++++++++++++++
 embed/ephy-web-view.h                   |    3 ++
 embed/webkit/webkit-embed.c             |   41 ---------------------------
 src/ephy-shell.c                        |    8 ++---
 src/ephy-window.c                       |    9 +++---
 src/epiphany.defs                       |   12 --------
 11 files changed, 56 insertions(+), 136 deletions(-)

diff --git a/doc/reference/epiphany-sections.txt b/doc/reference/epiphany-sections.txt
index 1b96a08..f86af63 100644
--- a/doc/reference/epiphany-sections.txt
+++ b/doc/reference/epiphany-sections.txt
@@ -71,10 +71,6 @@ ephy_embed_get_js_status
 ephy_embed_can_go_up
 ephy_embed_get_go_up_list
 ephy_embed_go_up
-ephy_embed_shistory_n_items
-ephy_embed_shistory_get_nth
-ephy_embed_shistory_get_pos
-ephy_embed_shistory_go_nth
 ephy_embed_get_security_level
 ephy_embed_find_set_properties
 ephy_embed_find_next
diff --git a/doc/reference/tmpl/ephy-embed.sgml b/doc/reference/tmpl/ephy-embed.sgml
index 6991679..bfa4157 100644
--- a/doc/reference/tmpl/ephy-embed.sgml
+++ b/doc/reference/tmpl/ephy-embed.sgml
@@ -252,7 +252,6 @@ be done by casting).
 @get_location: 
 @get_link_message: 
 @get_js_status: 
- shistory_copy: 
 @get_security_level: 
 @show_page_certificate: 
 @set_print_preview_mode: 
diff --git a/doc/reference/tmpl/epiphany-unused.sgml b/doc/reference/tmpl/epiphany-unused.sgml
index 4135728..ff95f58 100644
--- a/doc/reference/tmpl/epiphany-unused.sgml
+++ b/doc/reference/tmpl/epiphany-unused.sgml
@@ -633,41 +633,6 @@ Represents the state of an #EphyEmbed with regards to networking negotiations.
 @embed: 
 @zoom: 
 
-<!-- ##### FUNCTION ephy_embed_shistory_get_nth ##### -->
-<para>
-
-</para>
-
- embed: 
- nth: 
- is_relative: 
- url: 
- title: 
-
-<!-- ##### FUNCTION ephy_embed_shistory_get_pos ##### -->
-<para>
-
-</para>
-
- embed: 
- Returns: 
-
-<!-- ##### FUNCTION ephy_embed_shistory_go_nth ##### -->
-<para>
-
-</para>
-
- embed: 
- nth: 
-
-<!-- ##### FUNCTION ephy_embed_shistory_n_items ##### -->
-<para>
-
-</para>
-
- embed: 
- Returns: 
-
 <!-- ##### FUNCTION ephy_embed_single_load_proxy_autoconf ##### -->
 <para>
 
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 9243075..b52d010 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -501,28 +501,6 @@ ephy_embed_get_js_status (EphyEmbed *embed)
 }
 
 /**
- * ephy_embed_shistory_copy:
- * @source: the #EphyEmbed to copy the history from
- * @dest: the #EphyEmbed to copy the history to
- * @copy_back: %TRUE to copy the back history
- * @copy_forward: %TRUE to copy the forward history
- * @copy_current: %TRUE to set the current page to that in the copied history
- *
- * Copy's the back and/or forward history from @source to @dest,
- * and optionally set @dest to the current page of @source as well.
- **/
-void
-ephy_embed_shistory_copy (EphyEmbed *source,
-			  EphyEmbed *dest,
-			  gboolean copy_back,
-			  gboolean copy_forward,
-			  gboolean copy_current)
-{
-	EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (source);
-	iface->shistory_copy (source, dest, copy_back, copy_forward, copy_current);
-}
-
-/**
  * ephy_embed_get_security_level:
  * @embed: an #EphyEmbed
  * @level: return value of security level
diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h
index 8809bf6..814eda3 100644
--- a/embed/ephy-embed.h
+++ b/embed/ephy-embed.h
@@ -167,11 +167,6 @@ struct _EphyEmbedIface
 							   gboolean toplevel);
 	const char *	   (* get_link_message)		  (EphyEmbed *embed);
 	char *		   (* get_js_status)		  (EphyEmbed *embed);
-	void		   (* shistory_copy)		  (EphyEmbed *source,
-							   EphyEmbed *dest,
-							   gboolean copy_back,
-							   gboolean copy_forward,
-							   gboolean copy_current);
 	void		   (* get_security_level)	  (EphyEmbed *embed,
 							   EphyEmbedSecurityLevel *level,
 							   char **description);
@@ -232,12 +227,6 @@ GSList		 *ephy_embed_get_go_up_list		(EphyEmbed *embed);
 
 void		  ephy_embed_go_up			(EphyEmbed *embed);
 
-void		  ephy_embed_shistory_copy		(EphyEmbed *source,
-							 EphyEmbed *dest,
-							 gboolean copy_back,
-							 gboolean copy_forward,
-							 gboolean copy_current);
-
 void		  ephy_embed_get_security_level		(EphyEmbed *embed,
 							 EphyEmbedSecurityLevel *level,
 							 char **description);
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 1aade87..cb98dac 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));
+}
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index 9fc3135..870b54c 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -63,6 +63,9 @@ GtkWidget   *ephy_web_view_new                 (void);
 void         ephy_web_view_load_request        (EphyWebView *web_view,
                                                 WebKitNetworkRequest *request);
 
+void         ephy_web_view_copy_back_history   (EphyWebView *source,
+                                                EphyWebView *dest);
+
 G_END_DECLS
 
 #endif
diff --git a/embed/webkit/webkit-embed.c b/embed/webkit/webkit-embed.c
index 060b243..ddb69dc 100644
--- a/embed/webkit/webkit-embed.c
+++ b/embed/webkit/webkit-embed.c
@@ -830,46 +830,6 @@ impl_get_location (EphyEmbed *embed,
 }
 
 static void
-impl_shistory_copy (EphyEmbed *source,
-                    EphyEmbed *dest,
-                    gboolean copy_back,
-                    gboolean copy_forward,
-                    gboolean copy_current)
-{
-  WebKitWebView *source_view, *dest_view;
-  WebKitWebBackForwardList* source_bflist, *dest_bflist;
-  WebKitWebHistoryItem *item;
-  GList *items;
-
-  source_view = WEBKIT_EMBED (source)->priv->web_view;
-  dest_view = WEBKIT_EMBED (dest)->priv->web_view;
-
-  source_bflist = webkit_web_view_get_back_forward_list (source_view);
-  dest_bflist = webkit_web_view_get_back_forward_list (dest_view);
-
-  if (copy_back) {
-    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));
-
-  /* We ignore the 'copy_current' flag, it's unused in Epiphany */
-  /* We ignore the 'copy_forward' flag, ephy/gecko did nothing with it
-     either AFAICT*/
-}
-
-static void
 impl_get_security_level (EphyEmbed *embed,
                          EphyEmbedSecurityLevel *level,
                          char **description)
@@ -925,7 +885,6 @@ ephy_embed_iface_init (EphyEmbedIface *iface)
   iface->go_up = impl_go_up;
   iface->get_location = impl_get_location;
   iface->get_js_status = impl_get_js_status;
-  iface->shistory_copy = impl_shistory_copy;
   iface->show_page_certificate = impl_show_page_certificate;
   iface->set_print_preview_mode = impl_set_print_preview_mode;
   iface->print_preview_n_pages = impl_print_preview_n_pages;
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 1052b59..f957f3c 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -56,6 +56,7 @@
 #include "ephy-gui.h"
 #include "ephy-stock-icons.h"
 #include "ephy-embed-factory.h"
+#include "ephy-web-view.h"
 
 #ifdef ENABLE_NETWORK_MANAGER
 #include "ephy-net-monitor.h"
@@ -491,11 +492,8 @@ ephy_shell_new_tab_full (EphyShell *shell,
 
 	if (previous_embed != NULL)
 	{	
-		ephy_embed_shistory_copy (previous_embed,
-					  embed,
-					  TRUE,   /* back history */
-					  TRUE,   /* forward history */
-					  FALSE); /* current index */
+                ephy_web_view_copy_back_history (EPHY_WEB_VIEW (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (previous_embed)),
+                                                 EPHY_WEB_VIEW (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed)));
 	}		
 
 	ephy_gui_window_update_user_time (GTK_WIDGET (window), user_time);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 68b0573..3f0c4f4 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -57,6 +57,7 @@
 #include "ephy-embed-persist.h"
 #include "ephy-embed-factory.h"
 #include "ephy-location-entry.h"
+#include "ephy-web-view.h"
 
 #include <string.h>
 #include <glib/gi18n.h>
@@ -2264,11 +2265,9 @@ open_link_in_new (EphyWindow *window,
 
 	if (dest)
 	{
-		ephy_embed_shistory_copy (embed,
-					  dest,
-					  TRUE,   /* back history */
-					  FALSE,  /* forward history */
-					  FALSE); /* current index */
+                ephy_web_view_copy_back_history (EPHY_WEB_VIEW (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed)),
+                                                 EPHY_WEB_VIEW (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (dest)));
+
 		return TRUE;
 	}
 
diff --git a/src/epiphany.defs b/src/epiphany.defs
index ca57854..b0c439f 100644
--- a/src/epiphany.defs
+++ b/src/epiphany.defs
@@ -1081,18 +1081,6 @@
   (return-type "none")
 )
 
-(define-method shistory_copy
-  (of-object "EphyEmbed")
-  (c-name "ephy_embed_shistory_copy")
-  (return-type "none")
-  (parameters
-    '("EphyEmbed*" "dest")
-    '("gboolean" "copy_back")
-    '("gboolean" "copy_forward")
-    '("gboolean" "copy_current")
-  )
-)
-
 (define-method show_page_certificate
   (of-object "EphyEmbed")
   (c-name "ephy_embed_show_page_certificate")



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]