Ticket #4008: 0001-Use-the-new-lockable-Palette-SL-4008.patch

File 0001-Use-the-new-lockable-Palette-SL-4008.patch, 3.3 KB (added by erikos, 11 years ago)

Updated Paint patch

  • toolbox.py

    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(): 
    256256        #self._stroke_color.set_icon_name('icon-stroke')
    257257        self._stroke_color.set_title(_('Brush properties'))
    258258        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)
    262260
    263261        separator = Gtk.SeparatorToolItem()
    264262        separator.set_draw(True)
  • widgets.py

    diff --git a/widgets.py b/widgets.py
    index 46c8db2..b276ed3 100644
    a b class BrushButton(_ColorButton): 
    4747        GObject.GObject.__init__(self, **kwargs)
    4848        self._preview.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
    4949
    50         self._preview.connect('button_press_event', self.__mouse_down_cb)
    5150        self._preview.connect("draw", self.draw)
    5251        self.set_image(self._preview)
    5352
    class BrushButton(_ColorButton): 
    167166    def get_icon_size(self):
    168167        pass
    169168
    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 
    179169
    180170class ButtonStrokeColor(Gtk.ToolItem):
    181171    """Class to manage the Stroke Color of a Button"""
    class ButtonStrokeColor(Gtk.ToolItem): 
    206196        self.color_button.set_relief(Gtk.ReliefStyle.NONE)
    207197
    208198        self._palette_invoker.attach_tool(self)
     199        self._palette_invoker.props.toggle_palette = True
     200        self._palette_invoker.props.lock_palette = True
    209201
    210202        # This widget just proxies the following properties to the colorbutton
    211203        self.color_button.connect('notify::color', self.__notify_change)
    class ButtonStrokeColor(Gtk.ToolItem): 
    381373    palette_invoker = GObject.property(
    382374        type=object, setter=set_palette_invoker, getter=get_palette_invoker)
    383375
     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
    384399    def set_color(self, color):
    385400        self.color_button.set_color(color)
    386401