From a716936afa83905b1c65a5e4dc8bb53e477294fe Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Sat, 9 Apr 2011 16:24:48 +0000 Subject: [PATCH] 3649: Relative media paths used when creating new media objetcs by drag-and-drop svn: r17086 --- src/gui/editors/displaytabs/gallerytab.py | 3 +++ src/plugins/view/mediaview.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/gui/editors/displaytabs/gallerytab.py b/src/gui/editors/displaytabs/gallerytab.py index 4f17a0f0d..2dd2628b4 100644 --- a/src/gui/editors/displaytabs/gallerytab.py +++ b/src/gui/editors/displaytabs/gallerytab.py @@ -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) diff --git a/src/plugins/view/mediaview.py b/src/plugins/view/mediaview.py index 64b72d9f7..a4ab879e3 100644 --- a/src/plugins/view/mediaview.py +++ b/src/plugins/view/mediaview.py @@ -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)