diff options
author | Daniel Francis <francis@sugarlabs.org> | 2012-10-06 18:56:41 (GMT) |
---|---|---|
committer | Daniel Francis <francis@sugarlabs.org> | 2012-10-06 18:56:41 (GMT) |
commit | 28fcb38fbfe8f81f718151c64580813e55606e61 (patch) | |
tree | e20c539e0fa02871f0898bdc2ed0579f72d99848 | |
parent | 455e1c2250d834fc9bea9c9b06d78492519a10ef (diff) |
Update Sweetener
-rwxr-xr-x | application.py | 6 | ||||
-rw-r--r-- | desktop/sweetener/colors.py | 55 | ||||
-rw-r--r-- | desktop/sweetener/icon.py | 2 | ||||
-rw-r--r-- | desktop/sweetener/xocolor.py | 70 | ||||
-rw-r--r-- | sugar/sweetener/colors.py | 6 | ||||
-rw-r--r-- | sugar/sweetener/icon.py | 2 | ||||
-rw-r--r-- | sugar/sweetener/xocolor.py | 18 |
7 files changed, 61 insertions, 98 deletions
diff --git a/application.py b/application.py index c50b69f..23556ab 100755 --- a/application.py +++ b/application.py @@ -137,7 +137,7 @@ class Application(gtk.Window): self.canvas.connect('expose-event', self.expose_event) def expose_event(self, widget, event): - logger.debug('Exposing') + #logger.debug('Exposing') if not self.started: if self.file_path != None: self.canvas.read_file(self.file_path) @@ -240,7 +240,7 @@ class Application(gtk.Window): if __name__ == '__main__': - logger.debug('Initializing Graph Plotter') + logger.debug('Initializing %s' % info.name) import sys if info.io_mode == info.DOCUMENT: if len(sys.argv) > 1: @@ -263,5 +263,5 @@ if __name__ == '__main__': window.file_path = file_path window.show() gtk.main() - logger.debug('Closing Graph Plotter') + logger.debug('Closing %s' % info.name) exit() diff --git a/desktop/sweetener/colors.py b/desktop/sweetener/colors.py index d825f4c..cff7ca1 100644 --- a/desktop/sweetener/colors.py +++ b/desktop/sweetener/colors.py @@ -1,7 +1,11 @@ """Color handling. Utilities for handle color data and conversions. """ -# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org> +# XOColor from Sugar Toolkit: +# Copyright (C) 2006-2007 Red Hat, Inc. +# +# Adaptation and more: +# Copyright (C) 2012 Daniel Francis # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,7 +25,56 @@ Utilities for handle color data and conversions. import logging logger = logging.getLogger('colors') +# Part from Sugar Toolkit with very few adaptations. + +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): + logger.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) + +# Added in Sweetener def color2string(color): """Converts a GdkColor to a RGB string color -- gtk.gdk.Color diff --git a/desktop/sweetener/icon.py b/desktop/sweetener/icon.py index 446c603..3eb0515 100644 --- a/desktop/sweetener/icon.py +++ b/desktop/sweetener/icon.py @@ -29,7 +29,7 @@ import gobject import gtk import cairo -from xocolor import XoColor +from colors import XoColor class Node(object): 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) diff --git a/sugar/sweetener/colors.py b/sugar/sweetener/colors.py index 3b5d938..cb38f7a 100644 --- a/sugar/sweetener/colors.py +++ b/sugar/sweetener/colors.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org> +# Copyright (C) 2012 Daniel Francis # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,6 +18,7 @@ import logging logger = logging.getLogger('colors') +from sugar.graphics.xocolor import XOColor def color2string(color): color_string = ["#"] diff --git a/sugar/sweetener/icon.py b/sugar/sweetener/icon.py index 59be87a..07c8c47 100644 --- a/sugar/sweetener/icon.py +++ b/sugar/sweetener/icon.py @@ -1,4 +1,4 @@ -# Copyright (C) 2006-2007 Red Hat, Inc. +# Copyright (C) 2012 Daniel Francis # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public diff --git a/sugar/sweetener/xocolor.py b/sugar/sweetener/xocolor.py deleted file mode 100644 index a5344cc..0000000 --- a/sugar/sweetener/xocolor.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (C) 2012 Daniel Francis <francis@sugarlabs.org> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. - -from sugar.graphics.xocolor import * |