diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-09-15 00:54:25 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-09-15 00:54:25 (GMT) |
commit | 3a10f80aa1bc003329498f4e2df7d9d4ef6f3770 (patch) | |
tree | 5378d8ce506a33bb00fd3d80ef8d7babe3fdea6a /shell | |
parent | dd15b0d063ccfa2e76a81231b969dc0ec4293efd (diff) |
A bunch of cleanups and fixes
Diffstat (limited to 'shell')
-rw-r--r-- | shell/FriendIcon.py | 19 | ||||
-rw-r--r-- | shell/FriendPopup.py | 31 |
2 files changed, 34 insertions, 16 deletions
diff --git a/shell/FriendIcon.py b/shell/FriendIcon.py index 8d1017c..0c6b1e6 100644 --- a/shell/FriendIcon.py +++ b/shell/FriendIcon.py @@ -45,7 +45,8 @@ class FriendIcon(IconItem): FriendIcon._popup_shell.set_active(None) grid = Grid() - self._popup = FriendPopup(self._shell, grid, icon.get_friend()) + self._popup = FriendPopup(grid, icon.get_friend()) + self._popup.connect('action', self._popup_action_cb) self._popup.connect('enter-notify-event', self._popup_enter_notify_event_cb) self._popup.connect('leave-notify-event', @@ -74,9 +75,25 @@ class FriendIcon(IconItem): FriendIcon._popup_shell.set_active(self) + def _popup_action_cb(self, popup, action): + self._popdown() + + buddy = self._friend.get_buddy() + if buddy == None: + return + + if action == FriendPopup.ACTION_INVITE: + activity = self._shell.get_current_activity() + activity.invite(buddy) + elif action == FriendPopup.ACTION_MAKE_FRIEND: + friends = self._shell.get_owner().get_friends() + friends.add_buddy(buddy) + def _popdown_cb(self, friend): if not self._hover_popup: self._popdown() + else: + self._popdown_on_leave = True def _popup_enter_notify_event_cb(self, widget, event): self._hover_popup = True diff --git a/shell/FriendPopup.py b/shell/FriendPopup.py index 4a2cd1b..e208594 100644 --- a/shell/FriendPopup.py +++ b/shell/FriendPopup.py @@ -1,15 +1,23 @@ import gtk import goocanvas +import gobject from sugar.canvas.CanvasView import CanvasView from sugar.canvas.CanvasBox import CanvasBox from sugar.canvas.IconItem import IconItem class FriendPopup(gtk.Window): - def __init__(self, shell, grid, friend): + ACTION_MAKE_FRIEND = 0 + ACTION_INVITE = 0 + + __gsignals__ = { + 'action': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, ([int])), + } + + def __init__(self, grid, friend): gtk.Window.__init__(self, gtk.WINDOW_POPUP) - self._shell = shell self._friend = friend self._hover = False self._popdown_on_leave = False @@ -46,7 +54,8 @@ class FriendPopup(gtk.Window): grid.set_constraints(box, 0, 5) icon = IconItem(icon_name='stock-make-friend') - icon.connect('clicked', self._make_friend_clicked_cb) + icon.connect('clicked', self._action_clicked_cb, + FriendPopup.ACTION_MAKE_FRIEND) box.set_constraints(icon, 3, 3) box.add_child(icon) @@ -55,7 +64,8 @@ class FriendPopup(gtk.Window): box.add_child(icon) icon = IconItem(icon_name='stock-invite') - icon.connect('clicked', self._invite_clicked_cb) + icon.connect('clicked', self._action_clicked_cb, + FriendPopup.ACTION_INVITE) box.set_constraints(icon, 3, 3) box.add_child(icon) @@ -63,17 +73,8 @@ class FriendPopup(gtk.Window): canvas.set_model(model) - def _invite_clicked_cb(self, icon): - activity = self._shell.get_current_activity() - buddy = self._friend.get_buddy() - if buddy != None: - activity.invite(buddy) - - def _make_friend_clicked_cb(self, icon): - friends = self._shell.get_owner().get_friends() - buddy = self._friend.get_buddy() - if buddy != None: - friends.add_buddy(buddy) + def _action_clicked_cb(self, icon, action): + self.emit('action', action) def get_width(self): return self._width |