Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shell/model/homeactivity.py4
-rw-r--r--shell/model/homemodel.py37
-rw-r--r--sugar/Makefile.am2
-rw-r--r--sugar/activity/activity.py19
-rw-r--r--sugar/activity/activityservice.py10
-rw-r--r--sugar/wm.py10
6 files changed, 37 insertions, 45 deletions
diff --git a/shell/model/homeactivity.py b/shell/model/homeactivity.py
index f029e15..2a36ae5 100644
--- a/shell/model/homeactivity.py
+++ b/shell/model/homeactivity.py
@@ -40,7 +40,7 @@ class HomeActivity(gobject.GObject):
gobject.PARAM_READWRITE),
}
- def __init__(self, bundle=None, activity_id=None):
+ def __init__(self, bundle, activity_id):
"""Initialise the HomeActivity
bundle -- sugar.activity.bundle.Bundle instance,
@@ -72,8 +72,6 @@ class HomeActivity(gobject.GObject):
def set_service(self, service):
self._service = service
- if not self._activity_id:
- self._activity_id = service.get_id()
def get_service(self):
"""Retrieve the application's sugar introspection service
diff --git a/shell/model/homemodel.py b/shell/model/homemodel.py
index f9cd472..7eb4b46 100644
--- a/shell/model/homemodel.py
+++ b/shell/model/homemodel.py
@@ -20,6 +20,8 @@ import gobject
import wnck
import dbus
+from sugar import wm
+
from model.homeactivity import HomeActivity
from model import bundleregistry
@@ -94,23 +96,25 @@ class HomeModel(gobject.GObject):
if window.get_window_type() == wnck.WINDOW_NORMAL:
activity = None
- service = self._get_activity_service(window.get_xid())
- if service:
- activity_id = service.get_id()
- activity = self._get_activity_by_id(activity_id)
+ activity_id = wm.get_activity_id(window)
- if activity:
- activity.set_service(service)
+ bundle_id = wm.get_bundle_id(window)
+ if bundle_id:
+ bundle = self._bundle_registry.get_bundle(bundle_id)
else:
- activity = self._get_activity_by_xid(window.get_xid())
+ bundle = None
- if activity:
- activity.set_window(window)
- else:
- activity = HomeActivity()
- activity.set_window(window)
+ if activity_id:
+ activity = self._get_activity_by_id(activity_id)
+
+ if not activity:
+ activity = HomeActivity(bundle, activity_id)
self._add_activity(activity)
+ service = self._get_activity_service(window.get_xid())
+ activity.set_service(service)
+ activity.set_window(window)
+
activity.props.launching = False
self.emit('activity-started', activity)
@@ -127,10 +131,9 @@ class HomeModel(gobject.GObject):
try:
xid = int(name[len(_SERVICE_NAME):])
activity = self._get_activity_by_xid(xid)
- if activity:
+ if activity and not activity.get_service():
service = self._get_activity_service(xid)
- if service:
- activity.set_service()
+ activity.set_service(service)
except ValueError:
logging.error('Invalid activity service name, '
'cannot extract the xid')
@@ -221,8 +224,8 @@ class HomeModel(gobject.GObject):
self._add_activity(activity)
def notify_activity_launch_failed(self, activity_id):
- if self._activities.has_key(activity_id):
- activity = self._activities[activity_id]
+ activity = self._get_activity_by_id(activity_id)
+ if activity:
logging.debug("Activity %s (%s) launch failed" % (activity_id, activity.get_type()))
self._remove_activity(activity)
else:
diff --git a/sugar/Makefile.am b/sugar/Makefile.am
index 5a1f759..ecd0d16 100644
--- a/sugar/Makefile.am
+++ b/sugar/Makefile.am
@@ -9,7 +9,7 @@ sugar_PYTHON = \
ltihooks.py \
profile.py \
util.py \
- x11.py
+ wm.py
INCLUDES = \
$(LIB_CFLAGS) \
diff --git a/sugar/activity/activity.py b/sugar/activity/activity.py
index f1bda6c..143fa94 100644
--- a/sugar/activity/activity.py
+++ b/sugar/activity/activity.py
@@ -32,6 +32,7 @@ from sugar.graphics.window import Window
from sugar.graphics.toolbox import Toolbox
from sugar.graphics.toolbutton import ToolButton
from sugar.datastore import datastore
+from sugar import wm
from sugar import profile
class ActivityToolbar(gtk.Toolbar):
@@ -178,6 +179,7 @@ class Activity(Window, gtk.Container):
Window.__init__(self)
self.connect('destroy', self._destroy_cb)
+ self.connect('realize', self._realize_cb)
self._active = False
self._activity_id = handle.activity_id
@@ -207,7 +209,7 @@ class Activity(Window, gtk.Container):
logging.debug('Creating a jobject.')
self._jobject = datastore.create()
self._jobject.metadata['title'] = '%s %s' % (get_bundle_name(), 'Activity')
- self._jobject.metadata['activity'] = self.get_service_name()
+ self._jobject.metadata['activity'] = self._get_service_name()
self._jobject.metadata['keep'] = '0'
self._jobject.metadata['buddies'] = ''
self._jobject.metadata['preview'] = ''
@@ -286,20 +288,12 @@ class Activity(Window, gtk.Container):
self.present()
self.emit('joined')
- def get_service_name(self):
- """Gets the activity service name."""
- return os.environ['SUGAR_BUNDLE_SERVICE_NAME']
-
def get_shared(self):
"""Returns TRUE if the activity is shared on the mesh."""
if not self._shared_activity:
return False
return self._shared_activity.props.joined
- def get_id(self):
- """Get the unique activity identifier."""
- return self._activity_id
-
def _internal_share_cb(self, ps, success, activity, err):
self._pservice.disconnect(self._share_id)
self._share_id = None
@@ -322,6 +316,13 @@ class Activity(Window, gtk.Container):
"""Execute the given command with args"""
return False
+ def _get_service_name(self):
+ return os.environ['SUGAR_BUNDLE_SERVICE_NAME']
+
+ def _realize_cb(self, window):
+ wm.set_bundle_id(window.window, self._get_service_name())
+ wm.set_activity_id(window.window, self._activity_id)
+
def _destroy_cb(self, window):
"""Destroys our ActivityService and sharing service"""
if self._bus:
diff --git a/sugar/activity/activityservice.py b/sugar/activity/activityservice.py
index b69ba83..f456581 100644
--- a/sugar/activity/activityservice.py
+++ b/sugar/activity/activityservice.py
@@ -64,16 +64,6 @@ class ActivityService(dbus.service.Object):
self._activity.share()
@dbus.service.method(_ACTIVITY_INTERFACE)
- def get_id(self):
- """Get the activity identifier"""
- return self._activity.get_id()
-
- @dbus.service.method(_ACTIVITY_INTERFACE)
- def get_service_name(self):
- """Get the activity service name"""
- return self._activity.get_service_name()
-
- @dbus.service.method(_ACTIVITY_INTERFACE)
def get_shared(self):
"""Returns True if the activity is shared on the mesh."""
return self._activity.get_shared()
diff --git a/sugar/wm.py b/sugar/wm.py
index f5505c3..6610889 100644
--- a/sugar/wm.py
+++ b/sugar/wm.py
@@ -19,13 +19,13 @@ import gtk
import _sugarext
-def get_activity_id(wnck_window)
- window = gtk.gdk.window_foreign_new(window.get_xid())
+def get_activity_id(wnck_window):
+ window = gtk.gdk.window_foreign_new(wnck_window.get_xid())
return _sugarext.x11_get_string_property(
window, '_SUGAR_ACTIVITY_ID')
-def get_bundle_id(wnck_window, prop):
- window = gtk.gdk.window_foreign_new(window.get_xid())
+def get_bundle_id(wnck_window):
+ window = gtk.gdk.window_foreign_new(wnck_window.get_xid())
return _sugarext.x11_get_string_property(
window, '_SUGAR_BUNDLE_ID')
@@ -35,4 +35,4 @@ def set_activity_id(window, activity_id):
def set_bundle_id(window, bundle_id):
_sugarext.x11_set_string_property(
- window, '_SUGAR_BUNDLE_ID', activity_id)
+ window, '_SUGAR_BUNDLE_ID', bundle_id)