2002-11-26 18:43:31 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2005-02-25 21:56:26 +05:30
|
|
|
# Copyright (C) 2000-2005 Donald N. Allingham
|
2002-11-26 18:43:31 +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-19 23:30:58 +05:30
|
|
|
# $Id$
|
|
|
|
|
2004-09-21 04:56:41 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from gettext import gettext as _
|
|
|
|
|
2002-11-26 18:43:31 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gobject
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
2003-11-19 23:30:58 +05:30
|
|
|
import gnome
|
2002-11-26 18:43:31 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
import Utils
|
2003-01-10 10:51:32 +05:30
|
|
|
import RelLib
|
2004-09-21 04:56:41 +05:30
|
|
|
import Date
|
|
|
|
import DateEdit
|
2004-09-20 23:26:26 +05:30
|
|
|
import DateHandler
|
2002-11-26 18:43:31 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SourceSelector
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class SourceSelector:
|
|
|
|
def __init__(self,srclist,parent,update=None):
|
|
|
|
self.db = parent.db
|
|
|
|
self.parent = parent
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
if srclist:
|
|
|
|
if self.parent.child_windows.has_key(id(srclist)):
|
|
|
|
self.parent.child_windows[id(srclist)].present(None)
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
self.win_key = id(srclist)
|
|
|
|
else:
|
|
|
|
self.win_key = self
|
2002-11-26 18:43:31 +05:30
|
|
|
self.orig = srclist
|
|
|
|
self.list = []
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
self.child_windows = {}
|
2002-11-26 18:43:31 +05:30
|
|
|
for s in self.orig:
|
2003-01-10 10:51:32 +05:30
|
|
|
self.list.append(RelLib.SourceRef(s))
|
2002-11-26 18:43:31 +05:30
|
|
|
self.update=update
|
2003-08-17 07:44:33 +05:30
|
|
|
self.top = gtk.glade.XML(const.srcselFile,"sourcesel","gramps")
|
2003-09-14 02:12:57 +05:30
|
|
|
self.window = self.top.get_widget("sourcesel")
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2003-09-14 02:12:57 +05:30
|
|
|
Utils.set_titles(self.window, self.top.get_widget('title'),
|
2003-03-06 11:42:51 +05:30
|
|
|
_('Source Reference Selection'))
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2002-11-26 18:43:31 +05:30
|
|
|
self.top.signal_autoconnect({
|
|
|
|
"on_add_src_clicked" : self.add_src_clicked,
|
|
|
|
"on_del_src_clicked" : self.del_src_clicked,
|
2003-03-03 10:02:53 +05:30
|
|
|
"on_edit_src_clicked" : self.edit_src_clicked,
|
2003-11-19 23:30:58 +05:30
|
|
|
"on_help_srcsel_clicked" : self.on_help_clicked,
|
2004-02-20 09:55:22 +05:30
|
|
|
"on_cancel_srcsel_clicked" : self.close,
|
|
|
|
"on_ok_srcsel_clicked" : self.src_ok_clicked,
|
|
|
|
"on_srcsel_delete_event" : self.on_delete_event,
|
2002-11-26 18:43:31 +05:30
|
|
|
})
|
|
|
|
|
|
|
|
self.slist = self.top.get_widget("slist")
|
2003-03-24 09:21:07 +05:30
|
|
|
self.edit = self.top.get_widget('edit')
|
|
|
|
self.delete = self.top.get_widget('delete')
|
2005-02-18 10:19:59 +05:30
|
|
|
self.delete.set_sensitive(not self.db.readonly)
|
2002-11-26 18:43:31 +05:30
|
|
|
self.selection = self.slist.get_selection()
|
|
|
|
self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
|
|
|
self.slist.set_model(self.model)
|
2005-02-18 10:19:59 +05:30
|
|
|
self.top.get_widget('add').set_sensitive(not self.db.readonly)
|
|
|
|
self.top.get_widget('ok').set_sensitive(not self.db.readonly)
|
2002-11-26 18:43:31 +05:30
|
|
|
|
|
|
|
colno = 0
|
|
|
|
for title in [ (_('ID'),0,100), (_('Title'),1,150)]:
|
|
|
|
renderer = gtk.CellRendererText ()
|
2003-07-27 09:20:57 +05:30
|
|
|
renderer.set_fixed_height_from_font(1)
|
2002-11-26 18:43:31 +05:30
|
|
|
column = gtk.TreeViewColumn (title[0], renderer, text=colno)
|
|
|
|
colno = colno + 1
|
2005-02-24 05:55:34 +05:30
|
|
|
column.set_clickable (True)
|
|
|
|
column.set_resizable(True)
|
2002-11-26 18:43:31 +05:30
|
|
|
column.set_sort_column_id(title[1])
|
|
|
|
column.set_min_width(title[2])
|
|
|
|
self.slist.append_column (column)
|
|
|
|
|
2003-03-24 09:21:07 +05:30
|
|
|
self.selection.connect('changed',self.selection_changed)
|
|
|
|
|
2005-02-24 05:55:34 +05:30
|
|
|
self.delete.set_sensitive(False)
|
|
|
|
self.edit.set_sensitive(False)
|
2002-11-26 18:43:31 +05:30
|
|
|
self.redraw()
|
2003-09-14 02:12:57 +05:30
|
|
|
if self.parent:
|
|
|
|
self.window.set_transient_for(self.parent.window)
|
2004-02-20 09:55:22 +05:30
|
|
|
self.add_itself_to_menu()
|
2003-09-14 02:12:57 +05:30
|
|
|
self.window.show()
|
2004-02-20 09:55:22 +05:30
|
|
|
|
|
|
|
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()
|
2003-09-14 02:12:57 +05:30
|
|
|
self.window.destroy()
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2004-02-20 09:55:22 +05:30
|
|
|
def close_child_windows(self):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
for child_window in self.child_windows.values():
|
2004-02-20 09:55:22 +05:30
|
|
|
child_window.close(None)
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
self.child_windows = {}
|
2004-02-20 09:55:22 +05:30
|
|
|
|
|
|
|
def add_itself_to_menu(self):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
self.parent.child_windows[self.win_key] = self
|
2004-02-20 09:55:22 +05:30
|
|
|
label = _('Source Reference')
|
|
|
|
self.parent_menu_item = gtk.MenuItem(label)
|
|
|
|
self.parent_menu_item.set_submenu(gtk.Menu())
|
|
|
|
self.parent_menu_item.show()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.parent.winsmenu.append(self.parent_menu_item)
|
|
|
|
self.winsmenu = self.parent_menu_item.get_submenu()
|
2004-02-20 09:55:22 +05:30
|
|
|
self.menu_item = gtk.MenuItem(_('Reference Selector'))
|
|
|
|
self.menu_item.connect("activate",self.present)
|
|
|
|
self.menu_item.show()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.winsmenu.append(self.menu_item)
|
2004-02-20 09:55:22 +05:30
|
|
|
|
|
|
|
def remove_itself_from_menu(self):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
del self.parent.child_windows[self.win_key]
|
2004-02-20 09:55:22 +05:30
|
|
|
self.menu_item.destroy()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.winsmenu.destroy()
|
2004-02-20 09:55:22 +05:30
|
|
|
self.parent_menu_item.destroy()
|
|
|
|
|
|
|
|
def present(self,obj):
|
|
|
|
self.window.present()
|
|
|
|
|
2003-11-19 23:30:58 +05:30
|
|
|
def on_help_clicked(self,obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2003-12-02 09:57:23 +05:30
|
|
|
gnome.help_display('gramps-manual','gramps-edit-complete')
|
2003-11-19 23:30:58 +05:30
|
|
|
|
2003-03-24 09:21:07 +05:30
|
|
|
def selection_changed(self,obj):
|
2004-08-23 04:46:57 +05:30
|
|
|
(store,node) = self.selection.get_selected()
|
|
|
|
if node:
|
2005-02-24 05:55:34 +05:30
|
|
|
self.delete.set_sensitive(True)
|
|
|
|
self.edit.set_sensitive(True)
|
2003-03-24 09:21:07 +05:30
|
|
|
else:
|
2005-02-24 05:55:34 +05:30
|
|
|
self.delete.set_sensitive(False)
|
|
|
|
self.edit.set_sensitive(False)
|
2003-03-24 09:21:07 +05:30
|
|
|
|
2002-11-26 18:43:31 +05:30
|
|
|
def redraw(self):
|
|
|
|
self.model.clear()
|
|
|
|
for s in self.list:
|
2004-07-28 07:59:07 +05:30
|
|
|
base_handle = s.get_base_handle()
|
2004-08-07 10:46:57 +05:30
|
|
|
base = self.db.get_source_from_handle(base_handle)
|
2004-08-23 04:46:57 +05:30
|
|
|
node = self.model.append()
|
2004-08-31 23:57:57 +05:30
|
|
|
self.model.set(node,0,base.get_gramps_id(),1,base.get_title())
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2004-02-20 09:55:22 +05:30
|
|
|
def src_ok_clicked(self,obj):
|
2002-11-26 18:43:31 +05:30
|
|
|
del self.orig[:]
|
|
|
|
for s in self.list:
|
|
|
|
self.orig.append(s)
|
|
|
|
if self.update:
|
|
|
|
self.update(self.orig)
|
2004-02-20 09:55:22 +05:30
|
|
|
self.close(obj)
|
2002-11-26 18:43:31 +05:30
|
|
|
|
|
|
|
def edit_src_clicked(self,obj):
|
2004-08-23 04:46:57 +05:30
|
|
|
store,node = self.selection.get_selected()
|
|
|
|
if node:
|
|
|
|
col = store.get_path(node)
|
2002-11-26 18:43:31 +05:30
|
|
|
src = self.list[col[0]]
|
|
|
|
SourceEditor(src,self.db,self.update_clist,self)
|
|
|
|
|
|
|
|
def update_clist(self,inst,ref):
|
|
|
|
inst.redraw()
|
|
|
|
|
|
|
|
def add_src_clicked(self,obj):
|
2003-01-10 10:51:32 +05:30
|
|
|
src = RelLib.SourceRef()
|
2002-11-26 18:43:31 +05:30
|
|
|
SourceEditor(src,self.db,self.add_ref,self)
|
|
|
|
|
|
|
|
def del_src_clicked(self,obj):
|
2004-08-23 04:46:57 +05:30
|
|
|
(store,node) = self.selection.get_selected()
|
|
|
|
if node:
|
|
|
|
path = store.get_path(node)
|
2002-11-26 18:43:31 +05:30
|
|
|
del self.list[path[0]]
|
|
|
|
self.redraw()
|
|
|
|
|
|
|
|
def add_ref(self,inst,ref):
|
|
|
|
self.parent.lists_changed = 1
|
|
|
|
inst.list.append(ref)
|
|
|
|
inst.redraw()
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SourceTab
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class SourceTab:
|
2005-02-17 10:16:13 +05:30
|
|
|
def __init__(self,srclist,parent,top,window,clist,add_btn,
|
|
|
|
edit_btn,del_btn,readonly=False):
|
2002-11-26 18:43:31 +05:30
|
|
|
self.db = parent.db
|
|
|
|
self.parent = parent
|
|
|
|
self.list = srclist
|
|
|
|
self.top = top
|
2003-09-14 02:12:57 +05:30
|
|
|
self.window = window
|
2002-11-26 18:43:31 +05:30
|
|
|
self.slist = clist
|
|
|
|
self.selection = clist.get_selection()
|
|
|
|
self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
|
|
|
|
2005-02-17 10:16:13 +05:30
|
|
|
add_btn.set_sensitive(not readonly)
|
|
|
|
del_btn.set_sensitive(not readonly)
|
|
|
|
|
2002-11-26 18:43:31 +05:30
|
|
|
colno = 0
|
|
|
|
for title in [ (_('ID'),0,100), (_('Title'),1,150)]:
|
|
|
|
renderer = gtk.CellRendererText ()
|
|
|
|
column = gtk.TreeViewColumn (title[0], renderer, text=colno)
|
|
|
|
colno = colno + 1
|
2005-02-24 05:55:34 +05:30
|
|
|
column.set_clickable (True)
|
|
|
|
column.set_resizable(True)
|
2002-11-26 18:43:31 +05:30
|
|
|
column.set_sort_column_id(title[1])
|
|
|
|
column.set_min_width(title[2])
|
|
|
|
self.slist.append_column (column)
|
|
|
|
|
|
|
|
self.slist.set_model(self.model)
|
|
|
|
|
|
|
|
add_btn.connect('clicked', self.add_src_clicked)
|
2003-03-03 10:02:53 +05:30
|
|
|
edit_btn.connect('clicked', self.edit_src_clicked)
|
2002-11-26 18:43:31 +05:30
|
|
|
del_btn.connect('clicked', self.del_src_clicked)
|
|
|
|
self.slist.connect('button-press-event',self.double_click)
|
|
|
|
self.redraw()
|
|
|
|
|
|
|
|
def double_click(self,obj,event):
|
|
|
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
|
|
|
self.edit_src_clicked(obj)
|
|
|
|
|
|
|
|
def redraw(self):
|
|
|
|
self.model.clear()
|
|
|
|
for s in self.list:
|
2004-07-28 07:59:07 +05:30
|
|
|
base_handle = s.get_base_handle()
|
2004-08-23 04:46:57 +05:30
|
|
|
node = self.model.append()
|
2004-08-07 10:46:57 +05:30
|
|
|
base = self.db.get_source_from_handle(base_handle)
|
2004-08-31 23:57:57 +05:30
|
|
|
self.model.set(node,0,base.get_gramps_id(),1,base.get_title())
|
2003-11-13 00:15:07 +05:30
|
|
|
if self.list:
|
|
|
|
Utils.bold_label(self.parent.sources_label)
|
|
|
|
else:
|
|
|
|
Utils.unbold_label(self.parent.sources_label)
|
2002-11-26 18:43:31 +05:30
|
|
|
|
|
|
|
def update_clist(self,inst,ref):
|
|
|
|
inst.redraw()
|
|
|
|
self.parent.lists_changed = 1
|
|
|
|
|
|
|
|
def edit_src_clicked(self,obj):
|
2004-08-23 04:46:57 +05:30
|
|
|
store,node = self.selection.get_selected()
|
|
|
|
if node:
|
|
|
|
col = store.get_path(node)
|
2002-11-26 18:43:31 +05:30
|
|
|
src = self.list[col[0]]
|
|
|
|
SourceEditor(src,self.db,self.update_clist,self)
|
|
|
|
|
|
|
|
def add_src_clicked(self,obj):
|
2003-01-10 10:51:32 +05:30
|
|
|
src = RelLib.SourceRef()
|
2002-11-26 18:43:31 +05:30
|
|
|
SourceEditor(src,self.db,self.add_ref,self)
|
|
|
|
|
|
|
|
def add_ref(self,inst,ref):
|
|
|
|
self.parent.lists_changed = 1
|
|
|
|
inst.list.append(ref)
|
|
|
|
inst.redraw()
|
|
|
|
|
|
|
|
def del_src_clicked(self,obj):
|
2004-08-23 04:46:57 +05:30
|
|
|
(store,node) = self.selection.get_selected()
|
|
|
|
if node:
|
|
|
|
path = store.get_path(node)
|
2002-11-26 18:43:31 +05:30
|
|
|
del self.list[path[0]]
|
2004-06-13 11:48:20 +05:30
|
|
|
self.parent.lists_changed = 1
|
2002-11-26 18:43:31 +05:30
|
|
|
self.redraw()
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SourceEditor
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class SourceEditor:
|
|
|
|
|
|
|
|
def __init__(self,srcref,database,update=None,parent=None):
|
|
|
|
|
|
|
|
self.db = database
|
|
|
|
self.parent = parent
|
2004-02-20 09:55:22 +05:30
|
|
|
if self.parent.__dict__.has_key('child_windows'):
|
|
|
|
self.win_parent = self.parent
|
|
|
|
else:
|
|
|
|
self.win_parent = self.parent.parent
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
if srcref:
|
|
|
|
if self.win_parent.child_windows.has_key(srcref):
|
|
|
|
self.win_parent.child_windows[srcref].present(None)
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
self.win_key = srcref
|
|
|
|
else:
|
|
|
|
self.win_key = self
|
|
|
|
self.update = update
|
|
|
|
self.source_ref = srcref
|
|
|
|
self.child_windows = {}
|
2003-08-17 07:44:33 +05:30
|
|
|
self.showSource = gtk.glade.XML(const.srcselFile, "sourceDisplay","gramps")
|
2003-03-06 11:42:51 +05:30
|
|
|
self.sourceDisplay = self.get_widget("sourceDisplay")
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2003-03-06 11:42:51 +05:30
|
|
|
Utils.set_titles(self.sourceDisplay, self.showSource.get_widget('title'),
|
|
|
|
_('Source Information'))
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2002-11-26 18:43:31 +05:30
|
|
|
self.showSource.signal_autoconnect({
|
2003-03-24 09:21:07 +05:30
|
|
|
"on_add_src_clicked" : self.add_src_clicked,
|
2003-11-19 23:30:58 +05:30
|
|
|
"on_help_srcDisplay_clicked" : self.on_help_clicked,
|
2004-02-20 05:09:01 +05:30
|
|
|
"on_ok_srcDisplay_clicked" : self.on_sourceok_clicked,
|
|
|
|
"on_cancel_srcDisplay_clicked" : self.close,
|
|
|
|
"on_sourceDisplay_delete_event" : self.on_delete_event,
|
2002-11-26 18:43:31 +05:30
|
|
|
})
|
|
|
|
self.source_field = self.get_widget("sourceList")
|
2005-01-02 10:46:25 +05:30
|
|
|
|
|
|
|
# setup menu
|
2002-11-26 18:43:31 +05:30
|
|
|
self.title_menu = self.get_widget("source_title")
|
2005-01-02 10:46:25 +05:30
|
|
|
cell = gtk.CellRendererText()
|
|
|
|
self.title_menu.pack_start(cell,True)
|
|
|
|
self.title_menu.add_attribute(cell,'text',0)
|
|
|
|
self.title_menu.connect('changed',self.on_source_changed)
|
2002-11-26 18:43:31 +05:30
|
|
|
self.conf_menu = self.get_widget("conf")
|
2004-11-28 01:18:25 +05:30
|
|
|
self.private = self.get_widget("priv")
|
2003-03-24 09:21:07 +05:30
|
|
|
self.ok = self.get_widget("ok")
|
2005-01-02 10:46:25 +05:30
|
|
|
self.conf_menu.set_active(srcref.get_confidence_level())
|
2002-11-26 18:43:31 +05:30
|
|
|
|
|
|
|
self.author_field = self.get_widget("sauthor")
|
|
|
|
self.pub_field = self.get_widget("spubinfo")
|
|
|
|
|
2004-09-21 04:56:41 +05:30
|
|
|
self.date_entry_field = self.get_widget("sdate")
|
|
|
|
|
2002-11-26 18:43:31 +05:30
|
|
|
if self.source_ref:
|
2005-01-02 10:46:25 +05:30
|
|
|
handle = self.source_ref.get_base_handle()
|
|
|
|
self.active_source = self.db.get_source_from_handle(handle)
|
2004-09-21 04:56:41 +05:30
|
|
|
self.date_obj = self.source_ref.get_date()
|
2004-12-29 10:36:10 +05:30
|
|
|
self.date_entry_field.set_text(DateHandler.displayer.display(self.date_obj))
|
2004-11-28 01:18:25 +05:30
|
|
|
self.private.set_active(self.source_ref.get_privacy())
|
2002-11-26 18:43:31 +05:30
|
|
|
else:
|
2004-09-21 04:56:41 +05:30
|
|
|
self.date_obj = Date.Date()
|
2002-11-26 18:43:31 +05:30
|
|
|
self.active_source = None
|
2003-03-24 09:21:07 +05:30
|
|
|
|
2004-09-21 04:56:41 +05:30
|
|
|
date_stat = self.get_widget("date_stat")
|
|
|
|
self.date_check = DateEdit.DateEdit(self.date_obj,
|
2004-11-28 01:18:25 +05:30
|
|
|
self.date_entry_field,
|
|
|
|
date_stat,
|
|
|
|
self.sourceDisplay)
|
2004-09-20 23:26:26 +05:30
|
|
|
|
2005-02-26 07:26:34 +05:30
|
|
|
self.draw(self.active_source,fresh=True)
|
2003-03-24 09:21:07 +05:30
|
|
|
self.set_button()
|
2003-09-14 02:12:57 +05:30
|
|
|
if self.parent:
|
|
|
|
self.sourceDisplay.set_transient_for(self.parent.window)
|
2004-02-20 06:22:24 +05:30
|
|
|
self.add_itself_to_menu()
|
2004-02-20 05:09:01 +05:30
|
|
|
self.sourceDisplay.show()
|
|
|
|
|
|
|
|
def on_delete_event(self,obj,b):
|
2004-02-20 06:22:24 +05:30
|
|
|
self.close_child_windows()
|
|
|
|
self.remove_itself_from_menu()
|
2004-02-20 05:09:01 +05:30
|
|
|
|
|
|
|
def close(self,obj):
|
2004-02-20 06:22:24 +05:30
|
|
|
self.close_child_windows()
|
|
|
|
self.remove_itself_from_menu()
|
2004-02-20 08:58:41 +05:30
|
|
|
self.sourceDisplay.destroy()
|
2004-02-20 05:09:01 +05:30
|
|
|
|
|
|
|
def close_child_windows(self):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
for child_window in self.child_windows.values():
|
2004-02-21 12:10:44 +05:30
|
|
|
child_window.close(None)
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
self.child_windows = {}
|
2004-02-20 05:09:01 +05:30
|
|
|
|
|
|
|
def add_itself_to_menu(self):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
self.win_parent.child_windows[self.win_key] = self
|
2004-02-20 05:09:01 +05:30
|
|
|
if self.active_source:
|
|
|
|
label = self.active_source.get_title()
|
|
|
|
else:
|
|
|
|
label = _("New Source")
|
2004-02-20 06:22:24 +05:30
|
|
|
if not label.strip():
|
|
|
|
label = _("New Source")
|
|
|
|
label = "%s: %s" % (_('Source Reference'),label)
|
|
|
|
self.parent_menu_item = gtk.MenuItem(label)
|
|
|
|
self.parent_menu_item.set_submenu(gtk.Menu())
|
|
|
|
self.parent_menu_item.show()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.win_parent.winsmenu.append(self.parent_menu_item)
|
|
|
|
self.winsmenu = self.parent_menu_item.get_submenu()
|
2004-02-20 06:22:24 +05:30
|
|
|
self.menu_item = gtk.MenuItem(_('Source Information'))
|
2004-02-20 05:09:01 +05:30
|
|
|
self.menu_item.connect("activate",self.present)
|
|
|
|
self.menu_item.show()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.winsmenu.append(self.menu_item)
|
2004-02-20 05:09:01 +05:30
|
|
|
|
|
|
|
def remove_itself_from_menu(self):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
del self.win_parent.child_windows[self.win_key]
|
2004-02-20 05:09:01 +05:30
|
|
|
self.menu_item.destroy()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.winsmenu.destroy()
|
2004-02-20 06:22:24 +05:30
|
|
|
self.parent_menu_item.destroy()
|
2004-02-20 05:09:01 +05:30
|
|
|
|
|
|
|
def present(self,obj):
|
2004-02-20 06:22:24 +05:30
|
|
|
self.sourceDisplay.present()
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2003-11-19 23:30:58 +05:30
|
|
|
def on_help_clicked(self,obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
|
|
|
gnome.help_display('gramps-manual','adv-si')
|
|
|
|
|
2003-03-24 09:21:07 +05:30
|
|
|
def set_button(self):
|
|
|
|
if self.active_source:
|
|
|
|
self.ok.set_sensitive(1)
|
|
|
|
else:
|
|
|
|
self.ok.set_sensitive(0)
|
|
|
|
|
2002-11-26 18:43:31 +05:30
|
|
|
def get_widget(self,name):
|
|
|
|
"""returns the widget associated with the specified name"""
|
|
|
|
return self.showSource.get_widget(name)
|
|
|
|
|
2005-02-26 07:26:34 +05:30
|
|
|
def draw(self,sel=None,fresh=False):
|
|
|
|
if self.source_ref and fresh:
|
2003-07-21 05:39:12 +05:30
|
|
|
spage = self.get_widget("spage")
|
2004-02-14 11:10:30 +05:30
|
|
|
spage.get_buffer().set_text(self.source_ref.get_page())
|
2002-11-26 18:43:31 +05:30
|
|
|
|
|
|
|
text = self.get_widget("stext")
|
2004-02-14 11:10:30 +05:30
|
|
|
text.get_buffer().set_text(self.source_ref.get_text())
|
2002-11-26 18:43:31 +05:30
|
|
|
|
|
|
|
scom = self.get_widget("scomment")
|
2004-02-14 11:10:30 +05:30
|
|
|
scom.get_buffer().set_text(self.source_ref.get_comments())
|
2004-08-07 10:46:57 +05:30
|
|
|
src = self.db.get_source_from_handle(self.source_ref.get_base_handle())
|
2002-11-26 18:43:31 +05:30
|
|
|
self.active_source = src
|
|
|
|
if src:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.author_field.set_text(src.get_author())
|
|
|
|
self.pub_field.set_text(src.get_publication_info())
|
2002-11-26 18:43:31 +05:30
|
|
|
else:
|
|
|
|
self.author_field.set_text("")
|
|
|
|
self.pub_field.set_text("")
|
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
keys = self.db.get_source_handles()
|
2004-08-21 23:43:18 +05:30
|
|
|
keys.sort(self.db._sortbysource)
|
2005-01-02 10:46:25 +05:30
|
|
|
|
|
|
|
store = gtk.ListStore(gobject.TYPE_STRING)
|
|
|
|
|
2002-11-26 18:43:31 +05:30
|
|
|
sel_child = None
|
2003-03-24 09:21:07 +05:30
|
|
|
self.active_source = sel
|
2005-01-02 10:46:25 +05:30
|
|
|
index = 0
|
|
|
|
sel_index = 0
|
|
|
|
self.handle_list = []
|
2004-02-23 11:12:19 +05:30
|
|
|
for src_id in keys:
|
2004-08-07 10:46:57 +05:30
|
|
|
src = self.db.get_source_from_handle(src_id)
|
2005-01-02 10:46:25 +05:30
|
|
|
title = src.get_title()
|
|
|
|
gid = src.get_gramps_id()
|
|
|
|
handle = src.get_handle()
|
|
|
|
store.append(row=["%s [%s]" % (title,gid)])
|
|
|
|
self.handle_list.append(handle)
|
|
|
|
if sel and sel.get_handle() == src_id:
|
|
|
|
sel_index = index
|
|
|
|
index += 1
|
|
|
|
self.title_menu.set_model(store)
|
|
|
|
|
|
|
|
if index > 0:
|
2003-04-20 09:22:54 +05:30
|
|
|
self.title_menu.set_sensitive(1)
|
2005-01-02 10:46:25 +05:30
|
|
|
self.title_menu.set_active(sel_index)
|
2003-04-20 09:22:54 +05:30
|
|
|
else:
|
|
|
|
self.title_menu.set_sensitive(0)
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2004-02-20 05:09:01 +05:30
|
|
|
def on_sourceok_clicked(self,obj):
|
2003-03-24 09:21:07 +05:30
|
|
|
|
2004-08-07 10:46:57 +05:30
|
|
|
if self.active_source != self.db.get_source_from_handle(self.source_ref.get_base_handle()):
|
2004-07-28 07:59:07 +05:30
|
|
|
self.source_ref.set_base_handle(self.active_source.get_handle())
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2005-01-02 10:46:25 +05:30
|
|
|
conf = self.get_widget("conf").get_active()
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2004-08-23 04:46:57 +05:30
|
|
|
buf = self.get_widget("scomment").get_buffer()
|
|
|
|
comments = unicode(buf.get_text(buf.get_start_iter(),
|
2005-02-24 05:55:34 +05:30
|
|
|
buf.get_end_iter(),False))
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2004-08-23 04:46:57 +05:30
|
|
|
buf = self.get_widget("stext").get_buffer()
|
|
|
|
text = unicode(buf.get_text(buf.get_start_iter(),
|
2005-02-24 05:55:34 +05:30
|
|
|
buf.get_end_iter(),False))
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2004-08-23 04:46:57 +05:30
|
|
|
buf = self.get_widget('spage').get_buffer()
|
|
|
|
page = unicode(buf.get_text(buf.get_start_iter(),
|
2005-02-24 05:55:34 +05:30
|
|
|
buf.get_end_iter(),False))
|
2003-07-21 05:39:12 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source_ref.set_page(page)
|
2004-09-21 04:56:41 +05:30
|
|
|
self.source_ref.set_date(self.date_obj)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.source_ref.set_text(text)
|
|
|
|
self.source_ref.set_comments(comments)
|
|
|
|
self.source_ref.set_confidence_level(conf)
|
2004-11-28 01:18:25 +05:30
|
|
|
self.source_ref.set_privacy(self.private.get_active())
|
2002-11-26 18:43:31 +05:30
|
|
|
|
|
|
|
if self.update:
|
|
|
|
self.update(self.parent,self.source_ref)
|
|
|
|
|
2004-02-20 08:08:31 +05:30
|
|
|
self.close(obj)
|
2002-11-26 18:43:31 +05:30
|
|
|
|
|
|
|
def on_source_changed(self,obj):
|
2005-01-02 10:46:25 +05:30
|
|
|
handle = self.handle_list[obj.get_active()]
|
|
|
|
self.active_source = self.db.get_source_from_handle(handle)
|
|
|
|
self.author_field.set_text(self.active_source.get_author())
|
|
|
|
self.pub_field.set_text(self.active_source.get_publication_info())
|
|
|
|
self.set_button()
|
2003-03-24 09:21:07 +05:30
|
|
|
|
|
|
|
def update_display(self,source):
|
2005-02-26 07:26:34 +05:30
|
|
|
self.draw(source,fresh=False)
|
2002-11-26 18:43:31 +05:30
|
|
|
|
2003-03-24 09:21:07 +05:30
|
|
|
def add_src_clicked(self,obj):
|
|
|
|
import EditSource
|
2004-11-28 01:18:25 +05:30
|
|
|
EditSource.EditSource(RelLib.Source(),self.db, self,
|
|
|
|
self.sourceDisplay, self.update_display)
|
2002-11-26 18:43:31 +05:30
|
|
|
|