Fix place selecton on LDS ords

svn: r6274
This commit is contained in:
Don Allingham 2006-04-05 22:36:48 +00:00
parent 455bedf69f
commit 824e61b9d6
5 changed files with 180 additions and 17 deletions

View File

@ -1205,6 +1205,13 @@ class LdsEmbedList(EmbeddedList):
EmbeddedList.__init__(self, dbstate, uistate, track, EmbeddedList.__init__(self, dbstate, uistate, track,
_('LDS'), LdsModel) _('LDS'), LdsModel)
def get_editor(self):
from Editors import EditLdsOrd
return EditLdsOrd
def new_data(self):
return RelLib.LdsOrd()
def get_data(self): def get_data(self):
return self.data return self.data
@ -1212,12 +1219,9 @@ class LdsEmbedList(EmbeddedList):
return ((1,0),(1,1),(1,2),(1,3),(1,4)) return ((1,0),(1,1),(1,2),(1,3),(1,4))
def add_button_clicked(self,obj): def add_button_clicked(self,obj):
lds = RelLib.LdsOrd()
try: try:
from Editors import EditLdsOrd self.get_editor()(self.dbstate, self.uistate, self.track,
self.new_data(), self.add_callback)
EditLdsOrd(self.dbstate, self.uistate, self.track,
lds, self.add_callback)
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass pass
@ -1229,9 +1233,7 @@ class LdsEmbedList(EmbeddedList):
lds = self.get_selected() lds = self.get_selected()
if lds: if lds:
try: try:
from Editors import EditLdsOrd self.get_editor()(self.dbstate, self.uistate, self.track,
EditLdsOrd(self.dbstate, self.uistate, self.track,
lds, self.edit_callback) lds, self.edit_callback)
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass pass
@ -1239,6 +1241,37 @@ class LdsEmbedList(EmbeddedList):
def edit_callback(self,name): def edit_callback(self,name):
self.rebuild() self.rebuild()
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class FamilyLdsEmbedList(LdsEmbedList):
_HANDLE_COL = 5
# _DND_TYPE = DdTargets.ADDRESS
_column_names = [
(_('Type'), 0, 150),
(_('Date'), 1, 150),
(_('Status'), 3, 75),
(_('Temple'), 2, 200),
(_('Place'), 3, 100),
]
def __init__(self,dbstate,uistate,track,data):
LdsEmbedList.__init__(self, dbstate, uistate, track, data)
def get_editor(self):
from Editors import EditFamilyLdsOrd
return EditFamilyLdsOrd
def new_data(self):
lds = RelLib.LdsOrd()
lds.set_type(RelLib.LdsOrd.SEAL_TO_SPOUSE)
return lds
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# #

View File

@ -486,6 +486,11 @@ class EditFamily(EditPrimary):
GalleryTab(self.dbstate, self.uistate, self.track, GalleryTab(self.dbstate, self.uistate, self.track,
self.obj.get_media_list())) self.obj.get_media_list()))
self.lds_list = self._add_tab(
notebook,
FamilyLdsEmbedList(self.dbstate,self.uistate,self.track,
self.obj.get_lds_ord_list()))
notebook.show_all() notebook.show_all()
self.hidden = (notebook, self.top.get_widget('info')) self.hidden = (notebook, self.top.get_widget('info'))
@ -767,7 +772,6 @@ class EditFamily(EditPrimary):
original = None original = None
if not original and not self.object_is_empty(): if not original and not self.object_is_empty():
print self.obj.serialize()
trans = self.db.transaction_begin() trans = self.db.transaction_begin()
# find the father, add the family handle to the father # find the father, add the family handle to the father

View File

