From 956b663409ae61234f1e73641d0b2eaddf1d0a57 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Sat, 16 Sep 2006 11:00:46 +0200 Subject: [PATCH] Do not show invite if there is no active activity --- shell/view/BuddyPopup.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/shell/view/BuddyPopup.py b/shell/view/BuddyPopup.py index 018e7fa8..5f5e1ba2 100644 --- a/shell/view/BuddyPopup.py +++ b/shell/view/BuddyPopup.py @@ -5,6 +5,7 @@ import gobject from sugar.canvas.CanvasView import CanvasView from sugar.canvas.CanvasBox import CanvasBox from sugar.canvas.IconItem import IconItem +from sugar.presence import PresenceService class BuddyPopup(gtk.Window): ACTION_MAKE_FRIEND = 0 @@ -58,6 +59,9 @@ class BuddyPopup(gtk.Window): canvas.set_model(model) def _add_actions(self, grid, root): + shell_model = self._shell.get_model() + pservice = PresenceService.get_instance() + separator = goocanvas.Path(data='M 15 0 L 185 0', line_width=3, fill_color='black') grid.set_constraints(separator, 0, 4) @@ -66,7 +70,7 @@ class BuddyPopup(gtk.Window): box = CanvasBox(grid, CanvasBox.HORIZONTAL, 1) grid.set_constraints(box, 0, 5) - friends = self._shell.get_model().get_friends() + friends = shell_model.get_friends() if friends.has_buddy(self._buddy): icon = IconItem(icon_name='stock-remove-friend') icon.connect('clicked', self._action_clicked_cb, @@ -83,11 +87,17 @@ class BuddyPopup(gtk.Window): box.set_constraints(icon, 3, 3) box.add_child(icon) - icon = IconItem(icon_name='stock-invite') - icon.connect('clicked', self._action_clicked_cb, - BuddyPopup.ACTION_INVITE) - box.set_constraints(icon, 3, 3) - box.add_child(icon) + activity = shell_model.get_current_activity() + if activity != None: + activity_ps = pservice.get_activity(activity.get_id()) + + # FIXME check that the buddy is not in the activity already + + icon = IconItem(icon_name='stock-invite') + icon.connect('clicked', self._action_clicked_cb, + BuddyPopup.ACTION_INVITE) + box.set_constraints(icon, 3, 3) + box.add_child(icon) root.add_child(box)