2006-02-16 10:36:40 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2000-2006 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
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2006-02-16 10:36:40 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
import RelLib
|
|
|
|
|
2006-05-06 10:50:19 +05:30
|
|
|
from DisplayTabs import \
|
2006-06-15 22:47:42 +05:30
|
|
|
NoteTab,TextTab,GalleryTab,SourceBackRefList,DataEmbedList,RepoEmbedList
|
2006-02-16 10:36:40 +05:30
|
|
|
from GrampsWidgets import *
|
2006-03-05 04:23:46 +05:30
|
|
|
from _EditReference import EditReference
|
2006-02-16 10:36:40 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# EditSourceRef class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-03-05 04:23:46 +05:30
|
|
|
class EditSourceRef(EditReference):
|
|
|
|
def __init__(self, state, uistate, track, source, source_ref, update):
|
2006-02-16 10:36:40 +05:30
|
|
|
|
2006-03-05 04:23:46 +05:30
|
|
|
EditReference.__init__(self, state, uistate, track, source,
|
|
|
|
source_ref, update)
|
2006-02-16 10:36:40 +05:30
|
|
|
|
2006-03-05 04:23:46 +05:30
|
|
|
def _local_init(self):
|
|
|
|
|
2006-02-16 10:36:40 +05:30
|
|
|
self.top = gtk.glade.XML(const.gladeFile, "source_ref_edit","gramps")
|
|
|
|
|
2006-04-24 03:48:01 +05:30
|
|
|
self.set_window(self.top.get_widget('source_ref_edit'),
|
|
|
|
self.top.get_widget('source_title'),
|
|
|
|
_('Source Reference Editor'))
|
2006-02-16 10:36:40 +05:30
|
|
|
|
2006-03-05 04:23:46 +05:30
|
|
|
self.define_warn_box(self.top.get_widget("warn_box"))
|
|
|
|
self.define_expander(self.top.get_widget("src_expander"))
|
2006-02-16 10:36:40 +05:30
|
|
|
|
2006-02-20 10:29:20 +05:30
|
|
|
def _connect_signals(self):
|
2006-03-05 04:23:46 +05:30
|
|
|
self.define_ok_button(self.top.get_widget('ok'),self.ok_clicked)
|
|
|
|
self.define_cancel_button(self.top.get_widget('cancel'))
|
2007-03-19 09:49:49 +05:30
|
|
|
self.define_help_button(self.top.get_widget("help"), 'adv-si')
|
2006-10-03 22:29:51 +05:30
|
|
|
|
2006-02-20 10:29:20 +05:30
|
|
|
def _setup_fields(self):
|
2006-08-30 05:15:07 +05:30
|
|
|
self.ref_privacy = PrivacyButton(
|
2006-12-14 21:02:33 +05:30
|
|
|
self.top.get_widget('privacy'), self.source_ref, self.db.readonly)
|
2006-02-20 10:29:20 +05:30
|
|
|
|
|
|
|
self.volume = MonitoredEntry(
|
|
|
|
self.top.get_widget("volume"), self.source_ref.set_page,
|
2006-12-15 18:09:28 +05:30
|
|
|
self.source_ref.get_page, self.db.readonly)
|
2006-02-20 10:29:20 +05:30
|
|
|
|
|
|
|
self.gid = MonitoredEntry(
|
|
|
|
self.top.get_widget('gid'), self.source.set_gramps_id,
|
2006-12-15 18:09:28 +05:30
|
|
|
self.source.get_gramps_id,self.db.readonly)
|
2006-02-20 10:29:20 +05:30
|
|
|
|
2006-08-30 05:15:07 +05:30
|
|
|
self.source_privacy = PrivacyButton(
|
|
|
|
self.top.get_widget("private"),
|
|
|
|
self.source, self.db.readonly)
|
|
|
|
|
2006-02-20 10:29:20 +05:30
|
|
|
self.title = MonitoredEntry(
|
2007-01-07 04:05:29 +05:30
|
|
|
self.top.get_widget('title'),
|
|
|
|
self.source.set_title,
|
|
|
|
self.source.get_title,
|
|
|
|
self.db.readonly)
|
2006-02-20 10:29:20 +05:30
|
|
|
|
|
|
|
self.abbrev = MonitoredEntry(
|
|
|
|
self.top.get_widget('abbrev'), self.source.set_abbreviation,
|
2006-12-15 18:09:28 +05:30
|
|
|
self.source.get_abbreviation,self.db.readonly)
|
2006-02-20 10:29:20 +05:30
|
|
|
|
|
|
|
self.author = MonitoredEntry(
|
|
|
|
self.top.get_widget('author'), self.source.set_author,
|
2006-12-15 18:09:28 +05:30
|
|
|
self.source.get_author,self.db.readonly)
|
2006-02-20 10:29:20 +05:30
|
|
|
|
|
|
|
self.pubinfo = MonitoredEntry(
|
|
|
|
self.top.get_widget('pub_info'), self.source.set_publication_info,
|
2006-12-15 18:09:28 +05:30
|
|
|
self.source.get_publication_info,self.db.readonly)
|
2006-02-20 10:29:20 +05:30
|
|
|
|
2006-02-21 10:43:15 +05:30
|
|
|
self.type_mon = MonitoredMenu(
|
2006-05-06 08:44:13 +05:30
|
|
|
self.top.get_widget('confidence'),
|
|
|
|
self.source_ref.set_confidence_level,
|
2006-02-21 10:43:15 +05:30
|
|
|
self.source_ref.get_confidence_level, [
|
|
|
|
(_('Very Low'), RelLib.SourceRef.CONF_VERY_LOW),
|
|
|
|
(_('Low'), RelLib.SourceRef.CONF_LOW),
|
|
|
|
(_('Normal'), RelLib.SourceRef.CONF_NORMAL),
|
|
|
|
(_('High'), RelLib.SourceRef.CONF_HIGH),
|
2006-12-15 18:09:28 +05:30
|
|
|
(_('Very High'), RelLib.SourceRef.CONF_VERY_HIGH)],
|
|
|
|
self.db.readonly)
|
2006-02-21 10:43:15 +05:30
|
|
|
|
2006-03-05 04:23:46 +05:30
|
|
|
self.date = MonitoredDate(
|
2007-03-24 06:00:14 +05:30
|
|
|
self.top.get_widget("date_entry"),
|
2006-03-05 04:23:46 +05:30
|
|
|
self.top.get_widget("date_stat"),
|
2006-05-06 08:44:13 +05:30
|
|
|
self.source_ref.get_date_object(),
|
|
|
|
self.uistate,
|
|
|
|
self.track,
|
|
|
|
self.db.readonly)
|
2006-02-16 10:36:40 +05:30
|
|
|
|
|
|
|
def _create_tabbed_pages(self):
|
|
|
|
"""
|
|
|
|
Creates the notebook tabs and inserts them into the main
|
|
|
|
window.
|
|
|
|
|
|
|
|
"""
|
2006-03-05 04:23:46 +05:30
|
|
|
|
|
|
|
notebook_src = self.top.get_widget('notebook_src')
|
|
|
|
notebook_ref = self.top.get_widget('notebook_ref')
|
|
|
|
|
|
|
|
self.note_tab = self._add_tab(
|
|
|
|
notebook_src,
|
|
|
|
NoteTab(self.dbstate, self.uistate, self.track,
|
2007-02-20 07:06:26 +05:30
|
|
|
self.source.get_note_list()))
|
2006-03-05 04:23:46 +05:30
|
|
|
|
|
|
|
self.gallery_tab = self._add_tab(
|
|
|
|
notebook_src,
|
|
|
|
GalleryTab(self.dbstate, self.uistate, self.track,
|
|
|
|
self.source.get_media_list()))
|
|
|
|
|
2006-05-06 10:50:19 +05:30
|
|
|
self.data_tab = self._add_tab(
|
|
|
|
notebook_src,
|
|
|
|
DataEmbedList(self.dbstate, self.uistate, self.track,
|
|
|
|
self.source))
|
|
|
|
|
|
|
|
self.repo_tab = self._add_tab(
|
|
|
|
notebook_src,
|
|
|
|
RepoEmbedList(self.dbstate, self.uistate, self.track,
|
|
|
|
self.source.get_reporef_list()))
|
|
|
|
|
2006-03-05 04:23:46 +05:30
|
|
|
self.srcref_list = self._add_tab(
|
|
|
|
notebook_src,
|
|
|
|
SourceBackRefList(self.dbstate,self.uistate, self.track,
|
2006-04-21 04:02:17 +05:30
|
|
|
self.db.find_backlink_handles(self.source.handle),
|
|
|
|
self.enable_warnbox
|
|
|
|
))
|
2006-03-05 04:23:46 +05:30
|
|
|
|
2006-06-15 22:47:42 +05:30
|
|
|
self.text_tab = self._add_tab(
|
|
|
|
notebook_ref,
|
|
|
|
TextTab(self.dbstate, self.uistate, self.track,self.source_ref))
|
|
|
|
|
2006-03-05 04:23:46 +05:30
|
|
|
self.comment_tab = self._add_tab(
|
|
|
|
notebook_ref,
|
|
|
|
NoteTab(self.dbstate, self.uistate, self.track,
|
2007-02-28 10:50:30 +05:30
|
|
|
self.source_ref.get_note_list()))
|
2006-02-16 10:36:40 +05:30
|
|
|
|
2007-01-16 12:42:10 +05:30
|
|
|
self._setup_notebook_tabs( notebook_src)
|
|
|
|
self._setup_notebook_tabs( notebook_ref)
|
|
|
|
|
2006-02-16 10:36:40 +05:30
|
|
|
def build_menu_names(self,sourceref):
|
|
|
|
if self.source:
|
|
|
|
source_name = self.source.get_title()
|
|
|
|
submenu_label = _('Source: %s') % source_name
|
|
|
|
else:
|
|
|
|
submenu_label = _('New Source')
|
|
|
|
return (_('Source Reference Editor'),submenu_label)
|
|
|
|
|
2006-02-20 10:29:20 +05:30
|
|
|
def ok_clicked(self,obj):
|
2006-02-16 10:36:40 +05:30
|
|
|
|
|
|
|
trans = self.db.transaction_begin()
|
2006-03-05 04:23:46 +05:30
|
|
|
if self.source.handle:
|
|
|
|
self.db.commit_source(self.source,trans)
|
2006-02-16 10:36:40 +05:30
|
|
|
self.db.transaction_commit(trans,_("Modify Source"))
|
2006-03-05 04:23:46 +05:30
|
|
|
else:
|
|
|
|
self.db.add_source(self.source,trans)
|
|
|
|
self.db.transaction_commit(trans,_("Add Source"))
|
2006-02-16 10:36:40 +05:30
|
|
|
|
|
|
|
if self.update:
|
2006-03-05 04:23:46 +05:30
|
|
|
self.update(self.source_ref,self.source)
|
2006-02-16 10:36:40 +05:30
|
|
|
|
2006-04-24 04:13:36 +05:30
|
|
|
self.close()
|