GEP 18: fix bug setting cite when no cite loaded. Factor out fields for reuse in citation GUI
svn: r22507
This commit is contained in:
@@ -91,10 +91,9 @@ class SrcTemplateTab(GrampsTab):
|
|||||||
self._set_label(show_image=False)
|
self._set_label(show_image=False)
|
||||||
widget.connect('key_press_event', self.key_pressed)
|
widget.connect('key_press_event', self.key_pressed)
|
||||||
|
|
||||||
self.lbls = []
|
self.tmplfields = TemplateFields(self.dbstate.db,
|
||||||
self.inpts = []
|
self.glade.get_object('gridfields'),
|
||||||
self.monentry = []
|
self.src, None, self.callback_src_changed, None)
|
||||||
self.gridfields = self.glade.get_object('gridfields')
|
|
||||||
self.autotitle = self.glade.get_object("autotitle_checkbtn")
|
self.autotitle = self.glade.get_object("autotitle_checkbtn")
|
||||||
#self.vbox_fields_label = self.glade.get_object('fields_01')
|
#self.vbox_fields_label = self.glade.get_object('fields_01')
|
||||||
#self.vbox_fields_input = self.glade.get_object('fields_02')
|
#self.vbox_fields_input = self.glade.get_object('fields_02')
|
||||||
@@ -165,34 +164,36 @@ class SrcTemplateTab(GrampsTab):
|
|||||||
srcattr = SrcAttributeType()
|
srcattr = SrcAttributeType()
|
||||||
if index in srcattr.EVIDENCETEMPLATES:
|
if index in srcattr.EVIDENCETEMPLATES:
|
||||||
#a predefined template,
|
#a predefined template,
|
||||||
self.reset_template_fields(srcattr.EVIDENCETEMPLATES[index])
|
self.tmplfields.reset_template_fields(srcattr.EVIDENCETEMPLATES[index])
|
||||||
|
|
||||||
def _add_entry(self, row, srcattrtype, label):
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# TemplateFields Class
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
class TemplateFields(object):
|
||||||
"""
|
"""
|
||||||
Add an entryfield to the grid of fields at row row, to edit the given
|
Class to manage fields of a source template.
|
||||||
srcattrtype value. Use label label if given to indicate the field
|
Can be used on source and on citation level.
|
||||||
(otherwise the srcattrtype string description is used)
|
|
||||||
Note srcattrtype should actually be the integer key of the type!
|
|
||||||
"""
|
"""
|
||||||
self.gridfields.insert_row(row)
|
def __init__(self, db, grid, src, cite, callback_src_changed,
|
||||||
field = srcattrtype
|
callback_cite_changed):
|
||||||
#setup label
|
"""
|
||||||
if not label:
|
grid: The Gtk.Grid that should hold the fields
|
||||||
srcattr = SrcAttributeType(field)
|
src : The source to which the fields belong
|
||||||
label = str(srcattr)
|
cite: The citation to which the fields belong (set None if only source)
|
||||||
lbl = Gtk.Label(_("%s:") % label)
|
"""
|
||||||
lbl.set_halign(Gtk.Align.START)
|
self.gridfields = grid
|
||||||
self.gridfields.attach(lbl, 0, row-1, 1, 1)
|
self.db = db
|
||||||
self.lbls.append(lbl)
|
self.src = src
|
||||||
#setup entry
|
self.cite = cite
|
||||||
inpt = UndoableEntry()
|
self.callback_src_changed = callback_src_changed
|
||||||
inpt.set_halign(Gtk.Align.FILL)
|
self.callback_cite_changed = callback_cite_changed
|
||||||
inpt.set_hexpand(True)
|
|
||||||
self.gridfields.attach(inpt, 1, row-1, 1, 1)
|
#storage
|
||||||
self.inpts.append(inpt)
|
self.lbls = []
|
||||||
MonitoredEntry(inpt, self.set_field, self.get_field,
|
self.inpts = []
|
||||||
read_only=self.dbstate.db.readonly,
|
self.monentry = []
|
||||||
parameter=srcattrtype)
|
|
||||||
|
|
||||||
def reset_template_fields(self, template):
|
def reset_template_fields(self, template):
|
||||||
# first remove old fields
|
# first remove old fields
|
||||||
@@ -229,7 +230,6 @@ class SrcTemplateTab(GrampsTab):
|
|||||||
self._add_entry(row, tempsattrt.short_version(fielddef[1]), '')
|
self._add_entry(row, tempsattrt.short_version(fielddef[1]), '')
|
||||||
row += 1
|
row += 1
|
||||||
|
|
||||||
|
|
||||||
# now add optional default citation values
|
# now add optional default citation values
|
||||||
fieldsF = [fielddef for fielddef in template[REF_TYPE_F]
|
fieldsF = [fielddef for fielddef in template[REF_TYPE_F]
|
||||||
if fielddef[1] not in fieldsL]
|
if fielddef[1] not in fieldsL]
|
||||||
@@ -250,7 +250,35 @@ class SrcTemplateTab(GrampsTab):
|
|||||||
self._add_entry(row, tempsattrt.short_version(fielddef[1]), '')
|
self._add_entry(row, tempsattrt.short_version(fielddef[1]), '')
|
||||||
row += 1
|
row += 1
|
||||||
|
|
||||||
self.show_all()
|
self.gridfields.show_all()
|
||||||
|
|
||||||
|
|
||||||
|
def _add_entry(self, row, srcattrtype, label):
|
||||||
|
"""
|
||||||
|
Add an entryfield to the grid of fields at row row, to edit the given
|
||||||
|
srcattrtype value. Use label label if given to indicate the field
|
||||||
|
(otherwise the srcattrtype string description is used)
|
||||||
|
Note srcattrtype should actually be the integer key of the type!
|
||||||
|
"""
|
||||||
|
self.gridfields.insert_row(row)
|
||||||
|
field = srcattrtype
|
||||||
|
#setup label
|
||||||
|
if not label:
|
||||||
|
srcattr = SrcAttributeType(field)
|
||||||
|
label = str(srcattr)
|
||||||
|
lbl = Gtk.Label(_("%s:") % label)
|
||||||
|
lbl.set_halign(Gtk.Align.START)
|
||||||
|
self.gridfields.attach(lbl, 0, row-1, 1, 1)
|
||||||
|
self.lbls.append(lbl)
|
||||||
|
#setup entry
|
||||||
|
inpt = UndoableEntry()
|
||||||
|
inpt.set_halign(Gtk.Align.FILL)
|
||||||
|
inpt.set_hexpand(True)
|
||||||
|
self.gridfields.attach(inpt, 1, row-1, 1, 1)
|
||||||
|
self.inpts.append(inpt)
|
||||||
|
MonitoredEntry(inpt, self.set_field, self.get_field,
|
||||||
|
read_only=self.db.readonly,
|
||||||
|
parameter=srcattrtype)
|
||||||
|
|
||||||
def get_field(self, srcattrtype):
|
def get_field(self, srcattrtype):
|
||||||
"""
|
"""
|
||||||
|
@@ -706,6 +706,7 @@ class EditSource(EditPrimary):
|
|||||||
else:
|
else:
|
||||||
msg = ''
|
msg = ''
|
||||||
# Make sure citation references this source
|
# Make sure citation references this source
|
||||||
|
if self.citation:
|
||||||
self.citation.set_reference_handle(self.obj.handle)
|
self.citation.set_reference_handle(self.obj.handle)
|
||||||
# Now commit the Citation Primary object if needed
|
# Now commit the Citation Primary object if needed
|
||||||
if self.citation_loaded:
|
if self.citation_loaded:
|
||||||
|
Reference in New Issue
Block a user