* src/DisplayTabs.py: fix editing of person events

* src/EditPerson.py: sort out birth/death references
* src/EventEdit.py: Handle event references properly
* src/PageView.py: Add setting default person
* src/PersonView.py: Add SetActive action
* src/ViewManager.py: move ColumnEdit action


svn: r5912
This commit is contained in:
Don Allingham 2006-02-10 01:10:52 +00:00
parent fc9d58a0c9
commit 5cdd61e46b
7 changed files with 124 additions and 46 deletions

View File

@ -1,3 +1,11 @@
2006-02-09 Don Allingham <don@gramps-project.org>
* src/DisplayTabs.py: fix editing of person events
* src/EditPerson.py: sort out birth/death references
* src/EventEdit.py: Handle event references properly
* src/PageView.py: Add setting default person
* src/PersonView.py: Add SetActive action
* src/ViewManager.py: move ColumnEdit action
2006-02-09 Jérôme Rapinat <romjerome@yahoo.fr> 2006-02-09 Jérôme Rapinat <romjerome@yahoo.fr>
* src/data/gramps.desktop: Add French strings. * src/data/gramps.desktop: Add French strings.

View File

@ -190,7 +190,14 @@ class ButtonTab(GrampsTab):
combination. combination.
""" """
def __init__(self,dbstate,uistate,track,name): _MSG = {
'add' : _('Add'),
'del' : _('Remove'),
'edit' : _('Edit'),
'share' : _('Share'),
}
def __init__(self,dbstate,uistate,track,name,share_button=False):
""" """
Similar to the base class, except after Build Similar to the base class, except after Build
@param dbstate: The database state. Contains a reference to @param dbstate: The database state. Contains a reference to
@ -208,9 +215,10 @@ class ButtonTab(GrampsTab):
@type name: str/unicode @type name: str/unicode
""" """
GrampsTab.__init__(self,dbstate,uistate,track,name) GrampsTab.__init__(self,dbstate,uistate,track,name)
self.create_buttons() self.tooltips = gtk.Tooltips()
self.create_buttons(share_button)
def create_buttons(self): def create_buttons(self,share_button):
""" """
Creates a button box consisting of three buttons, one for Add, Creates a button box consisting of three buttons, one for Add,
one for Edit, and one for Delete. This button box is then appended one for Edit, and one for Delete. This button box is then appended
@ -220,9 +228,19 @@ class ButtonTab(GrampsTab):
self.edit_btn = SimpleButton(gtk.STOCK_EDIT, self.edit_button_clicked) self.edit_btn = SimpleButton(gtk.STOCK_EDIT, self.edit_button_clicked)
self.del_btn = SimpleButton(gtk.STOCK_REMOVE, self.del_button_clicked) self.del_btn = SimpleButton(gtk.STOCK_REMOVE, self.del_button_clicked)
self.tooltips.set_tip(self.add_btn, self._MSG['add'])
self.tooltips.set_tip(self.edit_btn, self._MSG['edit'])
self.tooltips.set_tip(self.del_btn, self._MSG['del'])
if share_button:
self.share_btn = SimpleButton(gtk.STOCK_INDEX, self.share_button_clicked)
self.tooltips.set_tip(self.share_btn, self._MSG['share'])
vbox = gtk.VBox() vbox = gtk.VBox()
vbox.set_spacing(6) vbox.set_spacing(6)
vbox.pack_start(self.add_btn,False) vbox.pack_start(self.add_btn,False)
if share_button:
vbox.pack_start(self.share_btn,False)
vbox.pack_start(self.edit_btn,False) vbox.pack_start(self.edit_btn,False)
vbox.pack_start(self.del_btn,False) vbox.pack_start(self.del_btn,False)
vbox.show_all() vbox.show_all()
@ -243,6 +261,13 @@ class ButtonTab(GrampsTab):
""" """
print "Uncaught Add clicked" print "Uncaught Add clicked"
def share_button_clicked(self,obj):
"""
Function called with the Add button is clicked. This function
should be overridden by the derived class.
"""
print "Uncaught Share clicked"
def del_button_clicked(self,obj): def del_button_clicked(self,obj):
""" """
Function called with the Delete button is clicked. This function Function called with the Delete button is clicked. This function
@ -281,12 +306,12 @@ class EmbeddedList(ButtonTab):
_HANDLE_COL = -1 _HANDLE_COL = -1
_DND_TYPE = None _DND_TYPE = None
def __init__(self, dbstate, uistate, track, name, build_model): def __init__(self, dbstate, uistate, track, name, build_model,share=False):
""" """
Creates a new list, using the passed build_model to Creates a new list, using the passed build_model to
populate the list. populate the list.
""" """
ButtonTab.__init__(self, dbstate, uistate, track, name) ButtonTab.__init__(self, dbstate, uistate, track, name, share)
self.changed = False self.changed = False
self.build_model = build_model self.build_model = build_model
@ -536,6 +561,13 @@ class EventEmbedList(EmbeddedList):
_HANDLE_COL = 6 _HANDLE_COL = 6
_DND_TYPE = DdTargets.EVENTREF _DND_TYPE = DdTargets.EVENTREF
_MSG = {
'add' : _('Add a new event'),
'del' : _('Remove the selected event'),
'edit' : _('Edit the selected event'),
'share' : _('Share an exisiting event'),
}
_column_names = [ _column_names = [
(_('Type'),0,100), (_('Type'),0,100),
(_('Description'),1,175), (_('Description'),1,175),
@ -548,7 +580,7 @@ class EventEmbedList(EmbeddedList):
def __init__(self,dbstate,uistate,track,obj): def __init__(self,dbstate,uistate,track,obj):
self.obj = obj self.obj = obj
EmbeddedList.__init__(self, dbstate, uistate, track, EmbeddedList.__init__(self, dbstate, uistate, track,
_('Events'), EventRefModel) _('Events'), EventRefModel, True)
def get_icon_name(self): def get_icon_name(self):
return 'gramps-event' return 'gramps-event'
@ -561,9 +593,17 @@ class EventEmbedList(EmbeddedList):
def add_button_clicked(self,obj): def add_button_clicked(self,obj):
import EventEdit import EventEdit
ref = RelLib.EventRef()
EventEdit.EventRefEditor(self.dbstate,self.uistate,self.track, EventEdit.EventRefEditor(self.dbstate,self.uistate,self.track,
None, ref, self.obj, self.event_added) None, None, self.obj, self.event_added)
def share_button_clicked(self,obj):
import EventEdit
import SelectEvent
sel = SelectEvent.SelectEvent(self.dbstate.db,"Event Select")
event = sel.run()
EventEdit.EventRefEditor(self.dbstate,self.uistate,self.track,
event, None, self.obj, self.event_added)
def edit_button_clicked(self,obj): def edit_button_clicked(self,obj):
ref = self.get_selected() ref = self.get_selected()
@ -579,7 +619,7 @@ class EventEmbedList(EmbeddedList):
def event_added(self,value): def event_added(self,value):
value[0].ref = value[1].handle value[0].ref = value[1].handle
self.obj.add_event_ref(value[0]) self.get_data().append(value[0])
self.changed = True self.changed = True
self.rebuild() self.rebuild()
@ -594,7 +634,22 @@ class PersonEventEmbedList(EventEmbedList):
def get_data(self): def get_data(self):
return self.orig_data return self.orig_data
def return_info(self):
new_list = []
birth_ref = None
death_ref = None
for ref in self.orig_data:
event = self.dbstate.db.get_event_from_handle(ref.ref)
if birth_ref == None and event.get_type()[0] == RelLib.Event.BIRTH:
birth_ref = ref
elif death_ref == None and event.get_type()[0] == RelLib.Event.DEATH:
death_ref = ref
else:
new_list.append(ref)
return (birth_ref, death_ref, new_list)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# SourceBackRefList # SourceBackRefList

View File

@ -672,6 +672,12 @@ class EditPerson(DisplayState.ManagedWindow):
if self._check_for_unknown_gender(): if self._check_for_unknown_gender():
return return
(br, dr, el) = self.event_list.return_info()
self.person.set_birth_ref(br)
self.person.set_death_ref(dr)
self.person.set_event_ref_list(el)
self.window.hide() self.window.hide()

View File

@ -265,6 +265,8 @@ class EventEditor(DisplayState.ManagedWindow):
self.update_event(event_data,self.date,eplace_obj) self.update_event(event_data,self.date,eplace_obj)
print self.event, self.event.handle
if self.event.handle == None: if self.event.handle == None:
trans = self.db.transaction_begin() trans = self.db.transaction_begin()
self.db.add_event(self.event,trans) self.db.add_event(self.event,trans)
@ -336,40 +338,16 @@ class EventRefEditor(DisplayState.ManagedWindow):
self.window = self.top.get_widget('event_eref_edit') self.window = self.top.get_widget('event_eref_edit')
self.ref_note_field = self.top.get_widget('eer_ref_note') self.ref_note_field = self.top.get_widget('eer_ref_note')
self.role_combo = self.top.get_widget('eer_role_combo') self.role_combo = self.top.get_widget('eer_role_combo')
self.ref_privacy = PrivacyButton(self.top.get_widget('eer_ref_priv'), self.date_field = self.top.get_widget("eer_date")
self.event_ref)
self.place_field = self.top.get_widget("eer_place") self.place_field = self.top.get_widget("eer_place")
self.cause_field = self.top.get_widget("eer_cause") self.cause_field = self.top.get_widget("eer_cause")
self.cause_monitor = MonitoredEntry(self.cause_field,self.event.set_cause,
self.event.get_cause, False)
self.date_field = self.top.get_widget("eer_date")
self.descr_field = MonitoredEntry(self.top.get_widget("eer_description"),
self.event.set_description,
self.event.get_description, False)
self.ev_note_field = self.top.get_widget("eer_ev_note") self.ev_note_field = self.top.get_widget("eer_ev_note")
self.type_combo = self.top.get_widget("eer_type_combo") self.type_combo = self.top.get_widget("eer_type_combo")
self.ev_privacy = PrivacyButton(self.top.get_widget("eer_ev_priv"),
self.event)
self.general_label = self.top.get_widget("eer_general_tab") self.general_label = self.top.get_widget("eer_general_tab")
self.ok = self.top.get_widget('ok') self.ok = self.top.get_widget('ok')
self.expander = self.top.get_widget("eer_expander") self.expander = self.top.get_widget("eer_expander")
self.warning = self.top.get_widget("eer_warning") self.warning = self.top.get_widget("eer_warning")
self.notebook = self.top.get_widget('notebook') self.notebook = self.top.get_widget('notebook')
Utils.set_titles(self.window,
self.top.get_widget('eer_title'),
self.title)
self.top.signal_autoconnect({
"on_eer_help_clicked" : self.on_help_clicked,
"on_eer_ok_clicked" : self.on_ok_clicked,
"on_eer_cancel_clicked" : self.close,
"on_eer_delete_event" : self.close,
})
if self.referent.__class__.__name__ == 'Person': if self.referent.__class__.__name__ == 'Person':
default_type = RelLib.Event.BIRTH default_type = RelLib.Event.BIRTH
@ -382,16 +360,6 @@ class EventRefEditor(DisplayState.ManagedWindow):
ev_dict = Utils.family_events ev_dict = Utils.family_events
role_dict = Utils.family_event_roles role_dict = Utils.family_event_roles
self.role_selector = AutoComp.StandardCustomSelector(
role_dict,self.role_combo,
RelLib.EventRef.CUSTOM,default_role)
AutoComp.fill_entry(self.place_field,self.pmap.keys())
self.type_selector = AutoComp.StandardCustomSelector(
ev_dict,self.type_combo,
RelLib.Event.CUSTOM,default_type)
if self.event: if self.event:
self.event_added = False self.event_added = False
self.date = RelLib.Date(self.event.get_date_object()) self.date = RelLib.Date(self.event.get_date_object())
@ -417,6 +385,39 @@ class EventRefEditor(DisplayState.ManagedWindow):
self.event_ref.set_role((default_role,role_dict[default_role])) self.event_ref.set_role((default_role,role_dict[default_role]))
self.event_ref.set_reference_handle(self.event.get_handle()) self.event_ref.set_reference_handle(self.event.get_handle())
self.cause_monitor = MonitoredEntry(self.cause_field,self.event.set_cause,
self.event.get_cause, False)
self.ref_privacy = PrivacyButton(self.top.get_widget('eer_ref_priv'),
self.event_ref)
self.descr_field = MonitoredEntry(self.top.get_widget("eer_description"),
self.event.set_description,
self.event.get_description, False)
self.ev_privacy = PrivacyButton(self.top.get_widget("eer_ev_priv"),
self.event)
Utils.set_titles(self.window,
self.top.get_widget('eer_title'),
self.title)
self.top.signal_autoconnect({
"on_eer_help_clicked" : self.on_help_clicked,
"on_eer_ok_clicked" : self.on_ok_clicked,
"on_eer_cancel_clicked" : self.close,
"on_eer_delete_event" : self.close,
})
self.role_selector = AutoComp.StandardCustomSelector(
role_dict,self.role_combo,
RelLib.EventRef.CUSTOM,default_role)
AutoComp.fill_entry(self.place_field,self.pmap.keys())
self.type_selector = AutoComp.StandardCustomSelector(
ev_dict,self.type_combo,
RelLib.Event.CUSTOM,default_type)
self.date_check = DateEdit.DateEdit(self.date, self.date_check = DateEdit.DateEdit(self.date,
self.date_field, self.date_field,
self.top.get_widget("eer_date_stat"), self.top.get_widget("eer_date_stat"),

View File

@ -200,6 +200,8 @@ class PersonNavView(PageView):
self.add_action('HomePerson', gtk.STOCK_HOME, "_Home", self.add_action('HomePerson', gtk.STOCK_HOME, "_Home",
callback=self.home) callback=self.home)
self.add_action('SetActive', gtk.STOCK_HOME, "Set _Home Person",
callback=self.set_default_person)
self.add_action_group(self.back_action) self.add_action_group(self.back_action)
self.add_action_group(self.fwd_action) self.add_action_group(self.fwd_action)
@ -229,6 +231,11 @@ class PersonNavView(PageView):
self.fwd_action.set_sensitive(not hobj.at_end()) self.fwd_action.set_sensitive(not hobj.at_end())
self.back_action.set_sensitive(not hobj.at_front()) self.back_action.set_sensitive(not hobj.at_front())
def set_default_person(self,obj):
active = self.dbstate.active
if active:
self.dbstate.db.set_default_person_handle(active.get_handle())
def home(self,obj): def home(self,obj):
defperson = self.dbstate.db.get_default_person() defperson = self.dbstate.db.get_default_person()
if defperson: if defperson:

View File

@ -193,6 +193,7 @@ class PersonView(PageView.PersonNavView):
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>
</placeholder> </placeholder>
<menuitem action="SetActive"/>
</menu> </menu>
</menubar> </menubar>
<toolbar name="ToolBar"> <toolbar name="ToolBar">

View File

@ -304,7 +304,6 @@ class ViewManager:
('Quit', gtk.STOCK_QUIT, '_Quit', "<control>q", None, self.quit), ('Quit', gtk.STOCK_QUIT, '_Quit', "<control>q", None, self.quit),
('ViewMenu', None, '_View'), ('ViewMenu', None, '_View'),
('Preferences', gtk.STOCK_PREFERENCES, '_Preferences'), ('Preferences', gtk.STOCK_PREFERENCES, '_Preferences'),
('ColumnEdit', gtk.STOCK_PROPERTIES, '_Column Editor'),
('HelpMenu', None, '_Help'), ('HelpMenu', None, '_Help'),
('HomePage', None, _('GRAMPS _home page'), None, None, self.home_page_activate), ('HomePage', None, _('GRAMPS _home page'), None, None, self.home_page_activate),
('MailingLists', None, _('GRAMPS _mailing lists'), None, None, self.mailing_lists_activate), ('MailingLists', None, _('GRAMPS _mailing lists'), None, None, self.mailing_lists_activate),
@ -328,6 +327,7 @@ class ViewManager:
('Reports', gtk.STOCK_DND_MULTIPLE, '_Reports', None, None, self.reports_clicked), ('Reports', gtk.STOCK_DND_MULTIPLE, '_Reports', None, None, self.reports_clicked),
('Tools', gtk.STOCK_EXECUTE, '_Tools', None, None, self.tools_clicked), ('Tools', gtk.STOCK_EXECUTE, '_Tools', None, None, self.tools_clicked),
('EditMenu', None, '_Edit'), ('EditMenu', None, '_Edit'),
('ColumnEdit', gtk.STOCK_PROPERTIES, '_Column Editor'),
('GoMenu', None, '_Go'), ('GoMenu', None, '_Go'),
('BookMenu', None, '_Bookmarks'), ('BookMenu', None, '_Bookmarks'),
('AddBook', gtk.STOCK_INDEX, '_Add bookmark', '<control>d', None, self.add_bookmark), ('AddBook', gtk.STOCK_INDEX, '_Add bookmark', '<control>d', None, self.add_bookmark),