Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-03 Thread Sascha Silbe

On Sat, May 02, 2009 at 05:39:21PM +0100, Martin Dengler wrote:

[Clock behaviour in suspend]

But I take your point...the answer is: no, it's not easy (with my
simple patch).  I'm not sure what the behavior should be (hide on
idle?!, come out of suspend once a minute?!), really.
With the XO going into suspend automatically, it should at least 
indicate that the clock has stopped as well (and no, the pulsing power 
LED is not enough). Showing an old time is _much_ worse than not showing 
it at all.


CU Sascha

--
http://sascha.silbe.org/
http://www.infra-silbe.de/

signature.asc
Description: Digital signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-03 Thread pgf
sascha wrote:
  On Sat, May 02, 2009 at 05:39:21PM +0100, Martin Dengler wrote:
  
  [Clock behaviour in suspend]
   But I take your point...the answer is: no, it's not easy (with my
   simple patch).  I'm not sure what the behavior should be (hide on
   idle?!, come out of suspend once a minute?!), really.
  With the XO going into suspend automatically, it should at least 
  indicate that the clock has stopped as well (and no, the pulsing power 
  LED is not enough). Showing an old time is _much_ worse than not showing 
  it at all.

given martin's point about the battery level, wireless strength,
etc, all becoming stale as well, perhaps the best fix would be to
always hide the frame during idle suspend.  as far as i know,
however, there's currently no mechanism for apps to learn that
idle suspend is imminent.

paul
=-
 paul fox, p...@laptop.org
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-03 Thread Jameson Quinn
Well, if the frame always auto-hid after 10 seconds, and the delay for
idle-suspend was 15 seconds, then it would work. I personally believe that
the frame should be hidden more agressively - whenever there's a user action
that doesn't address it, and after a longish timeout around 10 seconds. In
my experience with kids, hitting the frame key and then trying to interact
with the activity and being unable to is one of the more common hangups.

(I'm afraid I don't understand the latest on suspend, but it's my
understanding that there are some kind of micro-suspend periods which are
separate from longer-term idle suspend.)

Jameson

2009/5/3 p...@laptop.org

 sascha wrote:
   On Sat, May 02, 2009 at 05:39:21PM +0100, Martin Dengler wrote:
  
   [Clock behaviour in suspend]
But I take your point...the answer is: no, it's not easy (with my
simple patch).  I'm not sure what the behavior should be (hide on
idle?!, come out of suspend once a minute?!), really.
   With the XO going into suspend automatically, it should at least
   indicate that the clock has stopped as well (and no, the pulsing power
   LED is not enough). Showing an old time is _much_ worse than not showing
   it at all.

 given martin's point about the battery level, wireless strength,
 etc, all becoming stale as well, perhaps the best fix would be to
 always hide the frame during idle suspend.  as far as i know,
 however, there's currently no mechanism for apps to learn that
 idle suspend is imminent.

 paul
 =-
  paul fox, p...@laptop.org
 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-03 Thread pgf
jameson wrote:
  Well, if the frame always auto-hid after 10 seconds, and the delay for
  idle-suspend was 15 seconds, then it would work. I personally believe that
  the frame should be hidden more agressively - whenever there's a user action
  that doesn't address it, and after a longish timeout around 10 seconds. In
  my experience with kids, hitting the frame key and then trying to interact
  with the activity and being unable to is one of the more common hangups.
  
  (I'm afraid I don't understand the latest on suspend, but it's my
  understanding that there are some kind of micro-suspend periods which are
  separate from longer-term idle suspend.)

that's the plan of record, but there's no current implementation.

(and currently the idle suspend timeout is much longer than 15 seconds --
more like 1 or 2 minutes.)

paul

  
  Jameson
  
  2009/5/3 p...@laptop.org
  
   sascha wrote:
 On Sat, May 02, 2009 at 05:39:21PM +0100, Martin Dengler wrote:

 [Clock behaviour in suspend]
  But I take your point...the answer is: no, it's not easy (with my
  simple patch).  I'm not sure what the behavior should be (hide on
  idle?!, come out of suspend once a minute?!), really.
 With the XO going into suspend automatically, it should at least
 indicate that the clock has stopped as well (and no, the pulsing power
 LED is not enough). Showing an old time is _much_ worse than not showing
 it at all.
  
   given martin's point about the battery level, wireless strength,
   etc, all becoming stale as well, perhaps the best fix would be to
   always hide the frame during idle suspend.  as far as i know,
   however, there's currently no mechanism for apps to learn that
   idle suspend is imminent.
  
   paul
   =-
