diff --git a/gramps/src/AddSpouse.py b/gramps/src/AddSpouse.py index ea162090d..31be67aa1 100644 --- a/gramps/src/AddSpouse.py +++ b/gramps/src/AddSpouse.py @@ -54,7 +54,6 @@ from RelLib import * import const import sort import utils -import Config class AddSpouse: def __init__(self,db,person,update,addperson): diff --git a/gramps/src/EditPerson.py b/gramps/src/EditPerson.py index b0c22ca5c..358cf318c 100644 --- a/gramps/src/EditPerson.py +++ b/gramps/src/EditPerson.py @@ -72,13 +72,50 @@ class EditPerson: self.path = db.getSavePath() self.not_loaded = 1 self.lists_changed = 0 - + pid = "i%s" % person.getId() + self.top = libglade.GladeXML(const.editPersonFile, "editPerson") + self.gallery_widget = self.top.get_widget("photolist") + self.gallery = PersonGallery(self, self.path, pid, self.gallery_widget, self.db) + self.top.signal_autoconnect({ + "destroy_passed_object" : self.on_cancel_edit, + "on_add_address_clicked" : self.on_add_addr_clicked, + "on_add_aka_clicked" : self.on_add_aka_clicked, + "on_add_attr_clicked" : self.on_add_attr_clicked, + "on_add_url_clicked" : self.on_add_url_clicked, + "on_addphoto_clicked" : self.gallery.on_add_photo_clicked, + "on_address_list_select_row": self.on_addr_list_select_row, + "on_aka_delete_clicked" : self.on_aka_delete_clicked, + "on_aka_update_clicked" : self.on_aka_update_clicked, + "on_apply_person_clicked" : self.on_apply_person_clicked, + "on_attr_list_select_row" : self.on_attr_list_select_row, + "on_edit_birth_clicked" : self.on_edit_birth_clicked, + "on_edit_death_clicked" : self.on_edit_death_clicked, + "on_delete_address_clicked" : self.on_delete_addr_clicked, + "on_delete_attr_clicked" : self.on_delete_attr_clicked, + "on_delete_event" : self.on_delete_event, + "on_delete_url_clicked" : self.on_delete_url_clicked, + "on_deletephoto_clicked" : self.gallery.on_delete_photo_clicked, + "on_edit_properties_clicked": self.gallery.popup_change_description, + "on_editperson_switch_page" : self.on_switch_page, + "on_event_add_clicked" : self.on_event_add_clicked, + "on_event_delete_clicked" : self.on_event_delete_clicked, + "on_event_select_row" : self.on_event_select_row, + "on_event_update_clicked" : self.on_event_update_clicked, + "on_makeprimary_clicked" : self.gallery.on_primary_photo_clicked, + "on_name_list_select_row" : self.on_name_list_select_row, + "on_name_note_clicked" : self.on_name_note_clicked, + "on_name_source_clicked" : self.on_primary_name_source_clicked, + "on_photolist_button_press_event" : self.gallery.on_photolist_button_press_event, + "on_photolist_select_icon" : self.gallery.on_photo_select_icon, + "on_update_address_clicked" : self.on_update_addr_clicked, + "on_update_attr_clicked" : self.on_update_attr_clicked, + "on_update_url_clicked" : self.on_update_url_clicked, + "on_web_go_clicked" : self.on_web_go_clicked, + "on_web_list_select_row" : self.on_web_list_select_row, + }) self.window = self.get_widget("editPerson") - self.gallery_widget = self.top.get_widget("photolist") - pid = "i%s" % person.getId() - self.gallery = PersonGallery(self, self.path, pid, self.gallery_widget, self.db) self.notes_field = self.get_widget("personNotes") self.event_name_field = self.get_widget("eventName") self.event_place_field = self.get_widget("eventPlace") @@ -155,44 +192,6 @@ class EditPerson: self.window.editable_enters(self.ddate); self.window.editable_enters(self.dplace); - id = self.top.signal_autoconnect({ - "destroy_passed_object" : self.on_cancel_edit, - "on_add_address_clicked" : self.on_add_addr_clicked, - "on_add_aka_clicked" : self.on_add_aka_clicked, - "on_add_attr_clicked" : self.on_add_attr_clicked, - "on_add_url_clicked" : self.on_add_url_clicked, - "on_addphoto_clicked" : self.gallery.on_add_photo_clicked, - "on_address_list_select_row": self.on_addr_list_select_row, - "on_aka_delete_clicked" : self.on_aka_delete_clicked, - "on_aka_update_clicked" : self.on_aka_update_clicked, - "on_apply_person_clicked" : self.on_apply_person_clicked, - "on_attr_list_select_row" : self.on_attr_list_select_row, - "on_edit_birth_clicked" : self.on_edit_birth_clicked, - "on_edit_death_clicked" : self.on_edit_death_clicked, - "on_delete_address_clicked" : self.on_delete_addr_clicked, - "on_delete_attr_clicked" : self.on_delete_attr_clicked, - "on_delete_event" : self.on_delete_event, - "on_delete_url_clicked" : self.on_delete_url_clicked, - "on_deletephoto_clicked" : self.gallery.on_delete_photo_clicked, - "on_edit_properties_clicked": self.gallery.popup_change_description, - "on_editperson_switch_page" : self.on_switch_page, - "on_event_add_clicked" : self.on_event_add_clicked, - "on_event_delete_clicked" : self.on_event_delete_clicked, - "on_event_select_row" : self.on_event_select_row, - "on_event_update_clicked" : self.on_event_update_clicked, - "on_makeprimary_clicked" : self.gallery.on_primary_photo_clicked, - "on_name_list_select_row" : self.on_name_list_select_row, - "on_name_note_clicked" : self.on_name_note_clicked, - "on_name_source_clicked" : self.on_primary_name_source_clicked, - "on_photolist_button_press_event" : self.gallery.on_photolist_button_press_event, - "on_photolist_select_icon" : self.gallery.on_photo_select_icon, - "on_update_address_clicked" : self.on_update_addr_clicked, - "on_update_attr_clicked" : self.on_update_attr_clicked, - "on_update_url_clicked" : self.on_update_url_clicked, - "on_web_go_clicked" : self.on_web_go_clicked, - "on_web_list_select_row" : self.on_web_list_select_row, - }) - if len(const.surnames) > 0: const.surnames.sort() self.get_widget("lastNameList").set_popdown_strings(const.surnames) @@ -313,16 +312,19 @@ class EditPerson: UrlEdit.UrlEditor(self,pname,None) def on_add_attr_clicked(self,obj): + """Brings up the AttributeEditor for a new attribute""" import AttrEdit pname = self.person.getPrimaryName().getName() AttrEdit.AttributeEditor(self,None,pname,const.personalAttributes) def on_event_add_clicked(self,obj): + """Brings up the EventEditor for a new event""" import EventEdit pname = self.person.getPrimaryName().getName() EventEdit.EventEditor(self,pname,const.personalEvents,const.save_fevent,None,0) def on_edit_birth_clicked(self,obj): + """Brings up the EventEditor for the birth record, event name cannot be changed""" import EventEdit pname = self.person.getPrimaryName().getName() event = self.birth @@ -334,6 +336,7 @@ class EditPerson: const.save_fevent,event,1) def on_edit_death_clicked(self,obj): + """Brings up the EventEditor for the death record, event name cannot be changed""" import EventEdit pname = self.person.getPrimaryName().getName() event = self.death @@ -344,26 +347,31 @@ class EditPerson: EventEdit.EventEditor(self,pname,const.personalEvents,const.save_fevent,event,1) def on_aka_delete_clicked(self,obj): + """Deletes the selected name from the name list""" if utils.delete_selected(obj,self.nlist): self.lists_changed = 1 self.redraw_name_list() def on_delete_url_clicked(self,obj): + """Deletes the selected URL from the URL list""" if utils.delete_selected(obj,self.ulist): self.lists_changed = 1 self.redraw_url_list() def on_delete_attr_clicked(self,obj): + """Deletes the selected attribute from the attribute list""" if utils.delete_selected(obj,self.alist): self.lists_changed = 1 self.redraw_attr_list() def on_delete_addr_clicked(self,obj): + """Deletes the selected address from the address list""" if utils.delete_selected(obj,self.plist): self.lists_changed = 1 self.redraw_addr_list() def on_web_go_clicked(self,obj): + """Attempts to display the selected URL in a web browser""" import gnome.url text = obj.get() @@ -371,6 +379,7 @@ class EditPerson: gnome.url.show(text) def on_cancel_edit(self,obj): + """If the data has changed, give the user a chance to cancel the close window""" if self.did_data_change(): q = _("Are you sure you want to abandon your changes?") GnomeQuestionDialog(q,self.cancel_callback) @@ -378,6 +387,7 @@ class EditPerson: utils.destroy_passed_object(obj) def on_delete_event(self,obj,b): + """If the data has changed, give the user a chance to cancel the close window""" if self.did_data_change(): q = _("Are you sure you want to abandon your changes?") GnomeQuestionDialog(q,self.cancel_callback) @@ -387,11 +397,12 @@ class EditPerson: return FALSE def cancel_callback(self,a): + """If the user answered yes to abandoning changes, close the window""" if a==0: utils.destroy_passed_object(self.window) def did_data_change(self): - + """Check to see if any of the data has changed from the original record""" surname = self.surname_field.get_text() suffix = self.suffix.get_text() given = self.given.get_text() @@ -448,6 +459,7 @@ class EditPerson: return changed def on_event_delete_clicked(self,obj): + """Delete the selected event""" if utils.delete_selected(obj,self.elist): self.lists_changed = 1 self.redraw_event_list() @@ -703,7 +715,6 @@ class EditPerson: self.update_lists() self.callback(self) - self.window.hide() utils.destroy_passed_object(obj) def on_primary_name_source_clicked(self,obj): diff --git a/gramps/src/EditPlace.py b/gramps/src/EditPlace.py index b3a60387a..8ffeef428 100644 --- a/gramps/src/EditPlace.py +++ b/gramps/src/EditPlace.py @@ -63,6 +63,7 @@ class EditPlace: self.callback = func self.path = db.getSavePath() self.not_loaded = 1 + self.ref_not_loaded = 1 self.lists_changed = 0 if place: self.srcreflist = place.getSourceRefList() @@ -105,6 +106,7 @@ class EditPlace: self.country.set_text(mloc.get_country()) self.longitude.set_text(place.get_longitude()) self.latitude.set_text(place.get_latitude()) + self.refinfo = self.top_window.get_widget("refinfo") self.note.set_point(0) self.note.insert_defaults(place.getNote()) @@ -148,7 +150,7 @@ class EditPlace: self.redraw_url_list() self.redraw_location_list() - + def update_lists(self): self.place.setUrlList(self.ulist) self.place.set_alternate_locations(self.llist) @@ -232,6 +234,9 @@ class EditPlace: if page == 3 and self.not_loaded: self.not_loaded = 0 self.gallery.load_images() + elif page == 5 and self.ref_not_loaded: + self.ref_not_loaded = 0 + self.display_references() def on_update_url_clicked(self,obj): import UrlEdit @@ -294,6 +299,48 @@ class EditPlace: self.loc_state.set_text(loc.get_state()) self.loc_country.set_text(loc.get_country()) + def display_references(self): + pevent = [] + fevent = [] + for p in self.db.getPersonMap().values(): + for event in [p.getBirth(), p.getDeath()] + p.getEventList(): + if event.getPlace() == self.place: + pevent.append((p,event)) + for f in self.db.getFamilyMap().values(): + for event in f.getEventList(): + if event.getPlace() == self.place: + fevent.append((f,event)) + + self.refinfo.set_point(0) + self.refinfo.set_word_wrap(1) + + if len(pevent) > 0: + self.refinfo.insert_defaults(_("People") + "\n") + self.refinfo.insert_defaults("_________________________\n\n") + t = _("%s [%s]: event %s\n") + + for e in pevent: + msg = t % (Config.nameof(e[0]),e[0].getId(),e[1].getName()) + self.refinfo.insert_defaults(msg) + + if len(fevent) > 0: + self.refinfo.insert_defaults("\n%s\n" % _("Families")) + self.refinfo.insert_defaults("_________________________\n\n") + t = _("%s [%s]: event %s\n") + + for e in fevent: + father = e[0].getFather() + mother = e[0].getMother() + if father and mother: + fname = "%s and %s" % (Config.nameof(father),Config.nameof(mother)) + elif father: + fname = "%s" % Config.nameof(father) + else: + fname = "%s" % Config.nameof(mother) + + msg = t % (fname,e[0].getId(),e[1].getName()) + self.refinfo.insert_defaults(msg) + #------------------------------------------------------------------------- # # @@ -316,56 +363,23 @@ def src_changed(parent): class DeletePlaceQuery: - def __init__(self,db,place,update,pevent,fevent): + def __init__(self,place,db,update): self.db = db self.place = place self.update = update - self.pevent = pevent - self.fevent = fevent - msg = [] - self.xml = libglade.GladeXML(const.gladeFile,"place_query") - self.xml.signal_autoconnect({ - 'on_force_delete_clicked': self.on_force_delete_clicked, - 'destroy_passed_object' : utils.destroy_passed_object}) - - textbox = self.xml.get_widget("text") - textbox.set_point(0) - textbox.set_word_wrap(1) - - if len(pevent) > 0: - textbox.insert_defaults(_("People") + "\n") - textbox.insert_defaults("_________________________\n\n") - t = _("%s [%s]: event %s\n") - - for e in pevent: - msg = t % (Config.nameof(e[0]),e[0].getId(),e[1].getName()) - textbox.insert_defaults(msg) - - if len(fevent) > 0: - textbox.insert_defaults("\n%s\n" % _("Families")) - textbox.insert_defaults("_________________________\n\n") - t = _("%s [%s]: event %s\n") - - for e in fevent: - father = e[0].getFather() - mother = e[0].getMother() - if father and mother: - fname = "%s and %s" % (Config.nameof(father),Config.nameof(mother)) - elif father: - fname = "%s" % Config.nameof(father) - else: - fname = "%s" % Config.nameof(mother) - - msg = t % (fname,e[0].getId(),e[1].getName()) - textbox.insert_defaults(msg) - - def on_force_delete_clicked(self,obj): - for event in self.pevent + self.fevent: - event[1].setPlace(None) - map = self.db.getPlaceMap() - del map[self.place.getId()] + def query_response(self,ans): + if ans == 1: + return + del self.db.getPlaceMap()[self.place.getId()] utils.modified() - utils.destroy_passed_object(obj) + + for p in self.db.getPersonMap().values(): + for event in [p.getBirth(), p.getDeath()] + p.getEventList(): + if event.getPlace() == self.place: + event.setPlace(None) + for f in self.db.getFamilyMap().values(): + for event in f.getEventList(): + if event.getPlace() == self.place: + event.setPlace(None) self.update(0) - diff --git a/gramps/src/EditSource.py b/gramps/src/EditSource.py index 2cac27aba..e8b384df8 100644 --- a/gramps/src/EditSource.py +++ b/gramps/src/EditSource.py @@ -43,6 +43,7 @@ import libglade import intl import const import utils +import Config from RelLib import * import ImageSelect @@ -62,6 +63,7 @@ class EditSource: self.callback = func self.path = db.getSavePath() self.not_loaded = 1 + self.ref_not_loaded = 1 self.top_window = libglade.GladeXML(const.gladeFile,"sourceEditor") sid = "s%s" % source.getId() @@ -71,7 +73,8 @@ class EditSource: self.author = self.top_window.get_widget("author") self.pubinfo = self.top_window.get_widget("pubinfo") self.note = self.top_window.get_widget("source_note") - + self.refinfo = self.top_window.get_widget("refinfo") + self.title.set_text(source.getTitle()) self.author.set_text(source.getAuthor()) self.pubinfo.set_text(source.getPubInfo()) @@ -87,6 +90,7 @@ class EditSource: "on_switch_page" : self.on_switch_page, "on_addphoto_clicked" : self.gallery.on_add_photo_clicked, "on_deletephoto_clicked" : self.gallery.on_delete_photo_clicked, + "on_edit_properties_clicked": self.gallery.popup_change_description, "on_sourceapply_clicked" : self.on_source_apply_clicked }) @@ -96,9 +100,101 @@ class EditSource: self.top_window.get_widget("add_photo").set_sensitive(0) self.top_window.get_widget("delete_photo").set_sensitive(0) - self.top.editable_enters(self.title); - self.top.editable_enters(self.author); - self.top.editable_enters(self.pubinfo); + self.top.editable_enters(self.title) + self.top.editable_enters(self.author) + self.top.editable_enters(self.pubinfo) + + def display_references(self): + p_event_list = [] + p_attr_list = [] + p_addr_list = [] + p_name_list = [] + m_list = [] + f_event_list = [] + f_attr_list = [] + p_list = [] + for p in self.db.getPlaceMap().values(): + name = p.get_title() + for sref in p.getSourceRefList(): + if sref.getBase() == self.source: + p_list.append(name) + for p in self.db.getPersonMap().values(): + name = Config.nameof(p) + for v in p.getEventList() + [p.getBirth(), p.getDeath()]: + for sref in v.getSourceRefList(): + if sref.getBase() == self.source: + p_event_list.append((name,v.getName())) + for v in p.getAttributeList(): + for sref in v.getSourceRefList(): + if sref.getBase() == self.source: + p_attr_list.append((name,v.getType())) + for v in p.getAlternateNames() + [p.getPrimaryName()]: + for sref in v.getSourceRefList(): + if sref.getBase() == self.source: + p_name_list.append((name,v.getName())) + for v in p.getAddressList(): + for sref in v.getSourceRefList(): + if sref.getBase() == self.source: + p_addr_list.append((name,v.getStreet())) + for p in self.db.getObjectMap().values(): + name = p.getDescription() + for sref in p.getSourceRefList(): + if sref.getBase() == self.source: + m_list.append(name) + for p in self.db.getFamilyMap().values(): + f = p.getFather() + m = p.getMother() + if f and m: + name = _("%s and %s") % (Config.nameof(f),Config.nameof(m)) + elif f: + name = "%s" % Config.nameof(f) + else: + name = "%s" % Config.nameof(m) + for v in p.getEventList(): + for sref in v.getSourceRefList(): + if sref.getBase() == self.source: + f_event_list.append((n,v.getName())) + for v in p.getAttributeList(): + for sref in v.getSourceRefList(): + if sref.getBase() == self.source: + f_attr_list.append((name,v.getType())) + + add = self.refinfo.insert_defaults + if len(p_event_list) > 0: + add(_("Individual Events")) + add("\n-----------------------------\n") + for p in p_event_list: + add("%s: %s\n" % (p[0],const.display_pevent(p[1]))) + if len(p_attr_list) > 0: + add(_("Individual Attributes")) + add("\n-----------------------------\n") + for p in p_attr_list: + add("%s: %s\n" % (p[0],const.display_pattr(p[1]))) + if len(p_name_list) > 0: + add(_("Individual Names")) + add("\n-----------------------------\n") + for p in p_name_list: + add("%s: %s\n" % p) + if len(f_event_list) > 0: + add(_("Family Events")) + add("\n-----------------------------\n") + for p in f_event_list: + add("%s: %s\n" % (p[0],const.display_fevent(p[1]))) + if len(f_attr_list) > 0: + add(_("Family Attributes")) + add("\n-----------------------------\n") + for p in f_event_list: + add("%s: %s\n" % (p[0],const.display_fattr(p[1]))) + if len(m_list) > 0: + add(_("Media Objects")) + add("\n-----------------------------\n") + for p in m_event_list: + add("%s\n" % m) + if len(m_list) > 0: + add(_("Places")) + add("\n-----------------------------\n") + for p in p_list: + add("%s\n" % m) def on_source_apply_clicked(self,obj): @@ -130,4 +226,61 @@ class EditSource: if page == 2 and self.not_loaded: self.not_loaded = 0 self.gallery.load_images() + elif page == 3 and self.ref_not_loaded: + self.ref_not_loaded = 0 + self.display_references() + + +class DelSrcQuery: + def __init__(self,source,db,update): + self.source = source + self.db = db + self.update = update + + def delete_source(self,object): + m = 0 + l = [] + for sref in object.getSourceRefList(): + if sref.getBase() != self.source: + l.append(sref) + else: + m = 1 + if m: + object.setSourceRefList(l) + + def query_response(self,ans): + if ans == 1: + return + del self.db.getSourceMap()[self.source.getId()] + utils.modified() + + for p in self.db.getPersonMap().values(): + for v in p.getEventList() + [p.getBirth(), p.getDeath()]: + self.delete_source(v) + + for v in p.getAttributeList(): + self.delete_source(v) + + for v in p.getAlternateNames() + [p.getPrimaryName()]: + self.delete_source(v) + + for v in p.getAddressList(): + self.delete_source(v) + + for p in self.db.getFamilyMap().values(): + for v in p.getEventList(): + self.delete_source(v) + + for v in p.getAttributeList(): + self.delete_source(v) + + for p in self.db.getObjectMap().values(): + self.delete_source(p) + + for p in self.db.getPlaceMap().values(): + self.delete_source(p) + + self.update(0) + + diff --git a/gramps/src/ImageSelect.py b/gramps/src/ImageSelect.py index c133d50ee..170c0c977 100644 --- a/gramps/src/ImageSelect.py +++ b/gramps/src/ImageSelect.py @@ -366,8 +366,9 @@ class Gallery(ImageSelect): # #------------------------------------------------------------------------- def popup_change_description(self, obj): - photo = self.dataobj.getPhotoList()[self.selectedIcon] - LocalMediaProperties(photo,self.path) + if self.selectedIcon >=0: + photo = self.dataobj.getPhotoList()[self.selectedIcon] + LocalMediaProperties(photo,self.path) class LocalMediaProperties: diff --git a/gramps/src/gramps.glade b/gramps/src/gramps.glade index 273055ccb..c7c4c99dd 100644 --- a/gramps/src/gramps.glade +++ b/gramps/src/gramps.glade @@ -2317,9 +2317,14 @@ GtkButton button104 - False True True + + clicked + on_delete_source_clicked + source_list + Thu, 18 Oct 2001 00:36:56 GMT + GTK_RELIEF_NORMAL @@ -4820,7 +4825,6 @@ Unknown GtkNotebook notebook2 - 450 350 True @@ -5121,7 +5125,7 @@ Unknown sourceEditor Thu, 31 May 2001 14:39:32 GMT - + GTK_RELIEF_NORMAL @@ -5136,7 +5140,22 @@ Unknown sourceEditor Thu, 31 May 2001 14:39:16 GMT - + + GTK_RELIEF_NORMAL + + + + GtkButton + button146 + True + True + + clicked + on_edit_properties_clicked + sourceEditor + Thu, 18 Oct 2001 00:11:41 GMT + + GTK_RELIEF_NORMAL @@ -5156,6 +5175,36 @@ Unknown 0 0 + + + GtkScrolledWindow + scrolledwindow32 + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + + GtkText + refinfo + True + False + + + + + + GtkLabel + Notebook:tab + label274 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + @@ -6246,159 +6295,6 @@ Unknown - - GnomeDialog - place_query - Gramps - Delete a currently used Place - GTK_WINDOW_DIALOG - GTK_WIN_POS_NONE - True - True - True - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox13 - False - 0 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area13 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - force_delete - True - True - - clicked - on_force_delete_clicked - place_query - Tue, 21 Aug 2001 15:30:46 GMT - - GNOME_STOCK_BUTTON_YES - - - - GtkButton - button116 - True - True - - clicked - destroy_passed_object - place_query - Tue, 21 Aug 2001 15:33:25 GMT - - GNOME_STOCK_BUTTON_NO - - - - - GtkVBox - vbox39 - False - 0 - - 0 - True - True - - - - GtkLabel - label234 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 10 - - 0 - False - False - - - - - GtkHSeparator - hseparator20 - - 0 - False - True - - - - - GtkScrolledWindow - scrolledwindow27 - 450 - 250 - GTK_POLICY_NEVER - GTK_POLICY_ALWAYS - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkText - text - True - False - - - - - - GtkLabel - label233 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 10 - - 0 - False - False - - - - - - GnomeDialog find diff --git a/gramps/src/gramps_main.py b/gramps/src/gramps_main.py index 135bed062..3ec846598 100755 --- a/gramps/src/gramps_main.py +++ b/gramps/src/gramps_main.py @@ -490,14 +490,6 @@ def on_add_source_clicked(obj): def on_add_place_clicked(obj): EditPlace.EditPlace(Place(),database,new_place_after_edit) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_delete_source_clicked(obj): - pass - #------------------------------------------------------------------------- # # @@ -509,27 +501,93 @@ def on_delete_place_clicked(obj): else: index = obj.selection[0] - pevent = [] - fevent = [] + used = 0 place = obj.get_row_data(index) for p in database.getPersonMap().values(): for event in [p.getBirth(), p.getDeath()] + p.getEventList(): if event.getPlace() == place: - pevent.append((p,event)) + used = 1 for f in database.getFamilyMap().values(): for event in f.getEventList(): if event.getPlace() == place: - fevent.append((f,event)) + used = 1 - if len(pevent) > 0 or len(fevent) > 0: + if used == 1: import EditPlace - EditPlace.DeletePlaceQuery(database,place,update_display,pevent,fevent) + ans = EditPlace.DeletePlaceQuery(place,database,update_display) + msg = _("This place is currently being used. Delete anyway?") + GnomeQuestionDialog(msg,ans.query_response) else: map = database.getPlaceMap() del map[place.getId()] utils.modified() update_display(0) - + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- + + +def on_delete_source_clicked(obj): + import EditSource + + if len(obj.selection) == 0: + return + else: + index = obj.selection[0] + + source = obj.get_row_data(index) + + ans = EditSource.DelSrcQuery(source,database,update_display) + + if is_source_used(source): + msg = _("This source is currently being used. Delete anyway?") + GnomeQuestionDialog(msg,ans.query_response) + else: + map = database.getSourceMap() + del map[source.getId()] + utils.modified() + update_display(0) + +def is_source_used(source): + for p in database.getPlaceMap().values(): + for sref in p.getSourceRefList(): + if sref.getBase() == source: + return 1 + for p in database.getPersonMap().values(): + for v in p.getEventList() + [p.getBirth(), p.getDeath()]: + for sref in v.getSourceRefList(): + if sref.getBase() == source: + return 1 + for v in p.getAttributeList(): + for sref in v.getSourceRefList(): + if sref.getBase() == source: + return 1 + for v in p.getAlternateNames() + [p.getPrimaryName()]: + for sref in v.getSourceRefList(): + if sref.getBase() == source: + return 1 + for v in p.getAddressList(): + for sref in v.getSourceRefList(): + if sref.getBase() == source: + return 1 + for p in database.getObjectMap().values(): + for sref in p.getSourceRefList(): + if sref.getBase() == source: + return 1 + for p in database.getFamilyMap().values(): + for v in p.getEventList(): + for sref in v.getSourceRefList(): + if sref.getBase() == source: + return 1 + for v in p.getAttributeList(): + for sref in v.getSourceRefList(): + if sref.getBase() == source: + return 1 + return 0 + #------------------------------------------------------------------------- # # diff --git a/gramps/src/places.glade b/gramps/src/places.glade index 2e2ecb6a7..026a03b93 100644 --- a/gramps/src/places.glade +++ b/gramps/src/places.glade @@ -132,7 +132,6 @@ GtkNotebook notebook3 - 450 350 True @@ -964,7 +963,6 @@ GtkCList loc_list - 500 True select_row @@ -1117,7 +1115,6 @@ GtkText place_note - 500 True True @@ -1611,6 +1608,36 @@ 0 0 + + + GtkScrolledWindow + scrolledwindow31 + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + + GtkText + refinfo + True + False + + + + + + GtkLabel + Notebook:tab + label278 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 +