* src/gramps.glade (Marriage): Re-work dialog similar to EditPerson.

* src/Utils.py (family_event_roles): Add mapping.
* src/RelLib.py (EventRef): Add FAMILY role.
* src/Marriage.py: Start using Listbox, so far for Events only.
* src/ListBox.py: Support both person and family primaries.
* src/EventEdit.py: Support both person and family primaries.
* src/EditPerson.py (on_apply_person_clicked): Do not commit
event, as this is done in the editor.


svn: r4809
This commit is contained in:
Alex Roitman 2005-06-08 18:47:55 +00:00
parent 399c5b61f4
commit d7ba30cacc
8 changed files with 416 additions and 842 deletions

View File

@ -9,6 +9,15 @@
* src/EventView.py (Module): Remove extra column.
* src/EventEdit.py (EventEditor.__init__): Remove obsolete code.
* src/gramps.glade (Marriage): Re-work dialog similar to EditPerson.
* src/Utils.py (family_event_roles): Add mapping.
* src/RelLib.py (EventRef): Add FAMILY role.
* src/Marriage.py: Start using Listbox, so far for Events only.
* src/ListBox.py: Support both person and family primaries.
* src/EventEdit.py: Support both person and family primaries.
* src/EditPerson.py (on_apply_person_clicked): Do not commit
event, as this is done in the editor.
2005-06-08 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/EventView.py (column_names): Add missing column
* src/RepositoryView.py (column_names): Add missing columns

View File

@ -1036,8 +1036,8 @@ class EditPerson:
self.db.commit_person(self.person, trans)
n = self.person.get_primary_name().get_regular_name()
for (event_ref,event) in self.event_box.get_changed_objects():
self.db.commit_event(event,trans)
#for (event_ref,event) in self.event_box.get_changed_objects():
# self.db.commit_event(event,trans)
self.db.transaction_commit(trans,_("Edit Person (%s)") % n)
if self.callback:

View File

@ -465,21 +465,25 @@ class EventRefEditor:
"on_eer_delete_event" : self.on_delete_event,
})
if self.referent.__class__.__name__ == 'Person':
default_type = RelLib.Event.BIRTH
default_role = RelLib.EventRef.PRIMARY
ev_dict = Utils.personal_events
role_dict = Utils.event_roles
elif self.referent.__class__.__name__ == 'Family':
default_type = RelLib.Event.MARRIAGE
default_role = RelLib.EventRef.FAMILY
ev_dict = Utils.family_events
role_dict = Utils.family_event_roles
self.role_selector = AutoComp.StandardCustomSelector(
Utils.event_roles,self.role_combo,
RelLib.EventRef.CUSTOM,RelLib.EventRef.PRIMARY)
role_dict,self.role_combo,
RelLib.EventRef.CUSTOM,default_role)
AutoComp.fill_entry(self.place_field,self.pmap.keys())
if self.referent.__class__.__name__ == 'Person':
default_type = RelLib.Event.BIRTH
default_str = _("Birth")
elif self.referent.__class__.__name__ == 'Family':
default_type = RelLib.Event.MARRIAGE
default_str = _("Marriage")
self.type_selector = AutoComp.StandardCustomSelector(
Utils.personal_events,self.type_combo,
ev_dict,self.type_combo,
RelLib.Event.CUSTOM,default_type)
if self.event:
@ -488,7 +492,7 @@ class EventRefEditor:
else:
trans = self.db.transaction_begin()
self.event = RelLib.Event()
self.event.set_type((default_type,default_str))
self.event.set_type((default_type,ev_dict[default_type]))
self.db.add_event(self.event,trans)
self.db.transaction_commit(trans,_("Add Event"))
self.date = Date.Date(None)
@ -496,7 +500,7 @@ class EventRefEditor:
if not self.event_ref:
self.event_ref = RelLib.EventRef()
self.event_ref.set_role((RelLib.EventRef.PRIMARY,_('Primary')))
self.event_ref.set_role((default_role,role_dict[default_role]))
self.event_ref.set_reference_handle(self.event.get_handle())
self.srcreflist = self.event.get_source_references()
@ -538,6 +542,10 @@ class EventRefEditor:
Utils.bold_label(self.gallery_label)
self.add_itself_to_menu()
try:
self.window.set_transient_for(self.parent.window)
except AttributeError:
pass
self.window.show()
def on_delete_event(self,obj,b):
@ -608,7 +616,7 @@ class EventRefEditor:
stop = buf.get_end_iter()
note = unicode(buf.get_text(start,stop,False))
self.event_ref.set_note(note)
self.referent.add_event_ref(self.event_ref)
#self.referent.add_event_ref(self.event_ref)
self.close(None)
if self.update:

