Fix bug: allow drop from Nautilius/Dolphin

svn: r14539
This commit is contained in:
Benny Malengier 2010-03-01 08:51:17 +00:00
parent 92b0b99e25
commit 9b30450f33
2 changed files with 31 additions and 25 deletions

View File

@ -456,14 +456,13 @@ class GalleryTab(ButtonTab, DbGUIElement):
elif self._DND_EXTRA and mytype == self._DND_EXTRA.drag_type:
self.handle_extra_type(mytype, obj)
except pickle.UnpicklingError:
#We assume this is for URI_LIST for Linux. For Windows split sel_data.data
#modern file managers provide URI_LIST. For Windows split sel_data.data
if constfunc.win():
files = sel_data.data.split('\n')
else:
files = sel_data.get_uris()
for file in files:
d = Utils.fix_encoding(file.replace('\0',' ').strip())
print repr(d)
protocol, site, mfile, j, k, l = urlparse.urlparse(d)
if protocol == "file":
name = Utils.fix_encoding(mfile)

View File

@ -147,8 +147,9 @@ class MediaView(ListView):
dnd_types = [ self._DND_TYPE.target() ]
self.list.drag_dest_set(gtk.DEST_DEFAULT_ALL, dnd_types,
gtk.gdk.ACTION_PRIVATE)
self.list.drag_dest_set(gtk.DEST_DEFAULT_MOTION|gtk.DEST_DEFAULT_DROP,
dnd_types,
gtk.gdk.ACTION_MOVE|gtk.gdk.ACTION_COPY)
self.list.drag_source_set(gtk.gdk.BUTTON1_MASK,
[self._DND_TYPE.target()],
gtk.gdk.ACTION_COPY)
@ -198,14 +199,20 @@ class MediaView(ListView):
The only data we accept on mediaview is dropping a file, so URI_LIST.
We assume this is what we obtain
"""
if sel_data and sel_data.data:
cleaned_string = sel_data.data.replace('\0', ' ')
cleaned_string = cleaned_string.replace("\r", " ").strip()
data_list = Utils.fix_encoding(cleaned_string).split('\n')
for d in [item.strip() for item in data_list]:
protocol, site, mfile, j, k, l = urlparse.urlparse(d)
if not sel_data:
return
#modern file managers provide URI_LIST. For Windows split sel_data.data
if constfunc.win():
files = sel_data.data.split('\n')
else:
files = sel_data.get_uris()
for file in files:
clean_string = Utils.fix_encoding(
file.replace('\0',' ').replace("\r", " ").strip())
protocol, site, mfile, j, k, l = urlparse.urlparse(clean_string)
if protocol == "file":
name = unicode(urllib.url2pathname(mfile.encode(sys.getfilesystemencoding())))
name = unicode(urllib.url2pathname(
mfile.encode(sys.getfilesystemencoding())))
mime = gen.mime.get_type(name)
if not gen.mime.is_valid_type(mime):
return