2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
* 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
|
|
|
# Copyright (C) 2001-2003 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
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gobject
|
|
|
|
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
|
|
|
|
import Utils
|
2003-01-10 10:51:32 +05:30
|
|
|
|
|
|
|
from QuestionDialog import QuestionDialog
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# internationalization
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2003-08-17 07:44:33 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SouceView
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class SourceView:
|
|
|
|
def __init__(self,db,glade,update):
|
|
|
|
self.glade = glade
|
|
|
|
self.db = db
|
|
|
|
self.update = update
|
|
|
|
self.list = glade.get_widget("source_list")
|
|
|
|
self.selection = self.list.get_selection()
|
|
|
|
colno = 0
|
2003-03-26 08:02:58 +05:30
|
|
|
|
|
|
|
self.column_headers = [(_('Title'),3,350),(_('ID'),1,50),
|
|
|
|
(_('Author'),4,70),('',3,0),('',4,0) ]
|
|
|
|
|
|
|
|
for title in self.column_headers:
|
2002-10-20 19:55:16 +05:30
|
|
|
renderer = gtk.CellRendererText ()
|
2003-07-27 09:20:57 +05:30
|
|
|
renderer.set_fixed_height_from_font(1)
|
2002-10-20 19:55:16 +05:30
|
|
|
column = gtk.TreeViewColumn (title[0], renderer, text=colno)
|
|
|
|
colno = colno + 1
|
|
|
|
column.set_clickable (gtk.TRUE)
|
|
|
|
if title[0] == '':
|
|
|
|
column.set_visible(gtk.FALSE)
|
|
|
|
else:
|
|
|
|
column.set_resizable(gtk.TRUE)
|
|
|
|
column.set_visible(gtk.TRUE)
|
|
|
|
column.set_sort_column_id(title[1])
|
|
|
|
column.set_min_width(title[2])
|
|
|
|
self.list.append_column(column)
|
|
|
|
|
|
|
|
self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_STRING)
|
|
|
|
self.list.set_model(self.model)
|
|
|
|
self.list.get_column(0).clicked()
|
* 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
|
|
|
|
|
|
|
def change_db(self,db):
|
|
|
|
self.db = db
|
|
|
|
|
2003-04-04 11:18:25 +05:30
|
|
|
def goto(self,id):
|
|
|
|
self.list.get_selection().select_iter(self.map[id])
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def load_sources(self):
|
2003-07-03 09:45:13 +05:30
|
|
|
self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
|
|
|
gobject.TYPE_STRING)
|
2003-04-04 11:18:25 +05:30
|
|
|
self.map = {}
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
for key in self.db.getSourceKeys():
|
|
|
|
val = self.db.getSourceDisplay(key)
|
|
|
|
|
|
|
|
iter = self.model.append()
|
2003-04-04 11:18:25 +05:30
|
|
|
self.map[val[1]] = iter
|
2002-10-20 19:55:16 +05:30
|
|
|
self.model.set(iter, 0, val[0], 1, val[1], 2, val[2],
|
|
|
|
3, val[3], 4, val[4])
|
|
|
|
self.list.connect('button-press-event',self.button_press)
|
2003-07-03 09:45:13 +05:30
|
|
|
self.list.set_model(self.model)
|
|
|
|
self.list.get_column(0).clicked()
|
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:
|
|
|
|
store,iter = self.selection.get_selected()
|
|
|
|
id = store.get_value(iter,1)
|
|
|
|
source = self.db.getSource(id)
|
* 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
|
|
|
EditSource.EditSource(source,self.db,self.topWindow,self.update_display)
|
2002-10-20 19:55:16 +05:30
|
|
|
return 1
|
2003-10-18 21:20:16 +05:30
|
|
|
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
|
|
|
self.build_context_menu()
|
|
|
|
return 1
|
2003-01-10 10:51:32 +05:30
|
|
|
return 0
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-10-18 21:20:16 +05:30
|
|
|
def build_context_menu(self):
|
|
|
|
"""Builds the menu with editing operations on the source's list"""
|
|
|
|
|
|
|
|
store,iter = self.selection.get_selected()
|
|
|
|
if iter:
|
|
|
|
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)
|
|
|
|
menu.popup(None,None,None,0,0)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def on_add_clicked(self,obj):
|
* 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
|
|
|
EditSource.EditSource(RelLib.Source(),self.db,self.topWindow,self.new_after_edit)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def on_delete_clicked(self,obj):
|
2002-10-28 19:06:39 +05:30
|
|
|
|
|
|
|
store,iter = self.selection.get_selected()
|
|
|
|
if not iter:
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
2002-10-28 19:06:39 +05:30
|
|
|
|
|
|
|
id = store.get_value(iter,1)
|
|
|
|
source = self.db.getSource(id)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if self.is_used(source):
|
|
|
|
ans = EditSource.DelSrcQuery(source,self.db,self.update)
|
|
|
|
|
2003-02-24 10:21:57 +05:30
|
|
|
QuestionDialog(_('Delete %s?') % source.getTitle(),
|
|
|
|
_('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:
|
|
|
|
self.db.removeSource(source.getId())
|
|
|
|
Utils.modified()
|
|
|
|
self.update(0)
|
|
|
|
|
|
|
|
def is_used(self,source):
|
|
|
|
for key in self.db.getPlaceKeys():
|
|
|
|
p = self.db.getPlace(key)
|
|
|
|
for sref in p.getSourceRefList():
|
|
|
|
if sref.getBase() == source:
|
|
|
|
return 1
|
|
|
|
for key in self.db.getPersonKeys():
|
|
|
|
p = self.db.getPerson(key)
|
|
|
|
for v in p.getEventList() + [p.getBirth(), p.getDeath()]:
|
|
|
|
for sref in v.getSourceRefList():
|
|
|
|
if sref.getBase() == source:
|
|
|
|
return 1
|
|
|
|
for v in p.getAttributeList():
|
|
|
|
for sref in v.getSourceRefList():
|
|
|
|
if sref.getBase() == source:
|
|
|
|
return 1
|
|
|
|
for v in p.getAlternateNames() + [p.getPrimaryName()]:
|
|
|
|
for sref in v.getSourceRefList():
|
|
|
|
if sref.getBase() == source:
|
|
|
|
return 1
|
|
|
|
for v in p.getAddressList():
|
|
|
|
for sref in v.getSourceRefList():
|
|
|
|
if sref.getBase() == source:
|
|
|
|
return 1
|
|
|
|
for p in self.db.getObjectMap().values():
|
|
|
|
for sref in p.getSourceRefList():
|
|
|
|
if sref.getBase() == source:
|
|
|
|
return 1
|
|
|
|
for p in self.db.getFamilyMap().values():
|
|
|
|
for v in p.getEventList():
|
|
|
|
for sref in v.getSourceRefList():
|
|
|
|
if sref.getBase() == source:
|
|
|
|
return 1
|
|
|
|
for v in p.getAttributeList():
|
|
|
|
for sref in v.getSourceRefList():
|
|
|
|
if sref.getBase() == source:
|
|
|
|
return 1
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def on_edit_clicked(self,obj):
|
|
|
|
list_store, iter = self.selection.get_selected()
|
|
|
|
if iter:
|
|
|
|
id = list_store.get_value(iter,1)
|
|
|
|
source = self.db.getSource(id)
|
* 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
|
|
|
EditSource.EditSource(source, self.db, self.topWindow, self.update_display)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def new_after_edit(self,source):
|
|
|
|
self.db.addSource(source)
|
|
|
|
self.update(0)
|
|
|
|
|
|
|
|
def update_display(self,place):
|
|
|
|
self.db.buildSourceDisplay(place.getId())
|
|
|
|
self.update(0)
|
|
|
|
|