* src/DisplayTabs.py: sub tabs for edit dialogs

* src/EditFamily.py: family editor integration
* src/gramps.glade: family editor changes


svn: r5732
This commit is contained in:
Don Allingham 2006-01-13 00:45:22 +00:00
parent 1866e43281
commit 4d840ed97d
5 changed files with 887 additions and 2121 deletions

View File

@ -1,3 +1,8 @@
2006-01-12 Don Allingham <don@gramps-project.org>
* src/DisplayTabs.py: sub tabs for edit dialogs
* src/EditFamily.py: family editor integration
* src/gramps.glade: family editor changes
2006-01-12 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/ObjectSelector/_ObjectSelectorWindow.py: initial outline of
ObjectSelector

View File

@ -197,87 +197,6 @@ class BaseModel(gtk.GenericTreeModel):
def on_iter_parent(self, node):
'''returns the parent of this node'''
return None
#-------------------------------------------------------------------------
#
# ChildModel
#
#-------------------------------------------------------------------------
class ChildModel(gtk.ListStore):
def __init__(self,child_list,db):
gtk.ListStore.__init__(self,int,str,str,str,str,str,str,str,str,str,int,int)
self.db = db
index = 1
for child_handle in child_list:
child = db.get_person_from_handle(child_handle)
self.append(row=[index,
child.get_gramps_id(),
NameDisplay.displayer.display(child),
_GENDER[child.get_gender()],
self.column_birth_day(child),
self.column_death_day(child),
self.column_birth_place(child),
self.column_death_place(child),
child.get_handle(),
child.get_primary_name().get_sort_name(),
self.column_birth_sort(child),
self.column_death_sort(child),
])
index += 1
def column_birth_day(self,data):
event_ref = data.get_birth_ref()
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
return DateHandler.get_date(event)
else:
return u""
def column_birth_sort(self,data):
event_ref = data.get_birth_ref()
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
return event.get_date_object().get_sort_value()
else:
return 0
def column_death_day(self,data):
event_ref = data.get_death_ref()
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
return DateHandler.get_date(event)
else:
return u""
def column_death_sort(self,data):
event_ref = data.get_death_ref()
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
return event.get_date_object().get_sort_value()
else:
return 0
def column_birth_place(self,data):
event_ref = data.get_birth_ref()
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
if event:
place_handle = event.get_place_handle()
if place_handle:
return self.db.get_place_from_handle(place_handle).get_title()
return u""
def column_death_place(self,data):
event_ref = data.get_death_ref()
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
if event:
place_handle = event.get_place_handle()
if place_handle:
return self.db.get_place_from_handle(place_handle).get_title()
return u""
#-------------------------------------------------------------------------
#

205
src/DisplayTabs.py Normal file
View File

