From a638a038bcedd7d78b02441696e4ccf83e78a549 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Fri, 20 Feb 2004 01:15:37 +0000 Subject: [PATCH] More svn: r2876 --- gramps2/src/AddrEdit.py | 51 ++++++++++++++++++++++++++----- gramps2/src/AttrEdit.py | 67 +++++++++++++++++++++++++++++++---------- gramps2/src/NameEdit.py | 1 - 3 files changed, 95 insertions(+), 24 deletions(-) diff --git a/gramps2/src/AddrEdit.py b/gramps2/src/AddrEdit.py index 9cf23bb96..47c0739d1 100644 --- a/gramps2/src/AddrEdit.py +++ b/gramps2/src/AddrEdit.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 @@ -85,6 +85,7 @@ class AddressEditor: 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") @@ -127,22 +128,57 @@ class AddressEditor: self.top.signal_autoconnect({ "on_switch_page" : self.on_switch_page, - "on_help_addr_clicked" : self.on_help_clicked + "on_help_addr_clicked" : self.on_help_clicked, + "on_ok_addr_clicked" : self.ok_clicked, + "on_cancel_addr_clicked" : self.close, + "on_addr_edit_delete_event" : self.on_delete_event, }) if parent_window: self.window.set_transient_for(parent_window) - self.val = self.window.run() - if self.val == gtk.RESPONSE_OK: - self.ok_clicked() + 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() self.window.destroy() + def close_child_windows(self): + for child_window in self.child_windows: + child_window.close(None) + self.child_windows = [] + + def add_itself_to_menu(self): + label = _('Address') + self.parent_menu_item = gtk.MenuItem(label) + self.parent_menu_item.set_submenu(gtk.Menu()) + self.parent_menu_item.show() + self.parent.menu.append(self.parent_menu_item) + self.menu = self.parent_menu_item.get_submenu() + self.menu_item = gtk.MenuItem(_('Address Editor')) + self.menu_item.connect("activate",self.present) + self.menu_item.show() + self.menu.append(self.menu_item) + + def remove_itself_from_menu(self): + self.menu_item.destroy() + self.menu.destroy() + self.parent_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') - self.val = self.window.run() - def ok_clicked(self): + def ok_clicked(self,obj): """ Called when the OK button is pressed. Gets data from the form and updates the Address data structure. @@ -166,6 +202,7 @@ class AddressEditor: self.update(date,street,city,state,country,postal,phone,note,format,priv) self.callback(self.addr) + self.close(obj) def check(self,get,set,data): """Compares a data item, updates if necessary, and sets the diff --git a/gramps2/src/AttrEdit.py b/gramps2/src/AttrEdit.py index 0b2430800..1ebfc8e55 100644 --- a/gramps2/src/AttrEdit.py +++ b/gramps2/src/AttrEdit.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 @@ -21,8 +21,8 @@ # $Id$ """ -The AttrEdit module provides the AddressEditor class. This provides a -mechanism for the user to edit address information. +The AttrEdit module provides the AttributeEditor class. This provides a +mechanism for the user to edit attribute information. """ __author__ = "Donald N. Allingham" @@ -85,6 +85,7 @@ class AttributeEditor: 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") @@ -123,31 +124,64 @@ class AttributeEditor: self.flowed.set_active(1) self.top.signal_autoconnect({ - "on_add_src_clicked" : self.add_source, - "on_del_src_clicked" : self.del_source, "on_help_attr_clicked" : self.on_help_clicked, + "on_ok_attr_clicked" : self.on_ok_clicked, + "on_cancel_attr_clicked" : self.close, + "on_attr_edit_delete_event" : self.on_delete_event, "on_switch_page" : self.on_switch_page }) if parent_window: self.window.set_transient_for(parent_window) - self.val = self.window.run() - if self.val == gtk.RESPONSE_OK: - self.on_ok_clicked() + 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() self.window.destroy() + def close_child_windows(self): + for child_window in self.child_windows: + child_window.close(None) + self.child_windows = [] + + def add_itself_to_menu(self): + if not self.attrib: + label = _("New Attribute") + else: + label = self.attrib.get_type() + if not label.strip(): + label = _("New Attribute") + label = "%s: %s" % (_('Attribute'),label) + self.parent_menu_item = gtk.MenuItem(label) + self.parent_menu_item.set_submenu(gtk.Menu()) + self.parent_menu_item.show() + self.parent.menu.append(self.parent_menu_item) + self.menu = self.parent_menu_item.get_submenu() + self.menu_item = gtk.MenuItem(_('Attribute Editor')) + self.menu_item.connect("activate",self.present) + self.menu_item.show() + self.menu.append(self.menu_item) + + def remove_itself_from_menu(self): + self.menu_item.destroy() + self.menu.destroy() + self.parent_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') - self.val = self.window.run() - def add_source(self,obj): - pass - - def del_source(self,obj): - pass - - def on_ok_clicked(self): + def on_ok_clicked(self,obj): """ Called when the OK button is pressed. Gets data from the form and updates the Attribute data structure. @@ -174,6 +208,7 @@ class AttributeEditor: self.attrib.set_source_reference_list(self.srcreflist) self.update(type,value,note,format,priv) self.callback(self.attrib) + self.close(obj) def check(self,get,set,data): """Compares a data item, updates if necessary, and sets the diff --git a/gramps2/src/NameEdit.py b/gramps2/src/NameEdit.py index 6f5eb0b59..6de54d7b5 100644 --- a/gramps2/src/NameEdit.py +++ b/gramps2/src/NameEdit.py @@ -172,7 +172,6 @@ class NameEditor: 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() def on_name_edit_ok_clicked(self,obj): first = unicode(self.given_field.get_text())