2005-08-10 19:58:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-06-29 04:01:55 +05:30
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
2005-08-10 19:58:16 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modiy
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# standard python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import cPickle as pickle
|
|
|
|
import os
|
|
|
|
from xml.sax.saxutils import escape
|
2006-03-23 11:40:45 +05:30
|
|
|
from time import strftime as strftime
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
2007-12-22 03:46:28 +05:30
|
|
|
from gtk.gdk import ACTION_COPY, BUTTON1_MASK, ACTION_MOVE
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
2009-10-08 06:42:51 +05:30
|
|
|
import config
|
2007-10-08 22:11:39 +05:30
|
|
|
import gen.lib
|
2005-08-17 19:21:53 +05:30
|
|
|
import DateHandler
|
2005-12-30 00:06:59 +05:30
|
|
|
import GrampsDisplay
|
2006-04-21 09:44:00 +05:30
|
|
|
import ManagedWindow
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import sgettext as _
|
2010-02-10 22:35:55 +05:30
|
|
|
from constfunc import mac
|
2009-05-15 01:45:59 +05:30
|
|
|
from glade import Glade
|
2005-08-10 19:58:16 +05:30
|
|
|
from DdTargets import DdTargets
|
|
|
|
|
2008-04-15 23:29:50 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-02-26 15:27:08 +05:30
|
|
|
WIKI_HELP_PAGE = '%s_-_Navigation' % const.URL_MANUAL_PAGE
|
2008-04-15 23:29:50 +05:30
|
|
|
WIKI_HELP_SEC = _('manual|Using_the_Clipboard')
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# icons used in the object listing
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2007-09-08 11:24:02 +05:30
|
|
|
_stock_image = os.path.join(const.IMAGE_DIR,'stock_link.png')
|
2006-03-05 04:23:46 +05:30
|
|
|
LINK_PIC = gtk.gdk.pixbuf_new_from_file(_stock_image)
|
2010-07-29 13:31:24 +05:30
|
|
|
ICONS = {}
|
|
|
|
for (name, file) in (
|
|
|
|
("media", "gramps-media.png"),
|
|
|
|
("note", "gramps-notes.png"),
|
|
|
|
("person", "gramps-person.png"),
|
|
|
|
("place", "gramps-place.png"),
|
|
|
|
('address', 'gramps-address.png'),
|
|
|
|
('attribute', 'gramps-attribute.png'),
|
|
|
|
('event', 'gramps-event.png'),
|
|
|
|
('family', 'gramps-family.png'),
|
|
|
|
('location', 'geo-place-link.png'),
|
|
|
|
('media', 'gramps-media.png'),
|
|
|
|
('name', 'geo-show-person.png'),
|
|
|
|
('repository', 'gramps-repository.png'),
|
|
|
|
('source', 'gramps-source.png'),
|
|
|
|
('text', 'gramps-font.png'),
|
|
|
|
('url', 'gramps-geo.png'),
|
|
|
|
):
|
|
|
|
_image = os.path.join(const.IMAGE_DIR, '16x16', file)
|
|
|
|
ICONS[name] = gtk.gdk.pixbuf_new_from_file(_image)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# wrapper classes to provide object specific listing in the ListView
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class ScratchPadWrapper(object):
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def __init__(self,dbstate, obj):
|
2006-11-01 19:11:09 +05:30
|
|
|
dbstate.connect('database-changed', self.database_changed)
|
|
|
|
self.database_changed(dbstate.db)
|
2005-08-10 19:58:16 +05:30
|
|
|
self._obj = obj
|
2010-07-28 20:34:45 +05:30
|
|
|
self._pickle = obj
|
2005-08-10 19:58:16 +05:30
|
|
|
self._type = _("Unknown")
|
2010-07-29 13:31:24 +05:30
|
|
|
self._objclass = None
|
|
|
|
self._handle = None
|
2010-07-28 20:34:45 +05:30
|
|
|
self._title = _('Unavailable')
|
|
|
|
self._value = _('Unavailable')
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def database_changed(self,db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def get_type(self):
|
|
|
|
return self._type
|
|
|
|
|
|
|
|
def get_title(self):
|
|
|
|
return self._title
|
|
|
|
|
|
|
|
def get_value(self):
|
|
|
|
return self._value
|
|
|
|
|
|
|
|
def pack(self):
|
|
|
|
return str(self._obj)
|
|
|
|
|
2005-08-17 19:21:53 +05:30
|
|
|
def is_valid(self):
|
|
|
|
return True
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2005-08-17 19:21:53 +05:30
|
|
|
class ScratchPadGrampsTypeWrapper(ScratchPadWrapper):
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def __init__(self,dbstate, obj):
|
|
|
|
ScratchPadWrapper.__init__(self,dbstate, obj)
|
2005-08-10 19:58:16 +05:30
|
|
|
#unpack object
|
2006-03-23 04:33:57 +05:30
|
|
|
(drag_type, idval, self._obj, val) = pickle.loads(obj)
|
2005-08-10 19:58:16 +05:30
|
|
|
self._pickle = obj
|
|
|
|
|
|
|
|
def pack(self):
|
|
|
|
return self._pickle
|
|
|
|
|
2005-08-17 19:21:53 +05:30
|
|
|
def is_valid(self):
|
|
|
|
valid_func_map = {'Person': self._db.get_person_from_handle,
|
|
|
|
'Family': self._db.get_family_from_handle,
|
|
|
|
'Event': self._db.get_event_from_handle,
|
|
|
|
'Place': self._db.get_place_from_handle,
|
|
|
|
'MediaObject': self._db.get_object_from_handle,
|
|
|
|
'Source': self._db.get_source_from_handle}
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
for (classname, handle) in self._obj.get_referenced_handles_recursively():
|
2009-05-23 00:13:40 +05:30
|
|
|
if classname in valid_func_map:
|
2005-08-17 19:21:53 +05:30
|
|
|
if not valid_func_map[classname](handle):
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
class ScratchPadAddress(ScratchPadGrampsTypeWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.ADDRESS]
|
|
|
|
DRAG_TARGET = DdTargets.ADDRESS
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS['address']
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def __init__(self,dbstate, obj):
|
|
|
|
ScratchPadGrampsTypeWrapper.__init__(self,dbstate, obj)
|
2005-08-10 19:58:16 +05:30
|
|
|
self._type = _("Address")
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
|
|
|
|
|
|
|
def reset(self):
|
2005-08-17 19:21:53 +05:30
|
|
|
self._title = DateHandler.get_date(self._obj)
|
2005-08-10 19:58:16 +05:30
|
|
|
self._value = "%s %s %s %s" % (self._obj.get_street(),self._obj.get_city(),
|
|
|
|
self._obj.get_state(),self._obj.get_country())
|
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2005-08-10 19:58:16 +05:30
|
|
|
s = "<big><b>%s</b></big>\n\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\n"\
|
|
|
|
"\t\t%s\n"\
|
|
|
|
"\t\t%s\n"\
|
|
|
|
"\t\t%s\n"\
|
|
|
|
"\t\t%s\n"\
|
|
|
|
"\t\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n" % (
|
|
|
|
_("Address"),
|
2005-08-17 19:21:53 +05:30
|
|
|
_("Date"), escape(DateHandler.get_date(self._obj)),
|
2005-08-10 19:58:16 +05:30
|
|
|
_("Location"),
|
|
|
|
escape(self._obj.get_street()),
|
|
|
|
escape(self._obj.get_city()),
|
|
|
|
escape(self._obj.get_state()),
|
|
|
|
escape(self._obj.get_country()),
|
|
|
|
escape(self._obj.get_postal_code()),
|
|
|
|
_("Telephone"), escape(self._obj.get_phone()))
|
|
|
|
|
|
|
|
if len(self._obj.get_source_references()) > 0:
|
|
|
|
psrc_ref = self._obj.get_source_references()[0]
|
2006-05-23 05:26:57 +05:30
|
|
|
psrc_id = psrc_ref.get_reference_handle()
|
2005-08-10 19:58:16 +05:30
|
|
|
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" % (
|
|
|
|
_("Sources"),
|
|
|
|
_("Name"),escape(short(psrc.get_title())))
|
|
|
|
|
|
|
|
return s
|
|
|
|
|
2006-03-23 22:11:51 +05:30
|
|
|
class ScratchPadLocation(ScratchPadGrampsTypeWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.LOCATION]
|
|
|
|
DRAG_TARGET = DdTargets.LOCATION
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS['location']
|
2006-03-23 22:11:51 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def __init__(self,dbstate, obj):
|
|
|
|
ScratchPadGrampsTypeWrapper.__init__(self,dbstate, obj)
|
2006-03-23 22:11:51 +05:30
|
|
|
self._type = _("Location")
|
|
|
|
self._value = "%s %s %s" % (self._obj.get_city(),
|
|
|
|
self._obj.get_state(),self._obj.get_country())
|
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2006-03-23 22:11:51 +05:30
|
|
|
s = "<big><b>%s</b></big>\n\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\n"\
|
|
|
|
"\t\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n" % (
|
|
|
|
_("Location"),
|
|
|
|
escape(self._obj.get_city()),
|
|
|
|
escape(self._obj.get_state()),
|
|
|
|
escape(self._obj.get_country()),
|
|
|
|
escape(self._obj.get_postal_code()),
|
|
|
|
_("Telephone"), escape(self._obj.get_phone()))
|
|
|
|
|
|
|
|
return s
|
|
|
|
|
2006-03-23 04:33:57 +05:30
|
|
|
class ScratchPadEvent(ScratchPadWrapper):
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.EVENT]
|
|
|
|
DRAG_TARGET = DdTargets.EVENT
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS["event"]
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def __init__(self,dbstate, obj):
|
|
|
|
ScratchPadWrapper.__init__(self,dbstate, obj)
|
2010-07-28 20:34:45 +05:30
|
|
|
self._type = _("Event")
|
2010-07-29 13:31:24 +05:30
|
|
|
self._objclass = 'Event'
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
2006-03-23 04:33:57 +05:30
|
|
|
|
2010-07-28 20:34:45 +05:30
|
|
|
def reset(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
|
|
|
value = self._db.get_event_from_handle(self._handle)
|
2010-07-28 20:34:45 +05:30
|
|
|
if value:
|
|
|
|
self._title = str(value.get_type())
|
|
|
|
self._value = value.get_description()
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2008-01-18 01:54:44 +05:30
|
|
|
# there are several errors in the below which all cause gramps to
|
|
|
|
# crash
|
|
|
|
|
|
|
|
# s = "<big><b>%s</b></big>\n\n"\
|
|
|
|
# "\t<b>%s:</b>\t%s\n"\
|
|
|
|
# "\t<b>%s:</b>\t%s\n"\
|
|
|
|
# "\t<b>%s:</b>\t%s\n"\
|
|
|
|
# "\t<b>%s:</b>\t%s\n"\
|
|
|
|
# "\t<b>%s:</b>\t%s\n" % (
|
|
|
|
# _("Event"),
|
|
|
|
# _("Type"),escape(Utils.format_personal_event(self._obj.get_name())),
|
|
|
|
# _("Date"),escape(DateHander.get_date(self._obj)),
|
|
|
|
# _("Place"),escape(place_title(self._db,self._obj)),
|
|
|
|
# _("Cause"),escape(self._obj.get_cause()),
|
|
|
|
# _("Description"), escape(self._obj.get_description()))
|
|
|
|
# if len(self._obj.get_source_references()) > 0:
|
|
|
|
# psrc_ref = self._obj.get_source_references()[0]
|
|
|
|
# psrc_id = psrc_ref.get_reference_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())))
|
|
|
|
s = ""
|
2007-01-30 18:37:21 +05:30
|
|
|
return s
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def is_valid(self):
|
|
|
|
data = pickle.loads(self._obj)
|
|
|
|
handle = data[2]
|
2006-11-01 20:39:14 +05:30
|
|
|
obj = self._db.get_event_from_handle(handle)
|
|
|
|
if obj:
|
2006-11-01 19:11:09 +05:30
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2006-11-06 04:41:02 +05:30
|
|
|
class ScratchPadPlace(ScratchPadWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.PLACE_LINK]
|
|
|
|
DRAG_TARGET = DdTargets.PLACE_LINK
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS["place"]
|
2006-11-06 04:41:02 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def __init__(self,dbstate, obj):
|
|
|
|
ScratchPadWrapper.__init__(self,dbstate, obj)
|
2006-11-06 04:41:02 +05:30
|
|
|
self._type = _("Place")
|
2010-07-29 13:31:24 +05:30
|
|
|
self._objclass = 'Place'
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
2006-11-06 04:41:02 +05:30
|
|
|
|
2010-07-28 20:34:45 +05:30
|
|
|
def reset(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
|
|
|
value = self._db.get_place_from_handle(self._handle)
|
2010-07-28 20:34:45 +05:30
|
|
|
if value:
|
2010-07-31 07:41:47 +05:30
|
|
|
self._title = value.gramps_id
|
|
|
|
self._value = value.get_title()
|
2006-11-06 04:41:02 +05:30
|
|
|
|
|
|
|
def tooltip(self):
|
|
|
|
return ""
|
|
|
|
|
|
|
|
def is_valid(self):
|
|
|
|
data = pickle.loads(self._obj)
|
|
|
|
handle = data[2]
|
|
|
|
obj = self._db.get_place_from_handle(handle)
|
|
|
|
if obj:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2007-03-28 21:57:45 +05:30
|
|
|
class ScratchPadNote(ScratchPadWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.NOTE_LINK]
|
|
|
|
DRAG_TARGET = DdTargets.NOTE_LINK
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS["note"]
|
2007-03-28 21:57:45 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def __init__(self,dbstate, obj):
|
|
|
|
ScratchPadWrapper.__init__(self,dbstate, obj)
|
2007-03-28 21:57:45 +05:30
|
|
|
self._type = _("Note")
|
2010-07-29 13:31:24 +05:30
|
|
|
self._objclass = 'Note'
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
2007-03-28 21:57:45 +05:30
|
|
|
|
2010-07-28 20:34:45 +05:30
|
|
|
def reset(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
|
|
|
value = self._db.get_note_from_handle(self._handle)
|
2010-07-28 20:34:45 +05:30
|
|
|
if value:
|
|
|
|
self._title = value.get_gramps_id()
|
|
|
|
note = value.get().replace('\n', ' ')
|
|
|
|
#String must be unicode for truncation to work for non ascii characters
|
|
|
|
note = unicode(note)
|
|
|
|
if len(note) > 80:
|
|
|
|
self._value = note[:80]+"..."
|
|
|
|
else:
|
|
|
|
self._value = note
|
2007-03-28 21:57:45 +05:30
|
|
|
|
|
|
|
def tooltip(self):
|
|
|
|
return ""
|
|
|
|
|
|
|
|
def is_valid(self):
|
|
|
|
data = pickle.loads(self._obj)
|
|
|
|
handle = data[2]
|
|
|
|
obj = self._db.get_note_from_handle(handle)
|
|
|
|
if obj:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
class ScratchPadFamilyEvent(ScratchPadGrampsTypeWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.FAMILY_EVENT]
|
|
|
|
DRAG_TARGET = DdTargets.FAMILY_EVENT
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS['family']
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2006-04-23 09:59:14 +05:30
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
|
2005-08-10 19:58:16 +05:30
|
|
|
self._type = _("Family Event")
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
|
|
|
|
|
|
|
def reset(self):
|
2006-04-21 09:44:00 +05:30
|
|
|
self._title = str(self._obj.get_type())
|
2005-08-10 19:58:16 +05:30
|
|
|
self._value = self._obj.get_description()
|
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2005-08-10 19:58:16 +05:30
|
|
|
s = "<big><b>%s</b></big>\n\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n" % (
|
|
|
|
_("Family Event"),
|
2006-04-21 09:44:00 +05:30
|
|
|
_("Type"),escape(str(self._obj.get_type())),
|
|
|
|
_("Date"),escape(DateHandler.get_date(self._obj)),
|
2006-04-23 09:59:14 +05:30
|
|
|
_("Place"),escape(place_title(self._db, self._obj)),
|
2005-08-10 19:58:16 +05:30
|
|
|
_("Cause"),escape(self._obj.get_cause()),
|
|
|
|
_("Description"), escape(self._obj.get_description()))
|
|
|
|
|
|
|
|
if len(self._obj.get_source_references()) > 0:
|
|
|
|
psrc_ref = self._obj.get_source_references()[0]
|
2006-05-23 05:26:57 +05:30
|
|
|
psrc_id = psrc_ref.get_reference_handle()
|
2005-08-10 19:58:16 +05:30
|
|
|
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 ScratchPadUrl(ScratchPadGrampsTypeWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.URL]
|
|
|
|
DRAG_TARGET = DdTargets.URL
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS['url']
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def __init__(self,dbstate, obj):
|
|
|
|
ScratchPadGrampsTypeWrapper.__init__(self,dbstate, obj)
|
2005-08-10 19:58:16 +05:30
|
|
|
self._type = _("Url")
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
|
|
|
|
|
|
|
def reset(self):
|
2005-08-10 19:58:16 +05:30
|
|
|
self._title = self._obj.get_path()
|
|
|
|
self._value = self._obj.get_description()
|
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2005-08-10 19:58:16 +05:30
|
|
|
return "<big><b>%s</b></big>\n\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s" % (_("Url"),
|
|
|
|
_("Path"),
|
|
|
|
escape(self._obj.get_path()),
|
|
|
|
_("Description"),
|
|
|
|
escape(self._obj.get_description()))
|
|
|
|
|
|
|
|
class ScratchPadAttribute(ScratchPadGrampsTypeWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.ATTRIBUTE]
|
|
|
|
DRAG_TARGET = DdTargets.ATTRIBUTE
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS['attribute']
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
|
2005-08-10 19:58:16 +05:30
|
|
|
self._type = _("Attribute")
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
|
|
|
|
|
|
|
def reset(self):
|
2006-04-23 09:59:14 +05:30
|
|
|
self._title = str(self._obj.get_type())
|
2005-08-10 19:58:16 +05:30
|
|
|
self._value = self._obj.get_value()
|
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2005-08-10 19:58:16 +05:30
|
|
|
s = "<big><b>%s</b></big>\n\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s" % (_("Attribute"),
|
|
|
|
_("Type"),
|
2006-04-23 09:59:14 +05:30
|
|
|
escape(str(self._obj.get_type())),
|
2005-08-10 19:58:16 +05:30
|
|
|
_("Value"),
|
|
|
|
escape(self._obj.get_value()))
|
|
|
|
|
|
|
|
if len(self._obj.get_source_references()) > 0:
|
|
|
|
psrc_ref = self._obj.get_source_references()[0]
|
2006-05-23 05:26:57 +05:30
|
|
|
psrc_id = psrc_ref.get_reference_handle()
|
2005-08-10 19:58:16 +05:30
|
|
|
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" % (
|
|
|
|
_("Sources"),
|
|
|
|
_("Name"),escape(short(psrc.get_title())))
|
|
|
|
|
|
|
|
return s
|
|
|
|
|
|
|
|
class ScratchPadFamilyAttribute(ScratchPadGrampsTypeWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.FAMILY_ATTRIBUTE]
|
|
|
|
DRAG_TARGET = DdTargets.FAMILY_ATTRIBUTE
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS['attribute']
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
|
2005-08-10 19:58:16 +05:30
|
|
|
self._type = _("Family Attribute")
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
|
|
|
|
|
|
|
def reset(self):
|
2006-04-23 09:59:14 +05:30
|
|
|
self._title = str(self._obj.get_type())
|
2005-08-10 19:58:16 +05:30
|
|
|
self._value = self._obj.get_value()
|
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2005-08-10 19:58:16 +05:30
|
|
|
s = "<big><b>%s</b></big>\n\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s" % (_("Family Attribute"),
|
|
|
|
_("Type"),
|
2006-04-23 09:59:14 +05:30
|
|
|
escape(str(self._obj.get_type())),
|
2005-08-10 19:58:16 +05:30
|
|
|
_("Value"),
|
|
|
|
escape(self._obj.get_value()))
|
|
|
|
|
|
|
|
if len(self._obj.get_source_references()) > 0:
|
|
|
|
psrc_ref = self._obj.get_source_references()[0]
|
2006-05-23 05:26:57 +05:30
|
|
|
psrc_id = psrc_ref.get_reference_handle()
|
2005-08-10 19:58:16 +05:30
|
|
|
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" % (
|
|
|
|
_("Sources"),
|
|
|
|
_("Name"),escape(short(psrc.get_title())))
|
|
|
|
|
|
|
|
return s
|
|
|
|
|
|
|
|
class ScratchPadSourceRef(ScratchPadGrampsTypeWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.SOURCEREF]
|
|
|
|
DRAG_TARGET = DdTargets.SOURCEREF
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = LINK_PIC
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
|
2006-03-23 04:33:57 +05:30
|
|
|
self._type = _("Source Reference")
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2010-07-28 20:34:45 +05:30
|
|
|
def reset(self):
|
2006-05-23 05:26:57 +05:30
|
|
|
base = self._db.get_source_from_handle(self._obj.get_reference_handle())
|
2010-07-28 20:34:45 +05:30
|
|
|
if base:
|
|
|
|
self._title = base.get_title()
|
|
|
|
notelist = map(self._db.get_note_from_handle, self._obj.get_note_list())
|
|
|
|
srctxtlist = [ note for note in notelist
|
|
|
|
if note.get_type() == gen.lib.NoteType.SOURCE_TEXT]
|
|
|
|
page = self._obj.get_page()
|
|
|
|
if not page:
|
|
|
|
page = _('not available|NA')
|
|
|
|
text = ""
|
|
|
|
if len(srctxtlist) > 0:
|
|
|
|
text = " ".join(srctxtlist[0].get().split())
|
|
|
|
#String must be unicode for truncation to work for non ascii characters
|
|
|
|
text = unicode(text)
|
|
|
|
if len(text) > 60:
|
|
|
|
text = text[:60]+"..."
|
|
|
|
self._value = _("Volume/Page: %(pag)s -- %(sourcetext)s") % {
|
|
|
|
'pag' : page,
|
|
|
|
'sourcetext' : text,
|
|
|
|
}
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2006-05-23 05:26:57 +05:30
|
|
|
base = self._db.get_source_from_handle(self._obj.get_reference_handle())
|
2005-08-10 19:58:16 +05:30
|
|
|
s = "<big><b>%s</b></big>\n\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
2007-07-19 09:18:38 +05:30
|
|
|
"\t<b>%s:</b>\t%s" % \
|
|
|
|
(_("Source Reference"),
|
|
|
|
_("Title"),escape(base.get_title()),
|
|
|
|
_("Page"), escape(self._obj.get_page()))
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
return s
|
|
|
|
|
2006-03-23 10:49:38 +05:30
|
|
|
class ScratchPadRepoRef(ScratchPadGrampsTypeWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.REPOREF]
|
|
|
|
DRAG_TARGET = DdTargets.REPOREF
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = LINK_PIC
|
2006-03-23 10:49:38 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
|
2006-03-23 10:49:38 +05:30
|
|
|
self._type = _("Repository Reference")
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
2006-03-23 10:49:38 +05:30
|
|
|
|
2010-07-28 20:34:45 +05:30
|
|
|
def reset(self):
|
2006-03-23 10:49:38 +05:30
|
|
|
base = self._db.get_repository_from_handle(self._obj.ref)
|
2010-07-28 20:34:45 +05:30
|
|
|
if base:
|
2010-07-31 07:41:47 +05:30
|
|
|
self._title = str(base.get_type())
|
|
|
|
self._value = base.get_name()
|
2006-03-23 10:49:38 +05:30
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2007-01-30 18:37:21 +05:30
|
|
|
base = self._db.get_repository_from_handle(self._obj.get_reference_handle())
|
|
|
|
s = "<big><b>%s</b></big>\n\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s" % (
|
|
|
|
_("Repository Reference"),
|
|
|
|
_("Name"),escape(base.get_name()),
|
|
|
|
_("Call Number"), escape(self._obj.get_call_number()),
|
2007-07-19 09:18:38 +05:30
|
|
|
_("Media Type"), escape(self._obj.get_media_type().__str__()))
|
2007-01-30 18:37:21 +05:30
|
|
|
|
|
|
|
return s
|
2006-03-23 10:49:38 +05:30
|
|
|
|
2006-03-23 04:33:57 +05:30
|
|
|
class ScratchPadEventRef(ScratchPadGrampsTypeWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.EVENTREF]
|
|
|
|
DRAG_TARGET = DdTargets.EVENTREF
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = LINK_PIC
|
2006-03-23 04:33:57 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
|
2006-10-28 09:23:46 +05:30
|
|
|
self._type = _("Event Reference")
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
2006-03-23 04:33:57 +05:30
|
|
|
|
2010-07-28 20:34:45 +05:30
|
|
|
def reset(self):
|
2006-03-23 04:33:57 +05:30
|
|
|
base = self._db.get_event_from_handle(self._obj.ref)
|
2010-07-28 20:34:45 +05:30
|
|
|
if base:
|
2010-07-31 07:41:47 +05:30
|
|
|
self._title = base.gramps_id
|
2010-07-28 20:34:45 +05:30
|
|
|
self._value = str(base.get_type())
|
2006-03-23 04:33:57 +05:30
|
|
|
|
|
|
|
def tooltip(self):
|
|
|
|
return ""
|
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
class ScratchPadName(ScratchPadGrampsTypeWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.NAME]
|
|
|
|
DRAG_TARGET = DdTargets.NAME
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS['name']
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
|
2005-08-10 19:58:16 +05:30
|
|
|
self._type = _("Name")
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
|
|
|
|
|
|
|
def reset(self):
|
2010-07-31 07:41:47 +05:30
|
|
|
self._title = str(self._obj.get_type())
|
|
|
|
self._value = self._obj.get_name()
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2005-08-10 19:58:16 +05:30
|
|
|
s = "<big><b>%s</b></big>\n\n"\
|
2007-01-30 18:37:21 +05:30
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
2005-08-10 19:58:16 +05:30
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n" % (
|
|
|
|
_("Name"),
|
|
|
|
_("Name"),escape(self._obj.get_name()),
|
2007-01-30 18:37:21 +05:30
|
|
|
_("Call Name"),escape(self._obj.get_call_name()),
|
|
|
|
_("Given"),escape(self._obj.get_first_name()),
|
|
|
|
_("Family"),escape(self._obj.get_surname()),
|
|
|
|
_("Patronymic"),escape(self._obj.get_patronymic()),
|
|
|
|
_("Prefix"),escape(self._obj.get_surname_prefix()),
|
2009-02-12 13:01:08 +05:30
|
|
|
_("Person|Title"),escape(self._obj.get_title()),
|
2007-01-30 18:37:21 +05:30
|
|
|
_("Suffix"),escape(self._obj.get_suffix()),
|
|
|
|
_("Type"),escape(self._obj.get_type().__str__()),
|
|
|
|
)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
if len(self._obj.get_source_references()) > 0:
|
|
|
|
psrc_ref = self._obj.get_source_references()[0]
|
2006-05-23 05:26:57 +05:30
|
|
|
psrc_id = psrc_ref.get_reference_handle()
|
2005-08-10 19:58:16 +05:30
|
|
|
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):
|
|
|
|
|
|
|
|
DROP_TARGETS = DdTargets.all_text()
|
|
|
|
DRAG_TARGET = DdTargets.TEXT
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS['text']
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadWrapper.__init__(self, dbstate, obj)
|
2005-08-10 19:58:16 +05:30
|
|
|
self._type = _("Text")
|
2010-07-31 07:41:47 +05:30
|
|
|
self._title = _("Text")
|
2005-08-10 19:58:16 +05:30
|
|
|
self._value = self._obj
|
2010-07-28 20:34:45 +05:30
|
|
|
self._pickle = self._obj
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2005-08-10 19:58:16 +05:30
|
|
|
return "<big><b>%s</b></big>\n"\
|
|
|
|
"%s" % (_("Text"),
|
|
|
|
escape(self._obj))
|
|
|
|
|
|
|
|
class ScratchMediaObj(ScratchPadWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.MEDIAOBJ]
|
|
|
|
DRAG_TARGET = DdTargets.MEDIAOBJ
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS["media"]
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadWrapper.__init__(self, dbstate, obj)
|
2010-07-28 20:34:45 +05:30
|
|
|
self._type = _("Media")
|
2010-07-29 13:31:24 +05:30
|
|
|
self._objclass = 'Media'
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
2006-09-04 03:44:47 +05:30
|
|
|
|
2010-07-28 20:34:45 +05:30
|
|
|
def reset(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
|
|
|
obj = self._db.get_object_from_handle(self._handle)
|
2010-07-28 20:34:45 +05:30
|
|
|
if obj:
|
|
|
|
self._title = obj.get_description()
|
|
|
|
self._value = obj.get_path()
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2007-01-30 18:37:21 +05:30
|
|
|
(drag_type, idval, handle, val) = pickle.loads(self._obj)
|
|
|
|
obj = self._db.get_object_from_handle(handle)
|
|
|
|
return "<big><b>%s</b></big>\n\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
2010-07-28 20:34:45 +05:30
|
|
|
"\t<b>%s:</b>\t%s\n" % (_("Media"),
|
2007-01-30 18:37:21 +05:30
|
|
|
_("Title"),escape(obj.get_description()),
|
|
|
|
_("Type"),escape(obj.get_mime_type()),
|
|
|
|
_("Name"),escape(obj.get_path()))
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def is_valid(self):
|
|
|
|
data = pickle.loads(self._obj)
|
|
|
|
handle = data[2]
|
2006-11-01 20:39:14 +05:30
|
|
|
obj = self._db.get_object_from_handle(handle)
|
2006-11-01 19:11:09 +05:30
|
|
|
if obj:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2006-09-04 03:44:47 +05:30
|
|
|
class ScratchPadMediaRef(ScratchPadGrampsTypeWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.MEDIAREF]
|
|
|
|
DRAG_TARGET = DdTargets.MEDIAREF
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = LINK_PIC
|
2006-09-04 03:44:47 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
|
2006-09-04 03:44:47 +05:30
|
|
|
self._type = _("Media Reference")
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
2006-09-04 03:44:47 +05:30
|
|
|
|
2010-07-28 20:34:45 +05:30
|
|
|
def reset(self):
|
2006-09-04 03:44:47 +05:30
|
|
|
base = self._db.get_object_from_handle(self._obj.get_reference_handle())
|
2010-07-28 20:34:45 +05:30
|
|
|
if base:
|
|
|
|
self._title = base.get_description()
|
|
|
|
self._value = base.get_path()
|
2006-09-04 03:44:47 +05:30
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2007-01-30 18:37:21 +05:30
|
|
|
base = self._db.get_object_from_handle(self._obj.get_reference_handle())
|
|
|
|
return "<big><b>%s</b></big>\n\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n" % (_("Media Reference"),
|
|
|
|
_("Title"),escape(base.get_description()),
|
|
|
|
_("Type"),escape(base.get_mime_type()),
|
|
|
|
_("Name"),escape(base.get_path()))
|
2006-09-04 03:44:47 +05:30
|
|
|
|
2006-11-11 04:58:40 +05:30
|
|
|
|
|
|
|
class ScratchPadPersonRef(ScratchPadGrampsTypeWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.PERSONREF]
|
|
|
|
DRAG_TARGET = DdTargets.PERSONREF
|
|
|
|
ICON = LINK_PIC
|
|
|
|
|
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
|
|
|
|
self._type = _("Person Reference")
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
2006-11-11 04:58:40 +05:30
|
|
|
|
2010-07-28 20:34:45 +05:30
|
|
|
def reset(self):
|
2006-11-11 04:58:40 +05:30
|
|
|
person = self._db.get_person_from_handle(self._obj.get_reference_handle())
|
2010-07-28 20:34:45 +05:30
|
|
|
if person:
|
|
|
|
self._title = self._obj.get_relation()
|
|
|
|
self._value = person.get_primary_name().get_name()
|
2006-11-11 04:58:40 +05:30
|
|
|
|
|
|
|
def tooltip(self):
|
|
|
|
return ""
|
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
class ScratchPersonLink(ScratchPadWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.PERSON_LINK]
|
|
|
|
DRAG_TARGET = DdTargets.PERSON_LINK
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS["person"]
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadWrapper.__init__(self, dbstate, obj)
|
2010-07-28 20:34:45 +05:30
|
|
|
self._type = _("Person")
|
2010-07-29 13:31:24 +05:30
|
|
|
self._objclass = 'Person'
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2010-07-28 20:34:45 +05:30
|
|
|
def reset(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
|
|
|
person = self._db.get_person_from_handle(self._handle)
|
2010-07-28 20:34:45 +05:30
|
|
|
if person:
|
2010-07-31 07:41:47 +05:30
|
|
|
self._title = person.gramps_id
|
|
|
|
self._value = person.get_primary_name().get_name()
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2006-07-09 08:17:34 +05:30
|
|
|
data = pickle.loads(self._obj)
|
|
|
|
handle = data[2]
|
|
|
|
person = self._db.get_person_from_handle(handle)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
s = "<big><b>%s</b></big>\n\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n" % (
|
2010-07-28 20:34:45 +05:30
|
|
|
_("Person"),
|
2005-08-10 19:58:16 +05:30
|
|
|
_("Name"),escape(self._title),
|
|
|
|
_("Birth"),escape(self._value))
|
|
|
|
|
2010-07-28 20:34:45 +05:30
|
|
|
if person and len(person.get_source_references()) > 0:
|
2005-08-10 19:58:16 +05:30
|
|
|
psrc_ref = person.get_source_references()[0]
|
2006-05-23 05:26:57 +05:30
|
|
|
psrc_id = psrc_ref.get_reference_handle()
|
2005-08-10 19:58:16 +05:30
|
|
|
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
|
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def is_valid(self):
|
|
|
|
data = pickle.loads(self._obj)
|
|
|
|
handle = data[2]
|
|
|
|
obj = self._db.get_person_from_handle(handle)
|
|
|
|
if obj:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2006-03-23 04:33:57 +05:30
|
|
|
|
2010-07-31 07:41:47 +05:30
|
|
|
class ScratchFamilyLink(ScratchPadWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.FAMILY_LINK]
|
|
|
|
DRAG_TARGET = DdTargets.FAMILY_LINK
|
|
|
|
ICON = ICONS["family"]
|
|
|
|
|
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadWrapper.__init__(self, dbstate, obj)
|
|
|
|
self._type = _("Family")
|
|
|
|
self._objclass = 'Family'
|
|
|
|
self.reset()
|
|
|
|
|
|
|
|
def reset(self):
|
|
|
|
from Simple import SimpleAccess
|
|
|
|
sa = SimpleAccess(self._db)
|
|
|
|
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
|
|
|
family = self._db.get_family_from_handle(self._handle)
|
|
|
|
self._title = family.gramps_id if family else _("Unavailable")
|
|
|
|
self._value = sa.describe(family)
|
|
|
|
|
|
|
|
def tooltip(self):
|
|
|
|
if not self.is_valid(): return _("Unavailable")
|
|
|
|
return ""
|
|
|
|
|
|
|
|
def is_valid(self):
|
|
|
|
data = pickle.loads(self._obj)
|
|
|
|
handle = data[2]
|
|
|
|
obj = self._db.get_family_from_handle(handle)
|
|
|
|
if obj:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2006-03-23 04:33:57 +05:30
|
|
|
class ScratchSourceLink(ScratchPadWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.SOURCE_LINK]
|
|
|
|
DRAG_TARGET = DdTargets.SOURCE_LINK
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS["source"]
|
2006-03-23 04:33:57 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadWrapper.__init__(self, dbstate, obj)
|
2010-07-28 20:34:45 +05:30
|
|
|
self._type = _("Source")
|
2010-07-29 13:31:24 +05:30
|
|
|
self._objclass = 'Source'
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
2006-03-23 04:33:57 +05:30
|
|
|
|
2010-07-28 20:34:45 +05:30
|
|
|
def reset(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
|
|
|
source = self._db.get_source_from_handle(self._handle)
|
2010-07-28 20:34:45 +05:30
|
|
|
if source:
|
2010-07-31 07:41:47 +05:30
|
|
|
self._title = source.get_gramps_id()
|
|
|
|
self._value = source.get_title()
|
2006-03-23 04:33:57 +05:30
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2007-01-30 18:37:21 +05:30
|
|
|
(drag_type, idval, handle, val) = pickle.loads(self._obj)
|
|
|
|
base = self._db.get_source_from_handle(handle)
|
|
|
|
s = "<big><b>%s</b></big>\n\n"\
|
2007-11-13 02:58:02 +05:30
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
2007-01-30 18:37:21 +05:30
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s" % (
|
2010-07-28 20:34:45 +05:30
|
|
|
_("Source"),
|
2007-01-30 18:37:21 +05:30
|
|
|
_("Title"),escape(base.get_title()),
|
|
|
|
_("Abbreviation"), escape(base.get_abbreviation()),
|
|
|
|
_("Author"), escape(base.get_author()),
|
2007-07-19 09:18:38 +05:30
|
|
|
_("Publication Information"), escape(base.get_publication_info()))
|
2007-01-30 18:37:21 +05:30
|
|
|
return s
|
2006-03-23 04:33:57 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def is_valid(self):
|
|
|
|
data = pickle.loads(self._obj)
|
|
|
|
handle = data[2]
|
|
|
|
obj = self._db.get_source_from_handle(handle)
|
|
|
|
if obj:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2006-03-23 10:49:38 +05:30
|
|
|
class ScratchRepositoryLink(ScratchPadWrapper):
|
|
|
|
|
|
|
|
DROP_TARGETS = [DdTargets.REPO_LINK]
|
|
|
|
DRAG_TARGET = DdTargets.REPO_LINK
|
2010-07-29 13:31:24 +05:30
|
|
|
ICON = ICONS["repository"]
|
2006-03-23 10:49:38 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def __init__(self, dbstate, obj):
|
|
|
|
ScratchPadWrapper.__init__(self, dbstate, obj)
|
2010-07-28 20:34:45 +05:30
|
|
|
self._type = _("Repository")
|
2010-07-29 13:31:24 +05:30
|
|
|
self._objclass = 'Repository'
|
2010-07-28 20:34:45 +05:30
|
|
|
self.reset()
|
2006-03-23 10:49:38 +05:30
|
|
|
|
2010-07-28 20:34:45 +05:30
|
|
|
def reset(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
|
|
|
source = self._db.get_repository_from_handle(self._handle)
|
2010-07-28 20:34:45 +05:30
|
|
|
if source:
|
2010-07-31 07:41:47 +05:30
|
|
|
self._title = str(source.get_type())
|
|
|
|
self._value = source.get_name()
|
2006-03-23 10:49:38 +05:30
|
|
|
|
|
|
|
def tooltip(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
if not self.is_valid(): return _("Unavailable")
|
2007-01-30 18:37:21 +05:30
|
|
|
(drag_type, idval, handle, val) = pickle.loads(self._obj)
|
|
|
|
base = self._db.get_repository_from_handle(handle)
|
|
|
|
s = "<big><b>%s</b></big>\n\n"\
|
|
|
|
"\t<b>%s:</b>\t%s\n"\
|
|
|
|
"\t<b>%s:</b>\t%s" % (
|
2010-07-28 20:34:45 +05:30
|
|
|
_("Repository"),
|
2007-01-30 18:37:21 +05:30
|
|
|
_("Name"),escape(base.get_name()),
|
|
|
|
_("Type"), escape(base.get_type().__str__()))
|
|
|
|
return s
|
2006-03-23 10:49:38 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def is_valid(self):
|
|
|
|
data = pickle.loads(self._obj)
|
|
|
|
handle = data[2]
|
|
|
|
obj = self._db.get_repository_from_handle(handle)
|
|
|
|
if obj:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Wrapper classes to deal with lists of objects
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class ScratchDropList(object):
|
2010-07-29 13:31:24 +05:30
|
|
|
DROP_TARGETS = [DdTargets.LINK_LIST]
|
|
|
|
DRAG_TARGET = None
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2010-07-29 13:31:24 +05:30
|
|
|
def __init__(self, dbstate, obj_list):
|
|
|
|
self._dbstate = dbstate
|
|
|
|
# ('link-list', id, (('person-link', handle),
|
|
|
|
# ('person-link', handle), ...), 0)
|
2005-08-10 19:58:16 +05:30
|
|
|
self._obj_list = pickle.loads(obj_list)
|
|
|
|
|
2010-07-29 13:31:24 +05:30
|
|
|
def map2class(self, target):
|
|
|
|
return {"person-link": ScratchPersonLink,
|
2010-07-31 07:41:47 +05:30
|
|
|
"family-link": ScratchFamilyLink,
|
2010-07-29 13:31:24 +05:30
|
|
|
'personref': ScratchPadPersonRef,
|
|
|
|
'source-link': ScratchSourceLink,
|
|
|
|
'srcref': ScratchPadSourceRef,
|
|
|
|
'repo-link': ScratchRepositoryLink,
|
|
|
|
'pevent': ScratchPadEvent,
|
|
|
|
'eventref': ScratchPadEventRef,
|
|
|
|
'mediaobj': ScratchMediaObj,
|
|
|
|
'mediaref': ScratchPadMediaRef,
|
|
|
|
'place-link': ScratchPadPlace,
|
|
|
|
'note-link': ScratchPadNote,
|
|
|
|
}[target]
|
|
|
|
|
2010-07-30 06:48:49 +05:30
|
|
|
def obj2class(self, target):
|
|
|
|
return {"Person": ScratchPersonLink,
|
2010-07-31 07:41:47 +05:30
|
|
|
"Family": ScratchFamilyLink,
|
2010-07-30 06:48:49 +05:30
|
|
|
'Source': ScratchSourceLink,
|
|
|
|
'Repository': ScratchRepositoryLink,
|
|
|
|
'Event': ScratchPadEvent,
|
|
|
|
'Media': ScratchMediaObj,
|
|
|
|
'Place': ScratchPadPlace,
|
|
|
|
'Note': ScratchPadNote,
|
|
|
|
}[target]
|
|
|
|
|
|
|
|
def obj2target(self, target):
|
|
|
|
return {"Person": 'person-link',
|
2010-07-31 07:41:47 +05:30
|
|
|
"Family": 'family-link',
|
2010-07-30 06:48:49 +05:30
|
|
|
'Source': 'source-link',
|
|
|
|
'Repository': 'repo-link',
|
|
|
|
'Event': 'pevent',
|
|
|
|
'Media': 'mediaobj',
|
|
|
|
'Place': 'place-link',
|
|
|
|
'Note': 'note-link',
|
|
|
|
}[target]
|
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
def get_objects(self):
|
2010-07-29 13:31:24 +05:30
|
|
|
list_type, id, handles, timestamp = self._obj_list
|
|
|
|
retval = []
|
|
|
|
for (target, handle) in handles:
|
|
|
|
_class = self.map2class(target)
|
|
|
|
obj = _class(self._dbstate, pickle.dumps((target, id, handle, timestamp)))
|
|
|
|
retval.append(obj)
|
|
|
|
return retval
|
|
|
|
|
|
|
|
class ScratchDropRawList(ScratchDropList):
|
|
|
|
DROP_TARGETS = [DdTargets.RAW_LIST]
|
|
|
|
DRAG_TARGET = None
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2010-07-29 13:31:24 +05:30
|
|
|
def __init__(self, dbstate, obj_list):
|
|
|
|
self._dbstate = dbstate
|
|
|
|
# ('raw-list', id, (ScratchObject, ScratchObject, ...), 0)
|
|
|
|
self._obj_list = pickle.loads(obj_list)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2010-07-29 13:31:24 +05:30
|
|
|
def get_objects(self):
|
|
|
|
retval = []
|
|
|
|
for item in self._obj_list:
|
|
|
|
target = pickle.loads(item)[0]
|
|
|
|
_class = self.map2class(target)
|
|
|
|
obj = _class(self._dbstate, item)
|
|
|
|
retval.append(obj)
|
|
|
|
return retval
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2010-07-30 06:48:49 +05:30
|
|
|
class ScratchDropHandleList(ScratchDropList):
|
|
|
|
DROP_TARGETS = [DdTargets.HANDLE_LIST]
|
|
|
|
DRAG_TARGET = None
|
|
|
|
|
|
|
|
def __init__(self, dbstate, obj_list):
|
|
|
|
self._dbstate = dbstate
|
|
|
|
# incoming:
|
|
|
|
# ('handle-list', id, (('Person', '2763526751235'),
|
|
|
|
# ('Source', '3786234743978'), ...), 0)
|
|
|
|
self._obj_list = pickle.loads(obj_list)
|
|
|
|
|
|
|
|
def get_objects(self):
|
|
|
|
retval = []
|
|
|
|
for (objclass, handle) in self._obj_list:
|
|
|
|
_class = self.obj2class(objclass)
|
|
|
|
target = self.obj2target(objclass)
|
|
|
|
# outgoing:
|
|
|
|
# (drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
|
|
|
data = (target, id(self), handle, 0)
|
|
|
|
obj = _class(self._dbstate, pickle.dumps(data))
|
|
|
|
retval.append(obj)
|
|
|
|
return retval
|
|
|
|
|
|
|
|
# FIXME: add family
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# ScratchPadListModel class
|
2008-01-29 02:52:06 +05:30
|
|
|
# Now shown as 'Clipboard'
|
2005-08-10 19:58:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class ScratchPadListModel(gtk.ListStore):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
gtk.ListStore.__init__(self,
|
|
|
|
str, # object type
|
|
|
|
object, # object
|
2010-07-29 13:31:24 +05:30
|
|
|
object, # tooltip callback
|
|
|
|
str, # type
|
|
|
|
str, # value
|
2005-08-10 19:58:16 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# ScratchPadListView class
|
2008-01-29 02:52:06 +05:30
|
|
|
# Now shown as 'Clipboard'
|
2005-08-10 19:58:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
2009-05-21 22:49:50 +05:30
|
|
|
class ScratchPadListView(object):
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
LOCAL_DRAG_TARGET = ('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0)
|
|
|
|
LOCAL_DRAG_TYPE = 'MY_TREE_MODEL_ROW'
|
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
def __init__(self, dbstate, widget):
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
self._widget = widget
|
2006-11-01 19:11:09 +05:30
|
|
|
self.dbstate = dbstate
|
|
|
|
self.dbstate.connect('database-changed', self.database_changed)
|
|
|
|
self.database_changed(dbstate.db)
|
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
self._target_type_to_wrapper_class_map = {}
|
|
|
|
self._previous_drop_time = 0
|
|
|
|
|
|
|
|
self.otitles = [(_('Type'),-1,150),
|
|
|
|
(_('Title'),-1,150),
|
|
|
|
(_('Value'),-1,150),
|
|
|
|
('',-1,0)] # To hold the tooltip text
|
|
|
|
|
|
|
|
# Create the tree columns
|
|
|
|
self._col1 = gtk.TreeViewColumn(_("Type"))
|
2010-07-29 13:31:24 +05:30
|
|
|
self._col1.set_sort_column_id(0)
|
2005-08-10 19:58:16 +05:30
|
|
|
self._col2 = gtk.TreeViewColumn(_("Title"))
|
2010-07-29 13:31:24 +05:30
|
|
|
self._col2.set_sort_column_id(3)
|
2005-08-10 19:58:16 +05:30
|
|
|
self._col3 = gtk.TreeViewColumn(_("Value"))
|
2010-07-29 13:31:24 +05:30
|
|
|
self._col3.set_sort_column_id(4)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
# Add columns
|
|
|
|
self._widget.append_column(self._col1)
|
|
|
|
self._widget.append_column(self._col2)
|
|
|
|
self._widget.append_column(self._col3)
|
|
|
|
|
|
|
|
# Create cell renders
|
|
|
|
self._col1_cellpb = gtk.CellRendererPixbuf()
|
|
|
|
self._col1_cell = gtk.CellRendererText()
|
|
|
|
self._col2_cell = gtk.CellRendererText()
|
|
|
|
self._col3_cell = gtk.CellRendererText()
|
|
|
|
|
|
|
|
# Add cells to view
|
|
|
|
self._col1.pack_start(self._col1_cellpb, False)
|
|
|
|
self._col1.pack_start(self._col1_cell, True)
|
|
|
|
self._col2.pack_start(self._col2_cell, True)
|
|
|
|
self._col3.pack_start(self._col3_cell, True)
|
|
|
|
|
|
|
|
# Setup the cell data callback funcs
|
|
|
|
self._col1.set_cell_data_func(self._col1_cellpb, self.object_pixbuf)
|
|
|
|
self._col1.set_cell_data_func(self._col1_cell, self.object_type)
|
|
|
|
self._col2.set_cell_data_func(self._col2_cell, self.object_title)
|
2010-07-29 22:27:25 +05:30
|
|
|
self._col3.set_cell_data_func(self._col3_cell, self.object_value)
|
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
# Set the column that inline searching will use.
|
2010-07-30 06:48:49 +05:30
|
|
|
self._widget.set_enable_search(True)
|
|
|
|
#self._widget.set_search_column(3)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
self._widget.drag_dest_set(gtk.DEST_DEFAULT_ALL,
|
|
|
|
(ScratchPadListView.LOCAL_DRAG_TARGET,) + \
|
2010-07-30 06:48:49 +05:30
|
|
|
DdTargets.all_targets(),
|
2005-08-10 19:58:16 +05:30
|
|
|
ACTION_COPY)
|
|
|
|
|
|
|
|
self._widget.connect('drag_data_get', self.object_drag_data_get)
|
|
|
|
self._widget.connect('drag_begin', self.object_drag_begin)
|
|
|
|
self._widget.connect('drag_data_received',
|
|
|
|
self.object_drag_data_received)
|
2009-04-10 08:31:42 +05:30
|
|
|
self._widget.connect('drag_end', self.object_drag_end)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
self.register_wrapper_classes()
|
|
|
|
|
|
|
|
def database_changed(self,db):
|
|
|
|
self._db = db
|
2010-03-01 18:22:57 +05:30
|
|
|
# Note: delete event is emitted before the delete, so checking
|
|
|
|
# if valid on this is useless !
|
2006-11-01 19:11:09 +05:30
|
|
|
db_signals = (
|
|
|
|
'person-update',
|
|
|
|
'person-rebuild',
|
|
|
|
'family-update',
|
|
|
|
'family-rebuild',
|
|
|
|
'source-update',
|
|
|
|
'source-rebuild',
|
|
|
|
'place-update',
|
|
|
|
'place-rebuild',
|
|
|
|
'media-update',
|
2006-11-01 20:39:14 +05:30
|
|
|
'media-rebuild',
|
|
|
|
'event-update',
|
|
|
|
'event-rebuild',
|
|
|
|
'repository-update',
|
2010-03-01 18:22:57 +05:30
|
|
|
'repository-rebuild',
|
|
|
|
'note-rebuild'
|
2006-11-01 19:11:09 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
for signal in db_signals:
|
|
|
|
self._db.connect(signal,self.remove_invalid_objects)
|
2006-11-06 04:41:02 +05:30
|
|
|
|
2010-03-01 18:22:57 +05:30
|
|
|
self._db.connect('person-delete',
|
|
|
|
gen_del_obj(self.delete_object, 'person-link'))
|
|
|
|
self._db.connect('person-delete',
|
|
|
|
gen_del_obj(self.delete_object_ref, 'personref'))
|
|
|
|
self._db.connect('source-delete',
|
|
|
|
gen_del_obj(self.delete_object, 'source-link'))
|
|
|
|
self._db.connect('source-delete',
|
|
|
|
gen_del_obj(self.delete_object_ref, 'srcref'))
|
|
|
|
self._db.connect('repository-delete',
|
|
|
|
gen_del_obj(self.delete_object, 'repo-link'))
|
|
|
|
self._db.connect('event-delete',
|
|
|
|
gen_del_obj(self.delete_object, 'pevent'))
|
|
|
|
self._db.connect('event-delete',
|
|
|
|
gen_del_obj(self.delete_object_ref, 'eventref'))
|
|
|
|
self._db.connect('media-delete',
|
|
|
|
gen_del_obj(self.delete_object, 'mediaobj'))
|
|
|
|
self._db.connect('media-delete',
|
|
|
|
gen_del_obj(self.delete_object_ref, 'mediaref'))
|
|
|
|
self._db.connect('place-delete',
|
|
|
|
gen_del_obj(self.delete_object, 'place-link'))
|
|
|
|
self._db.connect('note-delete',
|
|
|
|
gen_del_obj(self.delete_object, 'note-link'))
|
|
|
|
# family-delete not needed, cannot be dragged!
|
2006-11-03 09:42:12 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
self.remove_invalid_objects()
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2005-08-17 19:21:53 +05:30
|
|
|
def remove_invalid_objects(self,dummy=None):
|
|
|
|
model = self._widget.get_model()
|
|
|
|
|
2006-06-15 09:59:47 +05:30
|
|
|
if model:
|
|
|
|
for o in model:
|
2006-08-12 22:54:36 +05:30
|
|
|
if not o[1].is_valid():
|
2006-11-01 19:11:09 +05:30
|
|
|
model.remove(o.iter)
|
2006-11-03 09:42:12 +05:30
|
|
|
|
2006-11-06 04:41:02 +05:30
|
|
|
def delete_object(self, handle_list, link_type):
|
2006-11-03 09:42:12 +05:30
|
|
|
model = self._widget.get_model()
|
|
|
|
|
|
|
|
if model:
|
|
|
|
for o in model:
|
2006-11-06 04:41:02 +05:30
|
|
|
if o[0] == link_type:
|
2006-11-03 09:42:12 +05:30
|
|
|
data = pickle.loads(o[1]._obj)
|
|
|
|
if data[2] in handle_list:
|
|
|
|
model.remove(o.iter)
|
2005-08-17 19:21:53 +05:30
|
|
|
|
2010-03-01 18:22:57 +05:30
|
|
|
def delete_object_ref(self, handle_list, link_type):
|
|
|
|
model = self._widget.get_model()
|
|
|
|
|
|
|
|
if model:
|
|
|
|
for o in model:
|
|
|
|
if o[0] == link_type:
|
|
|
|
data = o[1]._obj.get_reference_handle()
|
|
|
|
if data in handle_list:
|
|
|
|
model.remove(o.iter)
|
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
# Method to manage the wrapper classes.
|
|
|
|
|
|
|
|
def register_wrapper_classes(self):
|
|
|
|
self.register_wrapper_class(ScratchPadAddress)
|
2006-03-23 22:11:51 +05:30
|
|
|
self.register_wrapper_class(ScratchPadLocation)
|
2005-08-10 19:58:16 +05:30
|
|
|
self.register_wrapper_class(ScratchPadEvent)
|
2006-11-06 04:41:02 +05:30
|
|
|
self.register_wrapper_class(ScratchPadPlace)
|
2006-03-23 04:33:57 +05:30
|
|
|
self.register_wrapper_class(ScratchPadEventRef)
|
|
|
|
self.register_wrapper_class(ScratchPadSourceRef)
|
2006-03-25 09:40:55 +05:30
|
|
|
self.register_wrapper_class(ScratchPadRepoRef)
|
2005-08-10 19:58:16 +05:30
|
|
|
self.register_wrapper_class(ScratchPadFamilyEvent)
|
|
|
|
self.register_wrapper_class(ScratchPadUrl)
|
|
|
|
self.register_wrapper_class(ScratchPadAttribute)
|
|
|
|
self.register_wrapper_class(ScratchPadFamilyAttribute)
|
|
|
|
self.register_wrapper_class(ScratchPadName)
|
2006-03-23 10:49:38 +05:30
|
|
|
self.register_wrapper_class(ScratchRepositoryLink)
|
2005-08-10 19:58:16 +05:30
|
|
|
self.register_wrapper_class(ScratchMediaObj)
|
2006-09-04 03:44:47 +05:30
|
|
|
self.register_wrapper_class(ScratchPadMediaRef)
|
2006-03-23 04:33:57 +05:30
|
|
|
self.register_wrapper_class(ScratchSourceLink)
|
2005-08-10 19:58:16 +05:30
|
|
|
self.register_wrapper_class(ScratchPersonLink)
|
2010-07-31 07:41:47 +05:30
|
|
|
self.register_wrapper_class(ScratchFamilyLink)
|
2010-07-29 13:31:24 +05:30
|
|
|
self.register_wrapper_class(ScratchDropList)
|
|
|
|
self.register_wrapper_class(ScratchDropRawList)
|
2010-07-30 06:48:49 +05:30
|
|
|
self.register_wrapper_class(ScratchDropHandleList)
|
2006-11-11 04:58:40 +05:30
|
|
|
self.register_wrapper_class(ScratchPadPersonRef)
|
2006-06-16 08:15:14 +05:30
|
|
|
self.register_wrapper_class(ScratchPadText)
|
2007-03-28 21:57:45 +05:30
|
|
|
self.register_wrapper_class(ScratchPadNote)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def register_wrapper_class(self,wrapper_class):
|
|
|
|
for drop_target in wrapper_class.DROP_TARGETS:
|
|
|
|
self._target_type_to_wrapper_class_map[drop_target.drag_type] = wrapper_class
|
|
|
|
|
|
|
|
# Methods for rendering the cells.
|
|
|
|
|
2006-04-21 09:44:00 +05:30
|
|
|
def object_pixbuf(self, column, cell, model, node, user_data=None):
|
|
|
|
o = model.get_value(node, 1)
|
2005-08-10 19:58:16 +05:30
|
|
|
cell.set_property('pixbuf', o.__class__.ICON)
|
|
|
|
|
2006-04-21 09:44:00 +05:30
|
|
|
def object_type(self, column, cell, model, node, user_data=None):
|
|
|
|
o = model.get_value(node, 1)
|
2005-08-10 19:58:16 +05:30
|
|
|
cell.set_property('text', o.get_type())
|
|
|
|
|
2006-04-21 09:44:00 +05:30
|
|
|
def object_title(self, column, cell, model, node, user_data=None):
|
|
|
|
o = model.get_value(node, 1)
|
2005-08-10 19:58:16 +05:30
|
|
|
cell.set_property('text', o.get_title())
|
|
|
|
|
2006-04-21 09:44:00 +05:30
|
|
|
def object_value(self, column, cell, model, node, user_data=None):
|
|
|
|
o = model.get_value(node, 1)
|
2005-08-10 19:58:16 +05:30
|
|
|
cell.set_property('text', o.get_value())
|
|
|
|
|
|
|
|
|
|
|
|
# handlers for the drag and drop events.
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def on_object_select_row(self, obj):
|
2005-08-10 19:58:16 +05:30
|
|
|
tree_selection = self._widget.get_selection()
|
2010-07-29 13:31:24 +05:30
|
|
|
model, paths = tree_selection.get_selected_rows()
|
|
|
|
if len(paths) > 1:
|
|
|
|
targets = [(DdTargets.RAW_LIST.drag_type, gtk.TARGET_SAME_WIDGET, 0),
|
|
|
|
ScratchPadListView.LOCAL_DRAG_TARGET]
|
|
|
|
else:
|
|
|
|
targets = [ScratchPadListView.LOCAL_DRAG_TARGET]
|
|
|
|
for path in paths:
|
|
|
|
node = model.get_iter(path)
|
|
|
|
if node is not None:
|
|
|
|
o = model.get_value(node,1)
|
|
|
|
targets += [target.target() for target in o.__class__.DROP_TARGETS]
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2010-07-30 06:48:49 +05:30
|
|
|
self._widget.enable_model_drag_source(BUTTON1_MASK, targets,
|
|
|
|
ACTION_COPY | ACTION_MOVE)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def object_drag_begin(self, context, a):
|
2009-04-10 08:31:42 +05:30
|
|
|
""" Handle the beginning of a drag operation. """
|
2010-07-29 22:27:25 +05:30
|
|
|
pass
|
2009-04-10 08:31:42 +05:30
|
|
|
|
|
|
|
def object_drag_end(self, widget, drag_context):
|
|
|
|
""" Handle the end of a drag operation. """
|
2010-07-29 22:27:25 +05:30
|
|
|
pass
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def object_drag_data_get(self, widget, context, sel_data, info, time):
|
|
|
|
tree_selection = widget.get_selection()
|
2010-07-29 13:31:24 +05:30
|
|
|
model, paths = tree_selection.get_selected_rows()
|
|
|
|
if len(paths) == 1:
|
|
|
|
path = paths[0]
|
|
|
|
node = model.get_iter(path)
|
|
|
|
o = model.get_value(node,1)
|
|
|
|
sel_data.set(sel_data.target, 8, o.pack())
|
|
|
|
elif len(paths) > 1:
|
|
|
|
raw_list = []
|
|
|
|
for path in paths:
|
|
|
|
node = model.get_iter(path)
|
|
|
|
o = model.get_value(node,1)
|
|
|
|
raw_list.append(o._pickle)
|
|
|
|
sel_data.set(sel_data.target, 8, pickle.dumps(raw_list))
|
|
|
|
return True
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2010-07-28 20:34:45 +05:30
|
|
|
def object_drag_data_received(self,widget,context,x,y,selection,info,time,
|
|
|
|
title=None, value=None):
|
2005-08-10 19:58:16 +05:30
|
|
|
model = widget.get_model()
|
|
|
|
sel_data = selection.data
|
2006-03-23 11:40:45 +05:30
|
|
|
# In Windows time is always zero. Until that is fixed, use the seconds
|
|
|
|
# of the local time to filter out double drops.
|
|
|
|
realTime = strftime("%S")
|
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
# There is a strange bug that means that if there is a selection
|
|
|
|
# in the list we get multiple drops of the same object. Luckily
|
|
|
|
# the time values are the same so we can drop all but the first.
|
2010-07-28 20:34:45 +05:30
|
|
|
if (realTime == self._previous_drop_time) and (time != -1):
|
|
|
|
return None
|
2006-11-06 04:41:02 +05:30
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
# Find a wrapper class
|
2009-08-05 23:59:21 +05:30
|
|
|
possible_wrappers = []
|
|
|
|
if mac():
|
|
|
|
# context is empty on mac due to a bug, work around this
|
|
|
|
# Note that this workaround code works fine in linux too as
|
|
|
|
# we know very well inside of GRAMPS what sel_data can be, so
|
|
|
|
# we can anticipate on it, instead of letting the wrapper handle
|
|
|
|
# it. This is less clean however !
|
|
|
|
# See http://www.gramps-project.org/bugs/view.php?id=3089 for
|
|
|
|
# an explaination of why this is required.
|
|
|
|
dragtype = None
|
|
|
|
try:
|
|
|
|
dragtype = pickle.loads(sel_data)[0]
|
|
|
|
except pickle.UnpicklingError, msg :
|
|
|
|
# not a pickled object, probably text
|
|
|
|
if isinstance(sel_data, basestring):
|
|
|
|
dragtype = DdTargets.TEXT.drag_type
|
|
|
|
if dragtype in self._target_type_to_wrapper_class_map:
|
|
|
|
possible_wrappers = [dragtype]
|
|
|
|
else:
|
|
|
|
possible_wrappers = [target for target in context.targets \
|
|
|
|
if target in self._target_type_to_wrapper_class_map]
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
if len(possible_wrappers) == 0:
|
|
|
|
# No wrapper for this class
|
2010-07-28 20:34:45 +05:30
|
|
|
return None
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
# Just select the first match.
|
2009-08-05 23:59:21 +05:30
|
|
|
wrapper_class = self._target_type_to_wrapper_class_map[
|
|
|
|
str(possible_wrappers[0])]
|
2010-07-29 13:31:24 +05:30
|
|
|
o = wrapper_class(self.dbstate, sel_data)
|
2010-07-28 20:34:45 +05:30
|
|
|
if title:
|
|
|
|
o._title = title
|
|
|
|
if value:
|
|
|
|
o._value = value
|
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
# If the wrapper object is a subclass of ScratchDropList then
|
|
|
|
# the drag data was a list of objects and we need to decode
|
|
|
|
# all of them.
|
|
|
|
if isinstance(o,ScratchDropList):
|
|
|
|
o_list = o.get_objects()
|
|
|
|
else:
|
|
|
|
o_list = [o]
|
|
|
|
for o in o_list:
|
|
|
|
drop_info = widget.get_dest_row_at_pos(x, y)
|
|
|
|
if drop_info:
|
|
|
|
path, position = drop_info
|
2006-04-21 09:44:00 +05:30
|
|
|
node = model.get_iter(path)
|
2005-08-10 19:58:16 +05:30
|
|
|
if (position == gtk.TREE_VIEW_DROP_BEFORE
|
|
|
|
or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
|
2010-07-29 13:31:24 +05:30
|
|
|
model.insert_before(node,[o.__class__.DRAG_TARGET.drag_type,
|
|
|
|
o, o.tooltip, o._type, o._value])
|
2005-08-10 19:58:16 +05:30
|
|
|
else:
|
2010-07-29 13:31:24 +05:30
|
|
|
model.insert_after(node,[o.__class__.DRAG_TARGET.drag_type,
|
|
|
|
o, o.tooltip, o._type, o._value])
|
2005-08-10 19:58:16 +05:30
|
|
|
else:
|
2010-07-29 13:31:24 +05:30
|
|
|
model.append([o.__class__.DRAG_TARGET.drag_type, o, o.tooltip,
|
|
|
|
o._type, o._value])
|
2007-12-22 03:46:28 +05:30
|
|
|
|
|
|
|
if context.action == ACTION_MOVE:
|
|
|
|
context.finish(True, True, time)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
# remember time for double drop workaround.
|
2006-03-23 11:40:45 +05:30
|
|
|
self._previous_drop_time = realTime
|
2010-07-28 20:34:45 +05:30
|
|
|
return o_list
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
# proxy methods to provide access to the real widget functions.
|
|
|
|
|
|
|
|
def set_model(self,model=None):
|
|
|
|
self._widget.set_model(model)
|
|
|
|
self._widget.get_selection().connect('changed',self.on_object_select_row)
|
2010-07-29 13:31:24 +05:30
|
|
|
self._widget.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def get_model(self):
|
|
|
|
return self._widget.get_model()
|
|
|
|
|
|
|
|
def get_selection(self):
|
|
|
|
return self._widget.get_selection()
|
2005-08-17 19:21:53 +05:30
|
|
|
|
|
|
|
def set_search_column(self,col):
|
|
|
|
return self._widget.set_search_column(col)
|
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# ScatchPadWindow class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-21 09:44:00 +05:30
|
|
|
class ScratchPadWindow(ManagedWindow.ManagedWindow):
|
2005-08-10 19:58:16 +05:30
|
|
|
"""
|
2008-01-29 02:52:06 +05:30
|
|
|
The Clipboard (was ScratchPad) provides a temporary area to hold objects
|
|
|
|
that can
|
2005-08-10 19:58:16 +05:30
|
|
|
be reused accross multiple Person records. The pad provides a window
|
|
|
|
onto which objects can be dropped and then dragged into new Person
|
|
|
|
dialogs. The objects are stored as the pickles that are built by the
|
|
|
|
origininating widget. The objects are only unpickled in order to
|
|
|
|
provide the text in the display.
|
|
|
|
|
|
|
|
No attempt is made to ensure that any references contained within
|
|
|
|
the pickles are valid. Because the pad extends the life time of drag
|
|
|
|
and drop objects, it is possible that references that were valid
|
|
|
|
when an object is copied to the pad are invalid by the time they
|
|
|
|
are dragged to a new Person. For this reason, using the pad places
|
|
|
|
a responsibility on all '_drag_data_received' methods to check the
|
|
|
|
references of objects before attempting to use them.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Class attribute used to hold the content of the
|
2008-01-29 02:52:06 +05:30
|
|
|
# Clipboard (was ScratchPad). A class attribute is used so that the content
|
|
|
|
# it preserved even when the Clipboard window is closed.
|
|
|
|
# As there is only ever one Clipboard we do not need to
|
2005-08-10 19:58:16 +05:30
|
|
|
# maintain a list of these.
|
|
|
|
otree = None
|
|
|
|
|
2006-04-21 09:44:00 +05:30
|
|
|
def __init__(self, dbstate, uistate):
|
2008-02-24 19:25:55 +05:30
|
|
|
"""Initialize the ScratchPad class, and displays the window"""
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2006-04-28 22:26:19 +05:30
|
|
|
ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__)
|
2006-11-01 19:11:09 +05:30
|
|
|
self.dbstate = dbstate
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2006-11-01 19:11:09 +05:30
|
|
|
self.database_changed(self.dbstate.db)
|
|
|
|
self.dbstate.connect('database-changed', self.database_changed)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2009-10-08 06:42:51 +05:30
|
|
|
self.width_key = 'interface.clipboard-width'
|
|
|
|
self.height_key = 'interface.clipboard-height'
|
2009-05-15 01:45:59 +05:30
|
|
|
|
|
|
|
self.top = Glade()
|
|
|
|
self.set_window(self.top.toplevel, None, None, msg=_("Clipboard"))
|
2009-04-12 15:58:37 +05:30
|
|
|
self._set_size()
|
2006-03-05 04:23:46 +05:30
|
|
|
|
2009-04-14 00:56:29 +05:30
|
|
|
self.clear_all_btn = self.top.get_object("btn_clear_all")
|
|
|
|
self.clear_btn = self.top.get_object("btn_clear")
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2010-07-29 13:31:24 +05:30
|
|
|
self.object_list = ScratchPadListView(self.dbstate,
|
|
|
|
self.top.get_object('objectlist'))
|
2006-04-21 09:44:00 +05:30
|
|
|
self.object_list.get_selection().connect('changed',
|
|
|
|
self.set_clear_btn_sensitivity)
|
2010-07-29 13:31:24 +05:30
|
|
|
self.object_list.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
|
2005-08-10 19:58:16 +05:30
|
|
|
self.set_clear_btn_sensitivity(sel=self.object_list.get_selection())
|
|
|
|
|
|
|
|
if not ScratchPadWindow.otree:
|
|
|
|
ScratchPadWindow.otree = ScratchPadListModel()
|
|
|
|
|
|
|
|
self.set_clear_all_btn_sensitivity(treemodel=ScratchPadWindow.otree)
|
2006-04-21 09:44:00 +05:30
|
|
|
ScratchPadWindow.otree.connect('row-deleted',
|
|
|
|
self.set_clear_all_btn_sensitivity)
|
|
|
|
ScratchPadWindow.otree.connect('row-inserted',
|
|
|
|
self.set_clear_all_btn_sensitivity)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
|
|
|
|
self.object_list.set_model(ScratchPadWindow.otree)
|
|
|
|
|
2010-03-01 18:22:57 +05:30
|
|
|
#Database might have changed, objects might have been removed,
|
|
|
|
#we need to reevaluate if all data is valid
|
|
|
|
self.object_list.remove_invalid_objects()
|
|
|
|
|
2009-04-14 00:56:29 +05:30
|
|
|
self.top.connect_signals({
|
2006-04-28 22:26:19 +05:30
|
|
|
"on_close_scratchpad" : self.close,
|
2005-08-10 19:58:16 +05:30
|
|
|
"on_clear_clicked": self.on_clear_clicked,
|
|
|
|
"on_help_clicked": self.on_help_clicked,
|
|
|
|
})
|
|
|
|
|
2006-04-21 09:44:00 +05:30
|
|
|
self.clear_all_btn.connect_object('clicked', gtk.ListStore.clear,
|
|
|
|
ScratchPadWindow.otree)
|
2005-08-17 19:21:53 +05:30
|
|
|
self.db.connect('database-changed', lambda x: ScratchPadWindow.otree.clear())
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2006-04-21 09:44:00 +05:30
|
|
|
self.show()
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def build_menu_names(self, obj):
|
2008-04-27 02:13:26 +05:30
|
|
|
return (_('Clipboard'),None)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def database_changed(self,database):
|
|
|
|
self.db = database
|
|
|
|
|
2006-04-21 09:44:00 +05:30
|
|
|
def set_clear_all_btn_sensitivity(self, treemodel=None,
|
|
|
|
path=None, node=None, user_param1=None):
|
2005-08-10 19:58:16 +05:30
|
|
|
if len(treemodel) == 0:
|
|
|
|
self.clear_all_btn.set_sensitive(False)
|
|
|
|
else:
|
|
|
|
self.clear_all_btn.set_sensitive(True)
|
|
|
|
|
|
|
|
def set_clear_btn_sensitivity(self, sel=None, user_param1=None):
|
|
|
|
if sel.count_selected_rows() == 0:
|
|
|
|
self.clear_btn.set_sensitive(False)
|
|
|
|
else:
|
|
|
|
self.clear_btn.set_sensitive(True)
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def on_help_clicked(self, obj):
|
2005-08-10 19:58:16 +05:30
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2008-04-15 23:29:50 +05:30
|
|
|
GrampsDisplay.help(webpage=WIKI_HELP_PAGE, section=WIKI_HELP_SEC)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def on_clear_clicked(self, obj):
|
2005-08-10 19:58:16 +05:30
|
|
|
"""Deletes the selected object from the object list"""
|
|
|
|
selection = self.object_list.get_selection()
|
2010-07-29 13:31:24 +05:30
|
|
|
model, paths = selection.get_selected_rows()
|
|
|
|
for path in paths:
|
|
|
|
node = model.get_iter(path)
|
|
|
|
if node:
|
|
|
|
model.remove(node)
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def short(val,size=60):
|
|
|
|
if len(val) > size:
|
|
|
|
return "%s..." % val[0:size]
|
|
|
|
else:
|
|
|
|
return val
|
|
|
|
|
|
|
|
def place_title(db,event):
|
|
|
|
pid = event.get_place_handle()
|
|
|
|
if pid:
|
|
|
|
return db.get_place_from_handle(pid).get_title()
|
|
|
|
else:
|
|
|
|
return u''
|
|
|
|
|
2006-11-06 04:41:02 +05:30
|
|
|
def gen_del_obj(func, t):
|
|
|
|
return lambda l : func(l, t)
|
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-08-17 19:21:53 +05:30
|
|
|
def ScratchPad(database,person,callback,parent=None):
|
|
|
|
ScratchPadWindow(database,parent)
|