aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Langdale <philipl@mail.utexas.edu>2005-10-13 11:14:12 +0800
committerPhilip Langdale <philipl@src.gnome.org>2005-10-13 11:14:12 +0800
commit54d95188256bc3a6504e949d8a6d85190401330e (patch)
tree6f8aba9ea3d03952e8232669c744fdf54e840374
parent85939a287cbb2b9c789581ddc6d529dd24d2c870 (diff)
downloadgsoc2013-epiphany-54d95188256bc3a6504e949d8a6d85190401330e.tar.gz
gsoc2013-epiphany-54d95188256bc3a6504e949d8a6d85190401330e.tar.zst
gsoc2013-epiphany-54d95188256bc3a6504e949d8a6d85190401330e.zip
embed/ephy-embed.c . Add a method to copy the back/forward history from
2005-10-12 Philip Langdale <philipl@mail.utexas.edu> * embed/ephy-embed.c * embed/ephy-embed.h: (ephy_embed_shistory_copy). Add a method to copy the back/forward history from one embed to another. * embed/mozilla/EphyBrowser.cpp: * embed/mozilla/EphyBrowser.h: (EphyBrowser::CopySHistory) Implementation of history copying. * embed/mozilla/mozilla-embed.cpp: Implement ephy_embed_shistory_copy by calling into EphyBrowser. * src/ephy-navigation-action.c: (activate_back_or_forward_menu_item_cb). If a history menu item is middle-clicked on, open a new tab, copy the history over and then go to the relevant page in the history. * src/ephy-toolbar.c: (ephy_toolbar_set_window) Attach handler for "open-link" to back/forward actions.
-rw-r--r--ChangeLog25
-rw-r--r--embed/ephy-embed.c22
-rw-r--r--embed/ephy-embed.h11
-rw-r--r--embed/mozilla/EphyBrowser.cpp58
-rw-r--r--embed/mozilla/EphyBrowser.h3
-rw-r--r--embed/mozilla/mozilla-embed.cpp16
-rw-r--r--src/ephy-navigation-action.c19
-rwxr-xr-xsrc/ephy-toolbar.c4
8 files changed, 158 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 14d96b416..48400ca23 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2005-10-12 Philip Langdale <philipl@mail.utexas.edu>
+
+ * embed/ephy-embed.c
+ * embed/ephy-embed.h: (ephy_embed_shistory_copy).
+ Add a method to copy the back/forward history from
+ one embed to another.
+
+ * embed/mozilla/EphyBrowser.cpp:
+ * embed/mozilla/EphyBrowser.h:
+ (EphyBrowser::CopySHistory) Implementation of
+ history copying.
+
+ * embed/mozilla/mozilla-embed.cpp:
+ Implement ephy_embed_shistory_copy by calling into
+ EphyBrowser.
+
+ * src/ephy-navigation-action.c:
+ (activate_back_or_forward_menu_item_cb). If a
+ history menu item is middle-clicked on, open a new
+ tab, copy the history over and then go to the
+ relevant page in the history.
+
+ * src/ephy-toolbar.c: (ephy_toolbar_set_window) Attach
+ handler for "open-link" to back/forward actions.
+
2005-10-12 Christian Persch <chpe@cvs.gnome.org>
* embed/ephy-embed-single.c: (ephy_embed_single_iface_init),
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index b1128a835..8c27762e8 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -718,6 +718,28 @@ ephy_embed_shistory_go_nth (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 96e4ee77f..4f268cd3b 100644
--- a/embed/ephy-embed.h
+++ b/embed/ephy-embed.h
@@ -179,6 +179,11 @@ struct _EphyEmbedIface
int (* shistory_get_pos) (EphyEmbed *embed);
void (* shistory_go_nth) (EphyEmbed *embed,
int nth);
+ 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);
@@ -259,6 +264,12 @@ int ephy_embed_shistory_get_pos (EphyEmbed *embed);
void ephy_embed_shistory_go_nth (EphyEmbed *embed,
int nth);
+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/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index 77b7e2c5c..1bc8fc440 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -50,6 +50,8 @@
#include "nsIDocShellTreeNode.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIWebPageDescriptor.h"
+#include "nsISHistory.h"
+#include "nsISHistoryInternal.h"
#include "nsISHEntry.h"
#include "nsIHistoryEntry.h"
#include "nsIDOMHTMLDocument.h"
@@ -790,6 +792,62 @@ nsresult EphyBrowser::GetSHistory (nsISHistory **aSHistory)
return NS_OK;
}
+nsresult EphyBrowser::CopySHistory (EphyBrowser *dest, PRBool copy_back,
+ PRBool copy_forward, PRBool copy_current)
+{
+ nsresult rv;
+
+ nsCOMPtr<nsISHistory> h_src;
+ GetSHistory (getter_AddRefs(h_src));
+ NS_ENSURE_TRUE (h_src, NS_ERROR_FAILURE);
+
+ PRInt32 count, index;
+ h_src->GetCount (&count);
+ h_src->GetIndex (&index);
+
+ nsCOMPtr<nsISHistory> h_dest;
+ dest->GetSHistory (getter_AddRefs (h_dest));
+ NS_ENSURE_TRUE (h_dest, NS_ERROR_FAILURE);
+
+ nsCOMPtr<nsISHistoryInternal> hi_dest = do_QueryInterface (h_dest);
+ NS_ENSURE_TRUE (hi_dest, NS_ERROR_FAILURE);
+
+ if (count)
+ {
+ nsCOMPtr<nsIHistoryEntry> he;
+ nsCOMPtr<nsISHEntry> she, dhe;
+
+ for (PRInt32 i = (copy_back ? 0 : index + 1);
+ i < (copy_forward ? count : index + 1);
+ i++)
+ {
+ rv = h_src->GetEntryAtIndex (i, PR_FALSE,
+ getter_AddRefs (he));
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ she = do_QueryInterface (he);
+ NS_ENSURE_TRUE (she, NS_ERROR_FAILURE);
+
+ rv = she->Clone(getter_AddRefs (dhe));
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ rv = hi_dest->AddEntry (dhe, PR_TRUE);
+ NS_ENSURE_SUCCESS (rv, rv);
+ }
+
+ if (copy_current)
+ {
+ nsCOMPtr<nsIWebNavigation> wn_dest = do_QueryInterface (dest->mWebBrowser);
+ NS_ENSURE_TRUE (wn_dest, NS_ERROR_FAILURE);
+
+ rv = wn_dest->GotoIndex(index);
+ if (!NS_SUCCEEDED(rv)) return NS_ERROR_FAILURE;
+ }
+ }
+
+ return NS_OK;
+}
+
nsresult EphyBrowser::Destroy ()
{
DetachListeners ();
diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h
index 2020cf4f1..c21aac103 100644
--- a/embed/mozilla/EphyBrowser.h
+++ b/embed/mozilla/EphyBrowser.h
@@ -177,6 +177,9 @@ public:
nsresult GetSecurityInfo (PRUint32 *aState, nsACString &aDescription);
nsresult ShowCertificate ();
+ nsresult CopySHistory (EphyBrowser *dest, PRBool copy_back,
+ PRBool copy_forward, PRBool copy_current);
+
nsresult Close ();
EphyEmbedDocumentType GetDocumentType ();
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index 5116f12e3..5a684a54e 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -42,6 +42,7 @@
#include <nsMemory.h>
#include <nsIURI.h>
#include <nsIRequest.h>
+#include <nsIWebNavigation.h>
#include <nsIWebProgressListener.h>
#include <nsGfxCIID.h>
@@ -721,6 +722,20 @@ impl_shistory_go_nth (EphyEmbed *embed,
}
static void
+impl_shistory_copy (EphyEmbed *source,
+ EphyEmbed *dest,
+ gboolean copy_back,
+ gboolean copy_forward,
+ gboolean copy_current)
+{
+ MozillaEmbedPrivate *spriv = MOZILLA_EMBED(source)->priv;
+ MozillaEmbedPrivate *dpriv = MOZILLA_EMBED(dest)->priv;
+
+ spriv->browser->CopySHistory(dpriv->browser, copy_back,
+ copy_forward, copy_current);
+}
+
+static void
impl_get_security_level (EphyEmbed *embed,
EphyEmbedSecurityLevel *level,
char **description)
@@ -1169,6 +1184,7 @@ ephy_embed_iface_init (EphyEmbedIface *iface)
iface->shistory_get_nth = impl_shistory_get_nth;
iface->shistory_get_pos = impl_shistory_get_pos;
iface->shistory_go_nth = impl_shistory_go_nth;
+ iface->shistory_copy = impl_shistory_copy;
iface->get_security_level = impl_get_security_level;
iface->show_page_certificate = impl_show_page_certificate;
iface->close = impl_close;
diff --git a/src/ephy-navigation-action.c b/src/ephy-navigation-action.c
index 8ad4a18f0..e1c0dfd2b 100644
--- a/src/ephy-navigation-action.c
+++ b/src/ephy-navigation-action.c
@@ -143,12 +143,31 @@ activate_back_or_forward_menu_item_cb (GtkWidget *menuitem,
{
EphyEmbed *embed;
int go_nth;
+ char *url;
embed = ephy_window_get_active_embed (action->priv->window);
g_return_if_fail (embed != NULL);
go_nth = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menuitem), NTH_DATA_KEY));
+ url = g_object_get_data (G_OBJECT (menuitem), URL_DATA_KEY);
+ g_return_if_fail (url != NULL);
+
+ if (ephy_gui_is_middle_click ())
+ {
+ EphyEmbed *dest;
+ EphyTab *newTab;
+
+ newTab = ephy_link_open (EPHY_LINK (action), "about:blank", NULL,
+ EPHY_LINK_NEW_TAB);
+ g_return_if_fail (newTab != NULL);
+
+ dest = ephy_tab_get_embed (newTab);
+ g_return_if_fail (dest != NULL);
+
+ ephy_embed_shistory_copy (embed, dest, TRUE, TRUE, FALSE);
+ embed = dest;
+ }
ephy_embed_shistory_go_nth (embed, go_nth);
}
diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c
index 7f2127d07..b74f397ea 100755
--- a/src/ephy-toolbar.c
+++ b/src/ephy-toolbar.c
@@ -276,6 +276,8 @@ ephy_toolbar_set_window (EphyToolbar *toolbar,
NULL);
g_signal_connect (action, "activate",
G_CALLBACK (window_cmd_go_back), priv->window);
+ g_signal_connect_swapped (action, "open-link",
+ G_CALLBACK (ephy_link_open), toolbar);
gtk_action_group_add_action (priv->action_group, action);
g_object_unref (action);
@@ -294,6 +296,8 @@ ephy_toolbar_set_window (EphyToolbar *toolbar,
NULL);
g_signal_connect (action, "activate",
G_CALLBACK (window_cmd_go_forward), priv->window);
+ g_signal_connect_swapped (action, "open-link",
+ G_CALLBACK (ephy_link_open), toolbar);
gtk_action_group_add_action (priv->action_group, action);
g_object_unref (action);