* src/ArgHandler.py: Make sure all databases are closed before

creating a new one.
* src/DisplayModels.py: Calculate new nodes properly after a
node has be deleted. The node hasn't been removed from the database
yet.
* src/EditPerson.py: Add check for unknown gender before closing
* src/EditSource.py: Remove unnecessary updates
* src/GrampsBSDDB.py: check for open in close()
* src/GrampsDbBase.py: spelling error
* src/MediaView.py: connect to database-changed
* src/PedView.py: remove unused update function
* src/PeopleView.py: connect to database-changed
* src/PlaceView.py: connect to database-changed
* src/SourceView.py: connect to database-changed, remove unnecessary
callback
* src/gramps_main.py: add database-changed signal


svn: r4288
This commit is contained in:
Don Allingham 2005-04-04 01:11:50 +00:00
parent 9a6894df98
commit 8126f34ec9
13 changed files with 76 additions and 48 deletions

View File

@ -1,3 +1,21 @@
2005-04-03 Don Allingham <don@gramps-project.org>
* src/ArgHandler.py: Make sure all databases are closed before
creating a new one.
* src/DisplayModels.py: Calculate new nodes properly after a
node has be deleted. The node hasn't been removed from the database
yet.
* src/EditPerson.py: Add check for unknown gender before closing
* src/EditSource.py: Remove unnecessary updates
* src/GrampsBSDDB.py: check for open in close()
* src/GrampsDbBase.py: spelling error
* src/MediaView.py: connect to database-changed
* src/PedView.py: remove unused update function
* src/PeopleView.py: connect to database-changed
* src/PlaceView.py: connect to database-changed
* src/SourceView.py: connect to database-changed, remove unnecessary
callback
* src/gramps_main.py: add database-changed signal
2005-04-03 Alex Roitman <shura@gramps-project.org> 2005-04-03 Alex Roitman <shura@gramps-project.org>
* src/AddMedia.py: Remove unneeded update argument. * src/AddMedia.py: Remove unneeded update argument.
* src/ArgHandler.py (auto_save_load): Mysterious workaround :-). * src/ArgHandler.py (auto_save_load): Mysterious workaround :-).

View File

@ -225,21 +225,20 @@ class ArgHandler:
filename = os.path.normpath(os.path.abspath(filename)) filename = os.path.normpath(os.path.abspath(filename))
filetype = GrampsMime.get_type(filename) filetype = GrampsMime.get_type(filename)
if filetype == const.app_gramps: if filetype == const.app_gramps:
# FIXME: For some reason the following two lines are needed
# to prevent source view from getting out of sync. Makes no
# sense to me right now, but it seems to fix a problem and
# make no harm otherwise. Should remove when understood.
import GrampsBSDDB import GrampsBSDDB
self.parent.db.close()
self.parent.db = GrampsBSDDB.GrampsBSDDB() self.parent.db = GrampsBSDDB.GrampsBSDDB()
self.parent.read_file(filename) self.parent.read_file(filename)
return 1 return 1
elif filetype == const.app_gramps_xml: elif filetype == const.app_gramps_xml:
import GrampsXMLDB import GrampsXMLDB
self.parent.db.close()
self.parent.db = GrampsXMLDB.GrampsXMLDB() self.parent.db = GrampsXMLDB.GrampsXMLDB()
self.parent.read_file(filename) self.parent.read_file(filename)
return 1 return 1
elif filetype == const.app_gedcom: elif filetype == const.app_gedcom:
import GrampsGEDDB import GrampsGEDDB
self.parent.db.close()
self.parent.db = GrampsGEDDB.GrampsGEDDB() self.parent.db = GrampsGEDDB.GrampsGEDDB()
self.parent.read_file(filename) self.parent.read_file(filename)
return 1 return 1

View File

@ -72,9 +72,6 @@ class BaseModel(gtk.GenericTreeModel):
self.datalist = [] self.datalist = []
self.indexlist = [] self.indexlist = []
def on_row_inserted(self,obj,path,node):
self.rebuild_data()
def add_row_by_handle(self,handle): def add_row_by_handle(self,handle):
self.datalist = self.sort_keys() self.datalist = self.sort_keys()
i = 0 i = 0
@ -88,7 +85,15 @@ class BaseModel(gtk.GenericTreeModel):
def delete_row_by_handle(self,handle): def delete_row_by_handle(self,handle):
index = self.indexlist[handle] index = self.indexlist[handle]
self.rebuild_data()
self.indexlist = {}
self.datalist = []
i = 0
for key in self.sort_keys():
if key != handle:
self.indexlist[key] = i
self.datalist.append(key)
i += 1
self.row_deleted(index) self.row_deleted(index)
def update_row_by_handle(self,handle): def update_row_by_handle(self,handle):

