[Sugar-devel] [PATCH] Browse: Set and restore index in the history - Fix OLPC #10779

Sascha Silbe sascha-ml-reply-to-2011-3 at silbe.org
Tue Jun 7 17:19:05 EDT 2011


Excerpts from godiard's message of Mon Jun 06 22:31:48 +0200 2011:

> If the user go back, or select any page in the history and
> close the activity, need restore at the next start, the history,
> and the index in the history too.

Please mentions the upstream ticket (SL#2499 [1]) as well.

I tried your patch and while it did restore all tabs (something I wasn't
sure it'd do from reading the code), both the history and the current
page in at least one tab were different after Stop/Resume.

> +            tab_number = 0
> +            for current in self.model.data['currents']:
> +                browser = self._tabbed_view.get_nth_page(tab_number)
> +                browser.set_history_index(current['index'])
> +                tab_number = tab_number + 1

You can use enumerate() instead:

            for number, tab in enumerate(self.model.data['currents']):
                browser = self._tabbed_view.get_nth_page(number)
                browser.set_history_index(current['history_index'])

> @@ -505,7 +498,10 @@ class WebActivity(activity.Activity):
>                  if n_browser != None:
>                      nsiuri = browser.progress.location
>                      ui_uri = browser.get_url_from_nsiuri(nsiuri)
> -                    info = {'title': browser.props.title, 'url': ui_uri}
> +                    index = browser.get_history_index()
> +                    info = {'title': browser.props.title, 'url': ui_uri,
> +                            'index': index}

Renaming index to history_index would make its meaning clearer.

Sascha

[1] https://bugs.sugarlabs.org/ticket/2499
-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 494 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20110607/a3ef1aa2/attachment.pgp>


More information about the Sugar-devel mailing list