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) |
51 | | |
52 | | def __stop_button_clicked_cb(self, button): |
53 | | print "out damn spot" |
54 | | """ |
55 | | class ColorPicker(EventIcon): |
56 | | __gsignals__ = { |
57 | | 'color-changed': (gobject.SIGNAL_RUN_FIRST, |
58 | | gobject.TYPE_NONE, |
59 | | ([str])) |
60 | | } |
61 | | def __init__(self, me, xo_color=None): |
62 | | EventIcon.__init__(self) |
63 | | self.icon.props.xo_color = xo_color |
64 | | self.icon.props.icon_name = 'computer-xo' |
65 | | self.icon.props.pixel_size = style.XLARGE_ICON_SIZE |
66 | | self.connect('button_press_event', self.__pressed_cb, me) |
67 | | |
68 | | def __pressed_cb(self, button, event, me): |
69 | | me.set_random_colors() |
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) |
119 | | |
120 | | def __pressed_cb(self, button, event, me): |
121 | | me.undo_colors() |
122 | | |
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' |
132 | | xocolor = XoColor() |
133 | | xocolor.set_color("#FFFFFF,#808080") |
134 | | self.icon.props.xo_color = xocolor |
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() |
| 58 | if direction == _DIRECTION_CENTER: |
| 59 | self.icon.props.pixel_size = style.XLARGE_ICON_SIZE |
| 60 | self.icon.props.xo_color = xo_color |
| 61 | else: |
| 62 | self.icon.props.pixel_size = style.STANDARD_ICON_SIZE |
| 63 | if direction == _DIRECTION_LEFT: |
| 64 | self.icon.props.xo_color = XoColor( |
| 65 | xo_color.get_prev_fill_color()) |
| 66 | elif direction == _DIRECTION_RIGHT: |
| 67 | self.icon.props.xo_color = XoColor( |
| 68 | xo_color.get_next_fill_color()) |
| 69 | elif direction == _DIRECTION_TOP: |
| 70 | self.icon.props.xo_color = XoColor( |
| 71 | xo_color.get_prev_stroke_color()) |
| 72 | else: |
| 73 | self.icon.props.xo_color = XoColor( |
| 74 | xo_color.get_next_stroke_color()) |
| 75 | self.connect('button_press_event', self.__pressed_cb, me, direction) |
| 76 | |
| 77 | def __pressed_cb(self, button, event, me, direction): |
| 78 | if direction == _DIRECTION_LEFT: |
| 79 | me.set_prev_fill_colors() |
| 80 | elif direction == _DIRECTION_RIGHT: |
| 81 | me.set_next_fill_colors() |
| 82 | elif direction == _DIRECTION_TOP: |
| 83 | me.set_prev_stroke_colors() |
| 84 | elif direction == _DIRECTION_BOTTOM: |
| 85 | me.set_next_stroke_colors() |
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) |
244 | | self._color_box.pack_start(self._color_picker, expand=False) |
245 | | self._color_picker.show() |
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 | | """ |
| 165 | self._color_prev_stroke = ColorPicker(self, self._xo_color, |
| 166 | _DIRECTION_TOP) |
| 167 | self._color_box.pack_start(self._color_prev_stroke, expand=False) |
| 168 | self._color_prev_stroke.show() |
| 169 | |
| 170 | self._current_color = ColorPicker(self, self._xo_color, |
| 171 | _DIRECTION_CENTER) |
| 172 | self._color_box.pack_start(self._current_color, expand=False) |
| 173 | self._current_color.show() |
| 174 | |
| 175 | self._color_next_stroke = ColorPicker(self, self._xo_color, |
| 176 | _DIRECTION_BOTTOM) |
| 177 | self._color_box.pack_start(self._color_next_stroke, expand=False) |
| 178 | self._color_next_stroke.show() |
| 179 | |
| 180 | self._color_next_fill = ColorPicker(self, self._xo_color, |
| 181 | _DIRECTION_RIGHT) |
| 182 | self._color_box.pack_start(self._color_next_fill, expand=False) |
| 183 | self._color_next_fill.show() |
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 | | |
| 200 | |
| 201 | def set_prev_fill_colors(self): |
| 202 | self._xo_color.set_color(self._xo_color.get_prev_fill_color()) |
| 203 | self._current_color.emit('color-changed', self._xo_color.to_string()) |
| 204 | self._current_color.icon.props.xo_color = self._xo_color |
| 205 | self._update_button_colors() |
| 206 | |
| 207 | def set_next_fill_colors(self): |
| 208 | self._xo_color.set_color(self._xo_color.get_next_fill_color()) |
| 209 | self._current_color.emit('color-changed', self._xo_color.to_string()) |
| 210 | self._current_color.icon.props.xo_color = self._xo_color |
| 211 | self._update_button_colors() |
| 212 | |
| 213 | def set_prev_stroke_colors(self): |
| 214 | self._xo_color.set_color(self._xo_color.get_prev_stroke_color()) |
| 215 | self._current_color.emit('color-changed', self._xo_color.to_string()) |
| 216 | self._current_color.icon.props.xo_color = self._xo_color |
| 217 | self._update_button_colors() |
| 218 | |
| 219 | def set_next_stroke_colors(self): |
| 220 | self._xo_color.set_color(self._xo_color.get_next_stroke_color()) |
| 221 | self._current_color.emit('color-changed', self._xo_color.to_string()) |
| 222 | self._current_color.icon.props.xo_color = self._xo_color |
| 223 | self._update_button_colors() |
| 224 | |
| 225 | def _update_button_colors(self): |
| 226 | next_fill_color = XoColor(self._xo_color.get_next_fill_color()) |
| 227 | self._color_next_fill.icon.props.xo_color = next_fill_color |
| 228 | prev_fill_color = XoColor(self._xo_color.get_prev_fill_color()) |
| 229 | self._color_prev_fill.icon.props.xo_color = prev_fill_color |
| 230 | next_stroke_color = XoColor(self._xo_color.get_next_stroke_color()) |
| 231 | self._color_next_stroke.icon.props.xo_color = next_stroke_color |
| 232 | prev_stroke_color = XoColor(self._xo_color.get_prev_stroke_color()) |
| 233 | self._color_prev_stroke.icon.props.xo_color = prev_stroke_color |
| 234 | |