[Sugar-devel] [PATCH Help v2] Migrated to Gtk3 and WebKit.WebView SL #3466

Manuel Quiñones manuq at laptop.org
Wed Apr 25 09:12:05 EDT 2012


Hi,

Overall, great job!  Just a few details:

El día 25 de abril de 2012 09:41, Manuel Kaufmann <humitos at gmail.com> escribió:
>  - All the code was migrated to Gtk3 following this guide[1]
>  - Toolbar View's icon was changed from "camera" to the right one:
>   "toolbar-view"
>  - Back and Forward buttons are working properly
>  - WebKit.WebView inside a Gtk.ScrolledWindow to be able to scroll the page.
>
> [1] http://wiki.sugarlabs.org/go/Features/GTK3/Porting
>
> Signed-off-by: Manuel Kaufmann <humitos at gmail.com>
> ---
>  browser.py      |   18 ------------------
>  helpactivity.py |   29 +++++++++++------------------
>  2 files changed, 11 insertions(+), 36 deletions(-)
>
> diff --git a/browser.py b/browser.py
> index 85017cb..650e5c0 100644
> --- a/browser.py
> +++ b/browser.py
> @@ -23,21 +23,3 @@ class Browser(WebKit.WebView):
>
>     def do_setup(self):
>         WebKit.WebView.do_setup(self)
> -
> -    def zoom_in(self):
> -        # contentViewer = self.doc_shell.queryInterface( \
> -        #         interfaces.nsIDocShell).contentViewer
> -        # if contentViewer is not None:
> -        #     markupDocumentViewer = contentViewer.queryInterface( \
> -        #             interfaces.nsIMarkupDocumentViewer)
> -        #     markupDocumentViewer.fullZoom += _ZOOM_AMOUNT
> -        pass
> -
> -    def zoom_out(self):
> -        # contentViewer = self.doc_shell.queryInterface( \
> -        #         interfaces.nsIDocShell).contentViewer
> -        # if contentViewer is not None:
> -        #     markupDocumentViewer = contentViewer.queryInterface( \
> -        #             interfaces.nsIMarkupDocumentViewer)
> -        #     markupDocumentViewer.fullZoom -= _ZOOM_AMOUNT
> -        pass

Now that you removed all that code, is browser.py needed at all?
_ZOOM_AMOUNT is not being used and WebKit.WebView does not have
do_setup method, and is not used too.  Please remove browser.py  .

> diff --git a/helpactivity.py b/helpactivity.py
> index f8e3435..a1cdf2e 100755
> --- a/helpactivity.py
> +++ b/helpactivity.py
> @@ -38,7 +38,9 @@ class HelpActivity(activity.Activity):
>         self.props.max_participants = 1
>
>         self._web_view = Browser()
> -
> +        self._scrolled_window = Gtk.ScrolledWindow()
> +        self._scrolled_window.add(self._web_view)
> +        self._scrolled_window.show()

There is no need to be a private attribute, self can be safely
removed, use just scrolled_window name for the variable.

>
>         toolbar_box = ToolbarBox()
>
> @@ -48,7 +50,7 @@ class HelpActivity(activity.Activity):
>
>         viewtoolbar = ViewToolbar(self)
>         viewbutton = ToolbarButton(page=viewtoolbar, \
> -                                   icon_name='camera')
> +                                   icon_name='toolbar-view')
>         toolbar_box.toolbar.insert(viewbutton, -1)
>         viewbutton.show()
>
> @@ -96,9 +98,8 @@ class HelpActivity(activity.Activity):
>         self.set_toolbar_box(toolbar_box)
>         toolbar_box.show()
>
> -        self.set_canvas(self._web_view)
> +        self.set_canvas(self._scrolled_window)
>         self._web_view.show()
> -
>         self._web_view.load_uri(HOME)
>
>
> @@ -128,31 +129,23 @@ class Toolbar(Gtk.Toolbar):
>         self.insert(self._home, -1)
>         self._home.show()
>
> -        """
> -        progress_listener = self._web_view.progress
> -        progress_listener.connect('location-changed',
> -                                  self._location_changed_cb)
> -        progress_listener.connect('loading-stop', self._loading_stop_cb)
> -        """
> +        self._web_view.connect('notify::uri', self._uri_changed_cb)
>
> -    def _location_changed_cb(self, progress_listener, uri):
> +    def _uri_changed_cb(self, progress_listener, uri):
>         self.update_navigation_buttons()
>
>     def _loading_stop_cb(self, progress_listener):
>         self.update_navigation_buttons()
>
>     def update_navigation_buttons(self):
> -        can_go_back = self._web_view.web_navigation.canGoBack
> -        self._back.props.sensitive = can_go_back
> -
> -        can_go_forward = self._web_view.web_navigation.canGoForward
> -        self._forward.props.sensitive = can_go_forward
> +        self._back.props.sensitive = self._web_view.can_go_back()
> +        self._forward.props.sensitive = self._web_view.can_go_forward()
>
>     def _go_back_cb(self, button):
> -        self._web_view.web_navigation.goBack()
> +        self._web_view.go_back()
>
>     def _go_forward_cb(self, button):
> -        self._web_view.web_navigation.goForward()
> +        self._web_view.go_forward()
>
>     def _go_home_cb(self, button):
>         self._web_view.load_uri(HOME)
> --
> 1.7.10
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel

Reviewed-by: Manuel Quiñones <manuq at laptop.org>

-- 
.. manuq ..


More information about the Sugar-devel mailing list