3649: Relative media paths used when creating new media objetcs by drag-and-drop

svn: r17087
This commit is contained in:
Nick Hall 2011-04-09 16:25:35 +00:00
parent 0380d94a46
commit 50486bb909
2 changed files with 6 additions and 0 deletions

View File

@ -472,6 +472,9 @@ class GalleryTab(ButtonTab, DbGUIElement):
if not gen.mime.is_valid_type(mime):
return
photo = gen.lib.MediaObject()
base_dir = unicode(Utils.media_path(self.dbstate.db))
if os.path.exists(base_dir):
name = Utils.relative_path(name, base_dir)
photo.set_path(name)
photo.set_mime_type(mime)
basename = os.path.basename(name)

View File

@ -188,6 +188,9 @@ class MediaView(ListView):
if not gen.mime.is_valid_type(mime):
return
photo = gen.lib.MediaObject()
base_dir = unicode(Utils.media_path(self.dbstate.db))
if os.path.exists(base_dir):
name = Utils.relative_path(name, base_dir)
photo.set_path(name)
photo.set_mime_type(mime)
basename = os.path.basename(name)