From 6be65fb5182c489443ea529773d6674ff216728f Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Thu, 26 Jul 2001 20:56:32 +0000 Subject: [PATCH] New event editing abilities svn: r259 --- gramps/src/EditPerson.glade | 1031 +++++++++++++++++++++++++---------- gramps/src/EditPerson.py | 175 +++--- 2 files changed, 836 insertions(+), 370 deletions(-) diff --git a/gramps/src/EditPerson.glade b/gramps/src/EditPerson.glade index 2b2832c17..721790b36 100644 --- a/gramps/src/EditPerson.glade +++ b/gramps/src/EditPerson.glade @@ -1464,306 +1464,233 @@ - GtkTable - table7 - 4 - 3 - False - 0 - 0 + GtkFrame + eventName + 5 + + 0 + GTK_SHADOW_ETCHED_IN - 0 + 5 False - True + False - GtkLabel - label103 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 5 - 8 - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - GtkLabel - label104 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 5 - 8 - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - False - - - - - GtkLabel - label105 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 5 - 8 - - 0 - 1 - 3 - 4 - 0 - 0 - False - False - False - False - True - False - - - - - GtkLabel - label106 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 5 - 8 - - 0 - 1 - 2 - 3 - 0 - 0 - False - False - False - False - True - False - - - - - GnomeEntry - eDescBox - event_description - 15 - - 1 - 3 - 3 - 4 - 3 - 3 - True - False - False - False - True - False - + GtkTable + table7 + 4 + 2 + False + 0 + 0 - GtkEntry - GnomeEntry:entry - eventDescription - True - True - True - 0 - - - - - - GtkEntry - eventDate - True - True - True - 0 - - - 1 - 2 - 1 - 2 - 3 - 3 - True - False - False - False - True - False - - - - - GtkCombo - personalEvents - False - True - False - True - False - - - 1 - 2 - 0 - 1 - 3 - 3 - True - False - False - False - True - False - - - - GtkEntry - GtkCombo:entry - eventName - True - True - True - 0 - - - - - - GtkButton - event_source - Edit source information for the highlighted event - True - - clicked - on_showsource_clicked - eventList - Thu, 11 Jan 2001 04:08:33 GMT - - - GTK_RELIEF_NORMAL - - 2 - 3 - 0 - 1 + GtkLabel + label103 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 5 - 0 - False - False - False - False - True - False - - - - - GtkButton - event_note - Edit note information for the highlighted event - True - - clicked - on_event_note_clicked - eventList - Tue, 29 May 2001 15:07:23 GMT - - - GTK_RELIEF_NORMAL - - 2 - 3 - 1 - 2 - 5 - 0 - False - False - False - False - True - False - - - - - GtkCombo - eventPlace_combo - False - True - False - True - False - - - 1 - 3 - 2 - 3 - 3 3 - True - False - False - False - True - False - + + 0 + 1 + 0 + 1 + 0 + 0 + False + False + False + False + True + False + + - GtkEntry - GtkCombo:entry + GtkLabel + label106 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 5 + 3 + + 0 + 1 + 1 + 2 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + label105 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 5 + 3 + + 0 + 1 + 2 + 3 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + eventDate + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + 1 + 2 + 0 + 1 + 3 + 3 + True + False + False + False + True + False + + + + + GtkLabel eventPlace - True - True - True - 0 - + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + 1 + 2 + 1 + 2 + 3 + 3 + True + False + False + False + True + False + + + + + GtkLabel + eventDescription + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + 1 + 2 + 2 + 3 + 3 + 3 + True + False + False + False + True + False + + + + + GtkLabel + label164 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 5 + 3 + + 0 + 1 + 3 + 4 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + event_details + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + 1 + 2 + 3 + 4 + 3 + 3 + True + False + False + False + True + False + @@ -1839,7 +1766,7 @@ GtkLabel CList:title - event_details + eventDetails GTK_JUSTIFY_CENTER False @@ -1894,7 +1821,7 @@ eventList Fri, 01 Dec 2000 02:58:32 GMT - + GTK_RELIEF_NORMAL @@ -3331,4 +3258,528 @@ + + GtkDialog + event_edit + Gramps - Event Editor + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + True + False + + + GtkVBox + Dialog:vbox + dialog-vbox1 + False + 0 + + + GtkHBox + Dialog:action_area + dialog-action_area1 + 10 + True + 5 + + 0 + False + True + GTK_PACK_END + + + + GtkHButtonBox + hbuttonbox18 + GTK_BUTTONBOX_END + 30 + 85 + 27 + 7 + 0 + + 0 + True + True + + + + GtkButton + button111 + True + True + + clicked + on_event_edit_ok_clicked + event_edit + Thu, 26 Jul 2001 20:29:11 GMT + + GNOME_STOCK_BUTTON_OK + GTK_RELIEF_NORMAL + + + + GtkButton + button112 + True + True + + clicked + on_event_edit_apply_clicked + event_edit + Thu, 26 Jul 2001 20:29:24 GMT + + GNOME_STOCK_BUTTON_APPLY + GTK_RELIEF_NORMAL + + + + GtkButton + button113 + True + True + + clicked + destroy_passed_object + event_edit + Thu, 26 Jul 2001 19:16:49 GMT + + GNOME_STOCK_BUTTON_CANCEL + GTK_RELIEF_NORMAL + + + + + + GtkVBox + vbox29 + False + 0 + + 0 + True + True + + + + GtkLabel + eventTitle + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 10 + + 0 + False + False + + + + + GtkHSeparator + hseparator1 + + 0 + False + True + + + + + GtkTable + table21 + 6 + 2 + False + 0 + 0 + + 0 + True + True + + + + GtkLabel + label154 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 5 + 8 + + 0 + 1 + 0 + 1 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + label155 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 5 + 8 + + 0 + 1 + 1 + 2 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + label156 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 5 + 8 + + 0 + 1 + 3 + 4 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + label157 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 5 + 8 + + 0 + 1 + 2 + 3 + 0 + 0 + False + False + False + False + True + False + + + + + GnomeEntry + eDescBox + event_description + 15 + + 1 + 2 + 3 + 4 + 3 + 3 + True + False + False + False + True + False + + + + GtkEntry + GnomeEntry:entry + eventDescription + True + True + True + 0 + + + + + + GtkCombo + eventPlace_combo + False + True + False + True + False + + + 1 + 2 + 2 + 3 + 3 + 3 + True + False + False + False + True + False + + + + GtkEntry + GtkCombo:entry + eventPlace + True + True + True + 0 + + + + + + GtkLabel + label158 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 5 + 8 + + 0 + 1 + 4 + 5 + 0 + 0 + False + False + False + False + True + False + + + + + GtkCombo + personalEvents + False + True + False + True + False + + + 1 + 2 + 0 + 1 + 3 + 3 + True + False + False + False + True + False + + + + GtkEntry + GtkCombo:entry + eventName + True + True + True + 0 + + + + + + GtkEntry + eventDate + True + True + True + 0 + + + 1 + 2 + 1 + 2 + 3 + 3 + True + False + False + False + True + False + + + + + GtkScrolledWindow + scrolledwindow21 + 400 + 150 + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 1 + 2 + 5 + 6 + 3 + 3 + False + True + False + False + True + True + + + + GtkText + eventNote + True + True + + + + + + GtkLabel + label159 + + GTK_JUSTIFY_CENTER + False + 1 + 0 + 5 + 8 + + 0 + 1 + 5 + 6 + 0 + 0 + False + False + False + False + True + True + + + + + GtkHBox + hbox21 + False + 0 + + 1 + 2 + 4 + 5 + 0 + 0 + False + False + False + False + True + True + + + + GtkEntry + event_source + True + True + True + 0 + + + 3 + True + True + + + + + GtkButton + button114 + 3 + Edit source information for the highlighted event + True + + clicked + on_showsource_clicked + eventList + Thu, 11 Jan 2001 04:08:33 GMT + + + GTK_RELIEF_NORMAL + + 3 + False + False + + + + + + + + diff --git a/gramps/src/EditPerson.py b/gramps/src/EditPerson.py index 7e94832b9..163d3bd1a 100644 --- a/gramps/src/EditPerson.py +++ b/gramps/src/EditPerson.py @@ -90,6 +90,7 @@ class EditPerson: self.event_place_field = self.get_widget("eventPlace") self.event_date_field = self.get_widget("eventDate") self.event_descr_field = self.get_widget("eventDescription") + self.event_details_field = self.get_widget("event_details") self.photo_list = self.get_widget("photolist") self.attr_list = self.get_widget("attr_list") self.attr_type = self.get_widget("attr_type") @@ -112,7 +113,7 @@ class EditPerson: self.alt_given_field = self.get_widget("alt_given") self.alt_last_field = self.get_widget("alt_last") self.alt_suffix_field = self.get_widget("alt_suffix") - self.surname = self.get_widget("surname") + self.surname_field = self.get_widget("surname") self.suffix = self.get_widget("suffix") self.given = self.get_widget("givenName") self.nick = self.get_widget("nickname") @@ -123,8 +124,6 @@ class EditPerson: self.dplace = self.get_widget("deathPlace") self.is_male = self.get_widget("genderMale") self.is_female = self.get_widget("genderFemale") - self.event_note = self.get_widget("event_note") - self.event_source = self.get_widget("event_source") self.addr_note = self.get_widget("addr_note") self.addr_source = self.get_widget("addr_source") self.attr_note = self.get_widget("attr_note") @@ -169,7 +168,6 @@ class EditPerson: "on_photolist_button_press_event" : on_photolist_button_press_event, "on_addphoto_clicked" : on_add_photo_clicked, "on_deletephoto_clicked" : on_delete_photo_clicked, - "on_event_note_clicked" : on_event_note_clicked, "on_showsource_clicked" : on_showsource_clicked, "on_applyPerson_clicked" : on_apply_person_clicked }) @@ -178,11 +176,6 @@ class EditPerson: self.surname_list.sort() self.get_widget("lastNameList").set_popdown_strings(self.surname_list) - event_names = self.get_widget("personalEvents") - - event_names.set_popdown_strings(const.personalEvents) - event_names.entry.set_text("") - attr_names = self.get_widget("attribute") attr_names.set_popdown_strings(const.personalAttributes) attr_names.entry.set_text("") @@ -199,7 +192,7 @@ class EditPerson: if len(const.places) > 0: self.get_widget("dp_combo").set_popdown_strings(const.places) self.get_widget("bp_combo").set_popdown_strings(const.places) - self.get_widget("eventPlace_combo").set_popdown_strings(const.places) +# self.get_widget("eventPlace_combo").set_popdown_strings(const.places) if Config.display_attr: self.get_widget("user_label").set_text(Config.attr_name) @@ -217,7 +210,8 @@ class EditPerson: # initial values self.get_widget("activepersonTitle").set_text(Config.nameof(person)) self.suffix.set_text(name.getSuffix()) - self.surname.set_text(name.getSurname()) + + self.surname_field.set_text(name.getSurname()) self.given.set_text(name.getFirstName()) if person.getGender() == Person.male: @@ -449,11 +443,6 @@ class EditPerson: current_row = current_row - 1 self.event_list.select_row(current_row,0) self.event_list.moveto(current_row,0) - self.event_note.set_sensitive(1) - self.event_source.set_sensitive(1) - else: - self.event_note.set_sensitive(0) - self.event_source.set_sensitive(0) self.event_list.set_data(INDEX,current_row) self.event_list.thaw() @@ -497,6 +486,7 @@ class EditPerson: def load_photo(self,photo): self.get_widget("personPix").load_file(photo) + #------------------------------------------------------------------------- # # on_name_list_select_row - sets the row object attached to the passed @@ -811,30 +801,7 @@ def on_add_address_clicked(obj): def on_event_add_clicked(obj): edit_person_obj = obj.get_data(EDITPERSON) - - date = edit_person_obj.event_date_field.get_text() - place= edit_person_obj.event_place_field.get_text() - name = edit_person_obj.event_name_field.get_text() - desc = edit_person_obj.event_descr_field.get_text() - - event = Event() - event.set(name,date,place,desc) - - if name not in const.personalEvents: - const.personalEvents.append(name) - menu = edit_person_obj.get_widget("personalEvents") - menu.set_popdown_strings(const.personalEvents) - - if place not in const.places: - const.places.append(place) - const.places.sort() - edit_person_obj.get_widget("dp_combo").set_popdown_strings(const.places) - edit_person_obj.get_widget("bp_combo").set_popdown_strings(const.places) - edit_person_obj.get_widget("eventPlace_combo").set_popdown_strings(const.places) - - edit_person_obj.person.addEvent(event) - edit_person_obj.redraw_event_list() - utils.modified() + editor = EventEditor(edit_person_obj,None) #------------------------------------------------------------------------- # @@ -877,19 +844,7 @@ def on_event_update_clicked(obj): edit_person_obj = obj.get_data(EDITPERSON) event = obj.get_row_data(row) - - date = edit_person_obj.event_date_field.get_text() - place = edit_person_obj.event_place_field.get_text() - name = edit_person_obj.event_name_field.get_text() - desc = edit_person_obj.event_descr_field.get_text() - - if name not in const.personalEvents: - const.personalEvents.append(name) - menu = edit_person_obj.get_widget("personalEvents") - menu.set_popdown_strings(const.personalEvents) - - update_event(event,name,date,place,desc) - edit_person_obj.redraw_event_list() + editor = EventEditor(edit_person_obj,event) #------------------------------------------------------------------------- # @@ -905,9 +860,20 @@ def on_event_select_row(obj,row,b,c): edit_person_obj = obj.get_data(EDITPERSON) edit_person_obj.event_date_field.set_text(event.getDate()) edit_person_obj.event_place_field.set_text(event.getPlace()) - edit_person_obj.event_name_field.set_text(const.display_pevent(event.getName())) + edit_person_obj.event_name_field.set_label(const.display_pevent(event.getName())) edit_person_obj.event_descr_field.set_text(event.getDescription()) + if event.getNote() != "": + details = _("Note") + else: + details = "" + if event.getSourceRef().getBase() != None: + if details == "": + details = _("Source") + else: + details = "%s, %s" % (_("Note"),_("Source")) + edit_person_obj.event_details_field.set_text(details) + #------------------------------------------------------------------------- # # @@ -978,7 +944,7 @@ def on_primary_photo_clicked(obj): # actually changed. # #------------------------------------------------------------------------- -def update_event(event,name,date,place,desc): +def update_event(event,name,date,place,desc,note): if event.getPlace() != place: event.setPlace(place) utils.modified() @@ -991,6 +957,10 @@ def update_event(event,name,date,place,desc): event.setDescription(desc) utils.modified() + if event.getNote() != note: + event.setNote(note) + utils.modified() + if event.getDate() != date: event.setDate(date) utils.modified() @@ -1189,31 +1159,6 @@ def on_save_note_clicked(obj): utils.destroy_passed_object(obj) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_event_note_clicked(obj): - row = obj.get_data(INDEX) - data = obj.get_row_data(row) - edit_person_obj = obj.get_data(EDITPERSON) - if row >= 0: - editnote = libglade.GladeXML(const.editnoteFile,"editnote") - textobj = editnote.get_widget("notetext") - en_obj = editnote.get_widget("editnote") - en_obj.set_data("n",data) - en_obj.set_data("w",textobj) - - textobj.set_point(0) - textobj.insert_defaults(data.getNote()) - textobj.set_word_wrap(1) - - editnote.signal_autoconnect({ - "on_save_note_clicked" : on_save_note_clicked, - "destroy_passed_object" : utils.destroy_passed_object - }) - #------------------------------------------------------------------------- # # @@ -1468,3 +1413,73 @@ def on_browse_clicked(obj): if path != "": gnome.url.show(path) + +#------------------------------------------------------------------------- +# +# EventEditor class +# +#------------------------------------------------------------------------- +class EventEditor: + + def __init__(self,parent,event): + self.parent = parent + self.event = event + self.top = libglade.GladeXML(const.editPersonFile, "event_edit") + self.window = self.top.get_widget("event_edit") + self.name_field = self.top.get_widget("eventName") + self.place_field = self.top.get_widget("eventPlace") + self.date_field = self.top.get_widget("eventDate") + self.descr_field = self.top.get_widget("eventDescription") + self.note_field = self.top.get_widget("eventNote") + self.event_menu = self.top.get_widget("personalEvents") + + name = parent.person.getPrimaryName().getName() + + self.top.get_widget("eventTitle").set_text(_("Event Editor for %s") % name) + self.event_menu.set_popdown_strings(const.personalEvents) + if event != None: + self.name_field.set_text(event.getName()) + self.place_field.set_text(event.getPlace()) + self.date_field.set_text(event.getDate()) + self.descr_field.set_text(event.getDescription()) + self.note_field.set_point(0) + self.note_field.insert_defaults(event.getNote()) + self.note_field.set_word_wrap(1) + + self.window.set_data("o",self) + self.top.signal_autoconnect({ + "destroy_passed_object" : utils.destroy_passed_object, + "on_event_edit_ok_clicked" : on_event_edit_ok_clicked, + "on_event_edit_apply_clicked" : on_event_edit_apply_clicked + }) + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def on_event_edit_apply_clicked(obj): + ee = obj.get_data("o") + event = ee.event + + ename = ee.name_field.get_text() + edate = ee.date_field.get_text() + eplace = ee.place_field.get_text() + enote = ee.note_field.get_chars(0,-1) + edesc = ee.descr_field.get_text() + + if event == None: + event = Event() + ee.parent.person.addEvent(event) + + update_event(event,ename,edate,eplace,edesc,enote) + ee.parent.redraw_event_list() + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def on_event_edit_ok_clicked(obj): + on_event_edit_apply_clicked(obj) + utils.destroy_passed_object(obj)