From f2a684d95795cf671c866be06d0a8c71732d20ba Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 19 Feb 2004 13:40:09 +0000 Subject: [PATCH] * src/EditPerson.py: Use parent class. Add/remove itself from/to the Windows menu. * src/NameEdit.py: Make non-modal. * src/gramps.glade: Add Windows menu. * src/gramps_main.py: Get Windows menu and its submenu. Pass Gramps class to the children -- first-class object editors. svn: r2870 --- gramps2/ChangeLog | 8 ++++++ gramps2/src/EditPerson.py | 28 ++++++++++++++++++++- gramps2/src/NameEdit.py | 18 ++++++++------ gramps2/src/gramps.glade | 50 ++++++++++++++++++++++---------------- gramps2/src/gramps_main.py | 9 +++++-- 5 files changed, 82 insertions(+), 31 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index b26afa36a..5c7d798e3 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,11 @@ +2004-02-19 Alex Roitman + * src/EditPerson.py: Use parent class. Add/remove itself from/to + the Windows menu. + * src/NameEdit.py: Make non-modal. + * src/gramps.glade: Add Windows menu. + * src/gramps_main.py: Get Windows menu and its submenu. + Pass Gramps class to the children -- first-class object editors. + 2004-02-16 Alex Roitman * src/Relationship.py: Factor out relationship distance computation. * src/plugins/rel_ru.py: Use self.get_distance(). diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index 7e5229bd2..bf6e80176 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -75,13 +75,17 @@ pycode_tgts = [('url', 0, 0), #------------------------------------------------------------------------- class EditPerson: - def __init__(self,person,db,callback=None): + def __init__(self,parent,person,db,callback=None): """Creates an edit window. Associates a person with the window.""" self.person = person self.original_id = person.get_id() + self.parent = parent + if self.parent.wins_dict.has_key(self.original_id): + return self.db = db self.callback = callback + self.child_windows = [] self.path = db.get_save_path() self.not_loaded = 1 self.lds_not_loaded = 1 @@ -403,8 +407,26 @@ class EditPerson: self.redraw_url_list() self.get_widget("notebook").set_current_page(0) self.given.grab_focus() + self.add_itself_to_winsmenu() self.window.show() + def add_itself_to_winsmenu(self): + self.parent.wins_dict[self.original_id] = self.window + label = GrampsCfg.nameof(self.person) + if not label.strip(): + label = _("NewPerson %(gramps_id)s") % { 'gramps_id' : self.original_id } + self.menu_item = gtk.MenuItem(label) + self.menu_item.connect("activate",self.present) + self.menu_item.show() + self.parent.winsmenu.append(self.menu_item) + + def remove_itself_from_winsmenu(self): + self.parent.wins_dict.pop(self.original_id,None) + self.menu_item.destroy() + + def present(self,obj): + self.window.present() + def on_help_clicked(self,obj): """Display the relevant portion of GRAMPS manual""" gnome.help_display('gramps-manual','gramps-edit-complete') @@ -974,6 +996,7 @@ class EditPerson: self.save) else: self.gallery.close(0) + self.remove_itself_from_winsmenu() self.window.destroy() def save(self): @@ -992,12 +1015,14 @@ class EditPerson: return 1 else: self.gallery.close(0) + self.remove_itself_from_winsmenu() self.window.destroy() return 0 def cancel_callback(self): """If the user answered yes to abandoning changes, close the window""" self.gallery.close(0) + self.remove_itself_from_winsmenu() self.window.destroy() def did_data_change(self): @@ -1558,6 +1583,7 @@ class EditPerson: self.callback(self) self.gallery.close(1) + self.remove_itself_from_winsmenu() self.window.destroy() def get_place(self,field,makenew=0): diff --git a/gramps2/src/NameEdit.py b/gramps2/src/NameEdit.py index 4b6453717..229205ad6 100644 --- a/gramps2/src/NameEdit.py +++ b/gramps2/src/NameEdit.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2003 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 @@ -101,6 +101,8 @@ class NameEditor: self.top.signal_autoconnect({ "on_help_name_clicked" : self.on_help_clicked, + "on_name_edit_ok_clicked" : self.on_name_edit_ok_clicked, + "destroy_passed_object" : Utils.destroy_passed_object, "on_switch_page" : self.on_switch_page }) @@ -121,17 +123,18 @@ class NameEditor: if parent_window: self.window.set_transient_for(parent_window) - self.val = self.window.run() - if self.val == gtk.RESPONSE_OK: - self.on_name_edit_ok_clicked() - self.window.destroy() + #self.val = self.window.run() + self.window.show() + #if self.val == gtk.RESPONSE_OK: + # self.on_name_edit_ok_clicked() + #self.window.destroy() def on_help_clicked(self,obj): """Display the relevant portion of GRAMPS manual""" gnome.help_display('gramps-manual','gramps-edit-complete') - self.val = self.window.run() + #self.val = self.window.run() - def on_name_edit_ok_clicked(self): + def on_name_edit_ok_clicked(self,obj): first = unicode(self.given_field.get_text()) last = unicode(self.surname_field.get_text()) title = unicode(self.title_field.get_text()) @@ -158,6 +161,7 @@ class NameEditor: self.parent.lists_changed = 1 self.callback(self.name) + Utils.destroy_passed_object(obj) def update_name(self,first,last,suffix,title,type,note,format,priv): diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index 8cb871680..775a7f1d8 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -51,7 +51,7 @@ - + True gtk-new 1 @@ -73,7 +73,7 @@ - + True gtk-open 1 @@ -95,7 +95,7 @@ - + True gtk-save 1 @@ -116,7 +116,7 @@ - + True gtk-save-as 1 @@ -150,7 +150,7 @@ True - + True gtk-convert 1 @@ -171,7 +171,7 @@ - + True gtk-revert-to-saved 1 @@ -192,7 +192,7 @@ - + True gtk-refresh 1 @@ -220,7 +220,7 @@ - + True gtk-quit 1 @@ -256,7 +256,7 @@ - + True gtk-add 1 @@ -279,7 +279,7 @@ - + True gtk-remove 1 @@ -317,7 +317,7 @@ - + True gtk-find 1 @@ -339,7 +339,7 @@ - + True gtk-convert 1 @@ -366,7 +366,7 @@ - + True gtk-preferences 1 @@ -387,7 +387,7 @@ - + True gtk-home 1 @@ -473,7 +473,7 @@ - + True gtk-index 1 @@ -495,7 +495,7 @@ - + True gnome-stock-book-open 1 @@ -542,6 +542,14 @@ + + + True + _Windows + True + + + True @@ -560,7 +568,7 @@ - + True gtk-help 1 @@ -581,7 +589,7 @@ - + True gnome-stock-book-open 1 @@ -608,7 +616,7 @@ - + True gtk-jump-to 1 @@ -629,7 +637,7 @@ - + True gnome-stock-mail 1 @@ -683,7 +691,7 @@ - + True gnome-stock-about 1 diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index aa3a14383..2ca3d00f2 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -264,6 +264,11 @@ class Gramps: self.fwdbtn = self.gtop.get_widget('fwd_btn') self.gomenuitem = self.gtop.get_widget("go1") + self.wins = self.gtop.get_widget("windows1") + self.wins.set_submenu(gtk.Menu()) + self.winsmenu = self.wins.get_submenu() + self.wins_dict = {} + self.gtop.signal_autoconnect({ "on_back_clicked" : self.back_clicked, "on_back_pressed" : self.back_pressed, @@ -1267,7 +1272,7 @@ class Gramps: def load_new_person(self,obj): self.active_person = RelLib.Person() try: - EditPerson.EditPerson(self.active_person,self.db, + EditPerson.EditPerson(self,self.active_person,self.db, self.new_after_edit) except: DisplayTrace.DisplayTrace() @@ -1637,7 +1642,7 @@ class Gramps: def load_person(self,person): if person: try: - EditPerson.EditPerson(person, self.db, self.update_after_edit) + EditPerson.EditPerson(self, person, self.db, self.update_after_edit) except: DisplayTrace.DisplayTrace()