* src/Editors/_EditPerson.py: add name callback to update screen
after a primary name change * src/DisplayTabs/_NameEmbedList.py: add primary name change menu item * src/GrampsWidgets.py: add reinitalization method to handle change of associated data item svn: r7268
This commit is contained in:
parent
445ea130cd
commit
2293665757
@ -2,6 +2,11 @@
|
||||
* src/const.py.in: Disable thumbnailer for Windows.
|
||||
|
||||
2006-08-25 Don Allingham <don@gramps-project.org>
|
||||
* src/Editors/_EditPerson.py: add name callback to update screen
|
||||
after a primary name change
|
||||
* src/DisplayTabs/_NameEmbedList.py: add primary name change menu item
|
||||
* src/GrampsWidgets.py: add reinitalization method to handle change of
|
||||
associated data item
|
||||
* src/DisplayModels/_MediaModel.py (MediaModel.sort_date): add
|
||||
sorting by date value instead of by text string
|
||||
|
||||
|
@ -20,6 +20,13 @@
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python classes
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python classes
|
||||
@ -53,8 +60,11 @@ class NameEmbedList(EmbeddedList):
|
||||
(_('Type'), 1, 100),
|
||||
]
|
||||
|
||||
def __init__(self, dbstate, uistate, track, data):
|
||||
def __init__(self, dbstate, uistate, track, data, person, callback):
|
||||
self.data = data
|
||||
self.person = person
|
||||
self.callback = callback
|
||||
|
||||
EmbeddedList.__init__(self, dbstate, uistate, track,
|
||||
_('Names'), NameModel)
|
||||
|
||||
@ -64,6 +74,24 @@ class NameEmbedList(EmbeddedList):
|
||||
def column_order(self):
|
||||
return ((1, 0), (1, 1))
|
||||
|
||||
def get_popup_menu_items(self):
|
||||
return [
|
||||
(True, gtk.STOCK_ADD, self.add_button_clicked),
|
||||
(True, gtk.STOCK_EDIT, self.edit_button_clicked),
|
||||
(True, gtk.STOCK_REMOVE, self.del_button_clicked),
|
||||
(False, _('Set as default name'), self.name_button_clicked),
|
||||
]
|
||||
|
||||
def name_button_clicked(self, obj):
|
||||
name = self.get_selected()
|
||||
pname = self.person.get_primary_name()
|
||||
if name:
|
||||
self.person.set_primary_name(name)
|
||||
self.data.remove(name)
|
||||
self.data.append(pname)
|
||||
self.rebuild()
|
||||
self.callback()
|
||||
|
||||
def add_button_clicked(self, obj):
|
||||
name = RelLib.Name()
|
||||
try:
|
||||
|
@ -175,13 +175,6 @@ class EditPerson(EditPrimary):
|
||||
),
|
||||
self.db.readonly)
|
||||
|
||||
self.ntype_field = GrampsWidgets.MonitoredDataType(
|
||||
self.top.get_widget("ntype"),
|
||||
self.pname.set_type,
|
||||
self.pname.get_type,
|
||||
self.db.readonly,
|
||||
self.db.get_name_types())
|
||||
|
||||
self.marker = GrampsWidgets.MonitoredDataType(
|
||||
self.top.get_widget('marker'),
|
||||
self.obj.set_marker,
|
||||
@ -190,6 +183,13 @@ class EditPerson(EditPrimary):
|
||||
self.db.get_marker_types(),
|
||||
)
|
||||
|
||||
self.ntype_field = GrampsWidgets.MonitoredDataType(
|
||||
self.top.get_widget("ntype"),
|
||||
self.pname.set_type,
|
||||
self.pname.get_type,
|
||||
self.db.readonly,
|
||||
self.db.get_name_types())
|
||||
|
||||
if self.use_patronymic:
|
||||
self.prefix = GrampsWidgets.MonitoredEntry(
|
||||
self.top.get_widget("prefix"),
|
||||
@ -260,7 +260,8 @@ class EditPerson(EditPrimary):
|
||||
self.name_list = self._add_tab(
|
||||
notebook,
|
||||
NameEmbedList(self.dbstate, self.uistate, self.track,
|
||||
self.obj.get_alternate_names()))
|
||||
self.obj.get_alternate_names(), self.obj,
|
||||
self.name_callback))
|
||||
|
||||
self.srcref_list = self._add_tab(
|
||||
notebook,
|
||||
@ -306,6 +307,40 @@ class EditPerson(EditPrimary):
|
||||
notebook.show_all()
|
||||
self.top.get_widget('vbox').pack_start(notebook, True)
|
||||
|
||||
def name_callback(self):
|
||||
self.pname = self.obj.get_primary_name()
|
||||
|
||||
self.ntype_field.reinit(self.pname.set_type, self.pname.get_type)
|
||||
|
||||
if self.use_patronymic:
|
||||
self.prefix.reinit(
|
||||
self.pname.set_patronymic,
|
||||
self.pname.get_patronymic)
|
||||
else:
|
||||
self.prefix.reinit(
|
||||
self.pname.set_surname_prefix,
|
||||
self.pname.get_surname_prefix)
|
||||
|
||||
self.suffix.reinit(
|
||||
self.pname.set_suffix,
|
||||
self.pname.get_suffix)
|
||||
|
||||
self.call.reinit(
|
||||
self.pname.set_call_name,
|
||||
self.pname.get_call_name)
|
||||
|
||||
self.given.reinit(
|
||||
self.pname.set_first_name,
|
||||
self.pname.get_first_name)
|
||||
|
||||
self.title.reinit(
|
||||
self.pname.set_title,
|
||||
self.pname.get_title)
|
||||
|
||||
self.surname_field.reinit(
|
||||
self.pname.set_surname,
|
||||
self.pname.get_surname)
|
||||
|
||||
def build_menu_names(self, person):
|
||||
"""
|
||||
Provides the information need by the base class to define the
|
||||
|
@ -303,6 +303,11 @@ class MonitoredEntry:
|
||||
if autolist:
|
||||
AutoComp.fill_entry(obj,autolist)
|
||||
|
||||
def reinit(self, set_val, get_val):
|
||||
self.set_val = set_val
|
||||
self.get_val = get_val
|
||||
self.update()
|
||||
|
||||
def set_text(self, text):
|
||||
self.obj.set_text(text)
|
||||
|
||||
@ -369,6 +374,11 @@ class MonitoredType:
|
||||
self.obj.set_sensitive(not readonly)
|
||||
self.obj.connect('changed', self.on_change)
|
||||
|
||||
def reinit(self, set_val, get_val):
|
||||
self.set_val = set_val
|
||||
self.get_val = get_val
|
||||
self.update()
|
||||
|
||||
def update(self):
|
||||
if self.get_val():
|
||||
self.sel.set_values(self.get_val())
|
||||
@ -404,6 +414,11 @@ class MonitoredDataType:
|
||||
self.obj.set_sensitive(not readonly)
|
||||
self.obj.connect('changed', self.on_change)
|
||||
|
||||
def reinit(self, set_val, get_val):
|
||||
self.set_val = set_val
|
||||
self.get_val = get_val
|
||||
self.update()
|
||||
|
||||
def fix_value(self, value):
|
||||
if value[0] == self.get_val().get_custom():
|
||||
return value
|
||||
|
Loading…
Reference in New Issue
Block a user