<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
<br>
On 19/12/09 20:41, Brent Chiodo wrote:
<blockquote
 cite="mid:f61f40e90912191141o5951d01bxaf063a55697df841@mail.gmail.com"
 type="cite">Hi,<br>
  <br>
I'm trying to make the background of a Desktop Widget semi-transparent
using the cairo graphics library. The widget is written in Python and
the only examples of this I've found are using C (I don't know much C
-- I wasn't even able to apply the examples to Python).<br>
  <br>
</blockquote>
<br>
I haven't tried in Python, but there's this blog entry by Zaheer Abbas
Merali which explains how to do it:<br>
<a class="moz-txt-link-freetext" href="http://zaheer.merali.org/articles/2009/10/12/maemo-widget-experience-circular-clock-with-transparent-background/">http://zaheer.merali.org/articles/2009/10/12/maemo-widget-experience-circular-clock-with-transparent-background/</a><br>
<br>
Hope that helps,<br>
marcoil<br>
<br>
<blockquote
 cite="mid:f61f40e90912191141o5951d01bxaf063a55697df841@mail.gmail.com"
 type="cite">This is the current code (that doesn't work -- the
background appears as a black box)<br>
  <br>
  <br>
   def __init__(self):<br>
      hildondesktop.HomePluginItem.__init__(self)<br>
...<br>
      self..connect("screen-changed", self.screen_changed)<br>
      self.connect("expose-event", self.expose)<br clear="all">
  <br>
  <br>
   def expose(self, widget, event):<br>
      cr = self.window.cairo_create()<br>
      cr.set_source_rgba(1.0, 1.0, 1.0, 0.0) # Transparent<br>
  <br>
      # Draw the background<br>
      cr.set_operator(cairo.OPERATOR_SOURCE)<br>
      cr.paint()<br>
  <br>
      # draw rounded rect<br>
      width, height = self.allocation[2], self.allocation[3]<br>
  <br>
      #/* a custom shape, that could be wrapped in a function */<br>
      x0 = 0   #/*&lt; parameters like cairo_rectangle */<br>
      y0 = 0<br>
  <br>
      radius = min(15, width/2, height/2)  #/*&lt; and an approximate
curvature radius */<br>
  <br>
      x1 = x0 + width<br>
      y1 = y0 + height<br>
  <br>
      cr.move_to  (x0, y0 + radius)<br>
      cr.arc (x0 + radius, y0 + radius, radius, 3.14, 1.5 * 3.14)<br>
      cr.line_to (x1 - radius, y0)<br>
      cr.arc (x1 - radius, y0 + radius, radius, 1.5 * 3.14, 0.0)<br>
      cr.line_to (x1 , y1 - radius)<br>
      cr.arc (x1 - radius, y1 - radius, radius, 0.0, 0.5 * 3.14)<br>
      cr.line_to (x0 + radius, y1)<br>
      cr.arc (x0 + radius, y1 - radius, radius, 0.5 * 3.14, 3.14)<br>
  <br>
      cr.close_path ()<br>
  <br>
      bg_color=gtk.gdk.color_parse("#000000")<br>
  <br>
      cr.set_source_rgba (bg_color.red / 65535.0,
bg_color.green/65535.0, bg_color.blue/65535.0, float(32767/65535.0))<br>
      cr.fill_preserve ()<br>
      # cr.set_source_rgba (0.5, 0.5, 1.0, 0.8)<br>
      # cr.stroke ()<br>
  <br>
   def screen_changed(self, widget):<br>
      screen = self.get_screen()<br>
      colormap = screen.get_rgba_colormap()<br>
      self.set_colormap(colormap)<br>
  <br>
      return False<br>
  <br>
  <br>
What I'm trying to do is have the widget appear semi-transparent with
rounded corners (like most widgets look) but the above code does not
work at all. I do not know much about cairo and got most of that code
from Khertan's HomeIP widget for Diablo/Chinook and only modified it a
little to work with Maemo 5.<br>
  <br>
Any help would be greatly appreciated. I've been "banging my head
against a wall" for a while with this one.<br>
  <br>
-- <br>
Best Regards,<br>
  <br>
Brent Chiodo<br>
  <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
maemo-developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:maemo-developers@maemo.org">maemo-developers@maemo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.maemo.org/mailman/listinfo/maemo-developers">https://lists.maemo.org/mailman/listinfo/maemo-developers</a>
  </pre>
</blockquote>
<br>
</body>
</html>