7837: Fix path when using drag & drop to add media

This commit is contained in:
Nick Hall 2014-06-22 00:04:27 +01:00
parent 6950679504
commit d3dfcdf2b9
2 changed files with 6 additions and 5 deletions

View File

@ -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)

View File

@ -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