From f69ade130cbb8fbf046468054acfa7c03c9193e4 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sat, 15 Aug 2015 22:16:45 +0200 Subject: [PATCH] place roster tooltips correctly. --- src/roster_window.py | 2 +- src/tooltips.py | 54 +++++++++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/roster_window.py b/src/roster_window.py index ce9beaade..a289874f6 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -4114,7 +4114,7 @@ class RosterWindow: self.tree.expand_row(path, False) return if self.rfilter_enabled: - Gobject.idle_add(self.disable_rfilter) + GObject.idle_add(self.disable_rfilter) jid = model[path][C_JID] resource = None contact = gajim.contacts.get_contact_with_highest_priority(account, jid) diff --git a/src/tooltips.py b/src/tooltips.py index 9647ac7dd..c0bbe1f58 100644 --- a/src/tooltips.py +++ b/src/tooltips.py @@ -73,6 +73,7 @@ class BaseTooltip: self.cur_data = None self.check_last_time = None self.shown = False + self.position_computed = False def populate(self, data): """ @@ -115,30 +116,36 @@ class BaseTooltip: self.hide_tooltip() def on_size_allocate(self, widget, rect): - half_width = rect.width / 2 + 1 - if self.preferred_position[1] + rect.height > self.screen.get_height(): - # flip tooltip up - self.preferred_position[1] -= rect.height + self.widget_height + 8 - if self.preferred_position[1] < 0: - self.preferred_position[1] = self.screen.get_height() - \ - rect.height - 2 + if not self.position_computed: + half_width = rect.width / 2 + 1 + if self.preferred_position[1] + rect.height > \ + self.screen.get_height(): + # flip tooltip up + self.preferred_position[1] -= rect.height + self.widget_height \ + + 8 + if self.preferred_position[1] < 0: + self.preferred_position[1] = self.screen.get_height() - \ + rect.height - 2 - if self.preferred_position[0] + rect.width + 7 < \ - self.screen.get_width(): - self.preferred_position[0] = self.preferred_position[0] + 7 - else: - self.preferred_position[0] = self.preferred_position[0] - \ - rect.width - 7 - self.win.move(self.preferred_position[0], - self.preferred_position[1]) - return - if self.preferred_position[0] < half_width: - self.preferred_position[0] = 0 - elif self.preferred_position[0] + rect.width > \ - self.screen.get_width() + half_width: - self.preferred_position[0] = self.screen.get_width() - rect.width - elif not self.check_last_time: - self.preferred_position[0] -= half_width + if self.preferred_position[0] + rect.width + 7 < \ + self.screen.get_width(): + self.preferred_position[0] = self.preferred_position[0]\ + + 7 + else: + self.preferred_position[0] = self.preferred_position[0]\ + - rect.width - 7 + self.win.move(self.preferred_position[0], + self.preferred_position[1]) + return + if self.preferred_position[0] < half_width: + self.preferred_position[0] = 0 + elif self.preferred_position[0] + rect.width > \ + self.screen.get_width() + half_width: + self.preferred_position[0] = self.screen.get_width() - \ + rect.width + elif not self.check_last_time: + self.preferred_position[0] -= half_width + self.position_computed = True self.win.move(self.preferred_position[0], self.preferred_position[1]) def show_tooltip(self, data, widget_height, widget_y_position): @@ -151,6 +158,7 @@ class BaseTooltip: """ if self.shown: return + self.position_computed = False self.cur_data = data # set tooltip contents self.populate(data)