From 2706bfb5521fd578a23180af721325335603328b Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Sat, 21 Jun 2014 16:07:40 +0100 Subject: [PATCH] 7842: Fix custom place types in the place editor Allow place type combobox to receive focus. Store custom place types in the metadata table. --- gramps/gen/db/base.py | 7 +++++++ gramps/gen/db/read.py | 8 ++++++++ gramps/gen/db/write.py | 5 +++++ gramps/gui/editors/editplace.py | 4 +++- gramps/gui/glade/editplace.glade | 5 +++-- 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/gramps/gen/db/base.py b/gramps/gen/db/base.py index de7b203e5..b724daba9 100644 --- a/gramps/gen/db/base.py +++ b/gramps/gen/db/base.py @@ -864,6 +864,13 @@ class DbReadBase(object): """ raise NotImplementedError + def get_place_types(self): + """ + Return a list of all custom place types assocated with Place instances + in the database. + """ + raise NotImplementedError + def gramps_upgrade(self): """ Return True if database is upgraded diff --git a/gramps/gen/db/read.py b/gramps/gen/db/read.py index d0d14d483..d85f6aea2 100644 --- a/gramps/gen/db/read.py +++ b/gramps/gen/db/read.py @@ -420,6 +420,7 @@ class DbBsddbRead(DbReadBase, Callback): self.source_media_types = set() self.url_types = set() self.media_attributes = set() + self.place_types = set() self.open = 0 self.genderStats = GenderStats() @@ -1633,6 +1634,13 @@ class DbBsddbRead(DbReadBase, Callback): """ return list(self.url_types) + def get_place_types(self): + """ + Return a list of all custom place types assocated with Place instances + in the database. + """ + return list(self.place_types) + def __log_error(self): pass diff --git a/gramps/gen/db/write.py b/gramps/gen/db/write.py index 6975f4ae6..8dc3464b0 100644 --- a/gramps/gen/db/write.py +++ b/gramps/gen/db/write.py @@ -970,6 +970,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): self.url_types = set(meta(b'url_types')) self.media_attributes = set(meta(b'mattr_names')) self.event_attributes = set(meta(b'eattr_names')) + self.place_types = set(meta(b'place_types')) # surname list self.surname_list = meta(b'surname_list') @@ -1442,6 +1443,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): txn.put(b'url_types', list(self.url_types)) txn.put(b'mattr_names', list(self.media_attributes)) txn.put(b'eattr_names', list(self.event_attributes)) + txn.put(b'place_types', list(self.place_types)) # name display formats txn.put(b'surname_list', self.surname_list) @@ -2017,6 +2019,9 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): self.commit_base(place, self.place_map, PLACE_KEY, transaction, change_time) + if place.get_type().is_custom(): + self.place_types.add(str(place.get_type())) + self.url_types.update([str(url.type) for url in place.urls if url.type.is_custom()]) diff --git a/gramps/gui/editors/editplace.py b/gramps/gui/editors/editplace.py index cce3f8fdc..b886114c6 100644 --- a/gramps/gui/editors/editplace.py +++ b/gramps/gui/editors/editplace.py @@ -132,7 +132,9 @@ class EditPlace(EditPrimary): self.place_type = MonitoredDataType(self.top.get_object("place_type"), self.obj.set_type, - self.obj.get_type) + self.obj.get_type, + self.db.readonly, + self.db.get_place_types()) self.code = MonitoredEntry( self.top.get_object("code_entry"), diff --git a/gramps/gui/glade/editplace.glade b/gramps/gui/glade/editplace.glade index 99d94250d..faa228b6f 100644 --- a/gramps/gui/glade/editplace.glade +++ b/gramps/gui/glade/editplace.glade @@ -354,12 +354,13 @@ You can set these values via the Geography View by searching the place, or via a True - False + True What type of place this is. Eg 'Country', 'City', ... . True - False + True + True