From 17873c0d3a98ec57a991acb3d255ace264c8232a Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Thu, 23 Feb 2006 05:08:25 +0000 Subject: [PATCH] completion svn: r5976 --- src/EventEdit.py | 7 ++----- src/GrampsDb/_GrampsDbBase.py | 15 +++++++++++++++ src/GrampsWidgets.py | 22 ---------------------- 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/src/EventEdit.py b/src/EventEdit.py index 91f8edd2f..50e9c278c 100644 --- a/src/EventEdit.py +++ b/src/EventEdit.py @@ -110,10 +110,6 @@ class EventEditor(DisplayState.ManagedWindow): if self.already_exist: return - for key in self.db.get_place_handles(): - title = self.db.get_place_from_handle(key).get_title() - self.pmap[title] = key - if not event: self.event = RelLib.Event() @@ -125,7 +121,7 @@ class EventEditor(DisplayState.ManagedWindow): etitle = _('Event Editor') Utils.set_titles(self.window,title_label, etitle, _('Event Editor')) - + self.place_field = self.top.get_widget("eventPlace") self.place_field.set_editable(not self.db.readonly) @@ -135,6 +131,7 @@ class EventEditor(DisplayState.ManagedWindow): else: place_name = self.db.get_place_from_handle(place_handle).get_title() self.place_field.set_text(place_name) + self.place_field.set_completion(self.dbstate.get_place_completion()) self._create_tabbed_pages() self._setup_fields() diff --git a/src/GrampsDb/_GrampsDbBase.py b/src/GrampsDb/_GrampsDbBase.py index 52a59221d..1cf06fe87 100644 --- a/src/GrampsDb/_GrampsDbBase.py +++ b/src/GrampsDb/_GrampsDbBase.py @@ -2045,3 +2045,18 @@ class DbState(GrampsDBCallback): self.active = None self.open = False self.emit('no-database') + + def get_place_completion(self): + import locale + + store = gtk.ListStore(str,str) + foo = [] + for val in self.places.keys(): + foo.append((locale.strxform(self.places[val]),val)) + foo.sort() + for val in foo: + self.store.append(row=[val[1],val[0]]) + self.completion = gtk.EntryCompletion() + self.completion.set_text_column(0) + self.completion.set_model(store) + return self.completion diff --git a/src/GrampsWidgets.py b/src/GrampsWidgets.py index 5b4267a93..d08f6aa8d 100644 --- a/src/GrampsWidgets.py +++ b/src/GrampsWidgets.py @@ -333,26 +333,4 @@ class MonitoredDate: button.set_sensitive(not readonly) field.set_text(DateHandler.displayer.display(self.date)) - -class MonitoredPlace: - - def __init__(self,obj,set_val,get_val,mapping,custom): - self.set_val = set_val - self.get_val = get_val - - self.obj = obj - - val = get_val() - if val: - default = val[0] - else: - default = None - - self.sel = AutoComp.StandardCustomSelector( - mapping, obj, custom, default) - - self.obj.connect('changed', self.on_change) - - def on_change(self, obj): - self.set_val(self.sel.get_values())