2002-11-26 18:43:31 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-02-04 03:33:53 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2002-11-26 18:43:31 +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-19 23:30:58 +05:30
|
|
|
# $Id$
|
|
|
|
|
2004-09-21 04:56:41 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from gettext import gettext as _
|
2005-12-06 12:08:09 +05:30
|
|
|
import gc
|
2004-09-21 04:56:41 +05:30
|
|
|
|
2002-11-26 18:43:31 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
2005-03-10 04:29:24 +05:30
|
|
|
from gtk.gdk import ACTION_COPY, BUTTON1_MASK, INTERP_BILINEAR, pixbuf_new_from_file
|
2005-04-01 19:09:34 +05:30
|
|
|
import cPickle as pickle
|
2002-11-26 18:43:31 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
import Utils
|
2003-01-10 10:51:32 +05:30
|
|
|
import RelLib
|
2004-09-21 04:56:41 +05:30
|
|
|
import DateEdit
|
2004-09-20 23:26:26 +05:30
|
|
|
import DateHandler
|
2005-12-06 12:08:09 +05:30
|
|
|
import GrampsDisplay
|
2005-08-18 11:28:28 +05:30
|
|
|
import Spell
|
2005-12-23 05:13:32 +05:30
|
|
|
import DisplayState
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2005-03-26 02:35:09 +05:30
|
|
|
from DdTargets import DdTargets
|
2005-12-06 12:08:09 +05:30
|
|
|
from WindowUtils import GladeIf
|
2005-03-26 02:35:09 +05:30
|
|
|
|
2002-11-26 18:43:31 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SourceEditor
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-12-23 05:13:32 +05:30
|
|
|
class SourceEditor(DisplayState.ManagedWindow):
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2005-12-23 05:13:32 +05:30
|
|
|
def __init__(self, state, uistate, track, srcref, update):
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2005-12-23 05:13:32 +05:30
|
|
|
self.db = state.db
|
|
|
|
self.state = state
|
|
|
|
self.track = track
|
|
|
|
self.uistate = uistate
|
* 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 srcref:
|
2005-12-23 05:13:32 +05:30
|
|
|
submenu_label = _('Source Reference')
|
* 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:
|
2005-12-23 05:13:32 +05:30
|
|
|
submenu_label = _('New Source Reference')
|
|
|
|
|
2005-12-24 05:39:04 +05:30
|
|
|
DisplayState.ManagedWindow.__init__(self, uistate, self.track, srcref)
|
2005-12-23 05:13:32 +05:30
|
|
|
|
* 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.update = update
|
|
|
|
self.source_ref = srcref
|
2006-01-17 10:33:30 +05:30
|
|
|
self.showSource = gtk.glade.XML(const.gladeFile,
|
2005-02-27 11:21:59 +05:30
|
|
|
"sourceDisplay","gramps")
|
2005-12-23 05:13:32 +05:30
|
|
|
self.window = self.get_widget("sourceDisplay")
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2005-12-23 05:13:32 +05:30
|
|
|
Utils.set_titles(self.window,
|
2005-02-27 11:21:59 +05:30
|
|
|
self.showSource.get_widget('title'),
|
2003-03-06 11:42:51 +05:30
|
|
|
_('Source Information'))
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
self.gladeif = GladeIf(self.showSource)
|
|
|
|
self.gladeif.connect('sourceDisplay','delete_event', self.on_delete_event)
|
|
|
|
self.gladeif.connect('button95','clicked',self.close)
|
|
|
|
self.gladeif.connect('ok','clicked',self.on_sourceok_clicked)
|
|
|
|
self.gladeif.connect('button144','clicked', self.on_help_clicked)
|
|
|
|
self.gladeif.connect('button143','clicked',self.add_src_clicked)
|
|
|
|
addbtn = self.get_widget('button143')
|
|
|
|
addbtn.set_sensitive(not self.db.readonly)
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2002-11-26 18:43:31 +05:30
|
|
|
self.source_field = self.get_widget("sourceList")
|
2005-01-02 10:46:25 +05:30
|
|
|
|
|
|
|
# setup menu
|
2002-11-26 18:43:31 +05:30
|
|
|
self.title_menu = self.get_widget("source_title")
|
2005-01-02 10:46:25 +05:30
|
|
|
cell = gtk.CellRendererText()
|
|
|
|
self.title_menu.pack_start(cell,True)
|
|
|
|
self.title_menu.add_attribute(cell,'text',0)
|
|
|
|
self.title_menu.connect('changed',self.on_source_changed)
|
2002-11-26 18:43:31 +05:30
|
|
|
self.conf_menu = self.get_widget("conf")
|
2005-12-06 12:08:09 +05:30
|
|
|
self.conf_menu.set_sensitive(not self.db.readonly)
|
2004-11-28 01:18:25 +05:30
|
|
|
self.private = self.get_widget("priv")
|
2005-12-06 12:08:09 +05:30
|
|
|
self.private.set_sensitive(not self.db.readonly)
|
2003-03-24 09:21:07 +05:30
|
|
|
self.ok = self.get_widget("ok")
|
2005-01-02 10:46:25 +05:30
|
|
|
self.conf_menu.set_active(srcref.get_confidence_level())
|
2002-11-26 18:43:31 +05:30
|
|
|
|
|
|
|
self.author_field = self.get_widget("sauthor")
|
|
|
|
self.pub_field = self.get_widget("spubinfo")
|
|
|
|
|
2004-09-21 04:56:41 +05:30
|
|
|
self.date_entry_field = self.get_widget("sdate")
|
2005-12-06 12:08:09 +05:30
|
|
|
self.date_entry_field.set_editable(not self.db.readonly)
|
2004-09-21 04:56:41 +05:30
|
|
|
|
2002-11-26 18:43:31 +05:30
|
|
|
if self.source_ref:
|
2005-01-02 10:46:25 +05:30
|
|
|
handle = self.source_ref.get_base_handle()
|
|
|
|
self.active_source = self.db.get_source_from_handle(handle)
|
2005-03-23 05:29:51 +05:30
|
|
|
self.date_obj = self.source_ref.get_date_object()
|
2005-04-02 11:03:06 +05:30
|
|
|
date_str = DateHandler.displayer.display(self.date_obj)
|
|
|
|
self.date_entry_field.set_text(date_str)
|
2004-11-28 01:18:25 +05:30
|
|
|
self.private.set_active(self.source_ref.get_privacy())
|
2002-11-26 18:43:31 +05:30
|
|
|
else:
|
2006-02-04 03:33:53 +05:30
|
|
|
self.date_obj = RelLib.Date()
|
2002-11-26 18:43:31 +05:30
|
|
|
self.active_source = None
|
2003-03-24 09:21:07 +05:30
|
|
|
|
2004-09-21 04:56:41 +05:30
|
|
|
date_stat = self.get_widget("date_stat")
|
2005-12-06 12:08:09 +05:30
|
|
|
date_stat.set_sensitive(not self.db.readonly)
|
2005-04-02 11:03:06 +05:30
|
|
|
self.date_check = DateEdit.DateEdit(
|
|
|
|
self.date_obj, self.date_entry_field,
|
2005-12-23 05:13:32 +05:30
|
|
|
date_stat, self.window)
|
2004-09-20 23:26:26 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
self.spage = self.get_widget("spage")
|
2005-12-06 12:08:09 +05:30
|
|
|
self.spage.set_editable(not self.db.readonly)
|
2005-08-18 11:28:28 +05:30
|
|
|
self.scom = self.get_widget("scomment")
|
2005-12-06 12:08:09 +05:30
|
|
|
self.scom.set_editable(not self.db.readonly)
|
2005-08-18 11:28:28 +05:30
|
|
|
self.spell1 = Spell.Spell(self.scom)
|
|
|
|
self.stext = self.get_widget("stext")
|
2005-12-06 12:08:09 +05:30
|
|
|
self.stext.set_editable(not self.db.readonly)
|
2005-08-18 11:28:28 +05:30
|
|
|
self.spell2 = Spell.Spell(self.stext)
|
|
|
|
|
2005-02-26 07:26:34 +05:30
|
|
|
self.draw(self.active_source,fresh=True)
|
2003-03-24 09:21:07 +05:30
|
|
|
self.set_button()
|
2005-04-02 11:03:06 +05:30
|
|
|
self.db.connect('source-add', self.rebuild_menu)
|
2005-12-26 10:22:21 +05:30
|
|
|
self.show()
|
2004-02-20 05:09:01 +05:30
|
|
|
|
2005-12-24 05:39:04 +05:30
|
|
|
def build_menu_names(self,srcref):
|
|
|
|
if srcref:
|
|
|
|
submenu_label = _('Source Reference')
|
|
|
|
else:
|
|
|
|
submenu_label = _('New Source Reference')
|
|
|
|
return (_('Source Reference Editor'),submenu_label)
|
|
|
|
|
2005-04-02 11:03:06 +05:30
|
|
|
def rebuild_menu(self,handle_list):
|
2005-04-03 02:44:53 +05:30
|
|
|
self.build_source_menu(handle_list[0])
|
2005-04-02 11:03:06 +05:30
|
|
|
|
2004-02-20 05:09:01 +05:30
|
|
|
def on_delete_event(self,obj,b):
|
2005-12-06 12:08:09 +05:30
|
|
|
self.gladeif.close()
|
|
|
|
gc.collect()
|
2004-02-20 05:09:01 +05:30
|
|
|
|
|
|
|
def close(self,obj):
|
2005-12-06 12:08:09 +05:30
|
|
|
self.gladeif.close()
|
2005-12-23 05:13:32 +05:30
|
|
|
self.window.destroy()
|
2005-12-06 12:08:09 +05:30
|
|
|
gc.collect()
|
2004-02-20 05:09:01 +05:30
|
|
|
|
2003-11-19 23:30:58 +05:30
|
|
|
def on_help_clicked(self,obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2005-12-06 12:08:09 +05:30
|
|
|
GrampsDisplay.help('adv-si')
|
2003-11-19 23:30:58 +05:30
|
|
|
|
2003-03-24 09:21:07 +05:30
|
|
|
def set_button(self):
|
|
|
|
if self.active_source:
|
2005-12-06 12:08:09 +05:30
|
|
|
self.ok.set_sensitive(not self.db.readonly)
|
2003-03-24 09:21:07 +05:30
|
|
|
else:
|
2005-08-18 11:28:28 +05:30
|
|
|
self.ok.set_sensitive(False)
|
2003-03-24 09:21:07 +05:30
|
|
|
|
2002-11-26 18:43:31 +05:30
|
|
|
def get_widget(self,name):
|
|
|
|
"""returns the widget associated with the specified name"""
|
|
|
|
return self.showSource.get_widget(name)
|
|
|
|
|
2005-02-26 07:26:34 +05:30
|
|
|
def draw(self,sel=None,fresh=False):
|
|
|
|
if self.source_ref and fresh:
|
2005-08-18 11:28:28 +05:30
|
|
|
self.spage.get_buffer().set_text(self.source_ref.get_page())
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
self.stext.get_buffer().set_text(self.source_ref.get_text())
|
|
|
|
self.scom.get_buffer().set_text(self.source_ref.get_note())
|
2005-04-02 11:03:06 +05:30
|
|
|
idval = self.source_ref.get_base_handle()
|
|
|
|
src = self.db.get_source_from_handle(idval)
|
2002-11-26 18:43:31 +05:30
|
|
|
self.active_source = src
|
|
|
|
if src:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.author_field.set_text(src.get_author())
|
|
|
|
self.pub_field.set_text(src.get_publication_info())
|
2002-11-26 18:43:31 +05:30
|
|
|
else:
|
|
|
|
self.author_field.set_text("")
|
|
|
|
self.pub_field.set_text("")
|
2005-04-02 11:03:06 +05:30
|
|
|
self.active_source = sel
|
2005-04-03 02:44:53 +05:30
|
|
|
if sel:
|
|
|
|
self.build_source_menu(sel.get_handle())
|
|
|
|
else:
|
|
|
|
self.build_source_menu(None)
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2005-04-03 02:44:53 +05:30
|
|
|
def build_source_menu(self,selected_handle):
|
2004-08-13 10:04:07 +05:30
|
|
|
keys = self.db.get_source_handles()
|
2004-08-21 23:43:18 +05:30
|
|
|
keys.sort(self.db._sortbysource)
|
2005-01-02 10:46:25 +05:30
|
|
|
|
2005-02-27 11:21:59 +05:30
|
|
|
store = gtk.ListStore(str)
|
2005-01-02 10:46:25 +05:30
|
|
|
|
2002-11-26 18:43:31 +05:30
|
|
|
sel_child = None
|
2005-01-02 10:46:25 +05:30
|
|
|
index = 0
|
|
|
|
sel_index = 0
|
|
|
|
self.handle_list = []
|
2004-02-23 11:12:19 +05:30
|
|
|
for src_id in keys:
|
2004-08-07 10:46:57 +05:30
|
|
|
src = self.db.get_source_from_handle(src_id)
|
2005-01-02 10:46:25 +05:30
|
|
|
title = src.get_title()
|
|
|
|
gid = src.get_gramps_id()
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
if len(title) > 40:
|
|
|
|
title = title[0:37] + "..."
|
|
|
|
|
2005-01-02 10:46:25 +05:30
|
|
|
store.append(row=["%s [%s]" % (title,gid)])
|
2005-04-03 02:44:53 +05:30
|
|
|
self.handle_list.append(src_id)
|
|
|
|
if selected_handle == src_id:
|
2005-01-02 10:46:25 +05:30
|
|
|
sel_index = index
|
|
|
|
index += 1
|
|
|
|
self.title_menu.set_model(store)
|
|
|
|
|
|
|
|
if index > 0:
|
2005-12-06 12:08:09 +05:30
|
|
|
self.title_menu.set_sensitive(not self.db.readonly)
|
2005-01-02 10:46:25 +05:30
|
|
|
self.title_menu.set_active(sel_index)
|
2003-04-20 09:22:54 +05:30
|
|
|
else:
|
|
|
|
self.title_menu.set_sensitive(0)
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2004-02-20 05:09:01 +05:30
|
|
|
def on_sourceok_clicked(self,obj):
|
2003-03-24 09:21:07 +05:30
|
|
|
|
2005-02-27 11:21:59 +05:30
|
|
|
shandle = self.source_ref.get_base_handle()
|
|
|
|
if self.active_source != self.db.get_source_from_handle(shandle):
|
2004-07-28 07:59:07 +05:30
|
|
|
self.source_ref.set_base_handle(self.active_source.get_handle())
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2005-01-02 10:46:25 +05:30
|
|
|
conf = self.get_widget("conf").get_active()
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
buf = self.scom.get_buffer()
|
2004-08-23 04:46:57 +05:30
|
|
|
comments = unicode(buf.get_text(buf.get_start_iter(),
|
2005-02-24 05:55:34 +05:30
|
|
|
buf.get_end_iter(),False))
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
buf = self.stext.get_buffer()
|
2004-08-23 04:46:57 +05:30
|
|
|
text = unicode(buf.get_text(buf.get_start_iter(),
|
2005-02-24 05:55:34 +05:30
|
|
|
buf.get_end_iter(),False))
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
buf = self.spage.get_buffer()
|
2004-08-23 04:46:57 +05:30
|
|
|
page = unicode(buf.get_text(buf.get_start_iter(),
|
2005-02-24 05:55:34 +05:30
|
|
|
buf.get_end_iter(),False))
|
2003-07-21 05:39:12 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source_ref.set_page(page)
|
2005-03-23 05:29:51 +05:30
|
|
|
self.source_ref.set_date_object(self.date_obj)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source_ref.set_text(text)
|
2005-03-28 10:28:28 +05:30
|
|
|
self.source_ref.set_note(comments)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source_ref.set_confidence_level(conf)
|
2004-11-28 01:18:25 +05:30
|
|
|
self.source_ref.set_privacy(self.private.get_active())
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2006-02-02 10:50:42 +05:30
|
|
|
self.update(self.source_ref)
|
2004-02-20 08:08:31 +05:30
|
|
|
self.close(obj)
|
2002-11-26 18:43:31 +05:30
|
|
|
|
|
|
|
def on_source_changed(self,obj):
|
2005-01-02 10:46:25 +05:30
|
|
|
handle = self.handle_list[obj.get_active()]
|
|
|
|
self.active_source = self.db.get_source_from_handle(handle)
|
|
|
|
self.author_field.set_text(self.active_source.get_author())
|
|
|
|
self.pub_field.set_text(self.active_source.get_publication_info())
|
|
|
|
self.set_button()
|
2003-03-24 09:21:07 +05:30
|
|
|
|
|
|
|
def update_display(self,source):
|
2005-02-26 07:26:34 +05:30
|
|
|
self.draw(source,fresh=False)
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2003-03-24 09:21:07 +05:30
|
|
|
def add_src_clicked(self,obj):
|
|
|
|
import EditSource
|
2005-12-23 05:13:32 +05:30
|
|
|
EditSource.EditSource(self.state, self.uistate, self.track, RelLib.Source())
|