View File

@ -58,13 +58,20 @@ import Utils
class ListBox:
"""
The ListBox manages the lists contained by the EditPerson dialog.
It manages the add, update, and delete buttons, along with the
The ListBox manages the lists contained by the EditPerson or Marriage
dialogs. It manages the add, update, and delete buttons, along with the
handling of inline editing.
The primary argument is either Person or Family object.
"""
def __init__(self, parent, person, obj, label, button_list, titles):
self.person = person
self.name = NameDisplay.displayer.display(person)
def __init__(self, parent, primary, obj, label, button_list, titles):
self.primary = primary
if self.primary.__class__.__name__ == 'Person':
self.name = NameDisplay.displayer.display(primary)
elif self.primary.__class__.__name__ == 'Family':
self.name = Utils.family_name(primary,parent.db)
else:
self.name = ""
self.label = label
self.db = parent.db
self.parent = parent
@ -162,9 +169,9 @@ class ListBox:
class ReorderListBox(ListBox):
def __init__(self,parent,person,obj,label,button_list,evalues, dnd_type):
def __init__(self,parent,primary,obj,label,button_list,evalues, dnd_type):
ListBox.__init__(self,parent,person,obj,label,button_list,evalues)
ListBox.__init__(self,parent,primary,obj,label,button_list,evalues)
self.dnd_type = dnd_type
@ -180,7 +187,7 @@ class ReorderListBox(ListBox):
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(node[0]);
data = str((self.dnd_type.drag_type, self.person.get_handle(), pickled));
data = str((self.dnd_type.drag_type, self.primary.get_handle(), pickled));
sel_data.set(sel_data.target, bits_per, data)
def unpickle(self, data):
@ -192,10 +199,10 @@ class ReorderListBox(ListBox):
if sel_data and sel_data.data:
exec 'data = %s' % sel_data.data
exec 'mytype = "%s"' % data[0]
exec 'person = "%s"' % data[1]
exec 'primary = "%s"' % data[1]
if mytype != self.dnd_type.drag_type:
return
elif person == self.person.get_handle():
elif primary == self.primary.get_handle():
self.move_element(self.list_model.get_selected_row(),row)
else:
self.unpickle(data[2])
@ -274,31 +281,38 @@ class EventListBox(ReorderListBox):
titles = ['Event', 'Description','Date','Place','Source','Note']
def __init__(self,parent,person,obj,label,button_list):
def __init__(self,parent,primary,obj,label,button_list):
self.data = []
self.person = person
self.primary = primary
self.parent = parent
birth_ref = person.get_birth_ref()
death_ref = person.get_death_ref()
if birth_ref:
self.data.append((birth_ref,
if self.primary.__class__.__name__ == 'Person':
birth_ref = primary.get_birth_ref()
death_ref = primary.get_death_ref()
if birth_ref:
self.data.append((birth_ref,
parent.db.get_event_from_handle(birth_ref.ref)))
if death_ref:
self.data.append((death_ref,
if death_ref:
self.data.append((death_ref,
parent.db.get_event_from_handle(death_ref.ref)))
for event_ref in person.get_event_ref_list():
self.ev_dict = Utils.personal_events
self.role_dict = Utils.event_roles
elif self.primary.__class__.__name__ == 'Family':
self.ev_dict = Utils.family_events
self.role_dict = Utils.family_event_roles
for event_ref in primary.get_event_ref_list():
self.data.append((event_ref,
parent.db.get_event_from_handle(event_ref.ref)))
ev_custom_str = Utils.personal_events[RelLib.Event.CUSTOM]
ev_custom_str = self.ev_dict[RelLib.Event.CUSTOM]
eventnames = filter(lambda x: x != ev_custom_str,
Utils.personal_events.values())
self.ev_dict.values())
eventnames.sort(locale.strcoll)
role_custom_str = Utils.event_roles[RelLib.EventRef.CUSTOM]
role_custom_str = self.role_dict[RelLib.EventRef.CUSTOM]
rolenames = filter(lambda x: x != role_custom_str,
Utils.event_roles.values())
self.role_dict.values())
evalues = [
# Title Sort Col Size, Type Argument
@ -311,13 +325,13 @@ class EventListBox(ReorderListBox):
(_('Note'), NOSORT, 50, TOGGLE, None, None),
]
ReorderListBox.__init__(self, parent, person, obj, label,
ReorderListBox.__init__(self, parent, primary, obj, label,
button_list, evalues, DdTargets.EVENT)
self.ev_name_map,self.ev_val_map = self.build_maps(
RelLib.Event.CUSTOM,Utils.personal_events)
RelLib.Event.CUSTOM,self.ev_dict)
self.ref_name_map,self.ref_val_map = self.build_maps(
RelLib.EventRef.CUSTOM,Utils.personal_events)
RelLib.EventRef.CUSTOM,self.role_dict)
def set_type(self,index,value):
val = self.ev_name_map.get(value,RelLib.Event.CUSTOM)
@ -349,11 +363,8 @@ class EventListBox(ReorderListBox):
def add(self,obj):
"""Brings up the EventEditor for a new event"""
EventEdit.EventRefEditor(None,None,self.person,self.parent.db,
EventEdit.EventRefEditor(None,None,self.primary,self.parent.db,
self.edit_callback,self.parent)
# self.parent, self.name, Utils.personal_events,
# None, None, False,
# self.edit_callback, noedit=self.db.readonly)
def select(self,obj):
"""
@ -365,7 +376,7 @@ class EventListBox(ReorderListBox):
self.parent.window)
event = sel_event.run()
if event:
EventEdit.EventRefEditor(event,None,self.person,self.parent.db,
EventEdit.EventRefEditor(event,None,self.primary,self.parent.db,
self.edit_callback,self.parent)
def update(self,obj):
@ -373,11 +384,8 @@ class EventListBox(ReorderListBox):
if not node:
return
event_ref,event = self.list_model.get_object(node)
EventEdit.EventRefEditor(event,event_ref,self.person,self.parent.db,
EventEdit.EventRefEditor(event,event_ref,self.primary,self.parent.db,
self.edit_callback,self.parent)
# self.parent, self.name, Utils.personal_events,
# event[1], None, False,
# self.edit_callback, noedit=self.db.readonly)
def display_data(self,event_tuple):
(event_ref, event) = event_tuple
@ -390,16 +398,16 @@ class EventListBox(ReorderListBox):
has_source = len(event.get_source_references())> 0
etype = event.get_type()
if etype[0] == RelLib.Event.CUSTOM \
or not Utils.personal_events.has_key(etype[0]):
or not self.ev_dict.has_key(etype[0]):
name = etype[1]
else:
name = Utils.personal_events[etype[0]]
name = self.ev_dict[etype[0]]
ref_role = event_ref.get_role()
if ref_role[0] == RelLib.EventRef.CUSTOM \
or not Utils.event_roles.has_key(ref_role[0]):
or not self.role_dict.has_key(ref_role[0]):
role = ref_role[1]
else:
role = Utils.event_roles[ref_role[0]]
role = self.role_dict[ref_role[0]]
return [name, event.get_description(), event.get_date(),
pname, role, has_source, has_note]

View File

@ -48,6 +48,7 @@ import const
import Utils
import AutoComp
import ListModel
import ListBox
import RelLib
import ImageSelect
import DateHandler
@ -121,16 +122,16 @@ class Marriage:
"on_addphoto_clicked" : self.gallery.on_add_media_clicked,
"on_selectphoto_clicked" : self.gallery.on_select_media_clicked,
"on_close_marriage_editor" : self.on_close_marriage_editor,
"on_delete_event" : self.on_delete_event,
#"on_delete_event" : self.on_delete_event,
"on_lds_src_clicked" : self.lds_src_clicked,
"on_lds_note_clicked" : self.lds_note_clicked,
"on_deletephoto_clicked" : self.gallery.on_delete_media_clicked,
"on_edit_photo_clicked" : self.gallery.on_edit_media_clicked,
"on_edit_properties_clicked": self.gallery.popup_change_description,
"on_marriageAddBtn_clicked" : self.on_add_clicked,
"on_event_update_clicked" : self.on_event_update_clicked,
#"on_marriageAddBtn_clicked" : self.on_add_clicked,
#"on_event_update_clicked" : self.on_event_update_clicked,
"on_attr_update_clicked" : self.on_update_attr_clicked,
"on_marriageDeleteBtn_clicked" : self.on_delete_clicked,
#"on_marriageDeleteBtn_clicked" : self.on_delete_clicked,
"on_switch_page" : self.on_switch_page
})
@ -148,22 +149,21 @@ class Marriage:
Utils.set_title_label(self.top,self.title)
self.event_list = self.get_widget("marriageEventList")
self.event_ref_list = self.get_widget("marriageEventList")
if gtk.gdk.screen_height() > 700:
self.event_list.set_size_request(500,250)
self.event_ref_list.set_size_request(500,250)
else:
self.event_list.set_size_request(500,-1)
self.event_ref_list.set_size_request(500,-1)
# widgets
self.complete = self.get_widget('complete')
self.complete.set_sensitive(mode)
self.date_field = self.get_widget("marriageDate")
self.place_field = self.get_widget("marriagePlace")
self.cause_field = self.get_widget("marriageCause")
self.name_field = self.get_widget("marriageEventName")
self.descr_field = self.get_widget("marriageDescription")
#self.date_field = self.get_widget("marriageDate")
#self.place_field = self.get_widget("marriagePlace")
#self.cause_field = self.get_widget("marriageCause")
#self.name_field = self.get_widget("marriageEventName")
#self.descr_field = self.get_widget("marriageDescription")
self.type_field = self.get_widget("marriage_type")
self.type_field.set_sensitive(mode)
self.notes_field = self.get_widget("marriageNotes")
@ -173,8 +173,12 @@ class Marriage:
self.attr_list = self.get_widget("attr_list")
self.attr_type = self.get_widget("attr_type")
self.attr_value = self.get_widget("attr_value")
self.event_src_field = self.get_widget("event_srcinfo")
self.event_conf_field = self.get_widget("event_conf")
#self.event_src_field = self.get_widget("event_srcinfo")
#self.event_conf_field = self.get_widget("event_conf")
event_add_btn = self.get_widget("marriage_add")
event_edit_btn = self.get_widget("marriage_edit")
event_delete_btn = self.get_widget("marriage_del")
event_sel_btn = self.get_widget("marriage_sel")
self.attr_src_field = self.get_widget("attr_srcinfo")
self.attr_conf_field = self.get_widget("attr_conf")
self.lds_date = self.get_widget("lds_date")
@ -201,7 +205,7 @@ class Marriage:
self.preform = self.get_widget("mar_preform")
self.preform.set_sensitive(mode)
self.ereflist = family.get_event_ref_list()[:]
#self.ereflist = family.get_event_ref_list()[:]
self.alist = family.get_attribute_list()[:]
self.lists_changed = 0
@ -210,16 +214,22 @@ class Marriage:
# set initial data
self.gallery.load_images()
etitles = [(_('Event'),-1,100),(_('Date'),-1,125),(_('Place'),-1,150)]
#etitles = [(_('Event'),-1,100),(_('Date'),-1,125),(_('Place'),-1,150)]
atitles = [(_('Attribute'),-1,150),(_('Value'),-1,150)]
self.etree = ListModel.ListModel(self.event_list, etitles,
self.on_select_row,
self.on_event_update_clicked)
#self.etree = ListModel.ListModel(self.event_list, etitles,
# self.on_select_row,
# self.on_event_update_clicked)
self.atree = ListModel.ListModel(self.attr_list, atitles,
self.on_attr_list_select_row,
self.on_update_attr_clicked)
# event display
self.event_box = ListBox.EventListBox(
self, family, self.event_ref_list, self.events_label,
[event_add_btn,event_edit_btn,event_delete_btn,event_sel_btn])
self.event_box.redraw()
self.type_selector = AutoComp.StandardCustomSelector( \
Utils.family_relations,self.type_field,
RelLib.Family.CUSTOM,RelLib.Name.MARRIED)
@ -264,17 +274,17 @@ class Marriage:
else:
Utils.unbold_label(self.lds_label)
self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
[DdTargets.FAMILY_EVENT.target()],
gtk.gdk.ACTION_COPY)
self.event_list.drag_source_set(gtk.gdk.BUTTON1_MASK,
[DdTargets.FAMILY_EVENT.target()],
gtk.gdk.ACTION_COPY)
self.event_list.connect('drag_data_get',
self.ev_source_drag_data_get)
self.event_list.connect('drag_data_received',
self.ev_dest_drag_data_received)
self.event_list.connect('drag_begin', self.ev_drag_begin)
#self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
# [DdTargets.FAMILY_EVENT.target()],
# gtk.gdk.ACTION_COPY)
#self.event_list.drag_source_set(gtk.gdk.BUTTON1_MASK,
# [DdTargets.FAMILY_EVENT.target()],
# gtk.gdk.ACTION_COPY)
#self.event_list.connect('drag_data_get',
# self.ev_source_drag_data_get)
#self.event_list.connect('drag_data_received',
# self.ev_dest_drag_data_received)
#self.event_list.connect('drag_begin', self.ev_drag_begin)
self.attr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
[DdTargets.FAMILY_ATTRIBUTE.target()],
@ -303,7 +313,7 @@ class Marriage:
self.top.get_widget('add_src'), self.top.get_widget('edit_src'),
self.top.get_widget('del_src'), self.db.readonly)
self.redraw_event_list()
#self.redraw_event_list()
self.redraw_attr_list()
self.add_itself_to_winsmenu()
self.top.get_widget('ok').set_sensitive(not self.db.readonly)
@ -524,7 +534,8 @@ class Marriage:
selection_data.set(selection_data.target, bits_per, data)
def update_lists(self):
self.family.set_event_ref_list(self.ereflist)
eref_list = [event_ref for (event_ref,event) in self.event_box.data]
self.family.set_event_ref_list(eref_list)
self.family.set_attribute_list(self.alist)
def attr_edit_callback(self,attr):
@ -848,6 +859,8 @@ class Marriage:
list.insert(dest,obj)
def on_switch_page(self,obj,a,page):
if page == 0:
self.event_box.redraw()
text = unicode(self.notes_buffer.get_text(self.notes_buffer.get_start_iter(),
self.notes_buffer.get_end_iter(),False))
if text:

View File

@ -4177,6 +4177,7 @@ class EventRef(BaseObject,PrivacyBase,NoteBase):
BRIDE = 5
GROOM = 6
WITNESS = 7
FAMILY = 8
def __init__(self,source=None):
"""

View File

@ -215,6 +215,12 @@ event_roles = {
RelLib.EventRef.WITNESS : _("Witness"),
}
family_event_roles = {
RelLib.EventRef.UNKNOWN : _("Unknown"),
RelLib.EventRef.CUSTOM : _("Custom"),
RelLib.EventRef.FAMILY : _("Family"),
}
repository_types = {
RelLib.Repository.UNKNOWN : _("Unknown"),
RelLib.Repository.CUSTOM : _("Custom"),

File diff suppressed because it is too large Load Diff