View File

@ -61,7 +61,7 @@ import DateHandler
import TransTable import TransTable
import NameDisplay import NameDisplay
from QuestionDialog import WarningDialog, ErrorDialog, SaveDialog from QuestionDialog import WarningDialog, ErrorDialog, SaveDialog, QuestionDialog2
from DdTargets import DdTargets from DdTargets import DdTargets
@ -1682,6 +1682,18 @@ class EditPerson:
def on_apply_person_clicked(self,obj): def on_apply_person_clicked(self,obj):
if self.is_unknown.get_active():
dialog = QuestionDialog2(
_("Unknown gender specified"),
_("The gender of the person is currently unknown. "
"Usually, this is a mistake. You may choose to "
"either continue saving, or returning to the "
"Edit Person dialog to fix the problem."),
_("Continue saving"), _("Return to window"),
self.window)
if not dialog.run():
return
self.window.hide() self.window.hide()
trans = self.db.transaction_begin() trans = self.db.transaction_begin()

View File

@ -375,11 +375,10 @@ class EditSource:
class DelSrcQuery: class DelSrcQuery:
def __init__(self,source,db,the_lists,update): def __init__(self,source,db,the_lists):
self.source = source self.source = source
self.db = db self.db = db
self.the_lists = the_lists self.the_lists = the_lists
self.update = update
def query_response(self): def query_response(self):
trans = self.db.transaction_begin() trans = self.db.transaction_begin()
@ -420,5 +419,5 @@ class DelSrcQuery:
self.db.commit_media_object(media,trans) self.db.commit_media_object(media,trans)
self.db.remove_source(self.source.get_handle(),trans) self.db.remove_source(self.source.get_handle(),trans)
self.db.transaction_commit(trans,_("Delete Source (%s)") % self.source.get_title()) self.db.transaction_commit(
self.update(self.source.get_handle()) trans,_("Delete Source (%s)") % self.source.get_title())

View File

@ -207,6 +207,8 @@ class GrampsBSDDB(GrampsDbBase):
self.close() self.close()
def close(self): def close(self):
if not self.person_map:
return
self.name_group.close() self.name_group.close()
self.person_map.close() self.person_map.close()
self.family_map.close() self.family_map.close()
@ -402,7 +404,6 @@ class GrampsBSDDB(GrampsDbBase):
print 'Successfully finished all upgrades' print 'Successfully finished all upgrades'
def upgrade_2(self,child_rel_notrans): def upgrade_2(self,child_rel_notrans):
print "Upgrading to DB version 2"
cursor = self.get_person_cursor() cursor = self.get_person_cursor()
data = cursor.first() data = cursor.first()
while data: while data:
@ -428,7 +429,6 @@ class GrampsBSDDB(GrampsDbBase):
cursor.close() cursor.close()
def upgrade_3(self): def upgrade_3(self):
print "Upgrading to DB version 3"
cursor = self.get_person_cursor() cursor = self.get_person_cursor()
data = cursor.first() data = cursor.first()
while data: while data:
@ -444,7 +444,6 @@ class GrampsBSDDB(GrampsDbBase):
cursor.close() cursor.close()
def upgrade_4(self,child_rel_notrans): def upgrade_4(self,child_rel_notrans):
print "Upgrading to DB version 4"
cursor = self.get_person_cursor() cursor = self.get_person_cursor()
data = cursor.first() data = cursor.first()
while data: while data:
@ -476,6 +475,7 @@ class GrampsBSDDB(GrampsDbBase):
# comments into note in SourceRefs # comments into note in SourceRefs
# in all primary and secondary objects # in all primary and secondary objects
# Also MediaObject gets place attribute removed # Also MediaObject gets place attribute removed
cursor = self.get_media_cursor() cursor = self.get_media_cursor()
data = cursor.first() data = cursor.first()
while data: while data:

View File

@ -189,8 +189,7 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
self.bookmarks = [] self.bookmarks = []
self.path = "" self.path = ""
self.place2title = {} self.place2title = {}
self.name_groups = {} self.name_group = {}
def need_upgrade(self): def need_upgrade(self):
return False return False

View File

@ -72,6 +72,7 @@ _HANDLE_COL = len(column_names)
class MediaView: class MediaView:
def __init__(self,parent,db,glade,update): def __init__(self,parent,db,glade,update):
self.parent = parent self.parent = parent
self.parent.connect('database-changed',self.change_db)
self.db = db self.db = db
self.list = glade.get_widget("media_list") self.list = glade.get_widget("media_list")
self.mid = glade.get_widget("mid") self.mid = glade.get_widget("mid")

