A bunch of fixes...

This commit is contained in:
Marco Pesenti Gritti 2006-07-26 12:57:54 +02:00
parent 57cc6a303c
commit 0947581a11
7 changed files with 49 additions and 37 deletions

View File

@ -9,15 +9,14 @@ class ActivityInfo:
self._service = service
def get_id(self):
activity_id = self._service.get_activity_id()
activity_id = self._service.get_id()
def get_type(self):
return self._service.get_type()
# FIXME
return "_web_olpc._udp"
def get_title(self):
escaped_title = self._service.get_published_value('Title')
title = xml.sax.saxutils.unescape(escaped_title)
return title
return "FIXME Title"
def get_service(self):
return self._service
@ -47,7 +46,4 @@ class ActivitiesModel(gobject.GObject):
return self._activities.__iter__()
def _on_activity_announced_cb(self, pservice, activity):
# FIXME We should not hard code activity types here
services = activity.get_services_of_type("_web_olpc._udp")
if len(services) > 0:
self.add_activity(services[0])
self.add_activity(activity)

View File

@ -2,9 +2,11 @@ import gtk
import dbus
from sugar.activity import Activity
from PeopleWindow import PeopleWindow
class ActivityHost:
def __init__(self, xid):
def __init__(self, shell, xid):
self._shell = shell
self._xid = xid
bus = dbus.SessionBus()
@ -16,11 +18,13 @@ class ActivityHost:
self._id = self._activity.get_id()
self._default_type = self._activity.get_default_type()
self._window = gtk.gdk.window_foreign_new(xid)
self._people_window = PeopleWindow(shell, self)
def get_id(self):
return self._id
def share(self):
self._people_window.share()
self._activity.share()
def get_shared(self):
@ -29,6 +33,9 @@ class ActivityHost:
def get_default_type(self):
return self._default_type
def show_people(self):
self.show_dialog(self._people_window)
def show_dialog(self, dialog):
dialog.show()
dialog.window.set_transient_for(self._window)

View File

@ -18,9 +18,12 @@ class PeopleWindow(gtk.Window):
hbox.pack_start(presence_view, False)
presence_view.show()
chat = ActivityChat(activity)
hbox.pack_start(chat)
chat.show()
self._chat = ActivityChat(activity)
hbox.pack_start(self._chat)
self._chat.show()
self.add(hbox)
hbox.show()
def share(self):
self._chat.share()

View File

@ -133,9 +133,9 @@ class PresenceView(gtk.VBox):
self._add_buddy(buddy)
def _add_buddy(self, buddy):
#if buddy.is_owner():
if buddy.is_owner():
# Do not show ourself in the buddy list
#return
return
aniter = self._buddy_store.append(None)
self._buddy_store.set(aniter,

View File

@ -12,7 +12,6 @@ from sugar.LogWriter import LogWriter
from ActivityRegistry import ActivityRegistry
from HomeWindow import HomeWindow
from sugar import env
from PeopleWindow import PeopleWindow
from ConsoleWindow import ConsoleWindow
from Owner import ShellOwner
from PresenceService import PresenceService
@ -66,29 +65,33 @@ class Shell:
self._home_window = HomeWindow(self)
self._home_window.show()
self._people_windows = {}
self._hosts = {}
self._console_windows = {}
def get_current_activity(self):
window = self._screen.get_active_window()
if window:
xid = None
if window.get_window_type() == wnck.WINDOW_NORMAL:
return ActivityHost(window.get_xid())
xid = window.get_xid()
elif window.get_window_type() == wnck.WINDOW_DIALOG:
parent = window.get_transient()
if not parent is None:
return ActivityHost(parent.get_xid())
xid = parent.get_xid()
if xid != None:
if self._hosts.has_key(xid):
return self._hosts[xid]
else:
self._hosts[xid] = ActivityHost(self, xid)
return self._hosts[xid]
return None
def show_people(self):
activity = self.get_current_activity()
if activity:
if not self._people_windows.has_key(activity.get_id()):
dialog = PeopleWindow(self, activity)
self._people_windows[activity.get_id()] = dialog
else:
dialog = self._people_windows[activity.get_id()]
activity.show_dialog(dialog)
activity.show_people()
def get_console(self, module_id):
if not self._console_windows.has_key(module_id):

View File

@ -7,6 +7,8 @@ import dbus.glib
import gtk
import gobject
from sugar.presence.PresenceService import PresenceService
# Work around for dbus mutex locking issue
gtk.gdk.threads_init()
dbus.glib.threads_init()
@ -55,9 +57,10 @@ class ActivityFactory(dbus.service.Object):
dbus.service.Object.__init__(self, bus_name, get_path(factory))
@dbus.service.method("com.redhat.Sugar.ActivityFactory")
def create_with_service(self, serialized_service, args):
service = Service.deserialize(serialized_service)
activity = self._class(service, args)
def create_with_service(self, service_path):
pservice = PresenceService()
service = pservice._new_object(service_path)
activity = self._class(service, [])
@dbus.service.method("com.redhat.Sugar.ActivityFactory")
def create(self):
@ -74,9 +77,9 @@ def create(activity_name, service = None, args = None):
proxy_obj = bus.get_object(factory_name, factory_path)
factory = dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityFactory")
if service and args:
serialized_service = service.serialize(service)
factory.create_with_service(serialized_service, args)
if service:
print service.object_path()
factory.create_with_service(service.object_path())
else:
factory.create()
@ -148,8 +151,8 @@ class Activity(gtk.Window):
def __init__(self, service = None):
gtk.Window.__init__(self)
if service and service.has_key('activity_id'):
self._activity_id = service['activity_id']
if service:
self._activity_id = service.get_id()
self._shared = True
else:
self._activity_id = sugar.util.unique_id()

View File

@ -16,9 +16,9 @@ class ActivityChat(GroupChat):
# Find an existing activity chat to latch onto
ps_activity = self._pservice.get_activity(activity.get_id())
if ps_activity is not None:
service = ps_activity.get_service_of_type(ActivityChat.SERVICE_TYPE)
if service is not None:
self._service_appeared_cb(self._pservice, service)
services = ps_activity.get_services_of_type(ActivityChat.SERVICE_TYPE)
if len(services) > 0:
self._service_appeared_cb(self._pservice, services[0])
def _service_appeared_cb(self, pservice, service):
if service.get_activity_id() != self._activity.get_id():