Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shell/home/FriendsView.py3
-rw-r--r--shell/home/HomeView.py8
-rw-r--r--shell/home/MeshView.py3
-rw-r--r--sugar/canvas/IconItem.py128
-rwxr-xr-xtools/hex-colors-to-dict19
5 files changed, 153 insertions, 8 deletions
diff --git a/shell/home/FriendsView.py b/shell/home/FriendsView.py
index b12616a..820b555 100644
--- a/shell/home/FriendsView.py
+++ b/shell/home/FriendsView.py
@@ -3,6 +3,7 @@ import random
import goocanvas
from sugar.canvas.IconItem import IconItem
+from sugar.canvas.IconItem import IconColor
class Model(goocanvas.CanvasModelSimple):
def __init__(self, data_model):
@@ -22,7 +23,7 @@ class Model(goocanvas.CanvasModelSimple):
def add_friend(self, friend):
root = self.get_root_item()
- icon = IconItem('stock-buddy', 'green', 48)
+ icon = IconItem('stock-buddy', IconColor(), 48)
icon.set_property('x', random.random() * 1100)
icon.set_property('y', random.random() * 800)
diff --git a/shell/home/HomeView.py b/shell/home/HomeView.py
index 6424e6e..acc451c 100644
--- a/shell/home/HomeView.py
+++ b/shell/home/HomeView.py
@@ -3,6 +3,7 @@ import goocanvas
import wnck
from sugar.canvas.IconItem import IconItem
+from sugar.canvas.IconItem import IconColor
from sugar.canvas.DonutItem import DonutItem
from sugar.canvas.DonutItem import PieceItem
from sugar.canvas.DonutItem import PieceIcon
@@ -29,7 +30,7 @@ class TasksItem(DonutItem):
def _add(self, activity):
icon_name = activity.get_icon_name()
- item = self.add_piece(100 / 8, icon_name, 'blue')
+ item = self.add_piece(100 / 8, icon_name, IconColor())
# FIXME This really sucks. Fix goocanvas event handling.
item.set_data('activity', activity)
@@ -41,7 +42,8 @@ class ActivityItem(IconItem):
ICON_SIZE = 30
def __init__(self, activity):
- IconItem.__init__(self, activity.get_icon(), 'white',
+ IconItem.__init__(self, activity.get_icon(),
+ IconColor('white'),
ActivityItem.ICON_SIZE)
self._activity = activity
@@ -100,7 +102,7 @@ class Model(goocanvas.CanvasModelSimple):
tasks.translate(600, 450)
root.add_child(tasks)
- me = IconItem('stock-buddy', 'green', 150)
+ me = IconItem('stock-buddy', IconColor(), 150)
me.translate(600 - (me.get_property('width') / 2),
450 - (me.get_property('height') / 2))
root.add_child(me)
diff --git a/shell/home/MeshView.py b/shell/home/MeshView.py
index bd8f230..8bbea05 100644
--- a/shell/home/MeshView.py
+++ b/shell/home/MeshView.py
@@ -3,13 +3,14 @@ import random
import goocanvas
from sugar.canvas.IconItem import IconItem
+from sugar.canvas.IconItem import IconColor
class ActivityItem(IconItem):
def __init__(self, activity, registry):
info = registry.get_activity(activity.get_type())
icon_name = info.get_icon()
- IconItem.__init__(self, icon_name, 'green', 48)
+ IconItem.__init__(self, icon_name, IconColor(), 48)
self._activity = activity
diff --git a/sugar/canvas/IconItem.py b/sugar/canvas/IconItem.py
index b4ac205..9d47a79 100644
--- a/sugar/canvas/IconItem.py
+++ b/sugar/canvas/IconItem.py
@@ -1,3 +1,4 @@
+import random
import re
import gobject
@@ -6,6 +7,124 @@ import goocanvas
from sugar.util import GObjectSingletonMeta
+class IconColor:
+ __colors_dict = {
+ 'white' : 'black' , \
+ '#66A531' : '#3D6E1C', \
+ '#C96FF4' : '#3D6E1C', \
+ '#AD9329' : '#7A5E21', \
+ '#3698FD' : '#7A5E21', \
+ '#EC7414' : '#AD3E19', \
+ '#3DA0C6' : '#AD3E19', \
+ '#F96564' : '#C3191D', \
+ '#48A39B' : '#C3191D', \
+ '#F85DA3' : '#BA1876', \
+ '#26AA65' : '#BA1876', \
+ '#C96FF4' : '#A116C8', \
+ '#66A531' : '#A116C8', \
+ '#3698FD' : '#4B44FB', \
+ '#AD9329' : '#4B44FB', \
+ '#3DA0C6' : '#276986', \
+ '#EC7414' : '#276986', \
+ '#48A39B' : '#366B68', \
+ '#F96564' : '#366B68', \
+ '#26AA65' : '#236F52', \
+ '#F85DA3' : '#236F52', \
+ '#77C32B' : '#318D34', \
+ '#C39EFD' : '#318D34', \
+ '#C2B10D' : '#9A7617', \
+ '#7DB2FB' : '#9A7617', \
+ '#F19D24' : '#C45F18', \
+ '#0FBEF1' : '#C45F18', \
+ '#F89760' : '#F71717', \
+ '#36C2C0' : '#F71717', \
+ '#F393B5' : '#E42D8E', \
+ '#2DC78E' : '#E42D8E', \
+ '#C39EFD' : '#C820FB', \
+ '#77C32B' : '#C820FB', \
+ '#7DB2FB' : '#576EF8', \
+ '#C2B10D' : '#576EF8', \
+ '#0FBEF1' : '#1485AC', \
+ '#F19D24' : '#1485AC', \
+ '#36C2C0' : '#2F8882', \
+ '#F89760' : '#2F8882', \
+ '#2DC78E' : '#108C64', \
+ '#F393B5' : '#108C64', \
+ '#3AE93B' : '#66A531', \
+ '#DFBCFA' : '#66A531', \
+ '#D3CF34' : '#AD9329', \
+ '#AECCF7' : '#AD9329', \
+ '#F9C216' : '#EC7414', \
+ '#52DCEE' : '#EC7414', \
+ '#FDBB98' : '#F96564', \
+ '#18E3C4' : '#F96564', \
+ '#F8B9C6' : '#F85DA3', \
+ '#41E586' : '#F85DA3', \
+ '#DFBCFA' : '#C96FF4', \
+ '#3AE93B' : '#C96FF4', \
+ '#AECCF7' : '#3698FD', \
+ '#D3CF34' : '#3698FD', \
+ '#52DCEE' : '#3DA0C6', \
+ '#F9C216' : '#3DA0C6', \
+ '#18E3C4' : '#48A39B', \
+ '#FDBB98' : '#48A39B', \
+ '#41E586' : '#26AA65', \
+ '#F8B9C6' : '#26AA65', \
+ '#3AE93B' : '#3D6E1C', \
+ '#DFBCFA' : '#3D6E1C', \
+ '#D3CF34' : '#7A5E21', \
+ '#AECCF7' : '#7A5E21', \
+ '#F9C216' : '#AD3E19', \
+ '#52DCEE' : '#AD3E19', \
+ '#FDBB98' : '#C3191D', \
+ '#18E3C4' : '#C3191D', \
+ '#F8B9C6' : '#BA1876', \
+ '#41E586' : '#BA1876', \
+ '#DFBCFA' : '#A116C8', \
+ '#3AE93B' : '#A116C8', \
+ '#AECCF7' : '#4B44FB', \
+ '#D3CF34' : '#4B44FB', \
+ '#52DCEE' : '#276986', \
+ '#F9C216' : '#276986', \
+ '#18E3C4' : '#366B68', \
+ '#FDBB98' : '#366B68', \
+ '#41E586' : '#236F52', \
+ '#F8B9C6' : '#236F52', \
+ '#98FC88' : '#318D34', \
+ '#EDDFFD' : '#318D34', \
+ '#F0EB10' : '#9A7617', \
+ '#E2E4EF' : '#9A7617', \
+ '#F3E3C9' : '#C45F18', \
+ '#D5E8EF' : '#C45F18', \
+ '#F3E1DE' : '#F71717', \
+ '#63FCE9' : '#F71717', \
+ '#FEDBEB' : '#E42D8E', \
+ '#92FBB0' : '#E42D8E', \
+ '#EDDFFD' : '#C820FB', \
+ '#98FC88' : '#C820FB', \
+ '#E2E4EF' : '#576EF8', \
+ '#F0EB10' : '#576EF8', \
+ '#D5E8EF' : '#1485AC', \
+ '#F3E3C9' : '#1485AC', \
+ '#63FCE9' : '#2F8882', \
+ '#F3E1DE' : '#2F8882', \
+ '#92FBB0' : '#108C64', \
+ '#FEDBEB' : '#108C64', \
+ }
+
+ def __init__(self, fill_color=None):
+ if fill_color == None:
+ n = int(random.random() * (len(self.__colors_dict) - 1))
+ fill_color = self.__colors_dict.keys()[n]
+
+ self._fill_color = fill_color
+
+ def get_stroke_color(self):
+ return self.__colors_dict[self._fill_color]
+
+ def get_fill_color(self):
+ return self._fill_color
+
class IconCache(gobject.GObject):
__metaclass__ = GObjectSingletonMeta
@@ -21,13 +140,16 @@ class IconCache(gobject.GObject):
icon_file.close()
if color != None:
- style = '.fill {fill:%s;stroke:%s;}' % (color, color)
+ fill = color.get_fill_color()
+ stroke = color.get_stroke_color()
+
+ style = '.fill {fill:%s;stroke:%s;}' % (fill, fill)
data = re.sub('\.fill \{.*\}', style, data)
- style = '.shape {stroke:%s;fill:%s;}' % ('black', 'black')
+ style = '.shape {stroke:%s;fill:%s;}' % (stroke, stroke)
data = re.sub('\.shape \{.*\}', style, data)
- style = '.shape-and-fill {fill:%s; stroke:%s;}' % (color, 'black')
+ style = '.shape-and-fill {fill:%s; stroke:%s;}' % (fill, stroke)
data = re.sub('\.shape-and-fill \{.*\}', style, data)
loader = gtk.gdk.pixbuf_loader_new_with_mime_type('image/svg-xml')
diff --git a/tools/hex-colors-to-dict b/tools/hex-colors-to-dict
new file mode 100755
index 0000000..5fa3ea7
--- /dev/null
+++ b/tools/hex-colors-to-dict
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+
+import sys
+
+result = 'colors_dict = {\n'
+result += '\'white\' : \'black\' , \\\n'
+
+hex_file = open(sys.argv[1], 'r')
+
+for line in hex_file.readlines():
+ [ stroke, fill ] = line.split()
+ result += '\'#%s\' : \'#%s\', \\\n' % (fill, stroke)
+
+result += '}'
+
+hex_file.close()
+
+print result
+