diff options
Diffstat (limited to 'extensions/cpsection/aboutme')
-rw-r--r-- | extensions/cpsection/aboutme/__init__.py | 2 | ||||
-rw-r--r-- | extensions/cpsection/aboutme/model.py | 64 | ||||
-rw-r--r-- | extensions/cpsection/aboutme/view.py | 34 |
3 files changed, 54 insertions, 46 deletions
diff --git a/extensions/cpsection/aboutme/__init__.py b/extensions/cpsection/aboutme/__init__.py index 98843e1..7ded428 100644 --- a/extensions/cpsection/aboutme/__init__.py +++ b/extensions/cpsection/aboutme/__init__.py @@ -24,5 +24,3 @@ ICON = 'module-about_me' TITLE = _('About Me') client = gconf.client_get_default() COLOR = XoColor(client.get_string('/desktop/sugar/user/color')) - - diff --git a/extensions/cpsection/aboutme/model.py b/extensions/cpsection/aboutme/model.py index 8500799..fb4c2f1 100644 --- a/extensions/cpsection/aboutme/model.py +++ b/extensions/cpsection/aboutme/model.py @@ -18,38 +18,45 @@ from gettext import gettext as _ import gconf -_COLORS = {'red': {'dark':'#b20008', 'medium':'#e6000a', 'light':'#ffadce'}, - 'orange': {'dark':'#9a5200', 'medium':'#c97e00', 'light':'#ffc169'}, - 'yellow': {'dark':'#807500', 'medium':'#be9e00', 'light':'#fffa00'}, - 'green': {'dark':'#008009', 'medium':'#00b20d', 'light':'#8bff7a'}, - 'blue': {'dark':'#00588c', 'medium':'#005fe4', 'light':'#bccdff'}, - 'purple': {'dark':'#5e008c', 'medium':'#7f00bf', 'light':'#d1a3ff'} - } + +_COLORS = { + 'red': {'dark': '#b20008', 'medium': '#e6000a', 'light': '#ffadce'}, + 'orange': {'dark': '#9a5200', 'medium': '#c97e00', 'light': '#ffc169'}, + 'yellow': {'dark': '#807500', 'medium': '#be9e00', 'light': '#fffa00'}, + 'green': {'dark': '#008009', 'medium': '#00b20d', 'light': '#8bff7a'}, + 'blue': {'dark': '#00588c', 'medium': '#005fe4', 'light': '#bccdff'}, + 'purple': {'dark': '#5e008c', 'medium': '#7f00bf', 'light': '#d1a3ff'}, +} _MODIFIERS = ('dark', 'medium', 'light') - + + def get_nick(): client = gconf.client_get_default() - return client.get_string("/desktop/sugar/user/nick") + return client.get_string('/desktop/sugar/user/nick') + def print_nick(): print get_nick() - + + def set_nick(nick): """Set the nickname. nick : e.g. 'walter' """ if not nick: - raise ValueError(_("You must enter a name.")) + raise ValueError(_('You must enter a name.')) if not isinstance(nick, unicode): nick = unicode(nick, 'utf-8') client = gconf.client_get_default() - client.set_string("/desktop/sugar/user/nick", nick) + client.set_string('/desktop/sugar/user/nick', nick) return 1 + def get_color(): client = gconf.client_get_default() - return client.get_string("/desktop/sugar/user/color") + return client.get_string('/desktop/sugar/user/color') + def print_color(): color_string = get_color() @@ -64,16 +71,17 @@ def print_color(): if _COLORS[color][hue] == tmp[1]: fill_tuple = (color, hue) - if stroke_tuple is not None: - print _('stroke: color=%s hue=%s') % (stroke_tuple[0], + if stroke_tuple is not None: + print _('stroke: color=%s hue=%s') % (stroke_tuple[0], stroke_tuple[1]) else: - print _('stroke: %s') % (tmp[0]) - if fill_tuple is not None: + print _('stroke: %s') % (tmp[0]) + if fill_tuple is not None: print _('fill: color=%s hue=%s') % (fill_tuple[0], fill_tuple[1]) else: print _('fill: %s') % (tmp[1]) - + + def set_color(stroke, fill, stroke_modifier='medium', fill_modifier='medium'): """Set the system color by setting a fill and stroke color. fill : [red, orange, yellow, blue, green, purple] @@ -81,35 +89,37 @@ def set_color(stroke, fill, stroke_modifier='medium', fill_modifier='medium'): hue stroke : [dark, medium, light] (optional) hue fill : [dark, medium, light] (optional) """ - + if stroke_modifier not in _MODIFIERS or fill_modifier not in _MODIFIERS: - print (_("Error in specified color modifiers.")) + print (_('Error in specified color modifiers.')) return if stroke not in _COLORS or fill not in _COLORS: - print (_("Error in specified colors.")) + print (_('Error in specified colors.')) return - + if stroke_modifier == fill_modifier: if fill_modifier == 'medium': fill_modifier = 'light' else: fill_modifier = 'medium' - + color = _COLORS[stroke][stroke_modifier] + ',' \ + _COLORS[fill][fill_modifier] client = gconf.client_get_default() - client.set_string("/desktop/sugar/user/color", color) + client.set_string('/desktop/sugar/user/color', color) return 1 + def get_color_xo(): client = gconf.client_get_default() - return client.get_string("/desktop/sugar/user/color") + return client.get_string('/desktop/sugar/user/color') + def set_color_xo(color): - """Set a color with an XoColor + """Set a color with an XoColor This method is used by the graphical user interface """ client = gconf.client_get_default() - client.set_string("/desktop/sugar/user/color", color) + client.set_string('/desktop/sugar/user/color', color) return 1 diff --git a/extensions/cpsection/aboutme/view.py b/extensions/cpsection/aboutme/view.py index 95314a1..84daec7 100644 --- a/extensions/cpsection/aboutme/view.py +++ b/extensions/cpsection/aboutme/view.py @@ -35,12 +35,12 @@ def _get_next_stroke_color(color): as color. """ current_index = _get_current_index(color) if current_index == -1: - return "%s,%s" % (color.stroke, color.fill) + return '%s,%s' % (color.stroke, color.fill) next_index = _next_index(current_index) while(colors[next_index][_FILL_COLOR] != \ colors[current_index][_FILL_COLOR]): next_index = _next_index(next_index) - return "%s,%s" % (colors[next_index][_STROKE_COLOR], + return '%s,%s' % (colors[next_index][_STROKE_COLOR], colors[next_index][_FILL_COLOR]) @@ -49,12 +49,12 @@ def _get_previous_stroke_color(color): as color. """ current_index = _get_current_index(color) if current_index == -1: - return "%s,%s" % (color.stroke, color.fill) + return '%s,%s' % (color.stroke, color.fill) previous_index = _previous_index(current_index) while (colors[previous_index][_FILL_COLOR] != \ colors[current_index][_FILL_COLOR]): previous_index = _previous_index(previous_index) - return "%s,%s" % (colors[previous_index][_STROKE_COLOR], + return '%s,%s' % (colors[previous_index][_STROKE_COLOR], colors[previous_index][_FILL_COLOR]) @@ -63,12 +63,12 @@ def _get_next_fill_color(color): as color. """ current_index = _get_current_index(color) if current_index == -1: - return "%s,%s" % (color.stroke, color.fill) + return '%s,%s' % (color.stroke, color.fill) next_index = _next_index(current_index) while (colors[next_index][_STROKE_COLOR] != \ colors[current_index][_STROKE_COLOR]): next_index = _next_index(next_index) - return "%s,%s" % (colors[next_index][_STROKE_COLOR], + return '%s,%s' % (colors[next_index][_STROKE_COLOR], colors[next_index][_FILL_COLOR]) @@ -77,12 +77,12 @@ def _get_previous_fill_color(color): as color. """ current_index = _get_current_index(color) if current_index == -1: - return "%s,%s" % (color.stroke, color.fill) + return '%s,%s' % (color.stroke, color.fill) previous_index = _previous_index(current_index) while (colors[previous_index][_STROKE_COLOR] != \ colors[current_index][_STROKE_COLOR]): previous_index = _previous_index(previous_index) - return "%s,%s" % (colors[previous_index][_STROKE_COLOR], + return '%s,%s' % (colors[previous_index][_STROKE_COLOR], colors[previous_index][_FILL_COLOR]) @@ -96,7 +96,7 @@ def _next_index(current_index): def _previous_index(current_index): previous_index = current_index - 1 if previous_index < 0: - previous_index = len(colors)-1 + previous_index = len(colors) - 1 return previous_index @@ -112,7 +112,7 @@ _PREVIOUS_STROKE_COLOR = 4 class EventIcon(gtk.EventBox): - __gtype_name__ = "SugarEventIcon" + __gtype_name__ = 'SugarEventIcon' def __init__(self, **kwargs): gtk.EventBox.__init__(self) @@ -131,7 +131,7 @@ class ColorPicker(EventIcon): __gsignals__ = { 'color-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, - ([object])) + ([object])), } def __init__(self, picker): @@ -184,12 +184,12 @@ class AboutMe(SectionView): self._color_alert = None self._pickers = { - _PREVIOUS_FILL_COLOR: ColorPicker(_PREVIOUS_FILL_COLOR), - _NEXT_FILL_COLOR: ColorPicker(_NEXT_FILL_COLOR), - _CURRENT_COLOR: ColorPicker(_CURRENT_COLOR), - _NEXT_STROKE_COLOR: ColorPicker(_NEXT_STROKE_COLOR), - _PREVIOUS_STROKE_COLOR: ColorPicker(_PREVIOUS_STROKE_COLOR) - } + _PREVIOUS_FILL_COLOR: ColorPicker(_PREVIOUS_FILL_COLOR), + _NEXT_FILL_COLOR: ColorPicker(_NEXT_FILL_COLOR), + _CURRENT_COLOR: ColorPicker(_CURRENT_COLOR), + _NEXT_STROKE_COLOR: ColorPicker(_NEXT_STROKE_COLOR), + _PREVIOUS_STROKE_COLOR: ColorPicker(_PREVIOUS_STROKE_COLOR), + } self._setup_color() initial_color = XoColor(self._model.get_color_xo()) |