Merge branch 'master' of git+ssh://crank.laptop.org/git/sugar

This commit is contained in:
Marco Pesenti Gritti 2006-06-19 15:31:32 -04:00
commit 9c0669dde4
3 changed files with 27 additions and 4 deletions

View File

@ -514,6 +514,8 @@ class PresenceService(gobject.GObject):
raise RuntimeError("presence service must be started first.") raise RuntimeError("presence service must be started first.")
rs_name = service.get_name() rs_name = service.get_name()
if self.get_owner() and rs_name != self.get_owner().get_nick_name():
raise RuntimeError("Tried to register a service that didn't have Owner nick as the service name!")
rs_stype = service.get_full_type() rs_stype = service.get_full_type()
rs_port = service.get_port() rs_port = service.get_port()
rs_props = service.get_properties() rs_props = service.get_properties()

View File

@ -143,9 +143,12 @@ class Service(object):
if uid and not self._properties.has_key(_ACTIVITY_UID_TAG): if uid and not self._properties.has_key(_ACTIVITY_UID_TAG):
self._properties[_ACTIVITY_UID_TAG] = uid self._properties[_ACTIVITY_UID_TAG] = uid
def serialize(self): def serialize(self, owner=None):
sdict = {} sdict = {}
sdict['name'] = dbus.Variant(self._name) if owner is not None:
sdict['name'] = dbus.Variant(owner.get_nick_name())
else:
sdict['name'] = dbus.Variant(self._name)
sdict['full_stype'] = dbus.Variant(self._full_stype) sdict['full_stype'] = dbus.Variant(self._full_stype)
sdict['activity_stype'] = dbus.Variant(self._activity_stype) sdict['activity_stype'] = dbus.Variant(self._activity_stype)
sdict['domain'] = dbus.Variant(self._domain) sdict['domain'] = dbus.Variant(self._domain)

View File

@ -93,6 +93,8 @@ class ActivitiesView(gtk.TreeView):
def __init__(self, model): def __init__(self, model):
gtk.TreeView.__init__(self, model) gtk.TreeView.__init__(self, model)
self._owner = None
self.set_headers_visible(False) self.set_headers_visible(False)
theme = gtk.icon_theme_get_default() theme = gtk.icon_theme_get_default()
@ -131,6 +133,9 @@ class ActivitiesView(gtk.TreeView):
cell.set_property('markup', markup) cell.set_property('markup', markup)
cell.set_property('ellipsize', pango.ELLIPSIZE_END) cell.set_property('ellipsize', pango.ELLIPSIZE_END)
def set_owner(self, owner):
self._owner = owner
def _row_activated_cb(self, treeview, path, column): def _row_activated_cb(self, treeview, path, column):
bus = dbus.SessionBus() bus = dbus.SessionBus()
proxy_obj = bus.get_object('com.redhat.Sugar.Browser', '/com/redhat/Sugar/Browser') proxy_obj = bus.get_object('com.redhat.Sugar.Browser', '/com/redhat/Sugar/Browser')
@ -145,7 +150,9 @@ class ActivitiesView(gtk.TreeView):
if service is None: if service is None:
browser_shell.open_browser(address) browser_shell.open_browser(address)
else: else:
serialized_service = service.serialize() if not self._owner:
raise RuntimeError("We don't have an owner yet!")
serialized_service = service.serialize(self._owner)
browser_shell.open_browser(address, serialized_service) browser_shell.open_browser(address, serialized_service)
class StartPage(gtk.HBox): class StartPage(gtk.HBox):
@ -161,6 +168,8 @@ class StartPage(gtk.HBox):
self._pservice = PresenceService.get_instance() self._pservice = PresenceService.get_instance()
self._pservice.connect("activity-announced", self._on_activity_announced_cb) self._pservice.connect("activity-announced", self._on_activity_announced_cb)
self._pservice.connect("new-service-adv", self._on_new_service_adv_cb) self._pservice.connect("new-service-adv", self._on_new_service_adv_cb)
self._pservice.connect("buddy-appeared", self._on_buddy_appeared_cb)
self._pservice.connect("buddy-disappeared", self._on_buddy_disappeared_cb)
self._pservice.start() self._pservice.start()
self._pservice.track_service_type(BrowserActivity._BROWSER_ACTIVITY_TYPE) self._pservice.track_service_type(BrowserActivity._BROWSER_ACTIVITY_TYPE)
@ -222,6 +231,7 @@ class StartPage(gtk.HBox):
self._activities_model = ActivitiesModel() self._activities_model = ActivitiesModel()
owner = self._pservice.get_owner()
self._activities = ActivitiesView(self._activities_model) self._activities = ActivitiesView(self._activities_model)
sw.add(self._activities) sw.add(self._activities)
self._activities.show() self._activities.show()
@ -245,6 +255,14 @@ class StartPage(gtk.HBox):
if activity_id: if activity_id:
self._pservice.track_service_type(short_stype) self._pservice.track_service_type(short_stype)
def _on_buddy_appeared_cb(self, pservice, buddy):
if buddy.is_owner():
self._activities.set_owner(buddy)
def _on_buddy_disappeared_cb(self, pservice, buddy):
if buddy.is_owner() and self._owner == buddy:
self._activities.set_owner(None)
def _on_activity_announced_cb(self, pservice, service, buddy): def _on_activity_announced_cb(self, pservice, service, buddy):
print "Found new activity with type %s" % service.get_full_type() print "Found new activity with type %s" % service.get_full_type()
self._activities_model.add_activity(buddy, service) self._activities_model.add_activity(buddy, service)