2006-03-25 23:16:24 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2009-02-08 04:24:16 +05:30
|
|
|
# 2009 Gary Burton
|
2006-03-25 23:16:24 +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
|
|
|
|
#
|
|
|
|
|
2008-01-22 14:47:46 +05:30
|
|
|
# $Id$
|
2006-03-25 23:16:24 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2006-03-25 23:16:24 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-02-19 01:37:09 +05:30
|
|
|
from gtk import glade
|
2006-03-25 23:16:24 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
2006-11-26 10:09:34 +05:30
|
|
|
import Config
|
2006-03-25 23:16:24 +05:30
|
|
|
|
2007-10-08 22:11:39 +05:30
|
|
|
from gen.lib import NoteType
|
2007-05-08 02:11:16 +05:30
|
|
|
|
2006-05-05 06:09:11 +05:30
|
|
|
from DisplayTabs import NoteTab,AddrEmbedList,WebEmbedList,SourceBackRefList
|
2008-05-09 01:10:56 +05:30
|
|
|
from widgets import MonitoredEntry, PrivacyButton, MonitoredDataType
|
2007-12-20 19:19:41 +05:30
|
|
|
from _EditReference import RefTab, EditReference
|
2006-03-25 23:16:24 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# EditRepoRef class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class EditRepoRef(EditReference):
|
2006-11-26 10:09:34 +05:30
|
|
|
|
2006-03-25 23:16:24 +05:30
|
|
|
def __init__(self, state, uistate, track, source, source_ref, update):
|
|
|
|
|
|
|
|
EditReference.__init__(self, state, uistate, track, source,
|
|
|
|
source_ref, update)
|
|
|
|
|
|
|
|
def _local_init(self):
|
2009-02-08 04:24:16 +05:30
|
|
|
self.width_key = Config.REPO_REF_WIDTH
|
|
|
|
self.height_key = Config.REPO_REF_HEIGHT
|
2006-03-25 23:16:24 +05:30
|
|
|
|
2008-02-19 01:37:09 +05:30
|
|
|
self.top = glade.XML(const.GLADE_FILE, "repository_ref_edit","gramps")
|
2006-03-25 23:16:24 +05:30
|
|
|
|
2006-04-24 03:48:01 +05:30
|
|
|
self.set_window(self.top.get_widget('repository_ref_edit'),
|
|
|
|
self.top.get_widget('repo_title'),
|
|
|
|
_('Repository Reference Editor'))
|
2006-03-25 23:16:24 +05:30
|
|
|
|
|
|
|
self.define_warn_box(self.top.get_widget("warn_box"))
|
|
|
|
self.define_expander(self.top.get_widget("src_expander"))
|
|
|
|
|
2007-12-20 19:19:41 +05:30
|
|
|
tblref = self.top.get_widget('table70')
|
|
|
|
notebook = self.top.get_widget('notebook_ref')
|
|
|
|
#recreate start page as GrampsTab
|
|
|
|
notebook.remove_page(0)
|
|
|
|
self.reftab = RefTab(self.dbstate, self.uistate, self.track,
|
|
|
|
_('General'), tblref)
|
|
|
|
tblref = self.top.get_widget('table69')
|
|
|
|
notebook = self.top.get_widget('notebook_src')
|
|
|
|
#recreate start page as GrampsTab
|
|
|
|
notebook.remove_page(0)
|
|
|
|
self.primtab = RefTab(self.dbstate, self.uistate, self.track,
|
2008-02-16 04:08:47 +05:30
|
|
|
_('_General'), tblref)
|
2007-12-20 19:19:41 +05:30
|
|
|
|
2006-03-25 23:16:24 +05:30
|
|
|
def _connect_signals(self):
|
|
|
|
self.define_ok_button(self.top.get_widget('ok'),self.ok_clicked)
|
|
|
|
self.define_cancel_button(self.top.get_widget('cancel'))
|
|
|
|
|
|
|
|
def _setup_fields(self):
|
|
|
|
self.callno = MonitoredEntry(
|
2006-12-15 18:09:28 +05:30
|
|
|
self.top.get_widget("call_number"),
|
|
|
|
self.source_ref.set_call_number,
|
|
|
|
self.source_ref.get_call_number,
|
|
|
|
self.db.readonly)
|
2006-03-25 23:16:24 +05:30
|
|
|
|
|
|
|
self.gid = MonitoredEntry(
|
2006-04-22 08:53:57 +05:30
|
|
|
self.top.get_widget('gid'),
|
|
|
|
self.source.set_gramps_id,
|
|
|
|
self.source.get_gramps_id,
|
2006-12-15 18:09:28 +05:30
|
|
|
self.db.readonly)
|
2006-08-30 05:15:07 +05:30
|
|
|
|
|
|
|
self.privacy = PrivacyButton(
|
|
|
|
self.top.get_widget("private"),
|
|
|
|
self.source,
|
|
|
|
self.db.readonly)
|
|
|
|
|
2007-07-18 09:47:30 +05:30
|
|
|
self.privacy = PrivacyButton(
|
|
|
|
self.top.get_widget("private_ref"),
|
|
|
|
self.source_ref,
|
|
|
|
self.db.readonly)
|
|
|
|
|
2006-03-25 23:16:24 +05:30
|
|
|
self.title = MonitoredEntry(
|
2006-04-22 08:53:57 +05:30
|
|
|
self.top.get_widget('repo_name'),
|
|
|
|
self.source.set_name,
|
|
|
|
self.source.get_name,
|
2006-12-15 18:09:28 +05:30
|
|
|
self.db.readonly)
|
2006-03-25 23:16:24 +05:30
|
|
|
|
2006-04-22 09:30:58 +05:30
|
|
|
self.type_selector = MonitoredDataType(
|
2006-03-25 23:16:24 +05:30
|
|
|
self.top.get_widget("media_type"),
|
2006-04-22 08:53:57 +05:30
|
|
|
self.source_ref.set_media_type,
|
2006-05-21 09:54:56 +05:30
|
|
|
self.source_ref.get_media_type,
|
|
|
|
self.db.readonly,
|
|
|
|
self.db.get_source_media_types(),
|
2006-04-22 09:30:58 +05:30
|
|
|
)
|
2006-03-25 23:16:24 +05:30
|
|
|
|
2006-04-22 08:53:57 +05:30
|
|
|
self.media_type_selector = MonitoredDataType(
|
2006-03-25 23:16:24 +05:30
|
|
|
self.top.get_widget("repo_type"),
|
2006-04-22 08:53:57 +05:30
|
|
|
self.source.set_type,
|
2006-05-21 09:54:56 +05:30
|
|
|
self.source.get_type,
|
|
|
|
self.db.readonly,
|
|
|
|
self.db.get_repository_types(),
|
2006-04-22 08:53:57 +05:30
|
|
|
)
|
2006-03-25 23:16:24 +05:30
|
|
|
|
|
|
|
def _create_tabbed_pages(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create the notebook tabs and inserts them into the main
|
2006-03-25 23:16:24 +05:30
|
|
|
window.
|
|
|
|
"""
|
|
|
|
|
|
|
|
notebook_src = self.top.get_widget('notebook_src')
|
|
|
|
notebook_ref = self.top.get_widget('notebook_ref')
|
|
|
|
|
2007-12-20 19:19:41 +05:30
|
|
|
self._add_tab(notebook_src, self.primtab)
|
|
|
|
self._add_tab(notebook_ref, self.reftab)
|
|
|
|
|
2006-03-25 23:16:24 +05:30
|
|
|
self.note_tab = self._add_tab(
|
|
|
|
notebook_src,
|
|
|
|
NoteTab(self.dbstate, self.uistate, self.track,
|
2007-05-08 02:11:16 +05:30
|
|
|
self.source.get_note_list(),
|
|
|
|
notetype=NoteType.REPO))
|
2006-03-25 23:16:24 +05:30
|
|
|
|
|
|
|
self.comment_tab = self._add_tab(
|
|
|
|
notebook_ref,
|
|
|
|
NoteTab(self.dbstate, self.uistate, self.track,
|
2007-05-08 02:11:16 +05:30
|
|
|
self.source_ref.get_note_list(),
|
|
|
|
notetype=NoteType.REPOREF))
|
2006-03-25 23:16:24 +05:30
|
|
|
|
|
|
|
self.address_tab = self._add_tab(
|
|
|
|
notebook_src,
|
|
|
|
AddrEmbedList(self.dbstate,self.uistate,self.track,
|
|
|
|
self.source.get_address_list()))
|
|
|
|
|
|
|
|
self.web_list = self._add_tab(
|
|
|
|
notebook_src,
|
|
|
|
WebEmbedList(self.dbstate,self.uistate,self.track,
|
|
|
|
self.source.get_url_list()))
|
|
|
|
|
2006-04-22 01:26:16 +05:30
|
|
|
self.backref_tab = self._add_tab(
|
2006-04-22 02:21:45 +05:30
|
|
|
notebook_src,
|
2006-04-22 01:26:16 +05:30
|
|
|
SourceBackRefList(self.dbstate, self.uistate, self.track,
|
2006-04-22 03:54:54 +05:30
|
|
|
self.db.find_backlink_handles(self.source.handle),
|
2006-04-22 01:26:16 +05:30
|
|
|
self.enable_warnbox))
|
|
|
|
|
2007-01-16 12:42:10 +05:30
|
|
|
self._setup_notebook_tabs( notebook_src)
|
|
|
|
self._setup_notebook_tabs( notebook_ref)
|
|
|
|
|
2006-03-25 23:16:24 +05:30
|
|
|
def build_menu_names(self,sourceref):
|
|
|
|
if self.source:
|
|
|
|
source_name = self.source.get_name()
|
2006-10-28 09:23:46 +05:30
|
|
|
submenu_label = _('Repository: %s') % source_name
|
2006-03-25 23:16:24 +05:30
|
|
|
else:
|
2006-10-28 09:23:46 +05:30
|
|
|
submenu_label = _('New Repository')
|
2006-03-25 23:16:24 +05:30
|
|
|
return (_('Repo Reference Editor'),submenu_label)
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def ok_clicked(self, obj):
|
2006-03-25 23:16:24 +05:30
|
|
|
|
|
|
|
trans = self.db.transaction_begin()
|
|
|
|
if self.source.handle:
|
|
|
|
self.db.commit_repository(self.source,trans)
|
2006-10-28 09:23:46 +05:30
|
|
|
self.db.transaction_commit(trans,_("Modify Repository"))
|
2006-03-25 23:16:24 +05:30
|
|
|
else:
|
|
|
|
self.db.add_repository(self.source,trans)
|
2006-10-28 09:23:46 +05:30
|
|
|
self.db.transaction_commit(trans,_("Add Repository"))
|
2006-03-25 23:16:24 +05:30
|
|
|
self.source_ref.ref = self.source.handle
|
|
|
|
|
|
|
|
if self.update:
|
|
|
|
self.update((self.source_ref,self.source))
|
|
|
|
|
2006-04-24 04:13:36 +05:30
|
|
|
self.close()
|