Use the default service to get activity informations, instead

of Activity ps object.
This commit is contained in:
Marco Pesenti Gritti 2006-08-08 12:01:45 +02:00
parent 544e47cbe0
commit 2535a88645
5 changed files with 13 additions and 11 deletions

View File

@ -46,8 +46,6 @@ class BrowserActivity(Activity):
self.add(vbox) self.add(vbox)
vbox.show() vbox.show()
self._pservice = PresenceService()
if service: if service:
service.connect('service-appeared', self._service_appeared_cb) service.connect('service-appeared', self._service_appeared_cb)

View File

@ -1,4 +1,5 @@
[Activity] [Activity]
name = Terminal name = Terminal
id = org.sugar.Terminal id = org.sugar.Terminal
default_type = _terminal_olpc._udp
python_module = terminal.TerminalActivity.TerminalActivity python_module = terminal.TerminalActivity.TerminalActivity

View File

@ -3,17 +3,17 @@ import xml.sax.saxutils
import gobject import gobject
from sugar.presence.PresenceService import PresenceService from sugar.presence.PresenceService import PresenceService
from ActivityRegistry import ActivityRegistry
class ActivityInfo: class ActivityInfo:
def __init__(self, service): def __init__(self, service):
self._service = service self._service = service
def get_id(self): def get_id(self):
activity_id = self._service.get_id() return self._service.get_activity_id()
def get_type(self): def get_type(self):
# FIXME return self._service.get_type()
return "_web_olpc._udp"
def get_title(self): def get_title(self):
return "FIXME Title" return "FIXME Title"
@ -29,13 +29,14 @@ class ActivitiesModel(gobject.GObject):
([gobject.TYPE_PYOBJECT])) ([gobject.TYPE_PYOBJECT]))
} }
def __init__(self): def __init__(self, registry):
gobject.GObject.__init__(self) gobject.GObject.__init__(self)
self._activities = [] self._activities = []
self._registry = registry
self._pservice = PresenceService() self._pservice = PresenceService()
self._pservice.connect("activity-appeared", self._on_activity_announced_cb) self._pservice.connect("service-appeared", self.__service_appeared_cb)
def add_activity(self, service): def add_activity(self, service):
activity_info = ActivityInfo(service) activity_info = ActivityInfo(service)
@ -45,5 +46,6 @@ class ActivitiesModel(gobject.GObject):
def __iter__(self): def __iter__(self):
return self._activities.__iter__() return self._activities.__iter__()
def _on_activity_announced_cb(self, pservice, activity): def __service_appeared_cb(self, pservice, service):
self.add_activity(activity) if self._registry.get_activity(service.get_type()) != None:
self.add_activity(service)

View File

@ -144,7 +144,7 @@ class HomeWindow(gtk.Window):
vbox.pack_start(label, False) vbox.pack_start(label, False)
label.show() label.show()
model = ActivitiesModel() model = ActivitiesModel(shell.get_registry())
grid = ActivitiesGrid(shell, model) grid = ActivitiesGrid(shell, model)
vbox.pack_start(grid) vbox.pack_start(grid)
grid.show() grid.show()

View File

@ -146,7 +146,7 @@ class Activity(gtk.Window):
gtk.Window.__init__(self) gtk.Window.__init__(self)
if service: if service:
self._activity_id = service.get_id() self._activity_id = service.get_activity_id()
self._shared = True self._shared = True
else: else:
self._activity_id = sugar.util.unique_id() self._activity_id = sugar.util.unique_id()
@ -156,6 +156,7 @@ class Activity(gtk.Window):
self._initial_service = None self._initial_service = None
self._activity_object = None self._activity_object = None
self._default_type = None self._default_type = None
self._pservice = PresenceService()
self.connect('realize', self.__realize) self.connect('realize', self.__realize)