Start implementing presence on the friends panel
This commit is contained in:
parent
7d01cee2ef
commit
4dbf80369b
@ -37,10 +37,12 @@ class ShellDbusService(dbus.service.Object):
|
|||||||
|
|
||||||
class Shell(gobject.GObject):
|
class Shell(gobject.GObject):
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'activity-opened': (gobject.SIGNAL_RUN_FIRST,
|
'activity-opened': (gobject.SIGNAL_RUN_FIRST,
|
||||||
gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])),
|
gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])),
|
||||||
'activity-closed': (gobject.SIGNAL_RUN_FIRST,
|
'activity-changed': (gobject.SIGNAL_RUN_FIRST,
|
||||||
gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT]))
|
gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])),
|
||||||
|
'activity-closed': (gobject.SIGNAL_RUN_FIRST,
|
||||||
|
gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT]))
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -62,6 +64,8 @@ class Shell(gobject.GObject):
|
|||||||
|
|
||||||
self._screen.connect('window-opened', self.__window_opened_cb)
|
self._screen.connect('window-opened', self.__window_opened_cb)
|
||||||
self._screen.connect('window-closed', self.__window_closed_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._screen.connect("showing_desktop_changed",
|
||||||
self.__showing_desktop_changed_cb)
|
self.__showing_desktop_changed_cb)
|
||||||
|
|
||||||
@ -126,6 +130,11 @@ class Shell(gobject.GObject):
|
|||||||
self._hosts[window.get_xid()] = host
|
self._hosts[window.get_xid()] = host
|
||||||
self.emit('activity-opened', 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):
|
def __window_closed_cb(self, screen, window):
|
||||||
if window.get_window_type() == wnck.WINDOW_NORMAL:
|
if window.get_window_type() == wnck.WINDOW_NORMAL:
|
||||||
xid = window.get_xid()
|
xid = window.get_xid()
|
||||||
|
@ -2,6 +2,30 @@ import goocanvas
|
|||||||
|
|
||||||
from panel.Panel import Panel
|
from panel.Panel import Panel
|
||||||
from sugar.canvas.IconItem import IconItem
|
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):
|
class ActionsBar(goocanvas.Group):
|
||||||
def __init__(self, shell, width):
|
def __init__(self, shell, width):
|
||||||
@ -47,5 +71,11 @@ class FriendsPanel(Panel):
|
|||||||
def construct(self):
|
def construct(self):
|
||||||
Panel.construct(self)
|
Panel.construct(self)
|
||||||
|
|
||||||
|
root = self.get_root()
|
||||||
|
|
||||||
actions_bar = ActionsBar(self._shell, self.get_width())
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user