svn: r2871
This commit is contained in:
Alex Roitman 2004-02-19 19:15:27 +00:00
parent f2a684d957
commit fdaaef219c
4 changed files with 63 additions and 26 deletions

View File

@ -5,6 +5,7 @@
* src/gramps.glade: Add Windows menu. * src/gramps.glade: Add Windows menu.
* src/gramps_main.py: Get Windows menu and its submenu. * src/gramps_main.py: Get Windows menu and its submenu.
Pass Gramps class to the children -- first-class object editors. Pass Gramps class to the children -- first-class object editors.
* src/dialog.glade: Add handler.
2004-02-16 Alex Roitman <shura@alex.neuro.umn.edu> 2004-02-16 Alex Roitman <shura@alex.neuro.umn.edu>
* src/Relationship.py: Factor out relationship distance computation. * src/Relationship.py: Factor out relationship distance computation.

View File

@ -82,7 +82,8 @@ class EditPerson:
self.original_id = person.get_id() self.original_id = person.get_id()
self.parent = parent self.parent = parent
if self.parent.wins_dict.has_key(self.original_id): 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.db = db
self.callback = callback self.callback = callback
self.child_windows = [] self.child_windows = []
@ -410,19 +411,36 @@ class EditPerson:
self.add_itself_to_winsmenu() self.add_itself_to_winsmenu()
self.window.show() 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): def add_itself_to_winsmenu(self):
self.parent.wins_dict[self.original_id] = self.window self.parent.wins_dict[self.original_id] = self
label = GrampsCfg.nameof(self.person) win_menu_label = GrampsCfg.nameof(self.person)
if not label.strip(): if not win_menu_label.strip():
label = _("NewPerson %(gramps_id)s") % { 'gramps_id' : self.original_id } win_menu_label = _("NewPerson")
self.menu_item = gtk.MenuItem(label) 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.connect("activate",self.present)
self.menu_item.show() self.menu_item.show()
self.parent.winsmenu.append(self.menu_item) self.menu.append(self.menu_item)
def remove_itself_from_winsmenu(self): def remove_itself_from_winsmenu(self):
self.parent.wins_dict.pop(self.original_id,None) self.parent.wins_dict.pop(self.original_id,None)
self.menu_item.destroy() self.menu_item.destroy()
self.menu.destroy()
self.win_menu_item.destroy()
def present(self,obj): def present(self,obj):
self.window.present() self.window.present()
@ -995,9 +1013,7 @@ class EditPerson:
self.cancel_callback, self.cancel_callback,
self.save) self.save)
else: else:
self.gallery.close(0) self.close(0)
self.remove_itself_from_winsmenu()
self.window.destroy()
def save(self): def save(self):
self.on_apply_person_clicked(None) self.on_apply_person_clicked(None)
@ -1014,16 +1030,12 @@ class EditPerson:
self.save) self.save)
return 1 return 1
else: else:
self.gallery.close(0) self.close(0)
self.remove_itself_from_winsmenu()
self.window.destroy()
return 0 return 0
def cancel_callback(self): def cancel_callback(self):
"""If the user answered yes to abandoning changes, close the window""" """If the user answered yes to abandoning changes, close the window"""
self.gallery.close(0) self.close(0)
self.remove_itself_from_winsmenu()
self.window.destroy()
def did_data_change(self): def did_data_change(self):
"""Check to see if any of the data has changed from the """Check to see if any of the data has changed from the
@ -1582,9 +1594,7 @@ class EditPerson:
if self.callback: if self.callback:
self.callback(self) self.callback(self)
self.gallery.close(1) self.close(1)
self.remove_itself_from_winsmenu()
self.window.destroy()
def get_place(self,field,makenew=0): def get_place(self,field,makenew=0):
text = unicode(string.strip(field.get_text())) text = unicode(string.strip(field.get_text()))

View File

@ -53,6 +53,7 @@ class NameEditor:
self.db = self.parent.db self.db = self.parent.db
self.name = name self.name = name
self.callback = callback self.callback = callback
self.child_windows = []
self.top = gtk.glade.XML(const.dialogFile, "name_edit","gramps") self.top = gtk.glade.XML(const.dialogFile, "name_edit","gramps")
self.window = self.top.get_widget("name_edit") self.window = self.top.get_widget("name_edit")
self.given_field = self.top.get_widget("alt_given") self.given_field = self.top.get_widget("alt_given")
@ -102,7 +103,8 @@ class NameEditor:
self.top.signal_autoconnect({ self.top.signal_autoconnect({
"on_help_name_clicked" : self.on_help_clicked, "on_help_name_clicked" : self.on_help_clicked,
"on_name_edit_ok_clicked" : self.on_name_edit_ok_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 "on_switch_page" : self.on_switch_page
}) })
@ -123,11 +125,34 @@ class NameEditor:
if parent_window: if parent_window:
self.window.set_transient_for(parent_window) self.window.set_transient_for(parent_window)
#self.val = self.window.run() self.parent.child_windows.append(self)
self.window.show() self.add_itself_to_menu()
#if self.val == gtk.RESPONSE_OK: self.window.show()
# self.on_name_edit_ok_clicked()
#self.window.destroy() 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): def on_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual""" """Display the relevant portion of GRAMPS manual"""

View File

@ -3241,6 +3241,7 @@
<property name="destroy_with_parent">False</property> <property name="destroy_with_parent">False</property>
<property name="icon">gramps.png</property> <property name="icon">gramps.png</property>
<property name="has_separator">True</property> <property name="has_separator">True</property>
<signal name="delete_event" handler="on_name_edit_delete_event" last_modification_time="Thu, 19 Feb 2004 18:07:08 GMT"/>
<child internal-child="vbox"> <child internal-child="vbox">
<widget class="GtkVBox" id="vbox32"> <widget class="GtkVBox" id="vbox32">
@ -3263,7 +3264,7 @@
<property name="use_stock">True</property> <property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-6</property> <property name="response_id">-6</property>
<signal name="clicked" handler="destroy_passed_object" object="name_edit"/> <signal name="clicked" handler="on_name_edit_cancel_clicked" last_modification_time="Thu, 19 Feb 2004 18:07:59 GMT"/>
</widget> </widget>
</child> </child>