[shpy-commit] r2881 - shpy/trunk/dist/shpy/ui_pygame

mwh@codespeak.net mwh@codespeak.net
Fri, 23 Jan 2004 14:59:25 +0100 (MET)


Author: mwh
Date: Fri Jan 23 14:59:24 2004
New Revision: 2881

Modified:
   shpy/trunk/dist/shpy/ui_pygame/ui_pygame.py
Log:
Replace various hacks with old-style classes with ever-so-slightly
cleaner hacks with new-style classes.


Modified: shpy/trunk/dist/shpy/ui_pygame/ui_pygame.py
==============================================================================
--- shpy/trunk/dist/shpy/ui_pygame/ui_pygame.py	(original)
+++ shpy/trunk/dist/shpy/ui_pygame/ui_pygame.py	Fri Jan 23 14:59:24 2004
@@ -34,7 +34,11 @@
 
 class Cursor(decorate.Decorator):
     typeid = 'cursor:0'
-    slots = 'x','line','cell','color','name',
+    x = decorate.structureproperty('x')
+    line = decorate.structureproperty('line')
+    cell = decorate.structureproperty('cell')
+    color = decorate.structureproperty('color')
+    name = decorate.structureproperty('name')
 
     def init_more(self):
         self.fixme()
@@ -93,24 +97,27 @@
 
 class Root(decorate.Decorator):
     typeid = 'root:0'
-    slots = 'cells', 'users',
+    cells = decorate.structureproperty('cells')
+    users = decorate.structureproperty('users')
 
 class Cell(decorate.Decorator):
     typeid = 'cell:0'
-    slots = 'lines',
+    lines = decorate.structureproperty('lines')
+
+class contentproperty(decorate.structureproperty):
+    def __set__(self, ob, value):
+        ob.color = ob.terminal.cursor.color
+        super(contentproperty, self).__set__(ob, value)
 
 class Line(decorate.Decorator):
     typeid = 'line:0'
-    slots = 'content', 'color',
+
+    content = contentproperty('content')
+    color = decorate.structureproperty('color')
 
     def getcolor(self):
         return getattr(self, 'color', (0, 0, 0))
 
-    def __setattr__(self, attr, value):
-        if attr == 'content':
-            self.color = self.terminal.cursor.color
-        decorate.Decorator.__setattr__(self, attr, value)
-
 
 class Terminal: