Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/graphics/iconcolor.py
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-10-03 22:55:20 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-10-03 22:55:20 (GMT)
commit1f8ff1db1fddbf60fc776c484b980d8926c44538 (patch)
treef44ca2aa4df4c905d4861688f622b07fd8fd3299 /sugar/graphics/iconcolor.py
parent717bdd66f45e31074952bbf49c78e14153f92c57 (diff)
Move all the canvas code that doesn't depend on goocanvas anymore in graphics.
Diffstat (limited to 'sugar/graphics/iconcolor.py')
-rw-r--r--sugar/graphics/iconcolor.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/sugar/graphics/iconcolor.py b/sugar/graphics/iconcolor.py
new file mode 100644
index 0000000..97c13c8
--- /dev/null
+++ b/sugar/graphics/iconcolor.py
@@ -0,0 +1,34 @@
+import random
+
+from sugar.graphics.colors import colors
+
+def _parse_string(color_string):
+ if color_string == 'white':
+ return ['#ffffff', '#4f4f4f']
+
+ splitted = color_string.split(',')
+ if len(splitted) == 2:
+ return [splitted[0], splitted[1]]
+ else:
+ return None
+
+def is_valid(color_string):
+ return (_parse_string(color_string) != None)
+
+class IconColor:
+ def __init__(self, color_string=None):
+ if color_string == None or not is_valid(color_string):
+ n = int(random.random() * (len(colors) - 1))
+ [self._stroke, self._fill] = colors[n]
+ else:
+ [self._stroke, self._fill] = _parse_string(color_string)
+
+ def get_stroke_color(self):
+ return self._stroke
+
+ def get_fill_color(self):
+ return self._fill
+
+ def to_string(self):
+ return '%s,%s' % (self._stroke, self._fill)
+