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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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