* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,

src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.


svn: r2905
This commit is contained in:
Alex Roitman 2004-02-24 05:37:06 +00:00
parent de1f713100
commit f2272091d7
13 changed files with 166 additions and 79 deletions

View File

@ -1,3 +1,11 @@
2004-02-23 Alex Roitman <shura@alex.neuro.umn.edu>
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
2004-02-22 Alex Roitman <shura@alex.neuro.umn.edu>
* src/plugins/DetAncestralReport.py: Translation corrections.
Change "was" to "is".

View File

@ -63,6 +63,26 @@ class AddressEditor:
parent - The class that called the Address editor.
addr - The address that is to be edited
"""
self.parent = parent
if addr:
if self.parent.child_windows.has_key(addr):
self.parent.child_windows[addr].present(None)
return
else:
self.win_key = addr
else:
self.win_key = self
self.db = self.parent.db
self.addr = addr
self.callback = callback
self.child_windows = {}
name = parent.person.get_primary_name().get_name()
if name == ", ":
text = _("Address Editor")
else:
text = _("Address Editor for %s") % name
# Get the important widgets from the glade description
self.top = gtk.glade.XML(const.dialogFile, "addr_edit","gramps")
self.window = self.top.get_widget("addr_edit")
@ -81,17 +101,6 @@ class AddressEditor:
self.flowed = self.top.get_widget("addr_flowed")
self.preform = self.top.get_widget("addr_preform")
self.parent = parent
self.db = self.parent.db
self.addr = addr
self.callback = callback
self.child_windows = []
name = parent.person.get_primary_name().get_name()
if name == ", ":
text = _("Address Editor")
else:
text = _("Address Editor for %s") % name
title_label = self.top.get_widget("title")
Utils.set_titles(self.window,title_label,
@ -136,27 +145,25 @@ class AddressEditor:
if parent_window:
self.window.set_transient_for(parent_window)
self.parent.child_windows.append(self)
self.add_itself_to_menu()
self.window.show()
def on_delete_event(self,obj,b):
self.close_child_windows()
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
def close(self,obj):
self.close_child_windows()
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
self.window.destroy()
def close_child_windows(self):
for child_window in self.child_windows:
for child_window in self.child_windows.values():
child_window.close(None)
self.child_windows = []
self.child_windows = {}
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
label = _('Address')
self.parent_menu_item = gtk.MenuItem(label)
self.parent_menu_item.set_submenu(gtk.Menu())
@ -169,6 +176,7 @@ class AddressEditor:
self.menu.append(self.menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.menu_item.destroy()
self.menu.destroy()
self.parent_menu_item.destroy()

View File

@ -70,8 +70,20 @@ class AttributeEditor:
"""
self.parent = parent
if attrib:
if self.parent.child_windows.has_key(attrib):
self.parent.child_windows[attrib].present(None)
return
else:
self.win_key = attrib
else:
self.win_key = self
self.db = self.parent.db
self.attrib = attrib
self.callback = callback
self.child_windows = {}
self.alist = list
self.top = gtk.glade.XML(const.dialogFile, "attr_edit","gramps")
self.type_field = self.top.get_widget("attr_type")
self.slist = self.top.get_widget("slist")
@ -84,9 +96,6 @@ class AttributeEditor:
self.notes_label = self.top.get_widget("noteAttr")
self.flowed = self.top.get_widget("attr_flowed")
self.preform = self.top.get_widget("attr_preform")
self.callback = callback
self.child_windows = []
self.alist = list
self.window = self.top.get_widget("attr_edit")
@ -133,27 +142,25 @@ class AttributeEditor:
if parent_window:
self.window.set_transient_for(parent_window)
self.parent.child_windows.append(self)
self.add_itself_to_menu()
self.window.show()
def on_delete_event(self,obj,b):
self.close_child_windows()
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
def close(self,obj):
self.close_child_windows()
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
self.window.destroy()
def close_child_windows(self):
for child_window in self.child_windows:
for child_window in self.child_windows.values():
child_window.close(None)
self.child_windows = []
self.child_windows = {}
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
if not self.attrib:
label = _("New Attribute")
else:
@ -172,6 +179,7 @@ class AttributeEditor:
self.menu.append(self.menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.menu_item.destroy()
self.menu.destroy()
self.parent_menu_item.destroy()

View File

@ -86,7 +86,7 @@ class EditPerson:
return
self.db = db
self.callback = callback
self.child_windows = []
self.child_windows = {}
self.path = db.get_save_path()
self.not_loaded = 1
self.lds_not_loaded = 1
@ -412,9 +412,9 @@ class EditPerson:
self.window.show()
def close_child_windows(self):
for child_window in self.child_windows:
for child_window in self.child_windows.values():
child_window.close(None)
self.child_windows = []
self.child_windows = {}
def close(self,ok=0):
self.gallery.close(ok)

View File

@ -53,7 +53,15 @@ class EditSource:
self.source = source
self.db = db
self.parent = parent
self.child_windows = []
if source:
if self.parent.child_windows.has_key(source.get_id()):
self.parent.child_windows[source.get_id()].present(None)
return
else:
self.win_key = source.get_id()
else:
self.win_key = self
self.child_windows = {}
self.callback = func
self.path = db.get_save_path()
self.not_loaded = 1
@ -122,14 +130,12 @@ class EditSource:
self.display_references()
if parent_window:
self.top.set_transient_for(parent_window)
self.parent.child_windows.append(self)
self.add_itself_to_menu()
self.top.show()
def on_delete_event(self,obj,b):
self.close_child_windows()
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
def on_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual"""
@ -139,15 +145,15 @@ class EditSource:
self.gallery.close(self.gallery_ok)
self.close_child_windows()
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
self.top.destroy()
def close_child_windows(self):
for child_window in self.child_windows:
for child_window in self.child_windows.values():
child_window.close(None)
self.child_windows = []
self.child_windows = {}
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
if not self.source:
label = _("New Source")
else:
@ -166,6 +172,7 @@ class EditSource:
self.menu.append(self.menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.menu_item.destroy()
self.menu.destroy()
self.parent_menu_item.destroy()

View File

@ -61,8 +61,16 @@ class EventEditor:
def_event=None):
self.parent = parent
self.db = self.parent.db
if event:
if self.parent.child_windows.has_key(event.get_id()):
self.parent.child_windows[event.get_id()].present(None)
return
else:
self.win_key = event.get_id()
else:
self.win_key = self
self.event = event
self.child_windows = []
self.child_windows = {}
self.trans = trans
self.callback = cb
self.plist = []
@ -201,27 +209,25 @@ class EventEditor:
self.calendar.set_menu(menu)
self.window.set_transient_for(self.parent.window)
self.parent.child_windows.append(self)
self.add_itself_to_menu()
self.window.show()
def on_delete_event(self,obj,b):
self.close_child_windows()
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
def close(self,obj):
self.close_child_windows()
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
self.window.destroy()
def close_child_windows(self):
for child_window in self.child_windows:
for child_window in self.child_windows.values():
child_window.close(None)
self.child_windows = []
self.child_windows = {}
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
if not self.event:
label = _("New Event")
else:
@ -240,6 +246,7 @@ class EventEditor:
self.menu.append(self.menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.menu_item.destroy()
self.menu.destroy()
self.parent_menu_item.destroy()

View File

@ -667,13 +667,21 @@ class Gallery(ImageSelect):
class LocalMediaProperties:
def __init__(self,photo,path,parent,parent_window=None):
self.parent = parent
if photo:
if self.parent.parent.child_windows.has_key(photo):
self.parent.parent.child_windows[photo].present(None)
return
else:
self.win_key = photo
else:
self.win_key = self
self.child_windows = {}
self.photo = photo
self.object = photo.get_reference()
self.alist = photo.get_attribute_list()[:]
self.lists_changed = 0
self.parent = parent
self.db = parent.db
self.child_windows = []
fname = self.object.get_path()
self.change_dialog = gtk.glade.XML(const.imageselFile,"change_description","gramps")
@ -741,27 +749,25 @@ class LocalMediaProperties:
self.window = self.change_dialog.get_widget('change_description')
if parent_window:
self.window.set_transient_for(parent_window)
self.parent.parent.child_windows.append(self)
self.add_itself_to_menu()
self.window.show()
def on_delete_event(self,obj,b):
self.close_child_windows()
self.remove_itself_from_menu()
self.parent.parent.child_windows.remove(self)
def close(self,obj):
self.close_child_windows()
self.remove_itself_from_menu()
self.parent.parent.child_windows.remove(self)
self.window.destroy()
def close_child_windows(self):
for child_window in self.child_windows:
for child_window in self.child_windows.values():
child_window.close(None)
self.child_windows = []
self.child_windows = {}
def add_itself_to_menu(self):
self.parent.parent.child_windows[self.win_key] = self
label = _('Media Reference')
self.parent_menu_item = gtk.MenuItem(label)
self.parent_menu_item.set_submenu(gtk.Menu())
@ -774,6 +780,7 @@ class LocalMediaProperties:
self.menu.append(self.menu_item)
def remove_itself_from_menu(self):
del self.parent.parent.child_windows[self.win_key]
self.menu_item.destroy()
self.menu.destroy()
self.parent_menu_item.destroy()

View File

@ -76,7 +76,7 @@ class Marriage:
if self.parent.wins_dict.has_key(family.get_id()):
self.parent.wins_dict[family.get_id()].present(None)
return
self.child_windows = []
self.child_windows = {}
self.db = db
self.path = db.get_save_path()
self.cb = callback
@ -260,9 +260,9 @@ class Marriage:
self.window.show()
def close_child_windows(self):
for child_window in self.child_windows:
for child_window in self.child_windows.values():
child_window.close(None)
self.child_windows = []
self.child_windows = {}
def close(self,ok=0):
self.gallery.close(ok)

View File

@ -51,9 +51,17 @@ class NameEditor:
def __init__(self,parent,name,callback,parent_window=None):
self.parent = parent
self.db = self.parent.db
if name:
if self.parent.child_windows.has_key(name):
self.parent.child_windows[name].present(None)
return
else:
self.win_key = name
else:
self.win_key = self
self.name = name
self.callback = callback
self.child_windows = []
self.child_windows = {}
self.top = gtk.glade.XML(const.dialogFile, "name_edit","gramps")
self.window = self.top.get_widget("name_edit")
self.given_field = self.top.get_widget("alt_given")
@ -125,27 +133,25 @@ class NameEditor:
if parent_window:
self.window.set_transient_for(parent_window)
self.parent.child_windows.append(self)
self.add_itself_to_menu()
self.window.show()
def on_delete_event(self,obj,b):
self.close_child_windows()
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
def close(self,obj):
self.close_child_windows()
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
self.window.destroy()
def close_child_windows(self):
for child_window in self.child_windows:
for child_window in self.child_windows.values():
child_window.close(None)
self.child_windows = []
self.child_windows = {}
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
if not self.name:
label = _("New Name")
else:
@ -164,6 +170,7 @@ class NameEditor:
self.menu.append(self.menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.menu_item.destroy()
self.menu.destroy()
self.parent_menu_item.destroy()

View File

@ -44,9 +44,17 @@ class NoteEditor:
"""Displays a simple text editor that allows a person to edit a note"""
def __init__(self,data,parent,parent_window=None):
self.parent = parent
if data:
if self.parent.child_windows.has_key(data):
self.parent.child_windows[data].present(None)
return
else:
self.win_key = data
else:
self.win_key = self
self.data = data
self.parent_window = parent_window
self.parent = parent
self.draw()
def draw(self):
@ -84,26 +92,25 @@ class NoteEditor:
if self.parent_window:
self.top.set_transient_for(self.parent_window)
self.parent.child_windows.append(self)
self.add_itself_to_menu()
self.top.show()
def on_delete_event(self,obj,b):
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
def close(self,obj):
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
self.top.destroy()
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
self.parent_menu_item = gtk.MenuItem(_('Note'))
self.parent_menu_item.connect("activate",self.present)
self.parent_menu_item.show()
self.parent.menu.append(self.parent_menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.parent_menu_item.destroy()
def present(self,obj):

View File

@ -50,9 +50,17 @@ class SourceSelector:
def __init__(self,srclist,parent,update=None):
self.db = parent.db
self.parent = parent
if srclist:
if self.parent.child_windows.has_key(id(srclist)):
self.parent.child_windows[id(srclist)].present(None)
return
else:
self.win_key = id(srclist)
else:
self.win_key = self
self.orig = srclist
self.list = []
self.child_windows = []
self.child_windows = {}
for s in self.orig:
self.list.append(RelLib.SourceRef(s))
self.update=update
@ -98,27 +106,25 @@ class SourceSelector:
self.redraw()
if self.parent:
self.window.set_transient_for(self.parent.window)
self.parent.child_windows.append(self)
self.add_itself_to_menu()
self.window.show()
def on_delete_event(self,obj,b):
self.close_child_windows()
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
def close(self,obj):
self.close_child_windows()
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
self.window.destroy()
def close_child_windows(self):
for child_window in self.child_windows:
for child_window in self.child_windows.values():
child_window.close(None)
self.child_windows = []
self.child_windows = {}
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
label = _('Source Reference')
self.parent_menu_item = gtk.MenuItem(label)
self.parent_menu_item.set_submenu(gtk.Menu())
@ -131,6 +137,7 @@ class SourceSelector:
self.menu.append(self.menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self.win_key]
self.menu_item.destroy()
self.menu.destroy()
self.parent_menu_item.destroy()
@ -282,13 +289,21 @@ class SourceEditor:
self.db = database
self.parent = parent
self.update = update
self.source_ref = srcref
self.child_windows = []
if self.parent.__dict__.has_key('child_windows'):
self.win_parent = self.parent
else:
self.win_parent = self.parent.parent
if srcref:
if self.win_parent.child_windows.has_key(srcref):
self.win_parent.child_windows[srcref].present(None)
return
else:
self.win_key = srcref
else:
self.win_key = self
self.update = update
self.source_ref = srcref
self.child_windows = {}
self.showSource = gtk.glade.XML(const.srcselFile, "sourceDisplay","gramps")
self.sourceDisplay = self.get_widget("sourceDisplay")
@ -327,27 +342,25 @@ class SourceEditor:
self.set_button()
if self.parent:
self.sourceDisplay.set_transient_for(self.parent.window)
self.win_parent.child_windows.append(self)
self.add_itself_to_menu()
self.sourceDisplay.show()
def on_delete_event(self,obj,b):
self.close_child_windows()
self.remove_itself_from_menu()
self.win_parent.child_windows.remove(self)
def close(self,obj):
self.close_child_windows()
self.remove_itself_from_menu()
self.win_parent.child_windows.remove(self)
self.sourceDisplay.destroy()
def close_child_windows(self):
for child_window in self.child_windows:
for child_window in self.child_windows.values():
child_window.close(None)
self.child_windows = []
self.child_windows = {}
def add_itself_to_menu(self):
self.win_parent.child_windows[self.win_key] = self
if self.active_source:
label = self.active_source.get_title()
else:
@ -366,6 +379,7 @@ class SourceEditor:
self.menu.append(self.menu_item)
def remove_itself_from_menu(self):
del self.win_parent.child_windows[self.win_key]
self.menu_item.destroy()
self.menu.destroy()
self.parent_menu_item.destroy()

View File

@ -47,6 +47,14 @@ class UrlEditor:
def __init__(self,parent,name,url,callback,parent_window=None):
self.parent = parent
if url:
if self.parent.child_windows.has_key(url):
self.parent.child_windows[url].present(None)
return
else:
self.win_key = url
else:
self.win_key = self
self.url = url
self.callback = callback
self.top = gtk.glade.XML(const.dialogFile, "url_edit","gramps")
@ -78,20 +86,18 @@ class UrlEditor:
if parent_window:
self.window.set_transient_for(parent_window)
self.parent.child_windows.append(self)
self.add_itself_to_menu()
self.window.show()
def on_delete_event(self,obj,b):
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
def close(self,obj):
self.remove_itself_from_menu()
self.parent.child_windows.remove(self)
self.window.destroy()
def add_itself_to_menu(self):
self.parent.child_windows[self.win_key] = self
label = _('Internet Address Editor')
self.parent_menu_item = gtk.MenuItem(label)
self.parent_menu_item.connect("activate",self.present)
@ -99,6 +105,7 @@ class UrlEditor:
self.parent.menu.append(self.parent_menu_item)
def remove_itself_from_menu(self):
self.parent.child_windows[self.win_key]
self.parent_menu_item.destroy()
def present(self,obj):

View File

@ -118,6 +118,14 @@ class WitnessEditor:
self.db = database
self.parent = parent
if ref:
if self.parent.parent.child_windows.has_key(ref):
self.parent.parent.child_windows[ref].present(None)
return
else:
self.win_key = ref
else:
self.win_key = self
self.update = update
self.ref = ref
self.show_witness = gtk.glade.XML(const.dialogFile, "witness_edit","gramps")
@ -155,26 +163,25 @@ class WitnessEditor:
if parent_window:
self.window.set_transient_for(parent_window)
self.parent.parent.child_windows.append(self)
self.add_itself_to_menu()
self.window.show()
def on_delete_event(self,obj,b):
self.remove_itself_from_menu()
self.parent.parent.child_windows.remove(self)
def close(self,obj):
self.remove_itself_from_menu()
self.parent.parent.child_windows.remove(self)
self.window.destroy()
def add_itself_to_menu(self):
self.parent.parent.child_windows[self.win_key] = self
self.parent_menu_item = gtk.MenuItem(_('Witness Editor'))
self.parent_menu_item.connect("activate",self.present)
self.parent_menu_item.show()
self.parent.parent.menu.append(self.parent_menu_item)
def remove_itself_from_menu(self):
self.parent.parent.child_windows[self.win_key]
self.parent_menu_item.destroy()
def present(self,obj):