From 5cdd61e46b507172967a22a18da764ad51c7489c Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 10 Feb 2006 01:10:52 +0000 Subject: [PATCH] * 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 --- ChangeLog | 8 +++++ src/DisplayTabs.py | 75 +++++++++++++++++++++++++++++++++++++++------- src/EditPerson.py | 6 ++++ src/EventEdit.py | 71 +++++++++++++++++++++---------------------- src/PageView.py | 7 +++++ src/PersonView.py | 1 + src/ViewManager.py | 2 +- 7 files changed, 124 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index baac0b1d3..a36d37c45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-02-09 Don Allingham + * 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 * src/data/gramps.desktop: Add French strings. diff --git a/src/DisplayTabs.py b/src/DisplayTabs.py index 56b86aff9..10d5b2ab6 100644 --- a/src/DisplayTabs.py +++ b/src/DisplayTabs.py @@ -190,7 +190,14 @@ class ButtonTab(GrampsTab): 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 @param dbstate: The database state. Contains a reference to @@ -208,9 +215,10 @@ class ButtonTab(GrampsTab): @type name: str/unicode """ 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, 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.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.set_spacing(6) 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.del_btn,False) vbox.show_all() @@ -243,6 +261,13 @@ class ButtonTab(GrampsTab): """ 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): """ Function called with the Delete button is clicked. This function @@ -281,12 +306,12 @@ class EmbeddedList(ButtonTab): _HANDLE_COL = -1 _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 populate the list. """ - ButtonTab.__init__(self, dbstate, uistate, track, name) + ButtonTab.__init__(self, dbstate, uistate, track, name, share) self.changed = False self.build_model = build_model @@ -536,6 +561,13 @@ class EventEmbedList(EmbeddedList): _HANDLE_COL = 6 _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 = [ (_('Type'),0,100), (_('Description'),1,175), @@ -548,7 +580,7 @@ class EventEmbedList(EmbeddedList): def __init__(self,dbstate,uistate,track,obj): self.obj = obj EmbeddedList.__init__(self, dbstate, uistate, track, - _('Events'), EventRefModel) + _('Events'), EventRefModel, True) def get_icon_name(self): return 'gramps-event' @@ -561,9 +593,17 @@ class EventEmbedList(EmbeddedList): def add_button_clicked(self,obj): import EventEdit - ref = RelLib.EventRef() 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): ref = self.get_selected() @@ -579,7 +619,7 @@ class EventEmbedList(EmbeddedList): def event_added(self,value): value[0].ref = value[1].handle - self.obj.add_event_ref(value[0]) + self.get_data().append(value[0]) self.changed = True self.rebuild() @@ -594,7 +634,22 @@ class PersonEventEmbedList(EventEmbedList): def get_data(self): 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 diff --git a/src/EditPerson.py b/src/EditPerson.py index 3cf00de93..fbf3a4902 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -672,6 +672,12 @@ class EditPerson(DisplayState.ManagedWindow): if self._check_for_unknown_gender(): 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() diff --git a/src/EventEdit.py b/src/EventEdit.py index a473a3711..270fc3a7a 100644 --- a/src/EventEdit.py +++ b/src/EventEdit.py @@ -265,6 +265,8 @@ class EventEditor(DisplayState.ManagedWindow): self.update_event(event_data,self.date,eplace_obj) + print self.event, self.event.handle + if self.event.handle == None: trans = self.db.transaction_begin() 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.ref_note_field = self.top.get_widget('eer_ref_note') self.role_combo = self.top.get_widget('eer_role_combo') - self.ref_privacy = PrivacyButton(self.top.get_widget('eer_ref_priv'), - self.event_ref) - + self.date_field = self.top.get_widget("eer_date") self.place_field = self.top.get_widget("eer_place") 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.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.ok = self.top.get_widget('ok') self.expander = self.top.get_widget("eer_expander") self.warning = self.top.get_widget("eer_warning") 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': default_type = RelLib.Event.BIRTH @@ -382,16 +360,6 @@ class EventRefEditor(DisplayState.ManagedWindow): ev_dict = Utils.family_events 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: self.event_added = False 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_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_field, self.top.get_widget("eer_date_stat"), diff --git a/src/PageView.py b/src/PageView.py index bc650b128..5cdcda34c 100644 --- a/src/PageView.py +++ b/src/PageView.py @@ -200,6 +200,8 @@ class PersonNavView(PageView): self.add_action('HomePerson', gtk.STOCK_HOME, "_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.fwd_action) @@ -229,6 +231,11 @@ class PersonNavView(PageView): self.fwd_action.set_sensitive(not hobj.at_end()) 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): defperson = self.dbstate.db.get_default_person() if defperson: diff --git a/src/PersonView.py b/src/PersonView.py index ee0584bb5..10aab3b62 100644 --- a/src/PersonView.py +++ b/src/PersonView.py @@ -193,6 +193,7 @@ class PersonView(PageView.PersonNavView): + diff --git a/src/ViewManager.py b/src/ViewManager.py index 035d1df2e..edf041b57 100644 --- a/src/ViewManager.py +++ b/src/ViewManager.py @@ -304,7 +304,6 @@ class ViewManager: ('Quit', gtk.STOCK_QUIT, '_Quit', "q", None, self.quit), ('ViewMenu', None, '_View'), ('Preferences', gtk.STOCK_PREFERENCES, '_Preferences'), - ('ColumnEdit', gtk.STOCK_PROPERTIES, '_Column Editor'), ('HelpMenu', None, '_Help'), ('HomePage', None, _('GRAMPS _home page'), None, None, self.home_page_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), ('Tools', gtk.STOCK_EXECUTE, '_Tools', None, None, self.tools_clicked), ('EditMenu', None, '_Edit'), + ('ColumnEdit', gtk.STOCK_PROPERTIES, '_Column Editor'), ('GoMenu', None, '_Go'), ('BookMenu', None, '_Bookmarks'), ('AddBook', gtk.STOCK_INDEX, '_Add bookmark', 'd', None, self.add_bookmark),