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

Gonzalo Odiard gonzalo at laptop.org
Fri May 4 16:48:32 EDT 2012


Thanks. Pushed and released Help 14

Gonzalo

On Thu, Apr 26, 2012 at 1:33 PM, Manuel Quiñones <manuq at laptop.org> wrote:

> El día 26 de abril de 2012 12:04, 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>
>
> Acked-by: Manuel Quiñones <manuq at laptop.org>
>
> > ---
> >  browser.py      |   43 -------------------------------------------
> >  helpactivity.py |   36 +++++++++++++++---------------------
> >  2 files changed, 15 insertions(+), 64 deletions(-)
> >  delete mode 100644 browser.py
> >
> > diff --git a/browser.py b/browser.py
> > deleted file mode 100644
> > index 85017cb..0000000
> > --- a/browser.py
> > +++ /dev/null
> > @@ -1,43 +0,0 @@
> > -# This program is free software; you can redistribute it and/or modify
> > -# it under the terms of the GNU General Public License as published by
> > -# the Free Software Foundation; either version 2 of the License, or
> > -# (at your option) any later version.
> > -#
> > -# This program is distributed in the hope that it will be useful,
> > -# but WITHOUT ANY WARRANTY; without even the implied warranty of
> > -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > -# GNU General Public License for more details.
> > -#
> > -# You should have received a copy of the GNU General Public License
> > -# along with this program; if not, write to the Free Software
> > -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
>  USA
> > -
> > -from gi.repository import WebKit
> > -
> > -_ZOOM_AMOUNT = 0.1
> > -
> > -
> > -class Browser(WebKit.WebView):
> > -    def __init__(self):
> > -        WebKit.WebView.__init__(self)
> > -
> > -    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
> > diff --git a/helpactivity.py b/helpactivity.py
> > index f8e3435..85ca801 100755
> > --- a/helpactivity.py
> > +++ b/helpactivity.py
> > @@ -17,14 +17,15 @@ from gettext import gettext as _
> >
> >  from gi.repository import Gtk
> >  from gi.repository import GObject
> > +from gi.repository import WebKit
> >
> >  from sugar3.activity import activity
> >  from sugar3.graphics.toolbutton import ToolButton
> > -from sugar3.graphics.toolbarbox import ToolbarBox, ToolbarButton
> > +from sugar3.graphics.toolbarbox import ToolbarBox
> > +from sugar3.graphics.toolbarbox import ToolbarButton
> >  from sugar3.activity.widgets import ActivityToolbarButton
> >  from sugar3.activity.widgets import StopButton
> >
> > -from browser import Browser
> >  from viewtoolbar import ViewToolbar
> >
> >  HOME = 'file://' + os.path.join(activity.get_bundle_path(),
> > @@ -37,8 +38,10 @@ class HelpActivity(activity.Activity):
> >
> >         self.props.max_participants = 1
> >
> > -        self._web_view = Browser()
> > -
> > +        self._web_view = WebKit.WebView()
> > +        _scrolled_window = Gtk.ScrolledWindow()
> > +        _scrolled_window.add(self._web_view)
> > +        _scrolled_window.show()
> >
> >         toolbar_box = ToolbarBox()
> >
> > @@ -48,7 +51,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 +99,8 @@ class HelpActivity(activity.Activity):
> >         self.set_toolbar_box(toolbar_box)
> >         toolbar_box.show()
> >
> > -        self.set_canvas(self._web_view)
> > +        self.set_canvas(_scrolled_window)
> >         self._web_view.show()
> > -
> >         self._web_view.load_uri(HOME)
> >
> >
> > @@ -128,31 +130,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
>
>
>
> --
> .. manuq ..
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20120504/607fe5c0/attachment.html>


More information about the Sugar-devel mailing list