GEDCOM/ANSEL handing, improved list access

svn: r1173
This commit is contained in:
Don Allingham 2002-11-09 18:44:58 +00:00
parent fcc6528af6
commit 47f08c4eb2
12 changed files with 98 additions and 71 deletions

View File

@ -13,10 +13,12 @@ BuildRoot: /var/tmp/%{name}-%{version}-root
URL: http://gramps.sourceforge.net URL: http://gramps.sourceforge.net
Requires: python >= 1.5.2 Requires: python >= 2.2
Requires: pygnome >= 1.0.53 Requires: gnome-python2 >= 1.99
Requires: _gladegnomemodule.so Requires: gnome-python2-gconf >= 1.99
Requires: pyexpat.so Requires: gnome-python2-canvas >= 1.99
Requires: pygtk2 >= 1.99
Requires: pygtk2-libglade >= 1.99
BuildRequires: scrollkeeper >= 0.1.4 BuildRequires: scrollkeeper >= 0.1.4
BuildRequires: automake >= 1.6 BuildRequires: automake >= 1.6

View File

@ -137,7 +137,6 @@ class EditPerson:
"on_ldsendow_src_clicked" : self.on_ldsendow_source_clicked, "on_ldsendow_src_clicked" : self.on_ldsendow_source_clicked,
"on_ldsseal_src_clicked" : self.on_ldsseal_source_clicked, "on_ldsseal_src_clicked" : self.on_ldsseal_source_clicked,
"on_name_source_clicked" : self.on_primary_name_source_clicked, "on_name_source_clicked" : self.on_primary_name_source_clicked,
"on_photolist_select_icon" : self.gallery.on_photo_select_icon,
"on_update_address_clicked" : self.on_update_addr_clicked, "on_update_address_clicked" : self.on_update_addr_clicked,
"on_update_attr_clicked" : self.on_update_attr_clicked, "on_update_attr_clicked" : self.on_update_attr_clicked,
"on_update_url_clicked" : self.on_update_url_clicked, "on_update_url_clicked" : self.on_update_url_clicked,
@ -746,9 +745,7 @@ class EditPerson:
if self.did_data_change(): if self.did_data_change():
QuestionDialog(_('Abandon Changes'), QuestionDialog(_('Abandon Changes'),
_("Are you sure you want to abandon your changes?"), _("Are you sure you want to abandon your changes?"),
_("Abandon Changes"), self.cancel_callback)
self.cancel_callback,
_("Continue Editing"))
else: else:
Utils.destroy_passed_object(obj) Utils.destroy_passed_object(obj)
@ -758,9 +755,7 @@ class EditPerson:
if self.did_data_change(): if self.did_data_change():
QuestionDialog(_('Abandon Changes'), QuestionDialog(_('Abandon Changes'),
_("Are you sure you want to abandon your changes?"), _("Are you sure you want to abandon your changes?"),
_("Abandon Changes"), self.cancel_callback)
self.cancel_callback,
_("Continue Editing"))
return 1 return 1
else: else:
Utils.destroy_passed_object(obj) Utils.destroy_passed_object(obj)

View File