@ -60,7 +60,7 @@ from GrampsWidgets import *
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# EditAttribute class # EditLdsOrd class
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class EditLdsOrd(EditSecondary): class EditLdsOrd(EditSecondary):
@ -213,7 +213,135 @@ class EditLdsOrd(EditSecondary):
def save(self,*obj): def save(self,*obj):
""" """
Called when the OK button is pressed. Gets data from the Called when the OK button is pressed. Gets data from the
form and updates the Attribute data structure. form and updates the LdsOrd data structure.
"""
(need_new, handle) = self.place_field.get_place_info()
if need_new:
place_obj = RelLib.Place()
place_obj.set_title(handle)
trans = self.db.transaction_begin()
self.db.add_place(place_obj,trans)
self.db.transaction_commit(trans,_("Add Place"))
self.obj.set_place_handle(place_obj.get_handle())
else:
self.obj.set_place_handle(handle)
if self.callback:
self.callback(self.obj)
self.close_window(obj)
#-------------------------------------------------------------------------
#
# EditFamilyLdsOrd
#
#-------------------------------------------------------------------------
class EditFamilyLdsOrd(EditSecondary):
"""
Displays a dialog that allows the user to edit an attribute.
"""
def __init__(self, state, uistate, track, attrib, callback):
"""
Displays the dialog box.
parent - The class that called the Address editor.
attrib - The attribute that is to be edited
title - The title of the dialog box
list - list of options for the pop down menu
"""
EditSecondary.__init__(self, state, uistate, track, attrib, callback)
def _local_init(self):
self.top = gtk.glade.XML(const.gladeFile, "lds_person_edit","gramps")
self.define_top_level(self.top.get_widget("lds_person_edit"),
self.top.get_widget('title'),
_('LDS Ordinance Editor'))
def _connect_signals(self):
self.define_cancel_button(self.top.get_widget('cancel'))
self.define_help_button(self.top.get_widget('help'),'adv-at')
self.define_ok_button(self.top.get_widget('ok'),self.save)
def _setup_fields(self):
self.parents_label = self.top.get_widget('parents_label')
self.parents = self.top.get_widget('parents')
self.parents_select = self.top.get_widget('parents_select')
self.priv = PrivacyButton(
self.top.get_widget("private"),
self.obj)
self.date_field = MonitoredDate(
self.top.get_widget("date"),
self.top.get_widget("date_stat"),
self.obj.get_date_object(),
self.window, self.db.readonly)
self.place_field = PlaceEntry(
self.top.get_widget("place"),
self.obj.get_place_handle(),
self.dbstate.get_place_completion(),
self.db.readonly)
self.type_menu = MonitoredMenu(
self.top.get_widget('type'),
self.obj.set_type,
self.obj.get_type,
[(_('Sealed to Spouse'),RelLib.LdsOrd.SEAL_TO_SPOUSE)],
self.db.readonly)
temple_list = []
for val in lds.temple_codes.keys():
temple_list.append((lds.temple_codes[val],val))
self.temple_menu = MonitoredStrMenu(
self.top.get_widget('temple'),
self.obj.set_temple,
self.obj.get_temple,
temple_list,
self.db.readonly)
self.status_menu = MonitoredMenu(
self.top.get_widget('status'),
self.obj.set_status,
self.obj.get_status,
[(_('<No Status>'), RelLib.LdsOrd.STATUS_NONE),
(_('Canceled'), RelLib.LdsOrd.STATUS_CANCELED),
(_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED),
(_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED),
(_("DNS"), RelLib.LdsOrd.STATUS_DNS),
(_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970),
(_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED),
(_("DNS/CAN"), RelLib.LdsOrd.STATUS_DNS_CAN),
(_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED),
(_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED),],
self.db.readonly)
def _create_tabbed_pages(self):
notebook = gtk.Notebook()
self.srcref_list = self._add_tab(
notebook,
SourceEmbedList(self.dbstate,self.uistate, self.track,
self.obj.source_list))
self.note_tab = self._add_tab(
notebook,
NoteTab(self.dbstate, self.uistate, self.track,
self.obj.get_note_object()))
notebook.show_all()
vbox = self.top.get_widget('vbox').pack_start(notebook,True)
def build_menu_names(self, attrib):
label = _("LDS Ordinance")
return (label, _('LDS Ordinance Editor'))
def save(self,*obj):
"""
Called when the OK button is pressed. Gets data from the
form and updates the LdsOrd data structure.
""" """
(need_new, handle) = self.place_field.get_place_info() (need_new, handle) = self.place_field.get_place_info()
@ -227,7 +355,6 @@ class EditLdsOrd(EditSecondary):
else: else:
self.obj.set_place_handle(handle) self.obj.set_place_handle(handle)
print self.obj.get_place_handle()
if self.callback: if self.callback:
self.callback(self.obj) self.callback(self.obj)
self.close_window(obj) self.close_window(obj)

View File

@ -376,10 +376,8 @@ class MonitoredMenu:
self.obj.set_active(0) self.obj.set_active(0)
def on_change(self, obj): def on_change(self, obj):
print "ON CHANGE"
self.set_val(self.model.get_value(obj.get_active_iter(), 1)) self.set_val(self.model.get_value(obj.get_active_iter(), 1))
if self.changed: if self.changed:
print "CALL"
self.changed() self.changed()
class MonitoredStrMenu: class MonitoredStrMenu:

View File

@ -88,11 +88,12 @@ class LdsOrd(SourceNote,DateBase,PlaceBase,PrivacyBase):
def serialize(self): def serialize(self):
return (SourceNote.serialize(self), return (SourceNote.serialize(self),
DateBase.serialize(self),self.place, DateBase.serialize(self),
self.type,self.place,
self.famc,self.temple,self.status) self.famc,self.temple,self.status)
def unserialize(self,data): def unserialize(self,data):
(sn,date,self.place, (sn,date,self.type,self.place,
self.famc,self.temple,self.status) = data self.famc,self.temple,self.status) = data
SourceNote.unserialize(self,sn) SourceNote.unserialize(self,sn)
DateBase.unserialize(self,date) DateBase.unserialize(self,date)