On Mon, Jun 6, 2011 at 3:31 PM, <span dir="ltr"><<a href="mailto:godiard@sugarlabs.org">godiard@sugarlabs.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
From: Gonzalo Odiard <<a href="mailto:godiard@gmail.com">godiard@gmail.com</a>><br>
<br>
If the user go back, or select any page in the history and<br>
close the activity, need restore at the next start, the history,<br>
and the index in the history too.<br>
---<br>
browser.py | 6 ++++++<br>
webactivity.py | 24 ++++++++++--------------<br>
2 files changed, 16 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/browser.py b/browser.py<br>
index b9c1f69..9bb7a1b 100644<br>
--- a/browser.py<br>
+++ b/browser.py<br>
@@ -351,6 +351,12 @@ class Browser(WebView):<br>
interfaces.nsIMarkupDocumentViewer)<br>
markupDocumentViewer.fullZoom -= _ZOOM_AMOUNT<br>
<br>
+ def get_history_index(self):<br>
+ return self.web_navigation.sessionHistory.index<br>
+<br>
+ def set_history_index(self, index):<br>
+ self.web_navigation.gotoIndex(index)<br>
+<br>
<br>
class PopupDialog(gtk.Window):<br>
def __init__(self):<br>
diff --git a/webactivity.py b/webactivity.py<br>
index 48cb3ed..8619144 100644<br>
--- a/webactivity.py<br>
+++ b/webactivity.py<br>
@@ -458,6 +458,12 @@ class WebActivity(activity.Activity):<br>
link['owner'], -1, link['hash'])<br>
logging.debug('########## reading %s', data)<br>
self._tabbed_view.set_session(self.model.data['history'])<br>
+ tab_number = 0<br>
+ for current in self.model.data['currents']:<br>
+ browser = self._tabbed_view.get_nth_page(tab_number)<br>
+ browser.set_history_index(current['index'])<br>
+ tab_number = tab_number + 1<br>
+<br>
self._tabbed_view.set_current_page(self.model.data['current_tab'])<br>
elif self.metadata['mime_type'] == 'text/uri-list':<br>
data = self._get_data_from_file_path(file_path)<br>
@@ -469,19 +475,6 @@ class WebActivity(activity.Activity):<br>
'list of multiple uris by now.')<br>
else:<br>
self._tabbed_view.props.current_browser.load_uri(file_path)<br>
- self._load_urls()<br>
-<br>
- def _load_urls(self):<br>
- if self.model.data['currents'] != None:<br>
- first = True<br>
- for current_tab in self.model.data['currents']:<br>
- if first:<br>
- browser = self._tabbed_view.current_browser<br>
- first = False<br>
- else:<br>
- browser = Browser()<br>
- self._tabbed_view._append_tab(browser)<br>
- browser.load_uri(current_tab['url'])<br>
<br>
def write_file(self, file_path):<br>
if not self.metadata['mime_type']:<br>
@@ -505,7 +498,10 @@ class WebActivity(activity.Activity):<br>
if n_browser != None:<br>
nsiuri = browser.progress.location<br>
ui_uri = browser.get_url_from_nsiuri(nsiuri)<br>
- info = {'title': browser.props.title, 'url': ui_uri}<br>
+ index = browser.get_history_index()<br>
+ info = {'title': browser.props.title, 'url': ui_uri,<br>
+ 'index': index}<br>
+<br>
self.model.data['currents'].append(info)<br>
<br>
f = open(file_path, 'w')<br>
<font color="#888888">--<br>
1.7.4.4<br>
<br></font></blockquote><div><br></div><div>Tested and works as expected. </div><div><br></div><div>Thanks and cheers. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<font color="#888888">
_______________________________________________<br>
Sugar-devel mailing list<br>
<a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
<a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
</font></blockquote></div><br>