sugar-toolkit-gtk3/shell/model/ShellModel.py

65 lines
1.7 KiB
Python
Raw Normal View History

2006-09-15 12:40:46 +02:00
import gobject
from sugar.presence import PresenceService
2006-09-15 16:19:56 +02:00
from model.Friends import Friends
2006-09-15 12:52:37 +02:00
from model.Owner import ShellOwner
2006-09-15 12:40:46 +02:00
class ShellModel(gobject.GObject):
__gsignals__ = {
'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):
gobject.GObject.__init__(self)
self._hosts = {}
self._current_activity = None
PresenceService.start()
self._pservice = PresenceService.get_instance()
2006-09-15 22:50:06 +02:00
self._owner = ShellOwner(self)
2006-09-15 12:40:46 +02:00
self._owner.announce()
2006-09-15 16:19:56 +02:00
self._friends = Friends()
2006-09-15 12:40:46 +02:00
def get_friends(self):
2006-09-15 16:19:56 +02:00
return self._friends
2006-09-15 12:40:46 +02:00
def get_invites(self):
2006-09-15 16:19:56 +02:00
return self._owner.get_invites()
2006-09-15 12:40:46 +02:00
def get_owner(self):
return self._owner
def add_activity(self, activity_host):
self._hosts[activity_host.get_xid()] = activity_host
self.emit('activity-opened', activity_host)
def set_current_activity(self, activity_xid):
activity_host = self._hosts[activity_xid]
if self._current_activity == activity_host:
return
self._current_activity = activity_host
self.emit('activity-changed', activity_host)
def remove_activity(self, activity_xid):
if self._hosts.has_key(activity_xid):
host = self._hosts[activity_xid]
self.emit('activity-closed', host)
del self._hosts[activity_xid]
def get_activity(self, activity_id):
for host in self._hosts.values():
if host.get_id() == activity_id:
return host
return None
def get_current_activity(self):
return self._current_activity