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: elif self._DND_EXTRA and mytype == self._DND_EXTRA.drag_type:
self.handle_extra_type(mytype, obj) self.handle_extra_type(mytype, obj)
except pickle.UnpicklingError: 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(): if constfunc.win():
files = sel_data.data.split('\n') files = sel_data.data.split('\n')
else: else:
files = sel_data.get_uris() files = sel_data.get_uris()
for file in files: for file in files:
d = Utils.fix_encoding(file.replace('\0',' ').strip()) d = Utils.fix_encoding(file.replace('\0',' ').strip())
print repr(d)
protocol, site, mfile, j, k, l = urlparse.urlparse(d) protocol, site, mfile, j, k, l = urlparse.urlparse(d)
if protocol == "file": if protocol == "file":
name = Utils.fix_encoding(mfile) name = Utils.fix_encoding(mfile)

View File

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