From d3dfcdf2b9d65981cb8edb61dc0cb14ac0986e09 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Sun, 22 Jun 2014 00:04:27 +0100 Subject: [PATCH] 7837: Fix path when using drag & drop to add media --- gramps/gui/editors/displaytabs/gallerytab.py | 7 ++++--- gramps/plugins/view/mediaview.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gramps/gui/editors/displaytabs/gallerytab.py b/gramps/gui/editors/displaytabs/gallerytab.py index 8e0882890..bd8a14c25 100644 --- a/gramps/gui/editors/displaytabs/gallerytab.py +++ b/gramps/gui/editors/displaytabs/gallerytab.py @@ -523,16 +523,17 @@ class GalleryTab(ButtonTab, DbGUIElement): d = conv_to_unicode((file.replace('\0',' ').strip()), None) protocol, site, mfile, j, k, l = urlparse(d) if protocol == "file": - mime = get_type(mfile) + name = url2pathname(mfile) + mime = get_type(name) if not is_valid_type(mime): return photo = MediaObject() self.uistate.set_busy_cursor(True) - photo.set_checksum(create_checksum(mfile)) + photo.set_checksum(create_checksum(name)) self.uistate.set_busy_cursor(False) base_dir = cuni(media_path(self.dbstate.db)) if os.path.exists(base_dir): - name = relative_path(mfile, base_dir) + name = relative_path(name, base_dir) photo.set_path(name) photo.set_mime_type(mime) basename = os.path.basename(name) diff --git a/gramps/plugins/view/mediaview.py b/gramps/plugins/view/mediaview.py index f821476f5..29ddf4458 100644 --- a/gramps/plugins/view/mediaview.py +++ b/gramps/plugins/view/mediaview.py @@ -58,7 +58,7 @@ from gi.repository import Gtk from gramps.gui.utils import open_file_with_default_application from gramps.gui.views.listview import ListView, TEXT, MARKUP, ICON from gramps.gui.views.treemodels import MediaModel -from gramps.gen.constfunc import win, cuni +from gramps.gen.constfunc import win, cuni, conv_to_unicode from gramps.gen.config import config from gramps.gen.utils.file import (media_path, relative_path, media_path_full, create_checksum) @@ -189,7 +189,7 @@ class MediaView(ListView): None) protocol, site, mfile, j, k, l = urlparse(clean_string) if protocol == "file": - name = mfile + name = url2pathname(mfile) mime = get_type(name) if not is_valid_type(mime): return