[Sugar-devel] [PATCH 1/2] Browse: always show tabs

Gary Martin garycmartin at googlemail.com
Sun Sep 4 17:42:58 EDT 2011


Hi Manuel,

On 4 Sep 2011, at 22:11, Manuel Quiñones <manuq at laptop.org> wrote:

> This was discussed and decided in Design Meeting of 29 Aug, improving
> the tabs usability in Browse.
> 
> If there is only one tab and it is closed, a new tab is created
> showing the homepage.  In order to do that, the _show_homepage method
> was moved from WebActivity class to Browser class.

Did we cover this in the Design Meeting? Seems new to me.

Can we not prevent the last tab from being closed (remove the x when we are down to the last tab), or is this behaviour being considered as a new way to get to the Home page (allowing the home toolbar icon to be removed to provide more URL entry space).

Apologies if I've misunderstood something.

Regards,
--Gary

> Signed-off-by: Manuel Quiñones <manuq at laptop.org>
> ---
> browser.py     |   20 ++++++++++++++++++--
> webactivity.py |   25 ++++---------------------
> 2 files changed, 22 insertions(+), 23 deletions(-)
> 
> diff --git a/browser.py b/browser.py
> index 96e6fb1..c9a80c3 100644
> --- a/browser.py
> +++ b/browser.py
> @@ -38,6 +38,7 @@ from sessionhistory import HistoryListener
> from progresslistener import ProgressListener
> 
> _ZOOM_AMOUNT = 0.1
> +_LIBRARY_PATH = '/usr/share/library-common/index.html'
> 
> 
> class SaveListener(object):
> @@ -173,12 +174,27 @@ class TabbedView(gtk.Notebook):
>         browser.show()
> 
>         self.set_current_page(-1)
> -        self.props.show_tabs = self.get_n_pages() > 1
> 
>     def __tab_close_cb(self, label, browser):
>         self.remove_page(self.page_num(browser))
>         browser.destroy()
> -        self.props.show_tabs = self.get_n_pages() > 1
> +        if self.get_n_pages() == 0:
> +            self._load_homepage(new_tab=True)
> +
> +    def _load_homepage(self, new_tab=False):
> +        # If new_tab is True, open the homepage in a new tab.
> +        if new_tab:
> +            browser = Browser()
> +            self._append_tab(browser)
> +        else:
> +            browser = self.current_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 _get_current_browser(self):
>         return self.get_nth_page(self.get_current_page())
> diff --git a/webactivity.py b/webactivity.py
> index fb1fec8..c6dcc13 100644
> --- a/webactivity.py
> +++ b/webactivity.py
> @@ -177,8 +177,6 @@ from edittoolbar import EditToolbar
> from viewtoolbar import ViewToolbar
> import downloadmanager
> 
> -_LIBRARY_PATH = '/usr/share/library-common/index.html'
> -
> from model import Model
> from sugar.presence.tubeconn import TubeConnection
> from messenger import Messenger
> @@ -292,7 +290,7 @@ class WebActivity(activity.Activity):
>         elif not self._jobject.file_path:
>             # TODO: we need this hack until we extend the activity API for
>             # opening URIs and default docs.
> -            self._load_homepage()
> +            self._tabbed_view._load_homepage()
> 
>         self.messenger = None
>         self.connect('shared', self._shared_cb)
> @@ -322,7 +320,7 @@ class WebActivity(activity.Activity):
>             _logger.debug('Created activity')
> 
>     def _new_tab_cb(self, gobject):
> -        self._load_homepage(new_tab=True)
> +        self._tabbed_view._load_homepage(new_tab=True)
> 
>     def _shared_cb(self, activity_):
>         _logger.debug('My activity was shared')
> @@ -425,21 +423,6 @@ class WebActivity(activity.Activity):
>             self.messenger = Messenger(self.tube_conn, self.initiating,
>                                        self.model)
> 
> -    def _load_homepage(self, new_tab=False):
> -        # If new_tab is True, open the homepage in a new tab.
> -        if new_tab:
> -            browser = Browser()
> -            self._tabbed_view._append_tab(browser)
> -        else:
> -            browser = self._tabbed_view.current_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 _get_data_from_file_path(self, file_path):
>         fd = open(file_path, 'r')
>         try:
> @@ -518,7 +501,7 @@ class WebActivity(activity.Activity):
>         self._add_link()
> 
>     def _go_home_button_cb(self, button):
> -        self._load_homepage()
> +        self._tabbed_view._load_homepage()
> 
>     def _key_press_cb(self, widget, event):
>         key_name = gtk.gdk.keyval_name(event.keyval)
> @@ -555,7 +538,7 @@ class WebActivity(activity.Activity):
>                 browser.web_navigation.reload(flags)
>             elif gtk.gdk.keyval_name(event.keyval) == "t":
>                 if not self._disable_multiple_tabs:
> -                    self._load_homepage(new_tab=True)
> +                    self._tabbed_view._load_homepage(new_tab=True)
>             else:
>                 return False
> 
> -- 
> 1.7.4.4
> 
> _______________________________________________
> 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