Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/home
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-09-14 11:03:11 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-09-14 11:03:11 (GMT)
commitfe69dec4ad5b6d117006f9038afad9e4c973814c (patch)
tree68fcc3107cb9071cff19adb9b513fe0def78a91f /shell/home
parent8f6baf62399edd81d6e1fa4a101690f200aeb89b (diff)
Implement popup menu for friends
Diffstat (limited to 'shell/home')
-rw-r--r--shell/home/FriendsGroup.py46
1 files changed, 37 insertions, 9 deletions
diff --git a/shell/home/FriendsGroup.py b/shell/home/FriendsGroup.py
index 170f144..2ff9a03 100644
--- a/shell/home/FriendsGroup.py
+++ b/shell/home/FriendsGroup.py
@@ -5,6 +5,8 @@ import goocanvas
from sugar.canvas.IconItem import IconItem
from home.IconLayout import IconLayout
from home.MyIcon import MyIcon
+from BuddyPopup import BuddyPopup
+from sugar.canvas.Grid import Grid
class FriendIcon(IconItem):
def __init__(self, friend):
@@ -31,19 +33,45 @@ class FriendsGroup(goocanvas.Group):
for friend in self._friends:
self.add_friend(friend)
- friends.connect('friend-added', self.__friend_added_cb)
-
- def __friend_clicked_cb(self, icon):
- activity = self._shell.get_current_activity()
- buddy = icon.get_friend().get_buddy()
- if buddy != None:
- activity.invite(buddy)
+ friends.connect('friend-added', self._friend_added_cb)
def add_friend(self, friend):
icon = FriendIcon(friend)
- icon.connect('clicked', self.__friend_clicked_cb)
+
+ icon.connect('popup', self._friend_popup_cb)
+ icon.connect('popdown', self._friend_popdown_cb)
+
self.add_child(icon)
self._icon_layout.add_icon(icon)
- def __friend_added_cb(self, data_model, friend):
+ def _friend_added_cb(self, data_model, friend):
self.add_friend(friend)
+
+ def _friend_popup_cb(self, icon, x1, y1, x2, y2):
+ grid = Grid()
+
+ self._popup = BuddyPopup(self._shell, grid, icon.get_friend())
+
+ [grid_x1, grid_y1] = grid.convert_from_screen(x1, y1)
+ [grid_x2, grid_y2] = grid.convert_from_screen(x2, y2)
+
+ if grid_x2 + self._popup.get_width() + 1 > Grid.ROWS:
+ grid_x = grid_x1 - self._popup.get_width() + 1
+ else:
+ grid_x = grid_x2 - 1
+
+ grid_y = grid_y1
+
+ if grid_y < 0:
+ grid_y = 0
+ if grid_y + self._popup.get_width() > Grid.ROWS:
+ grid_y = Grid.ROWS - self._popup.get_width()
+
+ grid.set_constraints(self._popup, grid_x, grid_y,
+ self._popup.get_width(), self._popup.get_height())
+
+ self._popup.show()
+
+ def _friend_popdown_cb(self, friend):
+ self._popup.popdown()
+ self._popup = None