[Sugar-devel] [PATCH] Browse: Add support for creating multiple tabs

Lucian Branescu lucian.branescu at gmail.com
Tue Jun 29 17:26:22 EDT 2010


I'm not sure it's a good idea to merge this if it causes Browse (vital
app) to occasionally crash on SoaS (very popular Sugar environment).
At the very least, the tabs feature should be disabled if that certain
version of cairo is detected.

Also, it would be more convenient if you put your work in a fork of
Browse at http://git.sugarlabs.org/projects/browse

On 29 June 2010 22:19, Anish Mangal <anishmangal2002 at gmail.com> wrote:
>> 1. On f13 based sugar environments (such as soas3, jhbuild-0.88), this
>
> Oops, I meant soas3 and jhbuild-0.88 running on f13.
>
> On Wed, Jun 30, 2010 at 2:46 AM, Anish Mangal <anishmangal2002 at gmail.com> wrote:
>> Note:
>>
>> 1. On f13 based sugar environments (such as soas3, jhbuild-0.88), this
>> patch will occasionally cause Browse to crash when closing tabs. This
>> probably happens because of a bug [1] (or something very similar to
>> this). As a workaround, one can downgrade the cairo package from
>> cairo-1.8.10 to cairo-1.8.8-1.fc11 (or upgrade to the latest
>> development version 1.9.10-1, though I haven't tested that).
>>
>> 2. This patch doesn't add an entry 'open link in new tab' to the
>> context menu. That can
> come as a separate patch.
>>
>>
>> [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=551852
>>
>> --
>> Anish Mangal
>> anish at sugarlabs.org
>>
>>
>> On Wed, Jun 30, 2010 at 2:28 AM, anishmangal2002
>> <anishmangal2002 at gmail.com> wrote:
>>> This patch adds support to create multiple tabbed windows
>>> in Browse. A tab may be added by either clicking the add tab
>>> ('+') icon in the activity toolbar or by pressing 'ctrl+t'.
>>>
>>> Signed-off-by: anishmangal2002 <anishmangal2002 at gmail.com>
>>> ---
>>>  icons/add-tab.svg |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>  webactivity.py    |   11 +++++++
>>>  webtoolbar.py     |   21 +++++++++++++
>>>  3 files changed, 118 insertions(+), 0 deletions(-)
>>>  create mode 100644 icons/add-tab.svg
>>>
>>> diff --git a/icons/add-tab.svg b/icons/add-tab.svg
>>> new file mode 100644
>>> index 0000000..0220993
>>> --- /dev/null
>>> +++ b/icons/add-tab.svg
>>> @@ -0,0 +1,86 @@
>>> +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
>>> +<!-- Created with Inkscape (http://www.inkscape.org/) -->
>>> +
>>> +<svg
>>> +   xmlns:dc="http://purl.org/dc/elements/1.1/"
>>> +   xmlns:cc="http://creativecommons.org/ns#"
>>> +   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>>> +   xmlns:svg="http://www.w3.org/2000/svg"
>>> +   xmlns="http://www.w3.org/2000/svg"
>>> +   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
>>> +   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
>>> +   version="1.1"
>>> +   width="55"
>>> +   height="55"
>>> +   id="svg2"
>>> +   inkscape:version="0.47 r22583"
>>> +   sodipodi:docname="add-tab.svg">
>>> +  <metadata
>>> +     id="metadata10">
>>> +    <rdf:RDF>
>>> +      <cc:Work
>>> +         rdf:about="">
>>> +        <dc:format>image/svg+xml</dc:format>
>>> +        <dc:type
>>> +           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
>>> +      </cc:Work>
>>> +    </rdf:RDF>
>>> +  </metadata>
>>> +  <sodipodi:namedview
>>> +     pagecolor="#ffffff"
>>> +     bordercolor="#666666"
>>> +     borderopacity="1"
>>> +     objecttolerance="10"
>>> +     gridtolerance="10"
>>> +     guidetolerance="10"
>>> +     inkscape:pageopacity="0"
>>> +     inkscape:pageshadow="2"
>>> +     inkscape:window-width="1280"
>>> +     inkscape:window-height="721"
>>> +     id="namedview8"
>>> +     showgrid="false"
>>> +     inkscape:zoom="4.2909091"
>>> +     inkscape:cx="27.5"
>>> +     inkscape:cy="27.033898"
>>> +     inkscape:window-x="0"
>>> +     inkscape:window-y="27"
>>> +     inkscape:window-maximized="1"
>>> +     inkscape:current-layer="layer1" />
>>> +  <defs
>>> +     id="defs4">
>>> +    <inkscape:perspective
>>> +       sodipodi:type="inkscape:persp3d"
>>> +       inkscape:vp_x="0 : 27.5 : 1"
>>> +       inkscape:vp_y="0 : 1000 : 0"
>>> +       inkscape:vp_z="55 : 27.5 : 1"
>>> +       inkscape:persp3d-origin="27.5 : 18.333333 : 1"
>>> +       id="perspective12" />
>>> +  </defs>
>>> +  <g
>>> +     transform="translate(0,-997.36218)"
>>> +     id="layer1">
>>> +    <rect
>>> +       width="55"
>>> +       height="55"
>>> +       x="0"
>>> +       y="0"
>>> +       transform="translate(0,997.36218)"
>>> +       id="rect2818"
>>> +       style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:none" />
>>> +    <rect
>>> +       width="9"
>>> +       height="38"
>>> +       x="23"
>>> +       y="1005.8622"
>>> +       id="rect3599"
>>> +       style="fill:#ffffff;fill-opacity:1;stroke:none" />
>>> +    <rect
>>> +       width="8.94349"
>>> +       height="37.99044"
>>> +       x="1020.3485"
>>> +       y="-47.595592"
>>> +       transform="matrix(-0.00107369,0.99999942,-0.99999889,-0.00148761,0,0)"
>>> +       id="rect3599-4"
>>> +       style="fill:#ffffff;fill-opacity:1;stroke:none" />
>>> +  </g>
>>> +</svg>
>>> diff --git a/webactivity.py b/webactivity.py
>>> index 4be551e..5f4f917 100644
>>> --- a/webactivity.py
>>> +++ b/webactivity.py
>>> @@ -152,6 +152,7 @@ def _set_accept_languages():
>>>     logging.debug('LANG set')
>>>
>>>  from browser import TabbedView
>>> +from browser import Browser
>>>  from webtoolbar import PrimaryToolbar
>>>  from edittoolbar import EditToolbar
>>>  from viewtoolbar import ViewToolbar
>>> @@ -443,6 +444,16 @@ class WebActivity(activity.Activity):
>>>                 _logger.debug('keyboard: Zoom in')
>>>                 self._tabbed_view.props.current_browser.zoom_in()
>>>                 return True
>>> +            elif gtk.gdk.keyval_name(event.keyval) == "t":
>>> +                browser = Browser()
>>> +                self._tabbed_view._append_tab(browser)
>>> +                if os.path.isfile(_LIBRARY_PATH):
>>> +                    browser.load_uri('file://' + _LIBRARY_PATH)
>>> +                else:
>>> +                    default_page = os.path.join(activity.get_bundle_path(),
>>> +                                            "data/index.html")
>>> +                    browser.load_uri(default_page)
>>> +
>>>         return False
>>>
>>>     def _add_link(self):
>>> diff --git a/webtoolbar.py b/webtoolbar.py
>>> index 854345c..99979ca 100644
>>> --- a/webtoolbar.py
>>> +++ b/webtoolbar.py
>>> @@ -18,6 +18,9 @@
>>>
>>>  from gettext import gettext as _
>>>
>>> +_LIBRARY_PATH = '/usr/share/library-common/index.html'
>>> +
>>> +import os
>>>  import gobject
>>>  import gtk
>>>  import pango
>>> @@ -31,6 +34,7 @@ from sugar.graphics.toolbarbox import ToolbarBox
>>>  from sugar.activity.widgets import ActivityToolbarButton
>>>  from sugar.activity.widgets import StopButton
>>>  from sugar.activity import activity
>>> +from browser import Browser
>>>
>>>  import filepicker
>>>  import places
>>> @@ -267,6 +271,13 @@ class PrimaryToolbar(ToolbarBox):
>>>         self.toolbar.insert(self._forward, -1)
>>>         self._forward.show()
>>>
>>> +        self._add_tab = ToolButton('add-tab')
>>> +        self._add_tab.set_tooltip(_('Add a tab'))
>>> +        self._add_tab.props.sensitive = True
>>> +        self._add_tab.connect('clicked', self._add_tab_cb)
>>> +        self.toolbar.insert(self._add_tab, -1)
>>> +        self._add_tab.show()
>>> +
>>>         self._link_add = ToolButton('emblem-favorite')
>>>         self._link_add.set_tooltip(_('Bookmark'))
>>>         self._link_add.connect('clicked', self._link_add_clicked_cb)
>>> @@ -385,6 +396,16 @@ class PrimaryToolbar(ToolbarBox):
>>>         browser.load_uri(entry.props.text)
>>>         browser.grab_focus()
>>>
>>> +    def _add_tab_cb(self, button):
>>> +        browser = Browser()
>>> +        self._tabbed_view._append_tab(browser)
>>> +        if os.path.isfile(_LIBRARY_PATH):
>>> +            browser.load_uri('file://' + _LIBRARY_PATH)
>>> +        else:
>>> +            default_page = os.path.join(activity.get_bundle_path(),
>>> +                                    "data/index.html")
>>> +            browser.load_uri(default_page)
>>> +
>>>     def _go_back_cb(self, button):
>>>         browser = self._tabbed_view.props.current_browser
>>>         browser.web_navigation.goBack()
>>> --
>>> 1.7.0.1
>>>
>>>
>>
>


More information about the Sugar-devel mailing list