2005-05-27 23:13:04 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-04-24 03:48:01 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2005-05-27 23:13:04 +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
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2005-05-27 23:13:04 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-03-01 10:38:11 +05:30
|
|
|
import gtk
|
2005-05-27 23:13:04 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
2006-11-26 06:59:58 +05:30
|
|
|
import Config
|
2007-10-08 22:11:39 +05:30
|
|
|
import gen.lib
|
2005-05-27 23:13:04 +05:30
|
|
|
|
2006-02-25 10:08:40 +05:30
|
|
|
from GrampsWidgets import *
|
2006-05-05 06:09:11 +05:30
|
|
|
from DisplayTabs import AddrEmbedList,WebEmbedList,NoteTab,SourceBackRefList
|
2006-03-04 12:04:48 +05:30
|
|
|
from _EditPrimary import EditPrimary
|
2006-02-25 10:08:40 +05:30
|
|
|
|
2006-03-04 12:04:48 +05:30
|
|
|
class EditRepository(EditPrimary):
|
2006-02-25 10:08:40 +05:30
|
|
|
|
|
|
|
def __init__(self,dbstate,uistate,track,repository):
|
2005-05-27 23:13:04 +05:30
|
|
|
|
2006-03-04 12:04:48 +05:30
|
|
|
EditPrimary.__init__(self, dbstate, uistate, track,
|
|
|
|
repository, dbstate.db.get_repository_from_handle)
|
2006-02-25 10:08:40 +05:30
|
|
|
|
2006-04-01 01:16:41 +05:30
|
|
|
def empty_object(self):
|
2007-10-08 22:11:39 +05:30
|
|
|
return gen.lib.Repository()
|
2006-04-01 01:16:41 +05:30
|
|
|
|
2006-11-27 02:48:30 +05:30
|
|
|
def get_menu_title(self):
|
|
|
|
if self.obj.get_handle():
|
|
|
|
title = self.obj.get_name()
|
|
|
|
if title:
|
|
|
|
title = _('Repository') + ": " + title
|
|
|
|
else:
|
|
|
|
title = _('Repository')
|
|
|
|
else:
|
|
|
|
title = _('New Repository')
|
|
|
|
return title
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _local_init(self):
|
2007-09-08 11:24:02 +05:30
|
|
|
self.glade = gtk.glade.XML(const.GLADE_FILE,"repository_editor","gramps")
|
2006-11-26 06:59:58 +05:30
|
|
|
|
2006-11-27 02:48:30 +05:30
|
|
|
self.set_window(self.glade.get_widget("repository_editor"), None, self.get_menu_title())
|
2006-11-26 06:59:58 +05:30
|
|
|
|
|
|
|
width = Config.get(Config.REPO_WIDTH)
|
|
|
|
height = Config.get(Config.REPO_HEIGHT)
|
|
|
|
self.window.resize(width, height)
|
2005-05-27 23:13:04 +05:30
|
|
|
|
2006-11-27 02:48:30 +05:30
|
|
|
def build_menu_names(self,source):
|
|
|
|
return (_('Edit Repository'), self.get_menu_title())
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _setup_fields(self):
|
2005-05-27 23:13:04 +05:30
|
|
|
|
2006-02-25 10:08:40 +05:30
|
|
|
self.name = MonitoredEntry(
|
|
|
|
self.glade.get_widget("repository_name"),
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.set_name,
|
|
|
|
self.obj.get_name,
|
2006-02-25 10:08:40 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
2006-04-19 09:27:10 +05:30
|
|
|
self.type = MonitoredDataType(
|
2006-02-25 10:08:40 +05:30
|
|
|
self.glade.get_widget("repository_type"),
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.set_type,
|
2006-05-21 09:54:56 +05:30
|
|
|
self.obj.get_type,
|
|
|
|
self.db.readonly,
|
|
|
|
self.db.get_repository_types(),
|
2006-04-19 09:27:10 +05:30
|
|
|
)
|
2006-02-25 10:08:40 +05:30
|
|
|
|
2006-02-26 09:59:39 +05:30
|
|
|
self.call_number = MonitoredEntry(
|
|
|
|
self.glade.get_widget('gid'),
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.set_gramps_id,
|
|
|
|
self.obj.get_gramps_id,
|
2006-02-26 09:59:39 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
2006-08-30 05:15:07 +05:30
|
|
|
self.privacy = PrivacyButton(
|
|
|
|
self.glade.get_widget("private"),
|
|
|
|
self.obj,
|
|
|
|
self.db.readonly)
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _create_tabbed_pages(self):
|
|
|
|
|
|
|
|
notebook = gtk.Notebook()
|
2006-02-25 10:08:40 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
self.addr_tab = self._add_tab(
|
|
|
|
notebook,
|
|
|
|
AddrEmbedList(self.dbstate, self.uistate, self.track,
|
|
|
|
self.obj.get_address_list()))
|
2006-02-26 09:59:39 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
self.url_tab = self._add_tab(
|
|
|
|
notebook,
|
|
|
|
WebEmbedList(self.dbstate, self.uistate, self.track,
|
|
|
|
self.obj.get_url_list()))
|
2005-05-27 23:13:04 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
self.note_tab = self._add_tab(
|
|
|
|
notebook,
|
|
|
|
NoteTab(self.dbstate, self.uistate, self.track,
|
2007-05-08 02:11:16 +05:30
|
|
|
self.obj.get_note_list(), self.get_menu_title(),
|
2007-10-08 22:11:39 +05:30
|
|
|
notetype=gen.lib.NoteType.REPO))
|
2006-03-01 10:38:11 +05:30
|
|
|
|
|
|
|
self.backref_tab = self._add_tab(
|
|
|
|
notebook,
|
|
|
|
SourceBackRefList(self.dbstate, self.uistate, self.track,
|
2006-04-22 01:26:16 +05:30
|
|
|
self.db.find_backlink_handles(self.obj.handle)))
|
2006-03-01 10:38:11 +05:30
|
|
|
|
2007-01-16 12:42:10 +05:30
|
|
|
self._setup_notebook_tabs( notebook)
|
2006-03-01 10:38:11 +05:30
|
|
|
notebook.show_all()
|
|
|
|
self.glade.get_widget("vbox").pack_start(notebook,True,True)
|
2005-05-27 23:13:04 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _connect_signals(self):
|
|
|
|
self.define_help_button(self.glade.get_widget('help'),'adv-src')
|
|
|
|
self.define_cancel_button(self.glade.get_widget('cancel'))
|
|
|
|
self.define_ok_button(self.glade.get_widget('ok'), self.save)
|
|
|
|
|
|
|
|
def save(self,*obj):
|
2007-04-08 09:54:38 +05:30
|
|
|
self.ok_button.set_sensitive(False)
|
2006-04-01 01:16:41 +05:30
|
|
|
if self.object_is_empty():
|
|
|
|
from QuestionDialog import ErrorDialog
|
|
|
|
ErrorDialog(_("Cannot save repository"),
|
|
|
|
_("No data exists for this repository. Please "
|
|
|
|
"enter data or cancel the edit."))
|
2007-04-08 09:54:38 +05:30
|
|
|
self.ok_button.set_sensitive(True)
|
2006-04-01 01:16:41 +05:30
|
|
|
return
|
|
|
|
|
2005-05-27 23:13:04 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2006-03-01 10:38:11 +05:30
|
|
|
if self.obj.get_handle() == None:
|
2006-04-22 08:53:57 +05:30
|
|
|
self.db.add_repository(self.obj,trans)
|
2005-05-27 23:13:04 +05:30
|
|
|
else:
|
2006-03-01 10:38:11 +05:30
|
|
|
self.db.commit_repository(self.obj,trans)
|
|
|
|
msg = _("Edit Repository (%s)") % self.obj.get_name()
|
|
|
|
self.db.transaction_commit(trans,msg)
|
2006-04-22 08:53:57 +05:30
|
|
|
self.close()
|
2005-05-27 23:13:04 +05:30
|
|
|
|
2006-11-26 06:59:58 +05:30
|
|
|
def _cleanup_on_exit(self):
|
|
|
|
self.backref_tab.close()
|
|
|
|
(width, height) = self.window.get_size()
|
|
|
|
Config.set(Config.REPO_WIDTH, width)
|
|
|
|
Config.set(Config.REPO_HEIGHT, height)
|
|
|
|
Config.sync()
|
|
|
|
|
2005-08-17 15:00:10 +05:30
|
|
|
class DelRepositoryQuery:
|
2007-01-23 09:07:13 +05:30
|
|
|
def __init__(self,dbstate,uistate,repository,sources):
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj = repository
|
2007-01-23 09:07:13 +05:30
|
|
|
self.db = dbstate.db
|
|
|
|
self.uistate = uistate
|
2005-05-27 23:13:04 +05:30
|
|
|
self.sources = sources
|
|
|
|
|
|
|
|
def query_response(self):
|
|
|
|
trans = self.db.transaction_begin()
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
repos_handle_list = [self.obj.get_handle()]
|
2005-05-27 23:13:04 +05:30
|
|
|
|
|
|
|
for handle in self.sources:
|
|
|
|
source = self.db.get_source_from_handle(handle)
|
|
|
|
source.remove_repo_references(repos_handle_list)
|
|
|
|
self.db.commit_source(source,trans)
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
self.db.remove_repository(self.obj.get_handle(),trans)
|
2005-05-27 23:13:04 +05:30
|
|
|
self.db.transaction_commit(
|
2006-03-01 10:38:11 +05:30
|
|
|
trans,_("Delete Repository (%s)") % self.obj.get_name())
|