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

Anish Mangal anishmangal2002 at gmail.com
Thu Jul 1 09:20:30 EDT 2010


Here is a screenshot

http://people.sugarlabs.org/anish/browse-tabbed.png

--Anish

P.S.  As a sidenote, we could have a better theme for displaying tab
widgets. If for example, the above screenshot had only two tabs
opened, it would be difficult to distinguish which is the active one.

On Thu, Jul 1, 2010 at 6:42 PM, Tomeu Vizoso <tomeu at sugarlabs.org> wrote:
> Any comments from the UX people? I hope the commit description is
> enough for imagining how it looks like (and if Anish had a link to a
> screenshot it would be great).
>
> Regards,
>
> Tomeu
>
> ---------- Forwarded message ----------
> From: anishmangal2002 <anishmangal2002 at gmail.com>
> Date: Tue, Jun 29, 2010 at 22:58
> Subject: [PATCH] Browse: Add support for creating multiple tabs
> To: lucian.branescu at gmail.com
> Cc: tomeu at sugarlabs.org, sugar-devel at lists.sugarlabs.org,
> anishmangal2002 <anishmangal2002 at gmail.com>
>
>
> 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
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>


More information about the Sugar-devel mailing list