4788: Fix drag-and-drop of files onto the media view
svn: r17085
This commit is contained in:
parent
f08d0442e2
commit
0380d94a46
@ -153,9 +153,17 @@ class ListView(NavigationView):
|
||||
else:
|
||||
# Tree
|
||||
self.list.connect('key-press-event', self._key_press_tree)
|
||||
|
||||
if self.drag_info():
|
||||
self.list.connect('drag_data_get', self.drag_data_get)
|
||||
self.list.connect('drag_begin', self.drag_begin)
|
||||
if self.drag_dest_info():
|
||||
self.list.connect('drag_data_received', self.drag_data_received)
|
||||
self.list.drag_dest_set(gtk.DEST_DEFAULT_MOTION |
|
||||
gtk.DEST_DEFAULT_DROP,
|
||||
[self.drag_dest_info().target()],
|
||||
gtk.gdk.ACTION_MOVE |
|
||||
gtk.gdk.ACTION_COPY)
|
||||
|
||||
scrollwindow = gtk.ScrolledWindow()
|
||||
scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
@ -409,6 +417,9 @@ class ListView(NavigationView):
|
||||
####################################################################
|
||||
|
||||
def drag_info(self):
|
||||
"""
|
||||
Specify the drag type for a single selected row
|
||||
"""
|
||||
return None
|
||||
|
||||
def drag_list_info(self):
|
||||
@ -417,6 +428,12 @@ class ListView(NavigationView):
|
||||
"""
|
||||
return DdTargets.LINK_LIST
|
||||
|
||||
def drag_dest_info(self):
|
||||
"""
|
||||
Specify the drag type for objects dropped on the view
|
||||
"""
|
||||
return None
|
||||
|
||||
def drag_begin(self, widget, context):
|
||||
widget.drag_source_set_icon_stock(self.get_stock())
|
||||
return True
|
||||
|
@ -113,8 +113,6 @@ class MediaView(ListView):
|
||||
FILTER_TYPE = 'MediaObject'
|
||||
QR_CATEGORY = CATEGORY_QR_MEDIA
|
||||
|
||||
_DND_TYPE = DdTargets.URI_LIST
|
||||
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
|
||||
signal_map = {
|
||||
@ -144,25 +142,6 @@ class MediaView(ListView):
|
||||
def navigation_type(self):
|
||||
return 'Media'
|
||||
|
||||
def _set_dnd(self):
|
||||
"""
|
||||
Set up drag-n-drop. The source and destination are set by calling .target()
|
||||
on the _DND_TYPE. Obviously, this means that there must be a _DND_TYPE
|
||||
variable defined that points to an entry in DdTargets.
|
||||
"""
|
||||
|
||||
dnd_types = [ self._DND_TYPE.target() ]
|
||||
|
||||
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)
|
||||
#connected in listview already
|
||||
#self.list.connect('drag_data_get', self.drag_data_get)
|
||||
self.list.connect('drag_data_received', self.drag_data_received)
|
||||
|
||||
def drag_info(self):
|
||||
"""
|
||||
Return the type of DND targets that this view will accept. For Media
|
||||
@ -170,6 +149,12 @@ class MediaView(ListView):
|
||||
"""
|
||||
return DdTargets.MEDIAOBJ
|
||||
|
||||
def drag_dest_info(self):
|
||||
"""
|
||||
Specify the drag type for objects dropped on the view
|
||||
"""
|
||||
return DdTargets.URI_LIST
|
||||
|
||||
def find_index(self, obj):
|
||||
"""
|
||||
returns the index of the object within the associated data
|
||||
|
Loading…
Reference in New Issue
Block a user