From 90379b7b42eef580d526456450d51465eb143c24 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Fri, 15 Oct 2010 21:42:56 +0000 Subject: [PATCH] continue adding to the editname GUI svn: r15999 --- po/POTFILES.in | 2 + src/DdTargets.py | 2 + src/ScratchPad.py | 13 + src/glade/editname.glade | 585 +++++++++++--------- src/glade/editperson.glade | 22 +- src/gui/editors/displaytabs/Makefile.am | 2 + src/gui/editors/displaytabs/__init__.py | 1 + src/gui/editors/displaytabs/surnamemodel.py | 55 ++ src/gui/editors/displaytabs/surnametab.py | 214 +++++++ src/gui/editors/editname.py | 70 ++- src/gui/editors/editperson.py | 42 +- src/gui/editors/editsecondary.py | 12 +- 12 files changed, 706 insertions(+), 314 deletions(-) create mode 100644 src/gui/editors/displaytabs/surnamemodel.py create mode 100644 src/gui/editors/displaytabs/surnametab.py diff --git a/po/POTFILES.in b/po/POTFILES.in index 407c02ffd..44acc682c 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -273,6 +273,8 @@ src/gui/editors/displaytabs/reporefmodel.py src/gui/editors/displaytabs/sourcebackreflist.py src/gui/editors/displaytabs/sourceembedlist.py src/gui/editors/displaytabs/sourcerefmodel.py +src/gui/editors/displaytabs/surnametab.py +src/gui/editors/displaytabs/surnamemodel.py src/gui/editors/displaytabs/webembedlist.py src/gui/editors/displaytabs/webmodel.py src/gui/editors/displaytabs/__init__.py diff --git a/src/DdTargets.py b/src/DdTargets.py index fd759ff38..3f588be27 100644 --- a/src/DdTargets.py +++ b/src/DdTargets.py @@ -133,6 +133,7 @@ class _DdTargets(object): self.SOURCEREF = _DdType(self, 'srcref') self.SOURCE_LINK = _DdType(self, 'source-link') self.URL = _DdType(self, 'url') + self.SURNAME = _DdType(self, 'surname') # List of all types that are used between # gramps widgets but should not be exported @@ -159,6 +160,7 @@ class _DdTargets(object): self.SOURCEREF, self.SOURCE_LINK, self.URL, + self.SURNAME ] self.CHILD = _DdType(self, 'child') diff --git a/src/ScratchPad.py b/src/ScratchPad.py index 181a6734d..48ec0eb63 100644 --- a/src/ScratchPad.py +++ b/src/ScratchPad.py @@ -507,6 +507,19 @@ class ScratchName(ScratchObjWrapper): self._title = str(self._obj.get_type()) self._value = self._obj.get_name() +class ScratchSurname(ScratchObjWrapper): + + DROP_TARGETS = [DdTargets.SURNAME] + DRAG_TARGET = DdTargets.SURNAME + ICON = ICONS['name'] + + def __init__(self, dbstate, obj): + super(ScratchSurname, self).__init__(dbstate, obj) + self._type = _("Surname") + if self._obj: + self._title = self._obj.get_surname() + self._value = self._obj.get_surname() + class ScratchText(ScratchWrapper): DROP_TARGETS = DdTargets.all_text() diff --git a/src/glade/editname.glade b/src/glade/editname.glade index aefc9a1c3..24c8ed810 100644 --- a/src/glade/editname.glade +++ b/src/glade/editname.glade @@ -12,275 +12,331 @@ True - vertical - + True - 12 - 4 - 5 - 12 - 6 - + True - 0 - _Given: - True - center - alt_given - - - 1 - 2 - GTK_FILL - - - - - - True - 0 - P_atronymic: - True - patronymic - - - 3 - 4 - GTK_FILL - - - - - - True - True - - - - 1 - 2 - 3 - 4 - - - - - - True - 0 - _Family: - True - center - alt_surname - - - GTK_FILL - - - - - - True - True - - - - 1 - 2 - - - - - - True - 0 - _Prefix: - True - center - alt_prefix - - - 2 - 3 - GTK_FILL - - - - - - True - 0 - Tit_le: - True - center - alt_title - - - 2 - 3 - GTK_FILL - - - - - - True - True - - - - 1 - 2 - 2 - 3 - - - - - - True - 0 - Suffi_x: - True - center - alt_suffix - - - 2 - 3 - 2 - 3 - GTK_FILL - - - - - - True - 0 - 0 - 1 - _Type: - True - center - name_type - - - 2 - 3 - 3 - 4 - GTK_FILL - - - - - - True - True - - - - 3 - 5 - - - - - - True - - - 3 - 5 - 3 - 4 - - - - - - True - True - - - - 3 - 4 - 2 - 3 - GTK_FILL - - - - - - True - True - True - none - + True - gtk-dialog-authentication - 1 + 0 + 4 + _Type: + True + center + ntype + + + False + 8 + 0 + + + + + True + + + 1 + + + + + + + + + + + + + + + + + True + True + True + none + + + True + gtk-dialog-authentication + 1 + + + + + end + 6 + + + + + False + False + 3 + 0 + + + + + + + + True + 0.029999999329447746 + + + True + 12 + + + True + 2 + 6 + 7 + 7 + + + True + 0 + _Given: + True + center + given_name + + + GTK_FILL + + + + + + True + 0 + T_itle: + True + + + 1 + 2 + GTK_FILL + + + + + + True + 0 + Suffi_x: + True + suffix + + + 2 + 3 + 1 + 2 + GTK_FILL + + + + + + True + 0 + C_all Name: + True + call + + + 4 + 5 + GTK_FILL + + + + + + True + True + True + True + + + + 1 + 4 + + + + + + True + 0 + _Nick Name: + True + nickname + + + 4 + 5 + 1 + 2 + GTK_FILL + + + + + + True + True + + + + 5 + 6 + + + + + True + True + + + + 1 + 2 + 1 + 2 + + + + + True + True + + + + 3 + 4 + 1 + 2 + + + + + True + True + + + + 5 + 6 + 1 + 2 + + + + + + + + + True + <i>Given Name(s) </i> + True - 4 - 5 - 2 - 3 - GTK_FILL - + False + False + 3 + 2 - + True - True - + 0.029999999329447746 + none + + + True + 12 + + + True + + + True + + + + + + + + + 0 + + + + + True + + + True + 0 + _Family Nick Name: + True + familynickname + + + False + 0 + + + + + True + True + + 25 + + + False + 3 + 1 + + + + + 3 + 1 + + + + + + + + + True + <i>Family Names </i> + True + + - 1 - 2 - 1 - 2 - - - - - - True - 0 - Call _Name: - True - call - - - 2 - 3 - 1 - 2 - GTK_FILL - - - - - - True - True - - - - 3 - 5 - 1 - 2 - + False + False + 2 + 3 @@ -288,6 +344,12 @@ 0 + + + + + + True @@ -367,7 +429,6 @@ True - liststore2 @@ -405,7 +466,6 @@ True - liststore1 @@ -555,7 +615,7 @@ - 1 + 3 @@ -591,7 +651,6 @@ True True True - True True True Accept changes and close window @@ -634,16 +693,4 @@ button131 - - - - - - - - - - - - diff --git a/src/glade/editperson.glade b/src/glade/editperson.glade index 3550b211a..73d660b24 100644 --- a/src/glade/editperson.glade +++ b/src/glade/editperson.glade @@ -134,7 +134,7 @@ True 0 - Gi_ven: + _Given: True center given_name @@ -148,7 +148,7 @@ True 0 - _Title: + T_itle: True title @@ -180,7 +180,7 @@ True 0 - Call _Name: + C_all Name: True call @@ -209,7 +209,7 @@ True 0 - N_ick Name: + _Nick Name: True nickname @@ -716,7 +716,7 @@ True 0 - _Gender: + G_ender: True gender @@ -729,12 +729,6 @@ - - - - - - True @@ -759,6 +753,12 @@ + + + + + + False diff --git a/src/gui/editors/displaytabs/Makefile.am b/src/gui/editors/displaytabs/Makefile.am index eaa2438f7..73a8619f2 100644 --- a/src/gui/editors/displaytabs/Makefile.am +++ b/src/gui/editors/displaytabs/Makefile.am @@ -42,6 +42,8 @@ pkgdata_PYTHON = \ sourcebackreflist.py \ sourceembedlist.py \ sourcerefmodel.py \ + surnamemodel.py \ + surnametab.py \ webembedlist.py \ webmodel.py \ __init__.py diff --git a/src/gui/editors/displaytabs/__init__.py b/src/gui/editors/displaytabs/__init__.py index b04413e1d..119114911 100644 --- a/src/gui/editors/displaytabs/__init__.py +++ b/src/gui/editors/displaytabs/__init__.py @@ -55,6 +55,7 @@ from personrefembedlist import PersonRefEmbedList from personbackreflist import PersonBackRefList from placebackreflist import PlaceBackRefList from repoembedlist import RepoEmbedList +from surnametab import SurnameTab from sourcebackreflist import SourceBackRefList from sourceembedlist import SourceEmbedList from webembedlist import WebEmbedList diff --git a/src/gui/editors/displaytabs/surnamemodel.py b/src/gui/editors/displaytabs/surnamemodel.py new file mode 100644 index 000000000..2c2ff64fc --- /dev/null +++ b/src/gui/editors/displaytabs/surnamemodel.py @@ -0,0 +1,55 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2010 Benny Malengier +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id$ + +#------------------------------------------------------------------------- +# +# GTK libraries +# +#------------------------------------------------------------------------- +import gtk +import gobject + +#------------------------------------------------------------------------- +# +# GRAMPS classes +# +#------------------------------------------------------------------------- + + +#------------------------------------------------------------------------- +# +# SurnamModel +# +#------------------------------------------------------------------------- +class SurnameModel(gtk.ListStore): + + def __init__(self, surn_list, db): + #setup model for the treeview + gtk.ListStore.__init__(self, str, str, str, gobject.TYPE_PYOBJECT, + bool, object) + for surn in surn_list: + # fill the liststore + self.append(row=[surn.get_prefix(), surn.get_surname(), + surn.get_connector(), surn.get_origintype(), + surn.get_primary(), surn]) + self.db = db diff --git a/src/gui/editors/displaytabs/surnametab.py b/src/gui/editors/displaytabs/surnametab.py new file mode 100644 index 000000000..e2510487f --- /dev/null +++ b/src/gui/editors/displaytabs/surnametab.py @@ -0,0 +1,214 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2010 Benny Malengier +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id$ + +#------------------------------------------------------------------------- +# +# Python classes +# +#------------------------------------------------------------------------- +from gen.ggettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GTK classes +# +#------------------------------------------------------------------------- +import gtk +_TAB = gtk.gdk.keyval_from_name("Tab") +_ENTER = gtk.gdk.keyval_from_name("Enter") + +#------------------------------------------------------------------------- +# +# GRAMPS classes +# +#------------------------------------------------------------------------- +from surnamemodel import SurnameModel +from embeddedlist import EmbeddedList +from DdTargets import DdTargets +from gen.lib import Surname, NameOriginType + +#------------------------------------------------------------------------- +# +# SurnameTab +# +#------------------------------------------------------------------------- +class SurnameTab(EmbeddedList): + + _HANDLE_COL = 5 + _DND_TYPE = DdTargets.SURNAME + + _MSG = { + 'add' : _('Create and add a new surname'), + 'del' : _('Remove the selected surname'), + 'edit' : _('Edit the selected surname'), + 'up' : _('Move the selected surname upwards'), + 'down' : _('Move the selected surname downwards'), + } + + #index = column in model. Value = + # (name, sortcol in model, width, markup/text + _column_names = [ + (_('Prefix'), 0, 150, 0, -1), + (_('Surname'), 1, 250, 0, -1), + (_('Connector'), 2, 100, 0, -1), + ] + + def __init__(self, dbstate, uistate, track, name): + self.obj = name + self.curr_col = -1 + self.curr_cellr = None + + EmbeddedList.__init__(self, dbstate, uistate, track, _('Family Surnames'), + SurnameModel, move_buttons=True) + + def build_columns(self): + #first the standard text columns with normal method + EmbeddedList.build_columns(self) + + # Need to add attributes to renderers + # and connect renderers to the 'edited' signal + for colno in range(len(self.columns)): + for renderer in self.columns[colno].get_cell_renderers(): + renderer.set_property('editable', not self.dbstate.db.readonly) + renderer.connect('editing_started', self.edit_start, colno) + renderer.connect('edited', self.edit_inline, colno) + + # now we add the two special columns + # TODO + + def get_data(self): + return self.obj.get_surname_list() + + def is_empty(self): + return len(self.model)==0 + + def _get_surn_from_model(self): + """ + Return new surname_list for storing in the name based on content of + the model + """ + new_list = [] + for idx in range(len(self.model)): + node = self.model.get_iter(idx) + surn = self.model.get_value(node, 5) + surn.set_prefix(unicode(self.model.get_value(node, 0))) + surn.set_surname(unicode(self.model.get_value(node, 1))) + surn.set_connector(unicode(self.model.get_value(node, 2))) + surn.set_primary(self.model.get_value(node, 4)) + new_list += [surn] + return new_list + + def update(self): + new_map = self._get_surn_from_model() + self.obj.set_surname_list(new_map) + # update name in title name editor + # TODO + + def column_order(self): + # order of columns for EmbeddedList. Only the text columns here + return ((1, 0), (1, 1), (1, 2)) + + def add_button_clicked(self, obj): + prim = False + if len(self.obj.get_surname_list()) == 0: + prim = true + node = self.model.append(row=['', '', '', NameOriginType(), prim, + Surname()]) + self.selection.select_iter(node) + path = self.model.get_path(node) + self.tree.set_cursor_on_cell(path, + focus_column=self.columns[0], + focus_cell=None, + start_editing=True) + + def del_button_clicked(self, obj): + (model, node) = self.selection.get_selected() + if node: + self.model.remove(node) + self.update() + + def edit_start(self, cellr, obj, path, colnr): + self.curr_col = colnr + self.curr_cellr = cellr + + def edit_inline(self, cell, path, new_text, colnr): + node = self.model.get_iter(path) + self.model.set_value(node, colnr, new_text) + self.update() + + def edit_button_clicked(self, obj): + (model, node) = self.selection.get_selected() + if node: + path = self.model.get_path(node) + self.tree.set_cursor_on_cell(path, + focus_column=self.columns[0], + focus_cell=None, + start_editing=True) + + def key_pressed(self, obj, event): + """ + Handles the key being pressed. + Here we make sure tab moves to next value in row + """ + if not EmbeddedList.key_pressed(self, obj, event): + if event.type == gtk.gdk.KEY_PRESS and event.keyval in (_TAB,): + if event.state not in (gtk.gdk.SHIFT_MASK, gtk.gdk.CONTROL_MASK): + self.next_cell() + elif event.state in (gtk.gdk.SHIFT_MASK, gtk.gdk.CONTROL_MASK): + self.prev_cell() + else: + return + elif event.type == gtk.gdk.KEY_PRESS and event.keyval in (_ENTER,): + self.next_cell() + else: + return + return True + + def next_cell(self): + """ + Move to the next cell to edit it + """ + print 'captured tab' + (model, node) = self.selection.get_selected() + if node: + path = self.model.get_path(node) + if self.curr_col+1 < len(self.columns): + self.tree.set_cursor_on_cell(path, + focus_column=self.columns[self.curr_col+1], + focus_cell=None, + start_editing=True) + elif self.curr_col+1 == len(self.columns): + #go to next line if there is one + if path[0]+1 < len(self.obj.get_surname_list()): + newpath = (path[0]+1,) + self.selection.select_path(newpath) + self.tree.set_cursor_on_cell(newpath, + focus_column=self.columns[0], + focus_cell=None, + start_editing=True) + else: + #stop editing + self.curr_cellr.stop_editing(True) + + def prev_cell(self): + print 'captured tab prev' diff --git a/src/gui/editors/editname.py b/src/gui/editors/editname.py index a486d6d98..5ca54378d 100644 --- a/src/gui/editors/editname.py +++ b/src/gui/editors/editname.py @@ -28,7 +28,9 @@ # Standard python modules # #------------------------------------------------------------------------- +import gobject from gen.ggettext import gettext as _ +from copy import copy #------------------------------------------------------------------------- # @@ -45,7 +47,7 @@ import gtk from gen.display.name import displayer as name_displayer from editsecondary import EditSecondary from gen.lib import NoteType -from displaytabs import GrampsTab,SourceEmbedList,NoteTab +from displaytabs import GrampsTab, SourceEmbedList, NoteTab, SurnameTab from gui.widgets import (MonitoredEntry, MonitoredMenu, MonitoredDate, MonitoredDataType, PrivacyButton) from glade import Glade @@ -111,12 +113,13 @@ class EditName(EditSecondary): self.top = Glade() - self.set_window(self.top.toplevel, - self.top.get_object("title"), - _("Name Editor")) + self.set_window(self.top.toplevel, None, _("Name Editor")) tblgnam = self.top.get_object('table23') notebook = self.top.get_object('notebook') + hbox_surn = self.top.get_object('hboxmultsurnames') + hbox_surn.pack_start(SurnameTab(self.dbstate, self.uistate, self.track, + self.obj)) #recreate start page as GrampsTab notebook.remove_page(0) self.gennam = GeneralNameTab(self.dbstate, self.uistate, self.track, @@ -147,7 +150,19 @@ class EditName(EditSecondary): def _connect_signals(self): self.define_cancel_button(self.top.get_object('button119')) self.define_help_button(self.top.get_object('button131')) - self.define_ok_button(self.top.get_object('button118'),self.save) + self.define_ok_button(self.top.get_object('button118'), self.save) + + def _validate_call(self, widget, text): + """ a callname must be a part of the given name, see if this is the + case """ + validcall = self.given_field.obj.get_text().split() + dummy = copy(validcall) + for item in dummy: + validcall += item.split('-') + if text in validcall: + return + return ValidationError(_("Call name must be the given name that " + "is normally used.")) def _setup_fields(self): self.group_as = MonitoredEntry( @@ -180,7 +195,7 @@ class EditName(EditSecondary): self.db.readonly) self.given_field = MonitoredEntry( - self.top.get_object("alt_given"), + self.top.get_object("given_name"), self.obj.set_first_name, self.obj.get_first_name, self.db.readonly) @@ -190,39 +205,42 @@ class EditName(EditSecondary): self.obj.set_call_name, self.obj.get_call_name, self.db.readonly) + self.call_field.connect("validate", self._validate_call) + #force validation now with initial entry + self.call_field.obj.validate(force=True) self.title_field = MonitoredEntry( - self.top.get_object("alt_title"), + self.top.get_object("title_field"), self.obj.set_title, self.obj.get_title, self.db.readonly) self.suffix_field = MonitoredEntry( - self.top.get_object("alt_suffix"), + self.top.get_object("suffix"), self.obj.set_suffix, self.obj.get_suffix, self.db.readonly) - self.patronymic_field = MonitoredEntry( - self.top.get_object("patronymic"), - self.obj.set_patronymic, - self.obj.get_patronymic, + self.nick = MonitoredEntry( + self.top.get_object("nickname"), + self.obj.set_nick_name, + self.obj.get_nick_name, self.db.readonly) - self.surname_field = MonitoredEntry( - self.top.get_object("alt_surname"), - self.obj.set_surname, - self.obj.get_surname, - self.db.readonly, - autolist=self.db.get_surname_list() if not self.db.readonly else [], - changed=self.update_group_as) - - self.prefix_field = MonitoredEntry( - self.top.get_object("alt_prefix"), - self.obj.set_surname_prefix, - self.obj.get_surname_prefix, + self.famnick = MonitoredEntry( + self.top.get_object("familynickname"), + self.obj.set_family_nick_name, + self.obj.get_family_nick_name, self.db.readonly) + #self.surname_field = MonitoredEntry( + # self.top.get_object("alt_surname"), + # self.obj.set_surname, + # self.obj.get_surname, + # self.db.readonly, + # autolist=self.db.get_surname_list() if not self.db.readonly else [], + # changed=self.update_group_as) + self.date = MonitoredDate( self.top.get_object("date_entry"), self.top.get_object("date_stat"), @@ -232,7 +250,7 @@ class EditName(EditSecondary): self.db.readonly) self.obj_combo = MonitoredDataType( - self.top.get_object("name_type"), + self.top.get_object("ntype"), self.obj.set_type, self.obj.get_type, self.db.readonly, @@ -322,7 +340,7 @@ class EditName(EditSecondary): surname = self.obj.get_surname() self.group_as.set_text(surname) - def save(self,*obj): + def save(self, *obj): """Save the name setting. All is ok, except grouping. We need to consider: 1/ global set, not local set --> unset (ask if global unset) diff --git a/src/gui/editors/editperson.py b/src/gui/editors/editperson.py index 7d7d218ab..ffb89487f 100644 --- a/src/gui/editors/editperson.py +++ b/src/gui/editors/editperson.py @@ -31,6 +31,7 @@ to edit information about a particular Person. # Standard python modules # #------------------------------------------------------------------------- +from copy import copy from gen.ggettext import sgettext as _ #------------------------------------------------------------------------- @@ -63,7 +64,7 @@ from Errors import ValidationError from displaytabs import (PersonEventEmbedList, NameEmbedList, SourceEmbedList, AttrEmbedList, AddrEmbedList, NoteTab, GalleryTab, WebEmbedList, PersonRefEmbedList, LdsEmbedList, - PersonBackRefList) + PersonBackRefList, SurnameTab) from gen.plug import CATEGORY_QR_PERSON #------------------------------------------------------------------------- @@ -150,6 +151,9 @@ class EditPerson(EditPrimary): self.singsurnfr = self.top.get_object("surnamefr") self.multsurnfr = self.top.get_object("multsurnamefr") self.singlesurn_active = True + self.surntab = SurnameTab(self.dbstate, self.uistate, self.track, + self.obj.get_primary_name()) + self.top.get_object("hboxmultsurnames").pack_start(self.surntab) self.set_contexteventbox(self.top.get_object("eventboxtop")) @@ -166,7 +170,12 @@ class EditPerson(EditPrimary): self.load_person_image() self.given.grab_focus() - self.multsurnfr.hide_all() + if len(self.obj.get_primary_name().get_surname_list()) > 1: + self.singsurnfr.hide_all() + self.singlesurn_active = False + else: + self.multsurnfr.hide_all() + self.singlesurn_active = True #if self.pname.get_surname() and not self.pname.get_first_name(): # self.given.grab_focus() #else: @@ -184,6 +193,8 @@ class EditPerson(EditPrimary): self.given.connect("focus_out_event", self._given_focus_out_event) self.top.get_object("editnamebtn").connect("clicked", self._edit_name_clicked) + self.top.get_object("multsurnamebtn").connect("clicked", + self._mult_surn_clicked) self.eventbox.connect('button-press-event', self._image_button_press) @@ -241,8 +252,13 @@ class EditPerson(EditPrimary): def _validate_call(self, widget, text): """ a callname must be a part of the given name, see if this is the case """ - if not text in self.given.obj.get_text().split(): - return ValidationError(_("Call name must be the given name that " + validcall = self.given.obj.get_text().split() + dummy = copy(validcall) + for item in dummy: + validcall += item.split('-') + if text in validcall: + return + return ValidationError(_("Call name must be the given name that " "is normally used.")) def _setup_fields(self): @@ -811,6 +827,14 @@ class EditPerson(EditPrimary): EditName(self.dbstate, self.uistate, self.track, self.pname, self._update_name) + def _mult_surn_clicked(self, obj): + """ + Show the list entry of multiple surnames + """ + self.singsurnfr.hide_all() + self.singlesurn_active = False + self.multsurnfr.show_all() + def _update_name(self, name): """ Called when the primary name has been changed by the EditName @@ -819,9 +843,15 @@ class EditPerson(EditPrimary): This allows us to update the main form in response to any changes. """ - for obj in (self.prefix_suffix, self.patro_title, self.given, - self.ntype_field, self.surname_field, self.call): + for obj in (self.ntype_field, self.given, self.call, self.title, + self.suffix, self.nick, self.surname_field, self.prefix, + self.ortype_field): obj.update() + if len(self.obj.get_primary_name().get_surname_list()) > 1: + #TODO: multiple surname must be activated if not yet the case + print 'person editor TODO' + #TODO: update list of surnames + print 'person editor TODO 2' def load_person_image(self): """ diff --git a/src/gui/editors/editsecondary.py b/src/gui/editors/editsecondary.py index 0126f22f6..cae0401ad 100644 --- a/src/gui/editors/editsecondary.py +++ b/src/gui/editors/editsecondary.py @@ -32,6 +32,7 @@ class EditSecondary(ManagedWindow.ManagedWindow, DbGUIElement): """Create an edit window. Associates a person with the window.""" self.obj = obj + self.old_obj = obj.serialize() self.dbstate = state self.uistate = uistate self.db = state.db @@ -113,13 +114,20 @@ class EditSecondary(ManagedWindow.ManagedWindow, DbGUIElement): button.set_sensitive(not self.db.readonly) def define_cancel_button(self,button): - button.connect('clicked',self.close) + button.connect('clicked', self.canceledits) def define_help_button(self, button, webpage='', section=''): button.connect('clicked', lambda x: GrampsDisplay.help(webpage, section)) - def close(self,*obj): + def canceledits(self, *obj): + """ + Undo the edits that happened on this secondary object + """ + self.obj.unserialize(self.old_obj) + self.close(obj) + + def close(self, *obj): self._cleanup_db_connects() self._cleanup_on_exit() ManagedWindow.ManagedWindow.close(self)