From ed8497953e20c259dc63cc25b501486cf3d732ee Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Fri, 20 Feb 2004 03:57:54 +0000 Subject: [PATCH] Update svn: r2882 --- src/EditPerson.py | 8 ++++---- src/NoteEdit.py | 45 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/EditPerson.py b/src/EditPerson.py index f01ad0118..e8a3ad6a0 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -1626,7 +1626,7 @@ class EditPerson: def on_name_note_clicked(self,obj): import NoteEdit - NoteEdit.NoteEditor(self.pname,self.window) + NoteEdit.NoteEditor(self.pname,self,self.window) def on_ldsbap_source_clicked(self,obj): Sources.SourceSelector(self.lds_baptism.get_source_references(), @@ -1638,7 +1638,7 @@ class EditPerson: def on_ldsbap_note_clicked(self,obj): import NoteEdit - NoteEdit.NoteEditor(self.lds_baptism,self.window) + NoteEdit.NoteEditor(self.lds_baptism,self,self.window) def on_ldsendow_source_clicked(self,obj): Sources.SourceSelector(self.lds_endowment.get_source_references(), @@ -1650,7 +1650,7 @@ class EditPerson: def on_ldsendow_note_clicked(self,obj): import NoteEdit - NoteEdit.NoteEditor(self.lds_endowment,self.window) + NoteEdit.NoteEditor(self.lds_endowment,self,self.window) def on_ldsseal_source_clicked(self,obj): Sources.SourceSelector(self.lds_sealing.get_source_references(), @@ -1662,7 +1662,7 @@ class EditPerson: def on_ldsseal_note_clicked(self,obj): import NoteEdit - NoteEdit.NoteEditor(self.lds_sealing,self.window) + NoteEdit.NoteEditor(self.lds_sealing,self,self.window) def load_person_image(self): photo_list = self.person.get_photo_list() diff --git a/src/NoteEdit.py b/src/NoteEdit.py index e7cd3fb46..168c04b1f 100644 --- a/src/NoteEdit.py +++ b/src/NoteEdit.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 @@ -42,10 +42,12 @@ from gettext import gettext as _ #------------------------------------------------------------------------- class NoteEditor: """Displays a simple text editor that allows a person to edit a note""" - def __init__(self,data,parent_window=None): + def __init__(self,data,parent,parent_window=None): self.data = data self.parent_window = parent_window + self.child_windows = [] + self.parent = parent self.draw() def draw(self): @@ -57,8 +59,8 @@ class NoteEditor: vbox = gtk.VBox() self.top.vbox.pack_start(vbox,gtk.TRUE,gtk.TRUE,0) - label = gtk.Label('%s' % _('Edit Note')) - label.set_use_markup(gtk.TRUE) + label = gtk.Label('%s' % _('Edit Note')) + label.set_use_markup(gtk.TRUE) vbox.pack_start(label, gtk.FALSE, gtk.FALSE, 10) self.entry = gtk.TextView() @@ -74,17 +76,39 @@ class NoteEditor: self.entry.get_buffer().set_text(self.data.get_note()) - self.top.add_button(gtk.STOCK_CANCEL,1) - self.top.add_button(gtk.STOCK_OK,0) + cancel_button = self.top.add_button(gtk.STOCK_CANCEL,1) + ok_button = self.top.add_button(gtk.STOCK_OK,0) + cancel_button.connect("clicked",self.close) + ok_button.connect("clicked",self.on_save_note_clicked) + self.top.connect("delete_event",self.on_delete_event) self.top.show_all() if self.parent_window: self.top.set_transient_for(self.parent_window) - if self.top.run() == 0: - self.on_save_note_clicked() - self.top.destroy() + self.parent.child_windows.append(self) + self.add_itself_to_menu() + self.top.show() - def on_save_note_clicked(self): + def on_delete_event(self,obj,b): + self.remove_itself_from_menu() + + def close(self,obj): + self.remove_itself_from_menu() + self.top.destroy() + + def add_itself_to_menu(self): + self.parent_menu_item = gtk.MenuItem(_('Note')) + self.parent_menu_item.connect("activate",self.present) + self.parent_menu_item.show() + self.parent.menu.append(self.parent_menu_item) + + def remove_itself_from_menu(self): + self.parent_menu_item.destroy() + + def present(self,obj): + self.top.present() + + def on_save_note_clicked(self,obj): """Saves the note and closes the window""" buffer = self.entry.get_buffer() text = unicode(buffer.get_text(buffer.get_start_iter(), @@ -92,3 +116,4 @@ class NoteEditor: if text != self.data.get_note(): self.data.set_note(text) Utils.modified() + self.close(obj)