Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/widgets.py
diff options
context:
space:
mode:
authorSimon Schampijer <simon@laptop.org>2012-11-15 18:02:51 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-11-23 12:36:09 (GMT)
commit6f78b8104b3a9846e6c1e9171e2a0be8de4aca8b (patch)
treeda319a0a39a671cd7831a7dc784dd5baff41fe1c /widgets.py
parentbbede53e28653119a8269c6d1e61cf1cf66f4a9e (diff)
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>
Diffstat (limited to 'widgets.py')
-rw-r--r--widgets.py35
1 files changed, 25 insertions, 10 deletions
diff --git a/widgets.py b/widgets.py
index b98a21e..9f996fa 100644
--- a/widgets.py
+++ b/widgets.py
@@ -47,7 +47,6 @@ class BrushButton(_ColorButton):
GObject.GObject.__init__(self, **kwargs)
self._preview.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
- self._preview.connect('button_press_event', self.__mouse_down_cb)
self._preview.connect("draw", self.draw)
self.set_image(self._preview)
@@ -167,15 +166,6 @@ class BrushButton(_ColorButton):
def get_icon_size(self):
pass
- def __mouse_down_cb(self, event):
- if self._palette:
- if not self._palette.is_up():
- self._palette.popup(immediate=True,
- state=self._palette.SECONDARY)
- else:
- self._palette.popdown(immediate=True)
- return True
-
class ButtonStrokeColor(Gtk.ToolItem):
"""Class to manage the Stroke Color of a Button"""
@@ -206,6 +196,8 @@ class ButtonStrokeColor(Gtk.ToolItem):
self.color_button.set_relief(Gtk.ReliefStyle.NONE)
self._palette_invoker.attach_tool(self)
+ self._palette_invoker.props.toggle_palette = True
+ self._palette_invoker.props.lock_palette = True
# This widget just proxies the following properties to the colorbutton
self.color_button.connect('notify::color', self.__notify_change)
@@ -376,6 +368,29 @@ class ButtonStrokeColor(Gtk.ToolItem):
palette_invoker = GObject.property(
type=object, setter=set_palette_invoker, getter=get_palette_invoker)
+ def set_expanded(self, expanded):
+ box = self.toolbar_box
+ if not box:
+ return
+
+ if not expanded:
+ self._palette_invoker.notify_popdown()
+ return
+
+ if box.expanded_button is not None:
+ box.expanded_button.queue_draw()
+ if box.expanded_button != self:
+ box.expanded_button.set_expanded(False)
+ box.expanded_button = self
+
+ def get_toolbar_box(self):
+ parent = self.get_parent()
+ if not hasattr(parent, 'owner'):
+ return None
+ return parent.owner
+
+ toolbar_box = property(get_toolbar_box)
+
def set_color(self, color):
self.color_button.set_color(color)