@ -38,6 +38,7 @@ from intl import gettext as _
import Utils import Utils
import GrampsCfg import GrampsCfg
from RelLib import Person from RelLib import Person
from QuestionDialog import QuestionDialog
import AddSpouse import AddSpouse
import SelectChild import SelectChild
@ -190,6 +191,13 @@ class FamilyView:
self.load_family() self.load_family()
def remove_spouse(self,obj): def remove_spouse(self,obj):
if self.selected_spouse:
name = self.selected_spouse.getPrimaryName().getRegularName()
QuestionDialog(_('Delete Spouse'),
_('Do you wish to remove %s as a spouse?') % name,
self.really_remove_spouse)
def really_remove_spouse(self):
"""Delete the currently selected spouse from the family""" """Delete the currently selected spouse from the family"""
if self.person == None: if self.person == None:
return return
@ -399,12 +407,27 @@ class FamilyView:
self.parent_add(self.person) self.parent_add(self.person)
def add_sp_parents(self,obj): def add_sp_parents(self,obj):
self.parent_editor(self.selected_spouse,self.sp_selection) if self.selected_spouse:
self.parent_add(self.selected_spouse)
def del_parents_clicked(self,obj): def del_parents_clicked(self,obj):
if len(self.person.getParentList()) == 0:
return
QuestionDialog(_('Delete Parents'),
_('Do you wish to remove the selected parents?'),
self.really_del_parents)
def really_del_parents(self):
self.parent_deleter(self.person,self.ap_selection) self.parent_deleter(self.person,self.ap_selection)
def del_sp_parents(self,obj): def del_sp_parents(self,obj):
if not self.selected_spouse or len(self.selected_spouse.getParentList()) == 0:
return
QuestionDialog(_('Delete Parents'),
_('Do you wish to remove the selected parents?'),
self.really_del_parents)
def really_del_parents(self):
self.parent_deleter(self.selected_spouse,self.sp_selection) self.parent_deleter(self.selected_spouse,self.sp_selection)
def child_back(self,obj): def child_back(self,obj):
@ -442,7 +465,6 @@ class FamilyView:
def parent_add(self,person): def parent_add(self,person):
if not person: if not person:
return return
try: try:
ChooseParents.ChooseParents(self.parent.db,person,None, ChooseParents.ChooseParents(self.parent.db,person,None,
self.load_family,self.parent.full_update) self.load_family,self.parent.full_update)
@ -452,12 +474,9 @@ class FamilyView:
def parent_deleter(self,person,selection): def parent_deleter(self,person,selection):
if not person: if not person:
return return
plist = person.getParentList() plist = person.getParentList()
if len(plist) == 0: if len(plist) == 0:
return return
if len(plist) == 1: if len(plist) == 1:
person.clearAltFamilyList() person.clearAltFamilyList()
else: else:
@ -468,6 +487,7 @@ class FamilyView:
row = model.get_path(iter) row = model.get_path(iter)
fam = person.getParentList()[row[0]] fam = person.getParentList()[row[0]]
person.removeAltFamily(fam[0]) person.removeAltFamily(fam[0])
Utils.modified()
self.load_family() self.load_family()

View File

@ -199,7 +199,6 @@ _drag_targets = [
('text/uri-list',0,2), ('text/uri-list',0,2),
('application/x-rootwin-drop',0,1)] ('application/x-rootwin-drop',0,1)]
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Gallery class - This class handles all the logic underlying a # Gallery class - This class handles all the logic underlying a
@ -505,19 +504,21 @@ class Gallery(ImageSelect):
def on_delete_photo_clicked(self, obj): def on_delete_photo_clicked(self, obj):
"""User wants to delete a new photo. Remove it from the displayed """User wants to delete a new photo. Remove it from the displayed
thumbnails, and remove it from the dataobj photo list.""" thumbnails, and remove it from the dataobj photo list."""
icon = self.selectedIcon
if icon != -1:
self.icon_list.remove(icon)
list = self.dataobj.getPhotoList()
del list[icon]
self.dataobj.setPhotoList(list)
self.parent.lists_changed = 1
if len(self.dataobj.getPhotoList()) == 0:
self.selectedIcon = -1
else:
self.selectedIcon = 0
self.icon_list.select_icon(0)
if self.sel:
(i,t,b,photo) = self.p_map[self.sel]
val = self.canvas_list[photo.getReference().getId()]
val[0].hide()
val[1].hide()
val[2].hide()
val[3].hide()
l = self.dataobj.getPhotoList()
l.remove(photo)
self.dataobj.setPhotoList(l)
self.parent.lists_changed = 1
self.load_images()
def show_popup(self, photo): def show_popup(self, photo):
"""Look for right-clicks on a picture and create a popup """Look for right-clicks on a picture and create a popup
menu of the available actions.""" menu of the available actions."""

