From 192b4170118e006c97cb7e34a7cdd6edd265798f Mon Sep 17 00:00:00 2001
From: Simon Schampijer <simon@laptop.org>
Date: Thu, 15 Nov 2012 19:02:51 +0100
Subject: [PATCH] Use the new lockable Palette, SL #4008
This is based on the lockable Palette support
in the toolkit that landed in 6064fb30cc3cca24d2c68c588bcf3de5a047f584
Signed-off-by: Simon Schampijer <simon@laptop.org>
---
toolbox.py | 4 +---
widgets.py | 35 +++++++++++++++++++++++++----------
2 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/toolbox.py b/toolbox.py
index 9902629..4016ca7 100644
a
|
b
|
class ToolsToolbarBuilder(): |
256 | 256 | #self._stroke_color.set_icon_name('icon-stroke') |
257 | 257 | self._stroke_color.set_title(_('Brush properties')) |
258 | 258 | self._stroke_color.connect('notify::color', self._color_button_cb) |
259 | | item = Gtk.ToolItem() |
260 | | item.add(self._stroke_color) |
261 | | toolbar.insert(item, -1) |
| 259 | toolbar.insert(self._stroke_color, -1) |
262 | 260 | |
263 | 261 | separator = Gtk.SeparatorToolItem() |
264 | 262 | separator.set_draw(True) |
diff --git a/widgets.py b/widgets.py
index 46c8db2..b276ed3 100644
a
|
b
|
class BrushButton(_ColorButton): |
47 | 47 | GObject.GObject.__init__(self, **kwargs) |
48 | 48 | self._preview.set_events(Gdk.EventMask.BUTTON_PRESS_MASK) |
49 | 49 | |
50 | | self._preview.connect('button_press_event', self.__mouse_down_cb) |
51 | 50 | self._preview.connect("draw", self.draw) |
52 | 51 | self.set_image(self._preview) |
53 | 52 | |
… |
… |
class BrushButton(_ColorButton): |
167 | 166 | def get_icon_size(self): |
168 | 167 | pass |
169 | 168 | |
170 | | def __mouse_down_cb(self, event): |
171 | | if self._palette: |
172 | | if not self._palette.is_up(): |
173 | | self._palette.popup(immediate=True, |
174 | | state=self._palette.SECONDARY) |
175 | | else: |
176 | | self._palette.popdown(immediate=True) |
177 | | return True |
178 | | |
179 | 169 | |
180 | 170 | class ButtonStrokeColor(Gtk.ToolItem): |
181 | 171 | """Class to manage the Stroke Color of a Button""" |
… |
… |
class ButtonStrokeColor(Gtk.ToolItem): |
206 | 196 | self.color_button.set_relief(Gtk.ReliefStyle.NONE) |
207 | 197 | |
208 | 198 | self._palette_invoker.attach_tool(self) |
| 199 | self._palette_invoker.props.toggle_palette = True |
| 200 | self._palette_invoker.props.lock_palette = True |
209 | 201 | |
210 | 202 | # This widget just proxies the following properties to the colorbutton |
211 | 203 | self.color_button.connect('notify::color', self.__notify_change) |
… |
… |
class ButtonStrokeColor(Gtk.ToolItem): |
381 | 373 | palette_invoker = GObject.property( |
382 | 374 | type=object, setter=set_palette_invoker, getter=get_palette_invoker) |
383 | 375 | |
| 376 | def set_expanded(self, expanded): |
| 377 | box = self.toolbar_box |
| 378 | if not box: |
| 379 | return |
| 380 | |
| 381 | if not expanded: |
| 382 | self._palette_invoker.notify_popdown() |
| 383 | return |
| 384 | |
| 385 | if box.expanded_button is not None: |
| 386 | box.expanded_button.queue_draw() |
| 387 | if box.expanded_button != self: |
| 388 | box.expanded_button.set_expanded(False) |
| 389 | box.expanded_button = self |
| 390 | |
| 391 | def get_toolbar_box(self): |
| 392 | parent = self.get_parent() |
| 393 | if not hasattr(parent, 'owner'): |
| 394 | return None |
| 395 | return parent.owner |
| 396 | |
| 397 | toolbar_box = property(get_toolbar_box) |
| 398 | |
384 | 399 | def set_color(self, color): |
385 | 400 | self.color_button.set_color(color) |
386 | 401 | |