diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 5c7d798e3..419735805 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -5,6 +5,7 @@ * 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. + * src/dialog.glade: Add handler. 2004-02-16 Alex Roitman * src/Relationship.py: Factor out relationship distance computation. diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index bf6e80176..47257140d 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -82,7 +82,8 @@ class EditPerson: self.original_id = person.get_id() self.parent = parent if self.parent.wins_dict.has_key(self.original_id): - return + self.parent.wins_dict[self.original_id].present(None) + return self.db = db self.callback = callback self.child_windows = [] @@ -410,19 +411,36 @@ class EditPerson: self.add_itself_to_winsmenu() self.window.show() + def close_child_windows(self): + for child_window in self.child_windows: + child_window.close(None) + + def close(self,ok=0): + self.gallery.close(ok) + self.close_child_windows() + self.remove_itself_from_winsmenu() + self.window.destroy() + 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.parent.wins_dict[self.original_id] = self + win_menu_label = GrampsCfg.nameof(self.person) + if not win_menu_label.strip(): + win_menu_label = _("NewPerson") + self.win_menu_item = gtk.MenuItem(win_menu_label) + self.win_menu_item.set_submenu(gtk.Menu()) + self.win_menu_item.show() + self.parent.winsmenu.append(self.win_menu_item) + self.menu = self.win_menu_item.get_submenu() + self.menu_item = gtk.MenuItem(_('Edit Person')) self.menu_item.connect("activate",self.present) self.menu_item.show() - self.parent.winsmenu.append(self.menu_item) + self.menu.append(self.menu_item) def remove_itself_from_winsmenu(self): self.parent.wins_dict.pop(self.original_id,None) self.menu_item.destroy() + self.menu.destroy() + self.win_menu_item.destroy() def present(self,obj): self.window.present() @@ -995,9 +1013,7 @@ class EditPerson: self.cancel_callback, self.save) else: - self.gallery.close(0) - self.remove_itself_from_winsmenu() - self.window.destroy() + self.close(0) def save(self): self.on_apply_person_clicked(None) @@ -1014,16 +1030,12 @@ class EditPerson: self.save) return 1 else: - self.gallery.close(0) - self.remove_itself_from_winsmenu() - self.window.destroy() + self.close(0) 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() + self.close(0) def did_data_change(self): """Check to see if any of the data has changed from the @@ -1582,9 +1594,7 @@ class EditPerson: if self.callback: self.callback(self) - self.gallery.close(1) - self.remove_itself_from_winsmenu() - self.window.destroy() + self.close(1) def get_place(self,field,makenew=0): text = unicode(string.strip(field.get_text())) diff --git a/gramps2/src/NameEdit.py b/gramps2/src/NameEdit.py index 229205ad6..b81187719 100644 --- a/gramps2/src/NameEdit.py +++ b/gramps2/src/NameEdit.py @@ -53,6 +53,7 @@ class NameEditor: self.db = self.parent.db self.name = name self.callback = callback + 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") @@ -102,7 +103,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_name_edit_cancel_clicked" : self.close, + "on_name_edit_delete_event" : self.on_delete_event, "on_switch_page" : self.on_switch_page }) @@ -123,11 +125,34 @@ class NameEditor: if parent_window: self.window.set_transient_for(parent_window) - #self.val = self.window.run() - self.window.show() - #if self.val == gtk.RESPONSE_OK: - # self.on_name_edit_ok_clicked() - #self.window.destroy() + 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() + + def close(self,obj): + self.close_child_windows() + self.remove_itself_from_menu() + Utils.destroy_passed_object(self.window) + + def close_child_windows(self): + for child_window in self.child_windows: + child_window.close() + + def add_itself_to_menu(self): + self.menu_item = gtk.MenuItem(_('Name Editor')) + self.menu_item.connect("activate",self.present) + self.menu_item.show() + self.parent.menu.append(self.menu_item) + + def remove_itself_from_menu(self): + self.menu_item.destroy() + + def present(self,obj): + self.window.present() def on_help_clicked(self,obj): """Display the relevant portion of GRAMPS manual""" diff --git a/gramps2/src/dialog.glade b/gramps2/src/dialog.glade index 7251e249d..a750eb3ae 100644 --- a/gramps2/src/dialog.glade +++ b/gramps2/src/dialog.glade @@ -3241,6 +3241,7 @@ False gramps.png True + @@ -3263,7 +3264,7 @@ True GTK_RELIEF_NORMAL -6 - +