From f0bfce68c2bbbea65fa8bacca419956ecedf4160 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Tue, 12 May 2015 23:00:20 +0100 Subject: [PATCH] Add a title preview to the place editors --- .../editors/displaytabs/placerefembedlist.py | 6 ++- gramps/gui/editors/editplace.py | 13 ++++- gramps/gui/editors/editplaceref.py | 14 +++++- gramps/gui/glade/editplace.glade | 48 ++++++++++++------ gramps/gui/glade/editplaceref.glade | 50 ++++++++++++------- 5 files changed, 93 insertions(+), 38 deletions(-) diff --git a/gramps/gui/editors/displaytabs/placerefembedlist.py b/gramps/gui/editors/displaytabs/placerefembedlist.py index 39dfb4216..4afbbe136 100644 --- a/gramps/gui/editors/displaytabs/placerefembedlist.py +++ b/gramps/gui/editors/displaytabs/placerefembedlist.py @@ -61,9 +61,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, _('Enclosed By'), PlaceRefModel, share_button=True, move_buttons=True) @@ -132,6 +133,9 @@ class PlaceRefEmbedList(EmbeddedList): def edit_callback(self, ref, place): self.rebuild() + def post_rebuild(self, prebuildpath): + self.callback() + def handle_extra_type(self, objtype, obj): if obj in self.get_skip_list(self.handle): ErrorDialog(_("Place cycle detected"), diff --git a/gramps/gui/editors/editplace.py b/gramps/gui/editors/editplace.py index 725a9d96a..ce90131c3 100644 --- a/gramps/gui/editors/editplace.py +++ b/gramps/gui/editors/editplace.py @@ -115,7 +115,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, @@ -167,6 +168,13 @@ 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_title = place_displayer.display(self.db, self.obj) + self.top.get_object("preview_title").set_text(new_title) + + def name_changed(self, obj): + self.update_title() + def build_menu_names(self, place): return (_('Edit Place'), self.get_menu_title()) @@ -182,7 +190,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") diff --git a/gramps/gui/editors/editplaceref.py b/gramps/gui/editors/editplaceref.py index 011d534ab..ec3bf3db9 100644 --- a/gramps/gui/editors/editplaceref.py +++ b/gramps/gui/editors/editplaceref.py @@ -35,6 +35,7 @@ from gramps.gen.lib import NoteType from gramps.gen.db import DbTxn from gramps.gen.errors import ValidationError from gramps.gen.utils.place import conv_lat_lon +from gramps.gen.display.place import displayer as place_displayer from gramps.gen.config import config from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext @@ -113,7 +114,8 @@ class EditPlaceRef(EditReference): self.name = MonitoredEntry(self.top.get_object("name_entry"), self.source.set_name, self.source.get_name, - self.db.readonly) + self.db.readonly, + changed=self.name_changed) self.gid = MonitoredEntry(self.top.get_object("gid"), self.source.set_gramps_id, @@ -165,6 +167,13 @@ class EditPlaceRef(EditReference): return ValidationError(_("Invalid longitude (syntax: 18\u00b09'") + _('48.21"E, -18.2412 or -18:9:48.21)')) + def update_title(self): + new_title = place_displayer.display(self.db, self.source) + self.top.get_object("preview_title").set_text(new_title) + + def name_changed(self, obj): + self.update_title() + def _create_tabbed_pages(self): """ Create the notebook tabs and inserts them into the main @@ -183,7 +192,8 @@ class EditPlaceRef(EditReference): self.uistate, self.track, self.source.get_placeref_list(), - self.source.handle) + self.source.handle, + self.update_title) self._add_tab(notebook, self.placeref_list) self.track_ref_for_deletion("placeref_list") diff --git a/gramps/gui/glade/editplace.glade b/gramps/gui/glade/editplace.glade index bef910a5d..751c80d59 100644 --- a/gramps/gui/glade/editplace.glade +++ b/gramps/gui/glade/editplace.glade @@ -94,7 +94,7 @@ 0 - 0 + 1 @@ -109,7 +109,7 @@ 0 - 2 + 3 @@ -124,7 +124,7 @@ 2 - 2 + 3 @@ -137,7 +137,7 @@ 1 - 0 + 1 4 @@ -152,7 +152,7 @@ 0 - 3 + 4 @@ -167,7 +167,7 @@ You can set these values via the Geography View by searching the place, or via a 1 - 2 + 3 @@ -182,7 +182,7 @@ You can set these values via the Geography View by searching the place, or via a 3 - 2 + 3 @@ -236,7 +236,7 @@ You can set these values via the Geography View by searching the place, or via a 1 - 3 + 4 @@ -266,7 +266,7 @@ You can set these values via the Geography View by searching the place, or via a 4 - 2 + 3 @@ -278,7 +278,7 @@ You can set these values via the Geography View by searching the place, or via a 4 - 3 + 4 @@ -290,7 +290,7 @@ You can set these values via the Geography View by searching the place, or via a 0 - 1 + 2 @@ -302,7 +302,7 @@ You can set these values via the Geography View by searching the place, or via a 2 - 1 + 2 @@ -315,7 +315,7 @@ You can set these values via the Geography View by searching the place, or via a 1 - 1 + 2 @@ -334,7 +334,7 @@ You can set these values via the Geography View by searching the place, or via a 3 - 1 + 2 @@ -346,7 +346,7 @@ You can set these values via the Geography View by searching the place, or via a 2 - 3 + 4 @@ -358,7 +358,23 @@ You can set these values via the Geography View by searching the place, or via a 3 - 3 + 4 + + + + + True + False + 6 + 0 + + + + + + 0 + 0 + 5 diff --git a/gramps/gui/glade/editplaceref.glade b/gramps/gui/glade/editplaceref.glade index df14ddc44..cca7a8dcb 100644 --- a/gramps/gui/glade/editplaceref.glade +++ b/gramps/gui/glade/editplaceref.glade @@ -200,7 +200,7 @@ 0 - 0 + 1 @@ -214,7 +214,7 @@ 0 - 1 + 2 @@ -229,7 +229,7 @@ 0 - 3 + 4 @@ -242,7 +242,7 @@ 0 - 2 + 3 @@ -285,7 +285,7 @@ 0 - 4 + 5 5 @@ -300,7 +300,7 @@ 2 - 1 + 2 @@ -314,7 +314,7 @@ 2 - 2 + 3 @@ -333,7 +333,7 @@ 3 - 1 + 2 @@ -363,7 +363,7 @@ 4 - 2 + 3 @@ -376,7 +376,7 @@ 1 - 0 + 1 4 @@ -390,7 +390,7 @@ 1 - 1 + 2 @@ -405,7 +405,7 @@ You can set these values via the Geography View by searching the place, or via a 1 - 2 + 3 @@ -420,7 +420,7 @@ You can set these values via the Geography View by searching the place, or via a 3 - 2 + 3 @@ -474,7 +474,7 @@ You can set these values via the Geography View by searching the place, or via a 1 - 3 + 4 @@ -486,7 +486,7 @@ You can set these values via the Geography View by searching the place, or via a 2 - 3 + 4 @@ -498,7 +498,7 @@ You can set these values via the Geography View by searching the place, or via a 3 - 3 + 4 @@ -510,7 +510,23 @@ You can set these values via the Geography View by searching the place, or via a 4 - 3 + 4 + + + + + True + False + 6 + 0 + + + + + + 0 + 0 + 5