Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/graphics
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-10-13 13:46:11 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-10-13 13:46:11 (GMT)
commit75b158c3d76eca9b13c4c1cced7a4cfd009927e9 (patch)
treec42f97ce189b0b0754006999971b988de97353c9 /sugar/graphics
parent4ac331200d3a40853ea483fe9840c430d7db35ba (diff)
First go at shared links (not functional)
Diffstat (limited to 'sugar/graphics')
-rw-r--r--sugar/graphics/bubble.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/sugar/graphics/bubble.py b/sugar/graphics/bubble.py
new file mode 100644
index 0000000..dc7c635
--- /dev/null
+++ b/sugar/graphics/bubble.py
@@ -0,0 +1,48 @@
+import gobject
+import hippo
+
+class Bubble(hippo.CanvasBox, hippo.CanvasItem):
+ __gtype_name__ = 'SugarBubble'
+
+ __gproperties__ = {
+ 'color' : (object, None, None,
+ gobject.PARAM_READWRITE),
+ }
+
+ def __init__(self, **kwargs):
+ self._color = None
+ self._radius = 12
+
+ hippo.CanvasBox.__init__(self, **kwargs)
+
+ def do_set_property(self, pspec, value):
+ if pspec.name == 'color':
+ self._color = value
+ self.emit_paint_needed(0, 0, -1, -1)
+
+ def do_get_property(self, pspec):
+ if pspec.name == 'color':
+ return self._color
+
+ def _color_string_to_rgb(self, color_string):
+ col = gtk.gdk.color_parse(color_string)
+ return (col.red / 65535, col.green / 65535, col.blue / 65535)
+
+ def do_paint_below_children(self, cr, damaged_box):
+ cairo_move_to(self._radius, 0);
+ cr.arc(width - self._radius, self._radius,
+ self._radius, math.pi * 1.5, math.pi * 2);
+ cr.arc(width - self._radius, height - self._radius,
+ self._radius, 0, math.pi * 0.5);
+ cr.arc(self._radius, height - self._radius,
+ self._radius, math.pi * 0.5, math.pi);
+ cr.arc(cr, self._radius, self._radius, self._radius,
+ math.pi, math.pi * 1.5);
+
+ color = self._color.get_fill_color()
+ cr.set_source_rgb(cr, self._color_string_to_rgb(color));
+ cairo_fill_preserve(cr);
+
+ color = self._color.get_stroke_color()
+ cr.set_source_rgb(cr, self._color_string_to_rgb(color));
+ cairo_stroke(cr);