View File

@ -182,7 +182,7 @@ class DispBox:
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class PedigreeView: class PedigreeView:
def __init__(self,parent,canvas,update,status_bar,change_active,lp): def __init__(self,parent,canvas,update,status_bar,lp):
self.parent = parent self.parent = parent
self.canvas = canvas self.canvas = canvas
self.canvas_items = [] self.canvas_items = []
@ -197,7 +197,6 @@ class PedigreeView:
self.y2 = 0 self.y2 = 0
self.update = update self.update = update
self.sb = status_bar self.sb = status_bar
self.change_active_person = change_active
self.load_person = lp self.load_person = lp
self.anchor = None self.anchor = None
self.canvas.parent.connect('button-press-event',self.on_canvas_press) self.canvas.parent.connect('button-press-event',self.on_canvas_press)
@ -339,7 +338,7 @@ class PedigreeView:
ypts[mindex], h, w, p[0], style, p[1]) ypts[mindex], h, w, p[0], style, p[1])
p = lst[i] p = lst[i]
box = DispBox(self.root,style,xpts[i],ypts[i],w,h,p[0],self.parent.db, box = DispBox(self.root,style,xpts[i],ypts[i],w,h,p[0],self.parent.db,
self.change_active_person, self.parent.change_active_person,
self.load_person, self.build_full_nav_menu) self.load_person, self.build_full_nav_menu)
self.boxes.append(box) self.boxes.append(box)
self.change_active_person(person) self.change_active_person(person)

View File

@ -69,6 +69,8 @@ class PeopleView:
def __init__(self,parent): def __init__(self,parent):
self.parent = parent self.parent = parent
self.parent.connect('database-changed',self.change_db)
all = GenericFilter.GenericFilter() all = GenericFilter.GenericFilter()
all.set_name(_("Entire Database")) all.set_name(_("Entire Database"))
all.add_rule(GenericFilter.Everyone([])) all.add_rule(GenericFilter.Everyone([]))
@ -170,7 +172,7 @@ class PeopleView:
self.parent.db.connect('person-update', self.person_updated) self.parent.db.connect('person-update', self.person_updated)
self.parent.db.connect('person-delete', self.person_removed) self.parent.db.connect('person-delete', self.person_removed)
self.parent.db.connect('person-rebuild', self.redisplay_person_list) self.parent.db.connect('person-rebuild', self.redisplay_person_list)
self.apply_filter()
def remove_from_person_list(self,person): def remove_from_person_list(self,person):
"""Remove the selected person from the list. A person object is """Remove the selected person from the list. A person object is

View File

@ -69,15 +69,15 @@ class PlaceView:
def __init__(self,parent,db,glade): def __init__(self,parent,db,glade):
self.parent = parent self.parent = parent
self.parent.connect('database-changed',self.change_db)
self.glade = glade self.glade = glade
self.list = glade.get_widget("place_list") self.list = glade.get_widget("place_list")
self.list.connect('button-press-event',self.button_press) self.list.connect('button-press-event',self.button_press)
self.list.connect('key-press-event',self.key_press) self.list.connect('key-press-event',self.key_press)
self.selection = self.list.get_selection() self.selection = self.list.get_selection()
self.selection.set_mode(gtk.SELECTION_MULTIPLE) self.selection.set_mode(gtk.SELECTION_MULTIPLE)
self.renderer = gtk.CellRendererText() self.renderer = gtk.CellRendererText()
self.model = DisplayModels.PlaceModel(self.parent.db) self.model = DisplayModels.PlaceModel(self.parent.db)
self.list.set_model(self.model) self.list.set_model(self.model)

View File