paul fox, p...@laptop.org
   ___
   Sugar-devel mailing list
   Sugar-devel@lists.sugarlabs.org
   http://lists.sugarlabs.org/listinfo/sugar-devel
  

=-
 paul fox, p...@laptop.org
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-03 Thread Martin Dengler
On Sun, May 03, 2009 at 09:01:14AM -0400, p...@laptop.org wrote:
 sascha wrote:
   On Sat, May 02, 2009 at 05:39:21PM +0100, Martin Dengler wrote:
   
   [Clock behaviour in suspend]
But I take your point...the answer is: no, it's not easy (with my
simple patch).  I'm not sure what the behavior should be (hide on
idle?!, come out of suspend once a minute?!), really.
   With the XO going into suspend automatically, it should at least 
   indicate that the clock has stopped as well (and no, the pulsing power 
   LED is not enough). Showing an old time is _much_ worse than not showing 
   it at all.
 
 given martin's point about the battery level, wireless strength,
 etc, all becoming stale as well, perhaps the best fix would be to
 always hide the frame during idle suspend.  as far as i know,
 however, there's currently no mechanism for apps to learn that
 idle suspend is imminent.

Given this, and the fact that frame icons don't get any useful
gtk.gdk.{VISIBILITY,EXPOSE} events more than once per Sugar session
(unless one changes VTs away and then back), don't expect an
acceptable clock (redraws when the frame is exposed and only then,
hides before power blanking) anytime soon.

If we want a clock before then, we're going to have to accept
something less than perfect.

 paul

Martin


pgpQ9zuJCu0ld.pgp
Description: PGP signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-03 Thread Martin Dengler
On Mon, May 04, 2009 at 12:17:05AM +0100, Martin Dengler wrote:
 On Sun, May 03, 2009 at 09:01:14AM -0400, p...@laptop.org wrote:
  given martin's point about the battery level, wireless strength,
  etc, all becoming stale as well, perhaps the best fix would be to
  always hide the frame during idle suspend.  as far as i know,
  however, there's currently no mechanism for apps to learn that
  idle suspend is imminent.
 
 Given this, and the fact that frame icons don't get any useful
 gtk.gdk.{VISIBILITY,EXPOSE} events more than once per Sugar session
 (unless one changes VTs away and then back), don't expect an
 acceptable clock (redraws when the frame is exposed and only then,
 hides before power blanking) anytime soon.

Getting rid of the compositing manager that I forgot I was
running solves the expose event problem.

Anybody have any great ideas about how to solve the problem of what to
do just before power management dims/blanks the screen, and how we
would want to be notified of that?  I'm not so sure we want to hide
the frame (but if we do, great, no more issues for the clock :)).

  paul
 
 Martin

Martin


 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel



pgpJvPJBlelZi.pgp
Description: PGP signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-03 Thread Martin Dengler
On Sat, May 02, 2009 at 05:36:12PM +0100, Martin Dengler wrote:
 On Sat, May 02, 2009 at 10:49:05AM -0400, Eben Eliason wrote:
  I think Sugar should only officially support a clock in the devices
  tray.
 
 What FRAME_RELATIVE_POSITION would you like it in?

  [clock should be HH:MM with additional information in the palette]
 
 Sure
 
  I'd also recommend putting the text against a filled background
 
 Will do.

I took a stab at these. Here is a screenshot of the clock, and the
code:

http://www.martindengler.com/tmp/clock_screenshot_04.png
http://www.martindengler.com/tmp/clock.py

Martin


pgpMgxuE2oE57.pgp
Description: PGP signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-03 Thread Benjamin M. Schwartz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Martin Dengler wrote:
 Anybody have any great ideas about how to solve the problem of what to
 do just before power management dims/blanks the screen, and how we
 would want to be notified of that?

IMHO, effort is best spent moving the suspend support into the kernel
(cpuidle) where it belongs.  That way, if the clock is visible, the
machine will wake up once a minute to update it.