@ -0,0 +1,205 @@
import gtk
import DateHandler
import NameDisplay
import RelLib
import Utils
import ToolTips
import GrampsLocale
_GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]
#-------------------------------------------------------------------------
#
# Localized constants
#
#-------------------------------------------------------------------------
_codeset = GrampsLocale.codeset
def sfunc(a,b):
return locale.strcoll(a[0],b[0])
class EmbeddedList(gtk.HBox):
_HANDLE_COL = 8
def __init__(self, db, build_model):
gtk.HBox.__init__(self)
self.build_model = build_model
self.tree = gtk.TreeView()
self.tree.set_rules_hint(True)
scroll = gtk.ScrolledWindow()
scroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
scroll.add_with_viewport(self.tree)
self.pack_start(scroll,True)
self.columns = []
self.db = db
self.build_columns()
self.rebuild()
self.show_all()
def set_label(self):
return
def get_data(self):
return []
def column_order(self):
return []
def build_columns(self):
for column in self.columns:
self.tree.remove_column(column)
self.columns = []
#for pair in self.parent.db.get_child_column_order():
for pair in self.column_order():
if not pair[0]:
continue
name = self.column_names[pair[1]][0]
column = gtk.TreeViewColumn(name, gtk.CellRendererText(),
text=pair[1])
column.set_resizable(True)
column.set_min_width(40)
column.set_sort_column_id(self.column_names[pair[1]][1])
self.columns.append(column)
self.tree.append_column(column)
def rebuild(self):
self.model = self.build_model(self.get_data(),self.db)
self.tree.set_model(self.model)
self.set_label()
def get_tab_widget(self):
return gtk.Label('UNDEFINED')
#-------------------------------------------------------------------------
#
# ChildModel
#
#-------------------------------------------------------------------------
class ChildModel(gtk.ListStore):
def __init__(self,child_list,db):
gtk.ListStore.__init__(self,int,str,str,str,str,str,str,str,str,str,int,int)
self.db = db
index = 1
for child_handle in child_list:
child = db.get_person_from_handle(child_handle)
self.append(row=[index,
child.get_gramps_id(),
NameDisplay.displayer.display(child),
_GENDER[child.get_gender()],
self.column_birth_day(child),
self.column_death_day(child),
self.column_birth_place(child),
self.column_death_place(child),
child.get_handle(),
child.get_primary_name().get_sort_name(),
self.column_birth_sort(child),
self.column_death_sort(child),
])
index += 1
def column_birth_day(self,data):
event_ref = data.get_birth_ref()
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
return DateHandler.get_date(event)
else:
return u""
def column_birth_sort(self,data):
event_ref = data.get_birth_ref()
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
return event.get_date_object().get_sort_value()
else:
return 0
def column_death_day(self,data):
event_ref = data.get_death_ref()
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
return DateHandler.get_date(event)
else:
return u""
def column_death_sort(self,data):
event_ref = data.get_death_ref()
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
return event.get_date_object().get_sort_value()
else:
return 0
def column_birth_place(self,data):
event_ref = data.get_birth_ref()
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
if event:
place_handle = event.get_place_handle()
if place_handle:
return self.db.get_place_from_handle(place_handle).get_title()
return u""
def column_death_place(self,data):
event_ref = data.get_death_ref()
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
if event:
place_handle = event.get_place_handle()
if place_handle:
return self.db.get_place_from_handle(place_handle).get_title()
return u""
def type_name(event):
t = event.get_type()
if t[0] == RelLib.Event.CUSTOM:
return t[1]
else:
return Utils.family_events[t[0]]
def place_of(event):
t = event.get_place_handle()
return t
#-------------------------------------------------------------------------
#
# EventRefModel
#
#-------------------------------------------------------------------------
class EventRefModel(gtk.ListStore):
def __init__(self,event_list,db):
gtk.ListStore.__init__(self,str,str,str,str,str,str)
self.db = db
index = 1
for event_ref in event_list:
event = db.get_event_from_handle(event_ref.ref)
self.append(row=[
event.get_description(),
event.get_gramps_id(),
type_name(event),
self.column_date(event_ref),
self.column_place(event_ref),
event.get_cause(),
])
index += 1
def column_date(self,event_ref):
event = self.db.get_event_from_handle(event_ref.ref)
return DateHandler.get_date(event)
def column_place(self,event_ref):
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
if event:
place_handle = event.get_place_handle()
if place_handle:
return self.db.get_place_from_handle(place_handle).get_title()
return u""

View File

