From e425c1d886450f8d34ed8301de26ab4ea5de70ca Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 16 Oct 2007 13:32:53 +0200 Subject: [PATCH 1/5] Fallback to mime parents if the main one doesn't have matches --- lib/sugar/datastore/datastore.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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 From cb0cedbc405ea7148fa30e47f0f8e38ff047daa3 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 16 Oct 2007 14:29:38 +0200 Subject: [PATCH 2/5] Do not use prgname for the bundle id because xulrunner is messing with it. Some activity launch fixes. --- bin/sugar-activity | 34 +++++++++++++++++----------------- lib/sugar/activity/activity.py | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) 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 c581c15f..d3cfe2ad 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) @@ -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 From 74dbcd5dfcb22a14295a2e25fafbde50d53bc040 Mon Sep 17 00:00:00 2001 From: Morgan Collett Date: Tue, 16 Oct 2007 14:10:21 +0100 Subject: [PATCH 3/5] Update NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index a80f5d7b..6e75b5d5 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ Snapshot 6d2828e54e Snapshot 1eb9932ab3 +* sugar.presence tracking handles of buddies (morgs) * Cleanup activity destruction (marco) * Added TimeoutAlert (erikos) From 34e2271833b63ccd098869f8dbe630d10e07768c Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 16 Oct 2007 14:40:43 +0200 Subject: [PATCH 4/5] Cast to string, looks like dbus strings confuse pygtk type checking here. --- lib/sugar/activity/activity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sugar/activity/activity.py b/lib/sugar/activity/activity.py index d3cfe2ad..ede81909 100644 --- a/lib/sugar/activity/activity.py +++ b/lib/sugar/activity/activity.py @@ -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() From de538ca0a84505f2d401ccfcc18c27e5ef074ecb Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 16 Oct 2007 14:46:27 +0200 Subject: [PATCH 5/5] Snapshot 34e2271833. --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 6e75b5d5..be9511ad 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +Snapshot 34e2271833 + +* Activity launching fixes (marco) + Snapshot 6d2828e54e * Code cleanups (marco)