@ -66,6 +66,7 @@ _HANDLE_COL = len(column_names)
class SourceView: class SourceView:
def __init__(self,parent,db,glade): def __init__(self,parent,db,glade):
self.parent = parent self.parent = parent
self.parent.connect('database-changed',self.change_db)
self.glade = glade self.glade = glade
self.list = glade.get_widget("source_list") self.list = glade.get_widget("source_list")
#self.list.set_property('fixed-height-mode',True) #self.list.set_property('fixed-height-mode',True)
@ -178,8 +179,7 @@ class SourceView:
source = self.parent.db.get_source_from_handle(handle) source = self.parent.db.get_source_from_handle(handle)
the_lists = Utils.get_source_referents(handle,self.parent.db) the_lists = Utils.get_source_referents(handle,self.parent.db)
ans = EditSource.DelSrcQuery(source,self.parent.db,the_lists, ans = EditSource.DelSrcQuery(source,self.parent.db,the_lists)
self.model.delete_row_by_handle)
if filter(None,the_lists): # quick test for non-emptiness if filter(None,the_lists): # quick test for non-emptiness
msg = _('This source is currently being used. Deleting it ' msg = _('This source is currently being used. Deleting it '

View File

@ -52,6 +52,7 @@ import gtk.gdk
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import RelLib import RelLib
import GrampsDbBase
import GrampsBSDDB import GrampsBSDDB
import PedView import PedView
import MediaView import MediaView
@ -77,11 +78,10 @@ import RelImage
import RecentFiles import RecentFiles
import NameDisplay import NameDisplay
import Errors import Errors
import GrampsDBCallback
from GrampsMime import mime_type_is_defined from GrampsMime import mime_type_is_defined
from QuestionDialog import * from QuestionDialog import *
from bsddb import db from bsddb import db
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -106,10 +106,16 @@ MEDIA_VIEW = 6
# Main GRAMPS class # Main GRAMPS class
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class Gramps: class Gramps(GrampsDBCallback.GrampsDBCallback):
__signals__ = {
'database-changed' : (GrampsDbBase.GrampsDbBase,),
}
def __init__(self,args): def __init__(self,args):
GrampsDBCallback.GrampsDBCallback.__init__(self)
try: try:
self.program = gnome.program_init('gramps',const.version, self.program = gnome.program_init('gramps',const.version,
gnome.libgnome_module_info_get(), gnome.libgnome_module_info_get(),
@ -318,9 +324,9 @@ class Gramps:
self.family_view = FamilyView.FamilyView(self) self.family_view = FamilyView.FamilyView(self)
self.people_view = PeopleView.PeopleView(self) self.people_view = PeopleView.PeopleView(self)
self.pedigree_view = PedView.PedigreeView(self, self.pedigree_view = PedView.PedigreeView(
self.canvas, self.modify_statusbar, self.statusbar, self, self.canvas, self.modify_statusbar, self.statusbar,
self.change_active_person, self.load_person self.load_person
) )
self.place_view = PlaceView.PlaceView(self,self.db,self.gtop) self.place_view = PlaceView.PlaceView(self,self.db,self.gtop)
@ -496,12 +502,7 @@ class Gramps:
if self.active_person: if self.active_person:
p = self.db.get_person_from_handle(self.active_person.get_handle()) p = self.db.get_person_from_handle(self.active_person.get_handle())
self.change_active_person(p) self.change_active_person(p)
self.place_view.change_db(self.db) self.emit('database-changed',(self.db,))
self.family_view.change_db()
self.people_view.change_db(self.db)
self.people_view.apply_filter()
self.source_view.change_db(self.db)
self.media_view.change_db(self.db)
def exit_and_undo(self,*args): def exit_and_undo(self,*args):
self.db.abort_changes() self.db.abort_changes()
@ -1111,21 +1112,14 @@ class Gramps:
def full_update(self): def full_update(self):
"""Brute force display update, updating all the pages""" """Brute force display update, updating all the pages"""
self.people_view.person_model.rebuild_data()
if Utils.wasHistory_broken(): if Utils.wasHistory_broken():
self.clear_history() self.clear_history()
Utils.clearHistory_broken() Utils.clearHistory_broken()
self.family_view.change_db() self.emit('database-changed',(self.db,))
self.people_view.change_db(self.db)
self.people_view.apply_filter()
if not self.active_person: if not self.active_person:
self.change_active_person(self.find_initial_person()) self.change_active_person(self.find_initial_person())
self.goto_active_person() self.goto_active_person()
self.place_view.change_db(self.db)
self.source_view.change_db(self.db)
self.media_view.change_db(self.db)
def update_display(self,changed=True): def update_display(self,changed=True):
"""Incremental display update, update only the displayed page""" """Incremental display update, update only the displayed page"""
page = self.views.get_current_page() page = self.views.get_current_page()
@ -1240,8 +1234,8 @@ class Gramps:
self.gtop.get_widget('edit_bookmarks').set_sensitive(not self.db.readonly) self.gtop.get_widget('edit_bookmarks').set_sensitive(not self.db.readonly)
self.gtop.get_widget('tools_menu').set_sensitive(not self.db.readonly) self.gtop.get_widget('tools_menu').set_sensitive(not self.db.readonly)
self.gtop.get_widget('tools').set_sensitive(not self.db.readonly) self.gtop.get_widget('tools').set_sensitive(not self.db.readonly)
self.goto_active_person() self.goto_active_person()
self.update_display()
return 1 return 1
def save_media(self,filename): def save_media(self,filename):