fix HTMLTextView tooltips
This commit is contained in:
parent
6b0edad24d
commit
1599dfdfbb
1 changed files with 11 additions and 2 deletions
|
@ -791,6 +791,16 @@ class HtmlTextView(gtk.TextView):
|
||||||
def show_tooltip(self, tag):
|
def show_tooltip(self, tag):
|
||||||
if not self.tooltip.win:
|
if not self.tooltip.win:
|
||||||
# check if the current pointer is still over the line
|
# check if the current pointer is still over the line
|
||||||
|
x, y, _ = self.window.get_pointer()
|
||||||
|
x, y = self.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, x, y)
|
||||||
|
tags = self.get_iter_at_location(x, y).get_tags()
|
||||||
|
is_over_anchor = False
|
||||||
|
for tag_ in tags:
|
||||||
|
if getattr(tag_, 'is_anchor', False):
|
||||||
|
is_over_anchor = True
|
||||||
|
break
|
||||||
|
if not is_over_anchor:
|
||||||
|
return
|
||||||
text = getattr(tag, 'title', False)
|
text = getattr(tag, 'title', False)
|
||||||
if text:
|
if text:
|
||||||
pointer = self.get_pointer()
|
pointer = self.get_pointer()
|
||||||
|
@ -814,8 +824,7 @@ class HtmlTextView(gtk.TextView):
|
||||||
window = widget.get_window(gtk.TEXT_WINDOW_TEXT)
|
window = widget.get_window(gtk.TEXT_WINDOW_TEXT)
|
||||||
window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
|
window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
|
||||||
self._changed_cursor = True
|
self._changed_cursor = True
|
||||||
gobject.timeout_add(500,
|
self.tooltip.timeout = gobject.timeout_add(500, self.show_tooltip, tag)
|
||||||
self.show_tooltip, tag)
|
|
||||||
elif self._changed_cursor and not is_over_anchor:
|
elif self._changed_cursor and not is_over_anchor:
|
||||||
window = widget.get_window(gtk.TEXT_WINDOW_TEXT)
|
window = widget.get_window(gtk.TEXT_WINDOW_TEXT)
|
||||||
window.set_cursor(gtk.gdk.Cursor(gtk.gdk.XTERM))
|
window.set_cursor(gtk.gdk.Cursor(gtk.gdk.XTERM))
|
||||||
|
|
Loading…
Add table
Reference in a new issue