From ada061974b06412453d1b76d50da824a99272517 Mon Sep 17 00:00:00 2001 From: Agustin Zubiaga Date: Fri, 09 Mar 2012 03:35:43 +0000 Subject: utils.py fixes --- diff --git a/activity.py b/activity.py index eae98c8..903ac2b 100644 --- a/activity.py +++ b/activity.py @@ -54,8 +54,8 @@ _STOPWATCH_MIME_TYPE = "application/x-stopwatch-activity" _CSV_MIME_TYPE = "text/csv" # GUI Colors -_COLOR1 = gtk.gdk.Color(utils.get_user_color()[0]) -_COLOR2 = gtk.gdk.Color(utils.get_user_color()[1]) +_COLOR1 = utils.get_user_fill_color() +_COLOR2 = utils.get_user_stroke_color() _WHITE = gtk.gdk.color_parse("white") # Paths @@ -112,8 +112,8 @@ class SimpleGraph(activity.Activity): self.x_label = "" self.y_label = "" - self.chart_color = utils.get_user_color()[0] - self.chart_line_color = utils.get_user_color()[1] + self.chart_color = utils.get_user_fill_color('str') + self.chart_line_color = utils.get_user_stroke_color('str') self.current_chart = None self.charts_area = None self.chart_data = [] @@ -438,11 +438,11 @@ class SimpleGraph(activity.Activity): self._update_chart_labels() def _set_chart_color(self, widget, pspec): - self.chart_color = utils.rgb_to_html(widget.get_color()) + self.chart_color = utils.rgb2html(widget.get_color()) self._render_chart() def _set_chart_line_color(self, widget, pspec): - self.chart_line_color = utils.rgb_to_html(widget.get_color()) + self.chart_line_color = utils.rgb2html(widget.get_color()) self._render_chart() def _object_chooser(self, mime_type, type_name): diff --git a/utils.py b/utils.py index 01741df..eff333c 100644 --- a/utils.py +++ b/utils.py @@ -19,10 +19,12 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import os -import gconf +import gtk +from sugar import profile -def rgb_to_html(color): + +def rgb2html(color): """Returns a html string from a Gdk color""" red = "%x" % int(color.red / 65535.0 * 255) if len(red) == 1: @@ -43,10 +45,30 @@ def rgb_to_html(color): return new_color -def get_user_color(): - """Returns the user colors""" - color = gconf.client_get_default().get_string("/desktop/sugar/user/color") - return color.split(",") +def get_user_fill_color(type='gdk'): + """Returns the user fill color""" + color = profile.get_color() + + if type == 'gdk': + rcolor = gtk.gdk.Color(color.get_fill_color()) + + elif type == 'str': + rcolor = color.get_fill_color() + + return rcolor + + +def get_user_stroke_color(type='gdk'): + """Returns the user stroke color""" + color = profile.get_color() + + if type == 'gdk': + rcolor = gtk.gdk.Color(color.get_stroke_color()) + + elif type == 'str': + rcolor = color.get_stroke_color() + + return rcolor def get_chart_file(activity_dir): -- cgit v0.9.1