diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-09-14 13:12:34 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-09-14 13:12:34 (GMT) |
commit | 2a6d2139ad98e8d99a71b99c1ecb3578ce36cdb9 (patch) | |
tree | 0fb2f63b262390e83a8a41e4764f29e5be40b1f7 /shell | |
parent | 3b41f1248a56fa06758c50c0ac48cca76a6b58bb (diff) |
Move popup menu handling in the icon
Diffstat (limited to 'shell')
-rw-r--r-- | shell/home/FriendsGroup.py | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/shell/home/FriendsGroup.py b/shell/home/FriendsGroup.py index 7ba1a3b..92b6d70 100644 --- a/shell/home/FriendsGroup.py +++ b/shell/home/FriendsGroup.py @@ -9,46 +9,21 @@ from BuddyPopup import BuddyPopup from sugar.canvas.Grid import Grid class FriendIcon(IconItem): - def __init__(self, friend): + def __init__(self, shell, friend): IconItem.__init__(self, icon_name='stock-buddy', color=friend.get_color(), size=96) - self._friend = friend - - def get_friend(self): - return self._friend - -class FriendsGroup(goocanvas.Group): - def __init__(self, shell, friends): - goocanvas.Group.__init__(self) - self._popup = None self._shell = shell - self._icon_layout = IconLayout(1200, 900) - self._friends = friends - - me = MyIcon(100) - me.translate(600 - (me.get_property('size') / 2), - 450 - (me.get_property('size') / 2)) - self.add_child(me) - - for friend in self._friends: - self.add_friend(friend) - - friends.connect('friend-added', self._friend_added_cb) - - def add_friend(self, friend): - icon = FriendIcon(friend) + self._friend = friend + self._popup = None - icon.connect('popup', self._friend_popup_cb) - icon.connect('popdown', self._friend_popdown_cb) + self.connect('popup', self._popup_cb) + self.connect('popdown', self._popdown_cb) - self.add_child(icon) - self._icon_layout.add_icon(icon) - - def _friend_added_cb(self, data_model, friend): - self.add_friend(friend) + def get_friend(self): + return self._friend - def _friend_popup_cb(self, icon, x1, y1, x2, y2): + def _popup_cb(self, icon, x1, y1, x2, y2): grid = Grid() if not self._popup: @@ -77,7 +52,33 @@ class FriendsGroup(goocanvas.Group): def _popup_destroy_cb(self, popup): self._popup = None - def _friend_popdown_cb(self, friend): + def _popdown_cb(self, friend): if self._popup: self._popup.connect('destroy', self._popup_destroy_cb) self._popup.popdown() + +class FriendsGroup(goocanvas.Group): + def __init__(self, shell, friends): + goocanvas.Group.__init__(self) + + self._shell = shell + self._icon_layout = IconLayout(1200, 900) + self._friends = friends + + me = MyIcon(100) + me.translate(600 - (me.get_property('size') / 2), + 450 - (me.get_property('size') / 2)) + self.add_child(me) + + for friend in self._friends: + self.add_friend(friend) + + friends.connect('friend-added', self._friend_added_cb) + + def add_friend(self, friend): + icon = FriendIcon(self._shell, friend) + self.add_child(icon) + self._icon_layout.add_icon(icon) + + def _friend_added_cb(self, data_model, friend): + self.add_friend(friend) |