View File

@ -375,8 +375,7 @@ class Marriage:
QuestionDialog(_('Abandon Changes'), QuestionDialog(_('Abandon Changes'),
_("Data was modified. Are you sure you " _("Data was modified. Are you sure you "
"want to abandon your changes?"), "want to abandon your changes?"),
_('Abandon Changes'),self.cancel_callback, self.cancel_callback)
_('Continue Editing'))
else: else:
Utils.destroy_passed_object(obj) Utils.destroy_passed_object(obj)

View File

@ -256,8 +256,7 @@ class MediaView:
QuestionDialog(_('Delete Object'), QuestionDialog(_('Delete Object'),
_("This media object is currently being used. " _("This media object is currently being used. "
"Delete anyway?"), "Delete anyway?"),
_('Delete Object'),ans.query_response, ans.query_response)
_('Keep Object'))
else: else:
map = self.db.getObjectMap() map = self.db.getObjectMap()
del map[mobj.getId()] del map[mobj.getId()]

View File

@ -203,8 +203,7 @@ class PlaceView:
ans = EditPlace.DeletePlaceQuery(place,self.db,self.update_display) ans = EditPlace.DeletePlaceQuery(place,self.db,self.update_display)
QuestionDialog(_('Delete Place'), QuestionDialog(_('Delete Place'),
_("This place is currently being used. Delete anyway?"), _("This place is currently being used. Delete anyway?"),
_('Delete Place'),ans.query_response, ans.query_response)
_('Keep Place'))
else: else:
self.db.removePlace(place.getId()) self.db.removePlace(place.getId())
self.update(0) self.update(0)

View File

@ -23,7 +23,7 @@ import gnome.ui
from intl import gettext as _ from intl import gettext as _
class QuestionDialog: class QuestionDialog:
def __init__(self,title,msg,blabel1,task1,blabel2,task2=None): def __init__(self,title,msg,task1,task2=None):
title = '%s - GRAMPS' % title title = '%s - GRAMPS' % title
self.top = gtk.Dialog() self.top = gtk.Dialog()
@ -82,6 +82,28 @@ class ErrorDialog:
self.top.run() self.top.run()
self.top.destroy() self.top.destroy()
class WarningDialog:
def __init__(self,msg):
title = '%s - GRAMPS' % _('Warning')
self.top = gtk.Dialog()
self.top.set_title(title)
label = gtk.Label(msg)
label.show()
hbox = gtk.HBox()
image = gtk.Image()
image.set_from_stock(gtk.STOCK_DIALOG_WARNING,gtk.ICON_SIZE_DIALOG)
hbox.set_spacing(10)
hbox.pack_start(image)
hbox.add(label)
self.top.vbox.pack_start(hbox)
self.top.set_default_size(300,150)
self.top.add_button(gtk.STOCK_OK,0)
self.top.set_response_sensitive(0,gtk.TRUE)
self.top.show_all()
self.top.run()
self.top.destroy()
class OkDialog: class OkDialog:
def __init__(self,msg): def __init__(self,msg):
title = '%s - GRAMPS' % _('Error') title = '%s - GRAMPS' % _('Error')

View File

@ -1971,9 +1971,12 @@ class GrampsDB(Persistent):
return self.surnames return self.surnames
def addSurname(self,name): def addSurname(self,name):
if name and name not in self.surnames: try:
self.surnames.append(name) if name and name not in self.surnames:
self.surnames.sort() self.surnames.append(name)
self.surnames.sort()
except:
print name
def getBookmarks(self): def getBookmarks(self):
"""returns the list of Person instances in the bookmarks""" """returns the list of Person instances in the bookmarks"""

View File

@ -127,8 +127,7 @@ class SourceView:
QuestionDialog(_('Delete Source'), QuestionDialog(_('Delete Source'),
_("This source is currently being used. Delete anyway?"), _("This source is currently being used. Delete anyway?"),
_('Delete Source'),ans.query_response, ans.query_response)
_('Keep Source'))
else: else:
self.db.removeSource(source.getId()) self.db.removeSource(source.getId())
Utils.modified() Utils.modified()

