remove usued files
svn: r6079
This commit is contained in:
parent
0ce3b5745a
commit
12aa0b0d73
@ -1316,8 +1316,8 @@ class GalleryTab(ButtonTab):
|
||||
except Errors.WindowActiveError:
|
||||
pass
|
||||
|
||||
def add_callback(self,name):
|
||||
self.get_data().append(name)
|
||||
def add_callback(self,media_ref, media):
|
||||
self.get_data().append(media_ref)
|
||||
self.changed = True
|
||||
self.rebuild()
|
||||
|
||||
@ -1339,7 +1339,7 @@ class GalleryTab(ButtonTab):
|
||||
except Errors.WindowActiveError:
|
||||
pass
|
||||
|
||||
def edit_callback(self, name):
|
||||
def edit_callback(self, media_ref, ref):
|
||||
self.changed = True
|
||||
self.rebuild()
|
||||
|
||||
|
@ -51,40 +51,37 @@ import GrampsDisplay
|
||||
|
||||
from DisplayTabs import *
|
||||
from GrampsWidgets import *
|
||||
from _EditReference import EditReference
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# LocalMediaProperties
|
||||
# EditMediaRef
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class EditMediaRef(DisplayState.ManagedWindow):
|
||||
class EditMediaRef(EditReference):
|
||||
def __init__(self, state, uistate, track, media, media_ref, update):
|
||||
|
||||
self.db = state.db
|
||||
self.state = state
|
||||
self.media_ref = media_ref
|
||||
self.media = media
|
||||
self.update = update
|
||||
EditReference.__init__(self, state, uistate, track, media,
|
||||
media_ref, update)
|
||||
|
||||
self.db = self.state.db
|
||||
|
||||
DisplayState.ManagedWindow.__init__(self, uistate, track, media_ref)
|
||||
def _local_init(self):
|
||||
|
||||
self.top = gtk.glade.XML(const.gladeFile,
|
||||
"change_description","gramps")
|
||||
"change_description","gramps")
|
||||
|
||||
title = _('Media Reference Editor')
|
||||
self.window = self.top.get_widget('change_description')
|
||||
Utils.set_titles(self.window,
|
||||
self.top.get_widget('title'), title)
|
||||
self.define_top_level(self.top.get_widget('change_description'),
|
||||
self.top.get_widget('title'),
|
||||
_('Media Reference Editor'))
|
||||
|
||||
mtype = self.media.get_mime_type()
|
||||
def _setup_fields(self):
|
||||
|
||||
self.pix = ImgManip.get_thumbnail_image(self.media.get_path(),mtype)
|
||||
mtype = self.source.get_mime_type()
|
||||
|
||||
self.pix = ImgManip.get_thumbnail_image(self.source.get_path(),mtype)
|
||||
self.pixmap = self.top.get_widget("pixmap")
|
||||
self.pixmap.set_from_pixbuf(self.pix)
|
||||
|
||||
coord = media_ref.get_rectangle()
|
||||
coord = self.source_ref.get_rectangle()
|
||||
|
||||
if coord and type(coord) == tuple:
|
||||
self.top.get_widget("upperx").set_value(coord[0])
|
||||
@ -94,25 +91,25 @@ class EditMediaRef(DisplayState.ManagedWindow):
|
||||
|
||||
self.descr_window = MonitoredEntry(
|
||||
self.top.get_widget("description"),
|
||||
self.media.set_description,
|
||||
self.media.get_description,
|
||||
self.source.set_description,
|
||||
self.source.get_description,
|
||||
self.db.readonly)
|
||||
|
||||
self.privacy = PrivacyButton(
|
||||
self.top.get_widget("private"),
|
||||
self.media_ref,
|
||||
self.source_ref,
|
||||
self.db.readonly)
|
||||
|
||||
self.gid = MonitoredEntry(
|
||||
self.top.get_widget("gid"),
|
||||
self.media.set_gramps_id,
|
||||
self.media.get_gramps_id,
|
||||
self.source.set_gramps_id,
|
||||
self.source.get_gramps_id,
|
||||
self.db.readonly)
|
||||
|
||||
self.path_obj = MonitoredEntry(
|
||||
self.top.get_widget("path"),
|
||||
self.media.set_path,
|
||||
self.media.get_path,
|
||||
self.source.set_path,
|
||||
self.source.get_path,
|
||||
self.db.readonly)
|
||||
|
||||
mt = Mime.get_description(mtype)
|
||||
@ -121,18 +118,9 @@ class EditMediaRef(DisplayState.ManagedWindow):
|
||||
else:
|
||||
self.top.get_widget("type").set_text("")
|
||||
|
||||
self.notebook_ref = self.top.get_widget('notebook_ref')
|
||||
self.notebook_src = self.top.get_widget('notebook_shared')
|
||||
|
||||
self._create_tabbed_pages()
|
||||
self._connect_signals()
|
||||
self.show()
|
||||
|
||||
def _connect_signals(self):
|
||||
self.window.connect('delete_event',self.on_delete_event)
|
||||
self.top.get_widget('button84').connect('clicked',self.close_window)
|
||||
self.top.get_widget('button82').connect('clicked',self.on_ok_clicked)
|
||||
self.top.get_widget('button104').connect('clicked',self.on_help_clicked)
|
||||
self.define_cancel_button(self.top.get_widget('button84'))
|
||||
self.define_ok_button(self.top.get_widget('button82'),self.save)
|
||||
|
||||
def _create_tabbed_pages(self):
|
||||
"""
|
||||
@ -140,52 +128,45 @@ class EditMediaRef(DisplayState.ManagedWindow):
|
||||
window.
|
||||
|
||||
"""
|
||||
self.srcref_list = self._add_ref_page(SourceEmbedList(
|
||||
self.state,self.uistate, self.track,
|
||||
self.media_ref.source_list))
|
||||
notebook_ref = self.top.get_widget('notebook_ref')
|
||||
notebook_src = self.top.get_widget('notebook_shared')
|
||||
|
||||
self.attr_list = self._add_ref_page(AttrEmbedList(
|
||||
self.state,self.uistate,self.track,
|
||||
self.media_ref.get_attribute_list()))
|
||||
self.srcref_list = self._add_tab(
|
||||
notebook_ref,
|
||||
SourceEmbedList(self.dbstate,self.uistate, self.track,
|
||||
self.source_ref.source_list))
|
||||
|
||||
self.backref_list = self._add_src_page(MediaBackRefList(
|
||||
self.state,self.uistate,self.track,
|
||||
self.db.find_backlink_handles(self.media.handle)))
|
||||
self.attr_list = self._add_tab(
|
||||
notebook_ref,
|
||||
AttrEmbedList(self.dbstate,self.uistate,self.track,
|
||||
self.source_ref.get_attribute_list()))
|
||||
|
||||
self.note_ref_tab = self._add_ref_page(NoteTab(
|
||||
self.state, self.uistate, self.track,
|
||||
self.media_ref.get_note_object()))
|
||||
self.backref_list = self._add_tab(
|
||||
notebook_src,
|
||||
MediaBackRefList(self.dbstate,self.uistate,self.track,
|
||||
self.db.find_backlink_handles(self.source.handle)))
|
||||
|
||||
self.src_srcref_list = self._add_src_page(SourceEmbedList(
|
||||
self.state,self.uistate, self.track,
|
||||
self.media.source_list))
|
||||
self.note_ref_tab = self._add_tab(
|
||||
notebook_ref,
|
||||
NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.source_ref.get_note_object()))
|
||||
|
||||
self.src_attr_list = self._add_src_page(AttrEmbedList(
|
||||
self.state,self.uistate,self.track,
|
||||
self.media.get_attribute_list()))
|
||||
self.src_srcref_list = self._add_tab(
|
||||
notebook_src,
|
||||
SourceEmbedList(self.dbstate,self.uistate, self.track,
|
||||
self.source.source_list))
|
||||
|
||||
self.src_note_ref_tab = self._add_src_page(NoteTab(
|
||||
self.state, self.uistate, self.track,
|
||||
self.media.get_note_object()))
|
||||
self.src_attr_list = self._add_tab(
|
||||
notebook_src,
|
||||
AttrEmbedList(self.dbstate,self.uistate,self.track,
|
||||
self.source.get_attribute_list()))
|
||||
|
||||
def _add_ref_page(self,page):
|
||||
self.notebook_ref.insert_page(page)
|
||||
self.notebook_ref.set_tab_label(page,page.get_tab_widget())
|
||||
return page
|
||||
self.src_note_ref_tab = self._add_tab(
|
||||
notebook_src,
|
||||
NoteTab(self.dbstate, self.uistate, self.track,
|
||||
self.source.get_note_object()))
|
||||
|
||||
def _add_src_page(self,page):
|
||||
self.notebook_src.insert_page(page)
|
||||
self.notebook_src.set_tab_label(page,page.get_tab_widget())
|
||||
return page
|
||||
|
||||
def on_delete_event(self,obj,b):
|
||||
self.close()
|
||||
|
||||
def close_window(self,obj):
|
||||
self.window.destroy()
|
||||
self.close()
|
||||
|
||||
def on_apply_clicked(self):
|
||||
def save(self,*obj):
|
||||
|
||||
coord = (
|
||||
self.top.get_widget("upperx").get_value_as_int(),
|
||||
@ -193,25 +174,20 @@ class EditMediaRef(DisplayState.ManagedWindow):
|
||||
self.top.get_widget("lowerx").get_value_as_int(),
|
||||
self.top.get_widget("lowery").get_value_as_int(),
|
||||
)
|
||||
|
||||
if (coord[0] == None and coord[1] == None
|
||||
and coord[2] == None and coord[3] == None):
|
||||
coord = None
|
||||
|
||||
self.media_ref.set_rectangle(coord)
|
||||
self.source_ref.set_rectangle(coord)
|
||||
|
||||
orig = self.db.get_object_from_handle(self.media.handle)
|
||||
orig = self.db.get_object_from_handle(self.source.handle)
|
||||
|
||||
if cmp(orig.serialize(),self.media.serialize()):
|
||||
if cmp(orig.serialize(),self.source.serialize()):
|
||||
trans = self.db.transaction_begin()
|
||||
self.db.commit_media_object(self.media,trans)
|
||||
self.db.commit_media_object(self.source,trans)
|
||||
self.db.transaction_commit(trans,_("Edit Media Object"))
|
||||
|
||||
self.update(self.media_ref)
|
||||
|
||||
def on_help_clicked(self, obj):
|
||||
"""Display the relevant portion of GRAMPS manual"""
|
||||
GrampsDisplay.help('gramps-edit-complete')
|
||||
|
||||
def on_ok_clicked(self,obj):
|
||||
self.on_apply_clicked()
|
||||
self.close()
|
||||
if self.update:
|
||||
self.update(self.source_ref,self.source)
|
||||
self.close_window()
|
||||
|
@ -89,7 +89,6 @@ gdir_PYTHON = \
|
||||
Report.py\
|
||||
ReportUtils.py\
|
||||
ScratchPad.py\
|
||||
SelectChild.py\
|
||||
SelectEvent.py\
|
||||
SelectObject.py\
|
||||
SelectPerson.py\
|
||||
@ -108,8 +107,7 @@ gdir_PYTHON = \
|
||||
TreeTips.py\
|
||||
Utils.py\
|
||||
ViewManager.py\
|
||||
WindowUtils.py\
|
||||
Witness.py
|
||||
WindowUtils.py
|
||||
|
||||
# Could use GNU make's ':=' syntax for nice wildcard use.
|
||||
# If not using GNU make, then list all files individually
|
||||
|
@ -1,356 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 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$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# internationalization
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
import gc
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk.glade
|
||||
import gobject
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import RelLib
|
||||
import const
|
||||
import Utils
|
||||
import PeopleModel
|
||||
import NameDisplay
|
||||
import AutoComp
|
||||
import GenericFilter
|
||||
import GrampsDisplay
|
||||
from QuestionDialog import ErrorDialog
|
||||
from WindowUtils import GladeIf
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
UNKNOWN_REL = (RelLib.Person.CHILD_UNKNOWN,
|
||||
Utils.child_relations[RelLib.Person.CHILD_UNKNOWN])
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# SelectChild
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class SelectChild:
|
||||
|
||||
def __init__(self,parent,db,family,person,callback):
|
||||
self.parent = parent
|
||||
self.db = db
|
||||
self.callback = callback
|
||||
self.person = person
|
||||
self.family = family
|
||||
self.renderer = gtk.CellRendererText()
|
||||
self.xml = gtk.glade.XML(const.gladeFile,"select_child","gramps")
|
||||
self.gladeif = GladeIf(self.xml)
|
||||
|
||||
if person:
|
||||
self.default_name = person.get_primary_name().get_surname().upper()
|
||||
else:
|
||||
self.default_name = ""
|
||||
|
||||
self.gladeif.connect('select_child','delete_event', self.on_delete_event)
|
||||
self.gladeif.connect('button49','clicked', self.close)
|
||||
self.gladeif.connect('button48','clicked', self.on_save_child_clicked)
|
||||
self.gladeif.connect('button163','clicked',self.on_child_help_clicked)
|
||||
self.gladeif.connect('checkbutton1','toggled',self.on_show_toggled)
|
||||
|
||||
self.select_child_list = {}
|
||||
self.top = self.xml.get_widget("select_child")
|
||||
title_label = self.xml.get_widget('title')
|
||||
|
||||
Utils.set_titles(self.top,title_label,_('Add Child to Family'))
|
||||
|
||||
self.add_child = self.xml.get_widget("childlist")
|
||||
|
||||
self.mrel = self.xml.get_widget("mrel_combo")
|
||||
self.frel = self.xml.get_widget("frel_combo")
|
||||
|
||||
self.frel_selector = AutoComp.StandardCustomSelector(
|
||||
Utils.child_relations,self.frel,
|
||||
RelLib.Person.CHILD_CUSTOM,RelLib.Person.CHILD_BIRTH)
|
||||
self.mrel_selector = AutoComp.StandardCustomSelector(
|
||||
Utils.child_relations,self.mrel,
|
||||
RelLib.Person.CHILD_CUSTOM,RelLib.Person.CHILD_BIRTH)
|
||||
|
||||
#self.build_list(self.mrel,RelLib.Person.CHILD_BIRTH)
|
||||
#self.build_list(self.frel,RelLib.Person.CHILD_BIRTH)
|
||||
|
||||
if self.family:
|
||||
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
||||
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
|
||||
else:
|
||||
if self.person.get_gender() == RelLib.Person.MALE:
|
||||
self.mrel.set_sensitive(False)
|
||||
else:
|
||||
self.frel.set_sensitive(False)
|
||||
|
||||
self.likely_filter = GenericFilter.GenericFilter()
|
||||
self.likely_filter.add_rule(LikelyFilter([self.person.handle]))
|
||||
self.active_filter = self.likely_filter
|
||||
|
||||
self.top.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
||||
gobject.idle_add(self.redraw_child_list)
|
||||
self.add_itself_to_menu()
|
||||
self.add_columns(self.add_child)
|
||||
self.top.show()
|
||||
|
||||
def build_list(self,opt_menu,sel):
|
||||
cell = gtk.CellRendererText()
|
||||
opt_menu.pack_start(cell,True)
|
||||
opt_menu.add_attribute(cell,'text',0)
|
||||
|
||||
store = gtk.ListStore(str)
|
||||
for val in Utils.child_relations.values():
|
||||
store.append(row=[val])
|
||||
opt_menu.set_model(store)
|
||||
opt_menu.set_active(sel)
|
||||
|
||||
def add_columns(self,tree):
|
||||
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
|
||||
column.set_resizable(True)
|
||||
#column.set_clickable(True)
|
||||
column.set_min_width(225)
|
||||
tree.append_column(column)
|
||||
column = gtk.TreeViewColumn(_('ID'), self.renderer,text=1)
|
||||
column.set_resizable(True)
|
||||
#column.set_clickable(True)
|
||||
column.set_min_width(75)
|
||||
tree.append_column(column)
|
||||
column = gtk.TreeViewColumn(_('Birth date'), self.renderer,text=3)
|
||||
#column.set_resizable(True)
|
||||
column.set_clickable(True)
|
||||
tree.append_column(column)
|
||||
|
||||
def on_delete_event(self,obj,b):
|
||||
self.gladeif.close()
|
||||
self.remove_itself_from_menu()
|
||||
gc.collect()
|
||||
|
||||
def close(self,obj):
|
||||
self.gladeif.close()
|
||||
self.remove_itself_from_menu()
|
||||
self.top.destroy()
|
||||
gc.collect()
|
||||
|
||||
def add_itself_to_menu(self):
|
||||
self.parent.child_windows[self] = self
|
||||
self.parent_menu_item = gtk.MenuItem(_('Add Child to Family'))
|
||||
self.parent_menu_item.connect("activate",self.present)
|
||||
self.parent_menu_item.show()
|
||||
self.parent.winsmenu.append(self.parent_menu_item)
|
||||
|
||||
def remove_itself_from_menu(self):
|
||||
del self.parent.child_windows[self]
|
||||
self.parent_menu_item.destroy()
|
||||
|
||||
def present(self,obj):
|
||||
self.top.present()
|
||||
|
||||
def on_child_help_clicked(self,obj):
|
||||
"""Display the relevant portion of GRAMPS manual"""
|
||||
GrampsDisplay.help('gramps-edit-quick')
|
||||
|
||||
def redraw_child_list(self):
|
||||
self.refmodel = PeopleModel.PeopleModel(self.db,self.active_filter)
|
||||
self.add_child.set_model(self.refmodel)
|
||||
self.top.window.set_cursor(None)
|
||||
|
||||
def select_function(self,store,path,node,id_list):
|
||||
id_list.append(self.refmodel.get_value(node,PeopleModel.COLUMN_INT_ID))
|
||||
|
||||
def get_selected_ids(self):
|
||||
mlist = []
|
||||
self.add_child.get_selection().selected_foreach(self.select_function,mlist)
|
||||
return mlist
|
||||
|
||||
def on_save_child_clicked(self,obj):
|
||||
|
||||
idlist = self.get_selected_ids()
|
||||
|
||||
if not idlist or not idlist[0]:
|
||||
return
|
||||
|
||||
handle = idlist[0]
|
||||
select_child = self.db.get_person_from_handle(handle)
|
||||
if self.person.get_handle() == handle:
|
||||
ErrorDialog(_("Error selecting a child"),
|
||||
_("A person cannot be linked as his/her own child"),
|
||||
self.top)
|
||||
return
|
||||
|
||||
trans = self.db.transaction_begin()
|
||||
|
||||
if self.family == None:
|
||||
self.family = RelLib.Family()
|
||||
self.db.add_family(self.family,trans)
|
||||
self.person.add_family_handle(self.family.get_handle())
|
||||
self.db.commit_person(self.person,trans)
|
||||
if self.person.get_gender() == RelLib.Person.MALE:
|
||||
self.family.set_father_handle(self.person.get_handle())
|
||||
else:
|
||||
self.family.set_mother_handle(self.person.get_handle())
|
||||
self.db.commit_family(self.family,trans)
|
||||
|
||||
# check that selected child is not already a child in family
|
||||
if handle in self.family.get_child_handle_list():
|
||||
ErrorDialog(_("Error selecting a child"),
|
||||
_("The person is already linked as child"),
|
||||
self.top)
|
||||
return
|
||||
|
||||
# check that selected child is not already a spouse in family
|
||||
if handle in (self.family.get_father_handle(),self.family.get_mother_handle()):
|
||||
ErrorDialog(_("Error selecting a child"),
|
||||
_("A person cannot be linked as his/her own child"),
|
||||
self.top)
|
||||
return
|
||||
|
||||
# TODO: Add child ordered by birth day
|
||||
self.family.add_child_handle(select_child.get_handle())
|
||||
|
||||
mrel = self.mrel_selector.get_values()
|
||||
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
|
||||
if mother and mother.get_gender() != RelLib.Person.FEMALE:
|
||||
if mrel[0] == RelLib.Person.CHILD_BIRTH:
|
||||
mrel = UNKNOWN_REL
|
||||
|
||||
frel = self.frel_selector.get_values()
|
||||
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
||||
if father and father.get_gender() != RelLib.Person.MALE:
|
||||
if frel[0] == RelLib.Person.CHILD_BIRTH:
|
||||
frel = UNKNOWN_REL
|
||||
|
||||
select_child.add_parent_family_handle(self.family.get_handle(),
|
||||
mrel,frel)
|
||||
|
||||
self.db.commit_person(select_child,trans)
|
||||
self.db.commit_family(self.family,trans)
|
||||
n = NameDisplay.displayer.display(select_child)
|
||||
self.db.transaction_commit(trans,_("Add Child to Family (%s)") % n)
|
||||
self.close(obj)
|
||||
self.callback()
|
||||
|
||||
def on_show_toggled(self,obj):
|
||||
if obj.get_active():
|
||||
self.active_filter = None
|
||||
else:
|
||||
self.active_filter = self.likely_filter
|
||||
self.top.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
||||
while(gtk.events_pending()):
|
||||
gtk.main_iteration()
|
||||
self.redraw_child_list()
|
||||
|
||||
def north_american(self,val):
|
||||
if self.person.get_gender() == RelLib.Person.MALE:
|
||||
return self.person.get_primary_name().get_surname()
|
||||
elif self.family:
|
||||
f = self.family.get_father_handle()
|
||||
if f:
|
||||
pname = f.get_primary_name()
|
||||
return (pname.get_surname_prefix(),pname.get_surname())
|
||||
return ("","")
|
||||
|
||||
def no_name(self,val):
|
||||
return ("","")
|
||||
|
||||
def latin_american(self,val):
|
||||
if self.family:
|
||||
father = self.family.get_father_handle()
|
||||
mother = self.family.get_mother_handle()
|
||||
if not father or not mother:
|
||||
return ("","")
|
||||
fsn = father.get_primary_name().get_surname()
|
||||
msn = mother.get_primary_name().get_surname()
|
||||
if not father or not mother:
|
||||
return ("","")
|
||||
try:
|
||||
return ("","%s %s" % (fsn.split()[0],msn.split()[0]))
|
||||
except:
|
||||
return ("","")
|
||||
else:
|
||||
return ("","")
|
||||
|
||||
def icelandic(self,val):
|
||||
fname = ""
|
||||
if self.person.get_gender() == RelLib.Person.MALE:
|
||||
fname = self.person.get_primary_name().get_first_name()
|
||||
elif self.family:
|
||||
f = self.family.get_father_handle()
|
||||
if f:
|
||||
fname = f.get_primary_name().get_first_name()
|
||||
if fname:
|
||||
fname = fname.split()[0]
|
||||
if val == 0:
|
||||
return ("","%ssson" % fname)
|
||||
elif val == 1:
|
||||
return ("","%sdóttir" % fname)
|
||||
else:
|
||||
return ("","")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Likely Filters
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class LikelyFilter(GenericFilter.Rule):
|
||||
|
||||
labels = [ 'Person handle' ]
|
||||
category = _('General filters')
|
||||
|
||||
def prepare(self,db):
|
||||
person = db.get_person_from_handle(self.list[0])
|
||||
if person.birth_handle:
|
||||
birth = db.get_event_from_handle(person.birth_handle)
|
||||
dateobj = RelLib.Date(birth.date)
|
||||
year = dateobj.get_year()
|
||||
dateobj.set_year(year+10)
|
||||
self.lower = dateobj.sortval
|
||||
dateobj.set_year(year+70)
|
||||
self.upper = dateobj.sortval
|
||||
else:
|
||||
self.lower = None
|
||||
self.upper = None
|
||||
|
||||
def apply(self,db,person):
|
||||
if not person.birth_handle or (self.upper == None and
|
||||
self.lower == None):
|
||||
return True
|
||||
event = db.get_event_from_handle(person.birth_handle)
|
||||
return (event.date == None or event.date.sortval == 0 or
|
||||
self.lower < event.date.sortval < self.upper)
|
||||
|
@ -1,276 +0,0 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2003-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 _
|
||||
import gc
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
import gtk.glade
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
import Utils
|
||||
import RelLib
|
||||
import ListModel
|
||||
import NameDisplay
|
||||
import GrampsDisplay
|
||||
from WindowUtils import GladeIf
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# WitnessTab
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class WitnessTab:
|
||||
def __init__(self,srclist,parent,top,window,clist,add_btn,edit_btn,del_btn):
|
||||
self.db = parent.db
|
||||
self.parent = parent
|
||||
self.list = srclist
|
||||
self.top = top
|
||||
self.window = window
|
||||
self.slist = clist
|
||||
self.selection = clist.get_selection()
|
||||
titles = [
|
||||
(_('Witness'), 0, 300, ListModel.TEXT, None, None),
|
||||
(_('ID'), 1, 100, ListModel.TEXT, None, None)
|
||||
]
|
||||
|
||||
self.model = ListModel.ListModel(
|
||||
clist,titles,event_func=self.edit_clicked);
|
||||
|
||||
add_btn.connect('clicked', self.add_clicked)
|
||||
edit_btn.connect('clicked', self.edit_clicked)
|
||||
del_btn.connect('clicked', self.del_clicked)
|
||||
|
||||
self.redraw()
|
||||
|
||||
def redraw(self):
|
||||
self.model.clear()
|
||||
for s in self.list:
|
||||
if s.get_type() == RelLib.Event.ID:
|
||||
handle = s.get_value()
|
||||
if self.db.has_person_handle(handle):
|
||||
person = self.db.get_person_from_handle(handle)
|
||||
n = NameDisplay.displayer.sorted(person)
|
||||
the_id = person.get_gramps_id()
|
||||
else:
|
||||
n = _('Unknown')
|
||||
the_id = ''
|
||||
self.model.add([n,the_id],s)
|
||||
else:
|
||||
self.model.add([s.get_value(),''],s)
|
||||
if self.list:
|
||||
Utils.bold_label(self.parent.witnesses_label)
|
||||
else:
|
||||
Utils.unbold_label(self.parent.witnesses_label)
|
||||
|
||||
def update_clist(self):
|
||||
self.redraw()
|
||||
self.parent.lists_changed = 1
|
||||
|
||||
def edit_clicked(self,obj):
|
||||
store,node = self.selection.get_selected()
|
||||
if node:
|
||||
objs = self.model.get_selected_objects()
|
||||
src = objs[0]
|
||||
WitnessEditor(src,self.db,self,self.update_clist,self.window)
|
||||
|
||||
def add_clicked(self,obj):
|
||||
WitnessEditor(None,self.db,self,self.update_clist,self.window)
|
||||
|
||||
def add_ref(self,inst,ref):
|
||||
self.parent.lists_changed = 1
|
||||
inst.list.append(ref)
|
||||
inst.redraw()
|
||||
|
||||
def del_clicked(self,obj):
|
||||
(store,node) = self.selection.get_selected()
|
||||
if node:
|
||||
path = store.get_path(node)
|
||||
del self.list[path[0]]
|
||||
self.redraw()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# WitnessEditor
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class WitnessEditor:
|
||||
|
||||
def __init__(self,ref,database,parent,update=None,parent_window=None):
|
||||
|
||||
self.db = database
|
||||
self.parent = parent
|
||||
if ref:
|
||||
if self.parent.parent.child_windows.has_key(ref):
|
||||
self.parent.parent.child_windows[ref].present(None)
|
||||
return
|
||||
else:
|
||||
self.win_key = ref
|
||||
else:
|
||||
self.win_key = self
|
||||
self.update = update
|
||||
self.ref = ref
|
||||
self.show_witness = gtk.glade.XML(const.gladeFile,
|
||||
"witness_edit","gramps")
|
||||
self.gladeif = GladeIf(self.show_witness)
|
||||
|
||||
self.gladeif.connect('witness_edit','delete_event',
|
||||
self.on_delete_event)
|
||||
self.gladeif.connect('cancelbutton1','clicked',self.close)
|
||||
self.gladeif.connect('ok','clicked',self.ok_clicked)
|
||||
self.gladeif.connect('button132','clicked',self.on_help_clicked)
|
||||
self.gladeif.connect('in_db','toggled',self.on_toggled)
|
||||
|
||||
self.window = self.show_witness.get_widget('witness_edit')
|
||||
self.name = self.show_witness.get_widget("name")
|
||||
self.private = self.show_witness.get_widget("priv")
|
||||
self.select = self.show_witness.get_widget("select")
|
||||
self.select.connect('clicked',self.choose)
|
||||
self.ok = self.show_witness.get_widget("ok")
|
||||
self.in_db = self.show_witness.get_widget("in_db")
|
||||
self.comment = self.show_witness.get_widget("comment")
|
||||
|
||||
if self.ref:
|
||||
if self.ref.get_type():
|
||||
self.idval = self.ref.get_value()
|
||||
if self.db.has_person_handle(self.idval):
|
||||
person = self.db.get_person_from_handle(self.idval)
|
||||
name = NameDisplay.displayer.display(person)
|
||||
self.name.set_text(name)
|
||||
self.in_db.set_active(True)
|
||||
else:
|
||||
self.name.set_text(_("Unknown"))
|
||||
self.in_db.set_active(False)
|
||||
else:
|
||||
self.name.set_text(self.ref.get_value())
|
||||
self.in_db.set_active(False)
|
||||
self.comment.get_buffer().set_text(self.ref.get_comment())
|
||||
self.private.set_active(self.ref.get_privacy())
|
||||
|
||||
self.on_toggled(None)
|
||||
Utils.set_titles(self.show_witness.get_widget('witness_edit'),
|
||||
self.show_witness.get_widget('title'),
|
||||
_('Witness Editor'))
|
||||
|
||||
if parent_window:
|
||||
self.window.set_transient_for(parent_window)
|
||||
self.add_itself_to_menu()
|
||||
self.window.show()
|
||||
|
||||
def on_delete_event(self,obj,b):
|
||||
self.gladeif.close()
|
||||
self.remove_itself_from_menu()
|
||||
gc.collect()
|
||||
|
||||
def close(self,obj):
|
||||
self.gladeif.close()
|
||||
self.remove_itself_from_menu()
|
||||
self.window.destroy()
|
||||
gc.collect()
|
||||
|
||||
def add_itself_to_menu(self):
|
||||
self.parent.parent.child_windows[self.win_key] = self
|
||||
self.parent_menu_item = gtk.MenuItem(_('Witness Editor'))
|
||||
self.parent_menu_item.connect("activate",self.present)
|
||||
self.parent_menu_item.show()
|
||||
self.parent.parent.winsmenu.append(self.parent_menu_item)
|
||||
|
||||
def remove_itself_from_menu(self):
|
||||
del self.parent.parent.child_windows[self.win_key]
|
||||
self.parent_menu_item.destroy()
|
||||
|
||||
def present(self,obj):
|
||||
self.window.present()
|
||||
|
||||
def on_help_clicked(self,obj):
|
||||
"""Display the relevant portion of GRAMPS manual"""
|
||||
GrampsDisplay.help('adv-wit')
|
||||
|
||||
def choose(self,obj):
|
||||
import SelectPerson
|
||||
sel_person = SelectPerson.SelectPerson(self.db,_('Select Person'),
|
||||
parent_window=self.window)
|
||||
new_person = sel_person.run()
|
||||
if new_person:
|
||||
self.new_person = new_person
|
||||
self.idval = new_person.get_handle()
|
||||
new_name = NameDisplay.displayer.display(new_person)
|
||||
if new_name:
|
||||
self.name.set_text(new_name)
|
||||
|
||||
def on_toggled(self,obj):
|
||||
if self.in_db.get_active():
|
||||
self.name.set_editable(False)
|
||||
self.name.set_sensitive(False)
|
||||
self.select.set_sensitive(True)
|
||||
else:
|
||||
self.name.set_editable(True)
|
||||
self.name.set_sensitive(True)
|
||||
self.select.set_sensitive(False)
|
||||
|
||||
def ok_clicked(self,obj):
|
||||
if not self.ref:
|
||||
if self.in_db.get_active():
|
||||
self.ref = RelLib.Witness(RelLib.Event.ID)
|
||||
else:
|
||||
self.ref = RelLib.Witness(RelLib.Event.NAME)
|
||||
self.parent.list.append(self.ref)
|
||||
|
||||
if self.in_db.get_active():
|
||||
try:
|
||||
self.ref.set_value(self.idval)
|
||||
self.ref.set_type(RelLib.Event.ID)
|
||||
except AttributeError:
|
||||
import QuestionDialog
|
||||
QuestionDialog.ErrorDialog(
|
||||
_("Witness selection error"),
|
||||
_("Since you have indicated that the person is "
|
||||
"in the database, you need to actually select "
|
||||
"the person by pressing the Select button.\n\n"
|
||||
"Please try again. The witness has not been changed."),
|
||||
self.window)
|
||||
else:
|
||||
self.ref.set_value(unicode(self.name.get_text()))
|
||||
self.ref.set_type(RelLib.Event.NAME)
|
||||
|
||||
c = self.comment.get_buffer()
|
||||
self.ref.set_comment(unicode(c.get_text(c.get_start_iter(),c.get_end_iter(),False)))
|
||||
self.ref.set_privacy(self.private.get_active())
|
||||
|
||||
if self.update:
|
||||
self.update()
|
||||
self.close(obj)
|
Loading…
Reference in New Issue
Block a user