Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2011-10-30 22:06:13 (GMT)
committer Sascha Silbe <silbe@activitycentral.com>2011-11-22 12:28:57 (GMT)
commit20017cc4e65a3e23943a3a605b3b4f5427d5729d (patch)
treeb403c05fb3012bb6933d7ec9e05d079cfb9d64c7
parent1ba539b025ed3af5498966ea1c14e2431481ac99 (diff)
Replace "expose-event" signal by a new "draw" signal
GtkWidget "expose-event" signal has been replaced by a new "draw" signal [1]. The context is already clipped [2], so do not base it on the values returned by get_allocation like before. [1] http://developer.gnome.org/gtk3/3.0/ch25s02.html#id1467092 [2] http://developer.gnome.org/gtk3/3.0/GtkWidget.html#GtkWidget-draw [squashed with a patch by Benjamin Berg <benjamin@sipsolutions.net>] Signed-off-by: Sascha Silbe <silbe@activitycentral.com>
-rw-r--r--src/sugar3/graphics/alert.py17
-rw-r--r--src/sugar3/graphics/icon.py4
2 files changed, 10 insertions, 11 deletions
diff --git a/src/sugar3/graphics/alert.py b/src/sugar3/graphics/alert.py
index 239afc2..fb4ca38 100644
--- a/src/sugar3/graphics/alert.py
+++ b/src/sugar3/graphics/alert.py
@@ -351,10 +351,9 @@ class _TimeoutIcon(Gtk.Alignment):
self._text.set_attributes(attrlist)
self.add(self._text)
self._text.show()
- self.connect("expose_event", self.__expose_cb)
+ self.connect('draw', self.__draw_cb)
- def __expose_cb(self, widget, event):
- context = widget.get_window().cairo_create()
+ def __draw_cb(self, widget, context):
self._draw(context)
return False
@@ -364,13 +363,15 @@ class _TimeoutIcon(Gtk.Alignment):
self._text.size_request()
def _draw(self, context):
- rect = self.get_allocation()
- x = rect.x + rect.width * 0.5
- y = rect.y + rect.height * 0.5
- radius = rect.width / 2
+ w = self.get_allocated_width()
+ h = self.get_allocated_height()
+ x = 0 + w * 0.5
+ y = 0 + h * 0.5
+ radius = w / 2
context.arc(x, y, radius, 0, 2 * math.pi)
widget_style = self.get_style()
- context.set_source_color(widget_style.bg[self.get_state()])
+ color = widget_style.bg[self.get_state()]
+ context.set_source_rgb(color.red, color.green, color.blue)
context.fill_preserve()
def set_text(self, text):
diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py
index 8faa1c0..7ecf88e 100644
--- a/src/sugar3/graphics/icon.py
+++ b/src/sugar3/graphics/icon.py
@@ -385,7 +385,7 @@ class Icon(Gtk.Image):
width = 0
return (width, width)
- def do_expose_event(self, event):
+ def do_draw(self, cr):
"""
Parameters
----------
@@ -414,8 +414,6 @@ class Icon(Gtk.Image):
y = math.floor(ypad +
(allocation.height - requisition.height) * yalign)
- cr = self.get_window().cairo_create()
-
if self._scale != 1.0:
cr.scale(self._scale, self._scale)