7837: Fix path when using drag & drop to add media
This commit is contained in:
parent
2706bfb552
commit
bf7d9c48fa
@ -523,16 +523,17 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
|||||||
d = conv_to_unicode((file.replace('\0',' ').strip()), None)
|
d = conv_to_unicode((file.replace('\0',' ').strip()), None)
|
||||||
protocol, site, mfile, j, k, l = urlparse(d)
|
protocol, site, mfile, j, k, l = urlparse(d)
|
||||||
if protocol == "file":
|
if protocol == "file":
|
||||||
mime = get_type(mfile)
|
name = url2pathname(mfile)
|
||||||
|
mime = get_type(name)
|
||||||
if not is_valid_type(mime):
|
if not is_valid_type(mime):
|
||||||
return
|
return
|
||||||
photo = MediaObject()
|
photo = MediaObject()
|
||||||
self.uistate.set_busy_cursor(True)
|
self.uistate.set_busy_cursor(True)
|
||||||
photo.set_checksum(create_checksum(mfile))
|
photo.set_checksum(create_checksum(name))
|
||||||
self.uistate.set_busy_cursor(False)
|
self.uistate.set_busy_cursor(False)
|
||||||
base_dir = cuni(media_path(self.dbstate.db))
|
base_dir = cuni(media_path(self.dbstate.db))
|
||||||
if os.path.exists(base_dir):
|
if os.path.exists(base_dir):
|
||||||
name = relative_path(mfile, base_dir)
|
name = relative_path(name, base_dir)
|
||||||
photo.set_path(name)
|
photo.set_path(name)
|
||||||
photo.set_mime_type(mime)
|
photo.set_mime_type(mime)
|
||||||
basename = os.path.basename(name)
|
basename = os.path.basename(name)
|
||||||
|
@ -58,7 +58,7 @@ from gi.repository import Gtk
|
|||||||
from gramps.gui.utils import open_file_with_default_application
|
from gramps.gui.utils import open_file_with_default_application
|
||||||
from gramps.gui.views.listview import ListView, TEXT, MARKUP, ICON
|
from gramps.gui.views.listview import ListView, TEXT, MARKUP, ICON
|
||||||
from gramps.gui.views.treemodels import MediaModel
|
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.config import config
|
||||||
from gramps.gen.utils.file import (media_path, relative_path, media_path_full,
|
from gramps.gen.utils.file import (media_path, relative_path, media_path_full,
|
||||||
create_checksum)
|
create_checksum)
|
||||||
@ -189,7 +189,7 @@ class MediaView(ListView):
|
|||||||
None)
|
None)
|
||||||
protocol, site, mfile, j, k, l = urlparse(clean_string)
|
protocol, site, mfile, j, k, l = urlparse(clean_string)
|
||||||
if protocol == "file":
|
if protocol == "file":
|
||||||
name = mfile
|
name = url2pathname(mfile)
|
||||||
mime = get_type(name)
|
mime = get_type(name)
|
||||||
if not is_valid_type(mime):
|
if not is_valid_type(mime):
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user