Merge SOUR_REPO branch with main trunk
svn: r4712
This commit is contained in:
parent
557638b510
commit
5610229889
@ -1,5 +1,23 @@
|
||||
2005-05-27 Alex Roitman <shura@gramps-project.org>
|
||||
* src/GrampsBSDDB.py (upgrade_7): Add upgrade path for repo changes.
|
||||
* src/const.py.in: Define integer constants for standard events.
|
||||
* gramps.glade: Resolve merge conflicts.
|
||||
|
||||
2005-05-27 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||
* src/EditRepository.py: polish Repository Ref UI
|
||||
* src/RelLib.py: merge minor changes from HEAD
|
||||
* src/RepositoryRefEdit.py: polish Repository Ref UI
|
||||
* src/gramps.glade: polish Repository Ref UI
|
||||
|
||||
2005-05-27 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||
* src/EditRepository.py: completed delete Repository
|
||||
* src/RepositoryView.py: completed delete Repository
|
||||
* src/Utils.py: added then removed a method, line number changed.
|
||||
|
||||
2005-05-27 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||
* src/EditSource.py: completed support Repository Ref UI
|
||||
* src/RepositoryRefEdit.py: everything now works accept MediaType
|
||||
* src/gramps.glade: tooltips etc. for Repository Ref UI
|
||||
|
||||
2005-05-27 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||
* src/RelLib.py: Add wrappers for old event handle API including a
|
||||
@ -24,6 +42,37 @@
|
||||
idle callback; (add_table_to_notebook): Work with PyGtk < 2.4;
|
||||
(format_relation): Adapt format to availably space.
|
||||
|
||||
2005-05-26 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||
* src/EditSource.py: added Repositories tab and related code (not complete)
|
||||
* src/RepositoryRefEdit.py: outline of Repository Ref UI
|
||||
* src/gramps.glade: Repositoy tab for Source and Repository Ref UI
|
||||
|
||||
2005-05-26 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||
* src/DisplayModels.py: fixed for removing phone
|
||||
* src/RelLib.py: removed phone field from Repository because it is
|
||||
in Location anyway.
|
||||
* src/RepositoryView.py: Fixed display of home_url in list view.
|
||||
|
||||
2005-05-26 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||
* src/EditRepository.py: add support for repository types
|
||||
* src/GrampsBSDDB.py: add get_repository_type_list method
|
||||
* src/GrampsInMemDB.py: add get_repository_type_list method
|
||||
|
||||
2005-05-26 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||
* src/EditRepository.py: new module to edit repository objects
|
||||
* src/RepositoryView.py: new module to main repository list view
|
||||
* src/DisplayModels.py: added a model for Repositories
|
||||
* src/gramps.glade: added Repository tab to gramps, and added new
|
||||
repositoryEditor dialog
|
||||
* src/gramps_main.py: added calls for repository editor
|
||||
|
||||
2005-05-26 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||
* src/GrampsBSDDB.py: add support for Repository primary table
|
||||
* src/GrampsDbBase.py: add support for Repository primary table
|
||||
* src/GrampsGconfKeys.py: add Repository id prefix keys
|
||||
* src/GrampsInMemDB.py: add support for Repository primary table
|
||||
* src/GrampsIniKeys.py: add Repository id prefix keys
|
||||
|
||||
2005-05-25 Alex Roitman <shura@gramps-project.org>
|
||||
* src/EditPlace.py: WATCH cursor and temp label for References tab.
|
||||
* src/EditSource.py: Improve manipulating notebook tab labels.
|
||||
@ -32,6 +81,14 @@
|
||||
* src/gramps.glade (event editor, source editor, place editor):
|
||||
Add icons to notebook tabs.
|
||||
|
||||
2005-05-25 Alex Roitman <shura@gramps-project.org>
|
||||
* src/RelLib.py: Switch Repository from using locations to using
|
||||
Address object. Adjust methods accordingly. Add RepoRef class.
|
||||
Add support for RepoRef list in Source class.
|
||||
|
||||
2005-05-25 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||
* src/RelLib.py: added Repository class and unittests
|
||||
|
||||
2005-05-25 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||
* src/plugins/ScratchPad.py: disabled search because it does not do
|
||||
what the user expects.
|
||||
|
@ -484,3 +484,114 @@ class MediaModel(BaseModel):
|
||||
def column_change(self,data):
|
||||
return unicode(time.strftime(_date_format,time.localtime(data[8])),
|
||||
_codeset)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# RepositoryModel
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class RepositoryModel(BaseModel):
|
||||
|
||||
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING):
|
||||
self.gen_cursor = db.get_repository_cursor
|
||||
self.map = db.repository_map
|
||||
self.fmap = [
|
||||
self.column_name,
|
||||
self.column_id,
|
||||
self.column_type,
|
||||
self.column_home_url,
|
||||
self.column_parish,
|
||||
self.column_postal_code,
|
||||
self.column_city,
|
||||
self.column_county,
|
||||
self.column_state,
|
||||
self.column_country,
|
||||
self.column_email,
|
||||
self.column_search_url,
|
||||
self.column_handle,
|
||||
]
|
||||
self.smap = [
|
||||
self.column_name,
|
||||
self.column_id,
|
||||
self.column_type,
|
||||
self.column_home_url,
|
||||
self.column_parish,
|
||||
self.column_postal_code,
|
||||
self.column_city,
|
||||
self.column_county,
|
||||
self.column_state,
|
||||
self.column_country,
|
||||
self.column_email,
|
||||
self.column_search_url,
|
||||
self.column_handle,
|
||||
]
|
||||
BaseModel.__init__(self,db,scol,order)
|
||||
|
||||
def on_get_n_columns(self):
|
||||
return len(self.fmap)+1
|
||||
|
||||
def column_handle(self,data):
|
||||
return unicode(data[0])
|
||||
|
||||
def column_id(self,data):
|
||||
return unicode(data[1])
|
||||
|
||||
def column_type(self,data):
|
||||
return unicode(data[2])
|
||||
|
||||
def column_name(self,data):
|
||||
return unicode(data[3])
|
||||
|
||||
def column_parish(self,data):
|
||||
try:
|
||||
return data[4].get_parish()
|
||||
except:
|
||||
return u''
|
||||
|
||||
def column_city(self,data):
|
||||
try:
|
||||
return data[4].get_city()
|
||||
except:
|
||||
return u''
|
||||
|
||||
def column_county(self,data):
|
||||
try:
|
||||
return data[4].get_county()
|
||||
except:
|
||||
return u''
|
||||
|
||||
def column_state(self,data):
|
||||
try:
|
||||
return data[4].get_state()
|
||||
except:
|
||||
return u''
|
||||
|
||||
def column_country(self,data):
|
||||
try:
|
||||
return data[4].get_country()
|
||||
except:
|
||||
return u''
|
||||
|
||||
def column_postal_code(self,data):
|
||||
try:
|
||||
return data[4].get_postal_code()
|
||||
except:
|
||||
return u''
|
||||
|
||||
def column_phone(self,data):
|
||||
try:
|
||||
return data[4].get_phone()
|
||||
except:
|
||||
return u''
|
||||
|
||||
|
||||
def column_email(self,data):
|
||||
return unicode(data[5])
|
||||
|
||||
def column_search_url(self,data):
|
||||
return unicode(data[6])
|
||||
|
||||
def column_home_url(self,data):
|
||||
return unicode(data[7])
|
||||
|
||||
|
650
gramps2/src/EditRepository.py
Normal file
650
gramps2/src/EditRepository.py
Normal file
@ -0,0 +1,650 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 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
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gobject
|
||||
import gtk.glade
|
||||
import gtk.gdk
|
||||
import gnome
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
import Utils
|
||||
import ImageSelect
|
||||
import ListModel
|
||||
import RelLib
|
||||
import NameDisplay
|
||||
import AutoComp
|
||||
import RepositoryRefEdit
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Classes to manager the list of Sources that have references to the
|
||||
# Repository
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
class ReposSrcListModel(gtk.ListStore):
|
||||
def __init__(self, model, repos=None):
|
||||
gtk.ListStore.__init__(self,
|
||||
object, # source
|
||||
object # repostory reference
|
||||
)
|
||||
|
||||
self.original_item_list = []
|
||||
self.set_model(model)
|
||||
self.set_repos(repos)
|
||||
|
||||
def rebuild(self):
|
||||
"""Clear the list and repopulate from the current source record,
|
||||
remember the original list in case it is useful later"""
|
||||
self.clear()
|
||||
|
||||
# Get the list of sources that reference this repository
|
||||
repos_handle = self._repos.get_handle()
|
||||
source_list = [ src_handle for src_handle \
|
||||
in self._db.get_source_handles() \
|
||||
if self._db.get_source_from_handle(src_handle).has_repo_reference(repos_handle)]
|
||||
|
||||
|
||||
# Add each (source,repos_ref) to list. It is possible for
|
||||
# a source to reference to same repository more than once.
|
||||
self.original_item_list = []
|
||||
for source_hdl in source_list:
|
||||
source = self._db.get_source_from_handle(source_hdl)
|
||||
repos_ref_list = [ repos_ref for repos_ref in source.get_reporef_list() \
|
||||
if repos_ref.get_reference_handle() == repos_handle ]
|
||||
|
||||
for repos_ref in repos_ref_list:
|
||||
self.append([self._db.get_source_from_handle(source_hdl),repos_ref])
|
||||
self.original_item_list.append((source_hdl,repos_ref))
|
||||
|
||||
|
||||
|
||||
def update(self,source,repos_ref,original_source=None):
|
||||
"""Add the record if it is not already in the list otherwise
|
||||
replace the record with the new one."""
|
||||
|
||||
if original_source != None and \
|
||||
source.get_handle() != original_source.get_handle():
|
||||
# If the source has changed we need to remove the
|
||||
# original reference
|
||||
found = False
|
||||
for val in range(0,len(self)):
|
||||
iter = self.get_iter(val)
|
||||
if original_source.get_handle() == self.get_value(iter,0).get_handle() \
|
||||
and repos_ref == self.get_value(iter,1):
|
||||
self.remove(iter)
|
||||
found = True
|
||||
break
|
||||
|
||||
# If the source has not changed but the ref has then just update the row
|
||||
found = False
|
||||
for val in range(0,len(self)):
|
||||
iter = self.get_iter(val)
|
||||
if source.get_handle() == self.get_value(iter,0).get_handle and \
|
||||
repos_ref == self.get_value(iter,1):
|
||||
self.row_changed(self.get_path(iter),iter)
|
||||
found = True
|
||||
break
|
||||
|
||||
if not found:
|
||||
self.append([source,repos_ref])
|
||||
|
||||
def set_repos(self, repos):
|
||||
self._repos = repos
|
||||
self.rebuild()
|
||||
|
||||
def set_model(self, model):
|
||||
self._model = model
|
||||
self._db = model.db
|
||||
|
||||
def get_deleted_items(self):
|
||||
# These are the ones that are in the original sources list
|
||||
# but no longer in the list model
|
||||
|
||||
self.items = []
|
||||
for val in range(0,len(self)):
|
||||
iter = self.get_iter(val)
|
||||
self.items.append((self.get_value(iter,0).get_handle(),self.get_value(iter,1)))
|
||||
|
||||
deleted = []
|
||||
for item in self.original_item_list:
|
||||
found = False
|
||||
for cur_item in self.items:
|
||||
if item[0] == cur_item[0] and \
|
||||
item[1] == cur_item[1]:
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
deleted.append(item)
|
||||
|
||||
return deleted
|
||||
|
||||
def get_added_items(self):
|
||||
# These are the ones that are in the list model but not in the
|
||||
# original sources list.
|
||||
|
||||
self.items = []
|
||||
for val in range(0,len(self)):
|
||||
iter = self.get_iter(val)
|
||||
self.items.append((self.get_value(iter,0).get_handle(),self.get_value(iter,1)))
|
||||
|
||||
added = []
|
||||
for cur_item in self.items:
|
||||
found = False
|
||||
for item in self.original_item_list:
|
||||
if item[0] == cur_item[0] and \
|
||||
item[1] == cur_item[1]:
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
added.append(cur_item)
|
||||
|
||||
return added
|
||||
|
||||
def get_update_items(self):
|
||||
# These are in both lists but the repos_ref has changed in the
|
||||
# list model.
|
||||
|
||||
self.items = []
|
||||
for val in range(0,len(self)):
|
||||
iter = self.get_iter(val)
|
||||
self.items.append((self.get_value(iter,0).get_handle(),self.get_value(iter,1)))
|
||||
|
||||
update = []
|
||||
for cur_item in self.items:
|
||||
found = False
|
||||
for item in self.original_item_list:
|
||||
if item[0] == cur_item[0] and \
|
||||
item[1] == cur_item[1]:
|
||||
found = True
|
||||
break
|
||||
if found:
|
||||
update.append(item)
|
||||
|
||||
return update
|
||||
|
||||
|
||||
class ReposSrcListView:
|
||||
|
||||
def __init__(self, model, widget):
|
||||
self._gramps_model = model
|
||||
|
||||
self.database_changed(self._gramps_model.db)
|
||||
self._gramps_model.connect('database-changed', self.database_changed)
|
||||
|
||||
self._widget = widget
|
||||
|
||||
# Create the tree columns
|
||||
self._col1 = gtk.TreeViewColumn(_("Title"))
|
||||
self._col2 = gtk.TreeViewColumn(_("Author"))
|
||||
self._col3 = gtk.TreeViewColumn(_("Reference Note"))
|
||||
|
||||
# Add columns
|
||||
self._widget.append_column(self._col1)
|
||||
self._widget.append_column(self._col2)
|
||||
self._widget.append_column(self._col3)
|
||||
|
||||
# Create cell renders
|
||||
self._col1_cell = gtk.CellRendererText()
|
||||
self._col2_cell = gtk.CellRendererText()
|
||||
self._col3_cell = gtk.CellRendererText()
|
||||
|
||||
# Add cells to view
|
||||
self._col1.pack_start(self._col1_cell, True)
|
||||
self._col2.pack_start(self._col2_cell, True)
|
||||
self._col3.pack_start(self._col3_cell, True)
|
||||
|
||||
# Setup the cell data callback funcs
|
||||
self._col1.set_cell_data_func(self._col1_cell, self.object_title)
|
||||
self._col2.set_cell_data_func(self._col2_cell, self.object_author)
|
||||
self._col3.set_cell_data_func(self._col3_cell, self.object_ref_note)
|
||||
self._widget.set_enable_search(False)
|
||||
|
||||
|
||||
def database_changed(self,db):
|
||||
self._db = db
|
||||
|
||||
# Methods for rendering the cells.
|
||||
|
||||
def object_title(self, column, cell, model, iter, user_data=None):
|
||||
source = model.get_value(iter, 0)
|
||||
cell.set_property('text', source.get_title())
|
||||
|
||||
def object_author(self, column, cell, model, iter, user_data=None):
|
||||
source = model.get_value(iter, 0)
|
||||
cell.set_property('text', source.get_author())
|
||||
|
||||
def object_ref_note(self, column, cell, model, iter, user_data=None):
|
||||
o = model.get_value(iter, 1)
|
||||
cell.set_property('text', o.get_note())
|
||||
|
||||
# proxy methods to provide access to the real widget functions.
|
||||
|
||||
def set_model(self,model=None):
|
||||
self._widget.set_model(model)
|
||||
|
||||
def get_model(self):
|
||||
return self._widget.get_model()
|
||||
|
||||
def get_selection(self):
|
||||
return self._widget.get_selection()
|
||||
|
||||
|
||||
|
||||
class EditRepository:
|
||||
|
||||
def __init__(self,repository,db,parent,parent_window=None,readonly=False):
|
||||
if repository:
|
||||
self.repository = repository
|
||||
else:
|
||||
self.repository = RelLib.Repository()
|
||||
self.db = db
|
||||
self.parent = parent
|
||||
self.name_display = NameDisplay.displayer.display
|
||||
if repository:
|
||||
if parent and self.parent.child_windows.has_key(repository.get_handle()):
|
||||
self.parent.child_windows[repository.get_handle()].present(None)
|
||||
return
|
||||
else:
|
||||
self.win_key = repository.get_handle()
|
||||
else:
|
||||
self.win_key = self
|
||||
self.child_windows = {}
|
||||
self.path = db.get_save_path()
|
||||
self.not_loaded = 1
|
||||
self.ref_not_loaded = 1
|
||||
self.lists_changed = 0
|
||||
mode = not self.db.readonly
|
||||
|
||||
self.top_window = gtk.glade.XML(const.gladeFile,"repositoryEditor","gramps")
|
||||
self.top = self.top_window.get_widget("repositoryEditor")
|
||||
|
||||
Utils.set_titles(self.top,self.top_window.get_widget('repository_title'),
|
||||
_('Repository Editor'))
|
||||
|
||||
self.name = self.top_window.get_widget("repository_name")
|
||||
self.name.set_text(repository.get_name())
|
||||
self.name.set_editable(mode)
|
||||
|
||||
self.type = self.top_window.get_widget("repository_type")
|
||||
AutoComp.fill_combo(self.type,[ repos_type for repos_type \
|
||||
in self.db.get_repository_type_list() \
|
||||
if repos_type != '' ])
|
||||
self.type.child.set_text(repository.get_type())
|
||||
|
||||
self.street = self.top_window.get_widget("repository_street")
|
||||
self.street.set_text(repository.get_address().get_parish())
|
||||
self.street.set_editable(mode)
|
||||
|
||||
self.city = self.top_window.get_widget("repository_city")
|
||||
self.city.set_text(repository.get_address().get_city())
|
||||
self.city.set_editable(mode)
|
||||
|
||||
self.county = self.top_window.get_widget("repository_county")
|
||||
self.county.set_text(repository.get_address().get_county())
|
||||
self.county.set_editable(mode)
|
||||
|
||||
self.state = self.top_window.get_widget("repository_state")
|
||||
self.state.set_text(repository.get_address().get_state())
|
||||
self.state.set_editable(mode)
|
||||
|
||||
self.postal = self.top_window.get_widget("repository_postal")
|
||||
self.postal.set_text(repository.get_address().get_postal_code())
|
||||
self.postal.set_editable(mode)
|
||||
|
||||
self.country = self.top_window.get_widget("repository_country")
|
||||
self.country.set_text(repository.get_address().get_country())
|
||||
self.country.set_editable(mode)
|
||||
|
||||
self.phone = self.top_window.get_widget("repository_phone")
|
||||
self.phone.set_text(repository.get_address().get_phone())
|
||||
self.phone.set_editable(mode)
|
||||
|
||||
self.email = self.top_window.get_widget("repository_email")
|
||||
self.email.set_text(repository.get_email())
|
||||
self.email.set_editable(mode)
|
||||
|
||||
self.search_url = self.top_window.get_widget("repository_search_url")
|
||||
self.search_url.set_text(repository.get_search_url())
|
||||
self.search_url.set_editable(mode)
|
||||
|
||||
self.home_url = self.top_window.get_widget("repository_home_url")
|
||||
self.home_url.set_text(repository.get_home_url())
|
||||
self.home_url.set_editable(mode)
|
||||
|
||||
|
||||
self.note = self.top_window.get_widget("repository_note")
|
||||
self.note.set_editable(mode)
|
||||
self.notes_buffer = self.note.get_buffer()
|
||||
|
||||
self.refs_label = self.top_window.get_widget("refsRepositoryEditor")
|
||||
self.notes_label = self.top_window.get_widget("notesRepositoryEditor")
|
||||
|
||||
self.flowed = self.top_window.get_widget("repository_flowed")
|
||||
self.flowed.set_sensitive(mode)
|
||||
self.preform = self.top_window.get_widget("repository_preformatted")
|
||||
self.preform.set_sensitive(mode)
|
||||
|
||||
self.refinfo = self.top_window.get_widget("refinfo")
|
||||
|
||||
|
||||
if repository.get_note():
|
||||
self.notes_buffer.set_text(repository.get_note())
|
||||
Utils.bold_label(self.notes_label)
|
||||
if repository.get_note_format() == 1:
|
||||
self.preform.set_active(1)
|
||||
else:
|
||||
self.flowed.set_active(1)
|
||||
|
||||
# Setup source reference tab
|
||||
self.repos_source_view = ReposSrcListView(self.parent,
|
||||
self.top_window.get_widget("repository_sources"))
|
||||
self.repos_source_model = ReposSrcListModel(self.parent,repository)
|
||||
self.repos_source_view.set_model(self.repos_source_model)
|
||||
|
||||
self.top_window.signal_autoconnect({
|
||||
"on_switch_page" : self.on_switch_page,
|
||||
"on_repositoryEditor_help_clicked" : self.on_help_clicked,
|
||||
"on_repositoryEditor_ok_clicked" : self.on_repository_apply_clicked,
|
||||
"on_repositoryEditor_cancel_clicked" : self.close,
|
||||
"on_repositoryEditor_delete_event" : self.on_delete_event,
|
||||
"on_add_repos_sources_clicked" : self.on_add_repos_ref_clicked,
|
||||
"on_delete_repos_ref_clicked" : self.on_delete_repos_ref_clicked,
|
||||
"on_edit_repos_ref_clicked" : self.on_edit_repos_ref_clicked,
|
||||
"on_edit_repos_ref_row_activated" : self.on_edit_repos_ref_clicked,
|
||||
})
|
||||
|
||||
|
||||
|
||||
if parent_window:
|
||||
self.top.set_transient_for(parent_window)
|
||||
|
||||
self.top_window.get_widget('repository_ok').set_sensitive(not self.db.readonly)
|
||||
|
||||
if parent_window:
|
||||
self.top.set_transient_for(parent_window)
|
||||
self.add_itself_to_menu()
|
||||
self.top.show()
|
||||
#self.refs_label.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
||||
#gobject.idle_add(self.display_references)
|
||||
|
||||
|
||||
def edit_cb(self, cell, path, new_text, data):
|
||||
node = self.data_model.get_iter(path)
|
||||
self.data_model.set_value(node,data,new_text)
|
||||
|
||||
def on_delete_event(self,obj,b):
|
||||
self.close_child_windows()
|
||||
self.remove_itself_from_menu()
|
||||
|
||||
def on_help_clicked(self,obj):
|
||||
"""Display the relevant portion of GRAMPS manual"""
|
||||
gnome.help_display('gramps-manual','adv-src')
|
||||
|
||||
def close(self,obj):
|
||||
self.close_child_windows()
|
||||
self.remove_itself_from_menu()
|
||||
self.top.destroy()
|
||||
|
||||
def close_child_windows(self):
|
||||
for child_window in self.child_windows.values():
|
||||
child_window.close(None)
|
||||
self.child_windows = {}
|
||||
|
||||
def add_itself_to_menu(self):
|
||||
self.parent.child_windows[self.win_key] = self
|
||||
if not self.repository:
|
||||
label = _("New Repository")
|
||||
else:
|
||||
label = self.repository.get_name()
|
||||
if not label.strip():
|
||||
label = _("New Repository")
|
||||
label = "%s: %s" % (_('Repository'),label)
|
||||
self.parent_menu_item = gtk.MenuItem(label)
|
||||
self.parent_menu_item.set_submenu(gtk.Menu())
|
||||
self.parent_menu_item.show()
|
||||
self.parent.winsmenu.append(self.parent_menu_item)
|
||||
self.winsmenu = self.parent_menu_item.get_submenu()
|
||||
self.menu_item = gtk.MenuItem(_('Repository Editor'))
|
||||
self.menu_item.connect("activate",self.present)
|
||||
self.menu_item.show()
|
||||
self.winsmenu.append(self.menu_item)
|
||||
|
||||
def remove_itself_from_menu(self):
|
||||
del self.parent.child_windows[self.win_key]
|
||||
self.menu_item.destroy()
|
||||
self.winsmenu.destroy()
|
||||
self.parent_menu_item.destroy()
|
||||
|
||||
def present(self,obj):
|
||||
self.top.present()
|
||||
|
||||
def on_add_repos_ref_clicked(self,widget):
|
||||
RepositoryRefEdit.RepositoryRefSourceEdit(RelLib.RepoRef(),
|
||||
None,
|
||||
self.db,
|
||||
self.repos_source_model.update,
|
||||
self)
|
||||
|
||||
def on_delete_repos_ref_clicked(self,widget):
|
||||
selection = self.repos_source_view.get_selection()
|
||||
model, iter = selection.get_selected()
|
||||
if iter:
|
||||
model.remove(iter)
|
||||
return
|
||||
|
||||
|
||||
|
||||
def on_edit_repos_ref_clicked(self,widget,path=None,colm=None,userp=None):
|
||||
selection = self.repos_source_view.get_selection()
|
||||
model, iter = selection.get_selected()
|
||||
|
||||
if iter:
|
||||
source = model.get_value(iter,0)
|
||||
repos_ref = model.get_value(iter,1)
|
||||
|
||||
RepositoryRefEdit.RepositoryRefSourceEdit(repos_ref,
|
||||
source,
|
||||
self.db,
|
||||
self.repos_source_model.update,
|
||||
self)
|
||||
|
||||
|
||||
|
||||
def on_repository_apply_clicked(self,obj):
|
||||
|
||||
name = unicode(self.name.get_text())
|
||||
if name != self.repository.get_name():
|
||||
self.repository.set_name(name)
|
||||
|
||||
repos_type = unicode(self.type.child.get_text())
|
||||
if repos_type != self.repository.get_type():
|
||||
self.repository.set_type(repos_type)
|
||||
|
||||
|
||||
street = unicode(self.street.get_text())
|
||||
if street != self.repository.get_address().get_parish():
|
||||
self.repository.get_address().set_parish(street)
|
||||
|
||||
city = unicode(self.city.get_text())
|
||||
if city != self.repository.get_address().get_city():
|
||||
self.repository.get_address().set_city(city)
|
||||
|
||||
county = unicode(self.county.get_text())
|
||||
if county != self.repository.get_address().get_county():
|
||||
self.repository.get_address().set_county(county)
|
||||
|
||||
state = unicode(self.state.get_text())
|
||||
if state != self.repository.get_address().get_state():
|
||||
self.repository.get_address().set_state(state)
|
||||
|
||||
postal = unicode(self.postal.get_text())
|
||||
if postal != self.repository.get_address().get_postal_code():
|
||||
self.repository.get_address().set_postal_code(postal)
|
||||
|
||||
country = unicode(self.country.get_text())
|
||||
if country != self.repository.get_address().get_country():
|
||||
self.repository.get_address().set_country(country)
|
||||
|
||||
phone = unicode(self.phone.get_text())
|
||||
if phone != self.repository.get_address().get_phone():
|
||||
self.repository.get_address().set_phone(phone)
|
||||
|
||||
email = unicode(self.email.get_text())
|
||||
if email != self.repository.get_email():
|
||||
self.repository.set_email(email)
|
||||
|
||||
search_url = unicode(self.search_url.get_text())
|
||||
if search_url != self.repository.get_search_url():
|
||||
self.repository.set_search_url(search_url)
|
||||
|
||||
home_url = unicode(self.home_url.get_text())
|
||||
if home_url != self.repository.get_home_url():
|
||||
self.repository.set_home_url(home_url)
|
||||
|
||||
note = unicode(self.notes_buffer.get_text(self.notes_buffer.get_start_iter(),
|
||||
self.notes_buffer.get_end_iter(),False))
|
||||
if note != self.repository.get_note():
|
||||
self.repository.set_note(note)
|
||||
|
||||
format = self.preform.get_active()
|
||||
if format != self.repository.get_note_format():
|
||||
self.repository.set_note_format(format)
|
||||
|
||||
|
||||
trans = self.db.transaction_begin()
|
||||
handle = None
|
||||
if self.repository.get_handle() == None:
|
||||
handle = self.db.add_repository(self.repository,trans)
|
||||
else:
|
||||
self.db.commit_repository(self.repository,trans)
|
||||
handle = self.repository.get_handle()
|
||||
self.db.transaction_commit(trans,_("Edit Repository (%s)") % name)
|
||||
|
||||
|
||||
|
||||
# Handle the source reference list
|
||||
|
||||
# First look for all the references that need to be deleted
|
||||
# These are the ones that are in the original sources list
|
||||
# but no longer in the list model
|
||||
items_deleted = self.repos_source_model.get_deleted_items()
|
||||
|
||||
# Now look for those that need to be added.
|
||||
# These are the ones that are in the list model but not in the
|
||||
# original sources list.
|
||||
items_added = self.repos_source_model.get_added_items()
|
||||
for item in items_added:
|
||||
item[1].set_reference_handle(handle)
|
||||
|
||||
# Finally look for those that need updating
|
||||
# These are in both lists but the repos_ref has changed in the
|
||||
# list model.
|
||||
items_updated = self.repos_source_model.get_update_items()
|
||||
|
||||
all_sources = {}
|
||||
for item in items_deleted + items_added + items_updated:
|
||||
all_sources[item[0]] = 1
|
||||
|
||||
commit_list = []
|
||||
for source_hdl in all_sources.keys():
|
||||
# Fetch existing list of repo_refs
|
||||
source = self.db.get_source_from_handle(source_hdl)
|
||||
original_list = source.get_reporef_list()
|
||||
|
||||
# strip out those from this repository
|
||||
stripped_list = [ repos_ref for repos_ref \
|
||||
in original_list \
|
||||
if repos_ref.get_reference_handle() != self.repository.get_handle() ]
|
||||
# Now add back in those to be added and updated
|
||||
new_list = stripped_list + \
|
||||
[ item[1] for item in items_added ] + \
|
||||
[ item[1] for item in items_updated ]
|
||||
|
||||
|
||||
# Set the new list on the source
|
||||
source.set_reporef_list(new_list)
|
||||
|
||||
# add it to the list of sources to be commited
|
||||
commit_list.append(source)
|
||||
|
||||
|
||||
trans = self.db.transaction_begin()
|
||||
for source in commit_list:
|
||||
self.db.commit_source(source,trans)
|
||||
self.db.transaction_commit(trans,_("Edit Repository (%s)") % name)
|
||||
|
||||
self.close(obj)
|
||||
|
||||
def on_switch_page(self,obj,a,page):
|
||||
##if page == 2 and self.not_loaded:
|
||||
## self.not_loaded = 0
|
||||
## elif page == 3 and self.ref_not_loaded:
|
||||
## self.ref_not_loaded = 0
|
||||
## self.refs_label.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
||||
## gobject.idle_add(self.display_references)
|
||||
## text = unicode(self.notes_buffer.get_text(self.notes_buffer.get_start_iter(),
|
||||
## self.notes_buffer.get_end_iter(),False))
|
||||
## if text:
|
||||
## Utils.bold_label(self.notes_label)
|
||||
## else:
|
||||
## Utils.unbold_label(self.notes_label)
|
||||
pass
|
||||
|
||||
|
||||
class DelReposQuery:
|
||||
def __init__(self,repository,db,sources):
|
||||
self.repository = repository
|
||||
self.db = db
|
||||
self.sources = sources
|
||||
|
||||
def query_response(self):
|
||||
trans = self.db.transaction_begin()
|
||||
|
||||
|
||||
repos_handle_list = [self.repository.get_handle()]
|
||||
|
||||
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)
|
||||
|
||||
self.db.remove_repository(self.repository.get_handle(),trans)
|
||||
self.db.transaction_commit(
|
||||
trans,_("Delete Repository (%s)") % self.repository.get_name())
|
@ -47,6 +47,7 @@ import ImageSelect
|
||||
import ListModel
|
||||
import RelLib
|
||||
import NameDisplay
|
||||
import RepositoryRefEdit
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -54,6 +55,109 @@ import NameDisplay
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
class ReposRefListModel(gtk.ListStore):
|
||||
def __init__(self, source=None):
|
||||
gtk.ListStore.__init__(self,
|
||||
object # repostory reference
|
||||
)
|
||||
self.set_source(source)
|
||||
|
||||
def rebuild(self):
|
||||
"""Clear the list and repopulate from the current source record."""
|
||||
self.clear()
|
||||
|
||||
for repos_ref in self._source.get_reporef_list():
|
||||
self.append([repos_ref])
|
||||
|
||||
def update(self,repos_ref):
|
||||
"""Add the record if it is not already in the list otherwise
|
||||
replace the record with the new one."""
|
||||
|
||||
found = False
|
||||
for val in range(0,len(self)):
|
||||
iter = self.get_iter(val)
|
||||
if repos_ref == self.get_value(iter,0):
|
||||
self.row_changed(self.get_path(iter),iter)
|
||||
found = True
|
||||
break
|
||||
|
||||
if not found:
|
||||
self.append([repos_ref])
|
||||
|
||||
def set_source(self, source):
|
||||
self._source = source
|
||||
self.rebuild()
|
||||
|
||||
class ReposRefListView:
|
||||
|
||||
def __init__(self, model, widget):
|
||||
self._gramps_model = model
|
||||
|
||||
self.database_changed(self._gramps_model.db)
|
||||
self._gramps_model.connect('database-changed', self.database_changed)
|
||||
|
||||
self._widget = widget
|
||||
|
||||
# Create the tree columns
|
||||
self._col1 = gtk.TreeViewColumn(_("Name"))
|
||||
self._col2 = gtk.TreeViewColumn(_("Type"))
|
||||
self._col3 = gtk.TreeViewColumn(_("Note"))
|
||||
|
||||
# Add columns
|
||||
self._widget.append_column(self._col1)
|
||||
self._widget.append_column(self._col2)
|
||||
self._widget.append_column(self._col3)
|
||||
|
||||
# Create cell renders
|
||||
self._col1_cell = gtk.CellRendererText()
|
||||
self._col2_cell = gtk.CellRendererText()
|
||||
self._col3_cell = gtk.CellRendererText()
|
||||
|
||||
# Add cells to view
|
||||
self._col1.pack_start(self._col1_cell, True)
|
||||
self._col2.pack_start(self._col2_cell, True)
|
||||
self._col3.pack_start(self._col3_cell, True)
|
||||
|
||||
# Setup the cell data callback funcs
|
||||
self._col1.set_cell_data_func(self._col1_cell, self.object_name)
|
||||
self._col2.set_cell_data_func(self._col2_cell, self.object_type)
|
||||
self._col3.set_cell_data_func(self._col3_cell, self.object_note)
|
||||
self._widget.set_enable_search(False)
|
||||
|
||||
|
||||
def database_changed(self,db):
|
||||
self._db = db
|
||||
|
||||
# Methods for rendering the cells.
|
||||
|
||||
def object_name(self, column, cell, model, iter, user_data=None):
|
||||
o = model.get_value(iter, 0)
|
||||
repos_hdl = o.get_reference_handle()
|
||||
repos = self._db.get_repository_from_handle(repos_hdl)
|
||||
cell.set_property('text', repos.get_name())
|
||||
|
||||
def object_type(self, column, cell, model, iter, user_data=None):
|
||||
o = model.get_value(iter, 0)
|
||||
repos_hdl = o.get_reference_handle()
|
||||
repos = self._db.get_repository_from_handle(repos_hdl)
|
||||
cell.set_property('text', repos.get_type())
|
||||
|
||||
def object_note(self, column, cell, model, iter, user_data=None):
|
||||
o = model.get_value(iter, 0)
|
||||
cell.set_property('text', o.get_note())
|
||||
|
||||
# proxy methods to provide access to the real widget functions.
|
||||
|
||||
def set_model(self,model=None):
|
||||
self._widget.set_model(model)
|
||||
|
||||
def get_model(self):
|
||||
return self._widget.get_model()
|
||||
|
||||
def get_selection(self):
|
||||
return self._widget.get_selection()
|
||||
|
||||
|
||||
class EditSource:
|
||||
|
||||
def __init__(self,source,db,parent,parent_window=None,readonly=False):
|
||||
@ -122,6 +226,15 @@ class EditSource:
|
||||
self.top_window.get_widget('sel_photo').set_sensitive(mode)
|
||||
self.top_window.get_widget('delete_photo').set_sensitive(mode)
|
||||
|
||||
self.repos_ref_view = ReposRefListView(self.parent,
|
||||
self.top_window.get_widget('repository_ref_list'))
|
||||
self.repos_ref_model = ReposRefListModel(self.source)
|
||||
self.repos_ref_view.set_model(self.repos_ref_model)
|
||||
|
||||
self.top_window.get_widget('add_repos_ref').set_sensitive(mode)
|
||||
self.top_window.get_widget('edit_repos_ref').set_sensitive(mode)
|
||||
self.top_window.get_widget('del_repos_ref').set_sensitive(mode)
|
||||
|
||||
if source.get_note():
|
||||
self.notes_buffer.set_text(source.get_note())
|
||||
Utils.bold_label(self.notes_label)
|
||||
@ -143,6 +256,12 @@ class EditSource:
|
||||
"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,
|
||||
|
||||
"on_add_repos_ref_clicked" : self.on_add_repos_ref_clicked,
|
||||
"on_delete_repos_ref_clicked" : self.on_delete_repos_ref_clicked,
|
||||
"on_edit_repos_ref_clicked" : self.on_edit_repos_ref_clicked,
|
||||
"on_edit_repos_ref_row_activated" : self.on_edit_repos_ref_clicked,
|
||||
|
||||
"on_edit_properties_clicked": self.gallery.popup_change_description,
|
||||
"on_sourceEditor_help_clicked" : self.on_help_clicked,
|
||||
"on_sourceEditor_ok_clicked" : self.on_source_apply_clicked,
|
||||
@ -214,6 +333,29 @@ class EditSource:
|
||||
if node:
|
||||
model.remove(node)
|
||||
|
||||
def on_add_repos_ref_clicked(self,widget):
|
||||
RepositoryRefEdit.RepositoryRefEdit(RelLib.RepoRef(),self.db,
|
||||
self.repos_ref_model.update,self)
|
||||
|
||||
def on_delete_repos_ref_clicked(self,widget):
|
||||
selection = self.repos_ref_view.get_selection()
|
||||
model, iter = selection.get_selected()
|
||||
if iter:
|
||||
model.remove(iter)
|
||||
return
|
||||
|
||||
|
||||
def on_edit_repos_ref_clicked(self,widget,path=None,colm=None,userp=None):
|
||||
selection = self.repos_ref_view.get_selection()
|
||||
model, iter = selection.get_selected()
|
||||
|
||||
if iter:
|
||||
repos_ref = model.get_value(iter,0)
|
||||
|
||||
RepositoryRefEdit.RepositoryRefEdit(repos_ref,self.db,
|
||||
self.repos_ref_model.update,self)
|
||||
|
||||
|
||||
def edit_cb(self, cell, path, new_text, data):
|
||||
node = self.data_model.get_iter(path)
|
||||
self.data_model.set_value(node,data,new_text)
|
||||
@ -398,6 +540,14 @@ class EditSource:
|
||||
new_map[unicode(key)] = unicode(value)
|
||||
if new_map != self.source.get_data_map():
|
||||
self.source.set_data_map(new_map)
|
||||
|
||||
# update repository refs
|
||||
repos_ref_list = []
|
||||
for val in range(0,len(self.repos_ref_model)):
|
||||
iter = self.repos_ref_model.get_iter(val)
|
||||
repos_ref_list.append(self.repos_ref_model.get_value(iter,0))
|
||||
|
||||
self.source.set_reporef_list(repos_ref_list)
|
||||
|
||||
self.gallery_ok = 1
|
||||
|
||||
@ -424,6 +574,10 @@ class EditSource:
|
||||
else:
|
||||
Utils.unbold_label(self.notes_label,self.top)
|
||||
|
||||
def update_repositories(self, repos_ref):
|
||||
"""Make the repository list reflect the change or addition of repos_ref"""
|
||||
pass
|
||||
|
||||
|
||||
class DelSrcQuery:
|
||||
def __init__(self,source,db,the_lists):
|
||||
|
@ -43,7 +43,7 @@ from bsddb import dbshelve, db
|
||||
from RelLib import *
|
||||
from GrampsDbBase import *
|
||||
|
||||
_DBVERSION = 6
|
||||
_DBVERSION = 7
|
||||
|
||||
def find_surname(key,data):
|
||||
return str(data[3].get_surname())
|
||||
@ -57,6 +57,9 @@ def find_fidmap(key,data):
|
||||
def find_eventname(key,data):
|
||||
return str(data[2])
|
||||
|
||||
def find_repository_type(key,data):
|
||||
return str(data[2])
|
||||
|
||||
class GrampsBSDDBCursor(GrampsCursor):
|
||||
|
||||
def __init__(self,source):
|
||||
@ -111,6 +114,9 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
def get_media_cursor(self):
|
||||
return GrampsBSDDBCursor(self.media_map)
|
||||
|
||||
def get_repository_cursor(self):
|
||||
return GrampsBSDDBCursor(self.repository_map)
|
||||
|
||||
def need_upgrade(self):
|
||||
return not self.readonly and self.metadata.get('version',0) < _DBVERSION
|
||||
|
||||
@ -129,13 +135,14 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
|
||||
name = os.path.basename(name)
|
||||
|
||||
self.family_map = self.dbopen(name, "family")
|
||||
self.place_map = self.dbopen(name, "places")
|
||||
self.source_map = self.dbopen(name, "sources")
|
||||
self.media_map = self.dbopen(name, "media")
|
||||
self.event_map = self.dbopen(name, "events")
|
||||
self.metadata = self.dbopen(name, "meta")
|
||||
self.person_map = self.dbopen(name, "person")
|
||||
self.family_map = self.dbopen(name, "family")
|
||||
self.place_map = self.dbopen(name, "places")
|
||||
self.source_map = self.dbopen(name, "sources")
|
||||
self.media_map = self.dbopen(name, "media")
|
||||
self.event_map = self.dbopen(name, "events")
|
||||
self.metadata = self.dbopen(name, "meta")
|
||||
self.person_map = self.dbopen(name, "person")
|
||||
self.repository_map = self.dbopen(name, "repository")
|
||||
|
||||
if self.readonly:
|
||||
openflags = db.DB_RDONLY
|
||||
@ -170,14 +177,24 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
self.oid_trans.set_flags(db.DB_DUP)
|
||||
self.oid_trans.open(name, "oidtrans", db.DB_HASH, flags=openflags)
|
||||
|
||||
self.rid_trans = db.DB(self.env)
|
||||
self.rid_trans.set_flags(db.DB_DUP)
|
||||
self.rid_trans.open(name, "ridtrans", db.DB_HASH, flags=openflags)
|
||||
|
||||
self.eventnames = db.DB(self.env)
|
||||
self.eventnames.set_flags(db.DB_DUP)
|
||||
self.eventnames.open(name, "eventnames", db.DB_HASH, flags=openflags)
|
||||
|
||||
self.repository_types = db.DB(self.env)
|
||||
self.repository_types.set_flags(db.DB_DUP)
|
||||
self.repository_types.open(name, "repostypes", db.DB_HASH, flags=openflags)
|
||||
|
||||
if not self.readonly:
|
||||
self.person_map.associate(self.surnames, find_surname, openflags)
|
||||
self.person_map.associate(self.id_trans, find_idmap, openflags)
|
||||
self.family_map.associate(self.fid_trans, find_idmap, openflags)
|
||||
self.repository_map.associate(self.rid_trans, find_idmap, openflags)
|
||||
self.repository_map.associate(self.repository_types, find_repository_type, openflags)
|
||||
self.place_map.associate(self.pid_trans, find_idmap, openflags)
|
||||
self.media_map.associate(self.oid_trans, find_idmap, openflags)
|
||||
self.source_map.associate(self.sid_trans, find_idmap, openflags)
|
||||
@ -213,6 +230,7 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
self.name_group.close()
|
||||
self.person_map.close()
|
||||
self.family_map.close()
|
||||
self.repository_map.close()
|
||||
self.place_map.close()
|
||||
self.source_map.close()
|
||||
self.media_map.close()
|
||||
@ -223,8 +241,10 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
self.metadata.close()
|
||||
self.surnames.close()
|
||||
self.eventnames.close()
|
||||
self.repository_types.close()
|
||||
self.id_trans.close()
|
||||
self.fid_trans.close()
|
||||
self.rid_trans.close()
|
||||
self.oid_trans.close()
|
||||
self.sid_trans.close()
|
||||
self.pid_trans.close()
|
||||
@ -237,15 +257,16 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
except:
|
||||
pass
|
||||
|
||||
self.person_map = None
|
||||
self.family_map = None
|
||||
self.place_map = None
|
||||
self.source_map = None
|
||||
self.media_map = None
|
||||
self.event_map = None
|
||||
self.surnames = None
|
||||
self.env = None
|
||||
self.metadata = None
|
||||
self.person_map = None
|
||||
self.family_map = None
|
||||
self.repository_map = None
|
||||
self.place_map = None
|
||||
self.source_map = None
|
||||
self.media_map = None
|
||||
self.event_map = None
|
||||
self.surnames = None
|
||||
self.env = None
|
||||
self.metadata = None
|
||||
|
||||
def _del_person(self,handle):
|
||||
self.person_map.delete(str(handle))
|
||||
@ -253,6 +274,9 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
def _del_source(self,handle):
|
||||
self.source_map.delete(str(handle))
|
||||
|
||||
def _del_repository(self,handle):
|
||||
self.repository_map.delete(str(handle))
|
||||
|
||||
def _del_place(self,handle):
|
||||
self.place_map.delete(str(handle))
|
||||
|
||||
@ -292,6 +316,16 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
vals.sort()
|
||||
return vals
|
||||
|
||||
def get_repository_type_list(self):
|
||||
repos_types = self.repository_types.keys()
|
||||
a = {}
|
||||
for repos_type in repos_types:
|
||||
|
||||
a[unicode(repos_type)] = 1
|
||||
vals = a.keys()
|
||||
vals.sort()
|
||||
return vals
|
||||
|
||||
def remove_person(self,handle,transaction):
|
||||
if not self.readonly and handle and str(handle) in self.person_map:
|
||||
person = self.get_person_from_handle(handle)
|
||||
@ -309,6 +343,14 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
self.emit('source-delete',([handle],))
|
||||
self.source_map.delete(str(handle))
|
||||
|
||||
def remove_repository(self,handle,transaction):
|
||||
if not self.readonly and handle and str(handle) in self.repository_map:
|
||||
if transaction != None:
|
||||
old_data = self.repository_map.get(str(handle))
|
||||
transaction.add(REPOSITORY_KEY,handle,old_data)
|
||||
self.emit('repository-delete',([handle],))
|
||||
self.repository_map.delete(str(handle))
|
||||
|
||||
def remove_family(self,handle,transaction):
|
||||
if not self.readonly and handle and str(handle) in self.family_map:
|
||||
if transaction != None:
|
||||
@ -388,6 +430,18 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_repository_from_gramps_id(self,val):
|
||||
"""finds a Repository in the database from the passed gramps' ID.
|
||||
If no such Repository exists, a new Repository is added to the database."""
|
||||
|
||||
data = self.rid_trans.get(str(val))
|
||||
if data:
|
||||
repository = Repository()
|
||||
repository.unserialize(cPickle.loads(data))
|
||||
return repository
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_object_from_gramps_id(self,val):
|
||||
"""finds a MediaObject in the database from the passed gramps' ID.
|
||||
If no such MediaObject exists, a new Person is added to the database."""
|
||||
@ -405,6 +459,8 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
self.family_map.sync()
|
||||
self.place_map.sync()
|
||||
self.source_map.sync()
|
||||
self.repository_map.sync()
|
||||
self.repository_types.sync()
|
||||
self.media_map.sync()
|
||||
self.event_map.sync()
|
||||
self.metadata.sync()
|
||||
@ -415,6 +471,7 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
self.fid_trans.sync()
|
||||
self.pid_trans.sync()
|
||||
self.sid_trans.sync()
|
||||
self.rid_trans.sync()
|
||||
self.oid_trans.sync()
|
||||
self.eventnames.sync()
|
||||
self.undodb.sync()
|
||||
@ -435,6 +492,8 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
self.upgrade_5()
|
||||
if version < 6:
|
||||
self.upgrade_6()
|
||||
if version < 7:
|
||||
self.upgrade_7()
|
||||
self.metadata['version'] = _DBVERSION
|
||||
print 'Successfully finished all upgrades'
|
||||
|
||||
@ -752,3 +811,19 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
order.append(val)
|
||||
self.set_media_column_order(order)
|
||||
|
||||
def upgrade_7(self):
|
||||
print "Upgrading to DB version 7"
|
||||
trans = Transaction("",self)
|
||||
trans.set_batch(True)
|
||||
# Change every source to have reporef_list
|
||||
cursor = self.get_source_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
handle,info = data
|
||||
source = Source()
|
||||
(source.handle, source.gramps_id, source.title, source.author,
|
||||
source.pubinfo, source.note, source.media_list,
|
||||
source.abbrev, source.change, source.datamap) = info
|
||||
self.commit_source(source,trans)
|
||||
data = cursor.next()
|
||||
cursor.close()
|
||||
|
@ -61,14 +61,17 @@ SOURCE_KEY = 2
|
||||
EVENT_KEY = 3
|
||||
MEDIA_KEY = 4
|
||||
PLACE_KEY = 5
|
||||
REPOSITORY_KEY = 6
|
||||
|
||||
PERSON_COL_KEY = 'columns'
|
||||
CHILD_COL_KEY = 'child_columns'
|
||||
PLACE_COL_KEY = 'place_columns'
|
||||
SOURCE_COL_KEY = 'source_columns'
|
||||
MEDIA_COL_KEY = 'media_columns'
|
||||
PERSON_COL_KEY = 'columns'
|
||||
CHILD_COL_KEY = 'child_columns'
|
||||
PLACE_COL_KEY = 'place_columns'
|
||||
SOURCE_COL_KEY = 'source_columns'
|
||||
MEDIA_COL_KEY = 'media_columns'
|
||||
REPOSITORY_COL_KEY = 'repository_columns'
|
||||
|
||||
_sigbase = ('person', 'family', 'source', 'event', 'media', 'place')
|
||||
_sigbase = ('person', 'family', 'source', 'event',
|
||||
'media', 'place', 'repository')
|
||||
|
||||
class GrampsCursor:
|
||||
"""
|
||||
@ -145,6 +148,10 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
'event-update' : (list,),
|
||||
'event-delete' : (list,),
|
||||
'event-rebuild' : None,
|
||||
'repository-add' : (list,),
|
||||
'repository-update' : (list,),
|
||||
'repository-delete' : (list,),
|
||||
'repository-rebuild' : None,
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
@ -164,6 +171,7 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
self.fmap_index = 0
|
||||
self.lmap_index = 0
|
||||
self.omap_index = 0
|
||||
self.rmap_index = 0
|
||||
|
||||
self.set_person_id_prefix(GrampsKeys.get_person_id_prefix())
|
||||
self.set_object_id_prefix(GrampsKeys.get_object_id_prefix())
|
||||
@ -171,6 +179,7 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
self.set_source_id_prefix(GrampsKeys.get_source_id_prefix())
|
||||
self.set_place_id_prefix(GrampsKeys.get_place_id_prefix())
|
||||
self.set_event_id_prefix(GrampsKeys.get_event_id_prefix())
|
||||
self.set_repository_id_prefix(GrampsKeys.get_repository_id_prefix())
|
||||
|
||||
self.open = 0
|
||||
self.genderStats = GenderStats()
|
||||
@ -181,11 +190,13 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
self.pid_trans = None
|
||||
self.sid_trans = None
|
||||
self.oid_trans = None
|
||||
self.rid_trans = None
|
||||
self.env = None
|
||||
self.person_map = None
|
||||
self.family_map = None
|
||||
self.place_map = None
|
||||
self.source_map = None
|
||||
self.repository_map = None
|
||||
self.media_map = None
|
||||
self.event_map = None
|
||||
self.eventnames = None
|
||||
@ -229,6 +240,9 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
def get_media_cursor(self):
|
||||
assert False, "Needs to be overridden in the derived class"
|
||||
|
||||
def get_repository_cursor(self):
|
||||
assert False, "Needs to be overridden in the derived class"
|
||||
|
||||
def load(self,name,callback):
|
||||
"""
|
||||
Opens the specified database. The method needs to be overridden
|
||||
@ -263,6 +277,7 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
self.emit('source-rebuild')
|
||||
self.emit('media-rebuild')
|
||||
self.emit('event-rebuild')
|
||||
self.emit('repository-rebuild')
|
||||
|
||||
def _commit_base(self, obj, data_map, key, update_list, add_list,
|
||||
transaction, change_time):
|
||||
@ -342,6 +357,15 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
transaction.family_update, transaction.family_add,
|
||||
transaction, change_time)
|
||||
|
||||
def commit_repository(self,repository,transaction,change_time=None):
|
||||
"""
|
||||
Commits the specified Repository to the database, storing the changes
|
||||
as part of the transaction.
|
||||
"""
|
||||
self._commit_base(repository, self.repository_map, REPOSITORY_KEY,
|
||||
transaction.repository_update, transaction.repository_add,
|
||||
transaction, change_time)
|
||||
|
||||
def find_next_person_gramps_id(self):
|
||||
"""
|
||||
Returns the next available GRAMPS' ID for a Person object based
|
||||
@ -411,6 +435,18 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
self.fmap_index += 1
|
||||
return index
|
||||
|
||||
def find_next_repository_gramps_id(self):
|
||||
"""
|
||||
Returns the next available GRAMPS' ID for a Respository object based
|
||||
off the repository ID prefix.
|
||||
"""
|
||||
index = self.rprefix % self.rmap_index
|
||||
while self.rid_trans.get(str(index)):
|
||||
self.rmap_index += 1
|
||||
index = self.rprefix % self.rmap_index
|
||||
self.rmap_index += 1
|
||||
return index
|
||||
|
||||
def _get_from_handle(self, handle, class_type, data_map):
|
||||
data = data_map.get(str(handle))
|
||||
if data:
|
||||
@ -461,6 +497,13 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
"""
|
||||
return self._get_from_handle(handle,Family,self.family_map)
|
||||
|
||||
def get_repository_from_handle(self,handle):
|
||||
"""
|
||||
Finds a Repository in the database from the passed gramps' ID.
|
||||
If no such Repository exists, None is returned.
|
||||
"""
|
||||
return self._get_from_handle(handle,Repository,self.repository_map)
|
||||
|
||||
def _find_from_handle(self,handle,transaction,class_type,dmap,add_func):
|
||||
obj = class_type()
|
||||
handle = str(handle)
|
||||
@ -519,6 +562,14 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
return self._find_from_handle(handle,transaction,Family,
|
||||
self.family_map,self.add_family)
|
||||
|
||||
def find_repository_from_handle(self,handle,transaction):
|
||||
"""
|
||||
Finds a Repository in the database from the passed gramps' ID.
|
||||
If no such Repository exists, a new Repository is added to the database.
|
||||
"""
|
||||
return self._find_from_handle(handle,transaction,Repository,
|
||||
self.repository_map,self.add_repository)
|
||||
|
||||
def get_person_from_gramps_id(self,val):
|
||||
"""
|
||||
Finds a Person in the database from the passed GRAMPS ID.
|
||||
@ -561,6 +612,14 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
"""
|
||||
assert False, "Needs to be overridden in the derived class"
|
||||
|
||||
def get_repository_from_gramps_id(self,val):
|
||||
"""finds a Repository in the database from the passed gramps' ID.
|
||||
If no such Repository exists, a new Repository is added to the database.
|
||||
|
||||
Needs to be overridden by the derrived class.
|
||||
"""
|
||||
assert False, "Needs to be overridden in the derived class"
|
||||
|
||||
def add_person(self,person,transaction):
|
||||
"""
|
||||
Adds a Person to the database, assigning internal IDs if they have
|
||||
@ -627,6 +686,15 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
self.find_next_object_gramps_id,
|
||||
self.commit_media_object)
|
||||
|
||||
def add_repository(self,obj,transaction):
|
||||
"""
|
||||
Adds a Repository to the database, assigning internal IDs if they have
|
||||
not already been defined.
|
||||
"""
|
||||
return self._add_object(obj,transaction,
|
||||
self.find_next_repository_gramps_id,
|
||||
self.commit_repository)
|
||||
|
||||
def get_name_group_mapping(self,name):
|
||||
"""
|
||||
Returns the default grouping name for a surname
|
||||
@ -737,6 +805,15 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
return self.family_map.keys()
|
||||
return []
|
||||
|
||||
def get_repository_handles(self):
|
||||
"""
|
||||
Returns a list of database handles, one handle for each Repository in
|
||||
the database.
|
||||
"""
|
||||
if self.repository_map:
|
||||
return self.repository_map.keys()
|
||||
return []
|
||||
|
||||
def set_person_id_prefix(self,val):
|
||||
"""
|
||||
Sets the naming template for GRAMPS Person ID values. The string is
|
||||
@ -826,7 +903,22 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
self.eprefix = val + "%d"
|
||||
else:
|
||||
self.eprefix = "E%04d"
|
||||
|
||||
|
||||
def set_repository_id_prefix(self,val):
|
||||
"""
|
||||
Sets the naming template for GRAMPS Repository ID values. The string is
|
||||
expected to be in the form of a simple text string, or in a format
|
||||
that contains a C/Python style format string using %d, such as E%d
|
||||
or E%04d.
|
||||
"""
|
||||
if val:
|
||||
if _id_reg.search(val):
|
||||
self.rprefix = val
|
||||
else:
|
||||
self.rprefix = val + "%d"
|
||||
else:
|
||||
self.rprefix = "R%04d"
|
||||
|
||||
def transaction_begin(self,msg=""):
|
||||
"""
|
||||
Creates a new Transaction tied to the current UNDO database. The
|
||||
@ -848,19 +940,21 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
else:
|
||||
self.translist[self.undoindex] = transaction
|
||||
|
||||
person_add = self._do_commit(transaction.person_add,self.person_map)
|
||||
family_add = self._do_commit(transaction.family_add,self.family_map)
|
||||
source_add = self._do_commit(transaction.source_add,self.source_map)
|
||||
place_add = self._do_commit(transaction.place_add,self.place_map)
|
||||
media_add = self._do_commit(transaction.media_add,self.media_map)
|
||||
event_add = self._do_commit(transaction.event_add,self.event_map)
|
||||
person_add = self._do_commit(transaction.person_add,self.person_map)
|
||||
family_add = self._do_commit(transaction.family_add,self.family_map)
|
||||
source_add = self._do_commit(transaction.source_add,self.source_map)
|
||||
place_add = self._do_commit(transaction.place_add,self.place_map)
|
||||
media_add = self._do_commit(transaction.media_add,self.media_map)
|
||||
event_add = self._do_commit(transaction.event_add,self.event_map)
|
||||
repository_add = self._do_commit(transaction.repository_add,self.repository_map)
|
||||
|
||||
person_upd = self._do_commit(transaction.person_update,self.person_map)
|
||||
family_upd = self._do_commit(transaction.family_update,self.family_map)
|
||||
source_upd = self._do_commit(transaction.source_update,self.source_map)
|
||||
place_upd = self._do_commit(transaction.place_update,self.place_map)
|
||||
media_upd = self._do_commit(transaction.media_update,self.media_map)
|
||||
event_upd = self._do_commit(transaction.event_update,self.event_map)
|
||||
person_upd = self._do_commit(transaction.person_update,self.person_map)
|
||||
family_upd = self._do_commit(transaction.family_update,self.family_map)
|
||||
source_upd = self._do_commit(transaction.source_update,self.source_map)
|
||||
place_upd = self._do_commit(transaction.place_update,self.place_map)
|
||||
media_upd = self._do_commit(transaction.media_update,self.media_map)
|
||||
event_upd = self._do_commit(transaction.event_update,self.event_map)
|
||||
repository_upd = self._do_commit(transaction.repository_update,self.repository_map)
|
||||
|
||||
self._do_emit('person', person_add, person_upd, transaction.person_del)
|
||||
self._do_emit('family', family_add, family_upd, transaction.family_del)
|
||||
@ -868,13 +962,15 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
self._do_emit('source', source_add, source_upd, transaction.source_del)
|
||||
self._do_emit('place', place_add, place_upd, transaction.place_del)
|
||||
self._do_emit('media', media_add, media_upd, transaction.media_del)
|
||||
self._do_emit('repository', repository_add, repository_upd, transaction.repository_del)
|
||||
|
||||
self._do_del(transaction.person_del, self._del_person)
|
||||
self._do_del(transaction.family_del, self._del_family)
|
||||
self._do_del(transaction.place_del, self._del_place)
|
||||
self._do_del(transaction.source_del, self._del_source)
|
||||
self._do_del(transaction.event_del, self._del_event)
|
||||
self._do_del(transaction.media_del, self._del_media)
|
||||
self._do_del(transaction.person_del, self._del_person)
|
||||
self._do_del(transaction.family_del, self._del_family)
|
||||
self._do_del(transaction.place_del, self._del_place)
|
||||
self._do_del(transaction.source_del, self._del_source)
|
||||
self._do_del(transaction.event_del, self._del_event)
|
||||
self._do_del(transaction.media_del, self._del_media)
|
||||
self._do_del(transaction.repository_del, self._del_repository)
|
||||
|
||||
if self.undo_callback:
|
||||
self.undo_callback(_("_Undo %s") % transaction.get_description())
|
||||
@ -1059,7 +1155,7 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
handle = str(handle)
|
||||
if not trans.batch:
|
||||
old_data = dmap.get(handle)
|
||||
transaction.add(key,handle,old_data)
|
||||
trans.add(key,handle,old_data)
|
||||
del_list.append(handle)
|
||||
|
||||
def remove_source(self,handle,transaction):
|
||||
@ -1107,6 +1203,15 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
self._do_remove_object(handle,transaction,self.family_map,
|
||||
FAMILY_KEY, transaction.family_del)
|
||||
|
||||
def remove_repository(self,handle,transaction):
|
||||
"""
|
||||
Removes the Repository specified by the database handle from the
|
||||
database, preserving the change in the passed transaction. This
|
||||
method must be overridden in the derived class.
|
||||
"""
|
||||
self._do_remove_object(handle,transaction,self.repository_map,
|
||||
REPOSITORY_KEY, transaction.repository_del)
|
||||
|
||||
def has_person_handle(self,handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Person database.
|
||||
@ -1125,6 +1230,12 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
"""
|
||||
return self.media_map.has_key(str(handle)) != None
|
||||
|
||||
def has_repository_handle(self,handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Repository database.
|
||||
"""
|
||||
return self.repository_map.has_key(str(handle)) != False
|
||||
|
||||
def _sortbyname(self,f,s):
|
||||
n1 = self.person_map.get(str(f))[3].sname
|
||||
n2 = self.person_map.get(str(s))[3].sname
|
||||
@ -1183,6 +1294,13 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
"""
|
||||
self._set_column_order(col_list,MEDIA_COL_KEY)
|
||||
|
||||
def set_repository_column_order(self,list):
|
||||
"""
|
||||
Stores the Repository display common information in the
|
||||
database's metadata.
|
||||
"""
|
||||
self._set_column_order(col_list,REPOSITORY_COL_KEY)
|
||||
|
||||
def _get_column_order(self,name,default):
|
||||
if self.metadata == None:
|
||||
return default
|
||||
@ -1233,6 +1351,14 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
|
||||
default = [(1,1),(0,5),(0,6),(1,2),(1,3),(0,4)]
|
||||
return self._get_column_order(MEDIA_COL_KEY,default)
|
||||
|
||||
def get_repository_column_order(self):
|
||||
"""
|
||||
Returns the Repository display common information stored in the
|
||||
database's metadata.
|
||||
"""
|
||||
default = [(1,1),(0,5),(0,6),(1,2),(1,3),(0,4)]
|
||||
return self._get_column_order(REPOSITORY_COL_KEY,default)
|
||||
|
||||
class Transaction:
|
||||
"""
|
||||
Defines a group of database commits that define a single logical
|
||||
@ -1276,6 +1402,11 @@ class Transaction:
|
||||
self.place_del = []
|
||||
self.place_update = []
|
||||
|
||||
self.repository_add = []
|
||||
self.repository_del = []
|
||||
self.repository_update = []
|
||||
|
||||
|
||||
def set_batch(self,batch):
|
||||
self.batch = batch
|
||||
|
||||
|
@ -251,6 +251,12 @@ def get_family_id_prefix():
|
||||
def save_fprefix(val):
|
||||
set_string_as_id_prefix("/apps/gramps/preferences/fprefix",val)
|
||||
|
||||
def get_repository_id_prefix():
|
||||
return get_string("/apps/gramps/preferences/rprefix")
|
||||
|
||||
def save_rprefix(val):
|
||||
set_string_as_id_prefix("/apps/gramps/preferences/rprefix",val)
|
||||
|
||||
def get_paper_preference():
|
||||
return get_string("/apps/gramps/preferences/paper-preference")
|
||||
|
||||
|
@ -71,22 +71,25 @@ class GrampsInMemDB(GrampsDbBase):
|
||||
def __init__(self):
|
||||
"""creates a new GrampsDB"""
|
||||
GrampsDbBase.__init__(self)
|
||||
self.person_map = {}
|
||||
self.name_group = {}
|
||||
self.family_map = {}
|
||||
self.place_map = {}
|
||||
self.source_map = {}
|
||||
self.media_map = {}
|
||||
self.event_map = {}
|
||||
self.metadata = {}
|
||||
self.filename = ""
|
||||
self.id_trans = {}
|
||||
self.pid_trans = {}
|
||||
self.fid_trans = {}
|
||||
self.sid_trans = {}
|
||||
self.oid_trans = {}
|
||||
self.eventnames = {}
|
||||
self.undodb = []
|
||||
self.person_map = {}
|
||||
self.name_group = {}
|
||||
self.family_map = {}
|
||||
self.place_map = {}
|
||||
self.source_map = {}
|
||||
self.repository_map = {}
|
||||
self.media_map = {}
|
||||
self.event_map = {}
|
||||
self.metadata = {}
|
||||
self.filename = ""
|
||||
self.id_trans = {}
|
||||
self.pid_trans = {}
|
||||
self.fid_trans = {}
|
||||
self.sid_trans = {}
|
||||
self.rid_trans = {}
|
||||
self.oid_trans = {}
|
||||
self.eventnames = {}
|
||||
self.repository_types = {}
|
||||
self.undodb = []
|
||||
|
||||
def load(self,name,callback,mode="w"):
|
||||
self.undolog = "%s.log" % name
|
||||
@ -107,6 +110,9 @@ class GrampsInMemDB(GrampsDbBase):
|
||||
def get_source_cursor(self):
|
||||
return GrampsInMemCursor(self.source_map)
|
||||
|
||||
def get_repository_cursor(self):
|
||||
return GrampsInMemCursor(self.repository_map)
|
||||
|
||||
def get_media_cursor(self):
|
||||
return GrampsInMemCursor(self.media_map)
|
||||
|
||||
@ -145,6 +151,15 @@ class GrampsInMemDB(GrampsDbBase):
|
||||
vals.sort()
|
||||
return vals
|
||||
|
||||
def get_repository_type_list(self):
|
||||
repos_types = self.repository_types.keys()
|
||||
a = {}
|
||||
for repos_type in repos_types:
|
||||
a[unicode(repos_type)] = 1
|
||||
vals = a.keys()
|
||||
vals.sort()
|
||||
return vals
|
||||
|
||||
def _del_person(self,handle):
|
||||
del self.id_trans[person.get_gramps_id()]
|
||||
del self.person_map[handle]
|
||||
@ -153,6 +168,10 @@ class GrampsInMemDB(GrampsDbBase):
|
||||
del self.sid_trans[source.get_gramps_id()]
|
||||
del self.source_map[str(handle)]
|
||||
|
||||
def _del_repository(self,handle):
|
||||
del self.rid_trans[repository.get_gramps_id()]
|
||||
del self.repository_map[str(handle)]
|
||||
|
||||
def _del_place(self,handle):
|
||||
del self.pid_trans[place.get_gramps_id()]
|
||||
del self.place_map[str(handle)]
|
||||
@ -203,6 +222,13 @@ class GrampsInMemDB(GrampsDbBase):
|
||||
self.sid_trans[gid] = source.get_handle()
|
||||
GrampsDbBase.commit_source(self,source,transaction,change_time)
|
||||
|
||||
def commit_repository(self,repository,transaction,change_time=None):
|
||||
if self.readonly or not repository.get_handle():
|
||||
return
|
||||
gid = repository.get_gramps_id()
|
||||
self.rid_trans[gid] = repository.get_handle()
|
||||
GrampsDbBase.commit_repository(self,repository,transaction,change_time)
|
||||
|
||||
def get_person_from_gramps_id(self,val):
|
||||
handle = self.id_trans.get(str(val))
|
||||
if handle:
|
||||
@ -243,6 +269,16 @@ class GrampsInMemDB(GrampsDbBase):
|
||||
return source
|
||||
return None
|
||||
|
||||
def get_repository_from_gramps_id(self,val):
|
||||
handle = self.rid_trans.get(str(val))
|
||||
if handle:
|
||||
data = self.repository_map[handle]
|
||||
if data:
|
||||
repository = Repository()
|
||||
repository.unserialize(data)
|
||||
return repository
|
||||
return None
|
||||
|
||||
def get_object_from_gramps_id(self,val):
|
||||
handle = self.oid_trans.get(str(val))
|
||||
if handle:
|
||||
|
@ -47,6 +47,7 @@ _ini_schema = {
|
||||
'preferences/oprefix' : 'O%04d',
|
||||
'preferences/pprefix' : 'P%04d',
|
||||
'preferences/sprefix' : 'S%04d',
|
||||
'preferences/rprefix' : 'R%04d',
|
||||
'preferences/goutput-preference' : 'No default format',
|
||||
'preferences/output-preference' : 'No default format',
|
||||
'preferences/paper-preference' : 'Letter',
|
||||
@ -400,6 +401,12 @@ def get_family_id_prefix():
|
||||
def save_fprefix(val):
|
||||
set_string_as_id_prefix("preferences", "fprefix",val)
|
||||
|
||||
def get_repository_id_prefix():
|
||||
return get_string("preferences", "rprefix")
|
||||
|
||||
def save_rprefix(val):
|
||||
set_string_as_id_prefix("preferences", "rprefix",val)
|
||||
|
||||
def get_paper_preference():
|
||||
return get_string("preferences", "paper-preference")
|
||||
|
||||
@ -624,6 +631,8 @@ if __name__ == "__main__":
|
||||
save_pprefix(val)
|
||||
print "get_family_id_prefix()", get_family_id_prefix()
|
||||
save_fprefix(val)
|
||||
print "get_repository_id_prefix()", get_repository_id_prefix()
|
||||
save_rprefix(val)
|
||||
print "get_paper_preference()", get_paper_preference()
|
||||
save_paper_preference(val)
|
||||
print "get_output_preference()", get_output_preference()
|
||||
|
@ -66,7 +66,7 @@ gdir_PYTHON = \
|
||||
ImageSelect.py\
|
||||
ImgManip.py\
|
||||
latin_ansel.py\
|
||||
latin_utf8.py\
|
||||
latin_utf8.py\
|
||||
ListBox.py\
|
||||
ListModel.py\
|
||||
LocEdit.py\
|
||||
|
@ -2867,12 +2867,13 @@ class Source(PrimaryObject,MediaBase,NoteBase):
|
||||
self.note = Note()
|
||||
self.datamap = {}
|
||||
self.abbrev = ""
|
||||
self.reporef_list = []
|
||||
|
||||
def serialize(self):
|
||||
return (self.handle, self.gramps_id, unicode(self.title),
|
||||
unicode(self.author), unicode(self.pubinfo),
|
||||
self.note, self.media_list, unicode(self.abbrev),
|
||||
self.change,self.datamap)
|
||||
self.change,self.datamap,self.reporef_list)
|
||||
|
||||
def unserialize(self,data):
|
||||
"""
|
||||
@ -2881,7 +2882,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
|
||||
"""
|
||||
(self.handle, self.gramps_id, self.title, self.author,
|
||||
self.pubinfo, self.note, self.media_list,
|
||||
self.abbrev, self.change, self.datamap) = data
|
||||
self.abbrev, self.change, self.datamap, self.reporef_list) = data
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
@ -2899,7 +2900,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
|
||||
@return: Returns the list of child objects that may carry textual data.
|
||||
@rtype: list
|
||||
"""
|
||||
check_list = self.media_list
|
||||
check_list = self.media_list + self.reporef_list
|
||||
if self.note:
|
||||
check_list.append(self.note)
|
||||
return check_list
|
||||
@ -3017,6 +3018,72 @@ class Source(PrimaryObject,MediaBase,NoteBase):
|
||||
"""returns the title abbreviation of the Source"""
|
||||
return self.abbrev
|
||||
|
||||
def add_repo_reference(self,repo_ref):
|
||||
"""
|
||||
Adds a L{RepoRef} instance to the Source's reporef list.
|
||||
|
||||
@param repo_ref: L{RepoRef} instance to be added to the object's reporef list.
|
||||
@type repo_ref: L{RepoRef}
|
||||
"""
|
||||
self.reporef_list.append(repo_ref)
|
||||
|
||||
def get_reporef_list(self):
|
||||
"""
|
||||
Returns the list of L{RepoRef} instances associated with the Source.
|
||||
|
||||
@returns: list of L{RepoRef} instances associated with the Source
|
||||
@rtype: list
|
||||
"""
|
||||
return self.reporef_list
|
||||
|
||||
def set_reporef_list(self,reporef_list):
|
||||
"""
|
||||
Sets the list of L{RepoRef} instances associated with the Source.
|
||||
It replaces the previous list.
|
||||
|
||||
@param reporef_list: list of L{RepoRef} instances to be assigned to the Source.
|
||||
@type reporef_list: list
|
||||
"""
|
||||
self.reporef_list = reporef_list
|
||||
|
||||
def has_repo_reference(self,repo_handle):
|
||||
"""
|
||||
Returns True if the Source has reference to this Repository handle.
|
||||
|
||||
@param repo_handle: The Repository handle to be checked.
|
||||
@type repo_handle: str
|
||||
@return: Returns whether the Source has reference to this Repository handle.
|
||||
@rtype: bool
|
||||
"""
|
||||
return repo_handle in [repo_ref.ref for repo_ref in self.reporef_list]
|
||||
|
||||
def remove_repo_references(self,repo_handle_list):
|
||||
"""
|
||||
Removes references to all Repository handles in the list.
|
||||
|
||||
@param repo_handle_list: The list of Repository handles to be removed.
|
||||
@type repo_handle_list: list
|
||||
"""
|
||||
new_reporef_list = [ repo_ref for repo_ref in self.reporef_list \
|
||||
if repo_ref.ref not in repo_handle_list ]
|
||||
self.reporef_list = new_reporef_list
|
||||
|
||||
def replace_repo_references(self,old_handle,new_handle):
|
||||
"""
|
||||
Replaces all references to old Repository handle with the new handle.
|
||||
|
||||
@param old_handle: The Repository handle to be replaced.
|
||||
@type old_handle: str
|
||||
@param new_handle: The Repository handle to replace the old one with.
|
||||
@type new_handle: str
|
||||
"""
|
||||
refs_list = [ repo_ref.ref for repo_ref in self.reporef_list ]
|
||||
n_replace = refs_list.count(old_handle)
|
||||
for ix_replace in xrange(n_replace):
|
||||
ix = refs_list.index(old_handle)
|
||||
self.reporef_list[ix].ref = new_handle
|
||||
refs_list.pop(ix)
|
||||
|
||||
class LdsOrd(SourceNote,DateBase,PlaceBase):
|
||||
"""
|
||||
Class that contains information about LDS Ordinances. LDS
|
||||
@ -4316,3 +4383,359 @@ class GenderStats:
|
||||
return Person.FEMALE
|
||||
|
||||
return Person.UNKNOWN
|
||||
|
||||
class RepoRef(NoteBase):
|
||||
"""
|
||||
Repository reference class.
|
||||
"""
|
||||
MEDIA_TYPE_CUSTOM = 0
|
||||
MEDIA_TYPE_AUDIO = 1
|
||||
MEDIA_TYPE_BOOK = 2
|
||||
MEDIA_TYPE_CARD = 3
|
||||
MEDIA_TYPE_ELECTRONIC = 4
|
||||
MEDIA_TYPE_FICHE = 5
|
||||
MEDIA_TYPE_FILM = 6
|
||||
MEDIA_TYPE_MAGAZINE = 7
|
||||
MEDIA_TYPE_MANUSCRIPT = 8
|
||||
MEDIA_TYPE_MAP = 9
|
||||
MEDIA_TYPE_NEWSPAPER = 10
|
||||
MEDIA_TYPE_PHOTO = 11
|
||||
MEDIA_TYPE_THOMBSTOBE = 12
|
||||
MEDIA_TYPE_VIDEO = 13
|
||||
|
||||
def __init__(self,source=None):
|
||||
NoteBase.__init__(self)
|
||||
if source:
|
||||
self.ref = source.ref
|
||||
self.call_number = source.call_number
|
||||
self.media_type_int = source.media_type_int
|
||||
self.media_type_str = source.media_type_str
|
||||
else:
|
||||
self.ref = None
|
||||
self.call_number = ""
|
||||
self.media_type_int = self.MEDIA_TYPE_CUSTOM
|
||||
self.media_type_str = ""
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
||||
@return: Returns the list of all textual attributes of the object.
|
||||
@rtype: list
|
||||
"""
|
||||
return [self.call_number,self.media_type_str]
|
||||
|
||||
def get_text_data_child_list(self):
|
||||
"""
|
||||
Returns the list of child objects that may carry textual data.
|
||||
|
||||
@return: Returns the list of child objects that may carry textual data.
|
||||
@rtype: list
|
||||
"""
|
||||
if self.note:
|
||||
return [self.note]
|
||||
return []
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
Returns the list of (classname,handle) tuples for all directly
|
||||
referenced primary objects.
|
||||
|
||||
@return: Returns the list of (classname,handle) tuples for referenced objects.
|
||||
@rtype: list
|
||||
"""
|
||||
if self.ref:
|
||||
return [('Repository',self.ref)]
|
||||
else:
|
||||
return []
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
Returns the list of child objects which may, directly or through
|
||||
their children, reference primary objects..
|
||||
|
||||
@return: Returns the list of objects refereincing primary objects.
|
||||
@rtype: list
|
||||
"""
|
||||
return []
|
||||
|
||||
def set_reference_handle(self,ref):
|
||||
self.ref = ref
|
||||
|
||||
def get_reference_handle(self):
|
||||
return self.ref
|
||||
|
||||
def set_call_number(self,number):
|
||||
self.call_number = number
|
||||
|
||||
def get_call_number(self):
|
||||
return self.call_number
|
||||
|
||||
def get_media_type(self):
|
||||
if self.media_type_int == self.MEDIA_TYPE_CUSTOM:
|
||||
return self.media_type_str
|
||||
else:
|
||||
return self.media_type_int
|
||||
|
||||
def set_media_type(self,media_type):
|
||||
if type(media_type) == int:
|
||||
self.media_type_int = media_type
|
||||
self.media_type_str = ""
|
||||
else:
|
||||
self.media_type_int = self.MEDIA_TYPE_CUSTOM
|
||||
self.media_type_str = media_type
|
||||
|
||||
class Repository(PrimaryObject,NoteBase):
|
||||
"""A location where collections of Sources are found"""
|
||||
|
||||
def __init__(self):
|
||||
"""creates a new Repository instance"""
|
||||
PrimaryObject.__init__(self)
|
||||
NoteBase.__init__(self)
|
||||
self.type = ""
|
||||
self.name = ""
|
||||
self.address = Location()
|
||||
self.email = ""
|
||||
self.search_url = ""
|
||||
self.home_url = ""
|
||||
self.note = Note()
|
||||
|
||||
def serialize(self):
|
||||
return (self.handle, self.gramps_id, unicode(self.type),
|
||||
unicode(self.name), self.address,
|
||||
unicode(self.email),
|
||||
unicode(self.search_url), unicode(self.home_url),
|
||||
self.note)
|
||||
|
||||
def unserialize(self,data):
|
||||
"""
|
||||
Converts the data held in a tuple created by the serialize method
|
||||
back into the data in an Repository structure.
|
||||
"""
|
||||
(self.handle, self.gramps_id, self.type, self.name,
|
||||
self.address, self.email,
|
||||
self.search_url, self.home_url, self.note) = data
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
||||
@return: Returns the list of all textual attributes of the object.
|
||||
@rtype: list
|
||||
"""
|
||||
return [self.name,self.email,self.search_url,self.home_url]
|
||||
|
||||
def get_text_data_child_list(self):
|
||||
"""
|
||||
Returns the list of child objects that may carry textual data.
|
||||
|
||||
@return: Returns the list of child objects that may carry textual data.
|
||||
@rtype: list
|
||||
"""
|
||||
check_list = [self.address]
|
||||
if self.note:
|
||||
check_list.append(self.note)
|
||||
return check_list
|
||||
|
||||
def has_source_reference(self,src_handle) :
|
||||
"""
|
||||
Returns True if any of the child objects has reference
|
||||
to this source handle.
|
||||
|
||||
@param src_handle: The source handle to be checked.
|
||||
@type src_handle: str
|
||||
@return: Returns whether any of it's child objects has reference to this source handle.
|
||||
@rtype: bool
|
||||
"""
|
||||
return False
|
||||
|
||||
def remove_source_references(self,src_handle_list):
|
||||
"""
|
||||
Removes references to all source handles in the list
|
||||
in all child objects.
|
||||
|
||||
@param src_handle_list: The list of source handles to be removed.
|
||||
@type src_handle_list: list
|
||||
"""
|
||||
pass
|
||||
|
||||
def replace_source_references(self,old_handle,new_handle):
|
||||
"""
|
||||
Replaces references to source handles in the list
|
||||
in this object and all child objects.
|
||||
|
||||
@param old_handle: The source handle to be replaced.
|
||||
@type old_handle: str
|
||||
@param new_handle: The source handle to replace the old one with.
|
||||
@type new_handle: str
|
||||
"""
|
||||
pass
|
||||
|
||||
def set_type(self,type):
|
||||
"""
|
||||
@param type: descriptive type of the Repository
|
||||
@type type: str
|
||||
"""
|
||||
self.type = type
|
||||
|
||||
def get_type(self):
|
||||
"""
|
||||
@returns: the descriptive type of the Repository
|
||||
@rtype: str
|
||||
"""
|
||||
return self.type
|
||||
|
||||
def set_name(self,name):
|
||||
"""
|
||||
@param name: descriptive name of the Repository
|
||||
@type name: str
|
||||
"""
|
||||
self.name = name
|
||||
|
||||
def get_name(self):
|
||||
"""
|
||||
@returns: the descriptive name of the Repository
|
||||
@rtype: str
|
||||
"""
|
||||
return self.name
|
||||
|
||||
def set_address(self,address):
|
||||
"""
|
||||
@param address: L{Location} instance to set as Repository's address
|
||||
@type address: L{Location}
|
||||
"""
|
||||
self.address = address
|
||||
|
||||
def get_address(self):
|
||||
"""
|
||||
@returns: L{Location} instance representing Repository's address
|
||||
@rtype: L{Location}
|
||||
"""
|
||||
return self.address
|
||||
|
||||
def set_email(self,email):
|
||||
"""
|
||||
@param email: descriptive email of the Repository
|
||||
@type email: str
|
||||
"""
|
||||
self.email = email
|
||||
|
||||
def get_email(self):
|
||||
"""
|
||||
@returns: the descriptive email of the Repository
|
||||
@rtype: str
|
||||
"""
|
||||
return self.email
|
||||
|
||||
def set_search_url(self,search_url):
|
||||
"""
|
||||
@param search_url: descriptive search_url of the Repository
|
||||
@type search_url: str
|
||||
"""
|
||||
self.search_url = search_url
|
||||
|
||||
def get_search_url(self):
|
||||
"""
|
||||
@returns: the descriptive search_url of the Repository
|
||||
@rtype: str
|
||||
"""
|
||||
return self.search_url
|
||||
|
||||
def set_home_url(self,home_url):
|
||||
"""
|
||||
@param home_url: descriptive home_url of the Repository
|
||||
@type home_url: str
|
||||
"""
|
||||
self.home_url = home_url
|
||||
|
||||
def get_home_url(self):
|
||||
"""
|
||||
@returns: the descriptive home_url of the Repository
|
||||
@rtype: str
|
||||
"""
|
||||
return self.home_url
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Testing code below this point
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import unittest
|
||||
|
||||
class TestRepository(unittest.TestCase):
|
||||
|
||||
def test_simple(self):
|
||||
|
||||
rep1 = Repository()
|
||||
rep1.set_type("type")
|
||||
rep1.set_name("name")
|
||||
addr1 = Location()
|
||||
rep1.set_address(addr1)
|
||||
rep1.set_email("email")
|
||||
rep1.set_search_url("search url")
|
||||
rep1.set_home_url("home url")
|
||||
rep1.set_note("a note")
|
||||
|
||||
assert rep1.get_type() == "type"
|
||||
assert rep1.get_name() == "name"
|
||||
assert rep1.get_address() == addr1
|
||||
assert rep1.get_email() == "email"
|
||||
assert rep1.get_search_url() == "search url"
|
||||
assert rep1.get_home_url() == "home url"
|
||||
assert rep1.get_note() == "a note"
|
||||
|
||||
def test_serialize(self):
|
||||
|
||||
rep1 = Repository()
|
||||
addr1 = Location()
|
||||
rep1.set_type("type")
|
||||
rep1.set_name("name")
|
||||
rep1.set_address(addr1)
|
||||
rep1.set_email("email")
|
||||
rep1.set_search_url("search url")
|
||||
rep1.set_home_url("home url")
|
||||
rep1.set_note("a note")
|
||||
|
||||
rep2 = Repository()
|
||||
rep2.unserialize(rep1.serialize())
|
||||
assert rep1.get_handle() == rep2.get_handle()
|
||||
assert rep1.get_gramps_id() == rep2.get_gramps_id()
|
||||
assert rep1.get_type() == rep2.get_type()
|
||||
assert rep1.get_name() == rep2.get_name()
|
||||
assert rep1.get_address() == rep2.get_address()
|
||||
assert rep1.get_email() == rep2.get_email()
|
||||
assert rep1.get_search_url() == rep2.get_search_url()
|
||||
assert rep1.get_home_url() == rep2.get_home_url()
|
||||
assert rep1.get_note() == rep2.get_note()
|
||||
|
||||
def test_methods(self):
|
||||
|
||||
rep1 = Repository()
|
||||
addr1 = Location()
|
||||
rep1.set_note("a note")
|
||||
rep1.set_address(addr1)
|
||||
|
||||
assert type(rep1.get_text_data_list()) == type([])
|
||||
assert rep1.get_text_data_child_list() == [addr1,rep1.note]
|
||||
assert rep1.get_handle_referents() == []
|
||||
assert rep1.has_source_reference(None) == False
|
||||
|
||||
|
||||
class TestRepoRef(unittest.TestCase):
|
||||
def test_simple(self):
|
||||
rr1 = RepoRef()
|
||||
rr1.set_reference_handle('ref-handle')
|
||||
rr1.set_call_number('call-number')
|
||||
rr1.set_media_type(RepoRef.MEDIA_TYPE_BOOK)
|
||||
rr1.set_note('some note')
|
||||
|
||||
assert rr1.get_reference_handle() == 'ref-handle'
|
||||
assert rr1.get_call_number() == 'call-number'
|
||||
assert rr1.get_media_type() == RepoRef.MEDIA_TYPE_BOOK
|
||||
assert rr1.get_note() == 'some note'
|
||||
|
||||
unittest.main()
|
||||
|
428
gramps2/src/RepositoryRefEdit.py
Normal file
428
gramps2/src/RepositoryRefEdit.py
Normal file
@ -0,0 +1,428 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 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
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
import gtk.glade
|
||||
import gnome
|
||||
from gtk.gdk import ACTION_COPY, BUTTON1_MASK, INTERP_BILINEAR, pixbuf_new_from_file
|
||||
from gobject import TYPE_PYOBJECT
|
||||
import cPickle as pickle
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
import Utils
|
||||
import RelLib
|
||||
import Date
|
||||
import DateEdit
|
||||
import DateHandler
|
||||
import GrampsDBCallback
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Repository Reference Editor
|
||||
#
|
||||
# This is used by both the RepositoryEditor and the SourceEditor
|
||||
# the UI is slightly different in each case. The subclasses look after
|
||||
# the difference and the common parts of the UI managed by the base class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
class RepositoryRefEditBase:
|
||||
|
||||
def __init__(self, reposref, database, update, parent):
|
||||
|
||||
self.db = database
|
||||
self.parent = parent
|
||||
if self.parent.__dict__.has_key('child_windows'):
|
||||
self.win_parent = self.parent
|
||||
else:
|
||||
self.win_parent = self.parent.parent
|
||||
if reposref:
|
||||
if self.win_parent.child_windows.has_key(reposref):
|
||||
self.win_parent.child_windows[reposref].present(None)
|
||||
return
|
||||
else:
|
||||
self.win_key = reposref
|
||||
else:
|
||||
self.win_key = self
|
||||
self.update = update
|
||||
self.repos_ref = reposref
|
||||
self.child_windows = {}
|
||||
|
||||
def init_widget(self,top, title):
|
||||
|
||||
self.top = top
|
||||
|
||||
Utils.set_titles(self.top,
|
||||
self.top_window.get_widget('title'),
|
||||
title)
|
||||
|
||||
self.top_window.signal_autoconnect({
|
||||
"on_help_repos_ref_edit_clicked" : self.on_help_clicked,
|
||||
"on_ok_repos_ref_edit_clicked" : self.on_ok_clicked,
|
||||
"on_cancel_repos_ref_edit_clicked" : self.close,
|
||||
"on_repos_ref_edit_delete_event" : self.on_delete_event,
|
||||
})
|
||||
|
||||
|
||||
self.media_type = self.get_widget("repos_ref_media_type")
|
||||
|
||||
self.call_number = self.get_widget("repos_ref_callnumber")
|
||||
self.note = self.get_widget("repos_ref_note")
|
||||
|
||||
self.ok = self.get_widget("repos_ref_ok_button")
|
||||
|
||||
def post_init(self):
|
||||
self.add_itself_to_menu()
|
||||
self.top.show()
|
||||
|
||||
|
||||
def on_delete_event(self,obj,b):
|
||||
self.close_child_windows()
|
||||
self.remove_itself_from_menu()
|
||||
|
||||
def close(self,obj):
|
||||
self.close_child_windows()
|
||||
self.remove_itself_from_menu()
|
||||
self.top.destroy()
|
||||
|
||||
def close_child_windows(self):
|
||||
for child_window in self.child_windows.values():
|
||||
child_window.close(None)
|
||||
self.child_windows = {}
|
||||
|
||||
def add_itself_to_menu(self):
|
||||
self.win_parent.child_windows[self.win_key] = self
|
||||
label = _('Repository Reference')
|
||||
self.parent_menu_item = gtk.MenuItem(label)
|
||||
self.parent_menu_item.set_submenu(gtk.Menu())
|
||||
self.parent_menu_item.show()
|
||||
self.win_parent.winsmenu.append(self.parent_menu_item)
|
||||
self.winsmenu = self.parent_menu_item.get_submenu()
|
||||
self.menu_item = gtk.MenuItem(_('Repository Information'))
|
||||
self.menu_item.connect("activate",self.present)
|
||||
self.menu_item.show()
|
||||
self.winsmenu.append(self.menu_item)
|
||||
|
||||
def remove_itself_from_menu(self):
|
||||
del self.win_parent.child_windows[self.win_key]
|
||||
self.menu_item.destroy()
|
||||
self.winsmenu.destroy()
|
||||
self.parent_menu_item.destroy()
|
||||
|
||||
def present(self,obj):
|
||||
self.top.present()
|
||||
|
||||
|
||||
def get_widget(self,name):
|
||||
"""returns the widget associated with the specified name"""
|
||||
return self.top_window.get_widget(name)
|
||||
|
||||
|
||||
def update_display(self,source):
|
||||
#self.draw(source,fresh=False)
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
class RepositoryRefEdit(RepositoryRefEditBase):
|
||||
|
||||
def __init__(self, reposref, database, update, parent):
|
||||
RepositoryRefEditBase.__init__(self, reposref,
|
||||
database, update,
|
||||
parent)
|
||||
|
||||
self.top_window = gtk.glade.XML(const.gladeFile,"repositoryRefEditor","gramps")
|
||||
self.top = self.top_window.get_widget("repositoryRefEditor")
|
||||
|
||||
self.init_widget(self.top,_('Repository Information'))
|
||||
|
||||
# setup menu
|
||||
self.repos_menu = self.get_widget("rep_sel_repository_list")
|
||||
cell = gtk.CellRendererText()
|
||||
self.repos_menu.pack_start(cell,True)
|
||||
self.repos_menu.add_attribute(cell,'text',0)
|
||||
self.repos_menu.connect('changed',self.on_source_changed)
|
||||
|
||||
self.type = self.get_widget("repos_ref_type")
|
||||
|
||||
if self.repos_ref:
|
||||
handle = self.repos_ref.get_reference_handle()
|
||||
self.active_repos = self.db.get_repository_from_handle(handle)
|
||||
else:
|
||||
self.active_repos = None
|
||||
|
||||
|
||||
self.draw(self.active_repos,fresh=True)
|
||||
self.set_button()
|
||||
#if self.parent:
|
||||
# self.top.set_transient_for(self.parent)
|
||||
|
||||
self.db.connect('repository-add', self.rebuild_menu)
|
||||
|
||||
self.top_window.signal_autoconnect({
|
||||
"on_add_repos_clicked" : self.add_repos_clicked
|
||||
})
|
||||
|
||||
self.post_init()
|
||||
|
||||
def rebuild_menu(self,handle_list):
|
||||
self.build_repository_menu(handle_list[0])
|
||||
|
||||
|
||||
def on_help_clicked(self,obj):
|
||||
"""Display the relevant portion of GRAMPS manual"""
|
||||
gnome.help_display('gramps-manual','adv-si')
|
||||
|
||||
def set_button(self):
|
||||
if self.active_repos:
|
||||
self.ok.set_sensitive(1)
|
||||
else:
|
||||
self.ok.set_sensitive(0)
|
||||
pass
|
||||
|
||||
def draw(self,sel=None,fresh=False):
|
||||
if self.repos_ref and fresh:
|
||||
self.call_number.set_text(self.repos_ref.get_call_number())
|
||||
self.note.get_buffer().set_text(self.repos_ref.get_note())
|
||||
|
||||
idval = self.repos_ref.get_reference_handle()
|
||||
repos = self.db.get_repository_from_handle(idval)
|
||||
self.active_repos = repos
|
||||
if repos:
|
||||
self.type.set_text(repos.get_type())
|
||||
else:
|
||||
self.type.set_text("")
|
||||
|
||||
self.active_repos = sel
|
||||
if sel:
|
||||
self.build_repository_menu(sel.get_handle())
|
||||
else:
|
||||
self.build_repository_menu(None)
|
||||
pass
|
||||
|
||||
def build_repository_menu(self,selected_handle):
|
||||
keys = self.db.get_repository_handles()
|
||||
keys.sort()
|
||||
store = gtk.ListStore(str)
|
||||
|
||||
sel_child = None
|
||||
index = 0
|
||||
sel_index = 0
|
||||
self.handle_list = []
|
||||
for repos_id in keys:
|
||||
repos = self.db.get_repository_from_handle(repos_id)
|
||||
name = repos.get_name()
|
||||
gid = repos.get_gramps_id()
|
||||
store.append(row=["%s [%s]" % (name,gid)])
|
||||
self.handle_list.append(repos_id)
|
||||
if selected_handle == repos_id:
|
||||
sel_index = index
|
||||
index += 1
|
||||
self.repos_menu.set_model(store)
|
||||
|
||||
if index > 0:
|
||||
self.repos_menu.set_sensitive(1)
|
||||
self.repos_menu.set_active(sel_index)
|
||||
else:
|
||||
self.repos_menu.set_sensitive(0)
|
||||
|
||||
def on_ok_clicked(self,obj):
|
||||
|
||||
shandle = self.repos_ref.get_reference_handle()
|
||||
if self.active_repos != self.db.get_repository_from_handle(shandle):
|
||||
self.repos_ref.set_reference_handle(self.active_repos.get_handle())
|
||||
|
||||
# handle type here.
|
||||
|
||||
buf = self.note.get_buffer()
|
||||
note = unicode(buf.get_text(buf.get_start_iter(),
|
||||
buf.get_end_iter(),False))
|
||||
if note != self.repos_ref.get_note():
|
||||
self.repos_ref.set_note(note)
|
||||
|
||||
callnumber = unicode(self.call_number.get_text())
|
||||
if callnumber != self.repos_ref.get_call_number():
|
||||
self.repos_ref.set_call_number(callnumber)
|
||||
|
||||
self.update(self.repos_ref)
|
||||
self.close(obj)
|
||||
|
||||
def on_source_changed(self,obj):
|
||||
handle = self.handle_list[obj.get_active()]
|
||||
self.active_repos = self.db.get_repository_from_handle(handle)
|
||||
self.type.set_text(self.active_repos.get_type())
|
||||
self.set_button()
|
||||
pass
|
||||
|
||||
def add_repos_clicked(self,obj):
|
||||
import EditRepository
|
||||
EditRepository.EditRepository(RelLib.Repository(),self.db, self)
|
||||
|
||||
|
||||
|
||||
class RepositoryRefSourceEdit(RepositoryRefEditBase):
|
||||
"""Edit a Repository Reference from the perspective of the Repository."""
|
||||
|
||||
def __init__(self, reposref, source, database, update, parent):
|
||||
RepositoryRefEditBase.__init__(self, reposref,
|
||||
database, update,
|
||||
parent)
|
||||
|
||||
self.top_window = gtk.glade.XML(const.gladeFile,"repositoryRefSourceEditor","gramps")
|
||||
self.top = self.top_window.get_widget("repositoryRefSourceEditor")
|
||||
|
||||
self.init_widget(self.top,_('Source Information'))
|
||||
|
||||
# setup menu
|
||||
self.source_menu = self.get_widget("rep_sel_source_list")
|
||||
cell = gtk.CellRendererText()
|
||||
self.source_menu.pack_start(cell,True)
|
||||
self.source_menu.add_attribute(cell,'text',0)
|
||||
self.source_menu.connect('changed',self.on_source_changed)
|
||||
|
||||
self.author = self.get_widget("rep_sel_source_author")
|
||||
self.pub_info = self.get_widget("rep_sel_source_pub_info")
|
||||
|
||||
self.original_source = source
|
||||
self.active_source = source
|
||||
|
||||
|
||||
self.draw(self.active_source,fresh=True)
|
||||
self.set_button()
|
||||
#if self.parent:
|
||||
# self.top.set_transient_for(self.parent)
|
||||
|
||||
self.db.connect('source-add', self.rebuild_menu)
|
||||
self.top_window.signal_autoconnect({
|
||||
"on_add_source_clicked" : self.add_source_clicked
|
||||
})
|
||||
|
||||
self.post_init()
|
||||
|
||||
def rebuild_menu(self,handle_list):
|
||||
self.build_source_menu(handle_list[0])
|
||||
|
||||
|
||||
def on_help_clicked(self,obj):
|
||||
"""Display the relevant portion of GRAMPS manual"""
|
||||
gnome.help_display('gramps-manual','adv-si')
|
||||
|
||||
def set_button(self):
|
||||
if self.active_source:
|
||||
self.ok.set_sensitive(1)
|
||||
else:
|
||||
self.ok.set_sensitive(0)
|
||||
pass
|
||||
|
||||
def draw(self,sel=None,fresh=False):
|
||||
if self.repos_ref and fresh:
|
||||
self.call_number.set_text(self.repos_ref.get_call_number())
|
||||
self.note.get_buffer().set_text(self.repos_ref.get_note())
|
||||
|
||||
if self.active_source:
|
||||
self.author.set_text(self.active_source.get_author())
|
||||
self.pub_info.set_text(self.active_source.get_publication_info())
|
||||
else:
|
||||
self.author.set_text("")
|
||||
self.pub_info.set_text("")
|
||||
|
||||
|
||||
if sel:
|
||||
self.active_source = sel
|
||||
self.build_source_menu(sel.get_handle())
|
||||
else:
|
||||
self.build_source_menu(None)
|
||||
pass
|
||||
|
||||
def build_source_menu(self,selected_handle):
|
||||
keys = self.db.get_source_handles()
|
||||
keys.sort()
|
||||
store = gtk.ListStore(str)
|
||||
|
||||
sel_child = None
|
||||
index = 0
|
||||
sel_index = 0
|
||||
self.handle_list = []
|
||||
for source_id in keys:
|
||||
source = self.db.get_source_from_handle(source_id)
|
||||
name = source.get_title()
|
||||
gid = source.get_gramps_id()
|
||||
store.append(row=["%s [%s]" % (name,gid)])
|
||||
self.handle_list.append(source_id)
|
||||
if selected_handle == source_id:
|
||||
sel_index = index
|
||||
index += 1
|
||||
self.source_menu.set_model(store)
|
||||
|
||||
if index > 0:
|
||||
self.source_menu.set_sensitive(1)
|
||||
self.source_menu.set_active(sel_index)
|
||||
else:
|
||||
self.source_menu.set_sensitive(0)
|
||||
|
||||
def on_ok_clicked(self,obj):
|
||||
|
||||
# handle type here.
|
||||
|
||||
buf = self.note.get_buffer()
|
||||
note = unicode(buf.get_text(buf.get_start_iter(),
|
||||
buf.get_end_iter(),False))
|
||||
if note != self.repos_ref.get_note():
|
||||
self.repos_ref.set_note(note)
|
||||
|
||||
callnumber = unicode(self.call_number.get_text())
|
||||
if callnumber != self.repos_ref.get_call_number():
|
||||
self.repos_ref.set_call_number(callnumber)
|
||||
|
||||
self.update(self.active_source,self.repos_ref,self.original_source)
|
||||
self.close(obj)
|
||||
|
||||
def on_source_changed(self,obj):
|
||||
source_hdl = self.handle_list[obj.get_active()]
|
||||
self.active_source = self.db.get_source_from_handle(source_hdl)
|
||||
self.author.set_text(self.active_source.get_author())
|
||||
self.pub_info.set_text(self.active_source.get_publication_info())
|
||||
self.set_button()
|
||||
|
||||
def add_source_clicked(self,obj):
|
||||
import EditSource
|
||||
EditSource.EditSource(RelLib.Source(),self.db, self.parent)
|
275
gramps2/src/RepositoryView.py
Normal file
275
gramps2/src/RepositoryView.py
Normal file
@ -0,0 +1,275 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2001-2005 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$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
import gtk.gdk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import RelLib
|
||||
import EditRepository
|
||||
import DisplayModels
|
||||
import const
|
||||
import Utils
|
||||
from QuestionDialog import QuestionDialog, ErrorDialog
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# internationalization
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
|
||||
column_names = [
|
||||
_('Name'),
|
||||
_('ID'),
|
||||
_('Type'),
|
||||
_('Home URL'),
|
||||
]
|
||||
|
||||
_HANDLE_COL = 12
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# RepositoryView
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class RepositoryView:
|
||||
def __init__(self,parent,db,glade):
|
||||
self.parent = parent
|
||||
self.parent.connect('database-changed',self.change_db)
|
||||
|
||||
self.glade = glade
|
||||
self.list = glade.get_widget("repository_list")
|
||||
self.list.connect('button-press-event',self.button_press)
|
||||
self.list.connect('key-press-event',self.key_press)
|
||||
self.selection = self.list.get_selection()
|
||||
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
self.renderer = gtk.CellRendererText()
|
||||
self.model = DisplayModels.RepositoryModel(self.parent.db,0)
|
||||
self.sort_col = 0
|
||||
|
||||
self.list.set_model(self.model)
|
||||
self.list.set_headers_clickable(True)
|
||||
self.topWindow = self.glade.get_widget("gramps")
|
||||
|
||||
self.columns = []
|
||||
self.change_db(db)
|
||||
|
||||
def column_clicked(self,obj,data):
|
||||
if self.sort_col != data:
|
||||
order = gtk.SORT_ASCENDING
|
||||
else:
|
||||
if (self.columns[data].get_sort_order() == gtk.SORT_DESCENDING
|
||||
or self.columns[data].get_sort_indicator() == False):
|
||||
order = gtk.SORT_ASCENDING
|
||||
else:
|
||||
order = gtk.SORT_DESCENDING
|
||||
self.sort_col = data
|
||||
handle = self.first_selected()
|
||||
self.model = DisplayModels.RepositoryModel(self.parent.db,
|
||||
self.sort_col,order)
|
||||
self.list.set_model(self.model)
|
||||
colmap = self.parent.db.get_repository_column_order()
|
||||
|
||||
if handle:
|
||||
path = self.model.on_get_path(handle)
|
||||
self.selection.select_path(path)
|
||||
self.list.scroll_to_cell(path,None,1,0.5,0)
|
||||
for i in range(0,len(self.columns)):
|
||||
self.columns[i].set_sort_indicator(i==colmap[data][1]-1)
|
||||
self.columns[self.sort_col].set_sort_order(order)
|
||||
|
||||
def build_columns(self):
|
||||
for column in self.columns:
|
||||
self.list.remove_column(column)
|
||||
|
||||
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
|
||||
column.set_resizable(True)
|
||||
column.set_min_width(225)
|
||||
column.set_clickable(True)
|
||||
column.connect('clicked',self.column_clicked,0)
|
||||
self.list.append_column(column)
|
||||
self.columns = [column]
|
||||
|
||||
index = 1
|
||||
for pair in self.parent.db.get_repository_column_order():
|
||||
if not pair[0]:
|
||||
continue
|
||||
name = column_names[pair[1]]
|
||||
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1])
|
||||
column.connect('clicked',self.column_clicked,index)
|
||||
column.set_resizable(True)
|
||||
column.set_min_width(75)
|
||||
column.set_clickable(True)
|
||||
self.columns.append(column)
|
||||
self.list.append_column(column)
|
||||
index += 1
|
||||
|
||||
def change_db(self,db):
|
||||
db.connect('repository-add', self.repository_add)
|
||||
db.connect('repository-update', self.repository_update)
|
||||
db.connect('repository-delete', self.repository_delete)
|
||||
db.connect('repository-rebuild',self.build_tree)
|
||||
self.build_columns()
|
||||
self.build_tree()
|
||||
|
||||
def build_tree(self):
|
||||
self.list.set_model(None)
|
||||
self.model = DisplayModels.RepositoryModel(self.parent.db,self.sort_col)
|
||||
self.list.set_model(self.model)
|
||||
self.selection = self.list.get_selection()
|
||||
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
|
||||
def button_press(self,obj,event):
|
||||
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
||||
mlist = []
|
||||
self.selection.selected_foreach(self.blist,mlist)
|
||||
handle = mlist[0]
|
||||
repository = self.parent.db.get_repository_from_handle(handle)
|
||||
EditRepository.EditRepository(repository,self.parent.db,self.parent,
|
||||
self.topWindow)
|
||||
return True
|
||||
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||
self.build_context_menu(event)
|
||||
return True
|
||||
return False
|
||||
|
||||
def key_press(self,obj,event):
|
||||
if event.keyval == gtk.gdk.keyval_from_name("Return") \
|
||||
and not event.state:
|
||||
self.on_edit_clicked(obj)
|
||||
return True
|
||||
return False
|
||||
|
||||
def build_context_menu(self,event):
|
||||
"""Builds the menu with editing operations on the repository's list"""
|
||||
|
||||
mlist = []
|
||||
self.selection.selected_foreach(self.blist,mlist)
|
||||
if mlist:
|
||||
sel_sensitivity = 1
|
||||
else:
|
||||
sel_sensitivity = 0
|
||||
|
||||
entries = [
|
||||
(gtk.STOCK_ADD, self.on_add_clicked,1),
|
||||
(gtk.STOCK_REMOVE, self.on_delete_clicked,sel_sensitivity),
|
||||
(_("Edit"), self.on_edit_clicked,sel_sensitivity),
|
||||
]
|
||||
|
||||
menu = gtk.Menu()
|
||||
menu.set_title(_('Repository Menu'))
|
||||
for stock_id,callback,sensitivity in entries:
|
||||
item = gtk.ImageMenuItem(stock_id)
|
||||
if callback:
|
||||
item.connect("activate",callback)
|
||||
item.set_sensitive(sensitivity)
|
||||
item.show()
|
||||
menu.append(item)
|
||||
menu.popup(None,None,None,event.button,event.time)
|
||||
|
||||
def on_add_clicked(self,obj):
|
||||
EditRepository.EditRepository(RelLib.Repository(),self.parent.db,self.parent,
|
||||
self.topWindow)
|
||||
|
||||
def on_delete_clicked(self,obj):
|
||||
mlist = []
|
||||
self.selection.selected_foreach(self.blist,mlist)
|
||||
|
||||
for repos_handle in mlist:
|
||||
|
||||
source_list = [ src_handle for src_handle \
|
||||
in self.parent.db.get_source_handles() \
|
||||
if self.parent.db.get_source_from_handle(src_handle).has_repo_reference(repos_handle)]
|
||||
|
||||
repository = self.parent.db.get_repository_from_handle(repos_handle)
|
||||
|
||||
ans = EditRepository.DelReposQuery(repository,self.parent.db,source_list)
|
||||
|
||||
if len(source_list) > 0:
|
||||
msg = _('This repository is currently being used. Deleting it '
|
||||
'will remove it from the database and from all '
|
||||
'sources that reference it.')
|
||||
else:
|
||||
msg = _('Deleting repository will remove it from the database.')
|
||||
|
||||
msg = "%s %s" % (msg,Utils.data_recover_msg)
|
||||
QuestionDialog(_('Delete %s?') % repository.get_name(), msg,
|
||||
_('_Delete Repository'),ans.query_response,
|
||||
self.topWindow)
|
||||
|
||||
def on_edit_clicked(self,obj):
|
||||
mlist = []
|
||||
self.selection.selected_foreach(self.blist,mlist)
|
||||
|
||||
for handle in mlist:
|
||||
repository = self.parent.db.get_repository_from_handle(handle)
|
||||
EditRepository.EditRepository(repository, self.parent.db, self.parent,
|
||||
self.topWindow)
|
||||
|
||||
def repository_add(self,handle_list):
|
||||
for handle in handle_list:
|
||||
self.model.add_row_by_handle(handle)
|
||||
|
||||
def repository_update(self,handle_list):
|
||||
for handle in handle_list:
|
||||
self.model.update_row_by_handle(handle)
|
||||
|
||||
def repository_delete(self,handle_list):
|
||||
for handle in handle_list:
|
||||
self.model.delete_row_by_handle(handle)
|
||||
|
||||
def first_selected(self):
|
||||
mlist = []
|
||||
self.selection.selected_foreach(self.blist,mlist)
|
||||
if mlist:
|
||||
return mlist[0]
|
||||
else:
|
||||
return None
|
||||
|
||||
def blist(self,store,path,iter,sel_list):
|
||||
handle = store.get_value(iter,_HANDLE_COL)
|
||||
sel_list.append(handle)
|
||||
|
||||
## def merge(self):
|
||||
## mlist = []
|
||||
## self.selection.selected_foreach(self.blist,mlist)
|
||||
|
||||
## if len(mlist) != 2:
|
||||
## msg = _("Cannot merge repositorys.")
|
||||
## msg2 = _("Exactly two repositorys must be selected to perform a merge. "
|
||||
## "A second repository can be selected by holding down the "
|
||||
## "control key while clicking on the desired repository.")
|
||||
## ErrorDialog(msg,msg2)
|
||||
## else:
|
||||
## import MergeData
|
||||
## MergeData.MergeRepositorys(self.parent.db,mlist[0],mlist[1],
|
||||
## self.build_tree)
|
@ -726,6 +726,7 @@ def get_media_referents(media_handle,db):
|
||||
|
||||
return (person_list,family_list,event_list,place_list,source_list)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
|
@ -335,7 +335,7 @@ family_events = {
|
||||
EVENT_MARR_CONTR : _("Marriage Contract"),
|
||||
EVENT_MARR_BANNS : _("Marriage Banns"),
|
||||
EVENT_ENGAGEMENT : _("Engagement"),
|
||||
EVENT_DIVORCE : _("Divorce")
|
||||
EVENT_DIVORCE : _("Divorce"),
|
||||
EVENT_DIV_FILING : _("Divorce Filing"),
|
||||
EVENT_ANNULMENT : _("Annulment"),
|
||||
EVENT_MARR_ALT : _("Alternate Marriage"),
|
||||
@ -554,6 +554,7 @@ NameTypesMap = TransTable({
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def init_personal_event_list():
|
||||
return
|
||||
p = personal_events.get_values()
|
||||
p.sort()
|
||||
return p
|
||||
@ -564,6 +565,7 @@ def init_personal_event_list():
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def init_marriage_event_list():
|
||||
return
|
||||
p = family_events.get_values()
|
||||
p.sort()
|
||||
return p
|
||||
@ -588,10 +590,10 @@ def init_family_attribute_list():
|
||||
p.sort()
|
||||
return p
|
||||
|
||||
personalEvents = init_personal_event_list()
|
||||
personalEvents = [] #init_personal_event_list()
|
||||
personalAttributes = init_personal_attribute_list()
|
||||
marriageEvents = init_marriage_event_list()
|
||||
defaultMarriageEvent = family_events.find_value("Marriage")
|
||||
marriageEvents = [] #init_marriage_event_list()
|
||||
defaultMarriageEvent = "" #family_events.find_value("Marriage")
|
||||
familyAttributes = init_family_attribute_list()
|
||||
places = []
|
||||
surnames = []
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -59,6 +59,7 @@ import MediaView
|
||||
import PlaceView
|
||||
import FamilyView
|
||||
import SourceView
|
||||
import RepositoryView
|
||||
import PeopleView
|
||||
import GenericFilter
|
||||
import DisplayTrace
|
||||
@ -93,13 +94,14 @@ _HOMEPAGE = "http://gramps-project.org"
|
||||
_MAILLIST = "http://sourceforge.net/mail/?group_id=25770"
|
||||
_BUGREPORT = "http://sourceforge.net/tracker/?group_id=25770&atid=385137"
|
||||
|
||||
PERSON_VIEW = 0
|
||||
FAMILY_VIEW1 = 1
|
||||
FAMILY_VIEW2 = 2
|
||||
PEDIGREE_VIEW = 3
|
||||
SOURCE_VIEW = 4
|
||||
PLACE_VIEW = 5
|
||||
MEDIA_VIEW = 6
|
||||
PERSON_VIEW = 0
|
||||
FAMILY_VIEW1 = 1
|
||||
FAMILY_VIEW2 = 2
|
||||
PEDIGREE_VIEW = 3
|
||||
SOURCE_VIEW = 4
|
||||
REPOSITORY_VIEW = 5
|
||||
PLACE_VIEW = 6
|
||||
MEDIA_VIEW = 7
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -376,10 +378,11 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
|
||||
self.load_person
|
||||
)
|
||||
|
||||
self.place_view = PlaceView.PlaceView(self,self.db,self.gtop)
|
||||
self.source_view = SourceView.SourceView(self,self.db,self.gtop)
|
||||
self.media_view = MediaView.MediaView(self,self.db,self.gtop,
|
||||
self.update_display)
|
||||
self.place_view = PlaceView.PlaceView(self,self.db,self.gtop)
|
||||
self.source_view = SourceView.SourceView(self,self.db,self.gtop)
|
||||
self.repository_view = RepositoryView.RepositoryView(self,self.db,self.gtop)
|
||||
self.media_view = MediaView.MediaView(self,self.db,self.gtop,
|
||||
self.update_display)
|
||||
|
||||
self.add_button = self.gtop.get_widget('addbtn')
|
||||
self.add_item = self.gtop.get_widget('add_item')
|
||||
@ -418,6 +421,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
|
||||
"on_add_bookmark_activate" : self.on_add_bookmark_activate,
|
||||
"on_add_place_clicked" : self.place_view.on_add_place_clicked,
|
||||
"on_add_source_clicked" : self.source_view.on_add_clicked,
|
||||
"on_add_repository_clicked" : self.repository_view.on_add_clicked,
|
||||
"on_addperson_clicked" : self.load_new_person,
|
||||
"on_apply_filter_clicked" : self.on_apply_filter_clicked,
|
||||
"on_arrow_left_clicked" : self.pedigree_view.on_show_child_menu,
|
||||
@ -427,6 +431,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
|
||||
"on_delete_person_clicked" : self.delete_person_clicked,
|
||||
"on_delete_place_clicked" : self.place_view.on_delete_clicked,
|
||||
"on_delete_source_clicked" : self.source_view.on_delete_clicked,
|
||||
"on_delete_repository_clicked" : self.repository_view.on_delete_clicked,
|
||||
"on_delete_media_clicked" : self.media_view.on_delete_clicked,
|
||||
"on_edit_active_person" : self.load_active_person,
|
||||
"on_edit_selected_people" : self.load_selected_people,
|
||||
@ -459,6 +464,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
|
||||
"on_revert_activate" : self.on_revert_activate,
|
||||
"on_show_plugin_status" : self.on_show_plugin_status,
|
||||
"on_source_list_button_press" : self.source_view.button_press,
|
||||
"on_repository_list_button_press" : self.repository_view.button_press,
|
||||
"on_sources_activate" : self.on_sources_activate,
|
||||
"on_tools_clicked" : self.on_tools_clicked,
|
||||
"on_gramps_home_page_activate" : self.home_page_activate,
|
||||
@ -583,6 +589,10 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
|
||||
self.db.set_source_column_order(list)
|
||||
self.source_view.build_columns()
|
||||
|
||||
def set_repository_column_order(self,list):
|
||||
self.db.set_repository_column_order(list)
|
||||
self.repository_view.build_columns()
|
||||
|
||||
def set_media_column_order(self,list):
|
||||
self.db.set_media_column_order(list)
|
||||
self.media_view.build_columns()
|
||||
@ -844,6 +854,8 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
|
||||
self.load_person(self.active_person)
|
||||
elif cpage == SOURCE_VIEW:
|
||||
self.source_view.on_edit_clicked(obj)
|
||||
elif cpage == REPOSITORY_VIEW:
|
||||
self.repository_view.on_edit_clicked(obj)
|
||||
elif cpage == PLACE_VIEW:
|
||||
self.place_view.on_edit_clicked(obj)
|
||||
elif cpage == MEDIA_VIEW:
|
||||
@ -855,6 +867,8 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
|
||||
self.load_new_person(obj)
|
||||
elif cpage == SOURCE_VIEW:
|
||||
self.source_view.on_add_clicked(obj)
|
||||
elif cpage == REPOSITORY_VIEW:
|
||||
self.repository_view.on_add_clicked(obj)
|
||||
elif cpage == PLACE_VIEW:
|
||||
self.place_view.on_add_place_clicked(obj)
|
||||
elif cpage == MEDIA_VIEW:
|
||||
@ -866,6 +880,8 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
|
||||
self.delete_person_clicked(obj)
|
||||
elif cpage == SOURCE_VIEW:
|
||||
self.source_view.on_delete_clicked(obj)
|
||||
elif cpage == REPOSITORY_VIEW:
|
||||
self.repository_view.on_delete_clicked(obj)
|
||||
elif cpage == PLACE_VIEW:
|
||||
self.place_view.on_delete_clicked(obj)
|
||||
elif cpage == MEDIA_VIEW:
|
||||
|
Loading…
Reference in New Issue
Block a user