[Sugar-devel] [PATCH Browse v2] Display 'Loading...' message in the tab and url titles while the page is loading #3550

Manuel Kaufmann humitos at gmail.com
Fri May 4 08:33:44 EDT 2012


On Fri, May 4, 2012 at 9:28 AM, Manuel Kaufmann <humitos at gmail.com> wrote:
> +    def __load_status_changed_cb(self, widget, param):
> +        status = widget.get_load_status()
> +        if WebKit.LoadStatus.PROVISIONAL <= status \
> +                < WebKit.LoadStatus.FINISHED:
> +            self._label.set_text(_('Loading...'))
> +        elif status == WebKit.LoadStatus.FINISHED:
> +            if widget.props.title == None:
> +                self._label.set_text(_('Untitled'))
> +
>
>  class Browser(WebKit.WebView):
>     __gtype_name__ = 'Browser'
> diff --git a/webtoolbar.py b/webtoolbar.py
> index d0f2dc9..cc53f2d 100644
> --- a/webtoolbar.py
> +++ b/webtoolbar.py
> @@ -350,6 +350,13 @@ class PrimaryToolbar(ToolbarBase):
>         self._update_navigation_buttons()
>
>     def __loading_changed_cb(self, widget, param):
> +        status = widget.get_load_status()
> +        if WebKit.LoadStatus.PROVISIONAL <= status \
> +                < WebKit.LoadStatus.FINISHED:
> +            self.entry._set_title(_('Loading...'))
> +        elif status == WebKit.LoadStatus.FINISHED:
> +            if widget.props.title == None:
> +                self.entry._set_title(_('Loading...'))

I have a question about this portion of code.

We have the exactly the same code here with the different of the
widget that we are modifying: self.entry._set_title and
self._label.set_text.

They are in different files and that signal is managed by different
widgets that have to do something with their own properties. So, is
this the correct form to do this? I mean, it seems to be a case of
"N"DRY (Not Don't Repeat yourself)


-- 
Kaufmann Manuel
Blog: http://humitos.wordpress.com/
Porfolio: http://fotos.mkaufmann.com.ar/
PyAr: http://www.python.com.ar/


More information about the Sugar-devel mailing list