Automatically populate the place title field

This commit is contained in:
Nick Hall 2014-03-05 00:08:35 +00:00
parent d268a966bd
commit ad4737edd5
2 changed files with 18 additions and 3 deletions

View File

@ -59,9 +59,10 @@ class PlaceRefEmbedList(EmbeddedList):
(_('Date'), 3, 150, TEXT_COL, -1, None),
]
def __init__(self, dbstate, uistate, track, data, handle):
def __init__(self, dbstate, uistate, track, data, handle, callback):
self.data = data
self.handle = handle
self.callback = callback
EmbeddedList.__init__(self, dbstate, uistate, track,
_('Parents'), PlaceRefModel,
move_buttons=True)
@ -99,3 +100,6 @@ class PlaceRefEmbedList(EmbeddedList):
def edit_callback(self, name):
self.rebuild()
def post_rebuild(self, prebuildpath):
self.callback()

View File

@ -47,6 +47,7 @@ from gi.repository import Gtk
#-------------------------------------------------------------------------
from gramps.gen.lib import NoteType, Place
from gramps.gen.db import DbTxn
from gramps.gen.utils.location import get_location_list
from .editprimary import EditPrimary
from .displaytabs import (PlaceRefEmbedList, AltNameEmbedList,
LocationEmbedList, CitationEmbedList,
@ -111,7 +112,8 @@ class EditPlace(EditPrimary):
self.name = MonitoredEntry(self.top.get_object("name_entry"),
self.obj.set_name, self.obj.get_name,
self.db.readonly)
self.db.readonly,
changed=self.name_changed)
self.gid = MonitoredEntry(self.top.get_object("gid"),
self.obj.set_gramps_id,
@ -161,6 +163,14 @@ class EditPlace(EditPrimary):
return ValidationError(_("Invalid longitude (syntax: 18\u00b09'") +
_('48.21"E, -18.2412 or -18:9:48.21)'))
def update_title(self):
new_name = ', '.join(get_location_list(self.db, self.obj))
self.top.get_object("place_title").set_text(new_name)
self.obj.set_title(new_name)
def name_changed(self, obj):
self.update_title()
def build_menu_names(self, place):
return (_('Edit Place'), self.get_menu_title())
@ -176,7 +186,8 @@ class EditPlace(EditPrimary):
self.uistate,
self.track,
self.obj.get_placeref_list(),
self.obj.handle)
self.obj.handle,
self.update_title)
self._add_tab(notebook, self.placeref_list)
self.track_ref_for_deletion("placeref_list")