2005-04-01 Richard Taylor <rjt-gramps@thegrindstone.me.uk>

* src/plugins/ScratchPad.py (ScratchPadListView.register_wrapper_classes,
	ScratchPadName): added support for Names
	* src/EditPerson.py (EditPerson.__init__, EditPerson.name_drag_data_get,
	EditPerson.name_drag_begin, EditPerson.name_drag_data_received): added dnd for Names
	* src/DdTargets.py (_DdTargets.__init__, _DdTargets.all_gramps_types,
	_DdTargets.all_gramps_targets): added Names as dnd target.


svn: r4272
This commit is contained in:
Richard Taylor 2005-04-01 14:22:26 +00:00
parent 7263714a87
commit 3ee50ab98e
4 changed files with 100 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2005-04-01 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/plugins/ScratchPad.py (ScratchPadListView.register_wrapper_classes,
ScratchPadName): added support for Names
* src/EditPerson.py (EditPerson.__init__, EditPerson.name_drag_data_get,
EditPerson.name_drag_begin, EditPerson.name_drag_data_received): added dnd for Names
* src/DdTargets.py (_DdTargets.__init__, _DdTargets.all_gramps_types,
_DdTargets.all_gramps_targets): added Names as dnd target.
2005-04-01 Richard Taylor <rjt-gramps@thegrindstone.me.uk> 2005-04-01 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/plugins/ScratchPad.py: changed pickle to cPickle. cPickle is much faster. * src/plugins/ScratchPad.py: changed pickle to cPickle. cPickle is much faster.
* src/EditPerson.py: changed pickle to cPickle. cPickle is much faster. * src/EditPerson.py: changed pickle to cPickle. cPickle is much faster.

View File

@ -102,6 +102,7 @@ class _DdTargets(object):
self.ATTRIBUTE = _DdType(self,'pattr') self.ATTRIBUTE = _DdType(self,'pattr')
self.ADDRESS = _DdType(self,'paddr') self.ADDRESS = _DdType(self,'paddr')
self.SOURCEREF = _DdType(self,'srcref') self.SOURCEREF = _DdType(self,'srcref')
self.NAME = _DdType(self,'name')
self.FAMILY_EVENT = _DdType(self,'fevent') self.FAMILY_EVENT = _DdType(self,'fevent')
self.FAMILY_ATTRIBUTE = _DdType(self,'fattr') self.FAMILY_ATTRIBUTE = _DdType(self,'fattr')
@ -160,6 +161,7 @@ class _DdTargets(object):
self.ATTRIBUTE.drag_type, self.ATTRIBUTE.drag_type,
self.ADDRESS.drag_type, self.ADDRESS.drag_type,
self.SOURCEREF.drag_type, self.SOURCEREF.drag_type,
self.NAME.drag_type,
self.FAMILY_EVENT.drag_type, self.FAMILY_EVENT.drag_type,
self.FAMILY_ATTRIBUTE.drag_type) self.FAMILY_ATTRIBUTE.drag_type)
@ -182,6 +184,7 @@ class _DdTargets(object):
self.ATTRIBUTE.target(), self.ATTRIBUTE.target(),
self.ADDRESS.target(), self.ADDRESS.target(),
self.SOURCEREF.target(), self.SOURCEREF.target(),
self.NAME.target(),
self.FAMILY_EVENT.target(), self.FAMILY_EVENT.target(),
self.FAMILY_ATTRIBUTE.target()) self.FAMILY_ATTRIBUTE.target())

View File