Anything else is just hacks on top of hacks.

- --Ben
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.11 (GNU/Linux)

iEYEARECAAYFAkn+Zr8ACgkQUJT6e6HFtqTLPgCeMXNehSJjLWUSb94Ns60austV
49kAn1UUx1cOtXsU2IkAL+9F/Lz1cpXU
=9la1
-END PGP SIGNATURE-
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-03 Thread Jameson Quinn

 Anything else is just hacks on top of hacks.


I disagree. Personally, I think auto-hiding the frame after a delay is a
clean solution that's desirable anyway. But I do agree that the decision of
whether to hide the frame or not should not be based on stopped clocks.

Jameson
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-02 Thread Tomeu Vizoso
Hi Martin,

I was hoping the frame clock could be implemented as a device icon
extension, so people could add it, remove it and customize it more
easily. Why is it inside the shell instead?

Btw, do you want me to ask in olpc-sur how people already using 8.2
would like the clock to look like?

Thanks,

Tomeu

On Wed, Apr 29, 2009 at 20:31, Martin Dengler mar...@martindengler.com wrote:
 ---
  src/jarabe/frame/clock.py |  108 
 +
  src/jarabe/frame/frame.py |    7 +++
  2 files changed, 115 insertions(+), 0 deletions(-)
  create mode 100644 src/jarabe/frame/clock.py

 diff --git a/src/jarabe/frame/clock.py b/src/jarabe/frame/clock.py
 new file mode 100644
 index 000..ea8dbb2
 --- /dev/null
 +++ b/src/jarabe/frame/clock.py
 @@ -0,0 +1,108 @@
 +# Copyright (C) 2008 Martin Dengler
 +#
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
 +# the Free Software Foundation; either version 2 of the License, or
 +# (at your option) any later version.
 +#
 +# This program is distributed in the hope that it will be useful,
 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +# GNU General Public License for more details.
 +#
 +# You should have received a copy of the GNU General Public License
 +# along with this program; if not, write to the Free Software
 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 +
 +from gettext import gettext as _
 +import gconf
 +
 +import gtk
 +import gtk.gdk
 +import pango
 +import pangocairo
 +import time
 +
 +from sugar.graphics import style
 +from sugar.graphics.toolbutton import ToolButton
 +from sugar.graphics.xocolor import XoColor
 +
 +
 +CLOCK_TEXT_FONT = Bitstream Vera Sans 36
 +
 +
 +class TextIcon(gtk.Image):
 +    def __init__(self, *args, **kwargs):
 +        gtk.Image.__init__(self, *args, **kwargs)
 +        client = gconf.client_get_default()
 +        mycolor = XoColor(client.get_string('/desktop/sugar/user/color'))
 +        self._fill_rgba = style.Color(mycolor.fill).get_rgba()
 +        self._stroke_rgba = style.Color(mycolor.stroke).get_rgba()
 +
 +    def my_expose_event(self, widget_, event):
 +        x, y, w, h = event.area
 +        cr = self.window.cairo_create()
 +        redraw_region = gtk.gdk.region_rectangle(self.allocation)
 +        exposed_region = gtk.gdk.region_rectangle(event.area)
 +        redraw_region.intersect(exposed_region)
 +        cr.region(redraw_region)
 +        cr.clip()
 +        x, y, w_, h_ = self.allocation
 +        cr.translate(x, y)
 +        self.texticon_draw(cr)
 +
 +    def write(self, cr, text, x=0, y=0, font=None):
 +        cr.save()
 +        pcr = pangocairo.CairoContext(cr)
 +        layout = pcr.create_layout()
 +        if font is None:
 +            font = CLOCK_TEXT_FONT
 +        layout.set_font_description(pango.FontDescription(font))
 +        layout.set_markup(text)
 +        if x != 0 or y != 0:
 +            cr.move_to(x, y)
 +        pcr.layout_path(layout)
 +        cr.set_source_rgba(*self._stroke_rgba)
 +        cr.set_line_width(0.5)
 +        cr.stroke_preserve()
 +        cr.set_source_rgba(*self._fill_rgba)
 +        cr.fill()
 +        cr.restore()
 +        self.set_size_request(*layout.get_pixel_size())
 +
 +    def texticon_draw(self, cr):
 +        
 +        draw the widget on the provided cairo surface
 +
 +        Should be overridden by subclasses; example:
 +
 +        def texticon_draw(self, cr):
 +            self.write(cr, time.strftime(_(%m/%d %H:%M), time.localtime()))
 +        
 +        raise Exception(TextIcon.texticon_draw(): subclasses must
 +                         override this method)
 +
 +
 +class DigitalClock(TextIcon):
 +    def texticon_draw(self, cr):
 +        self.write(cr, time.strftime(_(%m/%d %H:%M), time.localtime()))
 +
 +
 +class DigitalClockTrayItem(ToolButton):
 +
 +    FRAME_POSITION_RELATIVE = 50 # all the way on the right
 +
 +    def __init__(self):
 +        ToolButton.__init__(self)
 +        self._icon = DigitalClock()
 +        self.set_icon_widget(self._icon)
 +
 +        # TODO: consider what happens when composite manager is involved
 +        self.connect(expose-event, self._icon.my_expose_event)
 +
 +        self.props.sensitive = False
 +        self._icon.show()
 +
 +
 +def setup(tray):
 +    tray.add_device(DigitalClockTrayItem())
 diff --git a/src/jarabe/frame/frame.py b/src/jarabe/frame/frame.py
 index 0bb8d92..79b508b 100644
 --- a/src/jarabe/frame/frame.py
 +++ b/src/jarabe/frame/frame.py
 @@ -190,6 +190,13 @@ class Frame(object):
                 hippo.PACK_EXPAND)
         activities_tray.show()

 +        import sys; sys.path.insert(0, .)
 +        from clock import DigitalClockTrayItem as clock
 +        clockwidget = clock()
 +        panel.append(hippo.CanvasWidget(widget=clockwidget), 

Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-02 Thread Martin Dengler
On Sat, May 02, 2009 at 10:28:06AM +0200, Tomeu Vizoso wrote:
 Hi Martin,
 
 I was hoping the frame clock could be implemented as a device icon
 extension, so people could add it, remove it and customize it more
 easily. Why is it inside the shell instead?

The code (clock.py) is in fact a device icon, and if you drop it in
/usr/share/sugar/extensions/deviceicon it'll Just Work.

It's in the shell because it's in the upper-right corner of the frame,
where I found it looks a lot better:

http://www.xades.com/proj/clock_frame_767_screenshot.png

 Btw, do you want me to ask in olpc-sur how people already using 8.2
 would like the clock to look like?

Sure!

 Thanks,
 
 Tomeu

Martin


pgp9v9hGdO1wJ.pgp
Description: PGP signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-02 Thread pgf
martin wrote:
  On Sat, May 02, 2009 at 10:28:06AM +0200, Tomeu Vizoso wrote:
   Hi Martin,
   
   I was hoping the frame clock could be implemented as a device icon
   extension, so people could add it, remove it and customize it more
   easily. Why is it inside the shell instead?
  
  The code (clock.py) is in fact a device icon, and if you drop it in
  /usr/share/sugar/extensions/deviceicon it'll Just Work.
  
  It's in the shell because it's in the upper-right corner of the frame,
  where I found it looks a lot better:
  
  http://www.xades.com/proj/clock_frame_767_screenshot.png

sounds like there is, but to be sure:  it's easy for people to
remove or disable if they don't like having a stopped clock on
their screen during idle suspend on an XO?

paul
=-
 paul fox, p...@laptop.org
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-02 Thread Eben Eliason
On Sat, May 2, 2009 at 7:04 AM, Martin Dengler mar...@martindengler.com wrote:
 On Sat, May 02, 2009 at 10:28:06AM +0200, Tomeu Vizoso wrote:
 Hi Martin,

 I was hoping the frame clock could be implemented as a device icon
 extension, so people could add it, remove it and customize it more
 easily. Why is it inside the shell instead?

 The code (clock.py) is in fact a device icon, and if you drop it in
 /usr/share/sugar/extensions/deviceicon it'll Just Work.

 It's in the shell because it's in the upper-right corner of the frame,
 where I found it looks a lot better:

Hmmm, but this breaks the paradigm of the frame; I think Sugar should
only officially support a clock in the devices tray. Simple hacks, of
course, could allow people to change it to other corners, but I don't
think it should even be an option, officially.

 http://www.xades.com/proj/clock_frame_767_screenshot.png

Also, the clock takes up a significant amount of space. Can we use the
normal paradigm for device icons instead? If the clock simply read
12:34 and then additional information, such as the day and date,
appeared within the palette, along with options for, perhaps, 12 or 24
hour time, etc. I think it would be a lot cleaner. I'd also recommend
putting the text against a filled background, instead of the frame
itself, to give it presence as a device object, and not just some text
floating in the Frame.

That said, great work on adding a clock! If I get a chance I could try
mocking up some visual treatments.

Eben


 Btw, do you want me to ask in olpc-sur how people already using 8.2
 would like the clock to look like?

 Sure!

 Thanks,

 Tomeu

 Martin

 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel


___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-02 Thread Martin Dengler
On Sat, May 02, 2009 at 10:49:05AM -0400, Eben Eliason wrote:
 On Sat, May 2, 2009 at 7:04 AM, Martin Dengler mar...@martindengler.com 
 wrote:
  On Sat, May 02, 2009 at 10:28:06AM +0200, Tomeu Vizoso wrote:
  Hi Martin,
 
  I was hoping the frame clock could be implemented as a device icon
  extension, so people could add it, remove it and customize it more
  easily. Why is it inside the shell instead?
 
  The code (clock.py) is in fact a device icon, and if you drop it in
  /usr/share/sugar/extensions/deviceicon it'll Just Work.
 
  It's in the shell because it's in the upper-right corner of the frame,
  where I found it looks a lot better:
 
 Hmmm, but this breaks the paradigm of the frame

Well, I agree it breaks the paradigm, but it's a shame to let all that
nice space on the top right go spare.  I'm happy to have it hacked
there on my build, of course.

 I think Sugar should only officially support a clock in the devices
 tray.

What FRAME_RELATIVE_POSITION would you like it in?

 Also, the clock takes up a significant amount of space.

That's the advantage of putting it in the upper right where there's
lots of space :).  I like seeing the Month/Day, but of course that's
me.  I think the code is simple enough that that customisation can
just be hacked in (as other commenters have seemed satisfied with),
rather than spending time and effort designing and supporting some
sort of monster clock-configuration dbus-communicating control-panel.

 [clock should be HH:MM with additional information in the palette]