@ -27,8 +27,8 @@
#-------------------------------------------------------------------------
import cPickle as pickle
import gc
from gettext import gettext as _
import sys
from gettext import gettext as _
import logging
log = logging.getLogger(".")
@ -57,13 +57,86 @@ import GrampsDisplay
import RelLib
import ListModel
import ReportUtils
import DisplayTabs
from DdTargets import DdTargets
from WindowUtils import GladeIf
class EventEmbedList(DisplayTabs.EmbeddedList):
column_names = [
(_('Description'),0),
(_('ID'),1),
(_('Type'),2),
(_('Date'),3),
(_('Place'),4),
(_('Cause'),5),
]
def __init__(self,db,family):
self.family = family
self.hbox = gtk.HBox()
self.label = gtk.Label(_('Events'))
self.hbox.show_all()
DisplayTabs.EmbeddedList.__init__(self, db, DisplayTabs.EventRefModel)
def get_data(self):
return self.family.get_event_ref_list()
def column_order(self):
return ((1,0),(1,1),(1,2),(1,3),(1,4),(1,5))
def set_label(self):
if len(self.get_data()):
self.label.set_text("<b>%s</b>" % _('Events'))
self.label.set_use_markup(True)
else:
self.label.set_text(_('Events'))
def get_tab_widget(self):
return self.label
class ChildEmbedList(DisplayTabs.EmbeddedList):
column_names = [
(_('#'),0) ,
(_('ID'),1) ,
(_('Name'),9),
(_('Gender'),3),
(_('Birth Date'),10),
(_('Death Date'),11),
(_('Birth Place'),6),
(_('Death Place'),7),
]
def __init__(self,db,family):
self.family = family
self.hbox = gtk.HBox()
self.label = gtk.Label(_('Children'))
self.hbox.show_all()
DisplayTabs.EmbeddedList.__init__(self, db, DisplayTabs.ChildModel)
def get_data(self):
return self.family.get_child_handle_list()
def column_order(self):
return self.db.get_child_column_order()
def set_label(self):
if len(self.get_data()):
self.label.set_text("<b>%s</b>" % _('Children'))
self.label.set_use_markup(True)
else:
self.label.set_text(_('Children'))
def get_tab_widget(self):
return self.label
#-------------------------------------------------------------------------
#
# EditPlace
# EditFamily
#
#-------------------------------------------------------------------------
class EditFamily(DisplayState.ManagedWindow):
@ -105,19 +178,47 @@ class EditFamily(DisplayState.ManagedWindow):
self.gid = self.top.get_widget('gid')
self.reltype= self.top.get_widget('relationship_type')
self.mbutton= self.top.get_widget('mbutton')
self.fbutton= self.top.get_widget('fbutton')
self.ok = self.top.get_widget('ok')
self.cancel = self.top.get_widget('cancel')
self.vbox = self.top.get_widget('vbox')
self.notebook = gtk.Notebook()
self.notebook.show()
self.vbox.pack_start(self.notebook,True)
self.child_list = self.top.get_widget('child_list')
self.cancel.connect('clicked', self.close_window)
def load_data(self):
self.load_parent(self.family.get_father_handle(),self.fname,
self.fbirth, self.fdeath)
self.fbirth, self.fdeath, self.fbutton)
self.load_parent(self.family.get_mother_handle(),self.mname,
self.mbirth, self.mdeath)
self.mbirth, self.mdeath, self.mbutton)
def load_parent(self,handle,name_obj,birth_obj,death_obj):
if handle:
self.child_list = ChildEmbedList(self.dbstate.db, self.family)
self.event_list = EventEmbedList(self.dbstate.db, self.family)
self.notebook.insert_page(self.child_list)
self.notebook.set_tab_label(self.child_list,self.child_list.get_tab_widget())
self.notebook.insert_page(self.event_list)
self.notebook.set_tab_label(self.event_list,self.event_list.get_tab_widget())
self.gid.set_text(self.family.get_gramps_id())
def load_parent(self,handle,name_obj,birth_obj,death_obj,btn_obj):
is_used = handle != None
btn_obj.remove(btn_obj.get_children()[0])
if is_used:
db = self.dbstate.db
person = db.get_person_from_handle(handle)
name = "%s [%s]" % (NameDisplay.displayer.display(person),
@ -125,11 +226,21 @@ class EditFamily(DisplayState.ManagedWindow):
data = ReportUtils.get_birth_death_strings(db,person)
birth = data[0]
death = data[4]
del_image = gtk.Image()
del_image.show()
del_image.set_from_stock(gtk.STOCK_REMOVE,gtk.ICON_SIZE_BUTTON)
btn_obj.add(del_image)
else:
name = ""
birth = ""
death = ""
add_image = gtk.Image()
add_image.show()
add_image.set_from_stock(gtk.STOCK_ADD,gtk.ICON_SIZE_BUTTON)
btn_obj.add(add_image)
name_obj.set_text(name)
birth_obj.set_text(birth)
death_obj.set_text(death)

File diff suppressed because it is too large Load Diff