svn: r7948

This commit is contained in:
Don Allingham 2007-01-21 21:32:53 +00:00
parent ef7f1ffa65
commit 0365b04165
5 changed files with 45 additions and 13 deletions

View File

@ -30,7 +30,7 @@ Handling of loading new/existing databases.
#
#-------------------------------------------------------------------------
import os
from bsddb.db import DBAccessError, DBRunRecoveryError, DBPageNotFoundError
from bsddb.db import DBAccessError, DBRunRecoveryError, DBPageNotFoundError, DBInvalidArgError
from gettext import gettext as _
import logging
log = logging.getLogger(".")
@ -415,7 +415,15 @@ class DbLoader:
else:
mode = 'w'
dbclass = GrampsDb.gramps_db_factory(db_type = filetype)
try:
dbclass = GrampsDb.gramps_db_factory(db_type = filetype)
except GrampsDbException, msg:
QuestionDialog.ErrorDialog(
_("Could not open file: %s") % filename,
_("This may be caused by an improper installation of GRAMPS.") +
"\n" + str(msg))
return
self.dbstate.change_database(dbclass(Config.get(Config.TRANSACTIONS)))
self.dbstate.db.disable_signals()
@ -440,7 +448,7 @@ class DbLoader:
"problem persists, create a new database, import "
"from a backup database, and report the problem to "
"gramps-bugs@lists.sourceforge.net."))
except (DBAccessError, DBPageNotFoundError), msg:
except (DBAccessError, DBPageNotFoundError,DBInvalidArgError), msg:
QuestionDialog.ErrorDialog(
_("Could not open file: %s") % filename,
str(msg[1]))

View File

@ -121,11 +121,14 @@ class History(GrampsDb.GrampsDBCallback):
def back(self,step=1):
self.index -= step
person_handle = self.history[self.index]
if person_handle not in self.mhistory:
self.mhistory.append(person_handle)
self.emit('menu-changed',(self.mhistory,))
return str(self.history[self.index])
try:
person_handle = self.history[self.index]
if person_handle not in self.mhistory:
self.mhistory.append(person_handle)
self.emit('menu-changed',(self.mhistory,))
return str(self.history[self.index])
except IndexError:
return u""
def at_end(self):
return self.index+1 == len(self.history)

View File

@ -41,6 +41,7 @@ import gtk
#-------------------------------------------------------------------------
import GrampsWidgets
import RelLib
import DateHandler
from _SidebarFilter import SidebarFilter
from Filters.Rules.Person import *
@ -92,11 +93,25 @@ class PersonSidebarFilter(SidebarFilter):
self.generic.add_attribute(cell, 'text', 0)
self.on_filters_changed('Person')
# def set(self, quality, modifier, calendar, value, text=None):
exdate1 = RelLib.Date()
exdate2 = RelLib.Date()
exdate1.set(RelLib.Date.QUAL_NONE, RelLib.Date.MOD_RANGE, RelLib.Date.CAL_GREGORIAN,
(0,0,1800,False,0,0,1900,False))
exdate2.set(RelLib.Date.QUAL_NONE, RelLib.Date.MOD_BEFORE, RelLib.Date.CAL_GREGORIAN,
(0,0,1850,False))
msg1 = DateHandler.displayer.display(exdate1)
msg2 = DateHandler.displayer.display(exdate2)
self.add_text_entry(_('Name'), self.filter_name)
self.add_text_entry(_('ID'), self.filter_id)
self.add_entry(_('Gender'), self.filter_gender)
self.add_text_entry(_('Birth date'), self.filter_birth)
self.add_text_entry(_('Death date'), self.filter_death)
self.add_text_entry(_('Birth date'), self.filter_birth,
_('example: "%s" or "%s"') % (msg1, msg2))
self.add_text_entry(_('Death date'), self.filter_death,
_('example: "%s" or "%s"') % (msg1, msg2))
self.add_entry(_('Event'), self.etype)
self.add_entry(_('Marker'), self.mtype)
self.add_text_entry(_('Note'), self.filter_note)

View File

@ -35,6 +35,7 @@ class SidebarFilter:
self.table.set_row_spacings(6)
self.table.set_col_spacing(0,6)
self.table.set_col_spacing(1,6)
self.tooltips = gtk.Tooltips()
self._init_interface()
uistate.connect('filters-changed',self.on_filters_changed)
self.uistate = uistate
@ -91,9 +92,11 @@ class SidebarFilter:
def get_filter(self):
pass
def add_text_entry(self, name, widget):
def add_text_entry(self, name, widget, tooltip=None):
self.add_entry(name, widget)
widget.connect('key-press-event',self.key_press)
if tooltip:
self.tooltips.set_tip(widget, tooltip)
def key_press(self, obj, event):
if event.keyval == _RETURN and not event.state:

View File

@ -1209,8 +1209,11 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
The function must be overridden in the derived class.
"""
name = str(person.get_primary_name().get_surname())
if self.surnames.keys().count(name) == 1:
self.surname_list.remove(unicode(name))
try:
if self.surnames.keys().count(name) == 1:
self.surname_list.remove(unicode(name))
except ValueError:
pass
def _get_obj_from_gramps_id(self,val,tbl,class_init,prim_tbl):
if tbl.has_key(str(val)):