2004-08-24 09:18:15 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2004-02-15 08:54:12 +05:30
|
|
|
# Copyright (C) 2001-2004 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-10-18 21:20:16 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
import gtk.gdk
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2003-01-10 10:51:32 +05:30
|
|
|
import RelLib
|
2002-10-20 19:55:16 +05:30
|
|
|
import EditSource
|
2004-03-22 10:11:35 +05:30
|
|
|
import DisplayModels
|
2004-04-11 08:07:13 +05:30
|
|
|
import const
|
2003-01-10 10:51:32 +05:30
|
|
|
|
|
|
|
from QuestionDialog import QuestionDialog
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-05-14 04:15:51 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# internationalization
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from gettext import gettext as _
|
|
|
|
|
|
|
|
|
2004-03-22 10:11:35 +05:30
|
|
|
column_names = [
|
|
|
|
_('Title'),
|
|
|
|
_('ID'),
|
|
|
|
_('Author'),
|
|
|
|
_('Abbreviation'),
|
|
|
|
_('Publication Information'),
|
2004-08-24 09:18:15 +05:30
|
|
|
_('Last Changed'),
|
2004-03-22 10:11:35 +05:30
|
|
|
]
|
|
|
|
|
2004-08-30 09:20:33 +05:30
|
|
|
_HANDLE_COL = len(column_names)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SouceView
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class SourceView:
|
2004-02-26 09:04:19 +05:30
|
|
|
def __init__(self,parent,db,glade,update):
|
|
|
|
self.parent = parent
|
2002-10-20 19:55:16 +05:30
|
|
|
self.glade = glade
|
|
|
|
self.update = update
|
|
|
|
self.list = glade.get_widget("source_list")
|
2004-10-18 04:47:30 +05:30
|
|
|
#self.list.set_property('fixed-height-mode',True)
|
2004-03-30 10:20:24 +05:30
|
|
|
self.list.connect('button-press-event',self.button_press)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.selection = self.list.get_selection()
|
2003-03-26 08:02:58 +05:30
|
|
|
|
2004-03-22 10:11:35 +05:30
|
|
|
self.renderer = gtk.CellRendererText()
|
2004-02-01 10:19:49 +05:30
|
|
|
|
2004-08-19 08:07:35 +05:30
|
|
|
self.model = DisplayModels.SourceModel(self.parent.db)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.list.set_model(self.model)
|
* 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
|
|
|
self.topWindow = self.glade.get_widget("gramps")
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-03-22 10:11:35 +05:30
|
|
|
self.columns = []
|
|
|
|
self.build_columns()
|
|
|
|
|
|
|
|
def build_columns(self):
|
|
|
|
for column in self.columns:
|
|
|
|
self.list.remove_column(column)
|
|
|
|
|
|
|
|
column = gtk.TreeViewColumn(_('Title'), self.renderer,text=0)
|
2004-04-11 08:07:13 +05:30
|
|
|
column.set_resizable(gtk.TRUE)
|
2004-03-22 10:11:35 +05:30
|
|
|
column.set_min_width(225)
|
|
|
|
self.list.append_column(column)
|
|
|
|
self.columns = [column]
|
|
|
|
|
|
|
|
for pair in self.parent.db.get_source_column_order():
|
|
|
|
if not pair[0]:
|
|
|
|
continue
|
|
|
|
name = column_names[pair[1]]
|
|
|
|
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1])
|
|
|
|
column.set_resizable(gtk.TRUE)
|
|
|
|
column.set_min_width(75)
|
|
|
|
self.columns.append(column)
|
|
|
|
self.list.append_column(column)
|
|
|
|
|
2004-03-30 10:20:24 +05:30
|
|
|
def on_click(self,column):
|
|
|
|
self.click_col = column
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def change_db(self,db):
|
2004-03-22 10:11:35 +05:30
|
|
|
self.build_columns()
|
|
|
|
self.build_tree()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-03-22 10:11:35 +05:30
|
|
|
def build_tree(self):
|
|
|
|
self.list.set_model(None)
|
2004-08-19 08:07:35 +05:30
|
|
|
self.model = DisplayModels.SourceModel(self.parent.db)
|
2003-07-03 09:45:13 +05:30
|
|
|
self.list.set_model(self.model)
|
2004-03-22 10:11:35 +05:30
|
|
|
self.selection = self.list.get_selection()
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def button_press(self,obj,event):
|
|
|
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
2004-08-23 04:46:57 +05:30
|
|
|
store,node = self.selection.get_selected()
|
|
|
|
handle = store.get_value(node,_HANDLE_COL)
|
|
|
|
source = self.parent.db.get_source_from_handle(handle)
|
2004-08-07 10:46:57 +05:30
|
|
|
EditSource.EditSource(source,self.parent.db,self.parent,
|
2004-03-23 10:31:19 +05:30
|
|
|
self.topWindow,self.update_display)
|
2004-08-30 09:20:33 +05:30
|
|
|
return True
|
2003-10-18 21:20:16 +05:30
|
|
|
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
2003-10-20 08:17:03 +05:30
|
|
|
self.build_context_menu(event)
|
2004-08-30 09:20:33 +05:30
|
|
|
return True
|
|
|
|
return False
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-15 08:54:12 +05:30
|
|
|
def key_press(self,obj,event):
|
|
|
|
if event.keyval == gtk.gdk.keyval_from_name("Return") \
|
|
|
|
and not event.state:
|
|
|
|
self.on_edit_clicked(obj)
|
2004-08-30 09:20:33 +05:30
|
|
|
return True
|
|
|
|
return False
|
2004-02-15 08:54:12 +05:30
|
|
|
|
2003-10-20 08:17:03 +05:30
|
|
|
def build_context_menu(self,event):
|
2003-10-18 21:20:16 +05:30
|
|
|
"""Builds the menu with editing operations on the source's list"""
|
|
|
|
|
2004-08-23 04:46:57 +05:30
|
|
|
store,node = self.selection.get_selected()
|
|
|
|
if node:
|
2003-10-18 21:20:16 +05:30
|
|
|
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(_('Source 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)
|
2003-10-20 08:17:03 +05:30
|
|
|
menu.popup(None,None,None,event.button,event.time)
|
2003-10-18 21:20:16 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def on_add_clicked(self,obj):
|
2004-08-07 10:46:57 +05:30
|
|
|
EditSource.EditSource(RelLib.Source(),self.parent.db,self.parent,
|
2004-03-23 10:31:19 +05:30
|
|
|
self.topWindow,self.new_after_edit)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-08-30 09:20:33 +05:30
|
|
|
def delete_source(self,source):
|
|
|
|
trans = self.parent.db.transaction_begin()
|
|
|
|
source_handle = source.get_handle()
|
|
|
|
self.parent.db.remove_source(source_handle,trans)
|
|
|
|
title_msg = _("Delete Source (%s)") % source.get_title()
|
|
|
|
self.parent.db.transaction_commit(trans,title_msg)
|
|
|
|
self.model.delete_row_by_handle(source_handle)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def on_delete_clicked(self,obj):
|
2004-08-23 04:46:57 +05:30
|
|
|
store,node = self.selection.get_selected()
|
|
|
|
if not node:
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
2002-10-28 19:06:39 +05:30
|
|
|
|
2004-08-23 04:46:57 +05:30
|
|
|
handle = store.get_value(node,_HANDLE_COL)
|
|
|
|
source = self.parent.db.get_source_from_handle(handle)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if self.is_used(source):
|
2004-08-30 09:20:33 +05:30
|
|
|
ans = EditSource.DelSrcQuery(source,self.parent.db,
|
|
|
|
self.model.delete_row_by_handle)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
QuestionDialog(_('Delete %s?') % source.get_title(),
|
2003-02-24 10:21:57 +05:30
|
|
|
_('This source is currently being used. Deleting it '
|
|
|
|
'will remove it from the database and from all '
|
|
|
|
'records that reference it.'),
|
2003-03-23 09:20:59 +05:30
|
|
|
_('_Delete Source'),
|
* 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
|
|
|
ans.query_response,self.topWindow)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-08-30 09:20:33 +05:30
|
|
|
self.delete_source(source)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def is_used(self,source):
|
2004-08-13 10:04:07 +05:30
|
|
|
for key in self.parent.db.get_place_handles():
|
2004-08-07 10:46:57 +05:30
|
|
|
p = self.parent.db.get_place_from_handle(key)
|
2004-02-14 11:10:30 +05:30
|
|
|
for sref in p.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == source.get_handle():
|
2004-08-30 09:20:33 +05:30
|
|
|
return True
|
2004-08-13 10:04:07 +05:30
|
|
|
for key in self.parent.db.get_person_handles(sort_handles=False):
|
2004-08-07 10:46:57 +05:30
|
|
|
p = self.parent.db.get_person_from_handle(key)
|
2004-07-28 07:59:07 +05:30
|
|
|
for v_id in p.get_event_list() + [p.get_birth_handle(), p.get_death_handle()]:
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
v = self.parent.db.get_event_from_handle(v_id)
|
2004-02-23 11:12:19 +05:30
|
|
|
if v:
|
|
|
|
for sref in v.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == source.get_handle():
|
2004-08-30 09:20:33 +05:30
|
|
|
return True
|
2004-02-14 11:10:30 +05:30
|
|
|
for v in p.get_attribute_list():
|
|
|
|
for sref in v.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == source.get_handle():
|
2004-08-30 09:20:33 +05:30
|
|
|
return True
|
2004-02-14 11:10:30 +05:30
|
|
|
for v in p.get_alternate_names() + [p.get_primary_name()]:
|
|
|
|
for sref in v.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == source.get_handle():
|
2004-08-30 09:20:33 +05:30
|
|
|
return True
|
2004-02-14 11:10:30 +05:30
|
|
|
for v in p.get_address_list():
|
|
|
|
for sref in v.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == source.get_handle():
|
2004-08-30 09:20:33 +05:30
|
|
|
return True
|
2004-08-13 10:04:07 +05:30
|
|
|
for p_id in self.parent.db.get_media_object_handles():
|
2004-08-07 10:46:57 +05:30
|
|
|
p = self.parent.db.get_object_from_handle(p_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
for sref in p.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == source.get_handle():
|
2004-08-30 09:20:33 +05:30
|
|
|
return True
|
2004-08-13 10:04:07 +05:30
|
|
|
for p_id in self.parent.db.get_family_handles():
|
2004-08-20 03:05:16 +05:30
|
|
|
p = self.parent.db.get_family_from_handle(p_id)
|
2004-02-23 11:12:19 +05:30
|
|
|
for v_id in p.get_event_list():
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
v = self.parent.db.get_event_from_handle(v_id)
|
2004-02-23 11:12:19 +05:30
|
|
|
if v:
|
|
|
|
for sref in v.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == source.get_handle():
|
2004-08-30 09:20:33 +05:30
|
|
|
return True
|
2004-02-14 11:10:30 +05:30
|
|
|
for v in p.get_attribute_list():
|
|
|
|
for sref in v.get_source_references():
|
2004-07-28 07:59:07 +05:30
|
|
|
if sref.get_base_handle() == source.get_handle():
|
2004-08-30 09:20:33 +05:30
|
|
|
return True
|
|
|
|
return False
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def on_edit_clicked(self,obj):
|
2004-08-23 04:46:57 +05:30
|
|
|
list_store, node = self.selection.get_selected()
|
|
|
|
if node:
|
|
|
|
handle = list_store.get_value(node,_HANDLE_COL)
|
|
|
|
source = self.parent.db.get_source_from_handle(handle)
|
2004-08-07 10:46:57 +05:30
|
|
|
EditSource.EditSource(source, self.parent.db, self.parent,
|
2004-03-23 10:31:19 +05:30
|
|
|
self.topWindow, self.update_display)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def new_after_edit(self,source):
|
2004-08-31 09:21:05 +05:30
|
|
|
self.model.add_row_by_handle(source.get_handle())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-08-30 09:20:33 +05:30
|
|
|
def update_display(self,source):
|
|
|
|
self.model.update_row_by_handle(source.get_handle())
|