#1888 Fix opening items from the clipboard.

This commit is contained in:
Tomeu Vizoso
2007-07-11 11:39:40 +02:00
parent bbbea6167d
commit bb71cd61cf
3 changed files with 66 additions and 37 deletions
+34
View File
@@ -20,6 +20,9 @@ import logging
import gobject
from sugar.datastore import dbus_helpers
from sugar import activity
from sugar.activity.bundle import Bundle
from sugar.activity import activityfactory
class DSMetadata(gobject.GObject):
__gsignals__ = {
@@ -85,6 +88,37 @@ class DSObject:
file_path = property(get_file_path, set_file_path)
def get_activities(self):
activities = []
if self.metadata['activity']:
activity_info = activity.get_registry().get_activity(self.metadata['activity'])
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.service_name != self.metadata['activity']:
activities.append(activity_info)
return activities
def is_bundle(self):
return self.metadata['mime_type'] == 'application/vnd.olpc-x-sugar'
def resume(self):
if self.is_bundle():
bundle = Bundle(self.file_path)
if not bundle.is_installed():
bundle.install()
activityfactory.create(bundle.get_service_name())
else:
activity_info = self.get_activities()[0]
activityfactory.create_with_object_id(activity_info.service_name,
self.object_id)
def get(object_id):
logging.debug('datastore.get')
metadata = dbus_helpers.get_properties(object_id)