Ticket #4173: 0001-Lockable-Palettes-add-support-to-draw-the-arrow-at-t.patch

File 0001-Lockable-Palettes-add-support-to-draw-the-arrow-at-t.patch, 3.0 KB (added by erikos, 11 years ago)

Lockable Palettes: add support to draw the arrow at the bottom/top of the icon

  • src/sugar3/graphics/palettewindow.py

    From a84cc432d1870dcfd1fed2076f8454e486508daf Mon Sep 17 00:00:00 2001
    From: Simon Schampijer <simon@laptop.org>
    Date: Sat, 24 Nov 2012 11:28:50 +0100
    Subject: [PATCH toolkit-gtk3] Lockable Palettes: add support to draw the
     arrow at the bottom/top of the icon, part of
     SL #4173
    
    This allows to set a property to draw the arrow bottom/top
    of the icon. It defaults to bottom.
    ---
     src/sugar3/graphics/palettewindow.py | 32 ++++++++++++++++++++++++++++----
     1 file changed, 28 insertions(+), 4 deletions(-)
    
    diff --git a/src/sugar3/graphics/palettewindow.py b/src/sugar3/graphics/palettewindow.py
    index 7063681..cc01e34 100644
    a b class Invoker(GObject.GObject): 
    764764    TOP = [(0.0, -1.0, 0.0, 0.0), (-1.0, -1.0, 1.0, 0.0)]
    765765    LEFT = [(-1.0, 0.0, 0.0, 0.0), (-1.0, -1.0, 0.0, 1.0)]
    766766
     767    LOCK_ARROW_BOTTOM = 0
     768    LOCK_ARROW_TOP = 1
     769
    767770    def __init__(self):
    768771        GObject.GObject.__init__(self)
    769772
    class Invoker(GObject.GObject): 
    780783        self._cache_palette = True
    781784        self._toggle_palette = False
    782785        self._lock_palette = False
     786        self._lock_arrow_position = self.LOCK_ARROW_BOTTOM
    783787        self.locked = False
    784788
    785789    def attach(self, parent):
    class Invoker(GObject.GObject): 
    10311035    ignore mouse events. Defaults to False.
    10321036    """
    10331037
     1038    def get_lock_arrow_position(self):
     1039        return self._lock_arrow_position
     1040
     1041    def set_lock_arrow_position(self, position):
     1042        self._lock_arrow_position = position
     1043
     1044    lock_arrow_position = GObject.property(type=object,
     1045                                           setter=set_lock_arrow_position,
     1046                                           getter=get_lock_arrow_position)
     1047    """Set the position of the arrow that is drawn for a
     1048    locked Palette. Defaults to the bottom position.
     1049    """
     1050
    10341051    def __palette_popdown_cb(self, palette):
    10351052        if not self.props.cache_palette:
    10361053            self.set_palette(None)
    class WidgetInvoker(Invoker): 
    11981215            return False
    11991216        alloc = widget.get_allocation()
    12001217        arrow_size = style.TOOLBAR_ARROW_SIZE / 2
    1201         y = alloc.height - arrow_size
     1218        if self.props.lock_arrow_position == self.LOCK_ARROW_BOTTOM:
     1219            y = alloc.height - arrow_size
     1220        else:
     1221            y = alloc.y
    12021222        x = (alloc.width - arrow_size) / 2
    12031223        context = widget.get_style_context()
    12041224        context.add_class('toolitem')
    1205         if self.locked:
    1206             Gtk.render_arrow(context, cr, 0, x, y, arrow_size)
    1207         else:
     1225        if (not self.locked and
     1226            self.props.lock_arrow_position == self.LOCK_ARROW_BOTTOM) \
     1227            or \
     1228            (self.locked and
     1229             self.props.lock_arrow_position == self.LOCK_ARROW_TOP):
    12081230            Gtk.render_arrow(context, cr, math.pi, x, y, arrow_size)
     1231        else:
     1232            Gtk.render_arrow(context, cr, 0, x, y, arrow_size)
    12091233
    12101234
    12111235class CursorInvoker(Invoker):