Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGary Martin <gary@garycmartin.com>2008-12-20 02:06:25 (GMT)
committer Gary Martin <gary@garycmartin.com>2008-12-20 02:06:25 (GMT)
commita4f7e374c4bcc32c106fe640937021c98c217445 (patch)
tree921a063a0b9cb224d3fb4a4d72dfda750ed7d663 /src
parentb7a8aacf356533618e26ae2fadf3041ec018f21c (diff)
Use users XO colours for the primary thought.
Diffstat (limited to 'src')
-rw-r--r--src/TextThought.py4
-rw-r--r--src/utils.py44
2 files changed, 42 insertions, 6 deletions
diff --git a/src/TextThought.py b/src/TextThought.py
index de7817b..6d363f2 100644
--- a/src/TextThought.py
+++ b/src/TextThought.py
@@ -336,7 +336,9 @@ class TextThought (BaseThought.BaseThought):
context.stroke ()
(textx, texty) = (self.text_location[0], self.text_location[1])
- if (self.foreground_color):
+ if self.am_primary:
+ r, g, b = utils.primary_colors["text"]
+ elif (self.foreground_color):
r, g, b = utils.gtk_to_cairo_color(self.foreground_color)
else:
r, g ,b = utils.gtk_to_cairo_color(utils.default_colors["text"])
diff --git a/src/utils.py b/src/utils.py
index 05d468f..d3d4755 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -32,6 +32,13 @@ import os
import gtk
+try:
+ # Sugar specific modules
+ from sugar.profile import get_color
+ from sugar.graphics.style import Color
+except:
+ pass
+
def color_to_string(color):
# Needed for compatibility with pygtk < 2.12
return '#%04x%04x%04x' % (color.red, color.green, color.blue)
@@ -64,6 +71,29 @@ selected_colors = {
default_font = None
+try:
+ # Sugar specific tweak
+ xo_col = get_color()
+ rf, gf, bf, af = Color(xo_col.get_fill_color()).get_rgba()
+ rs, gs, bs, as = Color(xo_col.get_stroke_color()).get_rgba()
+
+ # Use white or black text for best contrast
+ if rf + gf + bf < 0.5:
+ rt, gt, bt = 1, 1, 1
+ else:
+ rt, gt, bt = 0, 0, 0
+ primary_colors = {
+ "bg" : (rf, gf, bf),
+ "fg" : (rs, gs, bs),
+ "text" : (rt, gt, bt)
+ }
+except:
+ primary_colors = {
+ "bg" : (0.2, 0.6, 1.0),
+ "fg" : (0, 0, 0),
+ "text" : (0, 0, 0)
+ }
+
def get_save_dir ():
''' Returns the path to the directory to save the maps to '''
try:
@@ -170,15 +200,19 @@ def draw_thought_extended (context, ul, lr, am_root, am_primary, background_colo
context.line_to (ul[0]+15, ul[1])
context.curve_to (ul[0], ul[1], ul[0], ul[1], ul[0], ul[1]+15)
if am_root:
- bg = selected_colors["bg"]
- context.set_source_rgb (bg[0], bg[1], bg[2])
+ r,g,b = selected_colors["bg"]
elif am_primary:
- context.set_source_rgb (0.937, 0.831, 0.000)
+ r,g,b = primary_colors["bg"]
else:
r,g,b = gtk_to_cairo_color(background_color)
- context.set_source_rgb (r, g, b)
+ context.set_source_rgb (r, g, b)
context.fill_preserve ()
- context.set_source_rgb (0,0,0)
+ if am_primary:
+ r,g,b = primary_colors["fg"]
+ context.set_source_rgb (r,g,b)
+ fatborder = True
+ else:
+ context.set_source_rgb (0,0,0)
if dashborder:
context.set_dash([4.0], 0.0)
if fatborder: