Copy the back forward history when opening a new tab

This commit is contained in:
Christian Dywan 2009-07-30 23:38:14 +02:00
parent 0057f32f1e
commit 420f2f02c5

View file

@ -1089,6 +1089,32 @@ midori_view_attach_inspector_cb (GtkWidget* view,
browser->inspector_view = inspector_view; browser->inspector_view = inspector_view;
} }
static void
midori_browser_view_copy_history (GtkWidget* view_to,
GtkWidget* view_from)
{
WebKitWebView* copy_from;
WebKitWebBackForwardList* list_from;
WebKitWebView* copy_to;
WebKitWebBackForwardList* list_to;
guint length_from;
guint i;
copy_from = WEBKIT_WEB_VIEW (gtk_bin_get_child (GTK_BIN (view_from)));
list_from = webkit_web_view_get_back_forward_list (copy_from);
copy_to = WEBKIT_WEB_VIEW (gtk_bin_get_child (GTK_BIN (view_to)));
list_to = webkit_web_view_get_back_forward_list (copy_to);
length_from = webkit_web_back_forward_list_get_back_length (list_from);
g_return_if_fail (!webkit_web_back_forward_list_get_back_length (list_to));
for (i = -length_from; i <= 0; i++)
{
webkit_web_back_forward_list_add_item (list_to,
webkit_web_back_forward_list_get_nth_item (list_from, i));
}
}
static void static void
midori_view_new_tab_cb (GtkWidget* view, midori_view_new_tab_cb (GtkWidget* view,
const gchar* uri, const gchar* uri,
@ -1096,6 +1122,9 @@ midori_view_new_tab_cb (GtkWidget* view,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
gint n = midori_browser_add_uri (browser, uri); gint n = midori_browser_add_uri (browser, uri);
midori_browser_view_copy_history (midori_browser_get_nth_tab (browser, n),
view);
if (!background) if (!background)
midori_browser_set_current_page (browser, n); midori_browser_set_current_page (browser, n);
} }