<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.sugarlabs.org/index.php?action=history&amp;feed=atom&amp;title=Features%2FEnhanced_color_selector%2FPatch-xocolor</id>
	<title>Features/Enhanced color selector/Patch-xocolor - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.sugarlabs.org/index.php?action=history&amp;feed=atom&amp;title=Features%2FEnhanced_color_selector%2FPatch-xocolor"/>
	<link rel="alternate" type="text/html" href="https://wiki.sugarlabs.org/index.php?title=Features/Enhanced_color_selector/Patch-xocolor&amp;action=history"/>
	<updated>2026-04-11T16:32:03Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.sugarlabs.org/index.php?title=Features/Enhanced_color_selector/Patch-xocolor&amp;diff=42153&amp;oldid=prev</id>
		<title>Walter at 22:46, 21 December 2009</title>
		<link rel="alternate" type="text/html" href="https://wiki.sugarlabs.org/index.php?title=Features/Enhanced_color_selector/Patch-xocolor&amp;diff=42153&amp;oldid=prev"/>
		<updated>2009-12-21T22:46:34Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://wiki.sugarlabs.org/index.php?title=Features/Enhanced_color_selector/Patch-xocolor&amp;amp;diff=42153&amp;amp;oldid=40403&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Walter</name></author>
	</entry>
	<entry>
		<id>https://wiki.sugarlabs.org/index.php?title=Features/Enhanced_color_selector/Patch-xocolor&amp;diff=40403&amp;oldid=prev</id>
		<title>Walter at 20:50, 19 November 2009</title>
		<link rel="alternate" type="text/html" href="https://wiki.sugarlabs.org/index.php?title=Features/Enhanced_color_selector/Patch-xocolor&amp;diff=40403&amp;oldid=prev"/>
		<updated>2009-11-19T20:50:37Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:50, 19 November 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--- src/sugar/graphics/xocolor.py	2009-11-19 14:54:22.000000000 -0500&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--- src/sugar/graphics/xocolor.py	2009-11-19 14:54:22.000000000 -0500&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;+++ src/sugar/graphics/xocolor.py	2009-11-19 15:00:58.000000000 -0500&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;+++ src/sugar/graphics/xocolor.py	2009-11-19 15:00:58.000000000 -0500&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l65&quot;&gt;Line 65:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 66:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  if __name__ == &amp;quot;__main__&amp;quot;:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  if __name__ == &amp;quot;__main__&amp;quot;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      import sys&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      import sys&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Walter</name></author>
	</entry>
	<entry>
		<id>https://wiki.sugarlabs.org/index.php?title=Features/Enhanced_color_selector/Patch-xocolor&amp;diff=40402&amp;oldid=prev</id>
		<title>Walter: Created page with &#039;--- src/sugar/graphics/xocolor.py	2009-11-19 14:54:22.000000000 -0500 +++ src/sugar/graphics/xocolor.py	2009-11-19 15:00:58.000000000 -0500 @@ -1,4 +1,5 @@  # Copyright (C) 2006-…&#039;</title>
		<link rel="alternate" type="text/html" href="https://wiki.sugarlabs.org/index.php?title=Features/Enhanced_color_selector/Patch-xocolor&amp;diff=40402&amp;oldid=prev"/>
		<updated>2009-11-19T20:50:10Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;--- src/sugar/graphics/xocolor.py	2009-11-19 14:54:22.000000000 -0500 +++ src/sugar/graphics/xocolor.py	2009-11-19 15:00:58.000000000 -0500 @@ -1,4 +1,5 @@  # Copyright (C) 2006-…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--- src/sugar/graphics/xocolor.py	2009-11-19 14:54:22.000000000 -0500&lt;br /&gt;
+++ src/sugar/graphics/xocolor.py	2009-11-19 15:00:58.000000000 -0500&lt;br /&gt;
@@ -1,4 +1,5 @@&lt;br /&gt;
 # Copyright (C) 2006-2007 Red Hat, Inc.&lt;br /&gt;
