[epiphany/tgt: 6/10] Handle back history button in document view



commit b3558e9f602180545f2354aa533ef34074f908bc
Author: Javier M. Mellid <jmunhoz igalia com>
Date:   Wed Aug 14 23:56:18 2013 +0200

    Handle back history button in document view
    
    WebKitBackForwardList is updated/handled by WebKit2 automatically. It
    can't be modified. New items are added when a web view loads new uris.
    
    Documents handled in document mode, such as pdf or djvu, are
    rendered/displayed by Ephy after a download so these uris aren't handled
    by WebKitWebView. As consecuence WebKitBackForwardList is not aware of
    any of these uris.
    
    All logic handling tab history depends on WebKitBackForwardList so if
    Ephy displays a document view and user click on back history button, Epy
    needs to be aware of changing mode and, at the same time, not back
    jumping over the current history item.
    
    Retrieving uri associated to web view, reloading that uri and restoring
    web view mode does the trick.

 src/ephy-navigation-history-action.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/ephy-navigation-history-action.c b/src/ephy-navigation-history-action.c
index dec2290..d4b1716 100644
--- a/src/ephy-navigation-history-action.c
+++ b/src/ephy-navigation-history-action.c
@@ -99,6 +99,20 @@ action_activate (GtkAction *action)
 
   web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
 
+  if (ephy_embed_get_mode (embed) == EPHY_EMBED_MODE_DOCUMENT) {
+    const char *current_uri;
+    WebKitBackForwardList *history;
+    WebKitBackForwardListItem *current_item;
+
+    history = webkit_web_view_get_back_forward_list (web_view);
+    current_item = webkit_back_forward_list_get_current_item (history);
+    current_uri = webkit_back_forward_list_item_get_original_uri (current_item);
+    webkit_web_view_load_uri (web_view, current_uri);
+    ephy_embed_set_mode (embed, EPHY_EMBED_MODE_WEB_VIEW);
+    gtk_widget_grab_focus (GTK_WIDGET (embed));
+    return;
+  }
+
   /* We use ephy_link_action_get_button on top of
    * ephy_gui_is_middle_click because of the hacks we have to do to
    * fake middle clicks on tool buttons. Read the documentation of


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