Human readable file names when copying on usb...

Conflicts:

	NEWS
This commit is contained in:
Marco Pesenti Gritti 2007-09-20 12:25:12 +02:00
parent c74276dcdb
commit 0f2a58d737
2 changed files with 16 additions and 0 deletions

4
NEWS
View File

@ -1,3 +1,7 @@
* #3649 Human readable file names on USB. (marco)
Snapshot b8ce5083b7
* #3601 Always remove invites from the frame. (cassidy) * #3601 Always remove invites from the frame. (cassidy)
Snapshot b8ce5083b7 Snapshot b8ce5083b7

View File

@ -27,6 +27,7 @@ from sugar import activity
from sugar.activity.bundle import Bundle from sugar.activity.bundle import Bundle
from sugar.activity.activityhandle import ActivityHandle from sugar.activity.activityhandle import ActivityHandle
from sugar.bundle.contentbundle import ContentBundle from sugar.bundle.contentbundle import ContentBundle
from sugar.objects import mime
class DSMetadata(gobject.GObject): class DSMetadata(gobject.GObject):
__gsignals__ = { __gsignals__ = {
@ -259,6 +260,17 @@ def copy(jobject, mount_point):
new_jobject = jobject.copy() new_jobject = jobject.copy()
new_jobject.metadata['mountpoint'] = mount_point new_jobject.metadata['mountpoint'] = mount_point
if jobject.metadata.has_key('title'):
filename = jobject.metadata['title']
if jobject.metadata.has_key('mime_type'):
mime_type = jobject.metadata['mime_type']
extension = mime.get_primary_extension(mime_type)
if extension:
filename += '.' + extension
new_jobject.metadata['suggested_filename'] = filename
# this will cause the file be retrieved from the DS # this will cause the file be retrieved from the DS
new_jobject.file_path = jobject.file_path new_jobject.file_path = jobject.file_path