View File

@ -109,7 +109,7 @@ class Gramps:
if os.getuid() == 0: if os.getuid() == 0:
msg = _("You are running GRAMPS as the 'root' user.\n" msg = _("You are running GRAMPS as the 'root' user.\n"
"This account is not meant for normal application use.") "This account is not meant for normal application use.")
gnome.ui.GnomeWarningDialog(msg) WarningDialog(msg)
# This will never contain data - It will be replaced by either # This will never contain data - It will be replaced by either
# a GrampsXML or GrampsZODB # a GrampsXML or GrampsZODB
@ -486,8 +486,7 @@ class Gramps:
QuestionDialog(_('Abandon Changes'), QuestionDialog(_('Abandon Changes'),
_("Unsaved changes exist in the current database\n" _("Unsaved changes exist in the current database\n"
"Do you wish to save the changes?"), "Do you wish to save the changes?"),
_("Save Changes"), self.save_query, self.save_query,self.quit)
_("Abandon Changes"),self.quit)
else: else:
self.db.close() self.db.close()
gtk.mainquit() gtk.mainquit()
@ -563,9 +562,7 @@ class Gramps:
"""Prompt for permission to close the current database""" """Prompt for permission to close the current database"""
msg = _("Do you want to close the current database and create a new one?") msg = _("Do you want to close the current database and create a new one?")
QuestionDialog(_('New Database'),msg, QuestionDialog(_('New Database'),msg, self.new_database_response)
_('Close Current Database'),self.new_database_response,
_('Return to Current Database'))
def new_database_response(self): def new_database_response(self):
import DbPrompter import DbPrompter
@ -692,9 +689,8 @@ class Gramps:
self.yname = autosave self.yname = autosave
self.nname = filename self.nname = filename
QuestionDialog(_('Autosave File'),q, QuestionDialog(_('Autosave File'),q,self.autosave_query,
_('Load Autosave File'),self.autosave_query, self.loadsaved_file)
_('Load Last Saved File'),self.loadsaved_file)
else: else:
self.read_file(filename) self.read_file(filename)
@ -845,9 +841,7 @@ class Gramps:
name = GrampsCfg.nameof(self.active_person) name = GrampsCfg.nameof(self.active_person)
msg = _("Do you really wish to delete %s?") % name msg = _("Do you really wish to delete %s?") % name
QuestionDialog(_('Delete Person'), msg, QuestionDialog(_('Delete Person'), msg, self.delete_person_response)
_('Delete Person'),self.delete_person_response,
_('Keep Person'))
def delete_person_response(self): def delete_person_response(self):
for family in self.active_person.getFamilyList(): for family in self.active_person.getFamilyList():
@ -973,7 +967,7 @@ class Gramps:
if (EditPerson.birth_dates_in_order(desired_order) == 0): if (EditPerson.birth_dates_in_order(desired_order) == 0):
clist.emit_stop_by_name("row_move") clist.emit_stop_by_name("row_move")
msg = _("Invalid move. Children must be ordered by birth date.") msg = _("Invalid move. Children must be ordered by birth date.")
gnome.ui.GnomeWarningDialog(msg) WarningDialog(msg)
return return
# OK, this birth order works too. Update the family data structures. # OK, this birth order works too. Update the family data structures.
@ -1023,13 +1017,11 @@ class Gramps:
msg = _("Do you wish to abandon your changes and " msg = _("Do you wish to abandon your changes and "
"revert to the last saved database?") "revert to the last saved database?")
QuestionDialog(_('Abandon Changes'),msg, QuestionDialog(_('Abandon Changes'),msg, self.revert_query)
_('Revert to Last Database'),self.revert_query,
_('Continue with Current Database'))
else: else:
msg = _("Cannot revert to a previous database, since " msg = _("Cannot revert to a previous database, since "
"one does not exist") "one does not exist")
gnome.ui.GnomeWarningDialog(msg) WarningDialog(msg)
def revert_query(self): def revert_query(self):
const.personalEvents = const.init_personal_event_list() const.personalEvents = const.init_personal_event_list()
@ -1356,7 +1348,7 @@ class Gramps:
def apply_filter(self): def apply_filter(self):
datacomp = self.DataFilter.compare datacomp = self.DataFilter.compare
for key in self.db.getPersonKeys(): for key in self.db.getPersonKeys():
person = self.db.getPerson(key) person = self.db.getPerson(key)
if datacomp(person): if datacomp(person):
@ -1372,7 +1364,6 @@ class Gramps:
else: else:
if self.id2col.has_key(key): if self.id2col.has_key(key):
self.person_model.remove(self.id2col[key]) self.person_model.remove(self.id2col[key])
self.person_model.sort_column_changed()
def on_home_clicked(self,obj): def on_home_clicked(self,obj):
temp = self.db.getDefaultPerson() temp = self.db.getDefaultPerson()
@ -1389,7 +1380,7 @@ class Gramps:
self.statusbar.set_status(_("%s has been bookmarked") % name) self.statusbar.set_status(_("%s has been bookmarked") % name)
gtk.timeout_add(5000,self.modify_statusbar) gtk.timeout_add(5000,self.modify_statusbar)
else: else:
gnome.ui.GnomeWarningDialog(_("Bookmark could not be set because no one was selected")) WarningDialog(_("Bookmark could not be set because no one was selected"))
def on_edit_bookmarks_activate(self,obj): def on_edit_bookmarks_activate(self,obj):
self.bookmarks.edit() self.bookmarks.edit()
@ -1403,9 +1394,7 @@ class Gramps:
name = self.active_person.getPrimaryName().getRegularName() name = self.active_person.getPrimaryName().getRegularName()
msg = _("Do you wish to set %s as the home person?") % name msg = _("Do you wish to set %s as the home person?") % name
QuestionDialog(_('Set Home Person'),msg, QuestionDialog(_('Set Home Person'),msg,self.set_person)
_('Set as Home Person'),self.set_person,
_('Do not change Home Person'))
def set_person(self): def set_person(self):
self.db.setDefaultPerson(self.active_person) self.db.setDefaultPerson(self.active_person)

