[Sugar-devel] [PATCH][Browse] Update progress bar and stop/reload buttons when switching tabs

Simon Schampijer simon at schampijer.de
Wed Mar 28 15:21:16 EDT 2012


This one looks good as well, please get it in.

Regards,
    Simon

On 03/23/2012 01:05 PM, Manuel Quiñones wrote:
> Calling the _set_status and _set_progress methods in the web toolbar
> directly when a new tab is activated.
>
> Also the callback for load-status is disconnected now in the previous
> tab, like the other callbacks.
>
> Removed the update of the navigation buttons when the loading status
> changes.  This is only needed when the adress changes or when the tabs
> are switched.
>
> Removed the title set to None when loading status chenges, this was
> giving the following Gtk error:
>
> Gtk-CRITICAL **: gtk_entry_set_text: assertion `text != NULL' failed
>
> Signed-off-by: Manuel Quiñones<manuq at laptop.org>
> ---
>   pdfviewer.py  |    1 -
>   webtoolbar.py |   18 +++++++++---------
>   2 files changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/pdfviewer.py b/pdfviewer.py
> index c7e2452..ef6a6ea 100644
> --- a/pdfviewer.py
> +++ b/pdfviewer.py
> @@ -366,7 +366,6 @@ class PDFTabPage(Gtk.HBox):
>
>       def __download_progress_cb(self, download, data):
>           progress = download.get_progress()
> -        self._browser.props.load_status = WebKit.LoadStatus.PROVISIONAL
>           self._browser.props.progress = progress
>
>       def __download_status_cb(self, download, data):
> diff --git a/webtoolbar.py b/webtoolbar.py
> index 7525053..654f720 100644
> --- a/webtoolbar.py
> +++ b/webtoolbar.py
> @@ -324,6 +324,7 @@ class PrimaryToolbar(ToolbarBase):
>               self._browser.disconnect(self._title_changed_hid)
>               self._browser.disconnect(self._uri_changed_hid)
>               self._browser.disconnect(self._progress_changed_hid)
> +            self._browser.disconnect(self._loading_changed_hid)
>
>           self._browser = browser
>           if self._browser.props.title:
> @@ -331,11 +332,11 @@ class PrimaryToolbar(ToolbarBase):
>           else:
>               self._set_title(_('Untitled'))
>           self._set_address(self._browser.props.uri)
> +        self._set_progress(self._browser.props.progress)
> +        self._set_status(self._browser.props.load_status)
>
> -        if isinstance(self._browser, Browser):
> -            self.entry.props.editable = True
> -        else:
> -            self.entry.props.editable = False
> +        is_webkit_browser = isinstance(self._browser, Browser)
> +        self.entry.props.editable = is_webkit_browser
>
>           self._title_changed_hid = self._browser.connect(
>                   'notify::title', self._title_changed_cb)
> @@ -349,15 +350,14 @@ class PrimaryToolbar(ToolbarBase):
>           self._update_navigation_buttons()
>
>       def __loading_changed_cb(self, widget, param):
> -        status = widget.get_load_status()
> -        if status<= WebKit.LoadStatus.COMMITTED:
> -            self._set_title(None)
> -        self._set_loading(status<  WebKit.LoadStatus.FINISHED)
> -        self._update_navigation_buttons()
> +        self._set_status(widget.get_load_status())
>
>       def __progress_changed_cb(self, widget, param):
>           self._set_progress(widget.get_progress())
>
> +    def _set_status(self, status):
> +        self._set_loading(status<  WebKit.LoadStatus.FINISHED)
> +
>       def _set_progress(self, progress):
>           if progress == 1.0:
>               self.entry.set_progress_fraction(0.0)



More information about the Sugar-devel mailing list