diff options
author | Manuel Quiñones <manuq@laptop.org> | 2012-03-02 13:01:53 (GMT) |
---|---|---|
committer | Manuel Quiñones <manuq@laptop.org> | 2012-03-02 13:32:43 (GMT) |
commit | 86db5936822e154dcca279f72801dcae7bb17ec0 (patch) | |
tree | d82d669c5c9351987cd6dd224870bcef189c5b2c /browser.py | |
parent | 298d3bc54581f9701311bf03237d8a5a8d4d8332 (diff) |
Fix session history when the current item is at the beginning of the history
Removed conditionals that were checking for back history lenght == 0 to
handle the case of an empty tab, and added a proper conditional: a tab
is empty if the history list has only one item and that item is None.
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
Diffstat (limited to 'browser.py')
-rw-r--r-- | browser.py | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -432,10 +432,12 @@ class Browser(WebKit.WebView): def get_history(self): """Return the browsing history of this browser.""" back_forward_list = self.get_back_forward_list() - if back_forward_list.get_back_length() == 0: - return '' - items_list = self._items_history_as_list(back_forward_list) + + # If this is an empty tab, return an empty history: + if len(items_list) == 1 and items_list[0] is None: + return [] + history = [] for item in items_list: history.append({'url': item.get_uri(), @@ -462,11 +464,10 @@ class Browser(WebKit.WebView): def set_history_index(self, index): """Go to the item in the history specified by the index.""" back_forward_list = self.get_back_forward_list() - if back_forward_list.get_back_length() != 0: - current_item = index - back_forward_list.get_back_length() - item = back_forward_list.get_nth_item(current_item) - if item is not None: - self.go_to_back_forward_item(item) + current_item = index - back_forward_list.get_back_length() + item = back_forward_list.get_nth_item(current_item) + if item is not None: + self.go_to_back_forward_item(item) def _items_history_as_list(self, history): """Return a list with the items of a WebKit.WebBackForwardList.""" |