[sugar] pulsing icon code move from sugar to sugar-toolkit?

Martin Dengler martin at martindengler.com
Sat Jul 19 22:34:19 EDT 2008


Hi sugar@,

As part of fixing #6995, I'd like to propose we move the contents of
sugar/view/pulsingicon.py into sugar-toolkit/graphics/pulsingicon.py.
The situation I need to handle is that a
sugar-toolkit/graphics/tray.TrayIcon needs to pulse, via its
sugar-toolkit/graphics/icon.Icon member[1].

A straw-man (that works, but isn't pretty - look for #FIXME's)
implementation so you can see the rough design / example as to how to
create a pulsing subclass of sugar-toolkit/graphics/icon.Icon:

http://dev.laptop.org/git?p=users/mdengler/sugar-toolkit;a=blob;f=src/sugar/graphics/pulsingicon.py;h=db13556a1921105f9c51aae830b45e9e61202311;hb=c6e7336fea471272b3eb59824fc40eeceeabd41b

It's tough to tell the icon is pulsing in these screen shots, but these
are some examples of the icon on my XO:

http://dev.laptop.org/~mdengler/6995/6995_screenshot_10.png
http://dev.laptop.org/~mdengler/6995/6995_screenshot_13.png
http://dev.laptop.org/~mdengler/6995/6995_screenshot_14.png

Any concerns/comments?  I'd specifically be interested in:

1) whether anyone thinks this is too invasive to get in to Sucrose
   0.82 / OLPC 8.2.0; and

2) whether anyone thinks pulsingicon.PulsingIcon should just become
   icon.Icon; and

3) whether anyone has a strong feeling as to whether
   sugar/view/pulsingicon.py should "import * from
   sugar.graphics.pulsingicon" or just be removed and all associated
   imports changed; and

4) not only do 2) *but also* icon.Icon.props.base-color and others
   should become icon.Icon.pulser.props.base-color (would require
   changing all the sugar code that uses PulsingIcon); and

Thanks any time you can give to this proposal.

Martin

PS. You can see a mixin (multiple/diamond inheritance) approach (which
works) in the commit right before the one above, but I'm even less
excited about that one because of the gobject.GObject gotchas evident
in even the composition-based approach above.

1. diff --git a/src/sugar/graphics/tray.py b/src/sugar/graphics/tray.py
index 8296a53..70c3414 100644
--- a/src/sugar/graphics/tray.py
+++ b/src/sugar/graphics/tray.py
@@ -22,6 +22,7 @@ from sugar.graphics import style
 from sugar.graphics.palette import ToolInvoker
 from sugar.graphics.toolbutton import ToolButton
 from sugar.graphics.icon import Icon
+from sugar.graphics.pulsingicon import PulsingIcon
 
 _PREVIOUS_PAGE = 0
 _NEXT_PAGE = 1
@@ -328,8 +329,8 @@ class _IconWidget(gtk.EventBox):
 
         self.set_app_paintable(True)
 
-        self._icon = Icon(icon_name=icon_name, xo_color=xo_color,
-                          icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
+        self._icon = PulsingIcon(icon_name=icon_name,
-                          xo_color=xo_color,
+
-                          icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
         self.add(self._icon)
         self._icon.show()



PPS: If you've read this far, you deserve some ASCII art -- this is
the current hierarchy:

...
 |
 |- gtk.Icon
    |
    |- sugar.graphics.Icon              (sugar-toolkit/graphics/icon.py)
       |
       |- sugar.graphics.PulsingIcon    (sugar-toolkit/graphics/pulsingicon.py)

...
 |
 |- hippo.CanvasBox          hippo.CanvasIcon
  \                       /
   -|---------------------
    |
    |- sugar.graphics.CanvasIcon        (sugar-toolkit/graphics/icon.py)
     |
     |- sugar.shell.view.CanvasPulsingIcon   (sugar/view/pulsingicon.py)


...and I'm proposing either this:

...
 |
 |- gtk.Icon
    |
    |- sugar.graphics.Icon              (sugar-toolkit/graphics/icon.py)
       |
       |- sugar.graphics.PulsingIcon    (sugar-toolkit/graphics/pulsingicon.py)
            \--- uses by composition:
             - sugar.graphics.Pulser    (sugar-toolkit/graphics/pulsingicon.py)


...
 |
 |- hippo.CanvasBox          hippo.CanvasIcon
  \                       /
   -|---------------------
    |
    |- sugar.graphics.CanvasIcon        (sugar-toolkit/graphics/icon.py)
     |
     |- sugar.graphics.CanvasPulsingIcon(sugar-toolkit/graphics/pulsingicon.py)
        \--- uses by composition:
         - sugar.graphics.Pulser        (sugar-toolkit/graphics/pulsingicon.py)


...or, more radically, just

...
 |
 |- gtk.Icon
    |
    |- sugar.graphics.Icon              (sugar-toolkit/graphics/icon.py)
          \--- uses by composition:
           - sugar.graphics.Pulser      (sugar-toolkit/graphics/pulsingicon.py)


...
 |
 |- hippo.CanvasBox          hippo.CanvasIcon
   \                       /
    -|---------------------
     |
     |- sugar.graphics.CanvasIcon              (sugar-toolkit/graphics/icon.py)
          \--- uses by composition:
           - sugar.graphics.Pulser      (sugar-toolkit/graphics/pulsingicon.py)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.laptop.org/pipermail/sugar/attachments/20080720/ca0ab557/attachment.pgp 


More information about the Sugar mailing list