2006-08-13 Don Allingham <don@gramps-project.org>

* src/DataViews/_MediaView.py: fix drag-n-drop
	* src/DisplayTabs/_GalleryTab.py: handle media obj and media ref 
	for drag-n-drop
	* src/DdTargets.py: add media ref type



svn: r7169
This commit is contained in:
Don Allingham 2006-08-14 01:50:47 +00:00
parent f98617dbf7
commit ff0967e18d
5 changed files with 29 additions and 19 deletions

View File

@ -1,3 +1,9 @@
2006-08-13 Don Allingham <don@gramps-project.org>
* src/DataViews/_MediaView.py: fix drag-n-drop
* src/DisplayTabs/_GalleryTab.py: handle media obj and media ref
for drag-n-drop
* src/DdTargets.py: add media ref type
2006-08-12 Brian Matherly <brian@gramps-project.org> 2006-08-12 Brian Matherly <brian@gramps-project.org>
* src/plugins/FamilyGroup.py: use family_id instead of spouse_id * src/plugins/FamilyGroup.py: use family_id instead of spouse_id
* src/gramps.py: catch logging error and ignore. * src/gramps.py: catch logging error and ignore.

View File

@ -4,15 +4,15 @@ dnl Process this file with autoconf to produce a configure script.
dnl May need to run automake && aclocal first dnl May need to run automake && aclocal first
AC_PREREQ(2.57) AC_PREREQ(2.57)
AC_INIT(gramps, 2.1.95, [gramps-bugs@lists.sourceforge.net]) AC_INIT(gramps, 2.1.91, [gramps-bugs@lists.sourceforge.net])
AC_CONFIG_SRCDIR(configure.in) AC_CONFIG_SRCDIR(configure.in)
AM_INIT_AUTOMAKE(1.6.3) AM_INIT_AUTOMAKE(1.6.3)
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
GNOME_DOC_INIT GNOME_DOC_INIT
RELEASE=0.SVN$(svnversion -n .) dnl RELEASE=0.SVN$(svnversion -n .)
dnl RELEASE=1 RELEASE=1
VERSIONSTRING=$VERSION VERSIONSTRING=$VERSION
if test x"$RELEASE" != "x" if test x"$RELEASE" != "x"

View File

@ -27,6 +27,7 @@
from gettext import gettext as _ from gettext import gettext as _
import urlparse import urlparse
import os import os
import cPickle as pickle
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -128,17 +129,13 @@ class MediaView(PageView.ListView):
of the object of the object
""" """
# get the selected object, returning if not is defined selected_ids = self.selected_handles()
obj = self.get_selected()
if not obj:
return
# pickle the data, and build the tuple to be passed data = (self.drag_info().drag_type, id(self), selected_ids[0], 0)
value = (self._DND_TYPE.drag_type, id(self), obj, self.find_index(obj)) sel_data.set(sel_data.target, 8 ,pickle.dumps(data))
data = pickle.dumps(value)
# pass as a string (8 bits) def drag_info(self):
sel_data.set(sel_data.target, 8, data) return DdTargets.MEDIAOBJ
def find_index(self, obj): def find_index(self, obj):
""" """

View File

@ -117,6 +117,7 @@ class _DdTargets(object):
self.REPO_LINK = _DdType(self,'repo-link') self.REPO_LINK = _DdType(self,'repo-link')
self.NAME = _DdType(self,'name') self.NAME = _DdType(self,'name')
self.MEDIAOBJ = _DdType(self,'mediaobj') self.MEDIAOBJ = _DdType(self,'mediaobj')
self.MEDIAREF = _DdType(self,'mediaref')
self.DATA = _DdType(self,'data_tuple') self.DATA = _DdType(self,'data_tuple')
self.PERSON_LINK = _DdType(self,'person-link') self.PERSON_LINK = _DdType(self,'person-link')

View File

@ -66,7 +66,7 @@ def make_launcher(prog, path):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class GalleryTab(ButtonTab): class GalleryTab(ButtonTab):
_DND_TYPE = DdTargets.MEDIAOBJ _DND_TYPE = DdTargets.MEDIAREF
_DND_EXTRA = DdTargets.URI_LIST _DND_EXTRA = DdTargets.URI_LIST
def __init__(self, dbstate, uistate, track, media_list, update=None): def __init__(self, dbstate, uistate, track, media_list, update=None):
@ -276,10 +276,8 @@ class GalleryTab(ButtonTab):
variable defined that points to an entry in DdTargets. variable defined that points to an entry in DdTargets.
""" """
if self._DND_EXTRA: dnd_types = [ self._DND_TYPE.target(), self._DND_EXTRA.target(),
dnd_types = [ self._DND_TYPE.target(), self._DND_EXTRA.target() ] DdTargets.MEDIAOBJ.target()]
else:
dnd_types = [ self._DND_TYPE.target() ]
self.iconlist.drag_dest_set(gtk.DEST_DEFAULT_ALL, dnd_types, self.iconlist.drag_dest_set(gtk.DEST_DEFAULT_ALL, dnd_types,
gtk.gdk.ACTION_COPY) gtk.gdk.ACTION_COPY)
@ -305,7 +303,10 @@ class GalleryTab(ButtonTab):
""" """
# get the selected object, returning if not is defined # get the selected object, returning if not is defined
obj = self.get_selected()
reflist = self.iconlist.get_selected_items()
obj = self.media_list[reflist[0][0]]
if not obj: if not obj:
return return
@ -323,7 +324,6 @@ class GalleryTab(ButtonTab):
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.
""" """
if sel_data and sel_data.data: if sel_data and sel_data.data:
try: try:
(mytype, selfid, obj, row_from) = pickle.loads(sel_data.data) (mytype, selfid, obj, row_from) = pickle.loads(sel_data.data)
@ -354,6 +354,12 @@ class GalleryTab(ButtonTab):
else: else:
self._handle_drag(row, obj) self._handle_drag(row, obj)
self.rebuild() self.rebuild()
elif mytype == DdTargets.MEDIAOBJ.drag_type:
oref = RelLib.MediaRef()
oref.set_reference_handle(obj)
self.get_data().append(oref)
self.changed = True
self.rebuild()
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: