fix gobject warning when hidding tooltips
This commit is contained in:
parent
ffaa6efbc7
commit
cc8e49b212
6 changed files with 27 additions and 13 deletions
|
@ -616,6 +616,7 @@ class ConversationTextview(GObject.GObject):
|
|||
GLib.idle_add(self.scroll_to_end)
|
||||
|
||||
def show_xep0184_warning_tooltip(self):
|
||||
self.xep0184_warning_tooltip.timeout = 0
|
||||
w = self.tv.get_window(Gtk.TextWindowType.TEXT)
|
||||
device = w.get_display().get_device_manager().get_client_pointer()
|
||||
pointer = w.get_device_position(device)
|
||||
|
@ -637,6 +638,7 @@ class ConversationTextview(GObject.GObject):
|
|||
'message got lost.'), 8, position[1] + y)
|
||||
|
||||
def show_line_tooltip(self):
|
||||
self.line_tooltip.timeout = 0
|
||||
w = self.tv.get_window(Gtk.TextWindowType.TEXT)
|
||||
device = w.get_display().get_device_manager().get_client_pointer()
|
||||
pointer = w.get_device_position(device)
|
||||
|
@ -711,11 +713,12 @@ class ConversationTextview(GObject.GObject):
|
|||
elif tag == tag_table.lookup('xep0184-warning'):
|
||||
xep0184_warning = True
|
||||
|
||||
if self.line_tooltip.timeout != 0:
|
||||
if self.line_tooltip.timeout != 0 or self.line_tooltip.shown:
|
||||
# Check if we should hide the line tooltip
|
||||
if not over_line:
|
||||
self.line_tooltip.hide_tooltip()
|
||||
if self.xep0184_warning_tooltip.timeout != 0:
|
||||
if self.xep0184_warning_tooltip.timeout != 0 or \
|
||||
self.xep0184_warning_tooltip.shown:
|
||||
# Check if we should hide the XEP-184 warning tooltip
|
||||
if not xep0184_warning:
|
||||
self.xep0184_warning_tooltip.hide_tooltip()
|
||||
|
|
|
@ -1294,6 +1294,7 @@ class ToplevelAgentBrowser(AgentBrowser):
|
|||
return 0
|
||||
|
||||
def _show_tooltip(self, state):
|
||||
self.tooltip.timeout = 0
|
||||
view = self.window.services_treeview
|
||||
w = view.get_window()
|
||||
device = w.get_display().get_device_manager().get_client_pointer()
|
||||
|
@ -1313,13 +1314,13 @@ class ToplevelAgentBrowser(AgentBrowser):
|
|||
# These are all callbacks to make tooltips work
|
||||
def on_treeview_leave_notify_event(self, widget, event):
|
||||
props = widget.get_path_at_pos(int(event.x), int(event.y))
|
||||
if self.tooltip.timeout > 0:
|
||||
if self.tooltip.timeout > 0 or self.tooltip.shown:
|
||||
if not props or self.tooltip.id == props[0]:
|
||||
self.tooltip.hide_tooltip()
|
||||
|
||||
def on_treeview_motion_notify_event(self, widget, event):
|
||||
props = widget.get_path_at_pos(int(event.x), int(event.y))
|
||||
if self.tooltip.timeout > 0:
|
||||
if self.tooltip.timeout > 0 or self.tooltip.shown:
|
||||
if not props or self.tooltip.id != props[0]:
|
||||
self.tooltip.hide_tooltip()
|
||||
if props:
|
||||
|
|
|
@ -2690,7 +2690,7 @@ class GroupchatControl(ChatControlBase):
|
|||
|
||||
def on_list_treeview_motion_notify_event(self, widget, event):
|
||||
props = widget.get_path_at_pos(int(event.x), int(event.y))
|
||||
if self.tooltip.timeout > 0:
|
||||
if self.tooltip.timeout > 0 or self.tooltip.shown:
|
||||
if not props or self.tooltip.id != props[0]:
|
||||
self.tooltip.hide_tooltip()
|
||||
if props:
|
||||
|
@ -2719,6 +2719,7 @@ class GroupchatControl(ChatControlBase):
|
|||
self.tooltip.hide_tooltip()
|
||||
|
||||
def show_tooltip(self, contact):
|
||||
self.tooltip.timeout = 0
|
||||
if not self.list_treeview.get_window():
|
||||
# control has been destroyed since tooltip was requested
|
||||
return
|
||||
|
|
|
@ -877,7 +877,7 @@ class HtmlTextView(Gtk.TextView):
|
|||
self.tagSthAtSth.connect('event', self.hyperlink_handler, 'sth_at_sth')
|
||||
|
||||
def __destroy_event(self, widget):
|
||||
if self.tooltip.timeout != 0:
|
||||
if self.tooltip.timeout != 0 or self.tooltip.shown:
|
||||
self.tooltip.hide_tooltip()
|
||||
|
||||
def __leave_event(self, widget, event):
|
||||
|
@ -887,6 +887,7 @@ class HtmlTextView(Gtk.TextView):
|
|||
self._changed_cursor = False
|
||||
|
||||
def show_tooltip(self, tag):
|
||||
self.tooltip.timeout = 0
|
||||
if not self.tooltip.win:
|
||||
# check if the current pointer is still over the line
|
||||
w = self.get_window(Gtk.TextWindowType.TEXT)
|
||||
|
@ -915,7 +916,7 @@ class HtmlTextView(Gtk.TextView):
|
|||
y = pointer[2]
|
||||
tags = widget.get_iter_at_location(x, y).get_tags()
|
||||
anchor_tags = [tag for tag in tags if getattr(tag, 'is_anchor', False)]
|
||||
if self.tooltip.timeout != 0:
|
||||
if self.tooltip.timeout != 0 or self.tooltip.shown:
|
||||
# Check if we should hide the line tooltip
|
||||
if not anchor_tags:
|
||||
self.tooltip.hide_tooltip()
|
||||
|
|
|
@ -2051,6 +2051,7 @@ class RosterWindow:
|
|||
vb.set_no_show_all(True)
|
||||
|
||||
def show_tooltip(self, contact):
|
||||
self.tooltip.timeout = 0
|
||||
device = self.tree.get_window().get_display().get_device_manager().\
|
||||
get_client_pointer()
|
||||
pointer = self.tree.get_window().get_device_position(device)
|
||||
|
@ -2068,7 +2069,6 @@ class RosterWindow:
|
|||
else:
|
||||
self.tooltip.hide_tooltip()
|
||||
|
||||
|
||||
def authorize(self, widget, jid, account):
|
||||
"""
|
||||
Authorize a contact (by re-sending auth menuitem)
|
||||
|
@ -2865,14 +2865,14 @@ class RosterWindow:
|
|||
|
||||
def on_roster_treeview_leave_notify_event(self, widget, event):
|
||||
props = widget.get_path_at_pos(int(event.x), int(event.y))
|
||||
if self.tooltip.timeout > 0:
|
||||
if self.tooltip.timeout > 0 or self.tooltip.shown:
|
||||
if not props or self.tooltip.id == props[0]:
|
||||
self.tooltip.hide_tooltip()
|
||||
|
||||
def on_roster_treeview_motion_notify_event(self, widget, event):
|
||||
model = widget.get_model()
|
||||
props = widget.get_path_at_pos(int(event.x), int(event.y))
|
||||
if self.tooltip.timeout > 0:
|
||||
if self.tooltip.timeout > 0 or self.tooltip.shown:
|
||||
if not props or self.tooltip.id != props[0]:
|
||||
self.tooltip.hide_tooltip()
|
||||
if props:
|
||||
|
@ -2885,7 +2885,8 @@ class RosterWindow:
|
|||
return
|
||||
if model[titer][C_TYPE] in ('contact', 'self_contact'):
|
||||
# we're on a contact entry in the roster
|
||||
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
|
||||
if (not self.tooltip.shown and self.tooltip.timeout == 0) or \
|
||||
self.tooltip.id != props[0]:
|
||||
account = model[titer][C_ACCOUNT]
|
||||
jid = model[titer][C_JID]
|
||||
self.tooltip.id = row
|
||||
|
@ -2901,7 +2902,8 @@ class RosterWindow:
|
|||
self.tooltip.timeout = GLib.timeout_add(500,
|
||||
self.show_tooltip, connected_contacts)
|
||||
elif model[titer][C_TYPE] == 'groupchat':
|
||||
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
|
||||
if (not self.tooltip.shown and self.tooltip.timeout == 0) or \
|
||||
self.tooltip.id != props[0]:
|
||||
account = model[titer][C_ACCOUNT]
|
||||
jid = model[titer][C_JID]
|
||||
self.tooltip.id = row
|
||||
|
@ -2911,7 +2913,8 @@ class RosterWindow:
|
|||
self.show_tooltip, contact)
|
||||
elif model[titer][C_TYPE] == 'account':
|
||||
# we're on an account entry in the roster
|
||||
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
|
||||
if (not self.tooltip.shown and self.tooltip.timeout == 0) or \
|
||||
self.tooltip.id != props[0]:
|
||||
account = model[titer][C_ACCOUNT]
|
||||
if account == 'all':
|
||||
self.tooltip.id = row
|
||||
|
|
|
@ -72,6 +72,7 @@ class BaseTooltip:
|
|||
self.id = None
|
||||
self.cur_data = None
|
||||
self.check_last_time = None
|
||||
self.shown = False
|
||||
|
||||
def populate(self, data):
|
||||
"""
|
||||
|
@ -148,6 +149,8 @@ class BaseTooltip:
|
|||
widget_height is the height of the widget on which we show the tooltip.
|
||||
widget_y_position is vertical position of the widget on the screen.
|
||||
"""
|
||||
if self.shown:
|
||||
return
|
||||
self.cur_data = data
|
||||
# set tooltip contents
|
||||
self.populate(data)
|
||||
|
@ -163,6 +166,7 @@ class BaseTooltip:
|
|||
self.preferred_position = [pointer_x, preferred_y]
|
||||
self.widget_height = widget_height
|
||||
self.win.show_all()
|
||||
self.shown = True
|
||||
|
||||
def hide_tooltip(self):
|
||||
if self.timeout > 0:
|
||||
|
@ -174,6 +178,7 @@ class BaseTooltip:
|
|||
self.id = None
|
||||
self.cur_data = None
|
||||
self.check_last_time = None
|
||||
self.shown = False
|
||||
|
||||
@staticmethod
|
||||
def colorize_status(status):
|
||||
|
|
Loading…
Add table
Reference in a new issue