* 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
This commit is contained in:
Alex Roitman 2004-02-19 13:40:09 +00:00
parent ccb88f8d46
commit f2a684d957
5 changed files with 82 additions and 31 deletions

View File

@ -1,3 +1,11 @@
2004-02-19 Alex Roitman <shura@alex.neuro.umn.edu>
* 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 <shura@alex.neuro.umn.edu>
* src/Relationship.py: Factor out relationship distance computation.
* src/plugins/rel_ru.py: Use self.get_distance().

View File

@ -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):

View File

@ -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):

View File

@ -51,7 +51,7 @@
<accelerator key="N" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1705">
<widget class="GtkImage" id="image1745">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
@ -73,7 +73,7 @@
<accelerator key="O" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1706">
<widget class="GtkImage" id="image1746">
<property name="visible">True</property>
<property name="stock">gtk-open</property>
<property name="icon_size">1</property>
@ -95,7 +95,7 @@
<accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1707">
<widget class="GtkImage" id="image1747">
<property name="visible">True</property>
<property name="stock">gtk-save</property>
<property name="icon_size">1</property>
@ -116,7 +116,7 @@
<signal name="activate" handler="on_save_as_activate" last_modification_time="Tue, 01 Apr 2003 03:50:28 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1708">
<widget class="GtkImage" id="image1748">
<property name="visible">True</property>
<property name="stock">gtk-save-as</property>
<property name="icon_size">1</property>
@ -150,7 +150,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1709">
<widget class="GtkImage" id="image1749">
<property name="visible">True</property>
<property name="stock">gtk-convert</property>
<property name="icon_size">1</property>
@ -171,7 +171,7 @@
<signal name="activate" handler="on_revert_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1710">
<widget class="GtkImage" id="image1750">
<property name="visible">True</property>
<property name="stock">gtk-revert-to-saved</property>
<property name="icon_size">1</property>
@ -192,7 +192,7 @@
<signal name="activate" handler="on_reload_plugins_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1711">
<widget class="GtkImage" id="image1751">
<property name="visible">True</property>
<property name="stock">gtk-refresh</property>
<property name="icon_size">1</property>
@ -220,7 +220,7 @@
<accelerator key="Q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1712">
<widget class="GtkImage" id="image1752">
<property name="visible">True</property>
<property name="stock">gtk-quit</property>
<property name="icon_size">1</property>
@ -256,7 +256,7 @@
<accelerator key="Insert" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1713">
<widget class="GtkImage" id="image1753">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@ -279,7 +279,7 @@
<accelerator key="Delete" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1714">
<widget class="GtkImage" id="image1754">
<property name="visible">True</property>
<property name="stock">gtk-remove</property>
<property name="icon_size">1</property>
@ -317,7 +317,7 @@
<accelerator key="F" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1715">
<widget class="GtkImage" id="image1755">
<property name="visible">True</property>
<property name="stock">gtk-find</property>
<property name="icon_size">1</property>
@ -339,7 +339,7 @@
<accelerator key="M" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1716">
<widget class="GtkImage" id="image1756">
<property name="visible">True</property>
<property name="stock">gtk-convert</property>
<property name="icon_size">1</property>
@ -366,7 +366,7 @@
<signal name="activate" handler="on_preferences1_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1717">
<widget class="GtkImage" id="image1757">
<property name="visible">True</property>
<property name="stock">gtk-preferences</property>
<property name="icon_size">1</property>
@ -387,7 +387,7 @@
<signal name="activate" handler="on_default_person_activate" last_modification_time="Sat, 16 Aug 2003 01:58:26 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1718">
<widget class="GtkImage" id="image1758">
<property name="visible">True</property>
<property name="stock">gtk-home</property>
<property name="icon_size">1</property>
@ -473,7 +473,7 @@
<accelerator key="D" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1719">
<widget class="GtkImage" id="image1759">
<property name="visible">True</property>
<property name="stock">gtk-index</property>
<property name="icon_size">1</property>
@ -495,7 +495,7 @@
<accelerator key="B" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1720">
<widget class="GtkImage" id="image1760">
<property name="visible">True</property>
<property name="stock">gnome-stock-book-open</property>
<property name="icon_size">1</property>
@ -542,6 +542,14 @@
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="windows1">
<property name="visible">True</property>
<property name="label" translatable="yes">_Windows</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="help1">
<property name="visible">True</property>
@ -560,7 +568,7 @@
<accelerator key="F1" modifiers="0" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1721">
<widget class="GtkImage" id="image1761">
<property name="visible">True</property>
<property name="stock">gtk-help</property>
<property name="icon_size">1</property>
@ -581,7 +589,7 @@
<signal name="activate" handler="on_faq_activate" last_modification_time="Wed, 26 Nov 2003 17:59:23 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1722">
<widget class="GtkImage" id="image1762">
<property name="visible">True</property>
<property name="stock">gnome-stock-book-open</property>
<property name="icon_size">1</property>
@ -608,7 +616,7 @@
<signal name="activate" handler="on_gramps_home_page_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1723">
<widget class="GtkImage" id="image1763">
<property name="visible">True</property>
<property name="stock">gtk-jump-to</property>
<property name="icon_size">1</property>
@ -629,7 +637,7 @@
<signal name="activate" handler="on_gramps_mailing_lists_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1724">
<widget class="GtkImage" id="image1764">
<property name="visible">True</property>
<property name="stock">gnome-stock-mail</property>
<property name="icon_size">1</property>
@ -683,7 +691,7 @@
<signal name="activate" handler="on_about_activate" last_modification_time="Tue, 01 Apr 2003 03:44:24 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1725">
<widget class="GtkImage" id="image1765">
<property name="visible">True</property>
<property name="stock">gnome-stock-about</property>
<property name="icon_size">1</property>

View File

@ -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()