View File

@ -47,10 +47,7 @@ import gnome.ui
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from RelLib import * from RelLib import *
import Date import Date
try: from ansel_utf8 import ansel_to_utf8
from ansel import ansel_to_latin
except:
from latin_ansel import ansel_to_latin
import latin_utf8 import latin_utf8
import Utils import Utils
@ -135,7 +132,7 @@ def importData(database, filename, cb=None):
close = g.parse_gedcom_file() close = g.parse_gedcom_file()
g.resolve_refns() g.resolve_refns()
statusTop.get_widget("close").set_sensitive(1) statusTop.get_widget("close").set_sensitive(1)
if close: if close:
statusWindow.destroy() statusWindow.destroy()
@ -1412,10 +1409,12 @@ class GedcomParser:
if matches[2] == "UNICODE" or matches[2] == "UTF-8" or \ if matches[2] == "UNICODE" or matches[2] == "UTF-8" or \
matches[2] == "UTF8": matches[2] == "UTF8":
self.code = UNICODE self.code = UNICODE
self.cnv = latin_utf8.utf8_to_latin self.cnv = nocnv
elif matches[2] == "ANSEL": elif matches[2] == "ANSEL":
self.code = ANSEL self.code = ANSEL
self.cnv = ansel_to_latin self.cnv = ansel_to_utf8
else:
self.cnv = latin_to_utf8
self.ignore_sub_junk(2) self.ignore_sub_junk(2)
self.update(self.encoding_obj,matches[2]) self.update(self.encoding_obj,matches[2])
elif matches[1] == "GEDC": elif matches[1] == "GEDC":