@ -400,6 +400,17 @@ class EditPerson:
self.flowed.set_active(1) self.flowed.set_active(1)
Utils.bold_label(self.notes_label) Utils.bold_label(self.notes_label)
self.name_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
[DdTargets.NAME.target()],
ACTION_COPY)
self.name_list.drag_source_set(BUTTON1_MASK,
[DdTargets.NAME.target()],
ACTION_COPY)
self.name_list.connect('drag_data_get', self.name_drag_data_get)
self.name_list.connect('drag_begin', self.name_drag_begin)
self.name_list.connect('drag_data_received',
self.name_drag_data_received)
self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL, self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
[DdTargets.EVENT.target()], [DdTargets.EVENT.target()],
ACTION_COPY) ACTION_COPY)
@ -807,7 +818,47 @@ class EditPerson:
def set_lds_seal(self,obj): def set_lds_seal(self,obj):
self.lds_sealing.set_status(obj.get_active()) self.lds_sealing.set_status(obj.get_active())
def name_drag_data_get(self,widget, context, sel_data, info, time):
name = self.ntree.get_selected_objects()
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(name[0]);
data = str((DdTargets.NAME.drag_type,self.person.get_handle(),pickled));
sel_data.set(sel_data.target, bits_per, data)
def name_drag_begin(self, context, a):
return
icon = self.ntree.get_icon()
t = self.ntree.tree
(x,y) = icon.get_size()
mask = gtk.gdk.Pixmap(self.window.window,x,y,1)
mask.draw_rectangle(t.get_style().white_gc, True, 0,0,x,y)
t.drag_source_set_icon(t.get_colormap(),icon,mask)
def name_drag_data_received(self,widget,context,x,y,sel_data,info,time):
row = self.ntree.get_row_at(x,y)
if sel_data and sel_data.data:
exec 'data = %s' % sel_data.data
exec 'mytype = "%s"' % data[0]
exec 'person = "%s"' % data[1]
if mytype != DdTargets.NAME.drag_type:
return
elif person == self.person.get_handle():
self.move_element(self.nlist,self.ntree.get_selected_row(),row)
else:
foo = pickle.loads(data[2]);
for src in foo.get_source_references():
base_handle = src.get_base_handle()
newbase = self.db.get_source_from_handle(base_handle)
src.set_base_handle(newbase.get_handle())
self.nlist.insert(row,foo)
self.lists_changed = True
self.redraw_name_list()
def ev_drag_data_received(self,widget,context,x,y,sel_data,info,time): def ev_drag_data_received(self,widget,context,x,y,sel_data,info,time):
row = self.etree.get_row_at(x,y) row = self.etree.get_row_at(x,y)

View File

@ -351,6 +351,42 @@ class ScratchPadSourceRef(ScratchPadGrampsTypeWrapper):
return s return s
class ScratchPadName(ScratchPadGrampsTypeWrapper):
DROP_TARGETS = [DdTargets.NAME]
DRAG_TARGET = DdTargets.NAME
ICON = BLANK_PIC
def __init__(self,db,obj):
ScratchPadGrampsTypeWrapper.__init__(self,db,obj)
self._type = _("Name")
self._title = self._obj.get_name()
self._value = self._obj.get_type()
def tooltip(self):
global escape
s = "<big><b>%s</b></big>\n\n"\
"\t<b>%s:</b>\t%s\n"\
"\t<b>%s:</b>\t%s\n" % (
_("Name"),
_("Name"),escape(self._obj.get_name()),
_("Type"),escape(self._obj.get_type()))
if len(self._obj.get_source_references()) > 0:
psrc_ref = self._obj.get_source_references()[0]
psrc_id = psrc_ref.get_base_handle()
psrc = self._db.get_source_from_handle(psrc_id)
s += "\n<big><b>%s</b></big>\n\n"\
"\t<b>%s:</b>\t%s\n" % (
_("Primary source"),
_("Name"),
escape(short(psrc.get_title())))
return s
class ScratchPadText(ScratchPadWrapper): class ScratchPadText(ScratchPadWrapper):
DROP_TARGETS = DdTargets.all_text() DROP_TARGETS = DdTargets.all_text()
@ -460,6 +496,7 @@ class ScratchPadListView:
self.register_wrapper_class(ScratchPadAttribute) self.register_wrapper_class(ScratchPadAttribute)
self.register_wrapper_class(ScratchPadFamilyAttribute) self.register_wrapper_class(ScratchPadFamilyAttribute)
self.register_wrapper_class(ScratchPadSourceRef) self.register_wrapper_class(ScratchPadSourceRef)
self.register_wrapper_class(ScratchPadName)
self.register_wrapper_class(ScratchPadText) self.register_wrapper_class(ScratchPadText)
def register_wrapper_class(self,wrapper_class): def register_wrapper_class(self,wrapper_class):