Consolidate all logic for setting up a 'surname' combo box.

svn: r531
This commit is contained in:
David Hampton 2001-11-01 02:33:55 +00:00
parent 4c0cfd41d9
commit 94eef45b33
8 changed files with 61 additions and 39 deletions

View File

@ -74,11 +74,7 @@ class AddSpouse:
self.surname_combo = self.glade.get_widget("surname_combo")
self.rel_combo.set_popdown_strings(const.familyRelations)
if len(const.surnames) > 0:
const.surnames.sort()
self.surname_combo.set_popdown_strings(const.surnames)
self.surname_combo.disable_activate()
self.surname.set_text("")
utils.attach_surnames(self.surname_combo)
# Typing CR selects 'Add Existing' button
self.top.editable_enters(self.given)

View File

@ -253,12 +253,7 @@ class ChooseParents:
window = self.xml.get_widget("addperson")
window.editable_enters(self.xml.get_widget("given"))
window.editable_enters(self.xml.get_widget("surname"))
if len(const.surnames) > 0:
const.surnames.sort()
combo = self.xml.get_widget("surnameCombo")
combo.set_popdown_strings(const.surnames)
combo.disable_activate()
self.xml.get_widget("surname").set_text("")
utils.attach_surnames(self.xml.get_widget("surnameCombo"))
def on_addfather_clicked(self,obj):
self.on_addparent_clicked(obj,"male")

View File

@ -193,9 +193,7 @@ class EditPerson:
self.window.editable_enters(self.ddate);
self.window.editable_enters(self.dplace);
if len(const.surnames) > 0:
const.surnames.sort()
self.get_widget("lastNameList").set_popdown_strings(const.surnames)
utils.attach_surnames(self.get_widget("lastNameList"))
self.gid.set_text(person.getId())
self.gid.set_editable(Config.id_edit)

View File

@ -62,7 +62,7 @@ class NameEditor:
self.surname_field = self.top.get_widget("alt_last")
self.suffix_field = self.top.get_widget("alt_suffix")
self.note_field = self.top.get_widget("alt_note")
self.top.get_widget("alt_surname_list").set_popdown_strings(const.surnames)
utils.attach_surnames(self.top.get_widget("alt_surname_list"))
self.priv = self.top.get_widget("priv")
if self.name:

View File

@ -233,6 +233,7 @@ class NewChild:
self.top = self.xml.get_widget("addChild")
self.surname = self.xml.get_widget("childSurname")
self.given = self.xml.get_widget("childGiven")
utils.attach_surnames(self.xml.get_widget("surname_combo"))
surname = ""
if self.person.getGender() == Person.male:

View File

@ -6542,30 +6542,6 @@ Very High
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>childSurname</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>5</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox18</name>
@ -6789,6 +6765,48 @@ Unknown
<text>Birth</text>
</widget>
</widget>
<widget>
<class>GtkCombo</class>
<name>surname_combo</name>
<value_in_list>False</value_in_list>
<ok_if_empty>True</ok_if_empty>
<case_sensitive>False</case_sensitive>
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items></items>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>5</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>childSurname</name>
<can_focus>True</can_focus>
<signal>
<name>insert_text</name>
<handler>on_combo_insert_text</handler>
<object>surname_combo</object>
<last_modification_time>Thu, 01 Nov 2001 02:12:35 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
</widget>
</widget>
</widget>
</widget>
</widget>

View File

@ -1965,6 +1965,7 @@ def post_load(name):
lastname = person.getPrimaryName().getSurname()
if lastname and lastname not in const.surnames:
const.surnames.append(lastname)
const.surnames.sort()
statusbar.set_progress(1.0)
full_update()

View File

@ -411,6 +411,19 @@ def thumb_path(dir,mobj):
return find_icon(type)
#-------------------------------------------------------------------------
#
#
# Common setup code for a combo box for inputting a surname.
#
#-------------------------------------------------------------------------
def attach_surnames(combo):
if len(const.surnames) > 0:
# Surnames are always sorted
combo.set_popdown_strings(const.surnames)
combo.disable_activate()
combo.entry.set_text("")
#-------------------------------------------------------------------------
#
# Sets up a delayed (0.005 sec) handler for text completion. Text