[hamster-applet] label quirks



commit f5589a6c25583091dd2e4f25e4fcd13e80bd8af6
Author: Toms Bauģis <toms baugis gmail com>
Date:   Thu Apr 8 13:48:28 2010 +0100

    label quirks

 src/hamster/graphics.py |   19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/src/hamster/graphics.py b/src/hamster/graphics.py
index 37d4ae6..4c755f5 100644
--- a/src/hamster/graphics.py
+++ b/src/hamster/graphics.py
@@ -483,37 +483,32 @@ class Label(Shape):
 
 
     def __setattr__(self, name, val):
-        self.__dict__[name] = val
-
+        Shape.__setattr__(self, name, val)
         if name == "width":
             # setting width means consumer wants to contrain the label
             if val is None or val == -1:
                 self.__dict__['_bounds_width'] = -1
             else:
                 self.__dict__['_bounds_width'] = val * pango.SCALE
-
-        if name in ("text", "size"):
+        elif name in ("text", "size", "width"):
             self._set_dimensions()
 
 
     def draw_shape(self):
-        self._set_dimensions()
         self.graphics.move_to(0, 0) #make sure we don't wander off somewhere nowhere
 
-        if self.color:
-            self.graphics.set_color(self.color)
+        if self.interactive: #if label is interactive, draw invisible bounding box for simple hit calculations
+            self.graphics.set_color("#000", 0)
+            self.graphics.rectangle(0,0, self.width, self.height)
+            self.graphics.stroke()
 
+        self.graphics.set_color(self.color)
         self.graphics.show_layout(self.text, self.font_desc,
                                   self.alignment,
                                   self._bounds_width,
                                   self.wrap,
                                   self.ellipsize)
 
-        if self.interactive: #if label is interactive, draw invisible bounding box for simple hit calculations
-            self.graphics.set_color("#000", 0)
-            self.graphics.rectangle(0,0, self.width, self.height)
-            self.graphics.stroke()
-
 
     def _set_dimensions(self):
         context = gtk.gdk.CairoContext(cairo.Context(cairo.ImageSurface(cairo.FORMAT_A1, 0,0)))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]