From ed5e9d072b98caec8cb02d86bb90ff9cb0e4b06e Mon Sep 17 00:00:00 2001 From: Sam Parkinson Date: Sun, 8 May 2016 21:49:46 +1000 Subject: [PATCH] Fix palette damage for tool buttons, fixes #4960 Currently, the ToolInvoker code passes the button child in such a way that the WidgetInvoker queues only the child's draw. In previous Gtk+ versions, this magically resulted in redrawing the parent as well. However, Gtk+ 3.20 is probably trying to save power and not randomly redraw widgets. To fix this, we must queue the redraw of the widget that we want to redraw explicitly. --- src/sugar3/graphics/palettewindow.py | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/sugar3/graphics/palettewindow.py b/src/sugar3/graphics/palettewindow.py index b2cafd87..3889cf0f 100644 --- a/src/sugar3/graphics/palettewindow.py +++ b/src/sugar3/graphics/palettewindow.py @@ -1388,14 +1388,36 @@ class CursorInvoker(Invoker): class ToolInvoker(WidgetInvoker): + ''' + A palette invoker for toolbar buttons and other items. This invoker + will properly align the palette so that is perpendicular to the toolbar + (a horizontal toolbar will spawn a palette going downwards). It also + draws the highlights specific to a toolitem. + + For :class:`sugar3.graphics.toolbutton.ToolButton` and subclasses, you + should not use the toolinvoker directly. Instead, just subclass the + tool button and override the `create_palette` function. + + Args: + parent (Gtk.Widget): toolitem to connect invoker to + ''' def __init__(self, parent=None): WidgetInvoker.__init__(self) + self._tool = None if parent: self.attach_tool(parent) def attach_tool(self, widget): + ''' + Attach a toolitem to the invoker. Same behaviour as passing the + `parent` argument to the constructor. + + Args: + widget (Gtk.Widget): toolitem to connect invoker to + ''' + self._tool = widget self.attach_widget(widget, widget.get_child()) def _get_alignments(self): @@ -1411,6 +1433,14 @@ class ToolInvoker(WidgetInvoker): def primary_text_clicked(self): self._widget.emit('clicked') + def notify_popup(self): + WidgetInvoker.notify_popup(self) + self._tool.queue_draw() + + def notify_popdown(self): + WidgetInvoker.notify_popdown(self) + self._tool.queue_draw() + class TreeViewInvoker(Invoker): def __init__(self):