Ticket #1592: 0001-color-selector-feature-changes.patch
File 0001-color-selector-feature-changes.patch, 19.1 KB (added by walter, 14 years ago) |
---|
-
extensions/cpsection/aboutme/view.py
From de6369d242140055b9ff3f907dc29b3717fdde83 Mon Sep 17 00:00:00 2001 From: Walter Bender <walter@walter-laptop.(none)> Date: Mon, 30 Nov 2009 09:28:21 -0500 Subject: [PATCH] color selector feature changes --- extensions/cpsection/aboutme/view.py | 209 ++++++++++++++++++++++++++++++++-- src/jarabe/intro/colorpicker.py | 72 ++++++++++++- src/jarabe/intro/window.py | 81 ++++++++++++- 3 files changed, 346 insertions(+), 16 deletions(-) diff --git a/extensions/cpsection/aboutme/view.py b/extensions/cpsection/aboutme/view.py index cabd66a..d92de87 100644
a b from gettext import gettext as _ 20 20 21 21 from sugar.graphics.icon import Icon 22 22 from sugar.graphics import style 23 from sugar.graphics.toolbutton import ToolButton 23 24 from sugar.graphics.xocolor import XoColor 24 25 25 26 from jarabe.controlpanel.sectionview import SectionView 26 27 from jarabe.controlpanel.inlinealert import InlineAlert 27 28 29 28 30 class EventIcon(gtk.EventBox): 29 31 __gtype_name__ = "SugarEventIcon" 30 32 def __init__(self, **kwargs): … … class EventIcon(gtk.EventBox): 38 40 39 41 self.add(self.icon) 40 42 self.icon.show() 43 """ 44 class StopButton(ToolButton): 45 46 def __init__(self, **kwargs): 47 ToolButton.__init__(self, 'activity-stop', **kwargs) 48 self.props.tooltip = _('Stop') 49 self.props.accelerator = '<Ctrl>Q' 50 self.connect('clicked', self.__stop_button_clicked_cb) 41 51 52 def __stop_button_clicked_cb(self, button): 53 print "out damn spot" 54 """ 42 55 class ColorPicker(EventIcon): 43 56 __gsignals__ = { 44 57 'color-changed': (gobject.SIGNAL_RUN_FIRST, 45 58 gobject.TYPE_NONE, 46 59 ([str])) 47 60 } 48 def __init__(self, xocolor=None):61 def __init__(self, me, xo_color=None): 49 62 EventIcon.__init__(self) 50 self.icon.props.xo_color = xo color63 self.icon.props.xo_color = xo_color 51 64 self.icon.props.icon_name = 'computer-xo' 52 65 self.icon.props.pixel_size = style.XLARGE_ICON_SIZE 53 self.connect('button_press_event', self.__pressed_cb) 66 self.connect('button_press_event', self.__pressed_cb, me) 67 68 def __pressed_cb(self, button, event, me): 69 me.set_random_colors() 70 71 class ColorPrev(EventIcon): 72 __gsignals__ = { 73 'color-changed': (gobject.SIGNAL_RUN_FIRST, 74 gobject.TYPE_NONE, 75 ([str])) 76 } 77 def __init__(self, me, xo_next_color=None): 78 EventIcon.__init__(self) 79 self.icon.props.xo_color = xo_next_color 80 self.icon.props.icon_name = 'computer-xo' 81 self.icon.props.pixel_size = style.STANDARD_ICON_SIZE 82 self.connect('button_press_event', self.__pressed_cb, me) 83 84 def __pressed_cb(self, button, event, me): 85 me.set_prev_colors() 86 87 class ColorNext(EventIcon): 88 __gsignals__ = { 89 'color-changed': (gobject.SIGNAL_RUN_FIRST, 90 gobject.TYPE_NONE, 91 ([str])) 92 } 93 def __init__(self, me, xo_next_color=None): 94 EventIcon.__init__(self) 95 self.icon.props.xo_color = xo_next_color 96 self.icon.props.icon_name = 'computer-xo' 97 self.icon.props.pixel_size = style.STANDARD_ICON_SIZE 98 self.connect('button_press_event', self.__pressed_cb, me) 99 100 def __pressed_cb(self, button, event, me): 101 me.set_next_colors() 102 103 class ColorUndo(EventIcon): 104 __gsignals__ = { 105 'color-changed': (gobject.SIGNAL_RUN_FIRST, 106 gobject.TYPE_NONE, 107 ([str])) 108 } 109 def __init__(self, me): 110 EventIcon.__init__(self) 111 self.icon.props.icon_name = 'edit-undo' 112 # self.icon.props.icon_name = 'view-refresh' 113 # self.icon.props.accelerator = '<Ctrl>z' 114 xocolor = XoColor() 115 xocolor.set_color("#FFFFFF,#FFFFFF") 116 self.icon.props.xo_color = xocolor 117 self.icon.props.pixel_size = style.MEDIUM_ICON_SIZE 118 self.connect('button_press_event', self.__pressed_cb, me) 54 119 55 def __pressed_cb(self, button, event ):56 self._set_random_colors()120 def __pressed_cb(self, button, event, me): 121 me.undo_colors() 57 122 58 def _set_random_colors(self): 123 class Prev(EventIcon): 124 __gsignals__ = { 125 'color-changed': (gobject.SIGNAL_RUN_FIRST, 126 gobject.TYPE_NONE, 127 ([str])) 128 } 129 def __init__(self, me): 130 EventIcon.__init__(self) 131 self.icon.props.icon_name = 'go-left' 59 132 xocolor = XoColor() 133 xocolor.set_color("#FFFFFF,#808080") 60 134 self.icon.props.xo_color = xocolor 61 self.emit('color-changed', xocolor.to_string()) 135 self.icon.props.pixel_size = style.STANDARD_ICON_SIZE 136 self.connect('button_press_event', self.__pressed_cb, me) 137 138 def __pressed_cb(self, button, event, me): 139 me.set_prev_colors() 140 141 class Next(EventIcon): 142 __gsignals__ = { 143 'color-changed': (gobject.SIGNAL_RUN_FIRST, 144 gobject.TYPE_NONE, 145 ([str])) 146 } 147 def __init__(self, me): 148 EventIcon.__init__(self) 149 self.icon.props.icon_name = 'go-right' 150 xocolor = XoColor() 151 xocolor.set_color("#FFFFFF,#808080") 152 self.icon.props.xo_color = xocolor 153 self.icon.props.pixel_size = style.STANDARD_ICON_SIZE 154 self.connect('button_press_event', self.__pressed_cb, me) 155 156 def __pressed_cb(self, button, event, me): 157 me.set_next_colors() 62 158 63 159 class AboutMe(SectionView): 64 160 def __init__(self, model, alerts): 65 161 SectionView.__init__(self) 66 162 67 163 self._model = model 164 self._xo_color = XoColor(self._model.get_color_xo()) 165 self._undo_colors = self._xo_color.to_string() 166 self._xo_next_color = XoColor(self._xo_color.get_next_color()) 167 self._xo_prev_color = XoColor(self._xo_color.get_prev_color()) 68 168 self.restart_alerts = alerts 69 169 self._nick_sid = 0 70 170 self._color_valid = True … … class AboutMe(SectionView): 131 231 self._group.add_widget(label_color) 132 232 self._color_box.pack_start(label_color, expand=False) 133 233 label_color.show() 234 235 self._color_prev = ColorPrev(self,self._xo_prev_color) 236 self._color_box.pack_start(self._color_prev, expand=False) 237 self._color_prev.show() 134 238 135 self._color_picker = ColorPicker() 239 self._prev = Prev(self) 240 self._color_box.pack_start(self._prev, expand=False) 241 self._prev.show() 242 243 self._color_picker = ColorPicker(self,self._xo_color) 136 244 self._color_box.pack_start(self._color_picker, expand=False) 137 245 self._color_picker.show() 138 246 247 self._next = Next(self) 248 self._color_box.pack_start(self._next, expand=False) 249 self._next.show() 250 251 self._color_next = ColorNext(self,self._xo_next_color) 252 self._color_box.pack_start(self._color_next, expand=False) 253 self._color_next.show() 254 255 self._color_undo = ColorUndo(self) 256 self._color_box.pack_start(self._color_undo, expand=False) 257 self._color_undo.show() 258 259 """ 260 self._stop = StopButton() 261 self._color_box.pack_start(self._stop, expand=False) 262 self._stop.show() 263 """ 264 139 265 label_color_error = gtk.Label() 140 266 self._group.add_widget(label_color_error) 141 267 self._color_alert_box.pack_start(label_color_error, expand=False) … … class AboutMe(SectionView): 152 278 self._color_box.show() 153 279 self._color_alert_box.show() 154 280 281 def set_prev_colors(self): 282 # update next color to the current color 283 self._xo_next_color.set_color(self._xo_color.to_string()) 284 self._color_next.icon.props.xo_color = self._xo_next_color 285 self._color_next.emit('color-changed', self._xo_next_color.to_string()) 286 # update color picker to the prev color 287 self._undo_colors = self._xo_color.to_string() 288 self._xo_color.set_color(self._xo_prev_color.to_string()) 289 self._color_picker.icon.props.xo_color = self._xo_color 290 self._color_picker.emit('color-changed', self._xo_color.to_string()) 291 # update prev color to its prev color 292 self._xo_prev_color.set_color(self._xo_prev_color.get_prev_color()) 293 self._color_prev.icon.props.xo_color = self._xo_prev_color 294 self._color_prev.emit('color-changed', self._xo_prev_color.to_string()) 295 296 def set_random_colors(self): 297 # update this color to a random color 298 self._undo_colors = self._xo_color.to_string() 299 self._xo_color.set_color(self._xo_color.get_random_color()) 300 self._color_picker.icon.props.xo_color = self._xo_color 301 self._color_picker.emit('color-changed', self._xo_color.to_string()) 302 # update prev color from the current color 303 self._xo_prev_color.set_color(self._xo_color.get_prev_color()) 304 self._color_prev.icon.props.xo_color = self._xo_prev_color 305 self._color_prev.emit('color-changed', self._xo_prev_color.to_string()) 306 # update next color from the current color 307 self._xo_next_color.set_color(self._xo_color.get_next_color()) 308 self._color_next.icon.props.xo_color = self._xo_next_color 309 self._color_next.emit('color-changed', self._xo_next_color.to_string()) 310 311 def set_next_colors(self): 312 # update prev color to the current color 313 self._xo_prev_color.set_color(self._xo_color.to_string()) 314 self._color_prev.icon.props.xo_color = self._xo_prev_color 315 self._color_prev.emit('color-changed', self._xo_prev_color.to_string()) 316 # update color picker to the next color 317 self._undo_colors = self._xo_color.to_string() 318 self._xo_color.set_color(self._xo_next_color.to_string()) 319 self._color_picker.icon.props.xo_color = self._xo_color 320 self._color_picker.emit('color-changed', self._xo_color.to_string()) 321 # update next color to its next color 322 self._xo_next_color.set_color(self._xo_next_color.get_next_color()) 323 self._color_next.icon.props.xo_color = self._xo_next_color 324 self._color_next.emit('color-changed', self._xo_next_color.to_string()) 325 326 def undo_colors(self): 327 # undo last change 328 tmp = self._xo_color.to_string() 329 self._xo_color.set_color(self._undo_colors) 330 self._undo_colors = tmp 331 self._color_picker.icon.props.xo_color = self._xo_color 332 self._color_picker.emit('color-changed', self._xo_color.to_string()) 333 # update prev color from the current color 334 self._xo_prev_color.set_color(self._xo_color.get_prev_color()) 335 self._color_prev.icon.props.xo_color = self._xo_prev_color 336 self._color_prev.emit('color-changed', self._xo_prev_color.to_string()) 337 # update next color from the current color 338 self._xo_next_color.set_color(self._xo_color.get_next_color()) 339 self._color_next.icon.props.xo_color = self._xo_next_color 340 self._color_next.emit('color-changed', self._xo_next_color.to_string()) 341 155 342 def setup(self): 156 343 self._nick_entry.set_text(self._model.get_nick()) 157 color = XoColor(self._model.get_color_xo()) 158 self._color_picker.icon.props.xo_color = color 344 # mycolor = self._model.get_color_xo() 345 self._color_picker.icon.props.xo_color = self._xo_color 346 self._color_next.icon.props.xo_color = self._xo_next_color 347 self._color_prev.icon.props.xo_color = self._xo_prev_color 159 348 160 349 self._color_valid = True 161 350 self._nick_valid = True -
src/jarabe/intro/colorpicker.py
diff --git a/src/jarabe/intro/colorpicker.py b/src/jarabe/intro/colorpicker.py index a939857..d37d1d1 100644
a b import hippo 19 19 from sugar.graphics.icon import CanvasIcon 20 20 from sugar.graphics import style 21 21 from sugar.graphics.xocolor import XoColor 22 22 """ 23 23 class ColorPicker(hippo.CanvasBox, hippo.CanvasItem): 24 24 def __init__(self, **kwargs): 25 25 hippo.CanvasBox.__init__(self, **kwargs) … … class ColorPicker(hippo.CanvasBox, hippo.CanvasItem): 41 41 def _set_random_colors(self): 42 42 self._xo_color = XoColor() 43 43 self._xo.props.xo_color = self._xo_color 44 """ 45 class ColorPicker(hippo.CanvasBox, hippo.CanvasItem): 46 def __init__(self, me, **kwargs): 47 hippo.CanvasBox.__init__(self, **kwargs) 48 self.props.orientation = hippo.ORIENTATION_HORIZONTAL 49 self._xo_color = None 50 51 self._xo = CanvasIcon(size=style.XLARGE_ICON_SIZE, 52 icon_name='computer-xo') 53 self._xo.connect('activated', self.__pressed_cb, me) 54 self.append(self._xo) 55 56 def __pressed_cb(self, item, me): 57 me.set_random_colors() 58 59 class ColorPrev(hippo.CanvasBox, hippo.CanvasItem): 60 def __init__(self, me, **kwargs): 61 hippo.CanvasBox.__init__(self, **kwargs) 62 self.props.orientation = hippo.ORIENTATION_HORIZONTAL 63 self._xo_color = None 64 65 self._xo = CanvasIcon(size=style.STANDARD_ICON_SIZE, 66 icon_name='computer-xo') 67 self._xo.connect('activated', self.__pressed_cb, me) 68 self.append(self._xo) 69 70 def __pressed_cb(self, item, me): 71 me.set_prev_colors() 72 73 class ColorNext(hippo.CanvasBox, hippo.CanvasItem): 74 def __init__(self, me, **kwargs): 75 hippo.CanvasBox.__init__(self, **kwargs) 76 self.props.orientation = hippo.ORIENTATION_HORIZONTAL 77 self._xo_color = None 78 79 self._xo = CanvasIcon(size=style.STANDARD_ICON_SIZE, 80 icon_name='computer-xo') 81 self._xo.connect('activated', self.__pressed_cb, me) 82 self.append(self._xo) 83 84 def __pressed_cb(self, item, me): 85 me.set_next_colors() 86 87 class Prev(hippo.CanvasBox, hippo.CanvasItem): 88 def __init__(self, me, **kwargs): 89 hippo.CanvasBox.__init__(self, **kwargs) 90 self.props.orientation = hippo.ORIENTATION_HORIZONTAL 91 self._xo_color = None 92 93 self._xo = CanvasIcon(size=style.STANDARD_ICON_SIZE, 94 icon_name='go-left') 95 self._xo.connect('activated', self.__pressed_cb, me) 96 self.append(self._xo) 97 98 def __pressed_cb(self, item, me): 99 me.set_prev_colors() 100 101 class Next(hippo.CanvasBox, hippo.CanvasItem): 102 def __init__(self, me, **kwargs): 103 hippo.CanvasBox.__init__(self, **kwargs) 104 self.props.orientation = hippo.ORIENTATION_HORIZONTAL 105 self._xo_color = None 106 107 self._xo = CanvasIcon(size=style.STANDARD_ICON_SIZE, 108 icon_name='go-right') 109 self._xo.connect('activated', self.__pressed_cb, me) 110 self.append(self._xo) 111 112 def __pressed_cb(self, item, me): 113 me.set_prev_colors() -
src/jarabe/intro/window.py
diff --git a/src/jarabe/intro/window.py b/src/jarabe/intro/window.py index 94c6782..9665d1b 100644
a b class _ColorPage(_Page): 125 125 xalign=hippo.ALIGNMENT_CENTER) 126 126 self.append(self._label) 127 127 128 self._cp = colorpicker.ColorPicker(xalign=hippo.ALIGNMENT_CENTER) 129 self.append(self._cp) 128 self._box = hippo.CanvasBox(orientation=hippo.ORIENTATION_HORIZONTAL) 129 130 self._p = colorpicker.Prev(self) 131 self._box.append(self._p) 132 133 self._pc = colorpicker.ColorPrev(self) 134 self._box.append(self._pc) 135 136 self._cp = colorpicker.ColorPicker(self) 137 self._box.append(self._cp) 138 139 self._nc = colorpicker.ColorNext(self) 140 self._box.append(self._nc) 141 142 self._n = colorpicker.Next(self) 143 self._box.append(self._n) 144 145 self.append(self._box) 130 146 131 self._color = self._cp.get_color()132 147 self.set_valid(True) 133 148 149 self.init_colors() 150 self.set_random_colors() 151 152 def init_colors(self): 153 self._cp._xo_color = XoColor() 154 self._cp._xo.props.xo_color = self._cp._xo_color 155 self._pc._xo_color = XoColor() 156 self._pc._xo.props.xo_color = self._pc._xo_color 157 self._nc._xo_color = XoColor() 158 self._nc._xo.props.xo_color = self._nc._xo_color 159 self._p._xo_color = XoColor() 160 self._p._xo_color.set_color("#808080,#808080") 161 self._p._xo.props.xo_color = self._p._xo_color 162 self._n._xo.props.xo_color = self._p._xo_color 163 164 def set_random_colors(self): 165 self._cp._xo_color.set_color(self._cp._xo_color.get_random_color()) 166 self._cp._xo.props.xo_color = self._cp._xo_color 167 self._pc._xo_color.set_color(self._cp._xo_color.get_prev_color()) 168 self._pc._xo.props.xo_color = self._pc._xo_color 169 self._nc._xo_color.set_color(self._cp._xo_color.get_next_color()) 170 self._nc._xo.props.xo_color = self._nc._xo_color 171 172 def set_prev_colors(self): 173 self._nc._xo_color.set_color(self._cp._xo_color.to_string()) 174 self._nc._xo.props.xo_color = self._nc._xo_color 175 self._cp._xo_color.set_color(self._pc._xo_color.to_string()) 176 self._cp._xo.props.xo_color = self._cp._xo_color 177 self._pc._xo_color.set_color(self._pc._xo_color.get_prev_color()) 178 self._pc._xo.props.xo_color = self._pc._xo_color 179 180 def set_next_colors(self): 181 self._pc._xo_color.set_color(self._cp._xo_color.to_string()) 182 self._pc._xo.props.xo_color = self._pc._xo_color 183 self._cp._xo_color.set_color(self._nc._xo_color.to_string()) 184 self._cp._xo.props.xo_color = self._cp._xo_color 185 self._nc._xo_color.set_color(self._nc._xo_color.get_next_color()) 186 self._nc._xo.props.xo_color = self._nc._xo_color 187 134 188 def get_color(self): 135 return self._cp. get_color()189 return self._cp._xo_color 136 190 137 191 class _IntroBox(hippo.CanvasBox): 138 192 __gsignals__ = { … … class _IntroBox(hippo.CanvasBox): 170 224 171 225 button_box = hippo.CanvasBox(orientation=hippo.ORIENTATION_HORIZONTAL) 172 226 173 if self._page != self.PAGE_FIRST: 227 if self._page == self.PAGE_FIRST: 228 lang_button = hippo.CanvasButton() 229 image = Icon(icon_name='module-language') 230 lang_button.props.widget.set_image(image) 231 lang_button.connect('activated', self._lang_activated_cb) 232 button_box.append(lang_button) 233 keyboard_button = hippo.CanvasButton() 234 image = Icon(icon_name='module-keyboard') 235 keyboard_button.props.widget.set_image(image) 236 keyboard_button.connect('activated', self._keyboard_activated_cb) 237 button_box.append(keyboard_button) 238 else: 174 239 back_button = hippo.CanvasButton(text=_('Back')) 175 240 image = Icon(icon_name='go-left') 176 241 back_button.props.widget.set_image(image) … … class _IntroBox(hippo.CanvasBox): 213 278 def _back_activated_cb(self, item): 214 279 self.back() 215 280 281 def _lang_activated_cb(self, item): 282 print "Language button pressed" 283 284 def _keyboard_activated_cb(self, item): 285 print "Keyboard button pressed" 286 216 287 def back(self): 217 288 if self._page != self.PAGE_FIRST: 218 289 self._page -= 1