From 4dbf80369b8d4a44b9d53075d2dd922cd2000e29 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 28 Aug 2006 18:40:41 +0200 Subject: [PATCH] Start implementing presence on the friends panel --- shell/Shell.py | 17 +++++++++++++---- shell/panel/FriendsPanel.py | 32 +++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/shell/Shell.py b/shell/Shell.py index 6292a78a..86e9a5f7 100755 --- a/shell/Shell.py +++ b/shell/Shell.py @@ -37,10 +37,12 @@ class ShellDbusService(dbus.service.Object): class Shell(gobject.GObject): __gsignals__ = { - 'activity-opened': (gobject.SIGNAL_RUN_FIRST, - gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])), - 'activity-closed': (gobject.SIGNAL_RUN_FIRST, - gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])) + 'activity-opened': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])), + 'activity-changed': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])), + 'activity-closed': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])) } def __init__(self): @@ -62,6 +64,8 @@ class Shell(gobject.GObject): self._screen.connect('window-opened', self.__window_opened_cb) self._screen.connect('window-closed', self.__window_closed_cb) + self._screen.connect('active-window-changed', + self.__active_window_changed_cb) self._screen.connect("showing_desktop_changed", self.__showing_desktop_changed_cb) @@ -126,6 +130,11 @@ class Shell(gobject.GObject): self._hosts[window.get_xid()] = host self.emit('activity-opened', host) + def __active_window_changed_cb(self, screen): + window = screen.get_active_window() + if window and window.get_window_type() == wnck.WINDOW_NORMAL: + self.emit('activity-changed', self.get_current_activity()) + def __window_closed_cb(self, screen, window): if window.get_window_type() == wnck.WINDOW_NORMAL: xid = window.get_xid() diff --git a/shell/panel/FriendsPanel.py b/shell/panel/FriendsPanel.py index b7e9dc3a..2593baad 100644 --- a/shell/panel/FriendsPanel.py +++ b/shell/panel/FriendsPanel.py @@ -2,6 +2,30 @@ import goocanvas from panel.Panel import Panel from sugar.canvas.IconItem import IconItem +from sugar.canvas.IconColor import IconColor +from sugar.presence import PresenceService + +class BuddyIcon(IconItem): + def __init__(self, buddy, **kwargs): + IconItem.__init__(self, icon_name='stock-buddy', + color=buddy.get_color(), **kwargs) + +class FriendsGroup(goocanvas.Group): + def __init__(self, shell, width): + goocanvas.Group.__init__(self) + + i = 0 + while i < 10: + icon = IconItem(icon_name='stock-buddy', + color=IconColor('white'), + y=i * (width + 6), size=width) + self.add_child(icon) + i += 1 + + shell.connect('activity-changed', self.__activity_changed_cb) + + def __activity_changed_cb(self, group, activity): + print 'Changed' class ActionsBar(goocanvas.Group): def __init__(self, shell, width): @@ -47,5 +71,11 @@ class FriendsPanel(Panel): def construct(self): Panel.construct(self) + root = self.get_root() + actions_bar = ActionsBar(self._shell, self.get_width()) - self.get_root().add_child(actions_bar) + root.add_child(actions_bar) + + friends_group = FriendsGroup(self._shell, self.get_width()) + friends_group.translate(0, 150) + root.add_child(friends_group)