Add color support to the profile
This commit is contained in:
parent
c3d0ae0359
commit
3f50668494
@ -3,7 +3,7 @@ import random
|
|||||||
import goocanvas
|
import goocanvas
|
||||||
|
|
||||||
from sugar.canvas.IconItem import IconItem
|
from sugar.canvas.IconItem import IconItem
|
||||||
from sugar.canvas.IconItem import IconColor
|
from sugar.canvas.IconColor import IconColor
|
||||||
|
|
||||||
import Theme
|
import Theme
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import goocanvas
|
|||||||
import wnck
|
import wnck
|
||||||
|
|
||||||
from sugar.canvas.IconItem import IconItem
|
from sugar.canvas.IconItem import IconItem
|
||||||
from sugar.canvas.IconItem import IconColor
|
from sugar.canvas.IconColor import IconColor
|
||||||
from sugar.canvas.DonutItem import DonutItem
|
from sugar.canvas.DonutItem import DonutItem
|
||||||
from sugar.canvas.DonutItem import PieceItem
|
from sugar.canvas.DonutItem import PieceItem
|
||||||
from sugar.canvas.DonutItem import PieceIcon
|
from sugar.canvas.DonutItem import PieceIcon
|
||||||
|
@ -2,7 +2,7 @@ import gtk
|
|||||||
import goocanvas
|
import goocanvas
|
||||||
|
|
||||||
from sugar.canvas.IconItem import IconItem
|
from sugar.canvas.IconItem import IconItem
|
||||||
from sugar.canvas.IconItem import IconColor
|
from sugar.canvas.IconColor import IconColor
|
||||||
from sugar import conf
|
from sugar import conf
|
||||||
from panel.Panel import Panel
|
from panel.Panel import Panel
|
||||||
|
|
||||||
|
119
sugar/canvas/IconColor.py
Normal file
119
sugar/canvas/IconColor.py
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
import random
|
||||||
|
|
||||||
|
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
|
@ -1,4 +1,3 @@
|
|||||||
import random
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import gobject
|
import gobject
|
||||||
@ -6,124 +5,7 @@ import gtk
|
|||||||
import goocanvas
|
import goocanvas
|
||||||
|
|
||||||
from sugar.util import GObjectSingletonMeta
|
from sugar.util import GObjectSingletonMeta
|
||||||
|
from sugar.canvas.IconColor import IconColor
|
||||||
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):
|
class IconCache(gobject.GObject):
|
||||||
__metaclass__ = GObjectSingletonMeta
|
__metaclass__ = GObjectSingletonMeta
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
from ConfigParser import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
|
from sugar.canvas.IconColor import IconColor
|
||||||
|
|
||||||
class Profile:
|
class Profile:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -12,6 +13,13 @@ class Profile:
|
|||||||
if exc[0] != 17: # file exists
|
if exc[0] != 17: # file exists
|
||||||
print "Could not create user directory."
|
print "Could not create user directory."
|
||||||
|
|
||||||
|
def get_color(self):
|
||||||
|
return self._color
|
||||||
|
|
||||||
|
def set_color(self, color):
|
||||||
|
self._color = color
|
||||||
|
self.save()
|
||||||
|
|
||||||
def get_nick_name(self):
|
def get_nick_name(self):
|
||||||
return self._nick_name
|
return self._nick_name
|
||||||
|
|
||||||
@ -27,6 +35,7 @@ class Profile:
|
|||||||
|
|
||||||
base_path = os.path.expanduser('~/.sugar')
|
base_path = os.path.expanduser('~/.sugar')
|
||||||
self._path = os.path.join(base_path, profile_id)
|
self._path = os.path.join(base_path, profile_id)
|
||||||
|
self._color = None
|
||||||
self._ensure_dirs()
|
self._ensure_dirs()
|
||||||
|
|
||||||
cp = ConfigParser()
|
cp = ConfigParser()
|
||||||
@ -34,6 +43,11 @@ class Profile:
|
|||||||
|
|
||||||
if cp.has_option('Buddy', 'NickName'):
|
if cp.has_option('Buddy', 'NickName'):
|
||||||
self._nick_name = cp.get('Buddy', 'NickName')
|
self._nick_name = cp.get('Buddy', 'NickName')
|
||||||
|
if cp.has_option('Buddy', 'Color'):
|
||||||
|
self._color = IconColor(cp.get('Buddy', 'Color'))
|
||||||
|
|
||||||
|
if self._color == None:
|
||||||
|
self.set_color(IconColor())
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
cp = ConfigParser()
|
cp = ConfigParser()
|
||||||
@ -41,6 +55,7 @@ class Profile:
|
|||||||
section = 'Buddy'
|
section = 'Buddy'
|
||||||
cp.add_section(section)
|
cp.add_section(section)
|
||||||
cp.set(section, 'NickName', self._nick_name)
|
cp.set(section, 'NickName', self._nick_name)
|
||||||
|
cp.set(section, 'Color', self._color.get_fill_color())
|
||||||
|
|
||||||
fileobject = open(self._get_config_path(), 'w')
|
fileobject = open(self._get_config_path(), 'w')
|
||||||
cp.write(fileobject)
|
cp.write(fileobject)
|
||||||
|
Loading…
Reference in New Issue
Block a user