GEDCOM/ANSEL handing, improved list access

svn: r1173
This commit is contained in:
Don Allingham 2002-11-09 18:44:58 +00:00
parent e9cf8ab1bd
commit a6a58ccf78
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
Requires: python >= 1.5.2
Requires: pygnome >= 1.0.53
Requires: _gladegnomemodule.so
Requires: pyexpat.so
Requires: python >= 2.2
Requires: gnome-python2 >= 1.99
Requires: gnome-python2-gconf >= 1.99
Requires: gnome-python2-canvas >= 1.99
Requires: pygtk2 >= 1.99
Requires: pygtk2-libglade >= 1.99
BuildRequires: scrollkeeper >= 0.1.4
BuildRequires: automake >= 1.6

View File

@ -137,7 +137,6 @@ class EditPerson:
"on_ldsendow_src_clicked" : self.on_ldsendow_source_clicked,
"on_ldsseal_src_clicked" : self.on_ldsseal_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_attr_clicked" : self.on_update_attr_clicked,
"on_update_url_clicked" : self.on_update_url_clicked,
@ -746,9 +745,7 @@ class EditPerson:
if self.did_data_change():
QuestionDialog(_('Abandon Changes'),
_("Are you sure you want to abandon your changes?"),
_("Abandon Changes"),
self.cancel_callback,
_("Continue Editing"))
self.cancel_callback)
else:
Utils.destroy_passed_object(obj)
@ -758,9 +755,7 @@ class EditPerson:
if self.did_data_change():
QuestionDialog(_('Abandon Changes'),
_("Are you sure you want to abandon your changes?"),
_("Abandon Changes"),
self.cancel_callback,
_("Continue Editing"))
self.cancel_callback)
return 1
else:
Utils.destroy_passed_object(obj)

View File

@ -38,6 +38,7 @@ from intl import gettext as _
import Utils
import GrampsCfg
from RelLib import Person
from QuestionDialog import QuestionDialog
import AddSpouse
import SelectChild
@ -190,6 +191,13 @@ class FamilyView:
self.load_family()
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"""
if self.person == None:
return
@ -399,12 +407,27 @@ class FamilyView:
self.parent_add(self.person)
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):
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)
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)
def child_back(self,obj):
@ -442,7 +465,6 @@ class FamilyView:
def parent_add(self,person):
if not person:
return
try:
ChooseParents.ChooseParents(self.parent.db,person,None,
self.load_family,self.parent.full_update)
@ -452,12 +474,9 @@ class FamilyView:
def parent_deleter(self,person,selection):
if not person:
return
plist = person.getParentList()
if len(plist) == 0:
return
if len(plist) == 1:
person.clearAltFamilyList()
else:
@ -468,6 +487,7 @@ class FamilyView:
row = model.get_path(iter)
fam = person.getParentList()[row[0]]
person.removeAltFamily(fam[0])
Utils.modified()
self.load_family()

View File

@ -199,7 +199,6 @@ _drag_targets = [
('text/uri-list',0,2),
('application/x-rootwin-drop',0,1)]
#-------------------------------------------------------------------------
#
# Gallery class - This class handles all the logic underlying a
@ -505,19 +504,21 @@ class Gallery(ImageSelect):
def on_delete_photo_clicked(self, obj):
"""User wants to delete a new photo. Remove it from the displayed
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):
"""Look for right-clicks on a picture and create a popup
menu of the available actions."""

View File

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

View File

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

View File

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

View File

@ -23,7 +23,7 @@ import gnome.ui
from intl import gettext as _
class QuestionDialog:
def __init__(self,title,msg,blabel1,task1,blabel2,task2=None):
def __init__(self,title,msg,task1,task2=None):
title = '%s - GRAMPS' % title
self.top = gtk.Dialog()
@ -82,6 +82,28 @@ class ErrorDialog:
self.top.run()
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:
def __init__(self,msg):
title = '%s - GRAMPS' % _('Error')

View File

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

View File

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

View File

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

View File

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