CellRendererInvoker: various fixups
- the GtkCellRenderer (which our CellRenderer derives from) is not a
GtkWidget and therefor the 'get_display' method does not exist, we
fallback to the default display in that case [1]
- the get_rect method should return a Gdk.Rectangle now, see other
invokers
- check if event.mode is Gdk.CrossingMode.NORMAL to trigger a mouse
leave see 289787e8c6
for a similar
case
- todo: the Palette does not go away when the mouse leaves the
widget
[1] http://developer.gnome.org/gtk3/3.4/GtkCellRenderer.html
Signed-off-by: Simon Schampijer <simon@laptop.org>
Acked-by: Manuel Quiñones <manuq@laptop.org>
This commit is contained in:
parent
c6c2220f0d
commit
9b391fa3cf
@ -400,7 +400,10 @@ class MouseSpeedDetector(GObject.GObject):
|
|||||||
self._state = None
|
self._state = None
|
||||||
|
|
||||||
def _get_mouse_position(self):
|
def _get_mouse_position(self):
|
||||||
display = self.parent.get_display()
|
if hasattr(self.parent, 'get_display'):
|
||||||
|
display = self.parent.get_display()
|
||||||
|
else:
|
||||||
|
display = Gdk.Display.get_default()
|
||||||
manager = display.get_device_manager()
|
manager = display.get_device_manager()
|
||||||
pointer_device = manager.get_client_pointer()
|
pointer_device = manager.get_client_pointer()
|
||||||
screen, x, y = pointer_device.get_position()
|
screen, x, y = pointer_device.get_position()
|
||||||
@ -745,7 +748,10 @@ class Invoker(GObject.GObject):
|
|||||||
invoker_valign = alignment[3]
|
invoker_valign = alignment[3]
|
||||||
|
|
||||||
if self._cursor_x == -1 or self._cursor_y == -1:
|
if self._cursor_x == -1 or self._cursor_y == -1:
|
||||||
display = self.parent.get_display()
|
if hasattr(self.parent, 'get_display'):
|
||||||
|
display = self.parent.get_display()
|
||||||
|
else:
|
||||||
|
display = Gdk.Display.get_default()
|
||||||
manager = display.get_device_manager()
|
manager = display.get_device_manager()
|
||||||
pointer_device = manager.get_client_pointer()
|
pointer_device = manager.get_client_pointer()
|
||||||
screen, x, y = pointer_device.get_position()
|
screen, x, y = pointer_device.get_position()
|
||||||
@ -1167,7 +1173,7 @@ class CellRendererInvoker(Invoker):
|
|||||||
self._release_hid = tree_view.connect('button-release-event',
|
self._release_hid = tree_view.connect('button-release-event',
|
||||||
self.__button_release_event_cb)
|
self.__button_release_event_cb)
|
||||||
|
|
||||||
self.attach(cell_renderer)
|
Invoker.attach(self, cell_renderer)
|
||||||
|
|
||||||
def detach(self):
|
def detach(self):
|
||||||
Invoker.detach(self)
|
Invoker.detach(self)
|
||||||
@ -1186,13 +1192,14 @@ class CellRendererInvoker(Invoker):
|
|||||||
x = 0
|
x = 0
|
||||||
y = 0
|
y = 0
|
||||||
|
|
||||||
x += allocation.x
|
rect = Gdk.Rectangle()
|
||||||
y += allocation.y
|
rect.x = x + allocation.x
|
||||||
|
rect.y = y + allocation.y
|
||||||
|
|
||||||
width = allocation.width
|
rect.width = allocation.width
|
||||||
height = allocation.height
|
rect.height = allocation.height
|
||||||
|
|
||||||
return (x, y, width, height)
|
return rect
|
||||||
|
|
||||||
def __motion_notify_event_cb(self, widget, event):
|
def __motion_notify_event_cb(self, widget, event):
|
||||||
if event.window != widget.get_bin_window():
|
if event.window != widget.get_bin_window():
|
||||||
@ -1231,7 +1238,9 @@ class CellRendererInvoker(Invoker):
|
|||||||
self._tree_view.queue_draw_area(x, y, area.width, area.height)
|
self._tree_view.queue_draw_area(x, y, area.width, area.height)
|
||||||
|
|
||||||
def __leave_notify_event_cb(self, widget, event):
|
def __leave_notify_event_cb(self, widget, event):
|
||||||
self.notify_mouse_leave()
|
if event.mode == Gdk.CrossingMode.NORMAL:
|
||||||
|
self.notify_mouse_leave()
|
||||||
|
return False
|
||||||
|
|
||||||
def __button_release_event_cb(self, widget, event):
|
def __button_release_event_cb(self, widget, event):
|
||||||
if event.button == 1 and self._point_in_cell_renderer(event.x,
|
if event.button == 1 and self._point_in_cell_renderer(event.x,
|
||||||
|
Loading…
Reference in New Issue
Block a user