Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-08-09 16:29:33 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-08-09 16:29:33 (GMT)
commit0dcaf314f7933a6852bd45ea1d6705bfb5659443 (patch)
tree96cf6753b900524c06146bfede49005206edb76e /sugar
parent95d9b7fe8e7cbde413ef5f937cc1dda2b7fa8813 (diff)
Several fixes and cleanups
Diffstat (limited to 'sugar')
-rw-r--r--sugar/activity/Activity.py32
-rw-r--r--sugar/activity/ActivityFactory.py7
2 files changed, 20 insertions, 19 deletions
diff --git a/sugar/activity/Activity.py b/sugar/activity/Activity.py
index ec745b2..cc7d933 100644
--- a/sugar/activity/Activity.py
+++ b/sugar/activity/Activity.py
@@ -1,3 +1,5 @@
+import os
+
import dbus
import dbus.service
import gtk
@@ -10,25 +12,23 @@ ACTIVITY_SERVICE_NAME = "org.laptop.Activity"
ACTIVITY_SERVICE_PATH = "/org/laptop/Activity"
ACTIVITY_INTERFACE = "org.laptop.Activity"
+def get_service_name(xid):
+ return ACTIVITY_SERVICE_NAME + '%d' % xid
+
+def get_object_path(xid):
+ return ACTIVITY_SERVICE_PATH + "/%s" % xid
+
+
class ActivityDbusService(dbus.service.Object):
"""Base dbus service object that each Activity uses to export dbus methods.
The dbus service is separate from the actual Activity object so that we can
tightly control what stuff passes through the dbus python bindings."""
- def __init__(self, pservice, xid, activity):
+ def start(self, pservice, activity):
self._activity = activity
self._pservice = pservice
- bus = dbus.SessionBus()
- service_name = ACTIVITY_SERVICE_NAME
- self._object_path = ACTIVITY_SERVICE_PATH + "/%s" % xid
- service = dbus.service.BusName(service_name, bus=bus)
- dbus.service.Object.__init__(self, service, self._object_path)
-
- def get_object_path(self):
- return self._object_path
-
@dbus.service.method(ACTIVITY_INTERFACE)
def share(self):
"""Called by the shell to request the activity to share itself on the network."""
@@ -68,7 +68,7 @@ class ActivityDbusService(dbus.service.Object):
class Activity(gtk.Window):
"""Base Activity class that all other Activities derive from."""
- def __init__(self, service = None):
+ def __init__(self):
gtk.Window.__init__(self)
self._shared = False
@@ -82,17 +82,17 @@ class Activity(gtk.Window):
group.realize()
self.window.set_group(group.window)
- self._bus = ActivityDbusService(self._pservice, self.window.xid, self)
+ bus = dbus.SessionBus()
+ xid = self.window.xid
+ bus_name = dbus.service.BusName(get_service_name(xid), bus=bus)
+ self._bus = ActivityDbusService(bus_name, get_object_path(xid))
+ self._bus.start(self._pservice, self)
def __del__(self):
if self._bus:
del self._bus
self._bus = None
- def get_object_path(self):
- """Returns the path of the activity dbus service"""
- return self._bus.get_object_path()
-
def set_default_type(self, default_type):
"""Set the activity default type.
diff --git a/sugar/activity/ActivityFactory.py b/sugar/activity/ActivityFactory.py
index e6cac08..3d47def 100644
--- a/sugar/activity/ActivityFactory.py
+++ b/sugar/activity/ActivityFactory.py
@@ -38,7 +38,7 @@ class ActivityFactory(dbus.service.Object):
@dbus.service.method("com.redhat.Sugar.ActivityFactory")
def create(self):
activity = self._class()
- return activity.get_object_path()
+ return activity.window.xid
def create(activity_name):
"""Create a new activity from his name."""
@@ -50,10 +50,11 @@ def create(activity_name):
proxy_obj = bus.get_object(factory_name, factory_path)
factory = dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityFactory")
- activity_path = factory.create()
+ xid = factory.create()
bus = dbus.SessionBus()
- proxy_obj = bus.get_object(Activity.ACTIVITY_SERVICE_NAME, activity_path)
+ proxy_obj = bus.get_object(Activity.get_service_name(xid),
+ Activity.get_object_path(xid))
activity = dbus.Interface(proxy_obj, Activity.ACTIVITY_INTERFACE)
return activity