GEP 18: add autotitle setting from given attributes
svn: r22483
This commit is contained in:
parent
1e99275b84
commit
ccf1f2eac5
@ -43,7 +43,7 @@ from gi.repository import Gtk
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.lib.srcattrtype import (SrcAttributeType, REF_TYPE_F,
|
||||
REF_TYPE_S, REF_TYPE_L, EMPTY)
|
||||
from gramps.gen.lib.srcattribute import SrcAttribute
|
||||
from gramps.gen.lib import SrcAttribute, SrcTemplate
|
||||
from ...autocomp import StandardCustomSelector
|
||||
from ...widgets.srctemplatetreeview import SrcTemplateTreeView
|
||||
from ...widgets import UndoableEntry, MonitoredEntry
|
||||
@ -80,7 +80,9 @@ class SrcTemplateTab(GrampsTab):
|
||||
self.glade = glade
|
||||
self.callback_src_changed = callback_src_changed
|
||||
self.readonly = dbstate.db.readonly
|
||||
|
||||
|
||||
self.autoset_title = False
|
||||
|
||||
GrampsTab.__init__(self, dbstate, uistate, track, _("Source Template"))
|
||||
eventbox = Gtk.EventBox()
|
||||
widget = self.glade.get_object('gridtemplate')
|
||||
@ -93,6 +95,7 @@ class SrcTemplateTab(GrampsTab):
|
||||
self.inpts = []
|
||||
self.monentry = []
|
||||
self.gridfields = self.glade.get_object('gridfields')
|
||||
self.autotitle = self.glade.get_object("autotitle_checkbtn")
|
||||
#self.vbox_fields_label = self.glade.get_object('fields_01')
|
||||
#self.vbox_fields_input = self.glade.get_object('fields_02')
|
||||
self.setup_interface(self.glade.get_object('scrolledtemplates'))
|
||||
@ -117,6 +120,34 @@ class SrcTemplateTab(GrampsTab):
|
||||
self.temp_tv = SrcTemplateTreeView(templ[2],
|
||||
sel_callback=self.on_template_selected)
|
||||
scrolled.add(self.temp_tv)
|
||||
|
||||
#autotitle checkbox
|
||||
self.autotitle.set_active(self.autotitle_get_orig_val())
|
||||
self.autotitle.set_sensitive(not self.dbstate.db.readonly)
|
||||
self.autotitle.connect('toggled', self.autotitle_on_toggle)
|
||||
|
||||
def autotitle_get_orig_val(self):
|
||||
"""
|
||||
If title of the source is what we would set with autotitle, we set
|
||||
the checkbox to true. Otherwise to False
|
||||
"""
|
||||
srctemp = SrcTemplate(self.src.get_source_template()[0])
|
||||
srctemp.set_attr_list(self.src.get_attribute_list())
|
||||
title = srctemp.title_gedcom()
|
||||
if self.src.get_title() == title:
|
||||
self.autoset_title = True
|
||||
else:
|
||||
self.autoset_title = False
|
||||
return self.autoset_title
|
||||
|
||||
def autotitle_on_toggle(self, obj):
|
||||
""" the autoset_title attribute will be used in editsource to
|
||||
determine that title must be set
|
||||
"""
|
||||
self.autoset_title = obj.get_active()
|
||||
#it might be that the title must be changed, so we trigger the callback
|
||||
# which will update the title in the source object
|
||||
self.callback_src_changed()
|
||||
|
||||
def on_template_selected(self, index, key):
|
||||
"""
|
||||
|
@ -80,6 +80,8 @@ class EditSource(EditPrimary):
|
||||
"""
|
||||
self.srctemp = None
|
||||
self.citation = citation
|
||||
self.template_tab = None
|
||||
self.attr_tab = None
|
||||
if not source and not citation:
|
||||
raise NotImplementedError
|
||||
elif not source:
|
||||
@ -104,13 +106,13 @@ class EditSource(EditPrimary):
|
||||
|
||||
def get_menu_title(self):
|
||||
title = self.obj.get_title()
|
||||
if title:
|
||||
if self.obj.get_handle():
|
||||
title = _('Source') + ": " + title
|
||||
else:
|
||||
title = _('New Source')
|
||||
if self.citation is not None:
|
||||
citeid = self.citation.get_gramps_id()
|
||||
if citeid:
|
||||
if self.citation.get_handle():
|
||||
if self.callertitle:
|
||||
title = _('Citation: %(id)s - %(context)s' % {
|
||||
'id' : citeid,
|
||||
@ -331,6 +333,12 @@ class EditSource(EditPrimary):
|
||||
self.refS.set_text(_("<no citation loaded>"))
|
||||
self.author.set_text(self.srctemp.author_gedcom())
|
||||
self.pubinfo.set_text(self.srctemp.pubinfo_gedcom())
|
||||
if self.template_tab and self.template_tab.autoset_title:
|
||||
title = self.srctemp.title_gedcom()
|
||||
self.obj.set_title(title)
|
||||
self.title.update()
|
||||
#lastly update the window title
|
||||
self.update_title(self.get_menu_title())
|
||||
|
||||
def update_template_data(self):
|
||||
"""
|
||||
@ -358,14 +366,13 @@ class EditSource(EditPrimary):
|
||||
notebook = self.glade.get_object('notebook')
|
||||
gridsrc = self.glade.get_object('gridsrc')
|
||||
#recreate start page as GrampsTab
|
||||
notebook.remove_page(1)
|
||||
notebook.remove_page(0)
|
||||
self.overviewtab = RefTab(self.dbstate, self.uistate, self.track,
|
||||
_('Overview'), gridsrc)
|
||||
self._add_tab(notebook, self.overviewtab)
|
||||
|
||||
#recreate second page as GrampsTab
|
||||
notebook.remove_page(0)
|
||||
self.attr_tab = None
|
||||
self.template_tab = SrcTemplateTab(self.dbstate, self.uistate,
|
||||
self.track, self.obj, self.glade,
|
||||
self.update_template_data
|
||||
|
@ -957,6 +957,22 @@
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="autotitle_checkbtn">
|
||||
<property name="label" translatable="yes">Automatically set Source title from source fields</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="margin_left">3</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
|
Loading…
Reference in New Issue
Block a user