2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2004-02-07 02:27:01 +05:30
|
|
|
# Copyright (C) 2000-2004 Donald N. Allingham
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2003-11-13 00:15:07 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk.glade
|
2003-11-19 23:30:58 +05:30
|
|
|
import gnome
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
import Utils
|
|
|
|
import GrampsCfg
|
|
|
|
import ImageSelect
|
2003-02-24 10:21:57 +05:30
|
|
|
import ListModel
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-08-17 07:44:33 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class EditSource:
|
|
|
|
|
2004-02-21 12:10:44 +05:30
|
|
|
def __init__(self,source,db,parent,parent_window=None,func=None):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.source = source
|
|
|
|
self.db = db
|
2004-02-21 12:10:44 +05:30
|
|
|
self.parent = parent
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
if source:
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.parent.child_windows.has_key(source.get_handle()):
|
|
|
|
self.parent.child_windows[source.get_handle()].present(None)
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
return
|
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
self.win_key = source.get_handle()
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
else:
|
|
|
|
self.win_key = self
|
|
|
|
self.child_windows = {}
|
2002-10-20 19:55:16 +05:30
|
|
|
self.callback = func
|
2004-02-14 11:10:30 +05:30
|
|
|
self.path = db.get_save_path()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.not_loaded = 1
|
|
|
|
self.ref_not_loaded = 1
|
2004-02-07 02:27:01 +05:30
|
|
|
self.lists_changed = 0
|
2004-02-21 12:10:44 +05:30
|
|
|
self.gallery_ok = 0
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-08-17 07:44:33 +05:30
|
|
|
self.top_window = gtk.glade.XML(const.gladeFile,"sourceEditor","gramps")
|
2003-03-06 11:42:51 +05:30
|
|
|
self.top = self.top_window.get_widget("sourceEditor")
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2003-03-06 11:42:51 +05:30
|
|
|
Utils.set_titles(self.top,self.top_window.get_widget('title'),
|
|
|
|
_('Source Editor'))
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
plwidget = self.top_window.get_widget("iconlist")
|
2004-05-14 04:15:51 +05:30
|
|
|
self.gallery = ImageSelect.Gallery(source, db.commit_place, self.path,
|
|
|
|
plwidget, db, self, self.top)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.author = self.top_window.get_widget("author")
|
|
|
|
self.pubinfo = self.top_window.get_widget("pubinfo")
|
2003-12-08 07:53:53 +05:30
|
|
|
self.abbrev = self.top_window.get_widget("abbrev")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.note = self.top_window.get_widget("source_note")
|
|
|
|
self.notes_buffer = self.note.get_buffer()
|
2003-11-13 00:15:07 +05:30
|
|
|
self.gallery_label = self.top_window.get_widget("gallerySourceEditor")
|
|
|
|
self.refs_label = self.top_window.get_widget("refsSourceEditor")
|
|
|
|
self.notes_label = self.top_window.get_widget("notesSourceEditor")
|
2003-12-16 01:30:47 +05:30
|
|
|
self.flowed = self.top_window.get_widget("source_flowed")
|
|
|
|
self.preform = self.top_window.get_widget("source_preform")
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.refinfo = self.top_window.get_widget("refinfo")
|
|
|
|
|
2003-03-06 11:42:51 +05:30
|
|
|
self.title = self.top_window.get_widget("source_title")
|
2004-02-14 11:10:30 +05:30
|
|
|
self.title.set_text(source.get_title())
|
|
|
|
self.author.set_text(source.get_author())
|
|
|
|
self.pubinfo.set_text(source.get_publication_info())
|
|
|
|
self.abbrev.set_text(source.get_abbreviation())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if source.get_note():
|
|
|
|
self.notes_buffer.set_text(source.get_note())
|
2003-12-07 10:34:14 +05:30
|
|
|
Utils.bold_label(self.notes_label)
|
2004-02-14 11:10:30 +05:30
|
|
|
if source.get_note_format() == 1:
|
2004-02-21 12:10:44 +05:30
|
|
|
self.preform.set_active(1)
|
2003-12-16 01:30:47 +05:30
|
|
|
else:
|
|
|
|
self.flowed.set_active(1)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-21 11:41:59 +05:30
|
|
|
if self.source.get_media_list():
|
2003-12-12 11:06:38 +05:30
|
|
|
Utils.bold_label(self.gallery_label)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.top_window.signal_autoconnect({
|
|
|
|
"on_switch_page" : self.on_switch_page,
|
2004-02-23 08:15:36 +05:30
|
|
|
"on_addphoto_clicked" : self.gallery.on_add_media_clicked,
|
|
|
|
"on_selectphoto_clicked" : self.gallery.on_select_media_clicked,
|
|
|
|
"on_deletephoto_clicked" : self.gallery.on_delete_media_clicked,
|
|
|
|
"on_editphoto_clicked" : self.gallery.on_edit_media_clicked,
|
2002-10-20 19:55:16 +05:30
|
|
|
"on_edit_properties_clicked": self.gallery.popup_change_description,
|
2003-11-19 23:30:58 +05:30
|
|
|
"on_sourceEditor_help_clicked" : self.on_help_clicked,
|
2004-02-21 12:10:44 +05:30
|
|
|
"on_sourceEditor_ok_clicked" : self.on_source_apply_clicked,
|
|
|
|
"on_sourceEditor_cancel_clicked" : self.close,
|
|
|
|
"on_sourceEditor_delete_event" : self.on_delete_event,
|
2002-10-20 19:55:16 +05:30
|
|
|
})
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.source.get_handle() == "":
|
2003-03-24 09:21:07 +05:30
|
|
|
self.top_window.get_widget("edit_photo").set_sensitive(0)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.top_window.get_widget("delete_photo").set_sensitive(0)
|
|
|
|
|
* src/SourceView.py (button_press,on_add_clicked,on_delete_clicked,
on_edit_clicked): Pass parent window to the child dialog.
* src/Sources.py (add_src_clicked): Likewise.
* src/EditSource.py (__init__): Add optional parent_window argument.
Make dialog modal and transient for its parent.
* src/gramps.glade (sourceEditor dialog): Delete unneeded handlers
for buttons.
* src/QuestionDialog.py (SaveDialog,QuestionDialog,OptionDialog,
ErrorDialog,WarningDialog,MissingMediaDialog): Set transient status
if parent is given.
* src/EventEdit.py (__init__): Make dialog modal and transient for
its parent.
* src/Witness.py: Make WittnessEditor dialog modal and transient for
its parent. Call SelectPerson with itself as a parent.
* src/SelectPerson.py (__init__): Make dialog transient for its parent.
* src/imagesel.glade: Define proper responses and delete unneeded handlers
for buttons. Make gtkFileEntry modal.
* src/dialog.glade (all dialogs): Define proper responses for buttons.
* src/EditPerson.py (on_add_aka_clicked, on_aka_update_clicked):
Call NameEdit with itself as a parent; (on_add_attr_clicked,
on_update_attr_clicked): Call AttributeEditor with itself as a parent;
(on_add_addr_clicked,on_update_addr_clicked): Call AddressEditor with
itself as a parent; (on_add_url_clicked,on_update_url_clicked): Call
UrlEditor with itself as a parent; (on_name_note_clicked,
on_ldsbap_note_clicked,on_ldsendow_note_clicked,
on_ldsseal_note_clicked): Call NoteEditor with itself as a parent.
* src/NameEdit.py (__init__): Make dialog modal and transient for
its parent.
* src/AttrEdit.py (__init__): Likewise.
* src/AddrEdit.py (__init__): Likewise.
* src/UrlEdit.py (__init__): Likewise.
* src/NoteEdit.py (__init__): Likewise.
svn: r2131
2003-09-15 09:41:30 +05:30
|
|
|
if parent_window:
|
|
|
|
self.top.set_transient_for(parent_window)
|
|
|
|
|
2003-11-13 00:15:07 +05:30
|
|
|
self.display_references()
|
2004-02-21 12:10:44 +05:30
|
|
|
if parent_window:
|
|
|
|
self.top.set_transient_for(parent_window)
|
|
|
|
self.add_itself_to_menu()
|
* src/SourceView.py (button_press,on_add_clicked,on_delete_clicked,
on_edit_clicked): Pass parent window to the child dialog.
* src/Sources.py (add_src_clicked): Likewise.
* src/EditSource.py (__init__): Add optional parent_window argument.
Make dialog modal and transient for its parent.
* src/gramps.glade (sourceEditor dialog): Delete unneeded handlers
for buttons.
* src/QuestionDialog.py (SaveDialog,QuestionDialog,OptionDialog,
ErrorDialog,WarningDialog,MissingMediaDialog): Set transient status
if parent is given.
* src/EventEdit.py (__init__): Make dialog modal and transient for
its parent.
* src/Witness.py: Make WittnessEditor dialog modal and transient for
its parent. Call SelectPerson with itself as a parent.
* src/SelectPerson.py (__init__): Make dialog transient for its parent.
* src/imagesel.glade: Define proper responses and delete unneeded handlers
for buttons. Make gtkFileEntry modal.
* src/dialog.glade (all dialogs): Define proper responses for buttons.
* src/EditPerson.py (on_add_aka_clicked, on_aka_update_clicked):
Call NameEdit with itself as a parent; (on_add_attr_clicked,
on_update_attr_clicked): Call AttributeEditor with itself as a parent;
(on_add_addr_clicked,on_update_addr_clicked): Call AddressEditor with
itself as a parent; (on_add_url_clicked,on_update_url_clicked): Call
UrlEditor with itself as a parent; (on_name_note_clicked,
on_ldsbap_note_clicked,on_ldsendow_note_clicked,
on_ldsseal_note_clicked): Call NoteEditor with itself as a parent.
* src/NameEdit.py (__init__): Make dialog modal and transient for
its parent.
* src/AttrEdit.py (__init__): Likewise.
* src/AddrEdit.py (__init__): Likewise.
* src/UrlEdit.py (__init__): Likewise.
* src/NoteEdit.py (__init__): Likewise.
svn: r2131
2003-09-15 09:41:30 +05:30
|
|
|
self.top.show()
|
2004-02-21 12:10:44 +05:30
|
|
|
|
|
|
|
def on_delete_event(self,obj,b):
|
|
|
|
self.close_child_windows()
|
|
|
|
self.remove_itself_from_menu()
|
2003-11-19 23:30:58 +05:30
|
|
|
|
|
|
|
def on_help_clicked(self,obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2003-12-02 09:57:23 +05:30
|
|
|
gnome.help_display('gramps-manual','gramps-edit-complete')
|
* src/SourceView.py (button_press,on_add_clicked,on_delete_clicked,
on_edit_clicked): Pass parent window to the child dialog.
* src/Sources.py (add_src_clicked): Likewise.
* src/EditSource.py (__init__): Add optional parent_window argument.
Make dialog modal and transient for its parent.
* src/gramps.glade (sourceEditor dialog): Delete unneeded handlers
for buttons.
* src/QuestionDialog.py (SaveDialog,QuestionDialog,OptionDialog,
ErrorDialog,WarningDialog,MissingMediaDialog): Set transient status
if parent is given.
* src/EventEdit.py (__init__): Make dialog modal and transient for
its parent.
* src/Witness.py: Make WittnessEditor dialog modal and transient for
its parent. Call SelectPerson with itself as a parent.
* src/SelectPerson.py (__init__): Make dialog transient for its parent.
* src/imagesel.glade: Define proper responses and delete unneeded handlers
for buttons. Make gtkFileEntry modal.
* src/dialog.glade (all dialogs): Define proper responses for buttons.
* src/EditPerson.py (on_add_aka_clicked, on_aka_update_clicked):
Call NameEdit with itself as a parent; (on_add_attr_clicked,
on_update_attr_clicked): Call AttributeEditor with itself as a parent;
(on_add_addr_clicked,on_update_addr_clicked): Call AddressEditor with
itself as a parent; (on_add_url_clicked,on_update_url_clicked): Call
UrlEditor with itself as a parent; (on_name_note_clicked,
on_ldsbap_note_clicked,on_ldsendow_note_clicked,
on_ldsseal_note_clicked): Call NoteEditor with itself as a parent.
* src/NameEdit.py (__init__): Make dialog modal and transient for
its parent.
* src/AttrEdit.py (__init__): Likewise.
* src/AddrEdit.py (__init__): Likewise.
* src/UrlEdit.py (__init__): Likewise.
* src/NoteEdit.py (__init__): Likewise.
svn: r2131
2003-09-15 09:41:30 +05:30
|
|
|
|
2002-11-28 11:22:02 +05:30
|
|
|
def close(self,obj):
|
2004-02-07 02:27:01 +05:30
|
|
|
self.gallery.close(self.gallery_ok)
|
2004-02-21 12:10:44 +05:30
|
|
|
self.close_child_windows()
|
|
|
|
self.remove_itself_from_menu()
|
2002-11-28 11:22:02 +05:30
|
|
|
self.top.destroy()
|
|
|
|
|
2004-02-21 12:10:44 +05:30
|
|
|
def close_child_windows(self):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
for child_window in self.child_windows.values():
|
2004-02-21 12:10:44 +05:30
|
|
|
child_window.close(None)
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
self.child_windows = {}
|
2004-02-21 12:10:44 +05:30
|
|
|
|
|
|
|
def add_itself_to_menu(self):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
self.parent.child_windows[self.win_key] = self
|
2004-02-21 12:10:44 +05:30
|
|
|
if not self.source:
|
|
|
|
label = _("New Source")
|
|
|
|
else:
|
|
|
|
label = self.source.get_title()
|
|
|
|
if not label.strip():
|
|
|
|
label = _("New Source")
|
|
|
|
label = "%s: %s" % (_('Source'),label)
|
|
|
|
self.parent_menu_item = gtk.MenuItem(label)
|
|
|
|
self.parent_menu_item.set_submenu(gtk.Menu())
|
|
|
|
self.parent_menu_item.show()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.parent.winsmenu.append(self.parent_menu_item)
|
|
|
|
self.winsmenu = self.parent_menu_item.get_submenu()
|
2004-02-21 12:10:44 +05:30
|
|
|
self.menu_item = gtk.MenuItem(_('Source Editor'))
|
|
|
|
self.menu_item.connect("activate",self.present)
|
|
|
|
self.menu_item.show()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.winsmenu.append(self.menu_item)
|
2004-02-21 12:10:44 +05:30
|
|
|
|
|
|
|
def remove_itself_from_menu(self):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
del self.parent.child_windows[self.win_key]
|
2004-02-21 12:10:44 +05:30
|
|
|
self.menu_item.destroy()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.winsmenu.destroy()
|
2004-02-21 12:10:44 +05:30
|
|
|
self.parent_menu_item.destroy()
|
|
|
|
|
|
|
|
def present(self,obj):
|
|
|
|
self.top.present()
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def display_references(self):
|
|
|
|
p_event_list = []
|
|
|
|
p_attr_list = []
|
|
|
|
p_addr_list = []
|
|
|
|
p_name_list = []
|
|
|
|
m_list = []
|
|
|
|
f_event_list = []
|
|
|
|
f_attr_list = []
|
|
|
|
p_list = []
|
2004-07-28 07:59:07 +05:30
|
|
|
for key in self.db.get_place_handle_keys():
|
|
|
|
p = self.db.get_place_handle(key)
|
2002-10-20 19:55:16 +05:30
|
|
|
name = p.get_title()
|
2004-02-14 11:10:30 +05:30
|
|
|
for sref in p.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == self.source.get_handle():
|
2002-10-20 19:55:16 +05:30
|
|
|
p_list.append(name)
|
2004-02-14 11:10:30 +05:30
|
|
|
for key in self.db.get_person_keys():
|
|
|
|
p = self.db.get_person(key)
|
2004-07-15 08:24:04 +05:30
|
|
|
name = GrampsCfg.get_nameof()(p)
|
2004-07-28 07:59:07 +05:30
|
|
|
for event_handle in p.get_event_list() + [p.get_birth_handle(), p.get_death_handle()]:
|
|
|
|
if event_handle:
|
|
|
|
event = self.db.find_event_from_handle(event_handle)
|
2004-02-22 10:27:06 +05:30
|
|
|
for sref in event.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == self.source.get_handle():
|
2004-02-22 10:27:06 +05:30
|
|
|
p_event_list.append((name,event.get_name()))
|
2004-02-14 11:10:30 +05:30
|
|
|
for v in p.get_attribute_list():
|
|
|
|
for sref in v.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == self.source.get_handle():
|
2004-02-14 11:10:30 +05:30
|
|
|
p_attr_list.append((name,v.get_type()))
|
|
|
|
for v in p.get_alternate_names() + [p.get_primary_name()]:
|
|
|
|
for sref in v.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == self.source.get_handle():
|
2004-02-14 11:10:30 +05:30
|
|
|
p_name_list.append((name,v.get_name()))
|
|
|
|
for v in p.get_address_list():
|
|
|
|
for sref in v.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == self.source.get_handle():
|
2004-02-14 11:10:30 +05:30
|
|
|
p_addr_list.append((name,v.get_street()))
|
2004-07-28 07:59:07 +05:30
|
|
|
for object_handle in self.db.get_object_keys():
|
|
|
|
object = self.db.try_to_find_object_from_handle(object_handle)
|
2004-02-22 10:27:06 +05:30
|
|
|
name = object.get_description()
|
|
|
|
for sref in object.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == self.source.get_handle():
|
2002-10-20 19:55:16 +05:30
|
|
|
m_list.append(name)
|
2004-07-28 07:59:07 +05:30
|
|
|
for family_handle in self.db.get_family_keys():
|
|
|
|
family = self.db.find_family_from_handle(family_handle)
|
|
|
|
f_id = family.get_father_handle()
|
|
|
|
m_id = family.get_mother_handle()
|
2004-03-01 10:08:39 +05:30
|
|
|
if f_id:
|
2004-07-28 07:59:07 +05:30
|
|
|
f = self.db.try_to_find_person_from_handle(f_id)
|
2004-03-01 10:08:39 +05:30
|
|
|
if m_id:
|
2004-07-28 07:59:07 +05:30
|
|
|
m = self.db.try_to_find_person_from_handle(m_id)
|
2004-03-01 10:08:39 +05:30
|
|
|
if f_id and m_id:
|
2002-10-20 19:55:16 +05:30
|
|
|
name = _("%(father)s and %(mother)s") % {
|
2004-07-15 08:24:04 +05:30
|
|
|
"father" : GrampsCfg.get_nameof()(f),
|
|
|
|
"mother" : GrampsCfg.get_nameof()(m)}
|
2004-03-01 10:08:39 +05:30
|
|
|
elif f_id:
|
2004-07-15 08:24:04 +05:30
|
|
|
name = GrampsCfg.get_nameof()(f)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-07-15 08:24:04 +05:30
|
|
|
name = GrampsCfg.get_nameof()(m)
|
2004-02-21 12:10:44 +05:30
|
|
|
for v_id in p.get_event_list():
|
2004-07-28 07:59:07 +05:30
|
|
|
v = self.db.find_event_from_handle(v_id)
|
2004-02-21 12:10:44 +05:30
|
|
|
if not v:
|
|
|
|
continue
|
2004-02-14 11:10:30 +05:30
|
|
|
for sref in v.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == self.source.get_handle():
|
2004-02-14 11:10:30 +05:30
|
|
|
f_event_list.append((name,v.get_name()))
|
|
|
|
for v in p.get_attribute_list():
|
|
|
|
for sref in v.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == self.source.get_handle():
|
2004-02-14 11:10:30 +05:30
|
|
|
f_attr_list.append((name,v.get_type()))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
slist = self.top_window.get_widget('slist')
|
2003-02-24 10:21:57 +05:30
|
|
|
|
|
|
|
titles = [(_('Source Type'),0,150),(_('Object'),1,150),(_('Value'),2,150)]
|
|
|
|
|
|
|
|
self.model = ListModel.ListModel(slist,titles)
|
2003-11-13 00:15:07 +05:30
|
|
|
any = 0
|
2002-10-20 19:55:16 +05:30
|
|
|
if len(p_event_list) > 0:
|
2003-11-13 00:15:07 +05:30
|
|
|
any = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
for p in p_event_list:
|
2003-02-24 10:21:57 +05:30
|
|
|
self.model.add([_("Individual Events"),p[0],
|
|
|
|
const.display_pevent(p[1])])
|
2002-10-20 19:55:16 +05:30
|
|
|
if len(p_attr_list) > 0:
|
2003-11-13 00:15:07 +05:30
|
|
|
any = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
for p in p_attr_list:
|
2003-02-24 10:21:57 +05:30
|
|
|
self.model.add([_("Individual Attributes"),p[0],
|
|
|
|
const.display_pattr(p[1])])
|
2002-10-20 19:55:16 +05:30
|
|
|
if len(p_name_list) > 0:
|
2003-11-13 00:15:07 +05:30
|
|
|
any = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
for p in p_name_list:
|
2003-02-24 10:21:57 +05:30
|
|
|
self.model.add([_("Individual Names"),p[0],p[1]])
|
2002-10-20 19:55:16 +05:30
|
|
|
if len(f_event_list) > 0:
|
2003-11-13 00:15:07 +05:30
|
|
|
any = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
for p in f_event_list:
|
2003-02-24 10:21:57 +05:30
|
|
|
self.model.add([_("Family Events"),p[0],
|
|
|
|
const.display_fevent(p[1])])
|
2002-10-20 19:55:16 +05:30
|
|
|
if len(f_attr_list) > 0:
|
2003-11-13 00:15:07 +05:30
|
|
|
any = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
for p in f_event_list:
|
2003-02-24 10:21:57 +05:30
|
|
|
self.model.add([_("Family Attributes"),p[0],
|
|
|
|
const.display_fattr(p[1])])
|
2002-10-20 19:55:16 +05:30
|
|
|
if len(m_list) > 0:
|
2003-11-13 00:15:07 +05:30
|
|
|
any = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
for p in m_list:
|
2003-02-24 10:21:57 +05:30
|
|
|
self.model.add([_("Media Objects"),p,''])
|
2002-10-20 19:55:16 +05:30
|
|
|
if len(p_list) > 0:
|
2003-11-13 00:15:07 +05:30
|
|
|
any = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
for p in p_list:
|
2003-02-24 10:21:57 +05:30
|
|
|
self.model.add([_("Places"),p,''])
|
2003-11-13 00:15:07 +05:30
|
|
|
|
|
|
|
if any:
|
|
|
|
Utils.bold_label(self.refs_label)
|
|
|
|
else:
|
|
|
|
Utils.unbold_label(self.refs_label)
|
|
|
|
|
|
|
|
self.ref_not_loaded = 0
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-21 12:10:44 +05:30
|
|
|
def on_source_apply_clicked(self,obj):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-12-17 10:53:16 +05:30
|
|
|
title = unicode(self.title.get_text())
|
|
|
|
author = unicode(self.author.get_text())
|
|
|
|
pubinfo = unicode(self.pubinfo.get_text())
|
|
|
|
abbrev = unicode(self.abbrev.get_text())
|
2003-12-17 21:36:36 +05:30
|
|
|
note = unicode(self.notes_buffer.get_text(self.notes_buffer.get_start_iter(),
|
|
|
|
self.notes_buffer.get_end_iter(),gtk.FALSE))
|
2003-12-16 01:30:47 +05:30
|
|
|
format = self.preform.get_active()
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if author != self.source.get_author():
|
|
|
|
self.source.set_author(author)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if title != self.source.get_title():
|
|
|
|
self.source.set_title(title)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if pubinfo != self.source.get_publication_info():
|
|
|
|
self.source.set_publication_info(pubinfo)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if abbrev != self.source.get_abbreviation():
|
|
|
|
self.source.set_abbreviation(abbrev)
|
2003-12-08 07:53:53 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if note != self.source.get_note():
|
|
|
|
self.source.set_note(note)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if format != self.source.get_note_format():
|
|
|
|
self.source.set_note_format(format)
|
2003-12-16 01:30:47 +05:30
|
|
|
|
2004-02-21 12:10:44 +05:30
|
|
|
self.gallery_ok = 1
|
2002-11-28 11:22:02 +05:30
|
|
|
|
2004-03-30 10:20:24 +05:30
|
|
|
trans = self.db.start_transaction()
|
|
|
|
self.db.commit_source(self.source,trans)
|
2004-05-19 11:43:36 +05:30
|
|
|
self.db.add_transaction(trans,_("Edit Source (%s)") % title)
|
2004-03-30 10:20:24 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.callback:
|
|
|
|
self.callback(self.source)
|
2004-02-21 12:10:44 +05:30
|
|
|
self.close(obj)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def on_switch_page(self,obj,a,page):
|
|
|
|
if page == 2 and self.not_loaded:
|
|
|
|
self.not_loaded = 0
|
|
|
|
self.gallery.load_images()
|
|
|
|
elif page == 3 and self.ref_not_loaded:
|
|
|
|
self.ref_not_loaded = 0
|
|
|
|
self.display_references()
|
2003-12-17 21:36:36 +05:30
|
|
|
text = unicode(self.notes_buffer.get_text(self.notes_buffer.get_start_iter(),
|
|
|
|
self.notes_buffer.get_end_iter(),gtk.FALSE))
|
2003-11-13 00:15:07 +05:30
|
|
|
if text:
|
|
|
|
Utils.bold_label(self.notes_label)
|
|
|
|
else:
|
|
|
|
Utils.unbold_label(self.notes_label)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
|
|
|
|
class DelSrcQuery:
|
|
|
|
def __init__(self,source,db,update):
|
|
|
|
self.source = source
|
|
|
|
self.db = db
|
|
|
|
self.update = update
|
|
|
|
|
|
|
|
def delete_source(self,object):
|
|
|
|
m = 0
|
|
|
|
l = []
|
2004-02-14 11:10:30 +05:30
|
|
|
for sref in object.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() != self.source.get_handle():
|
2002-10-20 19:55:16 +05:30
|
|
|
l.append(sref)
|
|
|
|
else:
|
|
|
|
m = 1
|
|
|
|
if m:
|
2004-02-14 11:10:30 +05:30
|
|
|
object.set_source_reference_list(l)
|
2004-03-30 10:20:24 +05:30
|
|
|
return m
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def query_response(self):
|
2004-03-30 10:20:24 +05:30
|
|
|
trans = self.db.start_transaction()
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for key in self.db.get_person_keys():
|
2004-03-30 10:20:24 +05:30
|
|
|
commit = 0
|
2004-02-14 11:10:30 +05:30
|
|
|
p = self.db.get_person(key)
|
2004-07-28 07:59:07 +05:30
|
|
|
for v_id in p.get_event_list() + [p.get_birth_handle(), p.get_death_handle()]:
|
|
|
|
v = self.db.find_event_from_handle(v_id)
|
2004-02-23 11:12:19 +05:30
|
|
|
if v:
|
2004-03-30 10:20:24 +05:30
|
|
|
commit += self.delete_source(v)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for v in p.get_attribute_list():
|
2004-03-30 10:20:24 +05:30
|
|
|
commit += self.delete_source(v)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for v in p.get_alternate_names() + [p.get_primary_name()]:
|
2004-03-30 10:20:24 +05:30
|
|
|
commit += self.delete_source(v)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for v in p.get_address_list():
|
2004-03-30 10:20:24 +05:30
|
|
|
commit += self.delete_source(v)
|
|
|
|
if commit > 0:
|
|
|
|
self.db.commit_person(p,trans)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-23 11:12:19 +05:30
|
|
|
for p_id in self.db.get_family_keys():
|
2004-03-30 10:20:24 +05:30
|
|
|
commit = 0
|
2004-07-28 07:59:07 +05:30
|
|
|
p = self.db.find_family_from_handle(p_id)
|
2004-02-23 11:12:19 +05:30
|
|
|
for v_id in p.get_event_list():
|
2004-07-28 07:59:07 +05:30
|
|
|
v = self.db.find_event_from_handle(v_id)
|
2004-02-23 11:12:19 +05:30
|
|
|
if v:
|
2004-03-30 10:20:24 +05:30
|
|
|
commit += self.delete_source(v)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for v in p.get_attribute_list():
|
2004-03-30 10:20:24 +05:30
|
|
|
commit += self.delete_source(v)
|
|
|
|
if commit > 0:
|
|
|
|
self.db.commit_family(p,trans)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-23 11:12:19 +05:30
|
|
|
for p_id in self.db.get_object_keys():
|
2004-07-28 07:59:07 +05:30
|
|
|
p = self.db.try_to_find_object_from_handle(p_id,trans)
|
2004-03-30 10:20:24 +05:30
|
|
|
if self.delete_source(p):
|
|
|
|
self.db.commit_media_object(p,trans)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for key in self.db.get_place_handle_keys():
|
|
|
|
p = self.db.try_to_find_place_from_handle(key)
|
|
|
|
if self.delete_source(self.db.try_to_find_place_from_handle(key)):
|
2004-03-30 10:20:24 +05:30
|
|
|
self.db.commit_place(p,trans)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
self.db.remove_source_handle(self.source.get_handle(),trans)
|
2004-05-19 11:43:36 +05:30
|
|
|
self.db.add_transaction(trans,_("Delete Source (%s)") % self.source.get_title())
|
2004-03-30 10:20:24 +05:30
|
|
|
self.update()
|