diff options
Diffstat (limited to 'desktop/sweetener/xocolor.py')
-rw-r--r-- | desktop/sweetener/xocolor.py | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/desktop/sweetener/xocolor.py b/desktop/sweetener/xocolor.py deleted file mode 100644 index ab05cb2..0000000 --- a/desktop/sweetener/xocolor.py +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright (C) 2006-2007 Red Hat, Inc. -# Copyright (C) 2012 Daniel Francis <francis@sugarlabs.org> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -""" -STABLE. -""" - -import logging - - -def _parse_string(color_string): - if not isinstance(color_string, (str, unicode)): - logging.error('Invalid color string: %r', color_string) - return None - - if color_string == 'white': - return ['#ffffff', '#414141'] - elif color_string == 'insensitive': - return ['#ffffff', '#e2e2e2'] - - 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 XoColor: - - def __init__(self, color_string): - if not is_valid(color_string): - logging.debug('Color string is not valid: %s, ' - 'fallback to default', color_string) - raise Exception - - [self.stroke, self.fill] = _parse_string(color_string) - - def __cmp__(self, other): - if isinstance(other, XoColor): - if self.stroke == other.stroke and self.fill == other.fill: - return 0 - return -1 - - 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) |