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): |
764 | 764 | TOP = [(0.0, -1.0, 0.0, 0.0), (-1.0, -1.0, 1.0, 0.0)] |
765 | 765 | LEFT = [(-1.0, 0.0, 0.0, 0.0), (-1.0, -1.0, 0.0, 1.0)] |
766 | 766 | |
| 767 | LOCK_ARROW_BOTTOM = 0 |
| 768 | LOCK_ARROW_TOP = 1 |
| 769 | |
767 | 770 | def __init__(self): |
768 | 771 | GObject.GObject.__init__(self) |
769 | 772 | |
… |
… |
class Invoker(GObject.GObject): |
780 | 783 | self._cache_palette = True |
781 | 784 | self._toggle_palette = False |
782 | 785 | self._lock_palette = False |
| 786 | self._lock_arrow_position = self.LOCK_ARROW_BOTTOM |
783 | 787 | self.locked = False |
784 | 788 | |
785 | 789 | def attach(self, parent): |
… |
… |
class Invoker(GObject.GObject): |
1031 | 1035 | ignore mouse events. Defaults to False. |
1032 | 1036 | """ |
1033 | 1037 | |
| 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 | |
1034 | 1051 | def __palette_popdown_cb(self, palette): |
1035 | 1052 | if not self.props.cache_palette: |
1036 | 1053 | self.set_palette(None) |
… |
… |
class WidgetInvoker(Invoker): |
1198 | 1215 | return False |
1199 | 1216 | alloc = widget.get_allocation() |
1200 | 1217 | 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 |
1202 | 1222 | x = (alloc.width - arrow_size) / 2 |
1203 | 1223 | context = widget.get_style_context() |
1204 | 1224 | 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): |
1208 | 1230 | Gtk.render_arrow(context, cr, math.pi, x, y, arrow_size) |
| 1231 | else: |
| 1232 | Gtk.render_arrow(context, cr, 0, x, y, arrow_size) |
1209 | 1233 | |
1210 | 1234 | |
1211 | 1235 | class CursorInvoker(Invoker): |