diff --git a/NEWS b/NEWS index a80f5d7b..be9511ad 100644 --- a/NEWS +++ b/NEWS @@ -1,9 +1,14 @@ +Snapshot 34e2271833 + +* Activity launching fixes (marco) + Snapshot 6d2828e54e * Code cleanups (marco) Snapshot 1eb9932ab3 +* sugar.presence tracking handles of buddies (morgs) * Cleanup activity destruction (marco) * Added TimeoutAlert (erikos) diff --git a/bin/sugar-activity b/bin/sugar-activity index ed6c7df8..2e10922a 100755 --- a/bin/sugar-activity +++ b/bin/sugar-activity @@ -94,17 +94,6 @@ if len(args) == 0: bundle_path = os.environ['SUGAR_BUNDLE_PATH'] sys.path.append(bundle_path) -bundle = ActivityBundle(bundle_path) - -gettext.bindtextdomain(bundle.get_bundle_id(), - bundle.get_locale_path()) -gettext.textdomain(bundle.get_bundle_id()) - -gtk.icon_theme_get_default().append_search_path(bundle.get_icons_path()) - -_sugarbaseext.set_prgname(bundle.get_bundle_id()) -_sugarbaseext.set_application_name(bundle.get_name()) - splitted_module = args[0].rsplit('.', 1) module_name = splitted_module[0] class_name = splitted_module[1] @@ -112,10 +101,8 @@ class_name = splitted_module[1] module = __import__(module_name) for comp in module_name.split('.')[1:]: module = getattr(module, comp) - if hasattr(module, 'start'): - module.start() -constructor = getattr(module, class_name) +constructor = getattr(module, class_name) handle = activityhandle.ActivityHandle( activity_id=options.activity_id, object_id=options.object_id, uri=options.uri) @@ -123,9 +110,8 @@ handle = activityhandle.ActivityHandle( if options.single_process is True: bus = dbus.SessionBus() - bundle_id = bundle.get_bundle_id() - service_name = get_single_process_name(bundle_id) - service_path = get_single_process_path(bundle_id) + service_name = get_single_process_name(options.bundle_id) + service_path = get_single_process_path(options.bundle_id) bus_object = bus.get_object( 'org.freedesktop.DBus', '/org/freedesktop/DBus') @@ -144,6 +130,20 @@ if options.single_process is True: print 'Created %s in a single process.' % service_name sys.exit(0) +if hasattr(module, 'start'): + module.start() + +bundle = ActivityBundle(bundle_path) + +os.environ['SUGAR_BUNDLE_ID'] = bundle.get_bundle_id() +os.environ['SUGAR_BUNDLE_NAME'] = bundle.get_name() + +gettext.bindtextdomain(bundle.get_bundle_id(), + bundle.get_locale_path()) +gettext.textdomain(bundle.get_bundle_id()) + +gtk.icon_theme_get_default().append_search_path(bundle.get_icons_path()) + create_activity_instance(constructor, handle) gtk.main() diff --git a/lib/sugar/activity/activity.py b/lib/sugar/activity/activity.py index 4bb214f4..8fceb6b1 100644 --- a/lib/sugar/activity/activity.py +++ b/lib/sugar/activity/activity.py @@ -362,7 +362,7 @@ class Activity(Window, gtk.Container): return self._activity_id def get_bundle_id(self): - return _sugarbaseext.get_prgname() + return os.environ['SUGAR_BUNDLE_ID'] def set_canvas(self, canvas): Window.set_canvas(self, canvas) @@ -607,7 +607,7 @@ class Activity(Window, gtk.Container): def __realize_cb(self, window): wm.set_bundle_id(window.window, self.get_bundle_id()) - wm.set_activity_id(window.window, self._activity_id) + wm.set_activity_id(window.window, str(self._activity_id)) def __delete_event_cb(self, widget, event): self.close() @@ -624,7 +624,7 @@ class Activity(Window, gtk.Container): def get_bundle_name(): """Return the bundle name for the current process' bundle """ - return _sugarbaseext.get_application_name() + return os.environ['SUGAR_BUNDLE_NAME'] def get_bundle_path(): """Return the bundle path for the current process' bundle diff --git a/lib/sugar/datastore/datastore.py b/lib/sugar/datastore/datastore.py index a865c303..6f1e1461 100644 --- a/lib/sugar/datastore/datastore.py +++ b/lib/sugar/datastore/datastore.py @@ -117,20 +117,28 @@ class DSObject(object): file_path = property(get_file_path, set_file_path) + def _get_activities_for_mime(self, mime_type): + registry = activity.get_registry() + result = registry.get_activities_for_type(mime_type) + if not result: + for parent_mime in mime.get_mime_parents(mime_type): + result.extend(registry.get_activities_for_type(parent_type)) + def get_activities(self): activities = [] - if self.metadata['activity']: - activity_info = activity.get_registry().get_activity(self.metadata['activity']) + bundle_id = self.metadata['activity'] + if bundle_id: + activity_info = activity.get_registry().get_activity(bundle_id) if activity_info: activities.append(activity_info) mime_type = self.metadata['mime_type'] if mime_type: - activities_info = activity.get_registry().get_activities_for_type(mime_type) - for activity_info in activities_info: - if activity_info.bundle_id != self.metadata['activity']: - activities.append(activity_info) + activities_info = self._get_activities_for_mime(mime_type) + for info in activities_info: + if activity_info.bundle_id != bundle_id: + activities.append(info) return activities