From ad4737edd5f35cfadb190b53284a3aff35a931b0 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Wed, 5 Mar 2014 00:08:35 +0000 Subject: [PATCH] Automatically populate the place title field --- .../gui/editors/displaytabs/placerefembedlist.py | 6 +++++- gramps/gui/editors/editplace.py | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gramps/gui/editors/displaytabs/placerefembedlist.py b/gramps/gui/editors/displaytabs/placerefembedlist.py index 72b64de8b..63269d70a 100644 --- a/gramps/gui/editors/displaytabs/placerefembedlist.py +++ b/gramps/gui/editors/displaytabs/placerefembedlist.py @@ -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() diff --git a/gramps/gui/editors/editplace.py b/gramps/gui/editors/editplace.py index de3e8d034..cce3f8fdc 100644 --- a/gramps/gui/editors/editplace.py +++ b/gramps/gui/editors/editplace.py @@ -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")