From 3191345e4aafa9ae92c676468e588b6d1df2862c Mon Sep 17 00:00:00 2001 From: Xan Lopez Date: Sat, 30 May 2009 19:21:03 +0300 Subject: 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 1b96a08ea..f86af6308 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 6991679d7..bfa4157ee 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 4135728d8..ff95f58a9 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: - - - - - -@embed: -@nth: -@is_relative: -@url: -@title: - - - - - - -@embed: -@Returns: - - - - - - -@embed: -@nth: - - - - - - -@embed: -@Returns: - diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 9243075fe..b52d0107e 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -500,28 +500,6 @@ ephy_embed_get_js_status (EphyEmbed *embed) return iface->get_js_status (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 diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h index 8809bf6f5..814eda3a3 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 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 #include @@ -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 9fc31355e..870b54c43 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 060b243c3..ddb69dc8b 100644 --- a/embed/webkit/webkit-embed.c +++ b/embed/webkit/webkit-embed.c @@ -829,46 +829,6 @@ impl_get_location (EphyEmbed *embed, return g_strdup (webkit_web_frame_get_uri (web_frame)); } -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, @@ -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 1052b59d3..f957f3c47 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 68b0573ba..3f0c4f497 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 #include @@ -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 ca5785480..b0c439fe5 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") -- cgit v1.2.3