[Sugar-devel] [PATCH] Change toolbar to enable the use in Sugar < 0.86

Gonzalo Odiard gonzalo at laptop.org
Tue Nov 2 22:37:04 EDT 2010


Thanks James, and sorry by doing lost your time.
When I worked with the second patch from Anish, I understand more changes
needed.

The new patch is
http://lists.sugarlabs.org/archive/sugar-devel/2010-November/028511.html

Gonzalo


On Tue, Nov 2, 2010 at 9:39 PM, James Cameron <quozl at laptop.org> wrote:

> Reviewed-by: James Cameron <quozl at laptop.org>
>
> On Tue, Nov 02, 2010 at 10:07:21AM -0300, godiard at sugarlabs.org wrote:
> > From: Gonzalo Odiard <godiard at sugarlabs.org>
> >
>
> No commit message body, but the subject said it well.
>
> > -        activity_toolbar.insert(gobutton, 2)
> > +        activity_toolbar.insert(gobutton, -1 if OLD_TOOLBAR else 2)
>
> I'd like to see this factored out into a function.  Here's what I mean:
>
>
> diff --git a/pippy_app.py b/pippy_app.py
> index fc8aaaa..01a6020 100644
> --- a/pippy_app.py
> +++ b/pippy_app.py
> @@ -45,6 +45,12 @@ PYTHON_PREFIX="""#!/usr/bin/python
>  # -*- coding: utf-8 -*-
>  """
>
> +OLD_TOOLBAR = False
> +try:
> +    from sugar.graphics.toolbarbox import ToolbarBox
> +except ImportError:
> +    OLD_TOOLBAR = True
> +
>  # get screen sizes
>  SIZE_X = gtk.gdk.screen_width()
>  SIZE_Y = gtk.gdk.screen_height()
> @@ -80,6 +86,13 @@ class PippyActivity(ViewSourceActivity,
> groupthink.sugar_tools.GroupActivity):
>          palette.menu.append(menu_item)
>         menu_item.show()
>
> +       if OLD_TOOLBAR:
> +           activity_toolbar = gtk.Toolbar()
> +           toolbox.add_toolbar('Pippy',activity_toolbar)
> +           toolbox.set_current_toolbar(1)
> +        def pos(x):
> +            return -1 if OLD_TOOLBAR else x
> +
>         # The "go" button
>         goicon_bw = gtk.Image()
>         goicon_bw.set_from_file("%s/icons/run_bw.svg" % os.getcwd())
> @@ -92,7 +105,7 @@ class PippyActivity(ViewSourceActivity,
> groupthink.sugar_tools.GroupActivity):
>          gobutton.connect('clicked', self.flash_cb, dict({'bw':goicon_bw,
>             'color':goicon_color}))
>         gobutton.connect('clicked', self.gobutton_cb)
> -        activity_toolbar.insert(gobutton, 2)
> +        activity_toolbar.insert(gobutton, pos(2))
>
>         # The "stop" button
>         stopicon_bw = gtk.Image()
> @@ -106,7 +119,7 @@ class PippyActivity(ViewSourceActivity,
> groupthink.sugar_tools.GroupActivity):
>              'color':stopicon_color}))
>         stopbutton.connect('clicked', self.stopbutton_cb)
>         stopbutton.set_tooltip("Stop Running")
> -        activity_toolbar.insert(stopbutton, 3)
> +        activity_toolbar.insert(stopbutton, pos(3))
>
>         # The "clear" button
>         clearicon_bw = gtk.Image()
> @@ -120,12 +133,12 @@ class PippyActivity(ViewSourceActivity,
> groupthink.sugar_tools.GroupActivity):
>          clearbutton.connect('clicked', self.flash_cb,
> dict({'bw':clearicon_bw,
>             'color':clearicon_color}))
>         clearbutton.set_tooltip("Clear")
> -        activity_toolbar.insert(clearbutton, 4)
> +        activity_toolbar.insert(clearbutton, pos(4))
>
>         # A vertical toolbar separator
>         separator = gtk.SeparatorToolItem()
>         separator.set_draw(True)
> -        activity_toolbar.insert(separator, 5)
> +        activity_toolbar.insert(separator, pos(5))
>          activity_toolbar.show_all()
>
>         self.set_toolbox(toolbox)
>
> --
> James Cameron
> http://quozl.linux.org.au/
> _______________________________________________
> 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/20101102/d2951cf2/attachment.html>


More information about the Sugar-devel mailing list