Let the invoker deal with popup/popdown redraw.
This commit is contained in:
parent
43fb1627a7
commit
4f1986e8a4
@ -398,6 +398,9 @@ class Palette(gtk.Window):
|
||||
self.menu.set_active(True)
|
||||
self.show()
|
||||
|
||||
if self._invoker:
|
||||
self._invoker.notify_popup()
|
||||
|
||||
self._up = True
|
||||
_palette_observer.emit('popup', self)
|
||||
self.emit('popup')
|
||||
@ -406,9 +409,13 @@ class Palette(gtk.Window):
|
||||
if not self._palette_popup_sid is None:
|
||||
_palette_observer.disconnect(self._palette_popup_sid)
|
||||
self._palette_popup_sid = None
|
||||
|
||||
self.menu.set_active(False)
|
||||
self.hide()
|
||||
|
||||
if self._invoker:
|
||||
self._invoker.notify_popdown()
|
||||
|
||||
self._up = False
|
||||
self.emit('popdown')
|
||||
|
||||
@ -543,6 +550,12 @@ class Invoker(gobject.GObject):
|
||||
height = gtk.gdk.screen_height()
|
||||
return gtk.gdk.Rectangle(0, 0, width, height)
|
||||
|
||||
def notify_popup(self):
|
||||
pass
|
||||
|
||||
def notify_popdown(self):
|
||||
pass
|
||||
|
||||
class WidgetInvoker(Invoker):
|
||||
def __init__(self, widget):
|
||||
Invoker.__init__(self)
|
||||
@ -602,6 +615,12 @@ class WidgetInvoker(Invoker):
|
||||
def get_toplevel(self):
|
||||
return self._widget.get_toplevel()
|
||||
|
||||
def notify_popup(self):
|
||||
self._widget.queue_draw()
|
||||
|
||||
def notify_popdown(self):
|
||||
self._widget.queue_draw()
|
||||
|
||||
class CanvasInvoker(Invoker):
|
||||
def __init__(self, item):
|
||||
Invoker.__init__(self)
|
||||
|
@ -41,9 +41,6 @@ class RadioToolButton(gtk.RadioToolButton):
|
||||
self._palette = palette
|
||||
self._palette.props.invoker = WidgetInvoker(self.child)
|
||||
self._palette.props.draw_gap = True
|
||||
|
||||
self._palette.connect("popup", self._palette_changed)
|
||||
self._palette.connect("popdown", self._palette_changed)
|
||||
|
||||
def set_tooltip(self, text):
|
||||
self._palette = Palette(text)
|
||||
@ -57,8 +54,4 @@ class RadioToolButton(gtk.RadioToolButton):
|
||||
|
||||
gtk.RadioToolButton.do_expose_event(self, event)
|
||||
|
||||
def _palette_changed(self, palette):
|
||||
# Force a redraw to update the invoker rectangle
|
||||
self.queue_draw()
|
||||
|
||||
palette = property(get_palette, set_palette)
|
||||
|
@ -40,9 +40,6 @@ class ToggleToolButton(gtk.ToggleToolButton):
|
||||
self._palette = palette
|
||||
self._palette.props.invoker = WidgetInvoker(self.child)
|
||||
self._palette.props.draw_gap = True
|
||||
|
||||
self._palette.connect("popup", self._palette_changed)
|
||||
self._palette.connect("popdown", self._palette_changed)
|
||||
|
||||
def set_tooltip(self, text):
|
||||
self._palette = Palette(text)
|
||||
@ -56,8 +53,4 @@ class ToggleToolButton(gtk.ToggleToolButton):
|
||||
|
||||
gtk.ToggleToolButton.do_expose_event(self, event)
|
||||
|
||||
def _palette_changed(self, palette):
|
||||
# Force a redraw to update the invoker rectangle
|
||||
self.queue_draw()
|
||||
|
||||
palette = property(get_palette, set_palette)
|
||||
|
@ -43,9 +43,6 @@ class ToolButton(gtk.ToolButton):
|
||||
self._palette = palette
|
||||
self._palette.props.invoker = WidgetInvoker(self.child)
|
||||
self._palette.props.draw_gap = True
|
||||
|
||||
self._palette.connect("popup", self._palette_changed)
|
||||
self._palette.connect("popdown", self._palette_changed)
|
||||
|
||||
def set_tooltip(self, text):
|
||||
self.set_palette(Palette(text))
|
||||
@ -62,8 +59,4 @@ class ToolButton(gtk.ToolButton):
|
||||
if self._palette:
|
||||
self._palette.popdown(True)
|
||||
|
||||
def _palette_changed(self, palette):
|
||||
# Force a redraw to update the invoker rectangle
|
||||
self.queue_draw()
|
||||
|
||||
palette = property(get_palette, set_palette)
|
||||
|
Loading…
Reference in New Issue
Block a user