Fix drag/drop bug: allow multiple drop on gallery
svn: r14515
This commit is contained in:
parent
24bf1c6434
commit
528ba93613
@ -456,11 +456,14 @@ 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:
|
||||||
d = Utils.fix_encoding(sel_data.data.replace('\0',' ').strip())
|
#We assume this is for URI_LIST
|
||||||
|
for file in sel_data.get_uris():
|
||||||
|
d = Utils.fix_encoding(file.replace('\0',' ').strip())
|
||||||
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)
|
||||||
name = unicode(urllib.url2pathname(name.encode(sys.getfilesystemencoding())))
|
name = unicode(urllib.url2pathname(
|
||||||
|
name.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
|
||||||
@ -476,7 +479,6 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
|||||||
oref.set_reference_handle(photo.get_handle())
|
oref.set_reference_handle(photo.get_handle())
|
||||||
self.get_data().append(oref)
|
self.get_data().append(oref)
|
||||||
self.changed = True
|
self.changed = True
|
||||||
# self.dataobj.add_media_reference(oref)
|
|
||||||
self.dbstate.db.transaction_commit(trans,
|
self.dbstate.db.transaction_commit(trans,
|
||||||
_("Drag Media Object"))
|
_("Drag Media Object"))
|
||||||
self.rebuild()
|
self.rebuild()
|
||||||
|
@ -148,11 +148,12 @@ 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_ALL, dnd_types,
|
||||||
gtk.gdk.ACTION_COPY)
|
gtk.gdk.ACTION_PRIVATE)
|
||||||
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)
|
||||||
self.list.connect('drag_data_get', self.drag_data_get)
|
#connected in listview already
|
||||||
|
#self.list.connect('drag_data_get', self.drag_data_get)
|
||||||
self.list.connect('drag_data_received', self.drag_data_received)
|
self.list.connect('drag_data_received', self.drag_data_received)
|
||||||
|
|
||||||
def drag_data_get(self, widget, context, sel_data, info, time):
|
def drag_data_get(self, widget, context, sel_data, info, time):
|
||||||
@ -194,6 +195,8 @@ class MediaView(ListView):
|
|||||||
|
|
||||||
If the selection data is define, extract the value from sel_data.data,
|
If the selection data is define, extract the value from sel_data.data,
|
||||||
and decide if this is a move or a reorder.
|
and decide if this is a move or a reorder.
|
||||||
|
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:
|
if sel_data and sel_data.data:
|
||||||
cleaned_string = sel_data.data.replace('\0', ' ')
|
cleaned_string = sel_data.data.replace('\0', ' ')
|
||||||
|
Loading…
Reference in New Issue
Block a user