Cleanup and refactor of some of Scratchpad, especially to make easier to use for Clipboard Gramplet

svn: r15654
This commit is contained in:
Doug Blank 2010-07-28 15:04:45 +00:00
parent 0f310e78a4
commit 9bc3a5d603

View File

@ -84,11 +84,11 @@ class ScratchPadWrapper(object):
def __init__(self,dbstate, obj): def __init__(self,dbstate, obj):
dbstate.connect('database-changed', self.database_changed) dbstate.connect('database-changed', self.database_changed)
self.database_changed(dbstate.db) self.database_changed(dbstate.db)
self._obj = obj self._obj = obj
self._pickle = obj
self._type = _("Unknown") self._type = _("Unknown")
self._title = '' self._title = _('Unavailable')
self._value = '' self._value = _('Unavailable')
def database_changed(self,db): def database_changed(self,db):
self._db = db self._db = db
@ -112,7 +112,6 @@ class ScratchPadGrampsTypeWrapper(ScratchPadWrapper):
def __init__(self,dbstate, obj): def __init__(self,dbstate, obj):
ScratchPadWrapper.__init__(self,dbstate, obj) ScratchPadWrapper.__init__(self,dbstate, obj)
#unpack object #unpack object
(drag_type, idval, self._obj, val) = pickle.loads(obj) (drag_type, idval, self._obj, val) = pickle.loads(obj)
self._pickle = obj self._pickle = obj
@ -145,13 +144,15 @@ class ScratchPadAddress(ScratchPadGrampsTypeWrapper):
def __init__(self,dbstate, obj): def __init__(self,dbstate, obj):
ScratchPadGrampsTypeWrapper.__init__(self,dbstate, obj) ScratchPadGrampsTypeWrapper.__init__(self,dbstate, obj)
self._type = _("Address") self._type = _("Address")
self.reset()
def reset(self):
self._title = DateHandler.get_date(self._obj) self._title = DateHandler.get_date(self._obj)
self._value = "%s %s %s %s" % (self._obj.get_street(),self._obj.get_city(), self._value = "%s %s %s %s" % (self._obj.get_street(),self._obj.get_city(),
self._obj.get_state(),self._obj.get_country()) self._obj.get_state(),self._obj.get_country())
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
s = "<big><b>%s</b></big>\n\n"\ 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>\n"\ "\t<b>%s:</b>\n"\
@ -194,9 +195,8 @@ class ScratchPadLocation(ScratchPadGrampsTypeWrapper):
self._value = "%s %s %s" % (self._obj.get_city(), self._value = "%s %s %s" % (self._obj.get_city(),
self._obj.get_state(),self._obj.get_country()) self._obj.get_state(),self._obj.get_country())
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
s = "<big><b>%s</b></big>\n\n"\ 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>\n"\ "\t<b>%s:</b>\n"\
@ -219,18 +219,18 @@ class ScratchPadEvent(ScratchPadWrapper):
def __init__(self,dbstate, obj): def __init__(self,dbstate, obj):
ScratchPadWrapper.__init__(self,dbstate, obj) ScratchPadWrapper.__init__(self,dbstate, obj)
self._type = _("Event Link") self._type = _("Event")
self.reset()
(drag_type, idval, handle, val) = pickle.loads(obj)
def reset(self):
(drag_type, idval, handle, val) = pickle.loads(self._obj)
value = self._db.get_event_from_handle(handle) value = self._db.get_event_from_handle(handle)
if value:
self._title = str(value.get_type()) self._title = str(value.get_type())
self._value = value.get_description() self._value = value.get_description()
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
# there are several errors in the below which all cause gramps to # there are several errors in the below which all cause gramps to
# crash # crash
@ -275,16 +275,16 @@ class ScratchPadPlace(ScratchPadWrapper):
def __init__(self,dbstate, obj): def __init__(self,dbstate, obj):
ScratchPadWrapper.__init__(self,dbstate, obj) ScratchPadWrapper.__init__(self,dbstate, obj)
self._type = _("Place") self._type = _("Place")
self.reset()
(drag_type, idval, handle, val) = pickle.loads(obj) def reset(self):
(drag_type, idval, handle, val) = pickle.loads(self._obj)
value = self._db.get_place_from_handle(handle) value = self._db.get_place_from_handle(handle)
if value:
self._title = value.get_title() self._title = value.get_title()
self._value = "" #value.get_description() self._value = "" #value.get_description()
def tooltip(self): def tooltip(self):
global escape
return "" return ""
def is_valid(self): def is_valid(self):
@ -304,22 +304,22 @@ class ScratchPadNote(ScratchPadWrapper):
def __init__(self,dbstate, obj): def __init__(self,dbstate, obj):
ScratchPadWrapper.__init__(self,dbstate, obj) ScratchPadWrapper.__init__(self,dbstate, obj)
self._type = _("Note") self._type = _("Note")
self.reset()
(drag_type, idval, handle, val) = pickle.loads(obj) def reset(self):
(drag_type, idval, handle, val) = pickle.loads(self._obj)
value = self._db.get_note_from_handle(handle) value = self._db.get_note_from_handle(handle)
if value:
self._title = value.get_gramps_id() self._title = value.get_gramps_id()
note = value.get().replace('\n', ' ') note = value.get().replace('\n', ' ')
#String must be unicode for truncation to work for non ascii characters #String must be unicode for truncation to work for non ascii characters
note = unicode(note) note = unicode(note)
if len(note) > 80: if len(note) > 80:
self._value = note[:80]+"..." self._value = note[:80]+"..."
else: else:
self._value = note self._value = note
def tooltip(self): def tooltip(self):
global escape
return "" return ""
def is_valid(self): def is_valid(self):
@ -339,12 +339,14 @@ class ScratchPadFamilyEvent(ScratchPadGrampsTypeWrapper):
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj) ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
self._type = _("Family Event") self._type = _("Family Event")
self.reset()
def reset(self):
self._title = str(self._obj.get_type()) self._title = str(self._obj.get_type())
self._value = self._obj.get_description() self._value = self._obj.get_description()
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
s = "<big><b>%s</b></big>\n\n"\ 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"\
@ -380,11 +382,14 @@ class ScratchPadUrl(ScratchPadGrampsTypeWrapper):
def __init__(self,dbstate, obj): def __init__(self,dbstate, obj):
ScratchPadGrampsTypeWrapper.__init__(self,dbstate, obj) ScratchPadGrampsTypeWrapper.__init__(self,dbstate, obj)
self._type = _("Url") self._type = _("Url")
self.reset()
def reset(self):
self._title = self._obj.get_path() self._title = self._obj.get_path()
self._value = self._obj.get_description() self._value = self._obj.get_description()
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
return "<big><b>%s</b></big>\n\n"\ 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" % (_("Url"), "\t<b>%s:</b>\t%s" % (_("Url"),
@ -402,11 +407,14 @@ class ScratchPadAttribute(ScratchPadGrampsTypeWrapper):
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj) ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
self._type = _("Attribute") self._type = _("Attribute")
self.reset()
def reset(self):
self._title = str(self._obj.get_type()) self._title = str(self._obj.get_type())
self._value = self._obj.get_value() self._value = self._obj.get_value()
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
s = "<big><b>%s</b></big>\n\n"\ 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" % (_("Attribute"), "\t<b>%s:</b>\t%s" % (_("Attribute"),
@ -435,11 +443,14 @@ class ScratchPadFamilyAttribute(ScratchPadGrampsTypeWrapper):
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj) ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
self._type = _("Family Attribute") self._type = _("Family Attribute")
self.reset()
def reset(self):
self._title = str(self._obj.get_type()) self._title = str(self._obj.get_type())
self._value = self._obj.get_value() self._value = self._obj.get_value()
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
s = "<big><b>%s</b></big>\n\n"\ 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" % (_("Family Attribute"), "\t<b>%s:</b>\t%s" % (_("Family Attribute"),
@ -468,31 +479,32 @@ class ScratchPadSourceRef(ScratchPadGrampsTypeWrapper):
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj) ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
self._type = _("Source Reference") self._type = _("Source Reference")
self.reset()
def reset(self):
base = self._db.get_source_from_handle(self._obj.get_reference_handle()) base = self._db.get_source_from_handle(self._obj.get_reference_handle())
self._title = base.get_title() if base:
self._title = base.get_title()
notelist = map(self._db.get_note_from_handle, self._obj.get_note_list()) notelist = map(self._db.get_note_from_handle, self._obj.get_note_list())
srctxtlist = [ note for note in notelist srctxtlist = [ note for note in notelist
if note.get_type() == gen.lib.NoteType.SOURCE_TEXT] if note.get_type() == gen.lib.NoteType.SOURCE_TEXT]
page = self._obj.get_page()
page = self._obj.get_page() if not page:
if not page: page = _('not available|NA')
page = _('not available|NA') text = ""
text = "" if len(srctxtlist) > 0:
if len(srctxtlist) > 0: text = " ".join(srctxtlist[0].get().split())
text = " ".join(srctxtlist[0].get().split()) #String must be unicode for truncation to work for non ascii characters
#String must be unicode for truncation to work for non ascii characters text = unicode(text)
text = unicode(text) if len(text) > 60:
if len(text) > 60: text = text[:60]+"..."
text = text[:60]+"..." self._value = _("Volume/Page: %(pag)s -- %(sourcetext)s") % {
self._value = _("Volume/Page: %(pag)s -- %(sourcetext)s") % { 'pag' : page,
'pag' : page, 'sourcetext' : text,
'sourcetext' : text, }
}
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
base = self._db.get_source_from_handle(self._obj.get_reference_handle()) base = self._db.get_source_from_handle(self._obj.get_reference_handle())
s = "<big><b>%s</b></big>\n\n"\ s = "<big><b>%s</b></big>\n\n"\
"\t<b>%s:</b>\t%s\n"\ "\t<b>%s:</b>\t%s\n"\
@ -512,13 +524,16 @@ class ScratchPadRepoRef(ScratchPadGrampsTypeWrapper):
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj) ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
self._type = _("Repository Reference") self._type = _("Repository Reference")
self.reset()
def reset(self):
base = self._db.get_repository_from_handle(self._obj.ref) base = self._db.get_repository_from_handle(self._obj.ref)
self._title = base.get_name() if base:
self._value = str(base.get_type()) self._title = base.get_name()
self._value = str(base.get_type())
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
base = self._db.get_repository_from_handle(self._obj.get_reference_handle()) base = self._db.get_repository_from_handle(self._obj.get_reference_handle())
s = "<big><b>%s</b></big>\n\n"\ s = "<big><b>%s</b></big>\n\n"\
"\t<b>%s:</b>\t%s\n"\ "\t<b>%s:</b>\t%s\n"\
@ -540,10 +555,13 @@ class ScratchPadEventRef(ScratchPadGrampsTypeWrapper):
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj) ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
self._type = _("Event Reference") self._type = _("Event Reference")
self.reset()
def reset(self):
base = self._db.get_event_from_handle(self._obj.ref) base = self._db.get_event_from_handle(self._obj.ref)
self._title = base.get_description() if base:
self._value = str(base.get_type()) self._title = base.get_description()
self._value = str(base.get_type())
def tooltip(self): def tooltip(self):
return "" return ""
@ -557,12 +575,14 @@ class ScratchPadName(ScratchPadGrampsTypeWrapper):
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj) ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
self._type = _("Name") self._type = _("Name")
self.reset()
def reset(self):
self._title = self._obj.get_name() self._title = self._obj.get_name()
self._value = str(self._obj.get_type()) self._value = str(self._obj.get_type())
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
s = "<big><b>%s</b></big>\n\n"\ 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"\
@ -607,12 +627,12 @@ class ScratchPadText(ScratchPadWrapper):
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
ScratchPadWrapper.__init__(self, dbstate, obj) ScratchPadWrapper.__init__(self, dbstate, obj)
self._type = _("Text") self._type = _("Text")
self._title = "" self._title = ""
self._value = self._obj self._value = self._obj
self._pickle = self._obj
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
return "<big><b>%s</b></big>\n"\ return "<big><b>%s</b></big>\n"\
"%s" % (_("Text"), "%s" % (_("Text"),
escape(self._obj)) escape(self._obj))
@ -625,22 +645,24 @@ class ScratchMediaObj(ScratchPadWrapper):
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
ScratchPadWrapper.__init__(self, dbstate, obj) ScratchPadWrapper.__init__(self, dbstate, obj)
self._type = _("Media")
self.reset()
(drag_type, idval, handle, val) = pickle.loads(obj) def reset(self):
self._type = _("Media Object") (drag_type, idval, handle, val) = pickle.loads(self._obj)
obj = self._db.get_object_from_handle(handle) obj = self._db.get_object_from_handle(handle)
self._title = obj.get_description() if obj:
self._value = obj.get_path() self._title = obj.get_description()
self._value = obj.get_path()
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
(drag_type, idval, handle, val) = pickle.loads(self._obj) (drag_type, idval, handle, val) = pickle.loads(self._obj)
obj = self._db.get_object_from_handle(handle) obj = self._db.get_object_from_handle(handle)
return "<big><b>%s</b></big>\n\n"\ 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"\ "\t<b>%s:</b>\t%s\n"\
"\t<b>%s:</b>\t%s\n" % (_("Media Object"), "\t<b>%s:</b>\t%s\n" % (_("Media"),
_("Title"),escape(obj.get_description()), _("Title"),escape(obj.get_description()),
_("Type"),escape(obj.get_mime_type()), _("Type"),escape(obj.get_mime_type()),
_("Name"),escape(obj.get_path())) _("Name"),escape(obj.get_path()))
@ -662,13 +684,16 @@ class ScratchPadMediaRef(ScratchPadGrampsTypeWrapper):
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj) ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
self._type = _("Media Reference") self._type = _("Media Reference")
self.reset()
def reset(self):
base = self._db.get_object_from_handle(self._obj.get_reference_handle()) base = self._db.get_object_from_handle(self._obj.get_reference_handle())
self._title = base.get_description() if base:
self._value = base.get_path() self._title = base.get_description()
self._value = base.get_path()
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
base = self._db.get_object_from_handle(self._obj.get_reference_handle()) base = self._db.get_object_from_handle(self._obj.get_reference_handle())
return "<big><b>%s</b></big>\n\n"\ return "<big><b>%s</b></big>\n\n"\
"\t<b>%s:</b>\t%s\n"\ "\t<b>%s:</b>\t%s\n"\
@ -688,10 +713,13 @@ class ScratchPadPersonRef(ScratchPadGrampsTypeWrapper):
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj) ScratchPadGrampsTypeWrapper.__init__(self, dbstate, obj)
self._type = _("Person Reference") self._type = _("Person Reference")
self.reset()
def reset(self):
person = self._db.get_person_from_handle(self._obj.get_reference_handle()) person = self._db.get_person_from_handle(self._obj.get_reference_handle())
self._title = self._obj.get_relation() if person:
self._value = person.get_primary_name().get_name() self._title = self._obj.get_relation()
self._value = person.get_primary_name().get_name()
def tooltip(self): def tooltip(self):
return "" return ""
@ -704,24 +732,24 @@ class ScratchPersonLink(ScratchPadWrapper):
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
ScratchPadWrapper.__init__(self, dbstate, obj) ScratchPadWrapper.__init__(self, dbstate, obj)
self._type = _("Person Link") self._type = _("Person")
self.reset()
(drag_type, idval, handle, val) = pickle.loads(obj) def reset(self):
(drag_type, idval, handle, val) = pickle.loads(self._obj)
person = self._db.get_person_from_handle(handle) person = self._db.get_person_from_handle(handle)
self._title = person.get_primary_name().get_name() if person:
birth_ref = person.get_birth_ref() self._title = person.get_primary_name().get_name()
if birth_ref: birth_ref = person.get_birth_ref()
birth_handle = birth_ref.ref if birth_ref:
birth = self._db.get_event_from_handle(birth_handle) birth_handle = birth_ref.ref
date_str = DateHandler.get_date(birth) birth = self._db.get_event_from_handle(birth_handle)
if date_str != "": date_str = DateHandler.get_date(birth)
self._value = escape(date_str) if date_str != "":
self._value = escape(date_str)
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
data = pickle.loads(self._obj) data = pickle.loads(self._obj)
handle = data[2] handle = data[2]
person = self._db.get_person_from_handle(handle) person = self._db.get_person_from_handle(handle)
@ -729,11 +757,11 @@ class ScratchPersonLink(ScratchPadWrapper):
s = "<big><b>%s</b></big>\n\n"\ 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" % (
_("Person Link"), _("Person"),
_("Name"),escape(self._title), _("Name"),escape(self._title),
_("Birth"),escape(self._value)) _("Birth"),escape(self._value))
if len(person.get_source_references()) > 0: if person and len(person.get_source_references()) > 0:
psrc_ref = person.get_source_references()[0] psrc_ref = person.get_source_references()[0]
psrc_id = psrc_ref.get_reference_handle() psrc_id = psrc_ref.get_reference_handle()
psrc = self._db.get_source_from_handle(psrc_id) psrc = self._db.get_source_from_handle(psrc_id)
@ -763,17 +791,18 @@ class ScratchSourceLink(ScratchPadWrapper):
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
ScratchPadWrapper.__init__(self, dbstate, obj) ScratchPadWrapper.__init__(self, dbstate, obj)
self._type = _("Source Link") self._type = _("Source")
self.reset()
(drag_type, idval, handle, val) = pickle.loads(obj) def reset(self):
(drag_type, idval, handle, val) = pickle.loads(self._obj)
source = self._db.get_source_from_handle(handle) source = self._db.get_source_from_handle(handle)
self._title = source.get_title() if source:
self._value = source.get_gramps_id() self._title = source.get_title()
self._value = source.get_gramps_id()
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
(drag_type, idval, handle, val) = pickle.loads(self._obj) (drag_type, idval, handle, val) = pickle.loads(self._obj)
base = self._db.get_source_from_handle(handle) base = self._db.get_source_from_handle(handle)
s = "<big><b>%s</b></big>\n\n"\ s = "<big><b>%s</b></big>\n\n"\
@ -781,7 +810,7 @@ class ScratchSourceLink(ScratchPadWrapper):
"\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" % ( "\t<b>%s:</b>\t%s" % (
_("Source Link"), _("Source"),
_("Title"),escape(base.get_title()), _("Title"),escape(base.get_title()),
_("Abbreviation"), escape(base.get_abbreviation()), _("Abbreviation"), escape(base.get_abbreviation()),
_("Author"), escape(base.get_author()), _("Author"), escape(base.get_author()),
@ -804,22 +833,24 @@ class ScratchRepositoryLink(ScratchPadWrapper):
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
ScratchPadWrapper.__init__(self, dbstate, obj) ScratchPadWrapper.__init__(self, dbstate, obj)
self._type = _("Repository Link") self._type = _("Repository")
self.reset()
(drag_type, idval, handle, val) = pickle.loads(obj) def reset(self):
(drag_type, idval, handle, val) = pickle.loads(self._obj)
source = self._db.get_repository_from_handle(handle) source = self._db.get_repository_from_handle(handle)
self._title = source.get_name() if source:
self._value = str(source.get_type()) self._title = source.get_name()
self._value = str(source.get_type())
def tooltip(self): def tooltip(self):
global escape if self._obj is None: return "Undefined"
(drag_type, idval, handle, val) = pickle.loads(self._obj) (drag_type, idval, handle, val) = pickle.loads(self._obj)
base = self._db.get_repository_from_handle(handle) base = self._db.get_repository_from_handle(handle)
s = "<big><b>%s</b></big>\n\n"\ 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" % ( "\t<b>%s:</b>\t%s" % (
_("Repository Link"), _("Repository"),
_("Name"),escape(base.get_name()), _("Name"),escape(base.get_name()),
_("Type"), escape(base.get_type().__str__())) _("Type"), escape(base.get_type().__str__()))
return s return s
@ -855,8 +886,6 @@ class ScratchPersonLinkList(ScratchDropList):
def __init__(self,model, obj_list): def __init__(self,model, obj_list):
ScratchDropList.__init__(self,model, obj_list) ScratchDropList.__init__(self,model, obj_list)
self._cls = ScratchPersonLink self._cls = ScratchPersonLink
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -1104,7 +1133,8 @@ class ScratchPadListView(object):
sel_data.set(sel_data.target, 8, o.pack()) sel_data.set(sel_data.target, 8, o.pack())
def object_drag_data_received(self,widget,context,x,y,selection,info,time): def object_drag_data_received(self,widget,context,x,y,selection,info,time,
title=None, value=None):
model = widget.get_model() model = widget.get_model()
sel_data = selection.data sel_data = selection.data
@ -1115,8 +1145,8 @@ class ScratchPadListView(object):
# There is a strange bug that means that if there is a selection # 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 # 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. # the time values are the same so we can drop all but the first.
if realTime == self._previous_drop_time: if (realTime == self._previous_drop_time) and (time != -1):
return return None
# Find a wrapper class # Find a wrapper class
possible_wrappers = [] possible_wrappers = []
@ -1143,13 +1173,17 @@ class ScratchPadListView(object):
if len(possible_wrappers) == 0: if len(possible_wrappers) == 0:
# No wrapper for this class # No wrapper for this class
return return None
# Just select the first match. # Just select the first match.
wrapper_class = self._target_type_to_wrapper_class_map[ wrapper_class = self._target_type_to_wrapper_class_map[
str(possible_wrappers[0])] str(possible_wrappers[0])]
o = wrapper_class(self.dbstate,sel_data) o = wrapper_class(self.dbstate,sel_data)
if title:
o._title = title
if value:
o._value = value
# try: # try:
# o = wrapper_class(self._db,sel_data) # o = wrapper_class(self._db,sel_data)
# except: # except:
@ -1162,7 +1196,7 @@ class ScratchPadListView(object):
o_list = o.get_objects() o_list = o.get_objects()
else: else:
o_list = [o] o_list = [o]
for o in o_list: for o in o_list:
drop_info = widget.get_dest_row_at_pos(x, y) drop_info = widget.get_dest_row_at_pos(x, y)
if drop_info: if drop_info:
@ -1181,6 +1215,7 @@ class ScratchPadListView(object):
# remember time for double drop workaround. # remember time for double drop workaround.
self._previous_drop_time = realTime self._previous_drop_time = realTime
return o_list
# proxy methods to provide access to the real widget functions. # proxy methods to provide access to the real widget functions.