diff --git a/ChangeLog b/ChangeLog index 88fa254b7..8693aedbf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,16 @@ * src/plugins/FilterEditor.py: Clean up window management. * src/rule.glade: Define event handlers. + * src/plugins/Desbrowser.py: Convert to db; window management. + * src/plugins/desbrowse.glade: Define event handler. + * src/plugins/EventCmp.py: Clean up window management. + * src/plugins/eventcmp.glade: Define event handler. + * src/plugins/Check.py: Clean up conversion to db. + * src/plugins/summary.glade: Make dialog modal. + * src/plugins/Merge.py: Window management. + * src/plugins/merge.glade: Define event handlers. + * src/plugins/ChangeTypes.py: Convert to db. + 2004-05-09 Don Allingham * src/DbPrompter.py: added a .grdb if not specified. diff --git a/src/plugins/ChangeTypes.py b/src/plugins/ChangeTypes.py index 278066718..9db97962e 100644 --- a/src/plugins/ChangeTypes.py +++ b/src/plugins/ChangeTypes.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000 Donald N. Allingham +# Copyright (C) 2000-2004 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -38,9 +38,9 @@ import AutoComp # # #------------------------------------------------------------------------- -def runTool(database,person,callback): +def runTool(database,person,callback,parent=None): try: - ChangeTypes(database,person) + ChangeTypes(database,person,parent) except: import DisplayTrace DisplayTrace.DisplayTrace() @@ -51,7 +51,7 @@ def runTool(database,person,callback): # #------------------------------------------------------------------------- class ChangeTypes: - def __init__(self,db,person): + def __init__(self,db,person,parent): self.person = person self.db = db @@ -78,12 +78,17 @@ class ChangeTypes: original = unicode(self.glade.get_widget("original_text").get_text()) new = unicode(self.glade.get_widget("new_text").get_text()) - for person in self.db.get_person_id_map().values(): - for event in person.get_event_list(): + for person_id in self.db.get_person_keys(): + person = self.db.find_person_from_id(person_id) + for event_id in person.get_event_list(): + if not event_id: + continue + event = self.db.find_event_from_id(event_id) if event.get_name() == original: event.set_name(new) modified = modified + 1 Utils.modified() + self.db.commit_event(event) if modified == 1: msg = _("1 event record was modified") diff --git a/src/plugins/Check.py b/src/plugins/Check.py index 466a9a12a..850bb2d11 100644 --- a/src/plugins/Check.py +++ b/src/plugins/Check.py @@ -55,10 +55,10 @@ from QuestionDialog import OkDialog, MissingMediaDialog # runTool # #------------------------------------------------------------------------- -def runTool(database,active_person,callback): +def runTool(database,active_person,callback,parent=None): try: - checker = CheckIntegrity(database) + checker = CheckIntegrity(database,parent) checker.check_for_broken_family_links() checker.cleanup_missing_photos(0) checker.check_parent_relationships() @@ -77,7 +77,7 @@ def runTool(database,active_person,callback): #------------------------------------------------------------------------- class CheckIntegrity: - def __init__(self,db): + def __init__(self,db,parent): self.db = db self.bad_photo = [] self.replaced_photo = [] diff --git a/src/plugins/Desbrowser.py b/src/plugins/Desbrowser.py index ccbd0ea15..012ba5fcf 100644 --- a/src/plugins/Desbrowser.py +++ b/src/plugins/Desbrowser.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000 Donald N. Allingham +# Copyright (C) 2000-2004 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,6 +18,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + "Analysis and Exploration/Interactive descendant browser" #------------------------------------------------------------------------ @@ -50,32 +52,35 @@ import gtk.glade # # #------------------------------------------------------------------------ -def runTool(database,person,callback): +def runTool(database,person,callback,parent=None): try: - DesBrowse(database,person,callback) + DesBrowse(database,person,callback,parent) except: import DisplayTrace DisplayTrace.DisplayTrace() class DesBrowse: - def __init__(self,database,person,callback): + def __init__(self,database,person,callback,parent): self.active = person self.db = database self.callback = callback + self.parent = parent + self.win_key = self base = os.path.dirname(__file__) glade_file = base + os.sep + "desbrowse.glade" self.glade = gtk.glade.XML(glade_file,"top","gramps") self.glade.signal_autoconnect({ - "destroy_passed_object" : Utils.destroy_passed_object, + "destroy_passed_object" : self.close, + "on_delete_event": self.on_delete_event, }) - top = self.glade.get_widget("top") + self.window = self.glade.get_widget("top") - Utils.set_titles(top,self.glade.get_widget('title'), + Utils.set_titles(self.window,self.glade.get_widget('title'), _("Descendant Browser")) - self.tree= self.glade.get_widget("tree1") + self.tree = self.glade.get_widget("tree1") col = gtk.TreeViewColumn('',gtk.CellRendererText(),text=0) self.tree.append_column(col) self.model = gtk.TreeStore(gobject.TYPE_STRING,gobject.TYPE_PYOBJECT) @@ -83,21 +88,45 @@ class DesBrowse: self.tree.set_rules_hint(gtk.TRUE) self.tree.set_headers_visible(gtk.FALSE) - self.add_to_tree(None,None,self.active) + self.add_to_tree(None,None,self.active.get_id()) self.tree.expand_all() self.tree.connect('event',self.button_press_event) - top.show() + self.add_itself_to_menu() + self.window.show() - def add_to_tree(self,parent,sib,person): - item = self.model.insert_after(parent,sib) - self.model.set(item,0,GrampsCfg.nameof(person)) - self.model.set(item,1,person) - prev = None - for family in person.get_family_id_list(): - for child in family.get_child_id_list(): - prev = self.add_to_tree(item,prev,child) - return item + def on_delete_event(self,obj,b): + self.remove_itself_from_menu() + + def close(self,obj): + self.remove_itself_from_menu() + self.window.destroy() + + def add_itself_to_menu(self): + self.parent.child_windows[self.win_key] = self + self.parent_menu_item = gtk.MenuItem(_("Descendant Browser tool")) + self.parent_menu_item.connect("activate",self.present) + self.parent_menu_item.show() + self.parent.winsmenu.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): + self.window.present() + + def add_to_tree(self,parent_id,sib_id,person_id): + item_id = self.model.insert_after(parent_id,sib_id) + person = self.db.find_person_from_id(person_id) + self.model.set(item_id,0,GrampsCfg.nameof(person)) + self.model.set(item_id,1,person_id) + prev_id = None + for family_id in person.get_family_id_list(): + family = self.db.find_family_from_id(family_id) + for child_id in family.get_child_id_list(): + prev_id = self.add_to_tree(item_id,prev_id,child_id) + return item_id def button_press_event(self,obj,event): import EditPerson @@ -105,8 +134,9 @@ class DesBrowse: if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: store,iter = self.tree.get_selection().get_selected() if iter: - person = store.get_value(iter,1) - EditPerson.EditPerson(person,self.db,self.callback) + person_id = store.get_value(iter,1) + person = self.db.find_person_from_id(person_id) + EditPerson.EditPerson(self.parent,person,self.db,self.callback) #------------------------------------------------------------------------ # @@ -123,5 +153,3 @@ register_tool( author_name="Donald N. Allingham", author_email="dallingham@users.sourceforge.net" ) - - diff --git a/src/plugins/EventCmp.py b/src/plugins/EventCmp.py index 531971628..f88232025 100644 --- a/src/plugins/EventCmp.py +++ b/src/plugins/EventCmp.py @@ -211,7 +211,7 @@ class EventComparison: if len(plist) == 0: WarningDialog(_("No matches were found")) else: - DisplayChart(self.db,plist,self.parent) + DisplayChart(self.db,plist,self) #------------------------------------------------------------------------ # @@ -248,6 +248,9 @@ class DisplayChart: self.db = database self.my_list = people_list self.row_data = [] + self.parent = parent + self.win_key = self + self.save_form = None base = os.path.dirname(__file__) self.glade_file = base + os.sep + "eventcmp.glade" @@ -255,13 +258,14 @@ class DisplayChart: self.topDialog = gtk.glade.XML(self.glade_file,"view","gramps") self.topDialog.signal_autoconnect({ "on_write_table" : self.on_write_table, - "destroy_passed_object" : Utils.destroy_passed_object + "destroy_passed_object" : self.close, + "on_view_delete_event" : self.on_delete_event, }) - self.top = self.topDialog.get_widget("view") + self.window = self.topDialog.get_widget("view") self.eventlist = self.topDialog.get_widget('treeview') - Utils.set_titles(self.top, self.topDialog.get_widget('title'), + Utils.set_titles(self.window, self.topDialog.get_widget('title'), _('Event Comparison')) self.sort = Sort.Sort(self.db) @@ -270,7 +274,33 @@ class DisplayChart: self.event_titles = self.make_event_titles() self.build_row_data() self.draw_clist_display() - self.top.show() + self.add_itself_to_menu() + self.window.show() + + def on_delete_event(self,obj,b): + self.remove_itself_from_menu() + if self.save_form: + self.save_form.destroy() + + def close(self,obj): + self.remove_itself_from_menu() + if self.save_form: + self.save_form.destroy() + self.window.destroy() + + def add_itself_to_menu(self): + self.parent.child_windows[self.win_key] = self + self.parent_menu_item = gtk.MenuItem(_("Event Comparison")) + self.parent_menu_item.connect("activate",self.present) + self.parent_menu_item.show() + self.parent.winsmenu.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): + self.window.present() def draw_clist_display(self): diff --git a/src/plugins/Merge.py b/src/plugins/Merge.py index adc37fa20..130309868 100644 --- a/src/plugins/Merge.py +++ b/src/plugins/Merge.py @@ -66,11 +66,6 @@ def is_initial(name): else: return name[0] == name[0].upper() -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- #------------------------------------------------------------------------- # # @@ -78,8 +73,10 @@ def is_initial(name): #------------------------------------------------------------------------- class Merge: - def __init__(self,database,callback): + def __init__(self,database,callback,parent): self.db = database + self.parent = parent + self.win_key = self self.map = {} self.list = [] self.index = 0 @@ -114,13 +111,38 @@ class Merge: self.menu = top.get_widget("menu") self.menu.set_menu(my_menu) - Utils.set_titles(top.get_widget('dialog'), top.get_widget('title'), + self.dialog_window = top.get_widget('dialog') + Utils.set_titles(self.dialog_window, top.get_widget('title'), _('Merge people')) top.signal_autoconnect({ "on_merge_ok_clicked" : self.on_merge_ok_clicked, - "destroy_passed_object" : Utils.destroy_passed_object + "destroy_passed_object" : self.close, + "on_delete_merge_event" : self.on_delete_event, }) + self.add_itself_to_menu() + self.dialog_window.show() + + def on_delete_event(self,obj,b): + self.remove_itself_from_menu() + + def close(self,obj): + self.remove_itself_from_menu() + self.dialog_window.destroy() + + def add_itself_to_menu(self): + self.parent.child_windows[self.win_key] = self + self.parent_menu_item = gtk.MenuItem(_('Merge people')) + self.parent_menu_item.connect("activate",self.present) + self.parent_menu_item.show() + self.parent.winsmenu.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): + self.dialog_window.present() def ancestors_of(self,p1_id,id_list): if (not p1_id) or (p1_id in id_list): @@ -136,7 +158,7 @@ class Merge: def on_merge_ok_clicked(self,obj): active = self.menu.get_menu().get_active().get_data("v") self.use_soundex = self.soundex_obj.get_active() - Utils.destroy_passed_object(obj) + self.close(obj) self.find_potentials(active) self.show() @@ -221,8 +243,9 @@ class Merge: self.mlist = top.get_widget("mlist") top.signal_autoconnect({ - "destroy_passed_object" : Utils.destroy_passed_object, + "destroy_passed_object" : self.close_show, "on_do_merge_clicked" : self.on_do_merge_clicked, + "on_delete_show_event" : self.on_delete_show_event, }) mtitles = [(_('Rating'),3,75),(_('First Person'),1,200), @@ -231,6 +254,29 @@ class Merge: event_func=self.on_do_merge_clicked) self.redraw() + self.add_show_to_menu() + self.window.show() + + def on_delete_show_event(self,obj,b): + self.remove_show_from_menu() + + def close_show(self,obj): + self.remove_show_from_menu() + self.window.destroy() + + def add_show_to_menu(self): + self.parent.child_windows[self.win_key] = self + self.parent_menu_item = gtk.MenuItem(_('Potential Merges')) + self.parent_menu_item.connect("activate",self.present_show) + self.parent_menu_item.show() + self.parent.winsmenu.append(self.parent_menu_item) + + def remove_show_from_menu(self): + del self.parent.child_windows[self.win_key] + self.parent_menu_item.destroy() + + def present_show(self,obj): + self.window.present() def redraw(self): list = [] @@ -258,7 +304,7 @@ class Merge: (p1,p2) = self.list.get_object(iter) pn1 = self.db.find_person_from_id(p1) pn2 = self.db.find_person_from_id(p2) - MergeData.MergePeople(self.db,pn1,pn2,self.on_update) + MergeData.MergePeople(self.parent,self.db,pn1,pn2,self.on_update) def on_update(self,p1_id,p2_id,old_id): self.dellist[p2_id] = p1_id @@ -562,7 +608,11 @@ class Merge: return chance - +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- def name_of(p): if not p: return "" @@ -579,9 +629,9 @@ def get_name_obj(person): # # #------------------------------------------------------------------------- -def runTool(database,active_person,callback): +def runTool(database,active_person,callback,parent=None): try: - Merge(database,callback) + Merge(database,callback,parent) except: import DisplayTrace DisplayTrace.DisplayTrace() @@ -608,4 +658,3 @@ register_tool( description=_("Searches the entire database, looking for " "individual entries that may represent the same person.") ) - diff --git a/src/plugins/desbrowse.glade b/src/plugins/desbrowse.glade index 164ab1f9b..7ff4df4f0 100644 --- a/src/plugins/desbrowse.glade +++ b/src/plugins/desbrowse.glade @@ -13,7 +13,13 @@ 400 True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST True + @@ -34,6 +40,7 @@ gtk-close True GTK_RELIEF_NORMAL + True 0 diff --git a/src/plugins/eventcmp.glade b/src/plugins/eventcmp.glade index 30983c8d4..1fdf4f4f9 100644 --- a/src/plugins/eventcmp.glade +++ b/src/plugins/eventcmp.glade @@ -292,6 +292,7 @@ GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST False + diff --git a/src/plugins/merge.glade b/src/plugins/merge.glade index 1f92f1bca..9cf180cb2 100644 --- a/src/plugins/merge.glade +++ b/src/plugins/merge.glade @@ -112,6 +112,7 @@ GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST False + @@ -239,6 +240,7 @@ GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST False + diff --git a/src/plugins/summary.glade b/src/plugins/summary.glade index 64d2d886c..edcd2a2a5 100644 --- a/src/plugins/summary.glade +++ b/src/plugins/summary.glade @@ -8,11 +8,16 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE - False + True 450 400 True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST False @@ -34,6 +39,7 @@ gtk-close True GTK_RELIEF_NORMAL + True 0 @@ -89,6 +95,8 @@ True True True + False + True GTK_JUSTIFY_LEFT GTK_WRAP_NONE True