Sure

 I'd also recommend putting the text against a filled background

Will do.

 If I get a chance I could try mocking up some visual treatments.

Cool - anything you get a chance to put together would be nice.

 Eben

Martin



pgpAKOu8ZMWX9.pgp
Description: PGP signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-02 Thread Martin Dengler
On Sat, May 02, 2009 at 08:08:29AM -0400, p...@laptop.org wrote:
 sounds like there is, but to be sure:  it's easy for people to
 remove or disable if they don't like having a stopped clock on
 their screen during idle suspend on an XO?

The clock refreshes itself when the Frame is shown, so it's no worse
than the wireless, wired, speaker, battery, clipboard, friends list,
etc. icons stopping when idle suspend happens :).

But I take your point...the answer is: no, it's not easy (with my
simple patch).  I'm not sure what the behavior should be (hide on
idle?!, come out of suspend once a minute?!), really.  I'm quite
tempted to say: it's just as fine as the battery icon not updating
during idle suspend.

When we come *out* of idle suspend the clock should update, and I bet
it currently does not.  That seems like a more serious problem with my
patch.

 paul

Martin


pgpFVdqfrINhk.pgp
Description: PGP signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] add clock to frame

2009-05-02 Thread Martin Dengler
On Sat, May 02, 2009 at 07:43:36AM -0500, Jameson Quinn wrote:
 In other words, IMO this should be two patches: a clock device icon; and the
 ability to put device icons in lower left, lower right, or upper
 right.