+# Copyright (C) 2008-2009 Sugar Labs&lt;br /&gt;
 #&lt;br /&gt;
 # This library is free software; you can redistribute it and/or&lt;br /&gt;
 # modify it under the terms of the GNU Lesser General Public&lt;br /&gt;
@@ -240,10 +241,11 @@ class XoColor:&lt;br /&gt;
             randomize = False&lt;br /&gt;
 &lt;br /&gt;
         if randomize:&lt;br /&gt;
-            n = int(random.random() * (len(colors) - 1))&lt;br /&gt;
-            [self.stroke, self.fill] = colors[n]&lt;br /&gt;
+            [self.strole, self.fill] = self.get_random_color()&lt;br /&gt;
         else:&lt;br /&gt;
             [self.stroke, self.fill] = _parse_string(color_string)&lt;br /&gt;
+        # save an index to our color in the list&lt;br /&gt;
+        self.n = self.find_index()&lt;br /&gt;
 &lt;br /&gt;
     def __cmp__(self, other):&lt;br /&gt;
         if isinstance(other, XoColor):&lt;br /&gt;
@@ -257,9 +259,43 @@ class XoColor:&lt;br /&gt;
     def get_fill_color(self):&lt;br /&gt;
         return self.fill&lt;br /&gt;
 &lt;br /&gt;
+    def set_color(self, color_string):&lt;br /&gt;
+        if color_string == None or not is_valid(color_string):&lt;br /&gt;
+            logging.debug(&amp;#039;Color string is not valid: %s, &amp;#039;&lt;br /&gt;
+                          &amp;#039;fallback to default&amp;#039;, color_string)&lt;br /&gt;
+        [self.stroke,self.fill] = _parse_string(color_string)&lt;br /&gt;
+        self.n = self.find_index()&lt;br /&gt;
+&lt;br /&gt;
+    def get_random_color(self):&lt;br /&gt;
+        my_n = int(random.random() * (len(colors) - 1))&lt;br /&gt;
+        [my_stroke, my_fill] = colors[my_n]&lt;br /&gt;
+        return &amp;quot;%s,%s&amp;quot; % (my_stroke, my_fill)&lt;br /&gt;
+&lt;br /&gt;
+    def get_next_color(self):&lt;br /&gt;
+        my_n = self.n&lt;br /&gt;
+        my_n += 1&lt;br /&gt;
+        if my_n == len(colors):&lt;br /&gt;
+            my_n = 0&lt;br /&gt;
+        [my_stroke, my_fill] = colors[my_n]&lt;br /&gt;
+        return &amp;quot;%s,%s&amp;quot; % (my_stroke, my_fill)&lt;br /&gt;
+&lt;br /&gt;
+    def get_prev_color(self):&lt;br /&gt;
+        my_n = self.n&lt;br /&gt;
+        my_n -= 1&lt;br /&gt;
+        if my_n &amp;lt; 0:&lt;br /&gt;
+            my_n = len(colors)-1&lt;br /&gt;
+        [my_stroke, my_fill] = colors[my_n]&lt;br /&gt;
+        return &amp;quot;%s,%s&amp;quot; % (my_stroke, my_fill)&lt;br /&gt;
+&lt;br /&gt;
     def to_string(self):&lt;br /&gt;
         return &amp;#039;%s,%s&amp;#039; % (self.stroke, self.fill)&lt;br /&gt;
 &lt;br /&gt;
+    def find_index(self):&lt;br /&gt;
+        for c in range(0,len(colors)):&lt;br /&gt;
+            if colors[c] == [self.stroke, self.fill]:&lt;br /&gt;
+                return c&lt;br /&gt;
+        # if the color is not found, then return 0&lt;br /&gt;
+        return 0&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
     import sys&lt;/div&gt;</summary>
		<author><name>Walter</name></author>
	</entry>
</feed>