2007-05-14 Espen Berg <espen.berg@ntnu.no>
* src/DateHandler/_Date_nb.py: svn: r8470
This commit is contained in:
parent
c7de89499c
commit
f00b8f381c
@ -1,3 +1,6 @@
|
||||
2007-05-14 Espen Berg <espen.berg@ntnu.no>
|
||||
* src/DateHandler/_Date_nb.py:
|
||||
|
||||
2007-05-13 Brian Matherly <brian@gramps-project.org>
|
||||
* src/plugins/NarrativeWeb.py: Fix reference paths on Windows.
|
||||
|
||||
|
171
gramps2/src/DateHandler/_Date_nb.py
Normal file
171
gramps2/src/DateHandler/_Date_nb.py
Normal file
@ -0,0 +1,171 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2006 Donald N. Allingham
|
||||
#
|
||||
# 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: _Date_nb.py 2007-05-10 13:37:16Z espenbe $
|
||||
|
||||
"""
|
||||
Nowegian-specific classes for parsing and displaying dates.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import re
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from RelLib import Date
|
||||
from _DateParser import DateParser
|
||||
from _DateDisplay import DateDisplay
|
||||
from _DateHandler import register_datehandler
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Swedish parser class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateParserNb(DateParser):
|
||||
"""
|
||||
Converts a text string into a Date object, expecting a date
|
||||
notation in the swedish language. If the date cannot be converted,
|
||||
the text string is assigned.
|
||||
"""
|
||||
|
||||
# modifiers before the date
|
||||
modifier_to_int = {
|
||||
u'før' : Date.MOD_BEFORE,
|
||||
u'innen' : Date.MOD_BEFORE,
|
||||
u'etter' : Date.MOD_AFTER,
|
||||
u'omkring' : Date.MOD_ABOUT,
|
||||
u'ca' : Date.MOD_ABOUT,
|
||||
u'ca' : Date.MOD_ABOUT
|
||||
}
|
||||
|
||||
bce = ["f Kr"]
|
||||
|
||||
calendar_to_int = {
|
||||
u'gregoriansk ' : Date.CAL_GREGORIAN,
|
||||
u'g' : Date.CAL_GREGORIAN,
|
||||
u'juliansk' : Date.CAL_JULIAN,
|
||||
u'j' : Date.CAL_JULIAN,
|
||||
u'hebraisk' : Date.CAL_HEBREW,
|
||||
u'h' : Date.CAL_HEBREW,
|
||||
u'islamisk' : Date.CAL_ISLAMIC,
|
||||
u'muslimsk' : Date.CAL_ISLAMIC,
|
||||
u'i' : Date.CAL_ISLAMIC,
|
||||
u'fransk' : Date.CAL_FRENCH,
|
||||
u'fransk republikansk' : Date.CAL_FRENCH,
|
||||
u'f' : Date.CAL_FRENCH,
|
||||
u'persisk' : Date.CAL_PERSIAN,
|
||||
u'p' : Date.CAL_PERSIAN,
|
||||
}
|
||||
|
||||
quality_to_int = {
|
||||
u'estimert' : Date.QUAL_ESTIMATED,
|
||||
u'estimert' : Date.QUAL_ESTIMATED,
|
||||
u'antatt' : Date.QUAL_ESTIMATED,
|
||||
u'antatt' : Date.QUAL_ESTIMATED,
|
||||
u'beregnet' : Date.QUAL_CALCULATED,
|
||||
u'beregnet' : Date.QUAL_CALCULATED,
|
||||
}
|
||||
|
||||
def init_strings(self):
|
||||
DateParser.init_strings(self)
|
||||
self._span = re.compile(u"(fra)?\s*(?P<start>.+)\s*(til|--|–)\s*(?P<stop>.+)",
|
||||
re.IGNORECASE)
|
||||
self._range = re.compile(u"(mellom)\s+(?P<start>.+)\s+og\s+(?P<stop>.+)",
|
||||
re.IGNORECASE)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Swedish display class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayNb(DateDisplay):
|
||||
"""
|
||||
Norwegian language date display class.
|
||||
"""
|
||||
|
||||
formats = (
|
||||
u"YYYY-MM-DD (ISO)",
|
||||
u"Numerisk",
|
||||
u"Måned dag, år",
|
||||
u"MND DAG ÅR",
|
||||
u"Dag måned år",
|
||||
u"DAG MND ÅR",
|
||||
)
|
||||
|
||||
calendar = (
|
||||
"",
|
||||
" (juliansk)",
|
||||
" (hebraisk)",
|
||||
" (fransk republikansk)",
|
||||
" (persisk)",
|
||||
" (islamisk)"
|
||||
)
|
||||
|
||||
_mod_str = ("",u"før ",u"etter ",u"ca ","","","")
|
||||
|
||||
_qual_str = ("",u"estimert ",u"beregnet ")
|
||||
|
||||
_bce_str = "%s f Kr"
|
||||
|
||||
def display(self,date):
|
||||
"""
|
||||
Returns a text string representing the date.
|
||||
"""
|
||||
mod = date.get_modifier()
|
||||
cal = date.get_calendar()
|
||||
qual = date.get_quality()
|
||||
start = date.get_start_date()
|
||||
|
||||
qual_str = self._qual_str[qual]
|
||||
|
||||
if mod == Date.MOD_TEXTONLY:
|
||||
return date.get_text()
|
||||
elif start == Date.EMPTY:
|
||||
return u""
|
||||
elif mod == Date.MOD_SPAN:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return u"%sfra %s til %s%s" % (qual_str,d1,d2,self.calendar[cal])
|
||||
elif mod == Date.MOD_RANGE:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return u"%smellom %s og %s%s" % (qual_str,d1,d2,
|
||||
self.calendar[cal])
|
||||
else:
|
||||
text = self.display_cal[date.get_calendar()](start)
|
||||
return u"%s%s%s%s" % (qual_str,self._mod_str[mod],
|
||||
text,self.calendar[cal])
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Register classes
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
register_datehandler(('nb_NO','nb','norsk'),DateParserNb, DateDisplayNb)
|
||||
|
@ -20,6 +20,10 @@
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Family Editor dialog
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# python modules
|
||||
@ -108,6 +112,9 @@ class ChildEmbedList(EmbeddedList):
|
||||
_('Children'), ChildModel, True)
|
||||
|
||||
def get_popup_menu_items(self):
|
||||
"""
|
||||
Creates the data for the popup menu
|
||||
"""
|
||||
return [
|
||||
(True, True, gtk.STOCK_ADD, self.add_button_clicked),
|
||||
(True, False, _('Share'), self.edit_button_clicked),
|
||||
@ -116,33 +123,36 @@ class ChildEmbedList(EmbeddedList):
|
||||
(True, True, gtk.STOCK_REMOVE, self.del_button_clicked),
|
||||
]
|
||||
|
||||
def find_index(self,obj):
|
||||
def find_index(self, obj):
|
||||
"""
|
||||
returns the index of the object within the associated data
|
||||
"""
|
||||
reflist = [ref.ref for ref in self.family.get_child_ref_list()]
|
||||
reflist = [ref.ref for ref in self.family.get_child_ref_list()]
|
||||
return reflist.index(obj)
|
||||
|
||||
def _find_row(self,x,y):
|
||||
row = self.tree.get_path_at_pos(x,y)
|
||||
def _find_row(self, x_loc, y_loc):
|
||||
"""
|
||||
Find the row from x/y coordinates
|
||||
"""
|
||||
row = self.tree.get_path_at_pos(x_loc, y_loc)
|
||||
if row == None:
|
||||
return len(self.family.get_child_ref_list())
|
||||
else:
|
||||
return row[0][0]
|
||||
|
||||
def _handle_drag(self, row, obj):
|
||||
self.family.get_child_ref_list().insert(row,obj)
|
||||
self.family.get_child_ref_list().insert(row, obj)
|
||||
self.changed = True
|
||||
self.rebuild()
|
||||
|
||||
def _move(self, row_from, row_to, obj):
|
||||
dlist = self.family.get_child_ref_list()
|
||||
if row_from < row_to:
|
||||
dlist.insert(row_to,obj)
|
||||
dlist.insert(row_to, obj)
|
||||
del dlist[row_from]
|
||||
else:
|
||||
del dlist[row_from]
|
||||
dlist.insert(row_to-1,obj)
|
||||
dlist.insert(row_to-1, obj)
|
||||
self.changed = True
|
||||
self.rebuild()
|
||||
|
||||
@ -187,9 +197,10 @@ class ChildEmbedList(EmbeddedList):
|
||||
return self.family
|
||||
|
||||
def column_order(self):
|
||||
return [(1,0),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(0,8),(0,9)]
|
||||
return [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),
|
||||
(1, 6), (0, 8), (0, 9)]
|
||||
|
||||
def add_button_clicked(self,obj):
|
||||
def add_button_clicked(self, obj):
|
||||
from Editors import EditPerson
|
||||
|
||||
person = RelLib.Person()
|
||||
@ -203,7 +214,7 @@ class ChildEmbedList(EmbeddedList):
|
||||
person.get_primary_name().set_surname(name[1])
|
||||
person.get_primary_name().set_surname_prefix(name[0])
|
||||
|
||||
EditPerson(self.dbstate, self.uistate, self.track,person,
|
||||
EditPerson(self.dbstate, self.uistate, self.track, person,
|
||||
self.new_child_added)
|
||||
|
||||
def new_child_added(self, person):
|
||||
@ -215,7 +226,7 @@ class ChildEmbedList(EmbeddedList):
|
||||
def child_ref_edited(self, person):
|
||||
self.rebuild()
|
||||
|
||||
def share_button_clicked(self,obj):
|
||||
def share_button_clicked(self, obj):
|
||||
# it only makes sense to skip those who are already in the family
|
||||
|
||||
skip_list = [self.family.get_father_handle(), \
|
||||
@ -232,12 +243,12 @@ class ChildEmbedList(EmbeddedList):
|
||||
self.family.add_child_ref(ref)
|
||||
self.rebuild()
|
||||
|
||||
def run(self,skip):
|
||||
def run(self, skip):
|
||||
skip_list = [ x for x in skip if x]
|
||||
SelectPerson(self.dbstate, self.uistate, self.track,
|
||||
_("Select Child"), skip=skip_list)
|
||||
|
||||
def del_button_clicked(self,obj):
|
||||
def del_button_clicked(self, obj):
|
||||
handle = self.get_selected()
|
||||
if handle:
|
||||
for ref in self.family.get_child_ref_list():
|
||||
@ -245,7 +256,7 @@ class ChildEmbedList(EmbeddedList):
|
||||
self.family.remove_child_ref(ref)
|
||||
self.rebuild()
|
||||
|
||||
def edit_button_clicked(self,obj):
|
||||
def edit_button_clicked(self, obj):
|
||||
handle = self.get_selected()
|
||||
if handle:
|
||||
from Editors import EditChildRef
|
||||
@ -269,11 +280,11 @@ class ChildEmbedList(EmbeddedList):
|
||||
for ref in self.family.get_child_ref_list():
|
||||
if ref.ref == handle:
|
||||
try:
|
||||
p = self.dbstate.db.get_person_from_handle(handle)
|
||||
person = self.dbstate.db.get_person_from_handle(handle)
|
||||
EditPerson(self.dbstate, self.uistate, self.track,
|
||||
p, self.child_ref_edited)
|
||||
person, self.child_ref_edited)
|
||||
except Errors.WindowActiveError:
|
||||
pass
|
||||
continue
|
||||
break
|
||||
|
||||
def drag_data_received(self, widget, context, x, y, sel_data, info, time):
|
||||
@ -296,12 +307,12 @@ class ChildEmbedList(EmbeddedList):
|
||||
# it is a standard drag-n-drop
|
||||
|
||||
if id(self) == selfid:
|
||||
obj = self.get_data().get_child_ref_list()[row_from]
|
||||
obj = self.get_data().get_child_ref_list()[row_from]
|
||||
self._move(row_from, row, obj)
|
||||
else:
|
||||
handle = obj
|
||||
obj = RelLib.ChildRef()
|
||||
obj.ref = handle
|
||||
handle = obj
|
||||
obj = RelLib.ChildRef()
|
||||
obj.ref = handle
|
||||
self._handle_drag(row, obj)
|
||||
self.rebuild()
|
||||
elif self._DND_EXTRA and mytype == self._DND_EXTRA.drag_type:
|
||||
@ -312,34 +323,34 @@ class ChildEmbedList(EmbeddedList):
|
||||
if father_handle:
|
||||
father = self.dbstate.db.get_person_from_handle(father_handle)
|
||||
pname = father.get_primary_name()
|
||||
return (pname.get_surname_prefix(),pname.get_surname())
|
||||
return ("","")
|
||||
return (pname.get_surname_prefix(), pname.get_surname())
|
||||
return ("", "")
|
||||
|
||||
def no_name(self):
|
||||
return ("","")
|
||||
return ("", "")
|
||||
|
||||
def latin_american(self):
|
||||
if self.family:
|
||||
father_handle = self.family.get_father_handle()
|
||||
mother_handle = self.family.get_mother_handle()
|
||||
if not father_handle or not mother_handle:
|
||||
return ("","")
|
||||
return ("", "")
|
||||
father = self.dbstate.db.get_person_from_handle(father_handle)
|
||||
mother = self.dbstate.db.get_person_from_handle(mother_handle)
|
||||
fsn = father.get_primary_name().get_surname()
|
||||
msn = mother.get_primary_name().get_surname()
|
||||
if not father or not mother:
|
||||
return ("","")
|
||||
return ("", "")
|
||||
try:
|
||||
return ("","%s %s" % (fsn.split()[0],msn.split()[0]))
|
||||
return ("", "%s %s" % (fsn.split()[0], msn.split()[0]))
|
||||
except:
|
||||
return ("","")
|
||||
return ("", "")
|
||||
else:
|
||||
return ("","")
|
||||
return ("", "")
|
||||
|
||||
class FastMaleFilter:
|
||||
|
||||
def __init__(self,db):
|
||||
def __init__(self, db):
|
||||
self.db = db
|
||||
|
||||
def match(self, handle):
|
||||
@ -348,7 +359,7 @@ class FastMaleFilter:
|
||||
|
||||
class FastFemaleFilter:
|
||||
|
||||
def __init__(self,db):
|
||||
def __init__(self, db):
|
||||
self.db = db
|
||||
|
||||
def match(self, handle):
|
||||
@ -362,7 +373,7 @@ class FastFemaleFilter:
|
||||
#-------------------------------------------------------------------------
|
||||
class EditFamily(EditPrimary):
|
||||
|
||||
def __init__(self,dbstate, uistate, track, family):
|
||||
def __init__(self, dbstate, uistate, track, family):
|
||||
|
||||
self.tooltips = gtk.Tooltips()
|
||||
EditPrimary.__init__(self, dbstate, uistate, track,
|
||||
@ -416,9 +427,10 @@ class EditFamily(EditPrimary):
|
||||
def check_for_family_change(self, handles):
|
||||
|
||||
# check to see if the handle matches the current object
|
||||
if self.obj.get_handle() in handles:
|
||||
hndl = self.obj.get_handle()
|
||||
if hndl in handles:
|
||||
|
||||
self.obj = self.dbstate.db.get_family_from_handle(self.obj.get_handle())
|
||||
self.obj = self.dbstate.db.get_family_from_handle(hndl)
|
||||
self.reload_people()
|
||||
self.event_embed.rebuild()
|
||||
self.source_embed.rebuild()
|
||||
@ -449,12 +461,12 @@ class EditFamily(EditPrimary):
|
||||
dialog_title = _("New Family")
|
||||
return dialog_title
|
||||
|
||||
def build_menu_names(self,family):
|
||||
def build_menu_names(self, family):
|
||||
return (_('Edit Family'), self.get_menu_title())
|
||||
|
||||
def build_interface(self):
|
||||
|
||||
self.top = gtk.glade.XML(const.gladeFile,"family_editor","gramps")
|
||||
self.top = gtk.glade.XML(const.gladeFile, "family_editor", "gramps")
|
||||
|
||||
self.set_window(self.top.get_widget("family_editor"), None, self.get_menu_title())
|
||||
|
||||
@ -463,16 +475,16 @@ class EditFamily(EditPrimary):
|
||||
height = Config.get(Config.FAMILY_HEIGHT)
|
||||
self.window.set_default_size(width, height)
|
||||
|
||||
self.fbirth = self.top.get_widget('fbirth')
|
||||
self.fdeath = self.top.get_widget('fdeath')
|
||||
self.fbirth = self.top.get_widget('fbirth')
|
||||
self.fdeath = self.top.get_widget('fdeath')
|
||||
|
||||
self.mbirth = self.top.get_widget('mbirth')
|
||||
self.mdeath = self.top.get_widget('mdeath')
|
||||
self.mbirth = self.top.get_widget('mbirth')
|
||||
self.mdeath = self.top.get_widget('mdeath')
|
||||
|
||||
self.mbutton = self.top.get_widget('mbutton')
|
||||
self.mbutton2= self.top.get_widget('mbutton2')
|
||||
self.fbutton = self.top.get_widget('fbutton')
|
||||
self.fbutton2= self.top.get_widget('fbutton2')
|
||||
self.mbutton = self.top.get_widget('mbutton')
|
||||
self.mbutton2 = self.top.get_widget('mbutton2')
|
||||
self.fbutton = self.top.get_widget('fbutton')
|
||||
self.fbutton2 = self.top.get_widget('fbutton2')
|
||||
|
||||
self.tooltips.set_tip(self.mbutton2,
|
||||
_("Add a new person as the mother"))
|
||||
@ -491,7 +503,7 @@ class EditFamily(EditPrimary):
|
||||
|
||||
def _setup_fields(self):
|
||||
|
||||
self.private= PrivacyButton(
|
||||
self.private = PrivacyButton(
|
||||
self.top.get_widget('private'),
|
||||
self.obj,
|
||||
self.db.readonly)
|
||||
@ -530,10 +542,10 @@ class EditFamily(EditPrimary):
|
||||
|
||||
self.phandles = [handle for handle in self.phandles if handle]
|
||||
|
||||
self.mbutton.connect('clicked',self.mother_clicked)
|
||||
self.mbutton2.connect('clicked',self.add_mother_clicked)
|
||||
self.fbutton.connect('clicked',self.father_clicked)
|
||||
self.fbutton2.connect('clicked',self.add_father_clicked)
|
||||
self.mbutton.connect('clicked', self.mother_clicked)
|
||||
self.mbutton2.connect('clicked', self.add_mother_clicked)
|
||||
self.fbutton.connect('clicked', self.father_clicked)
|
||||
self.fbutton2.connect('clicked', self.add_father_clicked)
|
||||
|
||||
def _create_tabbed_pages(self):
|
||||
|
||||
@ -541,16 +553,19 @@ class EditFamily(EditPrimary):
|
||||
|
||||
self.child_list = self._add_tab(
|
||||
notebook,
|
||||
ChildEmbedList(self.dbstate,self.uistate, self.track, self.obj))
|
||||
ChildEmbedList(self.dbstate, self.uistate, self.track, self.obj))
|
||||
|
||||
self.event_embed = EventEmbedList(self.dbstate,self.uistate, self.track,self.obj)
|
||||
self.event_embed = EventEmbedList(self.dbstate, self.uistate,
|
||||
self.track, self.obj)
|
||||
self.event_list = self._add_tab(notebook, self.event_embed)
|
||||
|
||||
self.source_embed = SourceEmbedList(self.dbstate,self.uistate,self.track,self.obj)
|
||||
self.source_embed = SourceEmbedList(self.dbstate, self.uistate,
|
||||
self.track, self.obj)
|
||||
self.src_list = self._add_tab(notebook, self.source_embed)
|
||||
|
||||
self.attr_embed = FamilyAttrEmbedList(self.dbstate, self.uistate, self.track,
|
||||
self.obj.get_attribute_list())
|
||||
self.attr_embed = FamilyAttrEmbedList(
|
||||
self.dbstate, self.uistate, self.track,
|
||||
self.obj.get_attribute_list())
|
||||
self.attr_list = self._add_tab(notebook, self.attr_embed)
|
||||
|
||||
self.note_tab = self._add_tab(
|
||||
@ -571,15 +586,15 @@ class EditFamily(EditPrimary):
|
||||
notebook.show_all()
|
||||
|
||||
self.hidden = (notebook, self.top.get_widget('info'))
|
||||
self.top.get_widget('vbox').pack_start(notebook,True)
|
||||
self.top.get_widget('vbox').pack_start(notebook, True)
|
||||
|
||||
def update_father(self,handle):
|
||||
def update_father(self, handle):
|
||||
self.load_parent(handle, self.fbox, self.fbirth,
|
||||
self.fdeath, self.fbutton, self.fbutton2,
|
||||
_("Select a person as the father"),
|
||||
_("Remove the person as the father"))
|
||||
|
||||
def update_mother(self,handle):
|
||||
def update_mother(self, handle):
|
||||
self.load_parent(handle, self.mbox, self.mbirth,
|
||||
self.mdeath, self.mbutton, self.mbutton2,
|
||||
_("Select a person as the mother"),
|
||||
@ -630,8 +645,7 @@ class EditFamily(EditPrimary):
|
||||
|
||||
if person:
|
||||
self.check_for_existing_family(self.obj.get_father_handle(),
|
||||
person.handle,
|
||||
self.obj.handle)
|
||||
person.handle)
|
||||
|
||||
self.obj.set_mother_handle(person.handle)
|
||||
self.update_mother(person.handle)
|
||||
@ -673,16 +687,13 @@ class EditFamily(EditPrimary):
|
||||
person = sel.run()
|
||||
|
||||
if person:
|
||||
|
||||
self.check_for_existing_family(person.handle,
|
||||
self.obj.get_mother_handle(),
|
||||
self.obj.handle)
|
||||
self.obj.get_mother_handle())
|
||||
|
||||
self.obj.set_father_handle(person.handle)
|
||||
self.update_father(person.handle)
|
||||
|
||||
def check_for_existing_family(self, father_handle, mother_handle,
|
||||
family_handle):
|
||||
def check_for_existing_family(self, father_handle, mother_handle):
|
||||
|
||||
if father_handle:
|
||||
father = self.dbstate.db.get_person_from_handle(father_handle)
|
||||
@ -701,7 +712,7 @@ class EditFamily(EditPrimary):
|
||||
'you cancel the editing of this window, and '
|
||||
'select the existing family'))
|
||||
|
||||
def edit_person(self,obj,event,handle):
|
||||
def edit_person(self, obj, event, handle):
|
||||
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:
|
||||
from _EditPerson import EditPerson
|
||||
try:
|
||||
@ -730,19 +741,19 @@ class EditFamily(EditPrimary):
|
||||
person = db.get_person_from_handle(handle)
|
||||
name = "%s [%s]" % (NameDisplay.displayer.display(person),
|
||||
person.gramps_id)
|
||||
data = ReportUtils.get_birth_death_strings(db,person)
|
||||
data = ReportUtils.get_birth_death_strings(db, person)
|
||||
birth = data[0]
|
||||
death = data[4]
|
||||
|
||||
del_image = gtk.Image()
|
||||
del_image.show()
|
||||
del_image.set_from_stock(gtk.STOCK_REMOVE,gtk.ICON_SIZE_BUTTON)
|
||||
del_image.set_from_stock(gtk.STOCK_REMOVE, gtk.ICON_SIZE_BUTTON)
|
||||
self.tooltips.set_tip(btn_obj, del_msg)
|
||||
btn_obj.add(del_image)
|
||||
|
||||
box.pack_start(LinkBox(
|
||||
BasicLabel(name),
|
||||
IconButton(self.edit_person,person.handle)
|
||||
IconButton(self.edit_person, person.handle)
|
||||
))
|
||||
else:
|
||||
btn2_obj.show()
|
||||
@ -752,31 +763,31 @@ class EditFamily(EditPrimary):
|
||||
|
||||
add_image = gtk.Image()
|
||||
add_image.show()
|
||||
add_image.set_from_stock(gtk.STOCK_INDEX,gtk.ICON_SIZE_BUTTON)
|
||||
add_image.set_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)
|
||||
self.tooltips.set_tip(btn_obj, add_msg)
|
||||
btn_obj.add(add_image)
|
||||
|
||||
birth_obj.set_text(birth)
|
||||
death_obj.set_text(death)
|
||||
|
||||
def fix_parent_handles(self,orig_handle, new_handle, trans):
|
||||
def fix_parent_handles(self, orig_handle, new_handle, trans):
|
||||
if orig_handle != new_handle:
|
||||
if orig_handle:
|
||||
person = self.db.get_person_from_handle(orig_handle)
|
||||
person.family_list.remove(self.obj.handle)
|
||||
self.db.commit_person(person,trans)
|
||||
self.db.commit_person(person, trans)
|
||||
if new_handle:
|
||||
person = self.db.get_person_from_handle(new_handle)
|
||||
if self.obj.handle not in person.family_list:
|
||||
person.family_list.append(self.obj.handle)
|
||||
self.db.commit_person(person,trans)
|
||||
self.db.commit_person(person, trans)
|
||||
|
||||
def object_is_empty(self):
|
||||
return self.obj.get_father_handle() == None and \
|
||||
self.obj.get_mother_handle() == None and \
|
||||
len(self.obj.get_child_ref_list()) == 0
|
||||
|
||||
def save(self,*obj):
|
||||
def save(self, *obj):
|
||||
try:
|
||||
self.__do_save()
|
||||
except db.DBRunRecoveryError, msg:
|
||||
@ -814,7 +825,6 @@ class EditFamily(EditPrimary):
|
||||
self.ok_button.set_sensitive(True)
|
||||
return
|
||||
|
||||
|
||||
if not original and not self.object_is_empty():
|
||||
trans = self.db.transaction_begin()
|
||||
|
||||
@ -823,23 +833,23 @@ class EditFamily(EditPrimary):
|
||||
if handle:
|
||||
parent = self.db.get_person_from_handle(handle)
|
||||
parent.add_family_handle(self.obj.handle)
|
||||
self.db.commit_person(parent,trans)
|
||||
self.db.commit_person(parent, trans)
|
||||
|
||||
# find the mother, add the family handle to the mother
|
||||
handle = self.obj.get_mother_handle()
|
||||
if handle:
|
||||
parent = self.db.get_person_from_handle(handle)
|
||||
parent.add_family_handle(self.obj.handle)
|
||||
self.db.commit_person(parent,trans)
|
||||
self.db.commit_person(parent, trans)
|
||||
|
||||
# for each child, add the family handle to the child
|
||||
for ref in self.obj.get_child_ref_list():
|
||||
child = self.db.get_person_from_handle(ref.ref)
|
||||
# fix - relationships need to be extracted from the list
|
||||
child.add_parent_family_handle(self.obj.handle)
|
||||
self.db.commit_person(child,trans)
|
||||
self.db.commit_person(child, trans)
|
||||
|
||||
self.db.add_family(self.obj,trans)
|
||||
self.db.add_family(self.obj, trans)
|
||||
self.db.transaction_commit(trans,_("Add Family"))
|
||||
elif not original and self.object_is_empty():
|
||||
QuestionDialog.ErrorDialog(_("Cannot save family"),
|
||||
@ -848,16 +858,16 @@ class EditFamily(EditPrimary):
|
||||
return
|
||||
elif original and self.object_is_empty():
|
||||
trans = self.db.transaction_begin()
|
||||
self.db.remove_family(self.obj.handle,trans)
|
||||
self.db.remove_family(self.obj.handle, trans)
|
||||
self.db.transaction_commit(trans,_("Remove Family"))
|
||||
elif cmp(original.serialize(),self.obj.serialize()):
|
||||
|
||||
trans = self.db.transaction_begin()
|
||||
|
||||
self.fix_parent_handles(original.get_father_handle(),
|
||||
self.obj.get_father_handle(),trans)
|
||||
self.obj.get_father_handle(), trans)
|
||||
self.fix_parent_handles(original.get_mother_handle(),
|
||||
self.obj.get_mother_handle(),trans)
|
||||
self.obj.get_mother_handle(), trans)
|
||||
|
||||
orig_set = set(original.get_child_ref_list())
|
||||
new_set = set(self.obj.get_child_ref_list())
|
||||
@ -866,19 +876,19 @@ class EditFamily(EditPrimary):
|
||||
for ref in orig_set.difference(new_set):
|
||||
person = self.db.get_person_from_handle(ref.ref)
|
||||
person.remove_parent_family_handle(self.obj.handle)
|
||||
self.db.commit_person(person,trans)
|
||||
self.db.commit_person(person, trans)
|
||||
|
||||
# add the family from children which have been addedna
|
||||
for ref in new_set.difference(orig_set):
|
||||
person = self.db.get_person_from_handle(ref.ref)
|
||||
person.add_parent_family_handle(self.obj.handle)
|
||||
self.db.commit_person(person,trans)
|
||||
self.db.commit_person(person, trans)
|
||||
|
||||
if self.object_is_empty():
|
||||
self.db.remove_family(self.obj.handle,trans)
|
||||
self.db.remove_family(self.obj.handle, trans)
|
||||
else:
|
||||
self.db.commit_family(self.obj,trans)
|
||||
self.db.transaction_commit(trans,_("Edit Family"))
|
||||
self.db.commit_family(self.obj, trans)
|
||||
self.db.transaction_commit(trans, _("Edit Family"))
|
||||
|
||||
self.close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user