Fair enough.

 now-I-can-go-back-to-building-my-own-bikeshed-ly y'rs,

;)

 Jameson

Martin


pgpMetFaHxrNL.pgp
Description: PGP signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH] add clock to frame

2009-04-29 Thread Martin Dengler
---
 src/jarabe/frame/clock.py |  108 +
 src/jarabe/frame/frame.py |7 +++
 2 files changed, 115 insertions(+), 0 deletions(-)
 create mode 100644 src/jarabe/frame/clock.py

diff --git a/src/jarabe/frame/clock.py b/src/jarabe/frame/clock.py
new file mode 100644
index 000..ea8dbb2
--- /dev/null
+++ b/src/jarabe/frame/clock.py
@@ -0,0 +1,108 @@
+# Copyright (C) 2008 Martin Dengler
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+from gettext import gettext as _
+import gconf
+
+import gtk
+import gtk.gdk
+import pango
+import pangocairo
+import time
+
+from sugar.graphics import style
+from sugar.graphics.toolbutton import ToolButton
+from sugar.graphics.xocolor import XoColor
+
+
+CLOCK_TEXT_FONT = Bitstream Vera Sans 36
+
+
+class TextIcon(gtk.Image):
+def __init__(self, *args, **kwargs):
+gtk.Image.__init__(self, *args, **kwargs)
+client = gconf.client_get_default()
+mycolor = XoColor(client.get_string('/desktop/sugar/user/color'))
+self._fill_rgba = style.Color(mycolor.fill).get_rgba()
+self._stroke_rgba = style.Color(mycolor.stroke).get_rgba()
+
+def my_expose_event(self, widget_, event):
+x, y, w, h = event.area
+cr = self.window.cairo_create()
+redraw_region = gtk.gdk.region_rectangle(self.allocation)
+exposed_region = gtk.gdk.region_rectangle(event.area)
+redraw_region.intersect(exposed_region)
+cr.region(redraw_region)
+cr.clip()
+x, y, w_, h_ = self.allocation
+cr.translate(x, y)
+self.texticon_draw(cr)
+
+def write(self, cr, text, x=0, y=0, font=None):
+cr.save()
+pcr = pangocairo.CairoContext(cr)
+layout = pcr.create_layout()
+if font is None:
+font = CLOCK_TEXT_FONT
+layout.set_font_description(pango.FontDescription(font))
+layout.set_markup(text)
+if x != 0 or y != 0:
+cr.move_to(x, y)
+pcr.layout_path(layout)
+cr.set_source_rgba(*self._stroke_rgba)
+cr.set_line_width(0.5)
+cr.stroke_preserve()
+cr.set_source_rgba(*self._fill_rgba)
+cr.fill()
+cr.restore()
+self.set_size_request(*layout.get_pixel_size())
+
+def texticon_draw(self, cr):
+
+draw the widget on the provided cairo surface
+
+Should be overridden by subclasses; example:
+
+def texticon_draw(self, cr):
+self.write(cr, time.strftime(_(%m/%d %H:%M), time.localtime()))
+
+raise Exception(TextIcon.texticon_draw(): subclasses must
+ override this method)
+
+
+class DigitalClock(TextIcon):
+def texticon_draw(self, cr):
+self.write(cr, time.strftime(_(%m/%d %H:%M), time.localtime()))
+
+
+class DigitalClockTrayItem(ToolButton):
+
+FRAME_POSITION_RELATIVE = 50 # all the way on the right
+
+def __init__(self):
+ToolButton.__init__(self)
+self._icon = DigitalClock()
+self.set_icon_widget(self._icon)
+
+# TODO: consider what happens when composite manager is involved
+self.connect(expose-event, self._icon.my_expose_event)
+
+self.props.sensitive = False
+self._icon.show()
+
+
+def setup(tray):
+tray.add_device(DigitalClockTrayItem())
diff --git a/src/jarabe/frame/frame.py b/src/jarabe/frame/frame.py
index 0bb8d92..79b508b 100644
--- a/src/jarabe/frame/frame.py
+++ b/src/jarabe/frame/frame.py
@@ -190,6 +190,13 @@ class Frame(object):
 hippo.PACK_EXPAND)
 activities_tray.show()
 
+import sys; sys.path.insert(0, .)
+from clock import DigitalClockTrayItem as clock
+clockwidget = clock()
+panel.append(hippo.CanvasWidget(widget=clockwidget), hippo.PACK_END)
+clockwidget.show()
+del sys.path[0]
+
 return panel
 
 def _create_bottom_panel(self):
-- 
1.6.0.6

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel