2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2005-02-16 19:19:32 +05:30
|
|
|
# Copyright (C) 2000-2005 Donald N. Allingham
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2003-11-13 00:15:07 +05:30
|
|
|
# $Id$
|
|
|
|
|
2005-02-16 19:19:32 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from gettext import gettext as _
|
2005-12-07 01:24:16 +05:30
|
|
|
import gc
|
2005-12-21 21:15:30 +05:30
|
|
|
import sys
|
|
|
|
|
2006-01-09 16:58:44 +05:30
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".")
|
2005-02-16 19:19:32 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-05-25 10:39:11 +05:30
|
|
|
import gobject
|
2002-10-20 19:55:16 +05:30
|
|
|
import gtk.glade
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
import Utils
|
2004-08-30 09:20:33 +05:30
|
|
|
import RelLib
|
2005-01-01 09:57:15 +05:30
|
|
|
import NameDisplay
|
2005-05-27 23:13:04 +05:30
|
|
|
import RepositoryRefEdit
|
2005-08-18 11:28:28 +05:30
|
|
|
import Spell
|
2005-12-07 01:24:16 +05:30
|
|
|
import GrampsDisplay
|
2005-12-23 05:13:32 +05:30
|
|
|
import DisplayState
|
|
|
|
|
2006-02-05 04:59:44 +05:30
|
|
|
from DisplayTabs import *
|
2005-12-07 01:24:16 +05:30
|
|
|
from WindowUtils import GladeIf
|
2006-02-23 08:43:15 +05:30
|
|
|
from GrampsWidgets import *
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2005-05-27 23:13:04 +05:30
|
|
|
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:
|
|
|
|
|
2005-08-17 15:00:10 +05:30
|
|
|
def __init__(self, dbstate, widget):
|
|
|
|
self._dbstate = dbstate
|
|
|
|
self.database_changed(self._dbstate.db)
|
|
|
|
self._db.connect('database-changed', self.database_changed)
|
2005-05-27 23:13:04 +05:30
|
|
|
|
|
|
|
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)
|
2005-06-03 19:48:06 +05:30
|
|
|
rtype = repos.get_type()
|
|
|
|
if rtype[0] == RelLib.Event.CUSTOM or rtype[0] not in Utils.repository_types:
|
|
|
|
name = rtype[1]
|
|
|
|
else:
|
|
|
|
name = Utils.repository_types[rtype[0]]
|
|
|
|
cell.set_property('text', name)
|
2005-05-27 23:13:04 +05:30
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
2005-12-23 05:13:32 +05:30
|
|
|
class EditSource(DisplayState.ManagedWindow):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-12-23 05:13:32 +05:30
|
|
|
def __init__(self,dbstate,uistate,track,source,readonly=False):
|
2005-08-12 08:05:27 +05:30
|
|
|
self.dbstate = dbstate
|
2005-12-23 05:13:32 +05:30
|
|
|
self.track = track
|
|
|
|
self.uistate = uistate
|
|
|
|
|
|
|
|
self.db = dbstate.db
|
|
|
|
self.name_display = NameDisplay.displayer.display
|
|
|
|
|
2005-12-24 05:39:04 +05:30
|
|
|
DisplayState.ManagedWindow.__init__(self, uistate, self.track, source)
|
2005-12-23 05:13:32 +05:30
|
|
|
|
2004-08-30 09:20:33 +05:30
|
|
|
if source:
|
|
|
|
self.source = source
|
2005-06-05 09:31:56 +05:30
|
|
|
else:
|
2005-12-23 05:13:32 +05:30
|
|
|
self.source = RelLib.Source()
|
|
|
|
|
2006-02-23 08:43:15 +05:30
|
|
|
self.glade = gtk.glade.XML(const.gladeFile,"sourceEditor","gramps")
|
|
|
|
self.window = self.glade.get_widget("sourceEditor")
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-23 08:43:15 +05:30
|
|
|
Utils.set_titles(self.window,self.glade.get_widget('title'),
|
2003-03-06 11:42:51 +05:30
|
|
|
_('Source Editor'))
|
2006-02-23 08:43:15 +05:30
|
|
|
|
|
|
|
self.vbox = self.glade.get_widget('vbox')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-01-25 10:37:10 +05:30
|
|
|
self.notebook = gtk.Notebook()
|
|
|
|
self.notebook.show()
|
|
|
|
self.vbox.pack_start(self.notebook,True)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-23 08:43:15 +05:30
|
|
|
self._create_tabbed_pages()
|
|
|
|
self._setup_fields()
|
|
|
|
self._connect_signals()
|
2005-12-24 01:46:43 +05:30
|
|
|
self.show()
|
2005-12-21 21:15:30 +05:30
|
|
|
|
2006-02-23 08:43:15 +05:30
|
|
|
def _connect_signals(self):
|
|
|
|
self.glade.get_widget('cancel').connect('clicked', self.close_window)
|
|
|
|
|
|
|
|
ok = self.glade.get_widget('ok')
|
|
|
|
ok.set_sensitive(not self.db.readonly)
|
|
|
|
ok.connect('clicked', self.apply_clicked)
|
|
|
|
|
|
|
|
def _setup_fields(self):
|
|
|
|
self.author = MonitoredEntry(
|
|
|
|
self.glade.get_widget("author"),
|
|
|
|
self.source.set_author,
|
|
|
|
self.source.get_author,
|
|
|
|
self.db.readonly)
|
|
|
|
|
|
|
|
self.pubinfo = MonitoredEntry(
|
|
|
|
self.glade.get_widget("pubinfo"),
|
|
|
|
self.source.set_publication_info,
|
|
|
|
self.source.get_publication_info,
|
|
|
|
self.db.readonly)
|
|
|
|
|
|
|
|
self.abbrev = MonitoredEntry(
|
|
|
|
self.glade.get_widget("abbrev"),
|
|
|
|
self.source.set_abbreviation,
|
|
|
|
self.source.get_abbreviation,
|
|
|
|
self.db.readonly)
|
|
|
|
|
|
|
|
self.title = MonitoredEntry(
|
|
|
|
self.glade.get_widget("source_title"),
|
|
|
|
self.source.set_title,
|
|
|
|
self.source.get_title,
|
|
|
|
self.db.readonly)
|
|
|
|
|
|
|
|
def _add_page(self,page):
|
|
|
|
self.notebook.insert_page(page)
|
|
|
|
self.notebook.set_tab_label(page,page.get_tab_widget())
|
|
|
|
return page
|
|
|
|
|
|
|
|
def _create_tabbed_pages(self):
|
|
|
|
self.note_tab = self._add_page(NoteTab(
|
2006-02-05 04:59:44 +05:30
|
|
|
self.dbstate, self.uistate, self.track,
|
2006-02-23 08:43:15 +05:30
|
|
|
self.source.get_note_object()))
|
|
|
|
|
|
|
|
self.gallery_tab = self._add_page(GalleryTab(
|
|
|
|
self.dbstate, self.uistate, self.track,
|
|
|
|
self.source.get_media_list()))
|
|
|
|
|
|
|
|
self.data_tab = self._add_page(DataEmbedList(
|
|
|
|
self.dbstate, self.uistate, self.track, self.source))
|
|
|
|
|
|
|
|
self.repo_tab = self._add_page(RepoEmbedList(
|
|
|
|
self.dbstate, self.uistate, self.track,
|
|
|
|
self.source.get_reporef_list()))
|
|
|
|
|
|
|
|
self.backref_tab = self._add_page(SourceBackRefList(
|
|
|
|
self.dbstate, self.uistate, self.track,
|
|
|
|
self.db.find_backlink_handles(self.source.handle)))
|
2006-01-25 10:37:10 +05:30
|
|
|
|
|
|
|
self.notebook.show_all()
|
2004-11-24 23:31:49 +05:30
|
|
|
|
2005-12-23 05:13:32 +05:30
|
|
|
def build_window_key(self,source):
|
|
|
|
if source:
|
|
|
|
return source.get_handle()
|
|
|
|
else:
|
2005-12-24 01:39:02 +05:30
|
|
|
return id(self)
|
2005-12-23 05:13:32 +05:30
|
|
|
|
|
|
|
def build_menu_names(self,source):
|
|
|
|
if source:
|
|
|
|
label = "Edit Source"
|
|
|
|
else:
|
|
|
|
label = "New Source"
|
|
|
|
return (label, _('Source Editor'))
|
|
|
|
|
2004-02-21 12:10:44 +05:30
|
|
|
def on_delete_event(self,obj,b):
|
2006-01-25 23:29:22 +05:30
|
|
|
self.backref_tab.close()
|
2006-02-25 03:30:20 +05:30
|
|
|
self.close()
|
2003-11-19 23:30:58 +05:30
|
|
|
|
|
|
|
def on_help_clicked(self,obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2005-12-07 01:24:16 +05:30
|
|
|
GrampsDisplay.help('adv-src')
|
* src/SourceView.py (button_press,on_add_clicked,on_delete_clicked,
on_edit_clicked): Pass parent window to the child dialog.
* src/Sources.py (add_src_clicked): Likewise.
* src/EditSource.py (__init__): Add optional parent_window argument.
Make dialog modal and transient for its parent.
* src/gramps.glade (sourceEditor dialog): Delete unneeded handlers
for buttons.
* src/QuestionDialog.py (SaveDialog,QuestionDialog,OptionDialog,
ErrorDialog,WarningDialog,MissingMediaDialog): Set transient status
if parent is given.
* src/EventEdit.py (__init__): Make dialog modal and transient for
its parent.
* src/Witness.py: Make WittnessEditor dialog modal and transient for
its parent. Call SelectPerson with itself as a parent.
* src/SelectPerson.py (__init__): Make dialog transient for its parent.
* src/imagesel.glade: Define proper responses and delete unneeded handlers
for buttons. Make gtkFileEntry modal.
* src/dialog.glade (all dialogs): Define proper responses for buttons.
* src/EditPerson.py (on_add_aka_clicked, on_aka_update_clicked):
Call NameEdit with itself as a parent; (on_add_attr_clicked,
on_update_attr_clicked): Call AttributeEditor with itself as a parent;
(on_add_addr_clicked,on_update_addr_clicked): Call AddressEditor with
itself as a parent; (on_add_url_clicked,on_update_url_clicked): Call
UrlEditor with itself as a parent; (on_name_note_clicked,
on_ldsbap_note_clicked,on_ldsendow_note_clicked,
on_ldsseal_note_clicked): Call NoteEditor with itself as a parent.
* src/NameEdit.py (__init__): Make dialog modal and transient for
its parent.
* src/AttrEdit.py (__init__): Likewise.
* src/AddrEdit.py (__init__): Likewise.
* src/UrlEdit.py (__init__): Likewise.
* src/NoteEdit.py (__init__): Likewise.
svn: r2131
2003-09-15 09:41:30 +05:30
|
|
|
|
2006-01-25 10:37:10 +05:30
|
|
|
def close_window(self,obj):
|
2006-01-25 23:29:22 +05:30
|
|
|
self.backref_tab.close()
|
2006-01-25 10:37:10 +05:30
|
|
|
self.close()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-05 04:59:44 +05:30
|
|
|
def apply_clicked(self,obj):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2004-08-30 09:20:33 +05:30
|
|
|
if self.source.get_handle() == None:
|
|
|
|
self.db.add_source(self.source,trans)
|
|
|
|
else:
|
|
|
|
self.db.commit_source(self.source,trans)
|
2004-08-13 10:04:07 +05:30
|
|
|
self.db.transaction_commit(trans,_("Edit Source (%s)") % title)
|
2004-02-21 12:10:44 +05:30
|
|
|
self.close(obj)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
class DelSrcQuery:
|
2005-04-04 06:41:50 +05:30
|
|
|
def __init__(self,source,db,the_lists):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.source = source
|
|
|
|
self.db = db
|
2005-03-12 02:35:46 +05:30
|
|
|
self.the_lists = the_lists
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def query_response(self):
|
2004-08-13 10:04:07 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2005-06-05 09:31:56 +05:30
|
|
|
self.db.disable_signals()
|
2004-03-30 10:20:24 +05:30
|
|
|
|
2005-03-12 02:35:46 +05:30
|
|
|
(person_list,family_list,event_list,
|
|
|
|
place_list,source_list,media_list) = self.the_lists
|
|
|
|
|
|
|
|
src_handle_list = [self.source.get_handle()]
|
|
|
|
|
|
|
|
for handle in person_list:
|
|
|
|
person = self.db.get_person_from_handle(handle)
|
|
|
|
person.remove_source_references(src_handle_list)
|
|
|
|
self.db.commit_person(person,trans)
|
|
|
|
|
|
|
|
for handle in family_list:
|
|
|
|
family = self.db.get_family_from_handle(handle)
|
|
|
|
family.remove_source_references(src_handle_list)
|
|
|
|
self.db.commit_family(family,trans)
|
|
|
|
|
|
|
|
for handle in event_list:
|
|
|
|
event = self.db.get_event_from_handle(handle)
|
|
|
|
event.remove_source_references(src_handle_list)
|
|
|
|
self.db.commit_event(event,trans)
|
|
|
|
|
|
|
|
for handle in place_list:
|
|
|
|
place = self.db.get_place_from_handle(handle)
|
|
|
|
place.remove_source_references(src_handle_list)
|
|
|
|
self.db.commit_place(place,trans)
|
|
|
|
|
|
|
|
for handle in source_list:
|
|
|
|
source = self.db.get_source_from_handle(handle)
|
|
|
|
source.remove_source_references(src_handle_list)
|
|
|
|
self.db.commit_source(source,trans)
|
|
|
|
|
|
|
|
for handle in media_list:
|
|
|
|
media = self.db.get_object_from_handle(handle)
|
|
|
|
media.remove_source_references(src_handle_list)
|
|
|
|
self.db.commit_media_object(media,trans)
|
2005-04-04 06:41:50 +05:30
|
|
|
|
2005-06-05 09:31:56 +05:30
|
|
|
self.db.enable_signals()
|
2004-08-13 10:04:07 +05:30
|
|
|
self.db.remove_source(self.source.get_handle(),trans)
|
2005-04-04 06:41:50 +05:30
|
|
|
self.db.transaction_commit(
|
|
|
|
trans,_("Delete Source (%s)") % self.source.get_title())
|