diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index cb8e8b2e7..a93cae0f7 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -7,7 +7,8 @@ src/ListBox.py, src/Marriage.py, src/NameEdit.py: Support tuple types. * src/gramps.glade: Replace ComboBox with ComboBoxEntry; add icons. - + + * various: More support for event refs. 2005-05-31 Martin Hawlisch * src/EditSource.py, src/ListBox.py, src/ReadGedcom.py, diff --git a/gramps2/src/AddSpouse.py b/gramps2/src/AddSpouse.py index 482f30541..54157a1c0 100644 --- a/gramps2/src/AddSpouse.py +++ b/gramps2/src/AddSpouse.py @@ -58,6 +58,7 @@ import Marriage import NameDisplay import GenericFilter from QuestionDialog import ErrorDialog, QuestionDialog2 +import AutoComp #------------------------------------------------------------------------- # @@ -93,13 +94,10 @@ class AddSpouse: self.glade = gtk.glade.XML(const.gladeFile, "spouseDialog","gramps") - self.relation_def = self.glade.get_widget("reldef") self.rel_combo = self.glade.get_widget("rel_combo") self.spouse_list = self.glade.get_widget("spouse_list") self.showall = self.glade.get_widget('showall') - self.set_gender() - self.renderer = gtk.CellRendererText() self.slist = PeopleModel.PeopleModel(self.db,self.filter) @@ -127,7 +125,11 @@ class AddSpouse: "destroy_passed_object" : Utils.destroy_passed_object }) - self.rel_combo.set_active(RelLib.Family.MARRIED) + self.rel_selector = AutoComp.StandardCustomSelector( + Utils.family_relations,self.rel_combo, + RelLib.Family.CUSTOM,RelLib.Family.MARRIED) + + self.set_gender() self.update_data() def build_all(self): @@ -203,8 +205,8 @@ class AddSpouse: """ import EditPerson - relation = self.rel_combo.get_active() - if relation == RelLib.Family.CIVIL_UNION: + rel_i,rel_s = self.rel_selector.get_values() + if rel_i == RelLib.Family.CIVIL_UNION: if self.person.get_gender() == RelLib.Person.MALE: gen = RelLib.Person.MALE else: @@ -309,8 +311,8 @@ class AddSpouse: self.active_family.set_father_handle(spouse.get_handle()) self.active_family.set_mother_handle(self.person.get_handle()) - rtype = self.rel_combo.get_active() - self.active_family.set_relationship((rtype,Utils.family_relations[rtype])) + rtype = self.rel_selector.get_values() + self.active_family.set_relationship(rtype) self.db.commit_family(self.active_family,trans) self.db.transaction_commit(trans,_("Add Spouse")) @@ -373,7 +375,8 @@ class AddSpouse: return 1 def set_gender(self): - if self.rel_combo.get_active() == RelLib.Family.CIVIL_UNION: + rel_i,rel_s = self.rel_selector.get_values() + if rel_i == RelLib.Family.CIVIL_UNION: if self.gender == RelLib.Person.MALE: self.sgender = RelLib.Person.FEMALE else: diff --git a/gramps2/src/EventEdit.py b/gramps2/src/EventEdit.py index 25faf957e..d4167ca16 100644 --- a/gramps2/src/EventEdit.py +++ b/gramps2/src/EventEdit.py @@ -60,7 +60,7 @@ from QuestionDialog import WarningDialog, ErrorDialog #------------------------------------------------------------------------- class EventEditor: - def __init__(self,parent,name,elist,trans,event,def_placename, + def __init__(self,parent,name,etypes,event,def_placename, read_only, cb, def_event=None, noedit=False): self.parent = parent self.db = self.parent.db @@ -74,7 +74,6 @@ class EventEditor: self.win_key = self self.event = event self.child_windows = {} - self.trans = trans self.callback = cb self.path = self.db.get_save_path() self.plist = [] @@ -83,15 +82,15 @@ class EventEditor: self.dp = DateHandler.parser self.dd = DateHandler.displayer - values = {} - for v in elist: - values[v] = 1 - for vv in self.db.get_person_event_type_list(): - v = _(vv) - values[v] = 1 - - self.elist = values.keys() - self.elist.sort() +# values = {} +# for v in elist: +# values[v] = 1 +# for vv in self.db.get_person_event_type_list(): +# v = _(vv) +# values[v] = 1 +# +# self.elist = values.keys() +# self.elist.sort() for key in self.parent.db.get_place_handles(): title = self.parent.db.get_place_from_handle(key).get_title() @@ -103,7 +102,6 @@ class EventEditor: if not self.witnesslist: self.witnesslist = [] self.date = Date.Date(self.event.get_date_object()) - transname = const.display_event(event.get_name()) # add the name to the list if it is not already there. This # tends to occur in translated languages with the 'Death' # event, which is a partial match to other events @@ -361,7 +359,7 @@ class EventEditor: if self.callback: self.callback(self.event) - def update_event(self,name,date,place,desc,note,format,priv,cause): + def update_event(self,the_type,date,place,desc,note,format,priv,cause): if place: if self.event.get_place_handle() != place.get_handle(): self.event.set_place_handle(place.get_handle()) @@ -371,8 +369,8 @@ class EventEditor: self.event.set_place_handle("") self.parent.lists_changed = 1 - if self.event.get_name() not in [self.trans.find_key(name)]: - self.event.set_name(self.trans.find_key(name)) + if self.event.get_type() != the_type: + self.event.set_type(the_type) self.parent.lists_changed = 1 if self.event.get_description() != desc: @@ -413,3 +411,128 @@ class EventEditor: Utils.bold_label(self.notes_label) else: Utils.unbold_label(self.notes_label) + + + +class EventRefEditor: + def __init__(self, eventref, referent, database, update, parent): + + self.db = database + self.parent = parent + self.referent = referent + if self.parent.__dict__.has_key('child_windows'): + self.win_parent = self.parent + else: + self.win_parent = self.parent.parent + if eventref: + if self.win_parent.child_windows.has_key(eventref): + self.win_parent.child_windows[eventref].present(None) + return + else: + self.win_key = eventref + else: + self.win_key = self + self.update = update + self.event_ref = eventref + self.child_windows = {} + + self.title = _('Event Reference Editor') + + self.top = gtk.glade.XML(const.dialogFile, "eventref_edit","gramps") + self.window = self.top.get_widget('eventref_edit') + self.note_field = self.top.get_widget('er_note') + self.role_combo = self.top.get_widget('er_role_combo') + self.type_label = self.top.get_widget('er_type_label') + self.id_label = self.top.get_widget('er_id_label') + self.privacy = self.top.get_widget('er_priv_button') + + Utils.set_titles(self.window, + self.top.get_widget('er_title'), + self.title) + + self.top.signal_autoconnect({ + "on_help_er_edit_clicked" : self.on_help_clicked, + "on_ok_er_edit_clicked" : self.on_ok_clicked, + "on_cancel_er_edit_clicked" : self.close, + "on_er_edit_delete_event" : self.on_delete_event, + }) + + self.role_selector = AutoComp.StandardCustomSelector( + Utils.event_roles,self.role_combo, + RelLib.EventRef.CUSTOM,RelLib.EventRef.PRIMARY) + + self.trans = self.db.transaction_begin() + + if not self.event_ref: + trans2 = self.db.transaction_begin() + e = RelLib.Event() + e.set_type((RelLib.Event.MARRIAGE,_("Married"))) + self.db.add_event(e,trans2) + self.db.transaction_commit(trans2,_("Add Event")) + self.event_ref = RelLib.EventRef() + self.event_ref.set_role((RelLib.EventRef.PRIMARY,_('Primary'))) + self.event_ref.set_note('Some text') + self.event_ref.set_reference_handle(e.get_handle()) + + self.role_selector.set_values(self.event_ref.get_role()) + self.note_field.get_buffer().set_text(self.event_ref.get_note()) + event = self.db.get_event_from_handle(self.event_ref.ref) + self.id_label.set_text(event.get_gramps_id()) + self.type_label.set_text(event.get_type()[1]) + + self.add_itself_to_menu() + self.window.show() + + def on_delete_event(self,obj,b): + self.close_child_windows() + self.remove_itself_from_menu() + + def close(self,obj): + self.close_child_windows() + self.remove_itself_from_menu() + self.window.destroy() + + def close_child_windows(self): + for child_window in self.child_windows.values(): + child_window.close(None) + self.child_windows = {} + + def add_itself_to_menu(self): + self.win_parent.child_windows[self.win_key] = self + label = _('Event Reference') + self.parent_menu_item = gtk.MenuItem(label) + self.parent_menu_item.set_submenu(gtk.Menu()) + self.parent_menu_item.show() + self.win_parent.winsmenu.append(self.parent_menu_item) + self.winsmenu = self.parent_menu_item.get_submenu() + self.menu_item = gtk.MenuItem(self.title) + self.menu_item.connect("activate",self.present) + self.menu_item.show() + self.winsmenu.append(self.menu_item) + + def remove_itself_from_menu(self): + del self.win_parent.child_windows[self.win_key] + self.menu_item.destroy() + self.winsmenu.destroy() + self.parent_menu_item.destroy() + + def present(self,obj): + self.window.present() + + def on_help_clicked(self,obj): + pass + + def on_ok_clicked(self,obj): + self.event_ref.set_role(self.role_selector.get_values()) + buf = self.note_field.get_buffer() + start = buf.get_start_iter() + 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) + if self.referent.__class__.__name__ == 'Person': + self.db.commit_person(self.referent,self.trans) + elif self.referent.__class__.__name__ == 'Family': + self.db.commit_family(self.referent,self.trans) + self.db.transaction_commit(self.trans,_("Add Event Reference")) + self.close(None) diff --git a/gramps2/src/FamilyView.py b/gramps2/src/FamilyView.py index 2a3785520..1eb2827bd 100644 --- a/gramps2/src/FamilyView.py +++ b/gramps2/src/FamilyView.py @@ -1084,7 +1084,7 @@ class FamilyView: for event_ref in family.get_event_ref_list(): if event_ref: event = self.parent.db.get_event_from_handle(event_ref.ref) - if event.get_name() == "Marriage": + if event.get_type()[0] == RelLib.Event.MARRIAGE: return event return None diff --git a/gramps2/src/Marriage.py b/gramps2/src/Marriage.py index 390f658d2..5d88a9d0e 100644 --- a/gramps2/src/Marriage.py +++ b/gramps2/src/Marriage.py @@ -557,7 +557,7 @@ class Marriage: place_name = self.db.get_place_from_handle(place_handle).get_title() else: place_name = "" - node = self.etree.add([const.display_fevent(event.get_name()), + node = self.etree.add([event.get_type()[1], event.get_quote_date(),place_name],event) self.emap[str(event)] = node if self.ereflist: @@ -726,11 +726,11 @@ class Marriage: def on_add_clicked(self,*obj): import EventEdit - name = Utils.family_name(self.family,self.db) - EventEdit.EventEditor( - self,name, const.marriageEvents, const.family_events, - None, None, 0, self.event_edit_callback, - const.defaultMarriageEvent, self.db.readonly) + #name = Utils.family_name(self.family,self.db) + EventEdit.EventRefEditor(None,self.family, self.db,None,self) + #self,name, Utils.family_events, + #None, None, 0, self.event_edit_callback, + #RelLib.Event.MARRIAGE, self.db.readonly) def on_event_update_clicked(self,obj): import EventEdit @@ -739,9 +739,9 @@ class Marriage: return event = self.etree.get_object(node) name = Utils.family_name(self.family,self.db) - EventEdit.EventEditor( - self, name, const.marriageEvents, const.family_events,event, - None, 0,self.event_edit_callback, None, self.db.readonly) + EventEdit.EventRefEditor( + self, name, Utils.family_events,event, + None, 0, self.event_edit_callback, None, self.db.readonly) def on_delete_clicked(self,obj): if Utils.delete_selected(obj,self.ereflist): @@ -763,7 +763,7 @@ class Marriage: place_name = u"" self.place_field.set_text(place_name) self.cause_field.set_text(event.get_cause()) - self.name_field.set_label(const.display_fevent(event.get_name())) + self.name_field.set_label(event.get_type()[1]) if len(event.get_source_references()) > 0: psrc_ref = event.get_source_references()[0] psrc_id = psrc_ref.get_base_handle() diff --git a/gramps2/src/RelLib.py b/gramps2/src/RelLib.py index f604fda58..ccb8fbdbf 100644 --- a/gramps2/src/RelLib.py +++ b/gramps2/src/RelLib.py @@ -4164,12 +4164,10 @@ class EventRef(BaseObject,PrivacyBase,NoteBase): NoteBase.__init__(self) if source: self.ref = source.ref - self.role_int = source.role_int - self.role_str = source.role_str + self.role = source.role_int else: self.ref = None - self.role_int = EventRef.ROLE_CUSTOM - self.role_str = "" + self.role = (EventRef.CUSTOM,"") def get_text_data_list(self): """ @@ -4218,25 +4216,15 @@ class EventRef(BaseObject,PrivacyBase,NoteBase): def get_role(self): """ - Returns the integer corresponding to the preset role. - If custom then the string is returned. + Returns the tuple corresponding to the preset role. """ - if self.role_int == EventRef.ROLE_CUSTOM: - return self.role_str - else: - return self.role_int + return self.role def set_role(self,role): """ Sets the role according to the given argument. - If integer, it is set as is. If string, it is recorded as custom role. """ - if type(role) == str: - self.role_int = EventRef.ROLE_CUSTOM - self.role_str = role - elif type(role) == int: - self.role_int = role - self.role_str = "" + self.role = role class GenderStats: """ diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index b4501e28d..79f0fbb0f 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -3891,20 +3891,14 @@ - + True - Married -Unmarried -Civil Union -Unknown -Other 1 2 0 1 - fill fill @@ -13179,7 +13173,7 @@ Other True - Add new event for this marriage + Add new event to the database and link this marriage to it True GTK_RELIEF_NORMAL True @@ -13204,6 +13198,34 @@ Other + + + True + Select an existing event from the database and link this marriage to it + True + GTK_RELIEF_NORMAL + True + + + + + True + gtk-index + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + True @@ -13226,7 +13248,7 @@ Other 0 False - True + False @@ -13254,13 +13276,9 @@ Other 0 False - True + False - - - - 0 @@ -34604,4 +34622,410 @@ Very High + + True + + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + gramps.png + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-help + True + GTK_RELIEF_NORMAL + True + -11 + + + + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + False + 0 + + + + True + + False + True + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 10 + + + 0 + False + False + + + + + + 12 + True + 5 + 3 + False + 6 + 12 + + + + True + Event I_D: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + _Role: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 3 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + Event _Type: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + _Note: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + True + _Private record + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 2 + 4 + 5 + fill + + + + + + + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 1 + 3 + 3 + 4 + + + + + + True + + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + er_add_button + + + 1 + 2 + 0 + 1 + + + + + + + True + + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 1 + 2 + + + + + + + True + Select an existing event for this reference + True + GTK_RELIEF_NORMAL + True + + + + True + gtk-index + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 2 + 3 + 1 + 2 + fill + + + + + + + True + Create new event for this reference + True + GTK_RELIEF_NORMAL + True + + + + True + gtk-add + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 2 + 3 + 0 + 1 + fill + + + + + + + True + + + 1 + 3 + 2 + 3 + fill + + + + + 0 + True + True + + + + + 0 + True + True + + + + + +