From 3fc81ae94530fb19f1519da983605e33ca2b4cb1 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 15 Sep 2006 01:01:26 +0200 Subject: [PATCH] Add a popup shell which ensure only one popup is active at the same time. --- shell/FriendIcon.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/shell/FriendIcon.py b/shell/FriendIcon.py index 94de02dc..36e702c5 100644 --- a/shell/FriendIcon.py +++ b/shell/FriendIcon.py @@ -2,7 +2,18 @@ from sugar.canvas.IconItem import IconItem from FriendPopup import FriendPopup from sugar.canvas.Grid import Grid +class _PopupShell: + def __init__(self): + self._popup_controller = None + + def set_active(self, controller): + if self._popup_controller: + self._popup_controller._popdown() + self._popup_controller = controller + class FriendIcon(IconItem): + _popup_shell = _PopupShell() + def __init__(self, shell, friend): IconItem.__init__(self, icon_name='stock-buddy', color=friend.get_color(), size=96) @@ -31,9 +42,10 @@ class FriendIcon(IconItem): def _popup_cb(self, icon, x1, y1, x2, y2): self._popdown() + FriendIcon._popup_shell.set_active(None) + grid = Grid() self._popup = FriendPopup(self._shell, grid, icon.get_friend()) - self._popup.connect('enter-notify-event', self._popup_enter_notify_event_cb) self._popup.connect('leave-notify-event', @@ -61,6 +73,8 @@ class FriendIcon(IconItem): self._popup.show() + FriendIcon._popup_shell.set_active(self) + def _popdown_cb(self, friend): if not self._hover_popup: self._popdown()