From d9c223deedf8c5bb1c2c4bcd1ef9d8de0da15fce Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 22 Feb 2002 03:55:32 +0000 Subject: [PATCH] Converted gramps_main.py to a class, replace utils.py with Utils.py and Config.py with GrampsCfg.py (for pychecker) svn: r789 --- src/AddMedia.py | 14 +- src/AddSpouse.py | 24 +- src/AddrEdit.py | 6 +- src/AttrEdit.py | 8 +- src/Bookmarks.py | 4 +- src/ChooseParents.py | 34 +- src/DrawDoc.py | 1 - src/EditPerson.py | 122 +- src/EditPlace.py | 48 +- src/EditSource.py | 28 +- src/EventEdit.py | 12 +- src/Find.py | 8 +- src/{Config.py => GrampsCfg.py} | 20 +- src/GrampsParser.py | 4 +- src/ImageSelect.py | 92 +- src/LocEdit.py | 6 +- src/Marriage.py | 64 +- src/MediaView.py | 54 +- src/MergeData.py | 38 +- src/NameEdit.py | 10 +- src/NoteEdit.py | 8 +- src/PaperMenu.py | 4 +- src/PedView.py | 6 +- src/PlaceView.py | 12 +- src/Plugins.py | 16 +- src/RelImage.py | 4 +- src/Report.py | 16 +- src/SelectChild.py | 26 +- src/SourceView.py | 12 +- src/Sources.py | 16 +- src/StartupDialog.py | 6 +- src/StyleEditor.py | 10 +- src/TextDoc.py | 1 - src/UrlEdit.py | 6 +- src/{utils.py => Utils.py} | 4 +- src/VersionControl.py | 8 +- src/WriteXML.py | 4 +- src/docgen/HtmlDoc.py | 1 - src/docgen/KwordDoc.py | 1 - src/docgen/OpenOfficeDoc.py | 1 - src/filters/RegExMatch.py | 4 +- src/filters/SubString.py | 4 +- src/gramps_main.py | 3657 ++++++++++++++----------------- src/plugins/AncestorChart.py | 6 +- src/plugins/ChangeTypes.py | 10 +- src/plugins/Check.py | 8 +- src/plugins/DesGraph.py | 2 - src/plugins/Desbrowser.py | 8 +- src/plugins/EventCmp.py | 22 +- src/plugins/Graph.py | 6 +- src/plugins/GraphViz.py | 3 +- src/plugins/IndivSummary.py | 2 - src/plugins/Merge.py | 14 +- src/plugins/PatchNames.py | 10 +- src/plugins/ReadGedcom.py | 20 +- src/plugins/ReadNative.py | 6 +- src/plugins/RelCalc.py | 4 +- src/plugins/ReorderIds.py | 4 +- src/plugins/Summary.py | 4 +- src/plugins/Verify.py | 6 +- src/plugins/WebPage.py | 7 +- src/plugins/WriteGedcom.py | 10 +- src/plugins/WritePafPalm.py | 6 +- src/plugins/WritePkg.py | 6 +- src/plugins/count_anc.py | 4 +- src/plugins/soundgen.py | 6 +- 66 files changed, 2085 insertions(+), 2513 deletions(-) rename src/{Config.py => GrampsCfg.py} (98%) rename src/{utils.py => Utils.py} (99%) diff --git a/src/AddMedia.py b/src/AddMedia.py index c238cab76..2a5f3197e 100644 --- a/src/AddMedia.py +++ b/src/AddMedia.py @@ -53,7 +53,7 @@ import libglade # #------------------------------------------------------------------------- import const -import utils +import Utils import RelImage import RelLib @@ -82,7 +82,7 @@ class AddMediaObject: self.glade.signal_autoconnect({ "on_savephoto_clicked" : self.on_savephoto_clicked, "on_name_changed" : self.on_name_changed, - "destroy_passed_object" : utils.destroy_passed_object + "destroy_passed_object" : Utils.destroy_passed_object }) self.window.editable_enters(self.description) @@ -102,7 +102,7 @@ class AddMediaObject: GnomeErrorDialog(msgstr % filename) return - type = utils.get_mime_type(filename) + type = Utils.get_mime_type(filename) if description == "": description = os.path.basename(filename) @@ -119,9 +119,9 @@ class AddMediaObject: name = filename mobj.setPath(name) - utils.modified() + Utils.modified() self.update() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def on_name_changed(self,obj): """ @@ -139,9 +139,9 @@ class AddMediaObject: self.temp_name = root if os.path.isfile(filename): - type = utils.get_mime_type(filename) + type = Utils.get_mime_type(filename) if type[0:5] == 'image': image = RelImage.scale_image(filename,const.thumbScale) self.image.load_imlib(image) else: - self.image.load_file(utils.find_icon(type)) + self.image.load_file(Utils.find_icon(type)) diff --git a/src/AddSpouse.py b/src/AddSpouse.py index 28207d82e..850578508 100644 --- a/src/AddSpouse.py +++ b/src/AddSpouse.py @@ -52,8 +52,8 @@ import libglade import RelLib import const import sort -import utils -import Config +import Utils +import GrampsCfg class AddSpouse: """ @@ -87,7 +87,7 @@ class AddSpouse: self.surname_combo = self.glade.get_widget("surname_combo") self.rel_combo.set_popdown_strings(const.familyRelations) - utils.attach_surnames(self.surname_combo) + Utils.attach_surnames(self.surname_combo) # Typing CR selects 'Add Existing' button self.top.editable_enters(self.given) @@ -96,15 +96,15 @@ class AddSpouse: self.name_list = self.db.getPersonMap().values() self.name_list.sort(sort.by_last_name) - title = _("Choose Spouse/Partner of %s") % Config.nameof(person) + title = _("Choose Spouse/Partner of %s") % GrampsCfg.nameof(person) self.glade.get_widget("spouseTitle").set_text(title) self.glade.signal_autoconnect({ "on_select_spouse_clicked" : self.select_spouse_clicked, "on_new_spouse_clicked" : self.new_spouse_clicked, "on_rel_type_changed" : self.relation_type_changed, - "on_combo_insert_text" : utils.combo_insert_text, - "destroy_passed_object" : utils.destroy_passed_object + "on_combo_insert_text" : Utils.combo_insert_text, + "destroy_passed_object" : Utils.destroy_passed_object }) self.relation_type.set_text(_("Married")) @@ -142,8 +142,8 @@ class AddSpouse: family.setFather(spouse) family.setMother(self.person) - utils.destroy_passed_object(obj) - utils.modified() + Utils.destroy_passed_object(obj) + Utils.modified() self.addperson(spouse) self.update(family) @@ -160,10 +160,10 @@ class AddSpouse: # don't do anything if the marriage already exists for f in self.person.getFamilyList(): if spouse == f.getMother() or spouse == f.getFather(): - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) return - utils.modified() + Utils.modified() family = self.db.newFamily() self.person.addFamily(family) spouse.addFamily(family) @@ -176,7 +176,7 @@ class AddSpouse: family.setMother(self.person) family.setRelationship(const.save_frel(self.relation_type.get_text())) - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) self.update(family) def relation_type_changed(self,obj): @@ -204,7 +204,7 @@ class AddSpouse: if person.getGender() == gender: continue name = person.getPrimaryName().getName() - self.spouse_list.append([name,utils.birthday(person)]) + self.spouse_list.append([name,Utils.birthday(person)]) self.spouse_list.set_row_data(index,person) index = index + 1 self.spouse_list.thaw() diff --git a/src/AddrEdit.py b/src/AddrEdit.py index 4e100b432..1fc6f5faa 100644 --- a/src/AddrEdit.py +++ b/src/AddrEdit.py @@ -35,7 +35,7 @@ import libglade # #------------------------------------------------------------------------- import const -import utils +import Utils import Date import RelLib @@ -102,7 +102,7 @@ class AddressEditor: self.srcreflist = [] self.top.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_addr_edit_ok_clicked" : self.ok_clicked, "on_source_clicked" : self.source_clicked }) @@ -133,7 +133,7 @@ class AddressEditor: self.update(date,street,city,state,country,postal,note,priv) self.parent.redraw_addr_list() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def check(self,get,set,data): """Compares a data item, updates if necessary, and sets the diff --git a/src/AttrEdit.py b/src/AttrEdit.py index 200b00688..5e590816e 100644 --- a/src/AttrEdit.py +++ b/src/AttrEdit.py @@ -35,7 +35,7 @@ import libglade # #------------------------------------------------------------------------- import const -import utils +import Utils from RelLib import * import Sources @@ -97,9 +97,9 @@ class AttributeEditor: self.window.set_data("o",self) self.top.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_attr_edit_ok_clicked" : self.on_ok_clicked, - "on_combo_insert_text" : utils.combo_insert_text, + "on_combo_insert_text" : Utils.combo_insert_text, "on_source_clicked" : self.on_source_clicked }) @@ -125,7 +125,7 @@ class AttributeEditor: self.update(type,value,note,priv) self.parent.redraw_attr_list() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def check(self,get,set,data): """Compares a data item, updates if necessary, and sets the diff --git a/src/Bookmarks.py b/src/Bookmarks.py index bd1e53194..1f10159c0 100644 --- a/src/Bookmarks.py +++ b/src/Bookmarks.py @@ -34,7 +34,7 @@ import libglade # #------------------------------------------------------------------------- import const -import utils +import Utils #------------------------------------------------------------------------- # @@ -81,7 +81,7 @@ class Bookmarks : def add(self,person): """appends the person to the bottom of the bookmarks""" if person not in self.bookmarks: - utils.modified() + Utils.modified() self.bookmarks.append(person) self.redraw() diff --git a/src/ChooseParents.py b/src/ChooseParents.py index d5a1b8944..7b1f4d4d0 100644 --- a/src/ChooseParents.py +++ b/src/ChooseParents.py @@ -41,8 +41,8 @@ import libglade import RelLib import const import sort -import utils -import Config +import Utils +import GrampsCfg class ChooseParents: """ @@ -98,11 +98,11 @@ class ChooseParents: "on_addmother_clicked" : self.add_mother_clicked, "on_addfather_clicked" : self.add_father_clicked, "on_prel_changed" : self.parent_relation_changed, - "on_combo_insert_text" : utils.combo_insert_text, - "destroy_passed_object" : utils.destroy_passed_object + "on_combo_insert_text" : Utils.combo_insert_text, + "destroy_passed_object" : Utils.destroy_passed_object }) - text = _("Choose the Parents of %s") % Config.nameof(self.person) + text = _("Choose the Parents of %s") % GrampsCfg.nameof(self.person) self.title.set_text(text) if self.family: self.prel.set_text(_(self.family.getRelationship())) @@ -114,8 +114,8 @@ class ChooseParents: type = obj.get_text() - self.father_name.set_text(Config.nameof(self.father)) - self.mother_name.set_text(Config.nameof(self.mother)) + self.father_name.set_text(GrampsCfg.nameof(self.father)) + self.mother_name.set_text(GrampsCfg.nameof(self.mother)) self.father_list.freeze() self.mother_list.freeze() @@ -137,7 +137,7 @@ class ChooseParents: continue if person.getGender() == RelLib.Person.unknown: continue - rdata = [utils.phonebook_name(person),utils.birthday(person)] + rdata = [Utils.phonebook_name(person),Utils.birthday(person)] if type == "Partners": self.father_list.append(rdata) self.father_list.set_row_data(father_index,person) @@ -192,11 +192,11 @@ class ChooseParents: def mother_list_select_row(self,obj,a,b,c): self.mother = obj.get_row_data(a) - self.mother_name.set_text(Config.nameof(self.mother)) + self.mother_name.set_text(GrampsCfg.nameof(self.mother)) def father_list_select_row(self,obj,a,b,c): self.father = obj.get_row_data(a) - self.father_name.set_text(Config.nameof(self.father)) + self.father_name.set_text(GrampsCfg.nameof(self.father)) def save_parents_clicked(self,obj): mother_rel = const.childRelations[self.mother_rel.get_text()] @@ -228,7 +228,7 @@ class ChooseParents: else: self.family = None - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) if self.family: self.family.setRelationship(type) self.change_family_type(self.family,mother_rel,father_rel) @@ -239,14 +239,14 @@ class ChooseParents: self.xml.get_widget(sex).set_active(1) self.xml.signal_autoconnect({ "on_addfather_close": self.add_parent_close, - "on_combo_insert_text" : utils.combo_insert_text, - "destroy_passed_object" : utils.destroy_passed_object + "on_combo_insert_text" : Utils.combo_insert_text, + "destroy_passed_object" : Utils.destroy_passed_object }) window = self.xml.get_widget("addperson") window.editable_enters(self.xml.get_widget("given")) window.editable_enters(self.xml.get_widget("surname")) - utils.attach_surnames(self.xml.get_widget("surnameCombo")) + Utils.attach_surnames(self.xml.get_widget("surnameCombo")) def add_father_clicked(self,obj): self.add_parent_clicked(obj,"male") @@ -300,7 +300,7 @@ class ChooseParents: self.person.setMainFamily(family) else: self.person.addAltFamily(family,mother_rel,father_rel) - utils.modified() + Utils.modified() def add_parent_close(self,obj): @@ -317,8 +317,8 @@ class ChooseParents: else: person.setGender(RelLib.Person.female) self.mother = person - utils.modified() + Utils.modified() self.parent_relation_changed(self.prel) - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) self.full_update() diff --git a/src/DrawDoc.py b/src/DrawDoc.py index 7c918ea7b..9681217dd 100644 --- a/src/DrawDoc.py +++ b/src/DrawDoc.py @@ -22,7 +22,6 @@ from TextDoc import * import string import os -import utils #------------------------------------------------------------------------ # diff --git a/src/EditPerson.py b/src/EditPerson.py index 7858c5281..65bffebc6 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -43,8 +43,8 @@ from GDK import ACTION_COPY, BUTTON1_MASK, _2BUTTON_PRESS # #------------------------------------------------------------------------- import const -import utils -import Config +import Utils +import GrampsCfg import Date from RelLib import * import ImageSelect @@ -225,19 +225,19 @@ class EditPerson: self.comp = AutoComp.AutoCombo(self.sncombo,const.surnames) self.gid.set_text(person.getId()) - self.gid.set_editable(Config.id_edit) - self.event_list.set_column_visibility(3,Config.show_detail) - self.name_list.set_column_visibility(1,Config.show_detail) - self.attr_list.set_column_visibility(2,Config.show_detail) - self.addr_list.set_column_visibility(2,Config.show_detail) + self.gid.set_editable(GrampsCfg.id_edit) + self.event_list.set_column_visibility(3,GrampsCfg.show_detail) + self.name_list.set_column_visibility(1,GrampsCfg.show_detail) + self.attr_list.set_column_visibility(2,GrampsCfg.show_detail) + self.addr_list.set_column_visibility(2,GrampsCfg.show_detail) self.event_list = self.get_widget("eventList") - if Config.display_attr: - self.get_widget("user_label").set_text(Config.attr_name) + if GrampsCfg.display_attr: + self.get_widget("user_label").set_text(GrampsCfg.attr_name) val = "" for attr in self.person.getAttributeList(): - if attr.getType() == const.save_pattr(Config.attr_name): + if attr.getType() == const.save_pattr(GrampsCfg.attr_name): val = attr.getValue() break self.get_widget("user_data").set_text(val) @@ -251,12 +251,12 @@ class EditPerson: self.lds_endowment = self.person.getLdsEndowment() self.lds_sealing = self.person.getLdsSeal() - if Config.uselds or self.lds_baptism or self.lds_endowment or self.lds_sealing: + if GrampsCfg.uselds or self.lds_baptism or self.lds_endowment or self.lds_sealing: self.get_widget("lds_tab").show() self.get_widget("lds_page").show() # initial values - self.get_widget("activepersonTitle").set_text(Config.nameof(person)) + self.get_widget("activepersonTitle").set_text(GrampsCfg.nameof(person)) self.suffix.set_text(self.pname.getSuffix()) self.surname_field.set_text(self.pname.getSurname()) @@ -381,12 +381,12 @@ class EditPerson: m = fam.getMother() if f and m: name = _("%(father)s and %(mother)s") % { - 'father' : Config.nameof(f), - 'mother' : Config.nameof(m) } + 'father' : GrampsCfg.nameof(f), + 'mother' : GrampsCfg.nameof(m) } elif f: - name = Config.nameof(f) + name = GrampsCfg.nameof(f) elif m: - name = Config.nameof(m) + name = GrampsCfg.nameof(m) else: name = _("unknown") item = gtk.GtkMenuItem(name) @@ -556,11 +556,11 @@ class EditPerson: def redraw_name_list(self): """redraws the name list""" - utils.redraw_list(self.nlist,self.name_list,disp_name) + Utils.redraw_list(self.nlist,self.name_list,disp_name) def redraw_url_list(self): """redraws the url list, disabling the go button if no url is selected""" - length = utils.redraw_list(self.ulist,self.web_list,disp_url) + length = Utils.redraw_list(self.ulist,self.web_list,disp_url) if length > 0: self.web_go.set_sensitive(1) else: @@ -570,11 +570,11 @@ class EditPerson: def redraw_attr_list(self): """Redraws the attribute list""" - utils.redraw_list(self.alist,self.attr_list,disp_attr) + Utils.redraw_list(self.alist,self.attr_list,disp_attr) def redraw_addr_list(self): """redraws the address list for the person""" - utils.redraw_list(self.plist,self.addr_list,disp_addr) + Utils.redraw_list(self.plist,self.addr_list,disp_addr) def redraw_event_list(self): """redraw_event_list - Update both the birth and death place combo @@ -584,11 +584,11 @@ class EditPerson: combo list resets its present value, this code will have to save and restore the value for the event *not* being edited.""" - utils.redraw_list(self.elist,self.event_list,disp_event) + Utils.redraw_list(self.elist,self.event_list,disp_event) # Remember old combo list input - prev_btext = utils.strip_id(self.bplace.get_text()) - prev_dtext = utils.strip_id(self.dplace.get_text()) + prev_btext = Utils.strip_id(self.bplace.get_text()) + prev_dtext = Utils.strip_id(self.dplace.get_text()) # Update birth with new values, make sure death values don't change if (self.update_birth): @@ -683,25 +683,25 @@ class EditPerson: def on_aka_delete_clicked(self,obj): """Deletes the selected name from the name list""" - if utils.delete_selected(obj,self.nlist): + 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): + 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): + 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): + if Utils.delete_selected(obj,self.plist): self.lists_changed = 1 self.redraw_addr_list() @@ -720,7 +720,7 @@ class EditPerson: q = _("Are you sure you want to abandon your changes?") GnomeQuestionDialog(q,self.cancel_callback) else: - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def on_delete_event(self,obj,b): """If the data has changed, give the user a chance to cancel @@ -730,13 +730,13 @@ class EditPerson: GnomeQuestionDialog(q,self.cancel_callback) return 1 else: - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) return 0 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) + 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""" @@ -884,7 +884,7 @@ class EditPerson: def on_event_delete_clicked(self,obj): """Delete the selected event""" - if utils.delete_selected(obj,self.elist): + if Utils.delete_selected(obj,self.elist): self.lists_changed = 1 self.redraw_event_list() @@ -953,7 +953,7 @@ class EditPerson: self.event_name_field.set_label(const.display_pevent(event.getName())) self.event_cause_field.set_text(event.getCause()) self.event_descr_field.set_text(event.getDescription()) - self.event_details_field.set_text(utils.get_detail_text(event)) + self.event_details_field.set_text(Utils.get_detail_text(event)) def on_addr_list_select_row(self,obj,row,b,c): @@ -967,7 +967,7 @@ class EditPerson: self.addr_state.set_text(a.getState()) self.addr_country.set_text(a.getCountry()) self.addr_postal.set_text(a.getPostal()) - self.addr_details_field.set_text(utils.get_detail_text(a)) + self.addr_details_field.set_text(Utils.get_detail_text(a)) def on_name_list_select_row(self,obj,row,b,c): @@ -976,7 +976,7 @@ class EditPerson: self.alt_given_field.set_text(name.getFirstName()) self.alt_last_field.set_text(name.getSurname()) self.alt_suffix_field.set_text(name.getSuffix()) - self.name_details_field.set_text(utils.get_detail_text(name)) + self.name_details_field.set_text(Utils.get_detail_text(name)) def on_web_list_select_row(self,obj,row,b,c): @@ -996,7 +996,7 @@ class EditPerson: attr = obj.get_row_data(row) self.attr_type.set_label(const.display_pattr(attr.getType())) self.attr_value.set_text(attr.getValue()) - self.attr_details_field.set_text(utils.get_detail_text(attr)) + self.attr_details_field.set_text(Utils.get_detail_text(attr)) def aka_double_click(self,obj,event): if event.button == 1 and event.type == _2BUTTON_PRESS: @@ -1032,7 +1032,7 @@ class EditPerson: self.person.setUrlList(self.ulist) self.person.setAttributeList(self.alist) self.person.setAddressList(self.plist) - utils.modified() + Utils.modified() def on_apply_person_clicked(self,obj): @@ -1052,9 +1052,9 @@ class EditPerson: del m[self.person.getId()] m[idval] = self.person self.person.setId(idval) - utils.modified() + Utils.modified() else: - n = Config.nameof(m[idval]) + n = GrampsCfg.nameof(m[idval]) msg1 = _("GRAMPS ID value was not changed.") msg2 = _("%(grampsid)s is already used by %(person)s") % { 'grampsid' : idval, @@ -1078,11 +1078,11 @@ class EditPerson: if not name.are_equal(self.person.getPrimaryName()): self.person.setPrimaryName(name) - utils.modified() + Utils.modified() if nick != self.person.getNickName(): self.person.setNickName(nick) - utils.modified() + Utils.modified() self.pmap = {} for p in self.db.getPlaces(): @@ -1124,7 +1124,7 @@ class EditPerson: else: temp_family.setMother(None) temp_family.setFather(self.person) - utils.modified() + Utils.modified() elif female and self.person.getGender() != Person.female: self.person.setGender(Person.female) for temp_family in self.person.getFamilyList(): @@ -1134,7 +1134,7 @@ class EditPerson: else: temp_family.setFather(None) temp_family.setMother(self.person) - utils.modified() + Utils.modified() elif unknown and self.person.getGender() != Person.unknown: self.person.setGender(Person.unknown) for temp_family in self.person.getFamilyList(): @@ -1150,7 +1150,7 @@ class EditPerson: else: temp_family.setMother(None) temp_family.setFather(self.person) - utils.modified() + Utils.modified() if error == 1: msg = _("Changing the gender caused problems with marriage information.") @@ -1160,7 +1160,7 @@ class EditPerson: text = self.notes_field.get_chars(0,-1) if text != self.person.getNote(): self.person.setNote(text) - utils.modified() + Utils.modified() if self.lds_not_loaded == 0: date = self.ldsbap_date.get_text() @@ -1200,30 +1200,30 @@ class EditPerson: ord.setFamily(self.ldsfam) ord.setPlace(place) self.person.setLdsSeal(ord) - utils.modified() + Utils.modified() else: d = Date() d.set(date) if compare_dates(d,ord.getDateObj()) != 0: ord.setDateObj(d) - utils.modified() + Utils.modified() if ord.getPlace() != place: ord.setPlace(place) - utils.modified() + Utils.modified() if ord.getTemple() != temple: ord.setTemple(temple) - utils.modified() + Utils.modified() if ord.getStatus() != self.seal_stat: ord.setStatus(self.seal_stat) - utils.modified() + Utils.modified() if ord.getFamily() != self.ldsfam: ord.setFamily(self.ldsfam) - utils.modified() + Utils.modified() self.update_lists() if self.callback: self.callback(self,self.add_places) - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def get_place(self,field,makenew=0): text = string.strip(field.get_text()) @@ -1236,7 +1236,7 @@ class EditPerson: self.pmap[text] = place self.db.addPlace(place) self.add_places.append(place) - utils.modified() + Utils.modified() return place else: return None @@ -1330,22 +1330,22 @@ def update_ord(func,ord,date,temple,stat,place): ord.setTemple(temple) ord.setPlace(place) func(ord) - utils.modified() + Utils.modified() else: d = Date() d.set(date) if compare_dates(d,ord.getDateObj()) != 0: ord.setDateObj(d) - utils.modified() + Utils.modified() elif ord.getTemple() != temple: ord.setTemple(temple) - utils.modified() + Utils.modified() elif ord.getPlace() != place: ord.setPlace(place) - utils.modified() + Utils.modified() elif ord.getStatus() != stat: ord.setStatus(stat) - utils.modified() + Utils.modified() #------------------------------------------------------------------------- # @@ -1353,7 +1353,7 @@ def update_ord(func,ord,date,temple,stat,place): # #------------------------------------------------------------------------- def disp_name(name): - return [name.getName(),utils.get_detail_flags(name)] + return [name.getName(),Utils.get_detail_flags(name)] #------------------------------------------------------------------------- # @@ -1369,7 +1369,7 @@ def disp_url(url): # #------------------------------------------------------------------------- def disp_attr(attr): - detail = utils.get_detail_flags(attr) + detail = Utils.get_detail_flags(attr) return [const.display_pattr(attr.getType()),attr.getValue(),detail] #------------------------------------------------------------------------- @@ -1379,7 +1379,7 @@ def disp_attr(attr): #------------------------------------------------------------------------- def disp_addr(addr): location = "%s %s %s" % (addr.getCity(),addr.getState(),addr.getCountry()) - return [addr.getDate(),location,utils.get_detail_flags(addr)] + return [addr.getDate(),location,Utils.get_detail_flags(addr)] #------------------------------------------------------------------------- # @@ -1387,7 +1387,7 @@ def disp_addr(addr): # #------------------------------------------------------------------------- def disp_event(event): - attr = utils.get_detail_flags(event) + attr = Utils.get_detail_flags(event) return [const.display_pevent(event.getName()), event.getQuoteDate(),event.getPlaceName(),attr] diff --git a/src/EditPlace.py b/src/EditPlace.py index ad1eea553..fe6d577cf 100644 --- a/src/EditPlace.py +++ b/src/EditPlace.py @@ -35,8 +35,8 @@ import libglade # #------------------------------------------------------------------------- import const -import utils -import Config +import Utils +import GrampsCfg from RelLib import * import Sources import ImageSelect @@ -111,7 +111,7 @@ class EditPlace: self.note.set_word_wrap(1) self.top_window.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_source_clicked" : self.on_source_clicked, "on_photolist_select_icon" : self.gallery.on_photo_select_icon, "on_photolist_button_press_event" : self.gallery.on_button_press_event, @@ -179,10 +179,10 @@ class EditPlace: self.place.setUrlList(self.ulist) self.place.set_alternate_locations(self.llist) if self.lists_changed: - utils.modified() + Utils.modified() def redraw_url_list(self): - length = utils.redraw_list(self.ulist,self.web_list,disp_url) + length = Utils.redraw_list(self.ulist,self.web_list,disp_url) if length > 0: self.web_go.set_sensitive(1) else: @@ -191,7 +191,7 @@ class EditPlace: self.web_description.set_text("") def redraw_location_list(self): - utils.redraw_list(self.llist,self.loc_list,disp_loc) + Utils.redraw_list(self.llist,self.loc_list,disp_loc) def on_web_go_clicked(self,obj): @@ -216,47 +216,47 @@ class EditPlace: mloc = self.place.get_main_location() if city != mloc.get_city(): mloc.set_city(city) - utils.modified() + Utils.modified() if parish != mloc.get_parish(): mloc.set_parish(parish) - utils.modified() + Utils.modified() if self.lists_changed: self.place.setSourceRefList(self.srcreflist) - utils.modified() + Utils.modified() if state != mloc.get_state(): mloc.set_state(state) - utils.modified() + Utils.modified() if county != mloc.get_county(): mloc.set_county(county) - utils.modified() + Utils.modified() if country != mloc.get_country(): mloc.set_country(country) - utils.modified() + Utils.modified() if title != self.place.get_title(): self.place.set_title(title) - utils.modified() + Utils.modified() if longitude != self.place.get_longitude(): self.place.set_longitude(longitude) - utils.modified() + Utils.modified() if latitude != self.place.get_latitude(): self.place.set_latitude(latitude) - utils.modified() + Utils.modified() if note != self.place.getNote(): self.place.setNote(note) - utils.modified() + Utils.modified() self.update_lists() - utils.destroy_passed_object(self.top) + Utils.destroy_passed_object(self.top) if self.callback: self.callback(self.place) @@ -285,12 +285,12 @@ class EditPlace: LocEdit.LocationEditor(self,obj.get_row_data(row)) def on_delete_url_clicked(self,obj): - if utils.delete_selected(obj,self.ulist): + if Utils.delete_selected(obj,self.ulist): self.lists_changed = 1 self.redraw_url_list() def on_delete_loc_clicked(self,obj): - if utils.delete_selected(obj,self.llist): + if Utils.delete_selected(obj,self.llist): self.lists_changed = 1 self.redraw_location_list() @@ -351,7 +351,7 @@ class EditPlace: t = _("%s [%s]: event %s\n") for e in pevent: - msg = t % (Config.nameof(e[0]),e[0].getId(),e[1].getName()) + msg = t % (GrampsCfg.nameof(e[0]),e[0].getId(),e[1].getName()) self.refinfo.insert_defaults(msg) if len(fevent) > 0: @@ -363,11 +363,11 @@ class EditPlace: father = e[0].getFather() mother = e[0].getMother() if father and mother: - fname = "%s and %s" % (Config.nameof(father),Config.nameof(mother)) + fname = "%s and %s" % (GrampsCfg.nameof(father),GrampsCfg.nameof(mother)) elif father: - fname = "%s" % Config.nameof(father) + fname = "%s" % GrampsCfg.nameof(father) else: - fname = "%s" % Config.nameof(mother) + fname = "%s" % GrampsCfg.nameof(mother) msg = t % (fname,e[0].getId(),e[1].getName()) self.refinfo.insert_defaults(msg) @@ -412,7 +412,7 @@ class DeletePlaceQuery: if ans == 1: return del self.db.getPlaceMap()[self.place.getId()] - utils.modified() + Utils.modified() for p in self.db.getPersonMap().values(): for event in [p.getBirth(), p.getDeath()] + p.getEventList(): diff --git a/src/EditSource.py b/src/EditSource.py index cafe5f824..56b0a38e0 100644 --- a/src/EditSource.py +++ b/src/EditSource.py @@ -32,8 +32,8 @@ import libglade # #------------------------------------------------------------------------- import const -import utils -import Config +import Utils +import GrampsCfg from RelLib import * import ImageSelect @@ -74,7 +74,7 @@ class EditSource: self.note.set_word_wrap(1) self.top_window.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_photolist_select_icon" : self.gallery.on_photo_select_icon, "on_photolist_button_press_event" : self.gallery.on_button_press_event, "on_switch_page" : self.on_switch_page, @@ -109,7 +109,7 @@ class EditSource: if sref.getBase() == self.source: p_list.append(name) for p in self.db.getPersonMap().values(): - name = Config.nameof(p) + name = GrampsCfg.nameof(p) for v in p.getEventList() + [p.getBirth(), p.getDeath()]: for sref in v.getSourceRefList(): if sref.getBase() == self.source: @@ -136,12 +136,12 @@ class EditSource: m = p.getMother() if f and m: name = _("%(father)s and %(mother)s") % { - "father" : Config.nameof(f), - "mother" : Config.nameof(m)} + "father" : GrampsCfg.nameof(f), + "mother" : GrampsCfg.nameof(m)} elif f: - name = Config.nameof(f) + name = GrampsCfg.nameof(f) else: - name = Config.nameof(m) + name = GrampsCfg.nameof(m) for v in p.getEventList(): for sref in v.getSourceRefList(): if sref.getBase() == self.source: @@ -197,21 +197,21 @@ class EditSource: if author != self.source.getAuthor(): self.source.setAuthor(author) - utils.modified() + Utils.modified() if title != self.source.getTitle(): self.source.setTitle(title) - utils.modified() + Utils.modified() if pubinfo != self.source.getPubInfo(): self.source.setPubInfo(pubinfo) - utils.modified() + Utils.modified() if note != self.source.getNote(): self.source.setNote(note) - utils.modified() + Utils.modified() - utils.destroy_passed_object(self.top) + Utils.destroy_passed_object(self.top) if self.callback: self.callback(self.source) @@ -245,7 +245,7 @@ class DelSrcQuery: if ans == 1: return del self.db.getSourceMap()[self.source.getId()] - utils.modified() + Utils.modified() for p in self.db.getPersonMap().values(): for v in p.getEventList() + [p.getBirth(), p.getDeath()]: diff --git a/src/EventEdit.py b/src/EventEdit.py index d98a3724f..de05f3398 100644 --- a/src/EventEdit.py +++ b/src/EventEdit.py @@ -35,8 +35,8 @@ import gtk #------------------------------------------------------------------------- import Sources import const -import utils -import Config +import Utils +import GrampsCfg import AutoComp from Date import compare_dates @@ -82,7 +82,7 @@ class EventEditor: self.priv = self.top.get_widget("priv") self.calendar = self.top.get_widget("calendar") - if Config.calendar: + if GrampsCfg.calendar: self.calendar.show() else: self.calendar.hide() @@ -126,7 +126,7 @@ class EventEditor: self.window.set_data("o",self) self.top.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_event_edit_ok_clicked" : self.on_event_edit_ok_clicked, "on_source_clicked" : self.on_edit_source_clicked }) @@ -160,7 +160,7 @@ class EventEditor: self.pmap[text] = place self.parent.db.addPlace(place) self.plist.append(place) - utils.modified() + Utils.modified() return place else: return None @@ -188,7 +188,7 @@ class EventEditor: self.update_event(ename,self.date,eplace_obj,edesc,enote,epriv,ecause) self.parent.redraw_event_list() self.callback(None,self.plist) - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def update_event(self,name,date,place,desc,note,priv,cause): if self.event.getPlace() != place: diff --git a/src/Find.py b/src/Find.py index 3ef23990a..75c8b7a82 100644 --- a/src/Find.py +++ b/src/Find.py @@ -24,9 +24,9 @@ __author__ = 'Don Allingham' import libglade -import Config +import GrampsCfg import const -import utils +import Utils import string import gtk import AutoComp @@ -45,7 +45,7 @@ class Find: self.task = task self.xml = libglade.GladeXML(const.findFile,"find") self.xml.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_next_clicked" : self.on_next_clicked, "on_prev_clicked" : self.on_prev_clicked, }) @@ -57,7 +57,7 @@ class Find: for n in plist: self.nlist.append(n.getPrimaryName().getName()) - if Config.autocomp: + if GrampsCfg.autocomp: self.comp = AutoComp.AutoEntry(self.entry,self.nlist) self.next = self.xml.get_widget("next") diff --git a/src/Config.py b/src/GrampsCfg.py similarity index 98% rename from src/Config.py rename to src/GrampsCfg.py index 76ddc656f..a4563283a 100644 --- a/src/Config.py +++ b/src/GrampsCfg.py @@ -50,7 +50,7 @@ from RelLib import * from Date import * import const -import utils +import Utils import ListColors from intl import gettext @@ -86,8 +86,8 @@ _date_entry_list = [ ] _name_format_list = [ - (_("Firstname Surname"), utils.normal_name), - (_("Surname, Firstname"), utils.phonebook_name), + (_("Firstname Surname"), Utils.normal_name), + (_("Surname, Firstname"), Utils.phonebook_name), ] panellist = [ @@ -131,7 +131,7 @@ uncompress = 0 show_detail = 0 hide_altnames = 0 lastfile = None -nameof = utils.normal_name +nameof = Utils.normal_name display_attr = 0 attr_name = "" status_bar = 0 @@ -377,9 +377,9 @@ def loadConfig(call): if _name_format == None or _name_format == 0: _name_format = 0 - nameof = utils.normal_name + nameof = Utils.normal_name else: - nameof = utils.phonebook_name + nameof = Utils.phonebook_name make_path(os.path.expanduser("~/.gramps")) make_path(os.path.expanduser("~/.gramps/filters")) @@ -870,11 +870,11 @@ class GrampsPreferences: gnome.help.display('gramps-manual','prefs.html') def on_close_clicked(self,obj): - utils.destroy_passed_object(self.window) + Utils.destroy_passed_object(self.window) def on_ok_clicked(self,obj): self.on_propertybox_apply(obj) - utils.destroy_passed_object(self.window) + Utils.destroy_passed_object(self.window) def on_propertybox_apply(self,obj): global nameof @@ -1006,9 +1006,9 @@ class GrampsPreferences: set_int("/gramps/config/autoSaveInterval",autosave_int) if autosave_int != 0: - utils.enable_autosave(None,autosave_int) + Utils.enable_autosave(None,autosave_int) else: - utils.disable_autosave() + Utils.disable_autosave() set_bool("/gramps/config/DisplayAltNames",hide_altnames) set_string("/gramps/config/ReportDirectory",report_dir) diff --git a/src/GrampsParser.py b/src/GrampsParser.py index b7c838b1a..6d748f71a 100644 --- a/src/GrampsParser.py +++ b/src/GrampsParser.py @@ -22,7 +22,7 @@ from RelLib import * from Date import SingleDate import string -import utils +import Utils import xml.parsers.expat #------------------------------------------------------------------------- @@ -405,7 +405,7 @@ class GrampsParser: a.setType(key) a.setValue(u2l(attrs[key])) self.photo.addAttribute(a) - self.photo.setMimeType(utils.get_mime_type(self.photo.getPath())) + self.photo.setMimeType(Utils.get_mime_type(self.photo.getPath())) self.db.addObject(self.photo) if self.family: self.family.addPhoto(self.pref) diff --git a/src/ImageSelect.py b/src/ImageSelect.py index 49476de42..9be06fc23 100644 --- a/src/ImageSelect.py +++ b/src/ImageSelect.py @@ -44,8 +44,8 @@ import libglade # #------------------------------------------------------------------------- import const -import utils -import Config +import Utils +import GrampsCfg import Plugins from RelLib import * import RelImage @@ -103,7 +103,7 @@ class ImageSelect: self.glade.signal_autoconnect({ "on_savephoto_clicked" : self.on_savephoto_clicked, "on_name_changed" : self.on_name_changed, - "destroy_passed_object" : utils.destroy_passed_object + "destroy_passed_object" : Utils.destroy_passed_object }) window.editable_enters(self.description) @@ -127,12 +127,12 @@ class ImageSelect: self.temp_name = root if os.path.isfile(filename): - type = utils.get_mime_type(filename) + type = Utils.get_mime_type(filename) if type[0:5] == "image": image = RelImage.scale_image(filename,const.thumbScale) self.image.load_imlib(image) else: - self.image.load_file(utils.find_icon(type)) + self.image.load_file(Utils.find_icon(type)) #------------------------------------------------------------------------- # @@ -159,7 +159,7 @@ class ImageSelect: self.dataobj.addPhoto(oref) self.add_thumbnail(oref) else: - type = utils.get_mime_type(filename) + type = Utils.get_mime_type(filename) mobj = Photo() if description == "": description = os.path.basename(filename) @@ -179,8 +179,8 @@ class ImageSelect: mobj.setLocal(1) mobj.setPath(name) - utils.modified() - utils.destroy_passed_object(obj) + Utils.modified() + Utils.destroy_passed_object(obj) self.load_images() #------------------------------------------------------------------------- @@ -249,7 +249,7 @@ class Gallery(ImageSelect): #------------------------------------------------------------------------- def add_thumbnail(self, photo): object = photo.getReference() - name = utils.thumb_path(self.db.getSavePath(),object) + name = Utils.thumb_path(self.db.getSavePath(),object) try: thumb = GdkImlib.Image(name) except IOError,msg: @@ -292,7 +292,7 @@ class Gallery(ImageSelect): protocol,site,file, j,k,l = urlparse.urlparse(d) if protocol == "file": name = file - mime = utils.get_mime_type(name) + mime = Utils.get_mime_type(name) photo = Photo() photo.setPath(name) photo.setMimeType(mime) @@ -300,12 +300,12 @@ class Gallery(ImageSelect): (root,ext) = os.path.splitext(basename) photo.setDescription(root) self.savephoto(photo) - if Config.mediaref == 0: + if GrampsCfg.mediaref == 0: name = RelImage.import_media_object(name,self.path,photo.getId()) photo.setPath(name) photo.setLocal(1) - utils.modified() - if Config.globalprop: + Utils.modified() + if GrampsCfg.globalprop: GlobalMediaProperties(self.db,photo,None) elif protocol != "": import urllib @@ -317,7 +317,7 @@ class Gallery(ImageSelect): gnome.ui.GnomeErrorDialog("%s\n%s %d" % (t,msg[0],msg[1])) return - mime = utils.get_mime_type(tfile) + mime = Utils.get_mime_type(tfile) photo = Photo() photo.setMimeType(mime) photo.setDescription(d) @@ -337,8 +337,8 @@ class Gallery(ImageSelect): w.drag_finish(context, 1, 0, time) return self.add_thumbnail(oref) - utils.modified() - if Config.globalprop: + Utils.modified() + if GrampsCfg.globalprop: GlobalMediaProperties(self.db,photo,None) else: if self.db.getObjectMap().has_key(data.data): @@ -359,7 +359,7 @@ class Gallery(ImageSelect): del nl[index] nl = nl[0:icon_index] + [item] + nl[icon_index:] self.dataobj.setPhotoList(nl) - utils.modified() + Utils.modified() self.load_images() return index = index + 1 @@ -367,9 +367,9 @@ class Gallery(ImageSelect): oref.setReference(self.db.findObjectNoMap(data.data)) self.dataobj.addPhoto(oref) self.add_thumbnail(oref) - if Config.globalprop: + if GrampsCfg.globalprop: LocalMediaProperties(oref,self.path) - utils.modified() + Utils.modified() w.drag_finish(context, 1, 0, time) else: w.drag_finish(context, 0, 0, time) @@ -426,15 +426,15 @@ class Gallery(ImageSelect): item = gtk.GtkTearoffMenuItem() item.show() menu.append(item) - utils.add_menuitem(menu,_("View in the default viewer"),None,self.popup_view_photo) + Utils.add_menuitem(menu,_("View in the default viewer"),None,self.popup_view_photo) object = photo.getReference() if object.getMimeType()[0:5] == "image": - utils.add_menuitem(menu,_("Edit with the GIMP"),\ + Utils.add_menuitem(menu,_("Edit with the GIMP"),\ None,self.popup_edit_photo) - utils.add_menuitem(menu,_("Edit Object Properties"),None, + Utils.add_menuitem(menu,_("Edit Object Properties"),None, self.popup_change_description) if object.getLocal() == 0: - utils.add_menuitem(menu,_("Convert to local copy"),None, + Utils.add_menuitem(menu,_("Convert to local copy"),None, self.popup_convert_to_private) menu.popup(None,None,None,0,0) @@ -445,7 +445,7 @@ class Gallery(ImageSelect): #------------------------------------------------------------------------- def popup_view_photo(self, obj): photo = self.dataobj.getPhotoList()[self.selectedIcon] - utils.view_photo(photo.getReference()) + Utils.view_photo(photo.getReference()) #------------------------------------------------------------------------- # @@ -505,7 +505,7 @@ class LocalMediaProperties: descr_window.set_text(self.object.getDescription()) mtype = self.object.getMimeType() - pixmap.load_file(utils.thumb_path(path,self.object)) + pixmap.load_file(Utils.thumb_path(path,self.object)) self.change_dialog.get_widget("private").set_active(photo.getPrivacy()) self.change_dialog.get_widget("gid").set_text(self.object.getId()) @@ -514,10 +514,10 @@ class LocalMediaProperties: self.change_dialog.get_widget("path").set_text("") else: self.change_dialog.get_widget("path").set_text(fname) - self.change_dialog.get_widget("type").set_text(utils.get_mime_description(mtype)) + self.change_dialog.get_widget("type").set_text(Utils.get_mime_description(mtype)) self.change_dialog.get_widget("notes").insert_defaults(photo.getNote()) self.change_dialog.signal_autoconnect({ - "on_cancel_clicked" : utils.destroy_passed_object, + "on_cancel_clicked" : Utils.destroy_passed_object, "on_up_clicked" : self.on_up_clicked, "on_down_clicked" : self.on_down_clicked, "on_ok_clicked" : self.on_ok_clicked, @@ -544,7 +544,7 @@ class LocalMediaProperties: obj.select_row(row+1,0) def redraw_attr_list(self): - utils.redraw_list(self.alist,self.attr_list,disp_attr) + Utils.redraw_list(self.alist,self.attr_list,disp_attr) def on_apply_clicked(self, obj): priv = self.change_dialog.get_widget("private").get_active() @@ -553,21 +553,21 @@ class LocalMediaProperties: if text != note or priv != self.photo.getPrivacy(): self.photo.setNote(text) self.photo.setPrivacy(priv) - utils.modified() + Utils.modified() if self.lists_changed: self.photo.setAttributeList(self.alist) - utils.modified() + Utils.modified() def on_ok_clicked(self, obj): self.on_apply_clicked(obj) - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def on_attr_list_select_row(self,obj,row,b,c): attr = obj.get_row_data(row) self.attr_type.set_label(attr.getType()) self.attr_value.set_text(attr.getValue()) - self.attr_details.set_text(utils.get_detail_text(attr)) + self.attr_details.set_text(Utils.get_detail_text(attr)) def on_update_attr_clicked(self,obj): import AttrEdit @@ -578,7 +578,7 @@ class LocalMediaProperties: Plugins.get_image_attributes()) def on_delete_attr_clicked(self,obj): - if utils.delete_selected(obj,self.alist): + if Utils.delete_selected(obj,self.alist): self.lists_changed = 1 self.redraw_attr_list() @@ -614,17 +614,17 @@ class GlobalMediaProperties: self.descr_window.set_text(self.object.getDescription()) mtype = self.object.getMimeType() - pixmap.load_file(utils.thumb_path(self.path,self.object)) + pixmap.load_file(Utils.thumb_path(self.path,self.object)) self.change_dialog.get_widget("gid").set_text(self.object.getId()) self.makelocal = self.change_dialog.get_widget("makelocal") self.update_info() - self.change_dialog.get_widget("type").set_text(utils.get_mime_description(mtype)) + self.change_dialog.get_widget("type").set_text(Utils.get_mime_description(mtype)) self.notes.insert_defaults(object.getNote()) self.change_dialog.signal_autoconnect({ - "on_cancel_clicked" : utils.destroy_passed_object, + "on_cancel_clicked" : Utils.destroy_passed_object, "on_up_clicked" : self.on_up_clicked, "on_down_clicked" : self.on_down_clicked, "on_ok_clicked" : self.on_ok_clicked, @@ -672,7 +672,7 @@ class GlobalMediaProperties: self.update() def redraw_attr_list(self): - utils.redraw_list(self.alist,self.attr_list,disp_attr) + Utils.redraw_list(self.alist,self.attr_list,disp_attr) def button_press(self,obj,event): if len(obj.selection) <= 0: @@ -692,13 +692,13 @@ class GlobalMediaProperties: for p in self.db.getPersonMap().values(): for o in p.getPhotoList(): if o.getReference() == self.object: - ref.append([_("Person"),p.getId(),Config.nameof(p)]) + ref.append([_("Person"),p.getId(),GrampsCfg.nameof(p)]) ref.set_row_data(index,(EditPerson.EditPerson,p,self.db)) index = index + 1 for p in self.db.getFamilyMap().values(): for o in p.getPhotoList(): if o.getReference() == self.object: - ref.append([_("Family"),p.getId(),utils.family_name(p)]) + ref.append([_("Family"),p.getId(),Utils.family_name(p)]) ref.set_row_data(index,(Marriage.Marriage,p,self.db)) index = index + 1 for p in self.db.getSourceMap().values(): @@ -725,23 +725,23 @@ class GlobalMediaProperties: if text != note or desc != self.object.getDescription(): self.object.setNote(text) self.object.setDescription(desc) - utils.modified() + Utils.modified() if self.lists_changed: self.object.setAttributeList(self.alist) - utils.modified() + Utils.modified() if self.update != None: self.update() def on_ok_clicked(self, obj): self.on_apply_clicked(obj) - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def on_attr_list_select_row(self,obj,row,b,c): attr = obj.get_row_data(row) self.attr_type.set_label(attr.getType()) self.attr_value.set_text(attr.getValue()) - self.attr_details.set_text(utils.get_detail_text(attr)) + self.attr_details.set_text(Utils.get_detail_text(attr)) def on_update_attr_clicked(self,obj): import AttrEdit @@ -752,7 +752,7 @@ class GlobalMediaProperties: Plugins.get_image_attributes()) def on_delete_attr_clicked(self,obj): - if utils.delete_selected(obj,self.alist): + if Utils.delete_selected(obj,self.alist): self.lists_changed = 1 self.redraw_attr_list() @@ -767,7 +767,7 @@ class GlobalMediaProperties: # #------------------------------------------------------------------------- def disp_attr(attr): - detail = utils.get_detail_flags(attr) + detail = Utils.get_detail_flags(attr) return [const.display_pattr(attr.getType()),attr.getValue(),detail] @@ -782,7 +782,7 @@ class DeleteMediaQuery: if ans == 1: return del self.db.getObjectMap()[self.media.getId()] - utils.modified() + Utils.modified() for p in self.db.getPersonMap().values(): nl = [] diff --git a/src/LocEdit.py b/src/LocEdit.py index ea6843fe7..0131e9f30 100644 --- a/src/LocEdit.py +++ b/src/LocEdit.py @@ -31,7 +31,7 @@ import libglade # #------------------------------------------------------------------------- import const -import utils +import Utils from RelLib import * from intl import gettext @@ -78,7 +78,7 @@ class LocationEditor: self.window.set_data("o",self) self.top.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_loc_edit_ok_clicked" : self.on_location_edit_ok_clicked }) @@ -98,7 +98,7 @@ class LocationEditor: self.update_location(city,parish,county,state,country) self.parent.redraw_location_list() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def update_location(self,city,parish,county,state,country): if self.location.get_city() != city: diff --git a/src/Marriage.py b/src/Marriage.py index d8072d0d2..2d1d44d4a 100644 --- a/src/Marriage.py +++ b/src/Marriage.py @@ -37,8 +37,8 @@ import libglade #------------------------------------------------------------------------- import const -import Config -import utils +import GrampsCfg +import Utils import AutoComp from RelLib import * import ImageSelect @@ -81,7 +81,7 @@ class Marriage: "on_add_attr_clicked" : self.on_add_attr_clicked, "on_addphoto_clicked" : self.gallery.on_add_photo_clicked, "on_attr_list_select_row" : self.on_attr_list_select_row, - "on_combo_insert_text" : utils.combo_insert_text, + "on_combo_insert_text" : Utils.combo_insert_text, "on_close_marriage_editor" : self.on_close_marriage_editor, "on_delete_attr_clicked" : self.on_delete_attr_clicked, "on_delete_event" : self.on_delete_event, @@ -99,8 +99,8 @@ class Marriage: }) text_win = self.get_widget("marriageTitle") - title = _("%s and %s") % (Config.nameof(family.getFather()), - Config.nameof(family.getMother())) + title = _("%s and %s") % (GrampsCfg.nameof(family.getFather()), + GrampsCfg.nameof(family.getMother())) text_win.set_text(title) self.event_list = self.get_widget("marriageEventList") @@ -124,8 +124,8 @@ class Marriage: self.lds_status = self.get_widget("lds_status") self.lds_place = self.get_widget("lds_place") - self.event_list.set_column_visibility(3,Config.show_detail) - self.attr_list.set_column_visibility(2,Config.show_detail) + self.event_list.set_column_visibility(3,GrampsCfg.show_detail) + self.attr_list.set_column_visibility(2,GrampsCfg.show_detail) self.elist = family.getEventList()[:] self.alist = family.getAttributeList()[:] @@ -139,7 +139,7 @@ class Marriage: frel = const.display_frel(family.getRelationship()) self.type_field.entry.set_text(frel) self.gid.set_text(family.getId()) - self.gid.set_editable(Config.id_edit) + self.gid.set_editable(GrampsCfg.id_edit) self.lds_temple.set_popdown_strings(_temple_names) @@ -291,10 +291,10 @@ class Marriage: self.family.setAttributeList(self.alist) def redraw_attr_list(self): - utils.redraw_list(self.alist,self.attr_list,disp_attr) + Utils.redraw_list(self.alist,self.attr_list,disp_attr) def redraw_event_list(self): - utils.redraw_list(self.elist,self.event_list,disp_event) + Utils.redraw_list(self.elist,self.event_list,disp_event) def get_widget(self,name): return self.top.get_widget(name) @@ -323,7 +323,7 @@ class Marriage: else: temple = "" - place = utils.get_place_from_list(self.lds_place) + place = Utils.get_place_from_list(self.lds_place) ord = self.family.getLdsSeal() if not ord: @@ -348,7 +348,7 @@ class Marriage: quit = obj GnomeQuestionDialog(q,cancel_callback) else: - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def on_delete_event(self,obj,b): self.on_cancel_edit(obj) @@ -363,7 +363,7 @@ class Marriage: del m[family.getId()] m[idval] = family family.setId(idval) - utils.modified() + Utils.modified() else: msg1 = _("GRAMPS ID value was not changed.") GnomeWarningDialog("%s" % msg1) @@ -383,12 +383,12 @@ class Marriage: self.family.setFather(mother) self.family.setMother(father) self.family.setRelationship(val) - utils.modified() + Utils.modified() text = self.notes_field.get_chars(0,-1) if text != self.family.getNote(): self.family.setNote(text) - utils.modified() + Utils.modified() date = self.lds_date.get_text() temple = self.lds_temple.entry.get_text() @@ -396,7 +396,7 @@ class Marriage: temple = const.lds_temple_codes[temple] else: temple = "" - place = utils.get_place_from_list(self.lds_place) + place = Utils.get_place_from_list(self.lds_place) ord = self.family.getLdsSeal() if not ord: @@ -407,32 +407,32 @@ class Marriage: ord.setStatus(self.seal_stat) ord.setPlace(place) self.family.setLdsSeal(ord) - utils.modified() + Utils.modified() else: d = Date() d.set(date) if compare_dates(d,ord.getDateObj()) != 0: ord.setDateObj(d) - utils.modified() + Utils.modified() if ord.getTemple() != temple: ord.setTemple(temple) - utils.modified() + Utils.modified() if ord.getStatus() != self.seal_stat: ord.setStatus(self.seal_stat) - utils.modified() + Utils.modified() if ord.getPlace() != place: ord.setPlace(place) - utils.modified() + Utils.modified() - utils.destroy_passed_object(self.get_widget("marriageEditor")) + Utils.destroy_passed_object(self.get_widget("marriageEditor")) self.update_lists() if self.lists_changed: - utils.modified() + Utils.modified() def on_add_clicked(self,obj): import EventEdit - name = utils.family_name(self.family) + name = Utils.family_name(self.family) EventEdit.EventEditor(self,name,const.marriageEvents, const.save_pevent,None,None,0,self.cb) @@ -442,12 +442,12 @@ class Marriage: return event = obj.get_row_data(obj.selection[0]) - name = utils.family_name(self.family) + name = Utils.family_name(self.family) EventEdit.EventEditor(self,name,const.marriageEvents, const.save_pevent,event,None,0,self.cb) def on_delete_clicked(self,obj): - if utils.delete_selected(obj,self.elist): + if Utils.delete_selected(obj,self.elist): self.lists_changed = 1 self.redraw_event_list() @@ -458,7 +458,7 @@ class Marriage: self.place_field.set_text(event.getPlaceName()) self.cause_field.set_text(event.getCause()) self.name_field.set_label(const.display_fevent(event.getName())) - self.event_details.set_text(utils.get_detail_text(event)) + self.event_details.set_text(Utils.get_detail_text(event)) self.descr_field.set_text(event.getDescription()) def on_attr_list_select_row(self,obj,row,b,c): @@ -466,7 +466,7 @@ class Marriage: self.attr_type.set_label(const.display_fattr(attr.getType())) self.attr_value.set_text(attr.getValue()) - self.attr_details_field.set_text(utils.get_detail_text(attr)) + self.attr_details_field.set_text(Utils.get_detail_text(attr)) def on_update_attr_clicked(self,obj): import AttrEdit @@ -485,7 +485,7 @@ class Marriage: AttrEdit.AttributeEditor(self,attr,name,const.familyAttributes) def on_delete_attr_clicked(self,obj): - if utils.delete_selected(obj,self.alist): + if Utils.delete_selected(obj,self.alist): self.lists_changed = 1 self.redraw_attr_list() @@ -509,7 +509,7 @@ class Marriage: # #------------------------------------------------------------------------- def disp_attr(attr): - detail = utils.get_detail_flags(attr) + detail = Utils.get_detail_flags(attr) return [const.display_fattr(attr.getType()),attr.getValue(),detail] #------------------------------------------------------------------------- @@ -519,7 +519,7 @@ def disp_attr(attr): #------------------------------------------------------------------------- def disp_event(event): return [const.display_fevent(event.getName()), event.getQuoteDate(), - event.getPlaceName(), utils.get_detail_flags(event)] + event.getPlaceName(), Utils.get_detail_flags(event)] #------------------------------------------------------------------------- # @@ -528,7 +528,7 @@ def disp_event(event): #------------------------------------------------------------------------- def cancel_callback(a): if a==0: - utils.destroy_passed_object(quit) + Utils.destroy_passed_object(quit) def src_changed(parent): parent.lists_changed = 1 diff --git a/src/MediaView.py b/src/MediaView.py index 107f60861..232475502 100644 --- a/src/MediaView.py +++ b/src/MediaView.py @@ -26,9 +26,9 @@ import string import ImageSelect from RelLib import * -import utils +import Utils import os -import Config +import GrampsCfg import const import RelImage @@ -72,13 +72,13 @@ class MediaView: GDK.ACTION_COPY|GDK.ACTION_MOVE) self.update = update - self.media_list.set_column_visibility(4,Config.show_detail) + self.media_list.set_column_visibility(4,GrampsCfg.show_detail) self.media_list.set_column_visibility(5,0) self.media_list.connect('button-press-event',self.on_button_press_event) # Restore the previous sort column - self.sort_col,self.sort_dir = Config.get_sort_cols("media",0,GTK.SORT_ASCENDING) + self.sort_col,self.sort_dir = GrampsCfg.get_sort_cols("media",0,GTK.SORT_ASCENDING) self.media_list.set_sort_type(self.sort_dir) self.media_list.set_sort_column(self.sort_map[self.sort_col]) self.set_arrow(self.sort_col) @@ -118,7 +118,7 @@ class MediaView: obj.set_sort_type(self.sort_dir) obj.set_sort_column(new_col) self.sort_col = column - Config.save_sort_cols("media",self.sort_col,self.sort_dir) + GrampsCfg.save_sort_cols("media",self.sort_col,self.sort_dir) obj.sort() if data: row = obj.find_row_from_data(data) @@ -130,14 +130,14 @@ class MediaView: mobj = obj.get_row_data(row) type = mobj.getMimeType() - type_name = utils.get_mime_description(type) + type_name = Utils.get_mime_description(type) path = mobj.getPath() - thumb_path = utils.thumb_path(self.db.getSavePath(),mobj) + thumb_path = Utils.thumb_path(self.db.getSavePath(),mobj) pexists = os.path.exists(path) if pexists and os.path.exists(thumb_path): self.preview.load_file(thumb_path) else: - self.preview.load_file(utils.find_icon(type)) + self.preview.load_file(Utils.find_icon(type)) if not pexists: fexists = 0 @@ -150,7 +150,7 @@ class MediaView: self.mpath.set_text(path) else: self.mpath.set_text("") - self.mdetails.set_text(utils.get_detail_text(mobj,0)) + self.mdetails.set_text(Utils.get_detail_text(mobj,0)) def on_button_press_event(self,obj,event): if len(self.media_list.selection) <= 0: @@ -164,19 +164,19 @@ class MediaView: item.show() menu.append(item) self.obj = object - utils.add_menuitem(menu,_("View in the default viewer"),None,self.popup_view_photo) + Utils.add_menuitem(menu,_("View in the default viewer"),None,self.popup_view_photo) if object.getMimeType()[0:5] == "image": - utils.add_menuitem(menu,_("Edit with the GIMP"),\ + Utils.add_menuitem(menu,_("Edit with the GIMP"),\ None,self.popup_edit_photo) - utils.add_menuitem(menu,_("Edit Object Properties"),None, + Utils.add_menuitem(menu,_("Edit Object Properties"),None, self.popup_change_description) if object.getLocal() == 0: - utils.add_menuitem(menu,_("Convert to local copy"),None, + Utils.add_menuitem(menu,_("Convert to local copy"),None, self.popup_convert_to_private) menu.popup(None,None,None,0,0) def popup_view_photo(self, obj): - utils.view_photo(self.obj) + Utils.view_photo(self.obj) def popup_edit_photo(self, obj): if os.fork() == 0: @@ -202,8 +202,8 @@ class MediaView: self.media_list.freeze() self.media_list.clear() - self.media_list.set_column_visibility(1,Config.id_visible) - self.media_list.set_column_visibility(4,Config.show_detail) + self.media_list.set_column_visibility(1,GrampsCfg.id_visible) + self.media_list.set_column_visibility(4,GrampsCfg.show_detail) index = 0 objects = self.db.getObjectMap().values() @@ -211,12 +211,12 @@ class MediaView: for src in objects: title = src.getDescription() id = src.getId() - type = utils.get_mime_description(src.getMimeType()) + type = Utils.get_mime_description(src.getMimeType()) if src.getLocal(): path = "" else: path = src.getPath() - details = utils.get_detail_flags(src,0) + details = Utils.get_detail_flags(src,0) stitle = string.upper(title) self.media_list.append([title,id,type,path,details,stitle]) self.media_list.set_row_data(index,src) @@ -267,7 +267,7 @@ class MediaView: else: map = self.db.getObjectMap() del map[mobj.getId()] - utils.modified() + Utils.modified() self.update(0) def is_media_object_used(self,mobj): @@ -302,25 +302,25 @@ class MediaView: protocol,site,file, j,k,l = urlparse.urlparse(d) if protocol == "file": name = file - mime = utils.get_mime_type(name) + mime = Utils.get_mime_type(name) photo = Photo() photo.setPath(name) photo.setMimeType(mime) description = os.path.basename(name) photo.setDescription(description) self.db.addObject(photo) - utils.modified() + Utils.modified() w.drag_finish(context, 1, 0, time) self.load_media() - if Config.mediaref == 0: + if GrampsCfg.mediaref == 0: name = RelImage.import_media_object(name, self.db.getSavePath(), photo.getId()) if name: photo.setPath(name) photo.setLocal(1) - utils.modified() - if Config.globalprop: + Utils.modified() + if GrampsCfg.globalprop: ImageSelect.GlobalMediaProperties(self.db,photo,self.load_media) elif protocol != "": import urllib @@ -332,7 +332,7 @@ class MediaView: gnome.ui.GnomeErrorDialog("%s\n%s %d" % (t,msg[0],msg[1])) return - mime = utils.get_mime_type(tfile) + mime = Utils.get_mime_type(tfile) photo = Photo() photo.setMimeType(mime) photo.setDescription(d) @@ -352,8 +352,8 @@ class MediaView: photo.setPath(tfile) w.drag_finish(context, 1, 0, time) return - utils.modified() - if Config.globalprop: + Utils.modified() + if GrampsCfg.globalprop: ImageSelect.GlobalMediaProperties(self.db,photo,None) else: w.drag_finish(context, 0, 0, time) diff --git a/src/MergeData.py b/src/MergeData.py index 27aed3499..5f89f5485 100644 --- a/src/MergeData.py +++ b/src/MergeData.py @@ -19,8 +19,8 @@ # import RelLib -import utils -import Config +import Utils +import GrampsCfg import const from intl import gettext @@ -53,21 +53,21 @@ class MergePeople: self.glade.signal_autoconnect({ "on_merge_clicked" : self.on_merge_clicked, "on_next_clicked" : self.on_merge_edit_clicked, - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, }) - label_text = "Merge %s and %s" % (Config.nameof(person1),Config.nameof(person2)) + label_text = "Merge %s and %s" % (GrampsCfg.nameof(person1),GrampsCfg.nameof(person2)) self.glade.get_widget("progress").set_text(label_text) f1 = person1.getMainFamily() f2 = person2.getMainFamily() - name1 = Config.nameof(person1) + name1 = GrampsCfg.nameof(person1) death1 = person1.getDeath().getDate() dplace1 = self.place_name(person1.getDeath()) birth1 = person1.getBirth().getDate() bplace1 = self.place_name(person1.getBirth()) - name2 = Config.nameof(person2) + name2 = GrampsCfg.nameof(person2) death2 = person2.getDeath().getDate() dplace2 = self.place_name(person2.getDeath()) birth2 = person2.getBirth().getDate() @@ -157,7 +157,7 @@ class MergePeople: if spouse == None: name = "unknown" else: - name = "%s (%s)" % (Config.nameof(spouse),spouse.getId()) + name = "%s (%s)" % (GrampsCfg.nameof(spouse),spouse.getId()) self.glade.get_widget("spouse1").append([name]) length = min(len(p2list),3) @@ -172,7 +172,7 @@ class MergePeople: if spouse == None: name = "unknown" else: - name = "%s (%s)" % (Config.nameof(spouse),spouse.getId()) + name = "%s (%s)" % (GrampsCfg.nameof(spouse),spouse.getId()) self.glade.get_widget("spouse2").append([name]) if name1 != name2: @@ -231,7 +231,7 @@ class MergePeople: # #--------------------------------------------------------------------- def on_merge_clicked(self,obj): - utils.modified() + Utils.modified() list = self.p1.getAlternateNames()[:] for xdata in self.p2.getAlternateNames(): @@ -345,9 +345,9 @@ class MergePeople: try: del self.db.getPersonMap()[self.p2.getId()] except: - print "%s is not in the person map!" % (Config.nameof(self.p2)) + print "%s is not in the person map!" % (GrampsCfg.nameof(self.p2)) self.update(self.p1,self.p2) - utils.destroy_passed_object(self.top) + Utils.destroy_passed_object(self.top) #--------------------------------------------------------------------- # @@ -579,8 +579,8 @@ def compare_people(p1,p2): if father1 == father2: chance = chance + 1 else: - fname1 = Config.nameof(father1) - fname2 = Config.nameof(father2) + fname1 = GrampsCfg.nameof(father1) + fname2 = GrampsCfg.nameof(father2) value = name_match(fname1,fname2) if value != -1: chance = chance + value @@ -591,8 +591,8 @@ def compare_people(p1,p2): if mother1 == mother2: chance = chance + 1 else: - mname1 = Config.nameof(mother1) - mname2 = Config.nameof(mother2) + mname1 = GrampsCfg.nameof(mother1) + mname2 = GrampsCfg.nameof(mother2) value = name_match(mname1,mname2) if value != -1: chance = chance + value @@ -786,7 +786,7 @@ def ancestors_of(p1,list): def name_of(p): if not p: return "" - return "%s (%s)" % ( Config.nameof(p),p.getId()) + return "%s (%s)" % ( GrampsCfg.nameof(p),p.getId()) #------------------------------------------------------------------------- # @@ -808,7 +808,7 @@ class MergePlaces: self.t3.set_text(place1.get_title()) self.glade.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_merge_places_clicked" : self.on_merge_places_clicked, }) self.top.show() @@ -860,6 +860,6 @@ class MergePlaces: event.setPlace(self.p1) del self.db.getPlaceMap()[self.p2.getId()] self.update() - utils.modified() - utils.destroy_passed_object(obj) + Utils.modified() + Utils.destroy_passed_object(obj) diff --git a/src/NameEdit.py b/src/NameEdit.py index ecf50ab68..a24e2988f 100644 --- a/src/NameEdit.py +++ b/src/NameEdit.py @@ -31,7 +31,7 @@ import libglade # #------------------------------------------------------------------------- import const -import utils +import Utils from RelLib import * from intl import gettext @@ -53,7 +53,7 @@ class NameEditor: self.surname_field = self.top.get_widget("alt_last") self.suffix_field = self.top.get_widget("alt_suffix") self.note_field = self.top.get_widget("alt_note") - utils.attach_surnames(self.top.get_widget("alt_surname_list")) + Utils.attach_surnames(self.top.get_widget("alt_surname_list")) self.priv = self.top.get_widget("priv") if self.name: @@ -81,8 +81,8 @@ class NameEditor: self.note_field.set_word_wrap(1) self.top.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, - "on_combo_insert_text" : utils.combo_insert_text, + "destroy_passed_object" : Utils.destroy_passed_object, + "on_combo_insert_text" : Utils.combo_insert_text, "on_name_edit_ok_clicked" : self.on_name_edit_ok_clicked, "on_source_clicked" : self.on_name_source_clicked }) @@ -107,7 +107,7 @@ class NameEditor: self.parent.lists_changed = 1 self.parent.redraw_name_list() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def update_name(self,first,last,suffix,note,priv): diff --git a/src/NoteEdit.py b/src/NoteEdit.py index 4bcd27468..a1aa1c90d 100644 --- a/src/NoteEdit.py +++ b/src/NoteEdit.py @@ -31,7 +31,7 @@ import libglade # #------------------------------------------------------------------------- import const -import utils +import Utils from RelLib import * #------------------------------------------------------------------------- @@ -55,12 +55,12 @@ class NoteEditor: self.editnote.signal_autoconnect({ "on_save_note_clicked" : self.on_save_note_clicked, - "destroy_passed_object" : utils.destroy_passed_object + "destroy_passed_object" : Utils.destroy_passed_object }) def on_save_note_clicked(self,obj): text = self.textobj.get_chars(0,-1) if text != self.data.getNote(): self.data.setNote(text) - utils.modified() - utils.destroy_passed_object(obj) + Utils.modified() + Utils.destroy_passed_object(obj) diff --git a/src/PaperMenu.py b/src/PaperMenu.py index 70158d9ee..36c17b48e 100644 --- a/src/PaperMenu.py +++ b/src/PaperMenu.py @@ -20,7 +20,7 @@ import TextDoc import gtk -import Config +import GrampsCfg from intl import gettext _ = gettext @@ -48,7 +48,7 @@ def make_paper_menu(main_menu): menuitem.set_data("i",paper) menuitem.show() myMenu.append(menuitem) - if name == Config.paper_preference: + if name == GrampsCfg.paper_preference: myMenu.set_active(index) index = index + 1 main_menu.set_menu(myMenu) diff --git a/src/PedView.py b/src/PedView.py index d163b59db..c0c536aaa 100644 --- a/src/PedView.py +++ b/src/PedView.py @@ -26,7 +26,7 @@ import GTK import GDK import gtk -import Config +import GrampsCfg from intl import gettext _ = gettext @@ -178,7 +178,7 @@ class PedigreeView: myMenu = gtk.GtkMenu() for family in self.active_person.getFamilyList(): for child in family.getChildList(): - menuitem = gtk.GtkMenuItem(Config.nameof(child)) + menuitem = gtk.GtkMenuItem(GrampsCfg.nameof(child)) myMenu.append(menuitem) menuitem.set_data(_PERSON,child) menuitem.connect("activate",self.on_childmenu_changed) @@ -358,7 +358,7 @@ class PedigreeView: elif event.type == GDK.ENTER_NOTIFY: obj.set(fill_color_gdk=style.bg[GTK.STATE_SELECTED], width_pixels=4) - name = Config.nameof(person) + name = GrampsCfg.nameof(person) msg = _("Double clicking will make %s the active person") % name self.sb.set_status(msg) elif event.type == GDK.LEAVE_NOTIFY: diff --git a/src/PlaceView.py b/src/PlaceView.py index ae131ba19..4b88376a7 100644 --- a/src/PlaceView.py +++ b/src/PlaceView.py @@ -45,8 +45,8 @@ import string #------------------------------------------------------------------------- from RelLib import * import EditPlace -import utils -import Config +import Utils +import GrampsCfg from intl import gettext _ = gettext @@ -86,7 +86,7 @@ class PlaceView: # Restore the previous sort column - self.sort_col,self.sort_dir = Config.get_sort_cols("place",0,GTK.SORT_ASCENDING) + self.sort_col,self.sort_dir = GrampsCfg.get_sort_cols("place",0,GTK.SORT_ASCENDING) self.set_arrow(self.sort_col) self.place_list.set_sort_column(self.sort_map[self.sort_col]) self.place_list.set_sort_type(self.sort_dir) @@ -104,7 +104,7 @@ class PlaceView: self.place_list.freeze() self.place_list.clear() - self.place_list.set_column_visibility(1,Config.id_visible) + self.place_list.set_column_visibility(1,GrampsCfg.id_visible) index = 0 u = string.upper @@ -184,7 +184,7 @@ class PlaceView: self.set_arrow(column) self.place_list.set_sort_type(self.sort_dir) self.place_list.set_sort_column(self.sort_map[self.sort_col]) - Config.save_sort_cols("place",self.sort_col,self.sort_dir) + GrampsCfg.save_sort_cols("place",self.sort_col,self.sort_dir) self.place_list.sort() if sel: @@ -253,7 +253,7 @@ class PlaceView: obj.remove(index) map = self.db.getPlaceMap() del map[place.getId()] - utils.modified() + Utils.modified() def on_edit_place_clicked(self,obj): """Display the selected places in the EditPlace display""" diff --git a/src/Plugins.py b/src/Plugins.py index 543e6b415..80aea7d44 100644 --- a/src/Plugins.py +++ b/src/Plugins.py @@ -50,8 +50,8 @@ from re import compile # #------------------------------------------------------------------------- import const -import utils -import Config +import Utils +import GrampsCfg from intl import gettext _ = gettext @@ -103,7 +103,7 @@ class ReportPlugins: self.dialog.signal_autoconnect({ "on_report_apply_clicked" : self.on_apply_clicked, "on_report_ok_clicked" : self.on_apply_clicked, - "destroy_passed_object" : utils.destroy_passed_object + "destroy_passed_object" : Utils.destroy_passed_object }) tree = self.dialog.get_widget("tree1") @@ -113,7 +113,7 @@ class ReportPlugins: def on_apply_clicked(self,obj): """Execute the selected report""" - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) if self.run_tool: self.run_tool(self.db,self.active) @@ -159,7 +159,7 @@ class ToolPlugins: self.dialog.signal_autoconnect({ "on_apply_clicked" : self.on_apply_clicked, "on_ok_clicked" : self.on_apply_clicked, - "destroy_passed_object" : utils.destroy_passed_object + "destroy_passed_object" : Utils.destroy_passed_object }) tree = self.dialog.get_widget("tree") @@ -169,7 +169,7 @@ class ToolPlugins: def on_apply_clicked(self,obj): """Execute the selected tool.""" - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) if self.run_tool: self.run_tool(self.db,self.active,self.update) @@ -487,7 +487,7 @@ def get_text_doc_menu(main_menu,tables,callback,obj=None): menuitem.connect("activate",callback) menuitem.show() myMenu.append(menuitem) - if name == Config.output_preference: + if name == GrampsCfg.output_preference: myMenu.set_active(index) callback(menuitem) index = index + 1 @@ -536,7 +536,7 @@ def get_draw_doc_menu(main_menu,callback=None,obj=None): menuitem.connect("activate",callback) menuitem.show() myMenu.append(menuitem) - if name == Config.goutput_preference: + if name == GrampsCfg.goutput_preference: myMenu.set_active(index) if callback: callback(menuitem) diff --git a/src/RelImage.py b/src/RelImage.py index dc4f25456..33f9f565c 100644 --- a/src/RelImage.py +++ b/src/RelImage.py @@ -40,7 +40,7 @@ from gnome.ui import GnomeErrorDialog, GnomeWarningDialog # #------------------------------------------------------------------------- import const -import utils +import Utils import ImgManip from intl import gettext _ = gettext @@ -58,7 +58,7 @@ def import_media_object(filename,path,base): GnomeErrorDialog(_("Could not import %s\nThe file has been moved or deleted") % filename) return "" - type = utils.get_mime_type(filename) + type = Utils.get_mime_type(filename) if type[0:5] == "image": name = "%s/%s.jpg" % (path,base) base = "%s.jpg" % (base) diff --git a/src/Report.py b/src/Report.py index 7382945b9..b4b6ebbea 100644 --- a/src/Report.py +++ b/src/Report.py @@ -26,7 +26,7 @@ import os import re import sort import string -import utils +import Utils import intl import Plugins @@ -35,7 +35,7 @@ _ = intl.gettext from TextDoc import * from StyleEditor import * -import Config +import GrampsCfg import PaperMenu from gtk import * @@ -127,7 +127,7 @@ class Report: def progress_bar_done(self): """Done with the progress bar. It can be destroyed now.""" - utils.destroy_passed_object(self.ptop) + Utils.destroy_passed_object(self.ptop) #------------------------------------------------------------------------ @@ -285,7 +285,7 @@ class ReportDialog: """Get the name of the directory to which the target dialog box should default. This value can be set in the preferences panel.""" - return Config.report_dir + return GrampsCfg.report_dir def set_default_directory(self, value): """Save the name of the current directory, so that any future @@ -295,7 +295,7 @@ class ReportDialog: This means that the last directory used will only be remembered for this session of gramps unless the user saves his/her preferences.""" - Config.report_dir = value + GrampsCfg.report_dir = value #------------------------------------------------------------------------ # @@ -360,7 +360,7 @@ class ReportDialog: frame, because it must be recreated to reflect any changes whenever the user closes the style editor dialog.""" style_sheet_map = self.style_sheet_list.get_style_sheet_map() - myMenu = utils.build_string_optmenu(style_sheet_map, "default") + myMenu = Utils.build_string_optmenu(style_sheet_map, "default") self.style_menu.set_menu(myMenu) #------------------------------------------------------------------------ @@ -566,7 +566,7 @@ class ReportDialog: # The optional pagecount stuff. if pagecount_map: self.pagecount_menu = GtkOptionMenu() - myMenu = utils.build_string_optmenu(pagecount_map, start_text) + myMenu = Utils.build_string_optmenu(pagecount_map, start_text) self.pagecount_menu.set_menu(myMenu) table.attach(GtkLabel(_("Page Count")),2,1,3,2,FILL,FILL,pad,pad) table.attach(self.pagecount_menu,3,2,4,2,xpadding=pad,ypadding=pad) @@ -654,7 +654,7 @@ class ReportDialog: self.extra_menu_label = GtkLabel(em_label) self.extra_menu_label.set_alignment(1.0,0.5) self.extra_menu = GtkOptionMenu() - myMenu = utils.build_string_optmenu(extra_map, preset) + myMenu = Utils.build_string_optmenu(extra_map, preset) self.extra_menu.set_menu(myMenu) self.extra_menu.set_sensitive(len(extra_map) > 1) self.add_tooltip(self.extra_menu,em_tip) diff --git a/src/SelectChild.py b/src/SelectChild.py index 4d7ece7b3..144bcca51 100644 --- a/src/SelectChild.py +++ b/src/SelectChild.py @@ -42,8 +42,8 @@ from RelLib import * import const import sort -import utils -import Config +import Utils +import GrampsCfg import string import AutoComp @@ -64,13 +64,13 @@ class SelectChild: self.xml.signal_autoconnect({ "on_save_child_clicked" : self.on_save_child_clicked, "on_show_toggled" : self.on_show_toggled, - "destroy_passed_object" : utils.destroy_passed_object + "destroy_passed_object" : Utils.destroy_passed_object }) self.select_child_list = {} self.top = self.xml.get_widget("selectChild") self.add_child = self.xml.get_widget("addChild") - self.add_child.set_column_visibility(1,Config.id_visible) + self.add_child.set_column_visibility(1,GrampsCfg.id_visible) if (self.family): father = self.family.getFather() @@ -161,8 +161,8 @@ class SelectChild: person_list.sort(sort.by_last_name) for person in person_list: - self.add_child.append([utils.phonebook_name(person), - utils.birthday(person), + self.add_child.append([Utils.phonebook_name(person), + Utils.birthday(person), person.getId()]) self.add_child.set_row_data(index,person) index = index + 1 @@ -202,9 +202,9 @@ class SelectChild: else: select_child.addAltFamily(self.family,mrel,frel) - utils.modified() + Utils.modified() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) self.redraw(self.family) def on_show_toggled(self,obj): @@ -225,7 +225,7 @@ class NewChild: "on_male_toggled" : self.on_male_toggled, "on_female_toggled" : self.on_female_toggled, "on_gender_toggled" : self.on_gender_toggled, - "destroy_passed_object" : utils.destroy_passed_object + "destroy_passed_object" : Utils.destroy_passed_object }) if autoname == 0: @@ -242,7 +242,7 @@ class NewChild: self.top = self.xml.get_widget("addChild") self.surname = self.xml.get_widget("surname") self.given = self.xml.get_widget("childGiven") - if Config.autocomp: + if GrampsCfg.autocomp: self.comp = AutoComp.AutoEntry(self.surname,const.surnames) self.surname.set_text(self.update_surname(2)) @@ -297,7 +297,7 @@ class NewChild: pass def combo_insert_text(self,combo,new_text,new_text_len,i_dont_care): - utils.combo_insert_text(combo,new_text,new_text_len,i_dont_care) + Utils.combo_insert_text(combo,new_text,new_text_len,i_dont_care) def north_american(self,val): if self.person.getGender() == Person.male: @@ -383,8 +383,8 @@ class NewChild: # must do an apply filter here to make sure the main window gets updated self.update(self.family,person,[]) - utils.modified() - utils.destroy_passed_object(obj) + Utils.modified() + Utils.destroy_passed_object(obj) self.new_child = person def other_update(self,arg1,plist): diff --git a/src/SourceView.py b/src/SourceView.py index dd38154d7..951eeb723 100644 --- a/src/SourceView.py +++ b/src/SourceView.py @@ -41,8 +41,8 @@ import gnome.ui #------------------------------------------------------------------------- from RelLib import * import EditSource -import utils -import Config +import Utils +import GrampsCfg #------------------------------------------------------------------------- # @@ -69,7 +69,7 @@ class SourceView: self.sort_arrow = [self.title_arrow, self.id_arrow, self.author_arrow] self.source_list.connect('click-column',self.click_column) - self.sort_col,self.sort_dir = Config.get_sort_cols("source",3,GTK.SORT_ASCENDING) + self.sort_col,self.sort_dir = GrampsCfg.get_sort_cols("source",3,GTK.SORT_ASCENDING) if self.sort_col >= len(self.sort_arrow): self.sort_col = 0 @@ -113,7 +113,7 @@ class SourceView: obj.set_sort_type(self.sort_dir) obj.set_sort_column(new_col) self.sort_col = new_col - Config.save_sort_cols("source",self.sort_col,self.sort_dir) + GrampsCfg.save_sort_cols("source",self.sort_col,self.sort_dir) obj.sort() if data: row = obj.find_row_from_data(data) @@ -129,7 +129,7 @@ class SourceView: self.source_list.clear() self.source_list.freeze() - self.source_list.set_column_visibility(1,Config.id_visible) + self.source_list.set_column_visibility(1,GrampsCfg.id_visible) index = 0 for src in self.db.getSourceMap().values(): @@ -174,7 +174,7 @@ class SourceView: else: map = self.db.getSourceMap() del map[source.getId()] - utils.modified() + Utils.modified() self.update(0) def is_source_used(self,source): diff --git a/src/Sources.py b/src/Sources.py index c4145856a..cc63b7ae0 100644 --- a/src/Sources.py +++ b/src/Sources.py @@ -33,7 +33,7 @@ import libglade #------------------------------------------------------------------------- import const -import utils +import Utils from RelLib import * #------------------------------------------------------------------------- @@ -56,7 +56,7 @@ class SourceSelector: self.update=update self.top = libglade.GladeXML(const.srcselFile,"sourcesel") self.top.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_add_src_clicked" : self.on_add_src_clicked, "on_del_src_clicked" : self.on_del_src_clicked, "on_edit_src_clicked" : self.on_edit_src_clicked, @@ -84,7 +84,7 @@ class SourceSelector: for s in self.list: self.orig.append(s) self.update(self.parent) - utils.destroy_passed_object(self.sourcesel) + Utils.destroy_passed_object(self.sourcesel) def on_edit_src_clicked(self,obj): sel = obj.selection @@ -119,17 +119,17 @@ class SourceEditor: self.source_ref = srcref self.showSource = libglade.GladeXML(const.srcselFile, "sourceDisplay") self.showSource.signal_autoconnect({ - "on_combo_insert_text" : utils.combo_insert_text, + "on_combo_insert_text" : Utils.combo_insert_text, "on_sourceok_clicked" : self.on_sourceok_clicked, "on_source_changed" : self.on_source_changed, - "destroy_passed_object" : utils.destroy_passed_object + "destroy_passed_object" : Utils.destroy_passed_object }) self.sourceDisplay = self.get_widget("sourceDisplay") self.source_field = self.get_widget("sourceList") self.title_menu = self.get_widget("source_title") self.title_menu.set_data("o",self) self.conf_menu = self.get_widget("conf") - utils.build_confidence_menu(self.conf_menu) + Utils.build_confidence_menu(self.conf_menu) self.conf_menu.set_history(srcref.getConfidence()) self.author_field = self.get_widget("sauthor") @@ -218,8 +218,8 @@ class SourceEditor: if self.update: self.update(self.parent,self.source_ref) - utils.modified() - utils.destroy_passed_object(obj) + Utils.modified() + Utils.destroy_passed_object(obj) def on_source_changed(self,obj): self.active_source = obj.list.get_selection()[0].get_data("s") diff --git a/src/StartupDialog.py b/src/StartupDialog.py index 17a9b4f55..7b6a77a3e 100644 --- a/src/StartupDialog.py +++ b/src/StartupDialog.py @@ -21,7 +21,7 @@ import const import libglade import gnome.config -import utils +import Utils _StartupEntry = "/gramps/config/startup" @@ -78,9 +78,9 @@ class StartupDialog: gnome.config.set_int("/gramps/config/UseLDS",lds) gnome.config.set_int(_StartupEntry,const.startup) gnome.config.sync() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def on_cancel_clicked(self,obj): gnome.config.set_int(_StartupEntry,const.startup) gnome.config.sync() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) diff --git a/src/StyleEditor.py b/src/StyleEditor.py index 040e959eb..c719c24d2 100644 --- a/src/StyleEditor.py +++ b/src/StyleEditor.py @@ -20,7 +20,7 @@ import libglade import gtk -import utils +import Utils import ListColors import const @@ -40,7 +40,7 @@ class StyleListDisplay: self.sheetlist = stylesheetlist self.top = libglade.GladeXML(const.stylesFile,"styles") self.top.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_list_select_row" : on_list_select_row, "on_ok_clicked" : on_ok_clicked, "on_add_clicked" : on_add_clicked, @@ -92,7 +92,7 @@ def on_ok_clicked(obj): top.callback(top.object) top.sheetlist.save() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) #------------------------------------------------------------------------ # @@ -143,7 +143,7 @@ class StyleEditor: self.top.signal_autoconnect({ "on_save_style_clicked" : on_save_style_clicked, - "destroy_passed_object" : utils.destroy_passed_object + "destroy_passed_object" : Utils.destroy_passed_object }) self.window = self.top.get_widget("editor") @@ -272,7 +272,7 @@ def on_save_style_clicked(obj): top.save_paragraph(p) top.parent.sheetlist.set_style_sheet(name,top.style) top.parent.redraw() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) diff --git a/src/TextDoc.py b/src/TextDoc.py index dd458f67e..ef407aaa3 100644 --- a/src/TextDoc.py +++ b/src/TextDoc.py @@ -20,7 +20,6 @@ import string import os -import utils #------------------------------------------------------------------------- # diff --git a/src/UrlEdit.py b/src/UrlEdit.py index 4965f39c4..7767bcf73 100644 --- a/src/UrlEdit.py +++ b/src/UrlEdit.py @@ -31,7 +31,7 @@ import libglade # #------------------------------------------------------------------------- import const -import utils +import Utils from RelLib import * #------------------------------------------------------------------------- @@ -58,7 +58,7 @@ class UrlEditor: self.priv.set_active(url.getPrivacy()) self.top.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_url_edit_ok_clicked" : self.on_url_edit_ok_clicked }) @@ -73,7 +73,7 @@ class UrlEditor: self.update_url(des,addr,priv) self.parent.redraw_url_list() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def update_url(self,des,addr,priv): if self.url.get_path() != addr: diff --git a/src/utils.py b/src/Utils.py similarity index 99% rename from src/utils.py rename to src/Utils.py index fcdc11ada..ab580c0ff 100644 --- a/src/utils.py +++ b/src/Utils.py @@ -167,10 +167,10 @@ def destroy_passed_object(obj): # #------------------------------------------------------------------------- def get_detail_flags(obj,priv=1): - import Config + import GrampsCfg detail = "" - if Config.show_detail: + if GrampsCfg.show_detail: if obj.getNote() != "": detail = "N" if len(obj.getSourceRefList()) > 0: diff --git a/src/VersionControl.py b/src/VersionControl.py index 844fa853d..c7f7d68cd 100644 --- a/src/VersionControl.py +++ b/src/VersionControl.py @@ -28,7 +28,7 @@ import os import string import shutil import const -import utils +import Utils from re import compile @@ -85,7 +85,7 @@ class RevisionComment: def on_savecomment_clicked(self,obj): comment = self.text.get_text() - utils.destroy_passed_object(self.win) + Utils.destroy_passed_object(self.win) self.save(self.filename,comment) @@ -113,7 +113,7 @@ class RevisionSelect: index = index + 1 def on_cancel_clicked(self,obj): - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) if self.callback: self.callback() @@ -122,7 +122,7 @@ class RevisionSelect: rev = self.revlist.get_row_data(self.revlist.selection[0]) f = self.vc.get_version(rev) self.load(f,self.filename,rev) - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) class VersionControl: """Base class for revision control systems""" diff --git a/src/WriteXML.py b/src/WriteXML.py index 42cb71555..9c2d53761 100644 --- a/src/WriteXML.py +++ b/src/WriteXML.py @@ -38,7 +38,7 @@ import os # #------------------------------------------------------------------------- import const -import Config +import GrampsCfg from RelLib import * from Date import SingleDate from intl import gettext @@ -65,7 +65,7 @@ def exportData(database, filename, callback): if os.path.isfile(filename): shutil.copy(filename, filename + ".bak") - compress = Config.uncompress ==0 and _gzip_ok == 1 + compress = GrampsCfg.uncompress ==0 and _gzip_ok == 1 try: g = XmlWriter(database,callback,0,compress) diff --git a/src/docgen/HtmlDoc.py b/src/docgen/HtmlDoc.py index 7ab7d1b26..49bf83b89 100644 --- a/src/docgen/HtmlDoc.py +++ b/src/docgen/HtmlDoc.py @@ -21,7 +21,6 @@ import os import string import re -import utils import gnome.ui import Plugins import ImgManip diff --git a/src/docgen/KwordDoc.py b/src/docgen/KwordDoc.py index eee4fe56c..9989d7d28 100644 --- a/src/docgen/KwordDoc.py +++ b/src/docgen/KwordDoc.py @@ -20,7 +20,6 @@ from TextDoc import * from latin_utf8 import latin_to_utf8 -import utils import time import StringIO import os diff --git a/src/docgen/OpenOfficeDoc.py b/src/docgen/OpenOfficeDoc.py index 7f17e9445..8c29518d1 100644 --- a/src/docgen/OpenOfficeDoc.py +++ b/src/docgen/OpenOfficeDoc.py @@ -25,7 +25,6 @@ import string from TextDoc import * from latin_utf8 import latin_to_utf8 import const -import utils import Plugins import intl import ImgManip diff --git a/src/filters/RegExMatch.py b/src/filters/RegExMatch.py index 754562c26..a5b427bc0 100644 --- a/src/filters/RegExMatch.py +++ b/src/filters/RegExMatch.py @@ -22,7 +22,7 @@ import Filter import re -import utils +import Utils import intl _ = intl.gettext @@ -41,7 +41,7 @@ class RegExMatch(Filter.Filter): if self.ok == 0: return 0 else: - return self.regexp.search(utils.phonebook_name(person)) + return self.regexp.search(Utils.phonebook_name(person)) #------------------------------------------------------------------------ # diff --git a/src/filters/SubString.py b/src/filters/SubString.py index 93fae4ff8..13cd487af 100644 --- a/src/filters/SubString.py +++ b/src/filters/SubString.py @@ -22,7 +22,7 @@ import Filter import string -import utils +import Utils import intl _ = intl.gettext @@ -30,7 +30,7 @@ class SubString(Filter.Filter): "Names that contain a substring" def match(self,person): - return string.find(utils.phonebook_name(person),self.text) >= 0 + return string.find(Utils.phonebook_name(person),self.text) >= 0 #------------------------------------------------------------------------ # diff --git a/src/gramps_main.py b/src/gramps_main.py index 57430a951..1b184ada3 100755 --- a/src/gramps_main.py +++ b/src/gramps_main.py @@ -62,10 +62,10 @@ import Filter import const import Plugins import sort -import utils +import Utils import Bookmarks import ListColors -import Config +import GrampsCfg import EditPerson import Marriage import Find @@ -73,2128 +73,1708 @@ import VersionControl #------------------------------------------------------------------------- # -# Global variables. -# -# I'm not fond of global variables. Howerver, I am fairly inexperienced -# with a GUI callback model, and I don't have another way of doing this -# yet. +# Main GRAMPS class # #------------------------------------------------------------------------- +class Gramps: -active_person = None -active_father = None -active_family = None -active_parents= None -active_mother = None -active_child = None -active_spouse = None + def __init__(self,arg): -id2col = {} -alt2col = {} + self.DataFilter = Filter.Filter("") + self.active_child = None + self.active_family = None + self.active_father = None + self.active_mother = None + self.active_parents= None + self.active_person = None + self.active_spouse = None + self.alt2col = {} + self.bookmarks = None + self.cDateArrow = None + self.cGenderArrow = None + self.cIDArrow = None + self.cNameArrow = None + self.c_birth_date = 4 + self.c_birth_order = 0 + self.c_details = 6 + self.c_gender = 3 + self.c_id = 2 + self.c_name = 1 + self.c_sort_column = self.c_birth_order + self.c_sort_direct = GTK.SORT_ASCENDING + self.id2col = {} + self.media_view = None + self.pedigree_view = None + self.place_view = None + self.preview = None + self.sort_column = None + self.sort_direct = None + self.source_view = None + self.toolbar = None -pedigree_view = None -place_view = None -media_view = None -source_view = None -toolbar = None -bookmarks = None -topWindow = None -statusbar = None -gtop = None -notebook = None -person_list = None -database = None -nameArrow = None -genderArrow = None -idArrow = None -deathArrow = None -dateArrow = None + gtk.rc_parse(const.gtkrcFile) -merge_button = None -sort_column = 0 -sort_direct = GTK.SORT_ASCENDING -DataFilter = Filter.Filter("") -c_birth_order = 0 -c_name = 1 -c_id = 2 -c_gender = 3 -c_birth_date = 4 -c_details = 6 -c_sort_column = c_birth_order -c_sort_direct = GTK.SORT_ASCENDING -cNameArrow = None -cGenderArrow = None -cIDArrow = None -cDateArrow = None + if os.getuid() == 0: + msg = _("You are running GRAMPS as the 'root' user.\nThis account is not meant for normal application use.") + gnome.ui.GnomeWarningDialog(msg) -#------------------------------------------------------------------------- -# -# Constants -# -#------------------------------------------------------------------------- + self.database = GrampsDB() -NOTEBOOK = "notebook1" -FILESEL = "fileselection" -FILTERNAME = "filter_list" + Plugins.load_plugins(const.docgenDir) + Plugins.load_plugins(os.path.expanduser("~/.gramps/docgen")) + Plugins.load_plugins(const.pluginsDir) + Plugins.load_plugins(os.path.expanduser("~/.gramps/plugins")) + Filter.load_filters(const.filtersDir) + Filter.load_filters(os.path.expanduser("~/.gramps/filters")) -#------------------------------------------------------------------------- -# -# Find support -# -#------------------------------------------------------------------------- -def on_find_activate(obj): - """Display the find box""" - Find.Find(person_list,find_goto_to,database.getPersonMap().values()) + self.sort_column = 0 + self.sort_direct = GTK.SORT_ASCENDING -def on_findname_activate(obj): - """Display the find box""" - pass + (self.sort_column,self.sort_direct) = GrampsCfg.get_sort_cols("person",self.sort_column,self.sort_direct) -def find_goto_to(person): - """Find callback to jump to the selected person""" - change_active_person(person) - goto_active_person() - update_display(0) + GrampsCfg.loadConfig(self.full_update) -def on_gramps_home_page_activate(obj): - import gnome.url - gnome.url.show("http://gramps.sourceforge.net") + self.gtop = libglade.GladeXML(const.gladeFile, "gramps") + self.toolbar = self.gtop.get_widget("toolbar1") + self.toolbar.set_style(GrampsCfg.toolbar) -def on_gramps_mailing_lists_activate(obj): - import gnome.url - gnome.url.show("http://sourceforge.net/mail/?group_id=25770") + self.statusbar = self.gtop.get_widget("statusbar") + self.topWindow = self.gtop.get_widget("gramps") + self.person_list = self.gtop.get_widget("person_list") + self.filter_list = self.gtop.get_widget("filter_list") + self.notebook = self.gtop.get_widget("notebook1") + self.nameArrow = self.gtop.get_widget("nameSort") + self.genderArrow = self.gtop.get_widget("genderSort") + self.idArrow = self.gtop.get_widget("idSort") + self.dateArrow = self.gtop.get_widget("dateSort") + self.deathArrow = self.gtop.get_widget("deathSort") + self.merge_button= self.gtop.get_widget("merge") -def on_gramps_report_bug_activate(obj): - import gnome.url - gnome.url.show("http://sourceforge.net/tracker/?group_id=25770&atid=385137") + self.col_map = [ 5, 1, 2, 6, 7 ] + self.col_arr = [ self.nameArrow, self.idArrow, self.genderArrow, + self.dateArrow, self.deathArrow] + + Plugins.build_report_menu(self.gtop.get_widget("reports_menu"),self.menu_report) + Plugins.build_tools_menu(self.gtop.get_widget("tools_menu"),self.menu_tools) + Plugins.build_export_menu(self.gtop.get_widget("export1"),self.export_callback) + Plugins.build_import_menu(self.gtop.get_widget("import1"),self.import_callback) -#------------------------------------------------------------------------- -# -# Merge -# -#------------------------------------------------------------------------- -def on_merge_activate(obj): - """Calls up the merge dialog for the selection""" - page = notebook.get_current_page() - if page == 0: - if len(person_list.selection) != 2: - msg = _("Exactly two people must be selected to perform a merge") - gnome.ui.GnomeErrorDialog(msg) - else: - import MergeData - (p1,x) = person_list.get_row_data(person_list.selection[0]) - (p2,x) = person_list.get_row_data(person_list.selection[1]) - MergeData.MergePeople(database,p1,p2,merge_update,update_after_edit) - elif page == 4: - place_view.merge() + self.canvas = self.gtop.get_widget("canvas1") + self.pedigree_view = PedigreeView(self.canvas, + self.modify_statusbar, + self.statusbar, + self.change_active_person, + self.load_person) + self.place_view = PlaceView(self.database,self.gtop,self.update_display) + self.source_view = SourceView(self.database,self.gtop,self.update_display) + self.media_view = MediaView(self.database,self.gtop,self.update_display) -#------------------------------------------------------------------------- -# -# Exiting -# -#------------------------------------------------------------------------- -def delete_event(widget, event): - """Catch the destruction of the top window, prompt to save if needed""" - widget.hide() - on_exit_activate(widget) - return 1 - -def on_exit_activate(obj): - """Prompt to save on exit if needed""" - if utils.wasModified(): - question = _("Unsaved changes exist in the current database\n") + \ - _("Do you wish to save the changes?") - gnome.ui.GnomeQuestionDialog(question,save_query) - else: - gtk.mainquit(obj) - -def save_query(value): - """Catch the reponse to the save on exit question""" - if value == 0: - on_save_activate_quit() - gtk.mainquit(gtop) - -#------------------------------------------------------------------------- -# -# Help -# -#------------------------------------------------------------------------- -def on_about_activate(obj): - """Displays the about box. Called from Help menu""" - gnome.ui.GnomeAbout(const.progName,const.version,const.copyright, - const.authors,const.comments,const.logo).show() + self.cNameArrow = self.gtop.get_widget("cNameSort") + self.cGenderArrow= self.gtop.get_widget("cGenderSort") + self.cIDArrow = self.gtop.get_widget("cIDSort") + self.cDateArrow = self.gtop.get_widget("cDateSort") + self.person_list.set_column_visibility(5,0) + self.person_list.set_column_visibility(6,0) + self.person_list.set_column_visibility(7,0) + fw = self.gtop.get_widget('filter') + self.filter_list.set_menu(Filter.build_filter_menu(self.on_filter_name_changed,fw)) -def on_contents_activate(obj): - """Display the GRAMPS manual""" - import gnome.help - gnome.help.display("gramps-manual","index.html") + fw.set_sensitive(0) -def on_writing_extensions_activate(obj): - """Display the Extending GRAMPS manual""" - import gnome.help - gnome.help.display("extending-gramps","index.html") + # set the window icon + self.topWindow.set_icon(gtk.GtkPixmap(self.topWindow,const.icon)) -#------------------------------------------------------------------------- -# -# Called when the remove child button clicked on the family page. If -# no active person is specified, or if no active child is specified, -# then the button press is meaningless, and should be ignored. Otherwise, -# remove the child from the active family, and set the family the child -# belongs to to None. -# -#------------------------------------------------------------------------- -def on_remove_child_clicked(obj): - if not active_family or not active_child or not active_person: - return + self.person_list.column_titles_active() - active_family.removeChild(active_child) - active_child.setMainFamily(None) - if len(active_family.getChildList()) == 0: - if active_family.getFather() == None: - delete_family_from(active_family.getMother()) - elif active_family.getMother() == None: - delete_family_from(active_family.getFather()) + self.change_sort(self.sort_column,self.sort_direct==GTK.SORT_DESCENDING) + self.set_sort_arrow(self.sort_column,self.sort_direct) - utils.modified() - load_family() - -def delete_family_from(person): - global active_family - - person.removeFamily(active_family) - database.deleteFamily(active_family) - flist = active_person.getFamilyList() - if len(flist) > 0: - active_family = flist[0] - else: - active_family = None - -#------------------------------------------------------------------------- -# -# Spouse editing callbacks -# -#------------------------------------------------------------------------- -def on_add_sp_clicked(obj): - """Add a new spouse to the current person""" - import AddSpouse - if active_person: - AddSpouse.AddSpouse(database,active_person,load_family,redisplay_person_list) - -def on_edit_sp_clicked(obj): - """Edit the marriage information for the current family""" - if active_person: - Marriage.Marriage(active_family,database,new_after_edit) - -def on_delete_sp_clicked(obj): - """Delete the currently selected spouse from the family""" - - if active_person == None: - return - elif active_person == active_family.getFather(): - person = active_family.getMother() - active_family.setMother(None) - else: - person = active_family.getFather() - active_family.setFather(None) - - if person: - person.removeFamily(active_family) - - if len(active_family.getChildList()) == 0: - active_person.removeFamily(active_family) - database.deleteFamily(active_family) - if len(active_person.getFamilyList()) > 0: - load_family(active_person.getFamilyList()[0]) - else: - load_family(None) - else: - load_family() - utils.modified() - -#------------------------------------------------------------------------- -# -# Selecting father, mother, or child from Family View -# -#------------------------------------------------------------------------- -def on_mother_next_clicked(obj): - """Makes the current mother the active person""" - if active_parents: - mother = active_parents.getMother() - if mother: - change_active_person(mother) - obj.set_sensitive(1) - load_family() - else: - obj.set_sensitive(0) - else: - obj.set_sensitive(0) - -def on_father_next_clicked(obj): - """Makes the current mother the active person""" - if active_parents: - father = active_parents.getFather() - if father: - change_active_person(father) - obj.set_sensitive(1) - load_family() - else: - obj.set_sensitive(0) - else: - obj.set_sensitive(0) - -def on_fv_prev_clicked(obj): - """makes the currently select child the active person""" - if active_child: - change_active_person(active_child) - load_family() - -#------------------------------------------------------------------------- -# -# Editing children of a marriage -# -#------------------------------------------------------------------------- -def on_add_child_clicked(obj): - """Select an existing child to add to the active family""" - import SelectChild - if active_person: - SelectChild.SelectChild(database,active_family,active_person,load_family) - -def on_add_new_child_clicked(obj): - """Create a new child to add to the existing family""" - import SelectChild - if active_person: - SelectChild.NewChild(database,active_family,active_person, - update_after_newchild,Config.lastnamegen) - -#------------------------------------------------------------------------- -# -# Choosing Parents -# -#------------------------------------------------------------------------- -def on_choose_parents_clicked(obj): - import ChooseParents - if active_person: - ChooseParents.ChooseParents(database,active_person,active_parents,load_family,full_update) - -#------------------------------------------------------------------------- -# -# Creating a new database -# -#------------------------------------------------------------------------- -def on_new_clicked(obj): - """Prompt for permission to close the current database""" - msg = _("Do you want to close the current database and create a new one?") - gnome.ui.GnomeQuestionDialog(msg,new_database_response) - -def new_database_response(val): - if val == 1: - return - clear_database() - DbPrompter(database,1) - -def clear_database(): - """Clear out the database if permission was granted""" - global active_person, active_father - global active_family, active_mother - global active_child, active_spouse - global id2col,alt2col,person_list - - const.personalEvents = const.initialize_personal_event_list() - const.personalAttributes = const.initialize_personal_attribute_list() - const.marriageEvents = const.initialize_marriage_event_list() - const.familyAttributes = const.initialize_family_attribute_list() - const.familyRelations = const.initialize_family_relation_list() - - database.new() - topWindow.set_title("GRAMPS") - active_person = None - active_father = None - active_family = None - active_mother = None - active_child = None - active_spouse = None - id2col = {} - alt2col = {} - - utils.clearModified() - utils.clear_timer() - change_active_person(None) - person_list.clear() - load_family() - source_view.load_sources() - place_view.load_places() - media_view.load_media() - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def tool_callback(val): - if val: - utils.modified() - full_update() + self.gtop.signal_autoconnect({ + "delete_event" : self.delete_event, + "destroy_passed_object" : Utils.destroy_passed_object, + "on_about_activate" : self.on_about_activate, + "on_add_bookmark_activate" : self.on_add_bookmark_activate, + "on_add_child_clicked" : self.on_add_child_clicked, + "on_add_new_child_clicked" : self.on_add_new_child_clicked, + "on_add_place_clicked" : self.place_view.on_add_place_clicked, + "on_add_source_clicked" : self.source_view.on_add_source_clicked, + "on_add_sp_clicked" : self.on_add_sp_clicked, + "on_addperson_clicked" : self.load_new_person, + "on_apply_filter_clicked" : self.on_apply_filter_clicked, + "on_arrow_left_clicked" : self.pedigree_view.on_show_child_menu, + "on_canvas1_event" : self.pedigree_view.on_canvas1_event, + "on_child_list_button_press_event" : self.on_child_list_button_press_event, + "on_child_list_select_row" : self.on_child_list_select_row, + "on_child_list_click_column" : self.on_child_list_click_column, + "on_child_list_row_move" : self.on_child_list_row_move, + "on_choose_parents_clicked" : self.on_choose_parents_clicked, + "on_contents_activate" : self.on_contents_activate, + "on_default_person_activate" : self.on_default_person_activate, + "on_delete_parents_clicked" : self.on_delete_parents_clicked, + "on_delete_person_clicked" : self.on_delete_person_clicked, + "on_delete_place_clicked" : self.place_view.on_delete_place_clicked, + "on_delete_source_clicked" : self.source_view.on_delete_source_clicked, + "on_delete_media_clicked" : self.media_view.on_delete_media_clicked, + "on_delete_sp_clicked" : self.on_delete_sp_clicked, + "on_edit_active_person" : self.load_active_person, + "on_edit_selected_people" : self.load_selected_people, + "on_edit_bookmarks_activate" : self.on_edit_bookmarks_activate, + "on_edit_father_clicked" : self.on_edit_father_clicked, + "on_edit_media_clicked" : self.media_view.on_edit_media_clicked, + "on_edit_mother_clicked" : self.on_edit_mother_clicked, + "on_edit_place_clicked" : self.place_view.on_edit_place_clicked, + "on_edit_source_clicked" : self.source_view.on_edit_source_clicked, + "on_edit_sp_clicked" : self.on_edit_sp_clicked, + "on_edit_spouse_clicked" : self.on_edit_spouse_clicked, + "on_exit_activate" : self.on_exit_activate, + "on_family1_activate" : self.on_family1_activate, + "on_father_next_clicked" : self.on_father_next_clicked, + "on_find_activate" : self.on_find_activate, + "on_findname_activate" : self.on_findname_activate, + "on_fv_prev_clicked" : self.on_fv_prev_clicked, + "on_home_clicked" : self.on_home_clicked, + "on_mother_next_clicked" : self.on_mother_next_clicked, + "on_new_clicked" : self.on_new_clicked, + "on_notebook1_switch_page" : self.on_notebook1_switch_page, + "on_ok_button1_clicked" : self.on_ok_button1_clicked, + "on_open_activate" : self.on_open_activate, + "on_pedegree1_activate" : self.on_pedegree1_activate, + "on_person_list1_activate" : self.on_person_list1_activate, + "on_person_list_button_press" : self.on_person_list_button_press, + "on_person_list_click_column" : self.on_person_list_click_column, + "on_person_list_select_row" : self.on_person_list_select_row, + "on_place_list_click_column" : self.place_view.on_click_column, + "on_main_key_release_event" : self.on_main_key_release_event, + "on_add_media_clicked" : self.media_view.create_add_dialog, + "on_media_activate" : self.on_media_activate, + "on_media_list_select_row" : self.media_view.on_select_row, + "on_media_list_drag_data_get" : self.media_view.on_drag_data_get, + "on_media_list_drag_data_received" : self.media_view.on_drag_data_received, + "on_merge_activate" : self.on_merge_activate, + "on_places_activate" : self.on_places_activate, + "on_preferences_activate" : self.on_preferences_activate, + "on_reload_plugins_activate" : Plugins.reload_plugins, + "on_remove_child_clicked" : self.on_remove_child_clicked, + "on_reports_clicked" : self.on_reports_clicked, + "on_revert_activate" : self.on_revert_activate, + "on_save_activate" : self.on_save_activate, + "on_save_as_activate" : self.on_save_as_activate, + "on_source_list_button_press_event" : self.source_view.on_button_press_event, + "on_sources_activate" : self.on_sources_activate, + "on_spouselist_changed" : self.on_spouselist_changed, + "on_swap_clicked" : self.on_swap_clicked, + "on_tools_clicked" : self.on_tools_clicked, + "on_gramps_home_page_activate" : self.on_gramps_home_page_activate, + "on_gramps_report_bug_activate" : self.on_gramps_report_bug_activate, + "on_gramps_mailing_lists_activate" : self.on_gramps_mailing_lists_activate, + "on_writing_extensions_activate" : self.on_writing_extensions_activate, + }) -#------------------------------------------------------------------------- -# -# Update the display -# -#------------------------------------------------------------------------- -def full_update(): - """Brute force display update, updating all the pages""" - global id2col - global alt2col - - id2col = {} - alt2col = {} - person_list.clear() - notebook.set_show_tabs(Config.usetabs) - clist = gtop.get_widget("child_list") - clist.set_column_visibility(c_details,Config.show_detail) - clist.set_column_visibility(c_id,Config.id_visible) - clist.set_column_visibility(c_birth_order,Config.index_visible) - apply_filter() - load_family() - source_view.load_sources() - place_view.load_places() - pedigree_view.load_canvas(active_person) - media_view.load_media() - toolbar.set_style(Config.toolbar) + self.person_list.set_column_visibility(1,GrampsCfg.id_visible) -def update_display(changed): - """Incremental display update, update only the displayed page""" - page = notebook.get_current_page() - if page == 0: - if changed: - apply_filter() + self.notebook.set_show_tabs(GrampsCfg.usetabs) + self.database.set_iprefix(GrampsCfg.iprefix) + self.database.set_oprefix(GrampsCfg.oprefix) + self.database.set_fprefix(GrampsCfg.fprefix) + self.database.set_sprefix(GrampsCfg.sprefix) + self.database.set_pprefix(GrampsCfg.pprefix) + self.child_list = self.gtop.get_widget("child_list") + self.child_list.set_column_visibility(self.c_details,GrampsCfg.show_detail) + self.child_list.set_column_justification(self.c_birth_order,GTK.JUSTIFY_RIGHT) + + if arg != None: + self.read_file(arg) + elif GrampsCfg.lastfile != None and GrampsCfg.lastfile != "" and GrampsCfg.autoload: + self.auto_save_load(GrampsCfg.lastfile) else: - goto_active_person() - elif page == 1: - load_family() - elif page == 2: - pedigree_view.load_canvas(active_person) - elif page == 3: - source_view.load_sources() - elif page == 4: + DbPrompter(self,0) + + if GrampsCfg.autosave_int != 0: + Utils.enable_autosave(self.autosave_database,GrampsCfg.autosave_int) + + self.database.setResearcher(GrampsCfg.get_researcher()) + + def on_find_activate(self,obj): + """Display the find box""" + Find.Find(self.person_list,self.find_goto_to, + self.database.getPersonMap().values()) + + def on_findname_activate(self,obj): + """Display the find box""" pass - else: - media_view.load_media() -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_tools_clicked(obj): - if active_person: - Plugins.ToolPlugins(database,active_person,tool_callback) + def find_goto_to(self,person): + """Find callback to jump to the selected person""" + self.change_active_person(person) + self.goto_active_person() + self.update_display(0) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_reports_clicked(obj): - if active_person: - Plugins.ReportPlugins(database,active_person) + def on_gramps_home_page_activate(self,obj): + import gnome.url + gnome.url.show("http://gramps.sourceforge.net") -#------------------------------------------------------------------------- -# -# Called from the fileselector, when the OK button is pressed (Open -# command). Currently loads a GEDCOM file and destroys the fileselector -# window, which is passed as "obj" -# -#------------------------------------------------------------------------- -def on_ok_button1_clicked(obj): - global yname - global nname + def on_gramps_mailing_lists_activate(self,obj): + import gnome.url + gnome.url.show("http://sourceforge.net/mail/?group_id=25770") + + def on_gramps_report_bug_activate(self,obj): + import gnome.url + gnome.url.show("http://sourceforge.net/tracker/?group_id=25770&atid=385137") - dbname = obj.get_data("dbname") - getoldrev = obj.get_data("getoldrev") - filename = dbname.get_full_path(0) - utils.destroy_passed_object(obj) - - if filename == "" or filename == None: - return - - clear_database() - - if getoldrev.get_active(): - vc = VersionControl.RcsVersionControl(filename) - VersionControl.RevisionSelect(database,filename,vc,load_revision) - else: - auto_save_load(filename) - -def auto_save_load(filename): - global yname, nname - - if os.path.isdir(filename): - dirname = filename - else: - dirname = os.path.dirname(filename) - autosave = "%s/autosave.gramps" % dirname - - if os.path.isfile(autosave): - q = _("An autosave file exists for %s.\nShould this be loaded instead of the last saved version?") % dirname - yname = autosave - nname = filename - gnome.ui.GnomeQuestionDialog(q,autosave_query) - else: - read_file(filename) - -def autosave_query(value): - if value == 0: - read_file(yname) - else: - read_file(nname) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def read_file(filename): - base = os.path.basename(filename) - if base == const.indexFile: - filename = os.path.dirname(filename) - elif base == "autosave.gramps": - filename = os.path.dirname(filename) - elif not os.path.isdir(filename): - displayError(_("%s is not a directory") % filename) - return - - statusbar.set_status(_("Loading %s ...") % filename) - - if load_database(filename) == 1: - if filename[-1] == '/': - filename = filename[:-1] - name = os.path.basename(filename) - topWindow.set_title("%s - %s" % (name,_("GRAMPS"))) - else: - statusbar.set_status("") - Config.save_last_file("") - -#------------------------------------------------------------------------- -# -# Called from the fileselector, when the OK button is pressed (Save -# command). Currently saves a GEDCOM file and destroys the fileselector -# window, which is passed as "obj" -# -#------------------------------------------------------------------------- -def on_ok_button2_clicked(obj): - filename = obj.get_filename() - if filename: - utils.destroy_passed_object(obj) - if Config.usevc and Config.vc_comment: - display_comment_box(filename) - else: - save_file(filename,_("No Comment Provided")) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def save_file(filename,comment): - import WriteXML - - path = filename - filename = os.path.normpath(filename) - autosave = "%s/autosave.gramps" % filename - - statusbar.set_status(_("Saving %s ...") % filename) - - utils.clearModified() - utils.clear_timer() - - if os.path.exists(filename): - if os.path.isdir(filename) == 0: - displayError(_("%s is not a directory") % filename) - return - else: - try: - os.mkdir(filename) - except IOError, msg: - gnome.ui.GnomeErrorDialog(_("Could not create %s") % filename + "\n" + str(msg)) - return - except OSError, msg: - gnome.ui.GnomeErrorDialog(_("Could not create %s") % filename + "\n" + str(msg)) - return - except: - gnome.ui.GnomeErrorDialog(_("Could not create %s") % filename) - return - - old_file = filename - filename = filename + os.sep + const.indexFile - try: - WriteXML.exportData(database,filename,load_progress) - except IOError, msg: - gnome.ui.GnomeErrorDialog(_("Could not create %s") % filename + "\n" + str(msg)) - return - except OSError, msg: - gnome.ui.GnomeErrorDialog(_("Could not create %s") % filename + "\n" + str(msg)) - return - - database.setSavePath(old_file) - Config.save_last_file(old_file) - - if Config.usevc: - vc = VersionControl.RcsVersionControl(path) - vc.checkin(filename,comment,not Config.uncompress) - - filename = database.getSavePath() - if filename[-1] == '/': - filename = filename[:-1] - name = os.path.basename(filename) - topWindow.set_title("%s - %s" % (name,_("GRAMPS"))) - statusbar.set_status("") - statusbar.set_progress(0) - if os.path.exists(autosave): - try: - os.remove(autosave) - except: - pass - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def autosave_database(): - import WriteXML - - path = database.getSavePath() - filename = os.path.normpath(path) - utils.clear_timer() - - filename = "%s/autosave.gramps" % (database.getSavePath()) - - statusbar.set_status(_("autosaving...")); - try: - WriteXML.quick_write(database,filename,quick_progress) - statusbar.set_status(_("autosave complete")); - except (IOError,OSError): - statusbar.set_status(_("autosave failed")); - except: - import traceback - traceback.print_exc() - - return 0 - -#------------------------------------------------------------------------- -# -# Edit Person window for specified people -# -#------------------------------------------------------------------------- -def load_selected_people(obj): - """Display the selected people in the EditPerson display""" - if len(person_list.selection) > 5: - msg = _("You requested too many people to edit at the same time") - gnome.ui.GnomeErrorDialog(msg) - else: - for p in person_list.selection: - (person,x) = person_list.get_row_data(p) - load_person(person) - -def load_active_person(obj): - load_person(active_person) - -def on_edit_spouse_clicked(obj): - """Display the active spouse in the EditPerson display""" - load_person(active_spouse) - -def on_edit_mother_clicked(obj): - """Display the active mother in the EditPerson display""" - load_person(active_mother) - -def on_edit_father_clicked(obj): - """Display the active father in the EditPerson display""" - load_person(active_father) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def load_new_person(obj): - global active_person - active_person = Person() - EditPerson.EditPerson(active_person,database,new_after_edit) - -#------------------------------------------------------------------------- -# -# Deleting a person -# -#------------------------------------------------------------------------- -def on_delete_person_clicked(obj): - if len(person_list.selection) == 1: - msg = _("Do you really wish to delete %s?") % Config.nameof(active_person) - gnome.ui.GnomeQuestionDialog( msg, delete_person_response) - elif len(person_list.selection) > 1: - gnome.ui.GnomeErrorDialog(_("Currently, you can only delete one person at a time")) - -def delete_person_response(val): - if val == 1: - return - - personmap = database.getPersonMap() - familymap = database.getPersonMap() - - for family in active_person.getFamilyList(): - if active_person.getGender == Person.male: - if family.getMother() == None: - for child in family.getChildList(): - child.setMainFamily(None) - del familymap[family] + def on_merge_activate(self,obj): + """Calls up the merge dialog for the selection""" + page = self.notebook.get_current_page() + if page == 0: + if len(self.person_list.selection) != 2: + msg = _("Exactly two people must be selected to perform a merge") + gnome.ui.GnomeErrorDialog(msg) else: - family.setFather(None) + import MergeData + (p1,x) = self.person_list.get_row_data(self.person_list.selection[0]) + (p2,x) = self.person_list.get_row_data(self.person_list.selection[1]) + MergeData.MergePeople(self.database,p1,p2,self.merge_update, + self.update_after_edit) + elif page == 4: + self.place_view.merge() + + def delete_event(self,widget, event): + """Catch the destruction of the top window, prompt to save if needed""" + widget.hide() + self.on_exit_activate(widget) + return 1 + + def on_exit_activate(self,obj): + """Prompt to save on exit if needed""" + if Utils.wasModified(): + question = _("Unsaved changes exist in the current database\n") + \ + _("Do you wish to save the changes?") + gnome.ui.GnomeQuestionDialog(question,self.save_query) + else: + gtk.mainquit(obj) + + def save_query(self,value): + """Catch the reponse to the save on exit question""" + if value == 0: + self.on_save_activate_quit() + gtk.mainquit(self.gtop) + + def on_about_activate(self,obj): + """Displays the about box. Called from Help menu""" + gnome.ui.GnomeAbout(const.progName,const.version,const.copyright, + const.authors,const.comments,const.logo).show() + + def on_contents_activate(self,obj): + """Display the GRAMPS manual""" + import gnome.help + gnome.help.display("gramps-manual","index.html") + + def on_writing_extensions_activate(self,obj): + """Display the Extending GRAMPS manual""" + import gnome.help + gnome.help.display("extending-gramps","index.html") + + def on_remove_child_clicked(self,obj): + if not self.active_family or not self.active_child or not self.active_person: + return + + self.active_family.removeChild(self.active_child) + self.active_child.setMainFamily(None) + if len(self.active_family.getChildList()) == 0: + if self.active_family.getFather() == None: + self.delete_family_from(self.active_family.getMother()) + elif self.active_family.getMother() == None: + self.delete_family_from(self.active_family.getFather()) + + Utils.modified() + self.load_family() + + def delete_family_from(self,person): + person.removeFamily(self.active_family) + self.database.deleteFamily(self.active_family) + flist = self.active_person.getFamilyList() + if len(flist) > 0: + self.active_family = flist[0] else: - if family.getFather() == None: - for child in family.getChildList(): - child.setMainFamily(None) - del familymap[family] + self.active_family = None + + def on_add_sp_clicked(self,obj): + """Add a new spouse to the current person""" + import AddSpouse + if self.active_person: + AddSpouse.AddSpouse(self.database,self.active_person, + self.load_family,self.redisplay_person_list) + + def on_edit_sp_clicked(self,obj): + """Edit the marriage information for the current family""" + if self.active_person: + Marriage.Marriage(self.active_family,self.database,self.new_after_edit) + + def on_delete_sp_clicked(self,obj): + """Delete the currently selected spouse from the family""" + + if self.active_person == None: + return + elif self.active_person == self.active_family.getFather(): + person = self.active_family.getMother() + self.active_family.setMother(None) + else: + person = self.active_family.getFather() + self.active_family.setFather(None) + + if person: + person.removeFamily(self.active_family) + + if len(self.active_family.getChildList()) == 0: + self.active_person.removeFamily(self.active_family) + self.database.deleteFamily(self.active_family) + if len(self.active_person.getFamilyList()) > 0: + self.load_family(self.active_person.getFamilyList()[0]) else: - family.setMother(None) + self.load_family(None) + else: + self.load_family() + Utils.modified() - family = active_person.getMainFamily() - if family: - family.removeChild(active_person) - - del personmap[active_person.getId()] - remove_from_person_list(active_person) - person_list.sort() - update_display(0) - utils.modified() - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def remove_from_person_list(person): - global active_person - - person_list.freeze() - if id2col.has_key(person): - for id in [id2col[person]] + alt2col[person]: - row = person_list.find_row_from_data(id) - person_list.remove(row) - - del id2col[person] - del alt2col[person] - - if row > person_list.rows: - (active_person,x) = person_list.get_row_data(row) - person_list.thaw() - -def merge_update(p1,p2): - remove_from_person_list(p1) - remove_from_person_list(p2) - redisplay_person_list(p1) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_delete_parents_clicked(obj): - if not active_parents: - return - - active_parents.removeChild(active_person) - if active_parents == active_person.getMainFamily(): - active_person.setMainFamily(None) - else: - active_person.removeAltFamily(active_parents) - load_family() - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_person_list_select_row(obj,row,b,c): - if row == obj.selection[0]: - (person,x) = obj.get_row_data(row) - change_active_person(person) - -#------------------------------------------------------------------------- -# -# on_person_list_click_column -# -# Called when the user selects a column header on the person_list window. -# Change the sort function (column 0 is the name column, and column 2 is -# the birthdate column), set the arrows on the labels to the correct -# orientation, and then call apply_filter to redraw the list -# -#------------------------------------------------------------------------- -def on_person_list_click_column(obj,column): - change_sort(column) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -col_map = [ 5, 1, 2, 6, 7 ] - -def set_sort_arrow(column,direct): - col_arr = [ nameArrow, idArrow, genderArrow, dateArrow, deathArrow] - - arrow = col_arr[column] - for a in col_arr: - if arrow != a: - a.hide() - arrow.show() - if direct == GTK.SORT_ASCENDING: - arrow.set(GTK.ARROW_DOWN,2) - else: - arrow.set(GTK.ARROW_UP,2) - -def change_sort(column,change=1): - global sort_direct - global sort_column - - col_arr = [ nameArrow, idArrow, genderArrow, dateArrow, deathArrow] - - arrow = col_arr[column] - for a in col_arr: - if arrow != a: - a.hide() - arrow.show() - - person_list.set_sort_column(col_map[column]) - person_list.set_sort_type(sort_direct) - - sort_person_list() - - if change: - if sort_column == column: - if sort_direct == GTK.SORT_DESCENDING: - sort_direct = GTK.SORT_ASCENDING - arrow.set(GTK.ARROW_DOWN,2) + def on_mother_next_clicked(self,obj): + """Makes the current mother the active person""" + if self.active_parents: + mother = self.active_parents.getMother() + if mother: + self.change_active_person(mother) + obj.set_sensitive(1) + self.load_family() else: - sort_direct = GTK.SORT_DESCENDING - arrow.set(GTK.ARROW_UP,2) + obj.set_sensitive(0) else: - sort_direct = GTK.SORT_ASCENDING - arrow.set(GTK.ARROW_DOWN,2) - sort_column = column + obj.set_sensitive(0) - if id2col.has_key(active_person): - row = person_list.find_row_from_data(id2col[active_person]) - person_list.moveto(row) - Config.save_sort_cols("person",sort_column,sort_direct) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def sort_person_list(): - person_list.freeze() - person_list.sort() - person_list.sort() - if ListColors.get_enable(): - try: - oddbg = gtk.GdkColor(ListColors.oddbg[0],ListColors.oddbg[1],ListColors.oddbg[2]) - oddfg = gtk.GdkColor(ListColors.oddfg[0],ListColors.oddfg[1],ListColors.oddfg[2]) - evenbg = gtk.GdkColor(ListColors.evenbg[0],ListColors.evenbg[1],ListColors.evenbg[2]) - evenfg = gtk.GdkColor(ListColors.evenfg[0],ListColors.evenfg[1],ListColors.evenfg[2]) - rows = person_list.rows - for i in range(0,rows,2): - person_list.set_background(i,oddbg) - person_list.set_foreground(i,oddfg) - if i != rows: - person_list.set_background(i+1,evenbg) - person_list.set_foreground(i+1,evenfg) - except OverflowError: - pass - goto_active_person() - person_list.thaw() - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_child_list_button_press_event(obj,event): - if event.button == 1 and event.type == GDK._2BUTTON_PRESS: - load_person(active_child) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_person_list_button_press(obj,event): - if event.button == 1 and event.type == GDK._2BUTTON_PRESS: - load_person(active_person) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def goto_active_person(): - if id2col.has_key(active_person): - pos = id2col[active_person] - column = person_list.find_row_from_data(pos) - if column != -1: - person_list.unselect_all() - person_list.select_row(column,0) - person_list.moveto(column) - else: - if person_list.rows > 0: - person_list.unselect_all() - person_list.select_row(0,0) - person_list.moveto(0) - (person,x) = person_list.get_row_data(0) - change_active_person(person) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def change_active_person(person): - global active_person - - active_person = person - modify_statusbar() - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def modify_statusbar(): - if active_person == None: - statusbar.set_status("") - else: - pname = Config.nameof(active_person) - if Config.status_bar == 1: - name = "[%s] %s" % (active_person.getId(),pname) - elif Config.status_bar == 2: - name = pname - for attr in active_person.getAttributeList(): - if attr.getType() == Config.attr_name: - name = "[%s] %s" % (attr.getValue(),pname) - break + def on_father_next_clicked(self,obj): + """Makes the current father the active person""" + if self.active_parents: + father = self.active_parents.getFather() + if father: + self.change_active_person(father) + obj.set_sensitive(1) + self.load_family() + else: + obj.set_sensitive(0) else: - name = pname - statusbar.set_status(name) - return 0 - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_child_list_select_row(obj,row,b,c): - global active_child - active_child = obj.get_row_data(row) + obj.set_sensitive(0) -#------------------------------------------------------------------------- -# -# on_child_list_click_column -# -# Called when the user selects a column header on the person_list window. -# Change the sort function (column 0 is the name column, and column 2 is -# the birthdate column), set the arrows on the labels to the correct -# orientation, and then call apply_filter to redraw the list -# -#------------------------------------------------------------------------- -def on_child_list_click_column(clist,column): - if column == c_name: - child_change_sort(clist,c_name,cNameArrow) - elif column == c_gender: - child_change_sort(clist,c_gender,cGenderArrow) - elif column == c_id: - child_change_sort(clist,c_id,cIDArrow) - elif (column == c_birth_order) or (column == c_birth_date): - child_change_sort(clist,c_birth_order,cDateArrow) - else: - return + def on_fv_prev_clicked(self,obj): + """makes the currently select child the active person""" + if self.active_child: + self.change_active_person(self.active_child) + self.load_family() - sort_child_list(clist) - if id2col.has_key(active_child): - row = clist.find_row_from_data(id2col[active_child]) - clist.moveto(row) + def on_add_child_clicked(self,obj): + """Select an existing child to add to the active family""" + import SelectChild + if self.active_person: + SelectChild.SelectChild(self.database,self.active_family, + self.active_person,self.load_family) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def child_change_sort(clist,column,arrow): - global c_sort_direct - global c_sort_column + def on_add_new_child_clicked(self,obj): + """Create a new child to add to the existing family""" + import SelectChild + if self.active_person: + SelectChild.NewChild(self.database,self.active_family, + self.active_person,self.update_after_newchild, + GrampsCfg.lastnamegen) - cNameArrow.hide() - cDateArrow.hide() - cIDArrow.hide() - cGenderArrow.hide() - arrow.show() + def on_choose_parents_clicked(self,obj): + import ChooseParents + if self.active_person: + ChooseParents.ChooseParents(self.database,self.active_person, + self.active_parents,self.load_family, + self.full_update) - if c_sort_column == column: - if c_sort_direct == GTK.SORT_DESCENDING: - c_sort_direct = GTK.SORT_ASCENDING - arrow.set(GTK.ARROW_DOWN,2) - else: - c_sort_direct = GTK.SORT_DESCENDING - arrow.set(GTK.ARROW_UP,2) - else: - c_sort_direct = GTK.SORT_ASCENDING - c_sort_column = column - clist.set_sort_type(c_sort_direct) - clist.set_sort_column(c_sort_column) - clist.set_reorderable(c_sort_column == c_birth_order) + def on_new_clicked(self,obj): + """Prompt for permission to close the current database""" + msg = _("Do you want to close the current database and create a new one?") + gnome.ui.GnomeQuestionDialog(msg,self.new_database_response) -def sort_child_list(clist): - clist.freeze() - clist.sort() - clist.sort() - if ListColors.get_enable(): - try: - oddbg = gtk.GdkColor(ListColors.oddbg[0],ListColors.oddbg[1],ListColors.oddbg[2]) - oddfg = gtk.GdkColor(ListColors.oddfg[0],ListColors.oddfg[1],ListColors.oddfg[2]) - evenbg = gtk.GdkColor(ListColors.evenbg[0],ListColors.evenbg[1],ListColors.evenbg[2]) - evenfg = gtk.GdkColor(ListColors.evenfg[0],ListColors.evenfg[1],ListColors.evenfg[2]) - ancestorfg = gtk.GdkColor(ListColors.ancestorfg[0],ListColors.ancestorfg[1],ListColors.ancestorfg[2]) - rows = clist.rows - for i in range(0,rows): - clist.set_background(i,(evenbg,oddbg)[i%2]) - person = clist.get_row_data(i) - if (person.getAncestor()): - clist.set_foreground(i,ancestorfg) - else: - clist.set_foreground(i,(evenfg,oddfg)[i%2]) - except OverflowError: - pass - clist.thaw() - -#------------------------------------------------------------------------- -# -# on_child_list_row_move -# -# Validate whether or not this child can be moved within the clist. -# This routine is called in the middle of the clist's callbacks, so -# the state can be confusing. If the code is being debugged, the -# display at this point shows that the list has been reordered when in -# actuality it hasn't. All accesses to the clist data structure -# reference the state just prior to the "move". -# -# This routine must keep/compute its own list indices as the functions -# list.remove(), list.insert(), list.reverse() etc. do not affect the -# values returned from the list.index() routine. -# -#------------------------------------------------------------------------- -def on_child_list_row_move(clist,fm,to): - family = clist.get_data("f") - - # Create a list based upon the current order of the clist - clist_order = [] - for i in range(clist.rows): - clist_order = clist_order + [clist.get_row_data(i)] - child = clist_order[fm] - - # This function deals with ascending order lists. Convert if - # necessary. - if (c_sort_direct == GTK.SORT_DESCENDING): - clist_order.reverse() - max_index = len(clist_order) - 1 - fm = max_index - fm - to = max_index - to - - # Create a new list to match the requested order - desired_order = clist_order[:fm] + clist_order[fm+1:] - desired_order = desired_order[:to] + [child] + desired_order[to:] - - # Check birth date order in the new list - if (EditPerson.birth_dates_in_order(desired_order) == 0): - clist.emit_stop_by_name("row_move") - gnome.ui.GnomeWarningDialog(_("Invalid move. Children must be ordered by birth date.")) - return - - # OK, this birth order works too. Update the family data structures. - family.setChildList(desired_order) - - # Build a mapping of child item to list position. This would not - # be necessary if indices worked properly - i = 0 - new_order = {} - for tmp in desired_order: - new_order[tmp] = i - i = i + 1 - - # Convert the original list back to whatever ordering is being - # used by the clist itself. - if (c_sort_direct == GTK.SORT_DESCENDING): - clist_order.reverse() - - # Update the clist indices so any change of sorting works - i = 0 - for tmp in clist_order: - clist.set_text(i, c_birth_order, "%2d"%(new_order[tmp]+1)) - i = i + 1 - - # Need to save the changed order - utils.modified() - -def on_open_activate(obj): - wFs = libglade.GladeXML(const.revisionFile, "dbopen") - wFs.signal_autoconnect({ - "on_ok_button1_clicked": on_ok_button1_clicked, - "destroy_passed_object": utils.destroy_passed_object - }) - - fileSelector = wFs.get_widget("dbopen") - dbname = wFs.get_widget("dbname") - getoldrev = wFs.get_widget("getoldrev") - fileSelector.set_data("dbname",dbname) - dbname.set_default_path(Config.db_dir) - fileSelector.set_data("getoldrev",getoldrev) - getoldrev.set_sensitive(Config.usevc) - fileSelector.show() - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_revert_activate(obj): - if database.getSavePath() != "": - msg = _("Do you wish to abandon your changes and revert to the last saved database?") - gnome.ui.GnomeQuestionDialog(msg,revert_query) - else: - msg = _("Cannot revert to a previous database, since one does not exist") - gnome.ui.GnomeWarningDialog(msg) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def revert_query(value): - if value == 0: + def new_database_response(self,val): + if val == 1: + return + self.clear_database() + DbPrompter(self.database,1) + + def clear_database(self): + """Clear out the database if permission was granted""" const.personalEvents = const.initialize_personal_event_list() const.personalAttributes = const.initialize_personal_attribute_list() const.marriageEvents = const.initialize_marriage_event_list() const.familyAttributes = const.initialize_family_attribute_list() const.familyRelations = const.initialize_family_relation_list() - - file = database.getSavePath() - database.new() - read_file(file) - utils.clearModified() - utils.clear_timer() - -#------------------------------------------------------------------------- -# -# Save the file -# -#------------------------------------------------------------------------- -def on_save_as_activate(obj): - wFs = libglade.GladeXML (const.gladeFile, FILESEL) - wFs.signal_autoconnect({ - "on_ok_button1_clicked": on_ok_button2_clicked, - "destroy_passed_object": utils.destroy_passed_object - }) - - fileSelector = wFs.get_widget(FILESEL) - fileSelector.show() - -def on_save_activate(obj): - """Saves the file, first prompting for a comment if revision control needs it""" - if not database.getSavePath(): - on_save_as_activate(obj) - else: - if Config.usevc and Config.vc_comment: - display_comment_box(database.getSavePath()) - else: - save_file(database.getSavePath(),_("No Comment Provided")) - -def on_save_activate_quit(): - """Saves the file, first prompting for a comment if revision control needs it""" - if not database.getSavePath(): - on_save_as_activate(None) - else: - if Config.usevc and Config.vc_comment: - display_comment_box(database.getSavePath()) - else: - save_file(database.getSavePath(),_("No Comment Provided")) - -def display_comment_box(filename): - """Displays a dialog box, prompting for a revison control comment""" - VersionControl.RevisionComment(filename,save_file) -#------------------------------------------------------------------------- -# -# Callbacks for the menu selections to change the view -# -#------------------------------------------------------------------------- -def on_person_list1_activate(obj): - """Switches to the person list view""" - notebook.set_page(0) + self.database.new() + self.topWindow.set_title("GRAMPS") + self.active_person = None + self.active_father = None + self.active_family = None + self.active_mother = None + self.active_child = None + self.active_spouse = None + self.id2col = {} + self.alt2col = {} -def on_family1_activate(obj): - """Switches to the family view""" - notebook.set_page(1) - -def on_pedegree1_activate(obj): - """Switches to the pedigree view""" - notebook.set_page(2) - -def on_sources_activate(obj): - """Switches to the sources view""" - notebook.set_page(3) - -def on_places_activate(obj): - """Switches to the places view""" - notebook.set_page(4) - -def on_media_activate(obj): - """Switches to the media view""" - notebook.set_page(5) - -#------------------------------------------------------------------------- -# -# Load the appropriate page after a notebook switch -# -#------------------------------------------------------------------------- -def on_notebook1_switch_page(obj,junk,page): - if page == 0: - goto_active_person() - merge_button.set_sensitive(1) - elif page == 1: - merge_button.set_sensitive(0) - load_family() - elif page == 2: - merge_button.set_sensitive(0) - pedigree_view.load_canvas(active_person) - elif page == 3: - merge_button.set_sensitive(0) - source_view.load_sources() - elif page == 4: - merge_button.set_sensitive(1) - #place_view.load_places() - elif page == 5: - merge_button.set_sensitive(0) - media_view.load_media() - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_swap_clicked(obj): - if not active_person: - return - if len(active_person.getFamilyList()) > 1: - spouse = gtop.get_widget("fv_spouse").get_menu().get_active().get_data("person") - else: - spouse = gtop.get_widget("fv_spouse1").get_data("person") - - if spouse: - change_active_person(spouse) - load_family() - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_apply_filter_clicked(obj): - global DataFilter - - invert_filter = gtop.get_widget("invert").get_active() - qualifer = gtop.get_widget("filter").get_text() - menu = gtop.get_widget(FILTERNAME).get_menu() - class_init = menu.get_active().get_data("function") - DataFilter = class_init(qualifer) - DataFilter.set_invert(invert_filter) - apply_filter() - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_filter_name_changed(obj): - qlabel = gtop.get_widget("qual") - filter = obj.get_data("filter") - if obj.get_data("qual"): - qlabel.show() - qlabel.set_sensitive(1) - qlabel.set_text(obj.get_data("label")) - filter.show() - else: - qlabel.hide() - filter.hide() + Utils.clearModified() + Utils.clear_timer() + self.change_active_person(None) + self.person_list.clear() + self.load_family() + self.source_view.load_sources() + self.place_view.load_places() + self.media_view.load_media() + + def tool_callback(self,val): + if val: + Utils.modified() + self.full_update() - filter.set_sensitive(obj.get_data("qual")) + def full_update(self): + """Brute force display update, updating all the pages""" + self.id2col = {} + self.alt2col = {} + self.person_list.clear() + self.notebook.set_show_tabs(GrampsCfg.usetabs) + clist = self.gtop.get_widget("child_list") + clist.set_column_visibility(self.c_details,GrampsCfg.show_detail) + clist.set_column_visibility(self.c_id,GrampsCfg.id_visible) + clist.set_column_visibility(self.c_birth_order,GrampsCfg.index_visible) + self.apply_filter() + self.load_family() + self.source_view.load_sources() + self.place_view.load_places() + self.pedigree_view.load_canvas(self.active_person) + self.media_view.load_media() + self.toolbar.set_style(GrampsCfg.toolbar) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_spouselist_changed(obj): - if active_person: - display_marriage(obj.get_data("family")) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def new_after_edit(epo,plist): - if epo: - if epo.person.getId() == "": - database.addPerson(epo.person) + def update_display(self,changed): + """Incremental display update, update only the displayed page""" + page = self.notebook.get_current_page() + if page == 0: + if changed: + self.apply_filter() + else: + self.goto_active_person() + elif page == 1: + self.load_family() + elif page == 2: + self.pedigree_view.load_canvas(self.active_person) + elif page == 3: + self.source_view.load_sources() + elif page == 4: + pass else: - database.addPersonNoMap(epo.person,epo.person.getId()) - change_active_person(epo.person) - redisplay_person_list(epo.person) - for p in plist: - place_view.new_place_after_edit(p) + self.media_view.load_media() -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def update_after_newchild(family,person,plist): - load_family(family) - redisplay_person_list(person) - for p in plist: - place_view.new_place_after_edit(p) + def on_tools_clicked(self,obj): + if self.active_person: + Plugins.ToolPlugins(self.database,self.active_person, + self.tool_callback) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def update_after_edit(epo,plist): - if epo: - remove_from_person_list(epo.person) - redisplay_person_list(epo.person) - for p in plist: - place_view.new_place_after_edit(p) - update_display(0) + def on_reports_clicked(self,obj): + if self.active_person: + Plugins.ReportPlugins(self.database,self.active_person) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def redisplay_person_list(person): - pos = (person,0) - id2col[person] = pos - alt2col[person] = [] - gname = utils.phonebook_from_name - if DataFilter.compare(person): - if person.getGender() == Person.male: - gender = const.male - elif person.getGender() == Person.female: - gender = const.female - else: - gender = const.unknown - bday = person.getBirth().getDateObj() - dday = person.getDeath().getDateObj() - name = person.getPrimaryName() - person_list.insert(0,[gname(name,0),person.getId(), - gender,bday.getQuoteDate(), - dday.getQuoteDate(), - sort.build_sort_name(name), - sort.build_sort_date(bday), - sort.build_sort_date(dday)]) - - person_list.set_row_data(0,pos) - - if Config.hide_altnames == 0: - for name in person.getAlternateNames(): - pos2 = (person,0) - alt2col[person].append(pos2) - person_list.insert(0,[gname(name,1),person.getId(), - gender,bday.getQuoteDate(), - dday.getQuoteDate(), - sort.build_sort_name(name), - sort.build_sort_date(bday), - sort.build_sort_date(dday)]) - - person_list.set_row_data(0,pos2) - - sort_person_list() - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def load_person(person): - if person: - EditPerson.EditPerson(person,database,update_after_edit) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def load_family(family=None): - global active_mother - global active_parents - global active_spouse - global active_family - - if family != None: - active_family = family + def on_ok_button1_clicked(self,obj): - family_types = [] - main_family = None + dbname = obj.get_data("dbname") + getoldrev = obj.get_data("getoldrev") + filename = dbname.get_full_path(0) + Utils.destroy_passed_object(obj) - gtop.get_widget("fv_person").set_text(Config.nameof(active_person)) - - if active_person: - main_family = active_person.getMainFamily() - active_parents = main_family - family_types = active_person.getAltFamilyList() - - if active_parents == None and len(family_types) > 0: - fam = family_types[0] - active_parents = fam[0] - else: - active_parents = None - - if len(family_types) > 0: - typeMenu = gtk.GtkMenu() - if main_family: - menuitem = gtk.GtkMenuItem(_("Birth")) - menuitem.set_data("parents",main_family) - menuitem.connect("activate",on_current_type_changed) - menuitem.show() - typeMenu.append(menuitem) - for fam in family_types: - if active_person == fam[0].getFather(): - menuitem = gtk.GtkMenuItem("%s/%s" % (fam[1],fam[2])) - else: - menuitem = gtk.GtkMenuItem("%s/%s" % (fam[2],fam[1])) - menuitem.set_data("parents",fam[0]) - menuitem.connect("activate",on_current_type_changed) - menuitem.show() - typeMenu.append(menuitem) - gtop.get_widget("childtype").set_menu(typeMenu) - gtop.get_widget("childtype").show() - else: - gtop.get_widget("childtype").hide() - - change_parents(active_parents) - - if active_person: - number_of_families = len(active_person.getFamilyList()) - if number_of_families > 1: - myMenu = gtk.GtkMenu() - index = 0 - opt_index = 0 - for f in active_person.getFamilyList(): - person = None - if f.getMother() == active_person: - if f.getFather() != None: - person = f.getFather() - else: - if f.getMother() != None: - person = f.getMother() - - menuitem = gtk.GtkMenuItem(Config.nameof(person)) - myMenu.append(menuitem) - menuitem.set_data("person",person) - menuitem.set_data("family",f) - menuitem.connect("activate",on_spouselist_changed) - menuitem.show() - if family and f == family: - opt_index = index - index = index + 1 - gtop.get_widget("fv_spouse").set_menu(myMenu) - gtop.get_widget("fv_spouse").set_history(opt_index) - gtop.get_widget("lab_or_list").set_page(1) - gtop.get_widget("edit_sp").set_sensitive(1) - gtop.get_widget("delete_sp").set_sensitive(1) - elif number_of_families == 1: - gtop.get_widget("lab_or_list").set_page(0) - f = active_person.getFamilyList()[0] - if active_person != f.getFather(): - spouse = f.getFather() - else: - spouse = f.getMother() - active_spouse = spouse - fv_spouse1 = gtop.get_widget("fv_spouse1") - fv_spouse1.set_text(Config.nameof(spouse)) - fv_spouse1.set_data("person",spouse) - fv_spouse1.set_data("family",active_person.getFamilyList()[0]) - gtop.get_widget("edit_sp").set_sensitive(1) - gtop.get_widget("delete_sp").set_sensitive(1) - else: - gtop.get_widget("lab_or_list").set_page(0) - gtop.get_widget("fv_spouse1").set_text("") - fv_spouse1 = gtop.get_widget("fv_spouse1") - fv_spouse1.set_text("") - fv_spouse1.set_data("person",None) - fv_spouse1.set_data("family",None) - active_spouse = None - gtop.get_widget("edit_sp").set_sensitive(0) - gtop.get_widget("delete_sp").set_sensitive(0) - - if number_of_families > 0: - if family: - display_marriage(family) - else: - display_marriage(active_person.getFamilyList()[0]) - else: - display_marriage(None) - else: - fv_spouse1 = gtop.get_widget("fv_spouse1").set_text("") - display_marriage(None) + if filename == "" or filename == None: + return -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def change_parents(family): - global active_father - global active_mother + self.clear_database() - if active_parents and active_parents.getRelationship() == "Partners": - fn = _("Parent") - mn = _("Parent") - else: - fn = _("Father") - mn = _("Mother") - - gtop.get_widget("editFather").children()[0].set_text(fn) - gtop.get_widget("editMother").children()[0].set_text(mn) - - fv_father = gtop.get_widget("fv_father") - fv_mother = gtop.get_widget("fv_mother") - father_next = gtop.get_widget("father_next") - mother_next = gtop.get_widget("mother_next") - - if family != None : - active_father = family.getFather() - if active_father != None : - fv_father.set_text(Config.nameof(active_father)) - father_next.set_sensitive(1) - else : - fv_father.set_text("") - father_next.set_sensitive(0) - - active_mother = family.getMother() - if active_mother != None : - fv_mother.set_text(Config.nameof(active_mother)) - mother_next.set_sensitive(1) - else : - fv_mother.set_text("") - mother_next.set_sensitive(0) - elif active_person == None: - fv_father.set_text("") - fv_mother.set_text("") - mother_next.set_sensitive(0) - father_next.set_sensitive(0) - active_father = None - active_mother = None - else : - fv_father.set_text("") - fv_mother.set_text("") - mother_next.set_sensitive(0) - father_next.set_sensitive(0) - active_father = None - active_mother = None - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def display_marriage(family): - global active_child - global active_family - global active_spouse - - active_family = family - clist = gtop.get_widget("child_list") - fv_prev = gtop.get_widget("fv_prev") - - clist.clear() - active_child = None - - i = 0 - clist.set_sort_type(c_sort_direct) - clist.set_sort_column(c_sort_column) - clist.set_reorderable(c_sort_column == c_birth_order) - - if family != None: - if active_person.getGender() == Person.male: - active_spouse = family.getMother() + if getoldrev.get_active(): + vc = VersionControl.RcsVersionControl(filename) + VersionControl.RevisionSelect(self.database,filename,vc, + self.load_revision) else: - active_spouse = family.getFather() + self.auto_save_load(filename) + + def auto_save_load(self,filename): + + if os.path.isdir(filename): + dirname = filename + else: + dirname = os.path.dirname(filename) + autosave = "%s/autosave.gramps" % dirname + + if os.path.isfile(autosave): + q = _("An autosave file exists for %s.\nShould this be loaded instead of the last saved version?") % dirname + self.yname = autosave + self.nname = filename + gnome.ui.GnomeQuestionDialog(q,self.autosave_query) + else: + self.read_file(filename) + + def autosave_query(self,value): + if value == 0: + self.read_file(self.yname) + else: + self.read_file(self.nname) + + def read_file(self,filename): + base = os.path.basename(filename) + if base == const.indexFile: + filename = os.path.dirname(filename) + elif base == "autosave.gramps": + filename = os.path.dirname(filename) + elif not os.path.isdir(filename): + self.displayError(_("%s is not a directory") % filename) + return + + self.statusbar.set_status(_("Loading %s ...") % filename) + + if self.load_database(filename) == 1: + if filename[-1] == '/': + filename = filename[:-1] + name = os.path.basename(filename) + self.topWindow.set_title("%s - %s" % (name,_("GRAMPS"))) + else: + self.statusbar.set_status("") + GrampsCfg.save_last_file("") + + def on_ok_button2_clicked(self,obj): + filename = obj.get_filename() + if filename: + Utils.destroy_passed_object(obj) + if GrampsCfg.usevc and GrampsCfg.vc_comment: + self.display_comment_box(filename) + else: + self.save_file(filename,_("No Comment Provided")) + + def save_file(self,filename,comment): + import WriteXML + + path = filename + filename = os.path.normpath(filename) + autosave = "%s/autosave.gramps" % filename + + self.statusbar.set_status(_("Saving %s ...") % filename) + + Utils.clearModified() + Utils.clear_timer() + + if os.path.exists(filename): + if os.path.isdir(filename) == 0: + self.displayError(_("%s is not a directory") % filename) + return + else: + try: + os.mkdir(filename) + except IOError, msg: + gnome.ui.GnomeErrorDialog(_("Could not create %s") % filename +\ + "\n" + str(msg)) + return + except OSError, msg: + gnome.ui.GnomeErrorDialog(_("Could not create %s") % filename + \ + "\n" + str(msg)) + return + except: + gnome.ui.GnomeErrorDialog(_("Could not create %s") % filename) + return + + old_file = filename + filename = filename + os.sep + const.indexFile + try: + WriteXML.exportData(self.database,filename,self.load_progress) + except IOError, msg: + gnome.ui.GnomeErrorDialog(_("Could not create %s") % filename +\ + "\n" + str(msg)) + return + except OSError, msg: + gnome.ui.GnomeErrorDialog(_("Could not create %s") % filename + \ + "\n" + str(msg)) + return + + self.database.setSavePath(old_file) + GrampsCfg.save_last_file(old_file) + + if GrampsCfg.usevc: + vc = VersionControl.RcsVersionControl(path) + vc.checkin(filename,comment,not GrampsCfg.uncompress) + + filename = self.database.getSavePath() + if filename[-1] == '/': + filename = filename[:-1] + name = os.path.basename(filename) + self.topWindow.set_title("%s - %s" % (name,_("GRAMPS"))) + self.statusbar.set_status("") + self.statusbar.set_progress(0) + if os.path.exists(autosave): + try: + os.remove(autosave) + except: + pass + + def autosave_database(self): + import WriteXML + + path = self.database.getSavePath() + filename = os.path.normpath(path) + Utils.clear_timer() + + filename = "%s/autosave.gramps" % (self.database.getSavePath()) + + self.statusbar.set_status(_("autosaving...")); + try: + WriteXML.quick_write(self.database,filename,self.quick_progress) + self.statusbar.set_status(_("autosave complete")); + except (IOError,OSError): + self.statusbar.set_status(_("autosave failed")); + except: + import traceback + traceback.print_exc() + return 0 + + def load_selected_people(self,obj): + """Display the selected people in the EditPerson display""" + if len(self.person_list.selection) > 5: + msg = _("You requested too many people to edit at the same time") + gnome.ui.GnomeErrorDialog(msg) + else: + for p in self.person_list.selection: + (person,x) = self.person_list.get_row_data(p) + self.load_person(person) + + def load_active_person(self,obj): + self.load_person(self.active_person) + + def on_edit_spouse_clicked(self,obj): + """Display the active spouse in the EditPerson display""" + self.load_person(self.active_spouse) + + def on_edit_mother_clicked(self,obj): + """Display the active mother in the EditPerson display""" + self.load_person(self.active_mother) + + def on_edit_father_clicked(self,obj): + """Display the active father in the EditPerson display""" + self.load_person(self.active_father) + + def load_new_person(self,obj): + self.active_person = Person() + EditPerson.EditPerson(self.active_person,self.database, + self.new_after_edit) + + def on_delete_person_clicked(self,obj): + if len(self.person_list.selection) == 1: + msg = _("Do you really wish to delete %s?") % \ + GrampsCfg.nameof(self.active_person) + gnome.ui.GnomeQuestionDialog( msg, self.delete_person_response) + elif len(self.person_list.selection) > 1: + gnome.ui.GnomeErrorDialog(_("Currently, you can only delete one person at a time")) + + def delete_person_response(self,val): + if val == 1: + return + + personmap = self.database.getPersonMap() + familymap = self.database.getPersonMap() + + for family in self.active_person.getFamilyList(): + if self.active_person.getGender == Person.male: + if family.getMother() == None: + for child in family.getChildList(): + child.setMainFamily(None) + del familymap[family] + else: + family.setFather(None) + else: + if family.getFather() == None: + for child in family.getChildList(): + child.setMainFamily(None) + del familymap[family] + else: + family.setMother(None) + + family = self.active_person.getMainFamily() + if family: + family.removeChild(self.active_person) - child_list = family.getChildList() - child_list.sort(sort.by_birthdate) + del personmap[self.active_person.getId()] + self.remove_from_person_list(self.active_person) + self.person_list.sort() + self.update_display(0) + Utils.modified() - attr = "" - for child in child_list: - status = _("Unknown") - if child.getGender() == Person.male: - gender = const.male - elif child.getGender() == Person.female: - gender = const.female + def remove_from_person_list(self,person): + + self.person_list.freeze() + if self.id2col.has_key(person): + for id in [self.id2col[person]] + self.alt2col[person]: + row = self.person_list.find_row_from_data(id) + self.person_list.remove(row) + + del self.id2col[person] + del self.alt2col[person] + + if row > self.person_list.rows: + (self.active_person,x) = self.person_list.get_row_data(row) + self.person_list.thaw() + + def merge_update(self,p1,p2): + self.remove_from_person_list(p1) + self.remove_from_person_list(p2) + self.redisplay_person_list(p1) + + def on_delete_parents_clicked(self,obj): + if not self.active_parents: + return + + self.active_parents.removeChild(self.active_person) + if self.active_parents == self.active_person.getMainFamily(): + self.active_person.setMainFamily(None) + else: + self.active_person.removeAltFamily(self.active_parents) + self.load_family() + + def on_person_list_select_row(self,obj,row,b,c): + if row == obj.selection[0]: + (person,x) = obj.get_row_data(row) + self.change_active_person(person) + + def on_person_list_click_column(self,obj,column): + self.change_sort(column) + + + def set_sort_arrow(self,column,direct): + + arrow = self.col_arr[column] + for a in self.col_arr: + if arrow != a: + a.hide() + arrow.show() + if direct == GTK.SORT_ASCENDING: + arrow.set(GTK.ARROW_DOWN,2) + else: + arrow.set(GTK.ARROW_UP,2) + + def change_sort(self,column,change=1): + + arrow = self.col_arr[column] + for a in self.col_arr: + if arrow != a: + a.hide() + arrow.show() + + self.person_list.set_sort_column(self.col_map[column]) + self.person_list.set_sort_type(self.sort_direct) + + self.sort_person_list() + + if change: + if self.sort_column == column: + if self.sort_direct == GTK.SORT_DESCENDING: + self.sort_direct = GTK.SORT_ASCENDING + arrow.set(GTK.ARROW_DOWN,2) + else: + self.sort_direct = GTK.SORT_DESCENDING + arrow.set(GTK.ARROW_UP,2) else: - gender = const.unknown - if child.getMainFamily() == family: - status = _("Birth") + self.sort_direct = GTK.SORT_ASCENDING + arrow.set(GTK.ARROW_DOWN,2) + self.sort_column = column + + if self.id2col.has_key(self.active_person): + data = self.id2col[self.active_person] + row = self.person_list.find_row_from_data(data) + self.person_list.moveto(row) + GrampsCfg.save_sort_cols("person",self.sort_column,self.sort_direct) + + def sort_person_list(self): + self.person_list.freeze() + self.person_list.sort() + self.person_list.sort() + if ListColors.get_enable(): + try: + loddbg = ListColors.oddbg + loddfg = ListColors.oddfg + levenbg = ListColors.evenbg + levenfg = ListColors.evenfg + + oddbg = gtk.GdkColor(loddbg[0],loddbg[1],loddbg[2]) + oddfg = gtk.GdkColor(loddfg[0],loddfg[1],loddfg[2]) + evenbg = gtk.GdkColor(levenbg[0],levenbg[1],levenbg[2]) + evenfg = gtk.GdkColor(levenfg[0],levenfg[1],levenfg[2]) + rows = self.person_list.rows + for i in range(0,rows,2): + self.person_list.set_background(i,oddbg) + self.person_list.set_foreground(i,oddfg) + if i != rows: + self.person_list.set_background(i+1,evenbg) + self.person_list.set_foreground(i+1,evenfg) + except OverflowError: + pass + self.goto_active_person() + self.person_list.thaw() + + def on_child_list_button_press_event(self,obj,event): + if event.button == 1 and event.type == GDK._2BUTTON_PRESS: + self.load_person(self.active_child) + + def on_person_list_button_press(self,obj,event): + if event.button == 1 and event.type == GDK._2BUTTON_PRESS: + self.load_person(self.active_person) + + def goto_active_person(self,): + if self.id2col.has_key(self.active_person): + pos = self.id2col[self.active_person] + column = self.person_list.find_row_from_data(pos) + if column != -1: + self.person_list.unselect_all() + self.person_list.select_row(column,0) + self.person_list.moveto(column) else: - for fam in child.getAltFamilyList(): - if fam[0] == family: - if active_person == family.getFather(): - status = "%s/%s" % (_(fam[2]),_(fam[1])) - else: - status = "%s/%s" % (_(fam[1]),_(fam[2])) - - if Config.show_detail: - attr = "" - if child.getNote() != "": - attr = attr + "N" - if len(child.getEventList())>0: - attr = attr + "E" - if len(child.getAttributeList())>0: - attr = attr + "A" - if len(child.getFamilyList()) > 0: - for f in child.getFamilyList(): - if f.getFather() and f.getMother(): - attr = attr + "M" - break - if len(child.getPhotoList()) > 0: - attr = attr + "P" - - clist.append(["%2d"%(i+1),Config.nameof(child),child.getId(),\ - gender,utils.birthday(child),status,attr]) - clist.set_row_data(i,child) - i=i+1 - if i != 0: - fv_prev.set_sensitive(1) - clist.select_row(0,0) - else: - fv_prev.set_sensitive(0) - clist.set_data("f",family) - sort_child_list(clist) - else: - fv_prev.set_sensitive(0) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def load_progress(value): - statusbar.set_progress(value) - while gtk.events_pending(): - gtk.mainiteration() - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def quick_progress(value): - gtk.threads_enter() - statusbar.set_progress(value) - while gtk.events_pending(): - gtk.mainiteration() - gtk.threads_leave() - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def post_load(name): - global active_person - - database.setSavePath(name) - res = database.getResearcher() - owner = Config.get_researcher() + if self.person_list.rows > 0: + self.person_list.unselect_all() + self.person_list.select_row(0,0) + self.person_list.moveto(0) + (person,x) = self.person_list.get_row_data(0) + self.change_active_person(person) - if res.getName() == "" and owner.getName() != "": - database.setResearcher(owner) - utils.modified() - - setup_bookmarks() - - mylist = database.getPersonEventTypes() - for type in mylist: - ntype = const.display_pevent(type) - if ntype not in const.personalEvents: - const.personalEvents.append(ntype) - - mylist = database.getFamilyEventTypes() - for type in mylist: - ntype = const.display_fevent(type) - if ntype not in const.marriageEvents: - const.marriageEvents.append(ntype) - - mylist = database.getPersonAttributeTypes() - for type in mylist: - ntype = const.display_pattr(type) - if ntype not in const.personalAttributes: - const.personalAttributes.append(ntype) - - mylist = database.getFamilyAttributeTypes() - for type in mylist: - if type not in const.familyAttributes: - const.familyAttributes.append(type) - - mylist = database.getFamilyRelationTypes() - for type in mylist: - if type not in const.familyRelations: - const.familyRelations.append(type) - - Config.save_last_file(name) - gtop.get_widget("filter").set_text("") + def change_active_person(self,person): + self.active_person = person + self.modify_statusbar() - person = database.getDefaultPerson() - if person: - active_person = person - for person in database.getPersonMap().values(): - if active_person == None: - active_person = person - lastname = person.getPrimaryName().getSurname() - if lastname and lastname not in const.surnames: - const.surnames.append(lastname) - const.surnames.sort() - - statusbar.set_progress(1.0) - full_update() - statusbar.set_progress(0.0) - return 1 - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def load_database(name): - filename = "%s/%s" % (name,const.indexFile) - if ReadXML.loadData(database,filename,load_progress) == 0: + def modify_statusbar(self): + if self.active_person == None: + self.statusbar.set_status("") + else: + pname = GrampsCfg.nameof(self.active_person) + if GrampsCfg.status_bar == 1: + name = "[%s] %s" % (self.active_person.getId(),pname) + elif GrampsCfg.status_bar == 2: + name = pname + for attr in self.active_person.getAttributeList(): + if attr.getType() == GrampsCfg.attr_name: + name = "[%s] %s" % (attr.getValue(),pname) + break + else: + name = pname + self.statusbar.set_status(name) return 0 - return post_load(name) + + def on_child_list_select_row(self,obj,row,b,c): + self.active_child = obj.get_row_data(row) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def load_revision(f,name,revision): - filename = "%s/%s" % (name,const.indexFile) - if ReadXML.loadRevision(database,f,filename,revision,load_progress) == 0: - return 0 - return post_load(name) + def on_child_list_click_column(self,clist,column): + """Called when the user selects a column header on the self.person_list + window. Change the sort function (column 0 is the name column, and column + 2 is the birthdate column), set the arrows on the labels to the correct + orientation, and then call apply_filter to redraw the list""" + if column == self.c_name: + self.child_change_sort(clist,self.c_name,self.cNameArrow) + elif column == self.c_gender: + self.child_change_sort(clist,self.c_gender,self.cGenderArrow) + elif column == self.c_id: + self.child_change_sort(clist,self.c_id,self.cIDArrow) + elif column == self.c_birth_order or column == self.c_birth_date: + self.child_change_sort(clist,self.c_birth_order,self.cDateArrow) + else: + return -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def setup_bookmarks(): - global bookmarks - bookmarks = Bookmarks.Bookmarks(database.getBookmarks(), - gtop.get_widget("jump_to"), - bookmark_callback) + self.sort_child_list(clist) + if self.id2col.has_key(self.active_child): + row = clist.find_row_from_data(self.id2col[self.active_child]) + clist.moveto(row) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def displayError(msg): - gnome.ui.GnomeErrorDialog(msg) - statusbar.set_status("") - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def apply_filter(): - global id2col - global alt2col - - person_list.freeze() - datacomp = DataFilter.compare - gname = utils.phonebook_from_name - - person_list.set_column_visibility(1,Config.id_visible) - new_alt2col = {} + def child_change_sort(self,clist,column,arrow): + self.cNameArrow.hide() + self.cDateArrow.hide() + self.cIDArrow.hide() + self.cGenderArrow.hide() + arrow.show() - bsn = sort.build_sort_name - bsd = sort.build_sort_date - for person in database.getPersonMap().values(): - if datacomp(person): - if id2col.has_key(person): - new_alt2col[person] = alt2col[person] - continue - pos = (person,0) - id2col[person] = pos - new_alt2col[person] = [] + if self.c_sort_column == column: + if self.c_sort_direct == GTK.SORT_DESCENDING: + self.c_sort_direct = GTK.SORT_ASCENDING + arrow.set(GTK.ARROW_DOWN,2) + else: + self.c_sort_direct = GTK.SORT_DESCENDING + arrow.set(GTK.ARROW_UP,2) + else: + self.c_sort_direct = GTK.SORT_ASCENDING + self.c_sort_column = column + clist.set_sort_type(self.c_sort_direct) + clist.set_sort_column(self.c_sort_column) + clist.set_reorderable(self.c_sort_column == self.c_birth_order) + def sort_child_list(self,clist): + clist.freeze() + clist.sort() + clist.sort() + if ListColors.get_enable(): + try: + loddbg = ListColors.oddbg + loddfg = ListColors.oddfg + levenbg = ListColors.evenbg + levenfg = ListColors.evenfg + lafg = ListColors.ancestorfg + + oddbg = gtk.GdkColor(loddbg[0],loddbg[1],loddbg[2]) + oddfg = gtk.GdkColor(loddfg[0],loddfg[1],loddfg[2]) + evenbg = gtk.GdkColor(levenbg[0],levenbg[1],levenbg[2]) + evenfg = gtk.GdkColor(levenfg[0],levenfg[1],levenfg[2]) + ancestorfg = gtk.GdkColor(lafg[0],lafg[1],lafg[2]) + rows = clist.rows + for i in range(0,rows): + clist.set_background(i,(evenbg,oddbg)[i%2]) + person = clist.get_row_data(i) + if (person.getAncestor()): + clist.set_foreground(i,ancestorfg) + else: + clist.set_foreground(i,(evenfg,oddfg)[i%2]) + except OverflowError: + pass + clist.thaw() + + def on_child_list_row_move(self,clist,fm,to): + """Validate whether or not this child can be moved within the clist. + This routine is called in the middle of the clist's callbacks, so + the state can be confusing. If the code is being debugged, the + display at this point shows that the list has been reordered when in + actuality it hasn't. All accesses to the clist data structure + reference the state just prior to the move. + + This routine must keep/compute its own list indices as the functions + list.remove(), list.insert(), list.reverse() etc. do not affect the + values returned from the list.index() routine.""" + + family = clist.get_data("f") + + # Create a list based upon the current order of the clist + clist_order = [] + for i in range(clist.rows): + clist_order = clist_order + [clist.get_row_data(i)] + child = clist_order[fm] + + # This function deals with ascending order lists. Convert if + # necessary. + if (self.c_sort_direct == GTK.SORT_DESCENDING): + clist_order.reverse() + max_index = len(clist_order) - 1 + fm = max_index - fm + to = max_index - to + + # Create a new list to match the requested order + desired_order = clist_order[:fm] + clist_order[fm+1:] + desired_order = desired_order[:to] + [child] + desired_order[to:] + + # Check birth date order in the new list + if (EditPerson.birth_dates_in_order(desired_order) == 0): + clist.emit_stop_by_name("row_move") + gnome.ui.GnomeWarningDialog(_("Invalid move. Children must be ordered by birth date.")) + return + + # OK, this birth order works too. Update the family data structures. + family.setChildList(desired_order) + + # Build a mapping of child item to list position. This would not + # be necessary if indices worked properly + i = 0 + new_order = {} + for tmp in desired_order: + new_order[tmp] = i + i = i + 1 + + # Convert the original list back to whatever ordering is being + # used by the clist itself. + if (self.c_sort_direct == GTK.SORT_DESCENDING): + clist_order.reverse() + + # Update the clist indices so any change of sorting works + i = 0 + for tmp in clist_order: + clist.set_text(i, self.c_birth_order, "%2d"%(new_order[tmp]+1)) + i = i + 1 + + # Need to save the changed order + Utils.modified() + + def on_open_activate(self,obj): + wFs = libglade.GladeXML(const.revisionFile, "dbopen") + wFs.signal_autoconnect({ + "on_ok_button1_clicked": self.on_ok_button1_clicked, + "destroy_passed_object": Utils.destroy_passed_object + }) + + fileSelector = wFs.get_widget("dbopen") + dbname = wFs.get_widget("dbname") + getoldrev = wFs.get_widget("getoldrev") + fileSelector.set_data("dbname",dbname) + dbname.set_default_path(GrampsCfg.db_dir) + fileSelector.set_data("getoldrev",getoldrev) + getoldrev.set_sensitive(GrampsCfg.usevc) + fileSelector.show() + + def on_revert_activate(self,obj): + if self.database.getSavePath() != "": + msg = _("Do you wish to abandon your changes and revert to the last saved database?") + gnome.ui.GnomeQuestionDialog(msg,self.revert_query) + else: + msg = _("Cannot revert to a previous database, since one does not exist") + gnome.ui.GnomeWarningDialog(msg) + + def revert_query(self,value): + if value == 0: + const.personalEvents = const.initialize_personal_event_list() + const.personalAttributes = const.initialize_personal_attribute_list() + const.marriageEvents = const.initialize_marriage_event_list() + const.familyAttributes = const.initialize_family_attribute_list() + const.familyRelations = const.initialize_family_relation_list() + + file = self.database.getSavePath() + self.database.new() + self.read_file(file) + Utils.clearModified() + Utils.clear_timer() + + def on_save_as_activate(self,obj): + wFs = libglade.GladeXML (const.gladeFile, "fileselection") + wFs.signal_autoconnect({ + "on_ok_button1_clicked": self.on_ok_button2_clicked, + "destroy_passed_object": Utils.destroy_passed_object + }) + + fileSelector = wFs.get_widget("fileselection") + fileSelector.show() + + def on_save_activate(self,obj): + """Saves the file, first prompting for a comment if revision + control needs it""" + if not self.database.getSavePath(): + self.on_save_as_activate(obj) + else: + if GrampsCfg.usevc and GrampsCfg.vc_comment: + self.display_comment_box(self.database.getSavePath()) + else: + self.save_file(self.database.getSavePath(),_("No Comment Provided")) + + def on_save_activate_quit(self): + """Saves the file, first prompting for a comment if revision + control needs it""" + if not self.database.getSavePath(): + self.on_save_as_activate(None) + else: + if GrampsCfg.usevc and GrampsCfg.vc_comment: + self.display_comment_box(self.database.getSavePath()) + else: + self.save_file(self.database.getSavePath(),_("No Comment Provided")) + + def display_comment_box(self,filename): + """Displays a dialog box, prompting for a revison control comment""" + VersionControl.RevisionComment(filename,self.save_file) + + def on_person_list1_activate(self,obj): + """Switches to the person list view""" + self.notebook.set_page(0) + + def on_family1_activate(self,obj): + """Switches to the family view""" + self.notebook.set_page(1) + + def on_pedegree1_activate(self,obj): + """Switches to the pedigree view""" + self.notebook.set_page(2) + + def on_sources_activate(self,obj): + """Switches to the sources view""" + self.notebook.set_page(3) + + def on_places_activate(self,obj): + """Switches to the places view""" + self.notebook.set_page(4) + + def on_media_activate(self,obj): + """Switches to the media view""" + self.notebook.set_page(5) + + def on_notebook1_switch_page(self,obj,junk,page): + """Load the appropriate page after a notebook switch""" + if page == 0: + self.goto_active_person() + self.merge_button.set_sensitive(1) + elif page == 1: + self.merge_button.set_sensitive(0) + self.load_family() + elif page == 2: + self.merge_button.set_sensitive(0) + self.pedigree_view.load_canvas(self.active_person) + elif page == 3: + self.merge_button.set_sensitive(0) + self.source_view.load_sources() + elif page == 4: + self.merge_button.set_sensitive(1) + elif page == 5: + self.merge_button.set_sensitive(0) + self.media_view.load_media() + + def on_swap_clicked(self,obj): + if not self.active_person: + return + if len(self.active_person.getFamilyList()) > 1: + spouse = self.gtop.get_widget("fv_spouse").get_menu().get_active().get_data("person") + else: + spouse = self.gtop.get_widget("fv_spouse1").get_data("person") + + if spouse: + self.change_active_person(spouse) + self.load_family() + + def on_apply_filter_clicked(self,obj): + invert_filter = self.gtop.get_widget("invert").get_active() + qualifer = self.gtop.get_widget("filter").get_text() + menu = self.gtop.get_widget("filter_list").get_menu() + class_init = menu.get_active().get_data("function") + self.DataFilter = class_init(qualifer) + self.DataFilter.set_invert(invert_filter) + self.apply_filter() + + def on_filter_name_changed(self,obj): + qlabel = self.gtop.get_widget("qual") + filter = obj.get_data("filter") + if obj.get_data("qual"): + qlabel.show() + qlabel.set_sensitive(1) + qlabel.set_text(obj.get_data("label")) + filter.show() + else: + qlabel.hide() + filter.hide() + + filter.set_sensitive(obj.get_data("qual")) + + def on_spouselist_changed(self,obj): + if self.active_person: + self.display_marriage(obj.get_data("family")) + + def new_after_edit(self,epo,plist): + if epo: + if epo.person.getId() == "": + self.database.addPerson(epo.person) + else: + self.database.addPersonNoMap(epo.person,epo.person.getId()) + self.change_active_person(epo.person) + self.redisplay_person_list(epo.person) + for p in plist: + self.place_view.new_place_after_edit(p) + + def update_after_newchild(self,family,person,plist): + self.load_family(family) + self.redisplay_person_list(person) + for p in plist: + self.place_view.new_place_after_edit(p) + + def update_after_edit(self,epo,plist): + if epo: + self.remove_from_person_list(epo.person) + self.redisplay_person_list(epo.person) + for p in plist: + self.place_view.new_place_after_edit(p) + self.update_display(0) + + def redisplay_person_list(self,person): + pos = (person,0) + self.id2col[person] = pos + self.alt2col[person] = [] + gname = Utils.phonebook_from_name + if self.DataFilter.compare(person): if person.getGender() == Person.male: gender = const.male elif person.getGender() == Person.female: gender = const.female else: gender = const.unknown - - name = person.getPrimaryName() bday = person.getBirth().getDateObj() dday = person.getDeath().getDateObj() - sort_bday = bsd(bday) - sort_dday = bsd(dday) - qbday = bday.getQuoteDate() - qdday = dday.getQuoteDate() - pid = person.getId() + name = person.getPrimaryName() + self.person_list.insert(0,[gname(name,0),person.getId(), + gender,bday.getQuoteDate(), + dday.getQuoteDate(), + sort.build_sort_name(name), + sort.build_sort_date(bday), + sort.build_sort_date(dday)]) - values = [gname(name,0), pid, gender, qbday, qdday, - bsn(name), sort_bday, sort_dday ] - person_list.insert(0,values) - person_list.set_row_data(0,pos) + self.person_list.set_row_data(0,pos) - if Config.hide_altnames: - continue + if GrampsCfg.hide_altnames == 0: + for name in person.getAlternateNames(): + pos2 = (person,0) + self.alt2col[person].append(pos2) + self.person_list.insert(0,[gname(name,1),person.getId(), + gender,bday.getQuoteDate(), + dday.getQuoteDate(), + sort.build_sort_name(name), + sort.build_sort_date(bday), + sort.build_sort_date(dday)]) - for name in person.getAlternateNames(): - pos = (person,0) - new_alt2col[person].append(pos) + self.person_list.set_row_data(0,pos2) + self.sort_person_list() - values = [gname(name,1), pid, gender, qbday, qdday, - bsn(name), sort_bday, sort_dday] - person_list.insert(0,values) - person_list.set_row_data(0,pos) - + def load_person(self,person): + if person: + EditPerson.EditPerson(person,self.database, + self.update_after_edit) + + def load_family(self,family=None): + if family != None: + self.active_family = family + + family_types = [] + main_family = None + + self.gtop.get_widget("fv_person").set_text(GrampsCfg.nameof(self.active_person)) + + if self.active_person: + main_family = self.active_person.getMainFamily() + self.active_parents = main_family + family_types = self.active_person.getAltFamilyList() + + if self.active_parents == None and len(family_types) > 0: + fam = family_types[0] + self.active_parents = fam[0] else: - if id2col.has_key(person): - pid = id2col[person] - del id2col[person] + self.active_parents = None - for id in [pid] + alt2col[person]: - row = person_list.find_row_from_data(id) - person_list.remove(row) + if len(family_types) > 0: + typeMenu = gtk.GtkMenu() + if main_family: + menuitem = gtk.GtkMenuItem(_("Birth")) + menuitem.set_data("parents",main_family) + menuitem.connect("activate",self.on_current_type_changed) + menuitem.show() + typeMenu.append(menuitem) + for fam in family_types: + if self.active_person == fam[0].getFather(): + menuitem = gtk.GtkMenuItem("%s/%s" % (fam[1],fam[2])) + else: + menuitem = gtk.GtkMenuItem("%s/%s" % (fam[2],fam[1])) + menuitem.set_data("parents",fam[0]) + menuitem.connect("activate",self.on_current_type_changed) + menuitem.show() + typeMenu.append(menuitem) + self.gtop.get_widget("childtype").set_menu(typeMenu) + self.gtop.get_widget("childtype").show() + else: + self.gtop.get_widget("childtype").hide() - alt2col = new_alt2col - person_list.thaw() - sort_person_list() + self.change_parents(self.active_parents) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_home_clicked(obj): - temp = database.getDefaultPerson() - if temp: - change_active_person(temp) - update_display(0) - else: - gnome.ui.GnomeErrorDialog(_("No default/home person has been set")) + if self.active_person: + number_of_families = len(self.active_person.getFamilyList()) + if number_of_families > 1: + myMenu = gtk.GtkMenu() + index = 0 + opt_index = 0 + for f in self.active_person.getFamilyList(): + person = None + if f.getMother() == self.active_person: + if f.getFather() != None: + person = f.getFather() + else: + if f.getMother() != None: + person = f.getMother() -#------------------------------------------------------------------------- -# -# Bookmark interface -# -#------------------------------------------------------------------------- -def on_add_bookmark_activate(obj): - bookmarks.add(active_person) - name = Config.nameof(active_person) - statusbar.set_status(_("%s has been bookmarked") % name) - gtk.timeout_add(5000,modify_statusbar) + menuitem = gtk.GtkMenuItem(GrampsCfg.nameof(person)) + myMenu.append(menuitem) + menuitem.set_data("person",person) + menuitem.set_data("family",f) + menuitem.connect("activate",self.on_spouselist_changed) + menuitem.show() + if family and f == family: + opt_index = index + index = index + 1 + self.gtop.get_widget("fv_spouse").set_menu(myMenu) + self.gtop.get_widget("fv_spouse").set_history(opt_index) + self.gtop.get_widget("lab_or_list").set_page(1) + self.gtop.get_widget("edit_sp").set_sensitive(1) + self.gtop.get_widget("delete_sp").set_sensitive(1) + elif number_of_families == 1: + self.gtop.get_widget("lab_or_list").set_page(0) + f = self.active_person.getFamilyList()[0] + if self.active_person != f.getFather(): + spouse = f.getFather() + else: + spouse = f.getMother() + self.active_spouse = spouse + fv_spouse1 = self.gtop.get_widget("fv_spouse1") + fv_spouse1.set_text(GrampsCfg.nameof(spouse)) + fv_spouse1.set_data("person",spouse) + fv_spouse1.set_data("family",self.active_person.getFamilyList()[0]) + self.gtop.get_widget("edit_sp").set_sensitive(1) + self.gtop.get_widget("delete_sp").set_sensitive(1) + else: + self.gtop.get_widget("lab_or_list").set_page(0) + self.gtop.get_widget("fv_spouse1").set_text("") + fv_spouse1 = self.gtop.get_widget("fv_spouse1") + fv_spouse1.set_text("") + fv_spouse1.set_data("person",None) + fv_spouse1.set_data("family",None) + self.active_spouse = None + self.gtop.get_widget("edit_sp").set_sensitive(0) + self.gtop.get_widget("delete_sp").set_sensitive(0) -def on_edit_bookmarks_activate(obj): - bookmarks.edit() + if number_of_families > 0: + if family: + self.display_marriage(family) + else: + self.display_marriage(self.active_person.getFamilyList()[0]) + else: + self.display_marriage(None) + else: + fv_spouse1 = self.gtop.get_widget("fv_spouse1").set_text("") + self.display_marriage(None) -def bookmark_callback(obj,person): - change_active_person(person) - update_display(0) + def change_parents(self,family): + if self.active_parents and self.active_parents.getRelationship() == "Partners": + fn = _("Parent") + mn = _("Parent") + else: + fn = _("Father") + mn = _("Mother") + + self.gtop.get_widget("editFather").children()[0].set_text(fn) + self.gtop.get_widget("editMother").children()[0].set_text(mn) + + fv_father = self.gtop.get_widget("fv_father") + fv_mother = self.gtop.get_widget("fv_mother") + father_next = self.gtop.get_widget("father_next") + mother_next = self.gtop.get_widget("mother_next") -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_default_person_activate(obj): - if active_person: - name = active_person.getPrimaryName().getRegularName() - msg = _("Do you wish to set %s as the home person?") % name - gnome.ui.GnomeQuestionDialog(msg,set_person) + if family != None : + self.active_father = family.getFather() + if self.active_father != None : + fv_father.set_text(GrampsCfg.nameof(self.active_father)) + father_next.set_sensitive(1) + else : + fv_father.set_text("") + father_next.set_sensitive(0) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def set_person(value): - if not value: - database.setDefaultPerson(active_person) - utils.modified() + self.active_mother = family.getMother() + if self.active_mother != None : + fv_mother.set_text(GrampsCfg.nameof(self.active_mother)) + mother_next.set_sensitive(1) + else : + fv_mother.set_text("") + mother_next.set_sensitive(0) + elif self.active_person == None: + fv_father.set_text("") + fv_mother.set_text("") + mother_next.set_sensitive(0) + father_next.set_sensitive(0) + self.active_father = None + self.active_mother = None + else : + fv_father.set_text("") + fv_mother.set_text("") + mother_next.set_sensitive(0) + father_next.set_sensitive(0) + self.active_father = None + self.active_mother = None -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_current_type_changed(obj): - global active_parents - - active_parents = obj.get_data("parents") - change_parents(active_parents) + def display_marriage(self,family): -#------------------------------------------------------------------------- -# -# Import/Export function callbacks -# -#------------------------------------------------------------------------- -def export_callback(obj,plugin_function): - """Call the export plugin, with the active person and database""" - if active_person: - plugin_function(database,active_person) - -def import_callback(obj,plugin_function): - """Call the import plugin""" - plugin_function(database,active_person,tool_callback) - topWindow.set_title("Gramps - " + database.getSavePath()) - -#------------------------------------------------------------------------- -# -# Call up the preferences dialog box -# -#------------------------------------------------------------------------- -def on_preferences_activate(obj): - Config.display_preferences_box(database) - -#------------------------------------------------------------------------- -# -# Report and tool callbacks from pull down menus -# -#------------------------------------------------------------------------- -def menu_report(obj,task): - """Call the report plugin selected from the menus""" - if active_person: - task(database,active_person) - -def menu_tools(obj,task): - """Call the tool plugin selected from the menus""" - if active_person: - task(database,active_person,tool_callback) - -#------------------------------------------------------------------------- -# -# Person list keypress events -# -#------------------------------------------------------------------------- -def on_main_key_release_event(obj,event): - """Respond to the insert and delete buttons in the person list""" - if event.keyval == GDK.Delete: - on_delete_person_clicked(obj) - elif event.keyval == GDK.Insert: - load_new_person(obj) - -#------------------------------------------------------------------------- -# -# Main program -# -#------------------------------------------------------------------------- - -def main(arg): - global pedigree_view, place_view, source_view, media_view - global database, gtop - global statusbar,notebook - global person_list - global topWindow, preview, merge_button - global nameArrow, dateArrow, deathArrow, idArrow, genderArrow - global cNameArrow, cDateArrow, cIDArrow, cGenderArrow, toolbar - global sort_column, sort_direct - - gtk.rc_parse(const.gtkrcFile) - - if os.getuid() == 0: - msg = _("You are running GRAMPS as the 'root' user.\nThis account is not meant for normal application use.") - gnome.ui.GnomeWarningDialog(msg) - - database = GrampsDB() - - Plugins.load_plugins(const.docgenDir) - Plugins.load_plugins(os.path.expanduser("~/.gramps/docgen")) - Plugins.load_plugins(const.pluginsDir) - Plugins.load_plugins(os.path.expanduser("~/.gramps/plugins")) - Filter.load_filters(const.filtersDir) - Filter.load_filters(os.path.expanduser("~/.gramps/filters")) - - (sort_column,sort_direct) = Config.get_sort_cols("person",sort_column,sort_direct) - - Config.loadConfig(full_update) - - gtop = libglade.GladeXML(const.gladeFile, "gramps") - toolbar = gtop.get_widget("toolbar1") - toolbar.set_style(Config.toolbar) - - statusbar = gtop.get_widget("statusbar") - topWindow = gtop.get_widget("gramps") - person_list = gtop.get_widget("person_list") - filter_list = gtop.get_widget("filter_list") - notebook = gtop.get_widget(NOTEBOOK) - nameArrow = gtop.get_widget("nameSort") - genderArrow = gtop.get_widget("genderSort") - idArrow = gtop.get_widget("idSort") - dateArrow = gtop.get_widget("dateSort") - deathArrow = gtop.get_widget("deathSort") - merge_button= gtop.get_widget("merge") - - Plugins.build_report_menu(gtop.get_widget("reports_menu"),menu_report) - Plugins.build_tools_menu(gtop.get_widget("tools_menu"),menu_tools) - Plugins.build_export_menu(gtop.get_widget("export1"),export_callback) - Plugins.build_import_menu(gtop.get_widget("import1"),import_callback) - - canvas = gtop.get_widget("canvas1") - pedigree_view = PedigreeView(canvas,modify_statusbar,\ - statusbar,change_active_person,\ - load_person) - place_view = PlaceView(database,gtop,update_display) - source_view = SourceView(database,gtop,update_display) - media_view = MediaView(database,gtop,update_display) - - cNameArrow = gtop.get_widget("cNameSort") - cGenderArrow= gtop.get_widget("cGenderSort") - cIDArrow = gtop.get_widget("cIDSort") - cDateArrow = gtop.get_widget("cDateSort") - person_list.set_column_visibility(5,0) - person_list.set_column_visibility(6,0) - person_list.set_column_visibility(7,0) - fw = gtop.get_widget('filter') - filter_list.set_menu(Filter.build_filter_menu(on_filter_name_changed,fw)) - - fw.set_sensitive(0) - - # set the window icon - topWindow.set_icon(gtk.GtkPixmap(topWindow,const.icon)) - - person_list.column_titles_active() - - change_sort(sort_column,sort_direct==GTK.SORT_DESCENDING) - set_sort_arrow(sort_column,sort_direct) - - gtop.signal_autoconnect({ - "delete_event" : delete_event, - "destroy_passed_object" : utils.destroy_passed_object, - "on_about_activate" : on_about_activate, - "on_add_bookmark_activate" : on_add_bookmark_activate, - "on_add_child_clicked" : on_add_child_clicked, - "on_add_new_child_clicked" : on_add_new_child_clicked, - "on_add_place_clicked" : place_view.on_add_place_clicked, - "on_add_source_clicked" : source_view.on_add_source_clicked, - "on_add_sp_clicked" : on_add_sp_clicked, - "on_addperson_clicked" : load_new_person, - "on_apply_filter_clicked" : on_apply_filter_clicked, - "on_arrow_left_clicked" : pedigree_view.on_show_child_menu, - "on_canvas1_event" : pedigree_view.on_canvas1_event, - "on_child_list_button_press_event" : on_child_list_button_press_event, - "on_child_list_select_row" : on_child_list_select_row, - "on_child_list_click_column" : on_child_list_click_column, - "on_child_list_row_move" : on_child_list_row_move, - "on_choose_parents_clicked" : on_choose_parents_clicked, - "on_contents_activate" : on_contents_activate, - "on_default_person_activate" : on_default_person_activate, - "on_delete_parents_clicked" : on_delete_parents_clicked, - "on_delete_person_clicked" : on_delete_person_clicked, - "on_delete_place_clicked" : place_view.on_delete_place_clicked, - "on_delete_source_clicked" : source_view.on_delete_source_clicked, - "on_delete_media_clicked" : media_view.on_delete_media_clicked, - "on_delete_sp_clicked" : on_delete_sp_clicked, - "on_edit_active_person" : load_active_person, - "on_edit_selected_people" : load_selected_people, - "on_edit_bookmarks_activate" : on_edit_bookmarks_activate, - "on_edit_father_clicked" : on_edit_father_clicked, - "on_edit_media_clicked" : media_view.on_edit_media_clicked, - "on_edit_mother_clicked" : on_edit_mother_clicked, - "on_edit_place_clicked" : place_view.on_edit_place_clicked, - "on_edit_source_clicked" : source_view.on_edit_source_clicked, - "on_edit_sp_clicked" : on_edit_sp_clicked, - "on_edit_spouse_clicked" : on_edit_spouse_clicked, - "on_exit_activate" : on_exit_activate, - "on_family1_activate" : on_family1_activate, - "on_father_next_clicked" : on_father_next_clicked, - "on_find_activate" : on_find_activate, - "on_findname_activate" : on_findname_activate, - "on_fv_prev_clicked" : on_fv_prev_clicked, - "on_home_clicked" : on_home_clicked, - "on_mother_next_clicked" : on_mother_next_clicked, - "on_new_clicked" : on_new_clicked, - "on_notebook1_switch_page" : on_notebook1_switch_page, - "on_ok_button1_clicked" : on_ok_button1_clicked, - "on_open_activate" : on_open_activate, - "on_pedegree1_activate" : on_pedegree1_activate, - "on_person_list1_activate" : on_person_list1_activate, - "on_person_list_button_press" : on_person_list_button_press, - "on_person_list_click_column" : on_person_list_click_column, - "on_person_list_select_row" : on_person_list_select_row, - "on_place_list_click_column" : place_view.on_click_column, - "on_main_key_release_event" : on_main_key_release_event, - "on_add_media_clicked" : media_view.create_add_dialog, - "on_media_activate" : on_media_activate, - "on_media_list_select_row" : media_view.on_select_row, - "on_media_list_drag_data_get" : media_view.on_drag_data_get, - "on_media_list_drag_data_received" : media_view.on_drag_data_received, - "on_merge_activate" : on_merge_activate, - "on_places_activate" : on_places_activate, - "on_preferences_activate" : on_preferences_activate, - "on_reload_plugins_activate" : Plugins.reload_plugins, - "on_remove_child_clicked" : on_remove_child_clicked, - "on_reports_clicked" : on_reports_clicked, - "on_revert_activate" : on_revert_activate, - "on_save_activate" : on_save_activate, - "on_save_as_activate" : on_save_as_activate, - "on_source_list_button_press_event" : source_view.on_button_press_event, - "on_sources_activate" : on_sources_activate, - "on_spouselist_changed" : on_spouselist_changed, - "on_swap_clicked" : on_swap_clicked, - "on_tools_clicked" : on_tools_clicked, - "on_gramps_home_page_activate" : on_gramps_home_page_activate, - "on_gramps_report_bug_activate" : on_gramps_report_bug_activate, - "on_gramps_mailing_lists_activate" : on_gramps_mailing_lists_activate, - "on_writing_extensions_activate" : on_writing_extensions_activate, - }) - - person_list.set_column_visibility(1,Config.id_visible) - - notebook.set_show_tabs(Config.usetabs) - database.set_iprefix(Config.iprefix) - database.set_oprefix(Config.oprefix) - database.set_fprefix(Config.fprefix) - database.set_sprefix(Config.sprefix) - database.set_pprefix(Config.pprefix) - child_list = gtop.get_widget("child_list") - child_list.set_column_visibility(c_details,Config.show_detail) - child_list.set_column_justification(c_birth_order,GTK.JUSTIFY_RIGHT) + self.active_family = family + clist = self.gtop.get_widget("child_list") + fv_prev = self.gtop.get_widget("fv_prev") - if arg != None: - read_file(arg) - elif Config.lastfile != None and Config.lastfile != "" and Config.autoload: - auto_save_load(Config.lastfile) - else: - DbPrompter(database,0) + clist.clear() + self.active_child = None + + i = 0 + clist.set_sort_type(self.c_sort_direct) + clist.set_sort_column(self.c_sort_column) + clist.set_reorderable(self.c_sort_column == self.c_birth_order) - if Config.autosave_int != 0: - utils.enable_autosave(autosave_database,Config.autosave_int) + if family != None: + if self.active_person.getGender() == Person.male: + self.active_spouse = family.getMother() + else: + self.active_spouse = family.getFather() + + child_list = family.getChildList() + child_list.sort(sort.by_birthdate) + + attr = "" + for child in child_list: + status = _("Unknown") + if child.getGender() == Person.male: + gender = const.male + elif child.getGender() == Person.female: + gender = const.female + else: + gender = const.unknown + if child.getMainFamily() == family: + status = _("Birth") + else: + for fam in child.getAltFamilyList(): + if fam[0] == family: + if self.active_person == family.getFather(): + status = "%s/%s" % (_(fam[2]),_(fam[1])) + else: + status = "%s/%s" % (_(fam[1]),_(fam[2])) + + if GrampsCfg.show_detail: + attr = "" + if child.getNote() != "": + attr = attr + "N" + if len(child.getEventList())>0: + attr = attr + "E" + if len(child.getAttributeList())>0: + attr = attr + "A" + if len(child.getFamilyList()) > 0: + for f in child.getFamilyList(): + if f.getFather() and f.getMother(): + attr = attr + "M" + break + if len(child.getPhotoList()) > 0: + attr = attr + "P" + + clist.append(["%2d"%(i+1),GrampsCfg.nameof(child),child.getId(),\ + gender,Utils.birthday(child),status,attr]) + clist.set_row_data(i,child) + i=i+1 + if i != 0: + fv_prev.set_sensitive(1) + clist.select_row(0,0) + else: + fv_prev.set_sensitive(0) + clist.set_data("f",family) + self.sort_child_list(clist) + else: + fv_prev.set_sensitive(0) + + def load_progress(self,value): + self.statusbar.set_progress(value) + while gtk.events_pending(): + gtk.mainiteration() + + def quick_progress(self,value): + gtk.threads_enter() + self.statusbar.set_progress(value) + while gtk.events_pending(): + gtk.mainiteration() + gtk.threads_leave() + + def post_load(self,name): + self.database.setSavePath(name) + res = self.database.getResearcher() + owner = GrampsCfg.get_researcher() + + if res.getName() == "" and owner.getName() != "": + self.database.setResearcher(owner) + Utils.modified() + + self.setup_bookmarks() + + mylist = self.database.getPersonEventTypes() + for type in mylist: + ntype = const.display_pevent(type) + if ntype not in const.personalEvents: + const.personalEvents.append(ntype) + + mylist = self.database.getFamilyEventTypes() + for type in mylist: + ntype = const.display_fevent(type) + if ntype not in const.marriageEvents: + const.marriageEvents.append(ntype) + + mylist = self.database.getPersonAttributeTypes() + for type in mylist: + ntype = const.display_pattr(type) + if ntype not in const.personalAttributes: + const.personalAttributes.append(ntype) + + mylist = self.database.getFamilyAttributeTypes() + for type in mylist: + if type not in const.familyAttributes: + const.familyAttributes.append(type) + + mylist = self.database.getFamilyRelationTypes() + for type in mylist: + if type not in const.familyRelations: + const.familyRelations.append(type) + + GrampsCfg.save_last_file(name) + self.gtop.get_widget("filter").set_text("") + + person = self.database.getDefaultPerson() + if person: + self.active_person = person + for person in self.database.getPersonMap().values(): + if self.active_person == None: + self.active_person = person + lastname = person.getPrimaryName().getSurname() + if lastname and lastname not in const.surnames: + const.surnames.append(lastname) + const.surnames.sort() + + self.statusbar.set_progress(1.0) + self.full_update() + self.statusbar.set_progress(0.0) + return 1 + + def load_database(self,name): + filename = "%s/%s" % (name,const.indexFile) + if ReadXML.loadData(self.database,filename,self.load_progress) == 0: + return 0 + return self.post_load(name) + + def load_revision(self,f,name,revision): + filename = "%s/%s" % (name,const.indexFile) + if ReadXML.loadRevision(self.database,f,filename,revision,self.load_progress) == 0: + return 0 + return self.post_load(name) + + def setup_bookmarks(self): + self.bookmarks = Bookmarks.Bookmarks(self.database.getBookmarks(), + self.gtop.get_widget("jump_to"), + self.bookmark_callback) + + def displayError(self,msg): + gnome.ui.GnomeErrorDialog(msg) + self.statusbar.set_status("") + + def apply_filter(self): + self.person_list.freeze() + datacomp = self.DataFilter.compare + gname = Utils.phonebook_from_name + + self.person_list.set_column_visibility(1,GrampsCfg.id_visible) + new_alt2col = {} + + bsn = sort.build_sort_name + bsd = sort.build_sort_date + for person in self.database.getPersonMap().values(): + if datacomp(person): + if self.id2col.has_key(person): + new_alt2col[person] = self.alt2col[person] + continue + pos = (person,0) + self.id2col[person] = pos + new_alt2col[person] = [] + + if person.getGender() == Person.male: + gender = const.male + elif person.getGender() == Person.female: + gender = const.female + else: + gender = const.unknown + + name = person.getPrimaryName() + bday = person.getBirth().getDateObj() + dday = person.getDeath().getDateObj() + sort_bday = bsd(bday) + sort_dday = bsd(dday) + qbday = bday.getQuoteDate() + qdday = dday.getQuoteDate() + pid = person.getId() + + values = [gname(name,0), pid, gender, qbday, qdday, + bsn(name), sort_bday, sort_dday ] + self.person_list.insert(0,values) + self.person_list.set_row_data(0,pos) + + if GrampsCfg.hide_altnames: + continue + + for name in person.getAlternateNames(): + pos = (person,0) + new_alt2col[person].append(pos) + + values = [gname(name,1), pid, gender, qbday, qdday, + bsn(name), sort_bday, sort_dday] + self.person_list.insert(0,values) + self.person_list.set_row_data(0,pos) + + else: + if self.id2col.has_key(person): + pid = self.id2col[person] + del self.id2col[person] + + for id in [pid] + self.alt2col[person]: + row = self.person_list.find_row_from_data(id) + self.person_list.remove(row) + + self.alt2col = new_alt2col + self.person_list.thaw() + self.sort_person_list() + + def on_home_clicked(self,obj): + temp = self.database.getDefaultPerson() + if temp: + self.change_active_person(temp) + self.update_display(0) + else: + gnome.ui.GnomeErrorDialog(_("No default/home person has been set")) + + def on_add_bookmark_activate(self,obj): + self.bookmarks.add(self.active_person) + name = GrampsCfg.nameof(self.active_person) + self.statusbar.set_status(_("%s has been bookmarked") % name) + gtk.timeout_add(5000,self.modify_statusbar) + + def on_edit_bookmarks_activate(self,obj): + self.bookmarks.edit() + + def bookmark_callback(self,obj,person): + self.change_active_person(person) + self.update_display(0) + + def on_default_person_activate(self,obj): + if self.active_person: + name = self.active_person.getPrimaryName().getRegularName() + msg = _("Do you wish to set %s as the home person?") % name + gnome.ui.GnomeQuestionDialog(msg,self.set_person) + + def set_person(self,value): + if not value: + self.database.setDefaultPerson(self.active_person) + Utils.modified() + + def on_current_type_changed(self,obj): + self.active_parents = obj.get_data("parents") + self.change_parents(self.active_parents) + + def export_callback(self,obj,plugin_function): + """Call the export plugin, with the active person and database""" + if self.active_person: + plugin_function(self.database,self.active_person) + + def import_callback(self,obj,plugin_function): + """Call the import plugin""" + plugin_function(self.database,self.active_person,self.tool_callback) + self.topWindow.set_title("Gramps - " + self.database.getSavePath()) + + def on_preferences_activate(self,obj): + GrampsCfg.display_preferences_box(self.database) + + def menu_report(self,obj,task): + """Call the report plugin selected from the menus""" + if self.active_person: + task(self.database,self.active_person) + + def menu_tools(self,obj,task): + """Call the tool plugin selected from the menus""" + if self.active_person: + task(self.database,self.active_person,self.tool_callback) + + def on_main_key_release_event(self,obj,event): + """Respond to the insert and delete buttons in the person list""" + if event.keyval == GDK.Delete: + self.on_delete_person_clicked(obj) + elif event.keyval == GDK.Insert: + self.load_new_person(obj) - database.setResearcher(Config.get_researcher()) #------------------------------------------------------------------------- # @@ -2223,10 +1803,10 @@ class DbPrompter: self.save_as_activate() else: self.open_activate() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def save_as_activate(self): - wFs = libglade.GladeXML (const.gladeFile, FILESEL) + wFs = libglade.GladeXML (const.gladeFile, "fileselection") wFs.signal_autoconnect({ "on_ok_button1_clicked": self.save_ok_button_clicked, "destroy_passed_object": self.cancel_button_clicked, @@ -2235,11 +1815,11 @@ class DbPrompter: def save_ok_button_clicked(self,obj): filename = obj.get_filename() if filename: - utils.destroy_passed_object(obj) - if Config.usevc and Config.vc_comment: - display_comment_box(filename) + Utils.destroy_passed_object(obj) + if GrampsCfg.usevc and GrampsCfg.vc_comment: + self.db.display_comment_box(filename) else: - save_file(filename,_("No Comment Provided")) + self.db.save_file(filename,_("No Comment Provided")) def open_activate(self): wFs = libglade.GladeXML(const.revisionFile, "dbopen") @@ -2251,11 +1831,11 @@ class DbPrompter: self.fileSelector = wFs.get_widget("dbopen") self.dbname = wFs.get_widget("dbname") self.getoldrev = wFs.get_widget("getoldrev") - self.dbname.set_default_path(Config.db_dir) - self.getoldrev.set_sensitive(Config.usevc) + self.dbname.set_default_path(GrampsCfg.db_dir) + self.getoldrev.set_sensitive(GrampsCfg.usevc) def cancel_button_clicked(self,obj): - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) self.show() def ok_button_clicked(self,obj): @@ -2264,14 +1844,15 @@ class DbPrompter: if not filename: return - utils.destroy_passed_object(obj) - clear_database() + Utils.destroy_passed_object(obj) + self.db.clear_database() if self.getoldrev.get_active(): vc = VersionControl.RcsVersionControl(filename) - VersionControl.RevisionSelect(self.db,filename,vc,load_revision,self.show) + VersionControl.RevisionSelect(self.db.database,filename,vc, + self.db.load_revision,self.show) else: - read_file(filename) + self.db.read_file(filename) def open_delete_event(self,obj,event): gtk.mainquit() @@ -2286,5 +1867,5 @@ class DbPrompter: # #------------------------------------------------------------------------- if __name__ == '__main__': - main(None) + Gramps(None) gtk.mainloop() diff --git a/src/plugins/AncestorChart.py b/src/plugins/AncestorChart.py index a720127c8..c3025f353 100644 --- a/src/plugins/AncestorChart.py +++ b/src/plugins/AncestorChart.py @@ -20,7 +20,7 @@ "Graphical Reports/Ancestor Chart" -import Config +import GrampsCfg import os import string @@ -88,10 +88,10 @@ class AncestorChart: B = person.getBirth().getPlaceName() D = person.getDeath().getPlaceName() i = "%s" % person.getId() - A = Config.attr_name + A = GrampsCfg.attr_name a = "" for attr in person.getAttributeList(): - if attr.getType() == Config.attr_name: + if attr.getType() == GrampsCfg.attr_name: a = attr.getValue() break diff --git a/src/plugins/ChangeTypes.py b/src/plugins/ChangeTypes.py index 01e8f3649..bf4810f0c 100644 --- a/src/plugins/ChangeTypes.py +++ b/src/plugins/ChangeTypes.py @@ -26,7 +26,7 @@ import gnome.ui import libglade import const -import utils +import Utils import intl _ = intl.gettext @@ -52,8 +52,8 @@ class ChangeTypes: self.glade.get_widget("new").set_popdown_strings(const.personalEvents) self.glade.signal_autoconnect({ - "on_close_clicked" : utils.destroy_passed_object, - "on_combo_insert_text" : utils.combo_insert_text, + "on_close_clicked" : Utils.destroy_passed_object, + "on_combo_insert_text" : Utils.combo_insert_text, "on_apply_clicked" : self.on_apply_clicked }) @@ -70,7 +70,7 @@ class ChangeTypes: if event.getName() == original: event.setName(new) modified = modified + 1 - utils.modified() + Utils.modified() if modified == 1: msg = _("1 event record was modified") @@ -78,7 +78,7 @@ class ChangeTypes: msg = _("%d event records were modified") % modified gnome.ui.GnomeOkDialog(msg) - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) #------------------------------------------------------------------------ # diff --git a/src/plugins/Check.py b/src/plugins/Check.py index d97249598..04ca5418d 100644 --- a/src/plugins/Check.py +++ b/src/plugins/Check.py @@ -21,7 +21,7 @@ "Database Processing/Check and repair database" import RelLib -import utils +import Utils import intl _ = intl.gettext @@ -81,7 +81,7 @@ class CheckIntegrity: break else: family.removeChild(child) - utils.modified() + Utils.modified() self.broken_links.append((child,family)) #------------------------------------------------------------------------- @@ -104,7 +104,7 @@ class CheckIntegrity: family_list = self.db.getFamilyMap().values()[:] for family in family_list: if family.getFather() == None and family.getMother() == None: - utils.modified() + Utils.modified() self.empty_family.append(family) self.delete_empty_family(family) @@ -200,7 +200,7 @@ class CheckIntegrity: glade_file = base + os.sep + "summary.glade" topDialog = libglade.GladeXML(glade_file,"summary") topDialog.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, }) title = _("Check Integrity") top = topDialog.get_widget("summary") diff --git a/src/plugins/DesGraph.py b/src/plugins/DesGraph.py index e96e75113..64c97c71d 100644 --- a/src/plugins/DesGraph.py +++ b/src/plugins/DesGraph.py @@ -27,8 +27,6 @@ from DrawDoc import * from Report import * from TextDoc import * -import Config - import libglade import gtk import string diff --git a/src/plugins/Desbrowser.py b/src/plugins/Desbrowser.py index 389e83030..a2b62350e 100644 --- a/src/plugins/Desbrowser.py +++ b/src/plugins/Desbrowser.py @@ -22,9 +22,9 @@ from RelLib import * import os -import utils +import Utils import intl -import Config +import GrampsCfg _ = intl.gettext @@ -51,7 +51,7 @@ class DesBrowse: self.glade = libglade.GladeXML(glade_file,"top") self.glade.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, }) top = self.glade.get_widget("top") tree= self.glade.get_widget("tree1") @@ -60,7 +60,7 @@ class DesBrowse: top.show() def add_to_tree(self,tree,person): - item = gtk.GtkTreeItem(Config.nameof(person)) + item = gtk.GtkTreeItem(GrampsCfg.nameof(person)) item.show() item.connect('button-press-event',self.button_press_event) item.set_data('d',person) diff --git a/src/plugins/EventCmp.py b/src/plugins/EventCmp.py index 8b4b813af..0eca6518a 100644 --- a/src/plugins/EventCmp.py +++ b/src/plugins/EventCmp.py @@ -27,7 +27,7 @@ #------------------------------------------------------------------------ import os import sort -import utils +import Utils import string import ListColors import Filter @@ -151,7 +151,7 @@ class EventComparison: "on_filter_save_clicked" : self.on_filter_save_clicked, "on_filter_load_clicked" : self.on_filter_load_clicked, "on_apply_clicked" : self.on_apply_clicked, - "destroy_passed_object" : utils.destroy_passed_object + "destroy_passed_object" : Utils.destroy_passed_object }) top =self.filterDialog.get_widget("filters") @@ -224,8 +224,8 @@ class EventComparison: if len(names) > 0: self.filter_combo.set_popdown_strings(names) self.load_dialog.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, - "combo_insert_text" : utils.combo_insert_text, + "destroy_passed_object" : Utils.destroy_passed_object, + "combo_insert_text" : Utils.combo_insert_text, "on_load_filter" : self.on_save_filter, }) @@ -237,8 +237,8 @@ class EventComparison: if len(names) > 0: self.filter_combo.set_popdown_strings(names) self.load_dialog.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, - "combo_insert_text" : utils.combo_insert_text, + "destroy_passed_object" : Utils.destroy_passed_object, + "combo_insert_text" : Utils.combo_insert_text, "on_load_filter" : self.on_load_filter, }) @@ -256,12 +256,12 @@ class EventComparison: name = Filter.get_filter_description(name) self.filter_list_obj.append([name,f.get_text(),invert]) self.filter_list_obj.thaw() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def on_save_filter(self,obj): name = self.load_dialog.get_widget("name").get_text() self.interface.save_filter(name,self.filter_list) - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def on_filter_name_changed(self,obj): self.qual = obj.get_data(QUALIFIER) @@ -376,7 +376,7 @@ class DisplayChart: self.topDialog = libglade.GladeXML(self.glade_file,"view") self.topDialog.signal_autoconnect({ "on_write_table" : self.on_write_table, - "destroy_passed_object" : utils.destroy_passed_object + "destroy_passed_object" : Utils.destroy_passed_object }) self.top = self.topDialog.get_widget("view") @@ -478,7 +478,7 @@ class DisplayChart: self.form.signal_autoconnect({ "on_save_clicked" : self.on_save_clicked, "on_html_toggled" : self.on_html_toggled, - "destroy_passed_object" : utils.destroy_passed_object + "destroy_passed_object" : Utils.destroy_passed_object }) self.save_form = self.form.get_widget("dialog1") self.save_form.show() @@ -505,7 +505,7 @@ class DisplayChart: spreadsheet.write_table_data(bottom) spreadsheet.finalize() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) #------------------------------------------------------------------------- # diff --git a/src/plugins/Graph.py b/src/plugins/Graph.py index a27e0485d..2f3435893 100644 --- a/src/plugins/Graph.py +++ b/src/plugins/Graph.py @@ -26,7 +26,7 @@ import posixpath import re import sort import string -import utils +import Utils import intl _ = intl.gettext @@ -155,7 +155,7 @@ def report(database,person): else: boxes.append( (x, y, (personList[id].getGender() == Person.female), id ) ) personList[id].setPosition( (x,y) ) - utils.modified() + Utils.modified() else: print "just lost person with key %s" % (id) @@ -368,7 +368,7 @@ def button_release_event(widget, event): id = b[3] person = db.findPersonNoMap(id) person.setPosition( (b[0], b[1]) ) - utils.modified() + Utils.modified() redraw_tree( widget ) return TRUE diff --git a/src/plugins/GraphViz.py b/src/plugins/GraphViz.py index e10b2378f..b5c8dfa68 100644 --- a/src/plugins/GraphViz.py +++ b/src/plugins/GraphViz.py @@ -22,6 +22,7 @@ import os import intl +import Utils _ = intl.gettext @@ -154,7 +155,7 @@ class GraphVizDialog(ReportDialog): """Build a one item menu of document types that are appropriate for this report.""" map = {"Graphviz (dot)" : None} - myMenu = utils.build_string_optmenu(map, None) + myMenu = Utils.build_string_optmenu(map, None) self.format_menu.set_menu(myMenu) def make_document(self): diff --git a/src/plugins/IndivSummary.py b/src/plugins/IndivSummary.py index 2bb9fb7cb..ec34c00ab 100644 --- a/src/plugins/IndivSummary.py +++ b/src/plugins/IndivSummary.py @@ -24,8 +24,6 @@ import RelLib import const import os import string -import utils -import Config import intl _ = intl.gettext diff --git a/src/plugins/Merge.py b/src/plugins/Merge.py index 2153775c5..58757de18 100644 --- a/src/plugins/Merge.py +++ b/src/plugins/Merge.py @@ -21,10 +21,10 @@ "Database Processing/Merge people" import RelLib -import utils +import Utils import soundex import intl -import Config +import GrampsCfg _ = intl.gettext import string @@ -104,13 +104,13 @@ class Merge: top.signal_autoconnect({ "on_merge_ok_clicked" : self.on_merge_ok_clicked, - "destroy_passed_object" : utils.destroy_passed_object + "destroy_passed_object" : Utils.destroy_passed_object }) def on_merge_ok_clicked(self,obj): active = self.menu.get_menu().get_active().get_data("v") self.use_soundex = self.soundex_obj.get_active() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) self.find_potentials(active) self.show() @@ -186,7 +186,7 @@ class Merge: self.window = top.get_widget("mergelist") self.mlist = top.get_widget("mlist") top.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_do_merge_clicked" : self.on_do_merge_clicked, }) self.mlist.connect('button-press-event',self.button_press_event) @@ -241,7 +241,7 @@ class Merge: def update_and_destroy(self,obj): self.update(1) - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) def list_reduce(self,list1,list2): value = 0 @@ -487,7 +487,7 @@ class Merge: def name_of(p): if not p: return "" - return "%s (%s)" % ( Config.nameof(p),p.getId()) + return "%s (%s)" % ( GrampsCfg.nameof(p),p.getId()) def get_name_obj(person): if person: diff --git a/src/plugins/PatchNames.py b/src/plugins/PatchNames.py index a741af406..3cfbc6066 100644 --- a/src/plugins/PatchNames.py +++ b/src/plugins/PatchNames.py @@ -23,7 +23,7 @@ import os import re import intl -import utils +import Utils _ = intl.gettext @@ -83,7 +83,7 @@ class PatchNames: self.top = libglade.GladeXML(glade_file,"summary") self.top.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_ok_clicked" : self.on_ok_clicked }) self.top.get_widget("textwindow").show_string(msg) @@ -96,15 +96,15 @@ class PatchNames: name = grp[0].getPrimaryName() name.setFirstName(grp[1]) grp[0].setNickName(grp[2]) - utils.modified() + Utils.modified() for grp in self.title_list: name = grp[0].getPrimaryName() name.setFirstName(grp[2]) name.setTitle(grp[1]) - utils.modified() + Utils.modified() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) self.cb(1) #------------------------------------------------------------------------ diff --git a/src/plugins/ReadGedcom.py b/src/plugins/ReadGedcom.py index f63585000..d322ca3d3 100644 --- a/src/plugins/ReadGedcom.py +++ b/src/plugins/ReadGedcom.py @@ -33,7 +33,7 @@ import os import re import string import const -import utils +import Utils import gtk import gnome.ui @@ -93,17 +93,17 @@ def importData(database, filename): statusWindow = statusTop.get_widget("status") statusTop.get_widget("close").set_sensitive(0) statusTop.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object + "destroy_passed_object" : Utils.destroy_passed_object }) try: g = GedcomParser(database,filename,statusTop) except IOError,msg: - utils.destroy_passed_object(statusWindow) + Utils.destroy_passed_object(statusWindow) gnome.ui.GnomeErrorDialog(_("%s could not be opened\n") % filename + str(msg)) return except: - utils.destroy_passed_object(statusWindow) + Utils.destroy_passed_object(statusWindow) gnome.ui.GnomeErrorDialog(_("%s could not be opened\n") % filename) return @@ -111,7 +111,7 @@ def importData(database, filename): statusTop.get_widget("close").set_sensitive(1) - utils.modified() + Utils.modified() if callback: callback(1) @@ -803,7 +803,7 @@ class GedcomParser: photo = Photo() photo.setPath(path) photo.setDescription(title) - photo.setMimeType(utils.get_mime_type(path)) + photo.setMimeType(Utils.get_mime_type(path)) self.db.addObject(photo) oref = ObjectRef() oref.setReference(photo) @@ -838,7 +838,7 @@ class GedcomParser: photo = Photo() photo.setPath(path) photo.setDescription(title) - photo.setMimeType(utils.get_mime_type(path)) + photo.setMimeType(Utils.get_mime_type(path)) self.db.addObject(photo) oref = ObjectRef() oref.setReference(photo) @@ -873,7 +873,7 @@ class GedcomParser: photo = Photo() photo.setPath(path) photo.setDescription(title) - photo.setMimeType(utils.get_mime_type(path)) + photo.setMimeType(Utils.get_mime_type(path)) self.db.addObject(photo) oref = ObjectRef() oref.setReference(photo) @@ -1647,7 +1647,7 @@ def on_ok_clicked(obj): else: clear_data = 0 - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) importData(db,name) #------------------------------------------------------------------------- @@ -1667,7 +1667,7 @@ def readData(database,active_person,cb): glade_file = "%s/gedcomimport.glade" % os.path.dirname(__file__) dic = { - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_ok_clicked" : on_ok_clicked } diff --git a/src/plugins/ReadNative.py b/src/plugins/ReadNative.py index 18c652af7..e5d267a7e 100644 --- a/src/plugins/ReadNative.py +++ b/src/plugins/ReadNative.py @@ -22,7 +22,7 @@ import libglade from ReadXML import * -import utils +import Utils import intl _ = intl.gettext @@ -53,7 +53,7 @@ def readData(database,active_person,cb): glade_file = base + os.sep + "grampsimport.glade" dic = { - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_ok_clicked" : on_ok_clicked } @@ -78,7 +78,7 @@ def on_ok_clicked(obj): name = topDialog.get_widget("filename").get_text() name = name + os.sep + const.indexFile - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) importData(db,name,progress) callback(1) diff --git a/src/plugins/RelCalc.py b/src/plugins/RelCalc.py index 2443124f6..f673e5060 100644 --- a/src/plugins/RelCalc.py +++ b/src/plugins/RelCalc.py @@ -29,7 +29,7 @@ from libglade import * import RelLib import sort import intl -import utils +import Utils _ = intl.gettext @@ -319,7 +319,7 @@ class RelCalc: self.people.thaw() self.glade.signal_autoconnect({ - "on_close_clicked" : utils.destroy_passed_object, + "on_close_clicked" : Utils.destroy_passed_object, "on_apply_clicked" : self.on_apply_clicked }) diff --git a/src/plugins/ReorderIds.py b/src/plugins/ReorderIds.py index 1815acad3..53a93689e 100644 --- a/src/plugins/ReorderIds.py +++ b/src/plugins/ReorderIds.py @@ -24,7 +24,7 @@ scheme specified in the database's prefix ids """ import re -import utils +import Utils import intl _ = intl.gettext @@ -39,7 +39,7 @@ def runTool(database,active_person,callback): make_new_ids(database.getObjectMap(),database.oprefix) make_new_ids(database.getSourceMap(),database.sprefix) make_new_ids(database.getPlaceMap(),database.pprefix) - utils.modified() + Utils.modified() callback(1) diff --git a/src/plugins/Summary.py b/src/plugins/Summary.py index 91a44f520..a55d49536 100644 --- a/src/plugins/Summary.py +++ b/src/plugins/Summary.py @@ -25,7 +25,7 @@ import os import posixpath import re import string -import utils +import Utils import intl _ = intl.gettext @@ -45,7 +45,7 @@ def report(database,person): topDialog = GladeXML(glade_file,"summary") topDialog.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, }) personList = database.getPersonMap().values() diff --git a/src/plugins/Verify.py b/src/plugins/Verify.py index 854e4933a..0030faa6b 100644 --- a/src/plugins/Verify.py +++ b/src/plugins/Verify.py @@ -26,7 +26,7 @@ import posixpath import re import sort import string -import utils +import Utils import intl _ = intl.gettext @@ -60,7 +60,7 @@ def runTool(database,active_person,callback): verifySettings = GladeXML(glade_file,"verify_settings") verifySettings.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_verify_ok_clicked" : on_apply_clicked }) @@ -272,7 +272,7 @@ def on_apply_clicked(obj): verifyResult = GladeXML(glade_file,"verify_result") verifyResult.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, }) top = verifyResult.get_widget("verify_result") textwindow = verifyResult.get_widget("textwindow") diff --git a/src/plugins/WebPage.py b/src/plugins/WebPage.py index a667cccbf..492001be7 100644 --- a/src/plugins/WebPage.py +++ b/src/plugins/WebPage.py @@ -24,8 +24,7 @@ from RelLib import * from HtmlDoc import * import const -import utils -import Config +import GrampsCfg import intl _ = intl.gettext @@ -844,7 +843,7 @@ class WebReportDialog(ReportDialog): """Get the name of the directory to which the target dialog box should default. This value can be set in the preferences panel.""" - return Config.web_dir + return GrampsCfg.web_dir def set_default_directory(self, value): """Save the name of the current directory, so that any future @@ -854,7 +853,7 @@ class WebReportDialog(ReportDialog): This means that the last directory used will only be remembered for this session of gramps unless the user saves his/her preferences.""" - Config.web_dir = value + GrampsCfg.web_dir = value #------------------------------------------------------------------------ # diff --git a/src/plugins/WriteGedcom.py b/src/plugins/WriteGedcom.py index 57f587f46..69d7a8ab5 100644 --- a/src/plugins/WriteGedcom.py +++ b/src/plugins/WriteGedcom.py @@ -25,7 +25,7 @@ import os import string import time import const -import utils +import Utils import intl import Date _ = intl.gettext @@ -410,7 +410,7 @@ class GedcomWriter: self.topDialog = libglade.GladeXML(glade_file,"gedcomExport") self.topDialog.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_ok_clicked" : self.on_ok_clicked }) @@ -484,13 +484,13 @@ class GedcomWriter: (self.plist,self.flist,self.slist) = filter(self.db,self.person,self.private) - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) glade_file = "%s/gedcomexport.glade" % os.path.dirname(__file__) self.exprogress = libglade.GladeXML(glade_file,"exportprogress") self.exprogress.signal_autoconnect({ - "on_close_clicked" : utils.destroy_passed_object + "on_close_clicked" : Utils.destroy_passed_object }) self.fbar = self.exprogress.get_widget("fbar") @@ -499,7 +499,7 @@ class GedcomWriter: self.progress = self.exprogress.get_widget('exportprogress') closebtn = self.exprogress.get_widget("close") - closebtn.connect("clicked",utils.destroy_passed_object) + closebtn.connect("clicked",Utils.destroy_passed_object) closebtn.set_sensitive(0) self.export_data(name) diff --git a/src/plugins/WritePafPalm.py b/src/plugins/WritePafPalm.py index bbfb11921..152747593 100644 --- a/src/plugins/WritePafPalm.py +++ b/src/plugins/WritePafPalm.py @@ -25,7 +25,7 @@ import os import string import time import const -import utils +import Utils import intl _ = intl.gettext @@ -531,7 +531,7 @@ def on_ok_clicked(obj): filter() exportData(db,name) - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) #------------------------------------------------------------------------- # @@ -550,7 +550,7 @@ def writeData(database,person): glade_file = base + os.sep + "pafexport.glade" dic = { - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_ok_clicked" : on_ok_clicked } diff --git a/src/plugins/WritePkg.py b/src/plugins/WritePkg.py index 6256c7cc7..50bbf61ef 100644 --- a/src/plugins/WritePkg.py +++ b/src/plugins/WritePkg.py @@ -27,7 +27,7 @@ import WriteXML import time import os import TarFile -import utils +import Utils import libglade from cStringIO import StringIO @@ -46,7 +46,7 @@ def writeData(database,person): glade_file = base + os.sep + "pkgexport.glade" dic = { - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, "on_ok_clicked" : on_ok_clicked } @@ -65,7 +65,7 @@ def on_ok_clicked(obj): global topDialog name = topDialog.get_widget("filename").get_text() - utils.destroy_passed_object(obj) + Utils.destroy_passed_object(obj) exportData(db,name) def callback(a): diff --git a/src/plugins/count_anc.py b/src/plugins/count_anc.py index e4174a2d4..b9747e09d 100644 --- a/src/plugins/count_anc.py +++ b/src/plugins/count_anc.py @@ -26,7 +26,7 @@ import posixpath import re import sort import string -import utils +import Utils import intl _ = intl.gettext @@ -40,7 +40,7 @@ def report(database,person): glade_file = base + os.sep + "summary.glade" topDialog = GladeXML(glade_file,"summary") topDialog.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : Utils.destroy_passed_object, }) thisgen = [] allgen = [] diff --git a/src/plugins/soundgen.py b/src/plugins/soundgen.py index 22b44e0b6..006742ac0 100644 --- a/src/plugins/soundgen.py +++ b/src/plugins/soundgen.py @@ -28,7 +28,7 @@ from libglade import * import RelLib import soundex -import utils +import Utils import intl _ = intl.gettext @@ -50,8 +50,8 @@ class SoundGen: self.glade = GladeXML(glade_file,"soundEx") self.glade.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, - "on_combo_insert_text" : utils.combo_insert_text, + "destroy_passed_object" : Utils.destroy_passed_object, + "on_combo_insert_text" : Utils.combo_insert_text, "on_apply_clicked" : self.on_apply_clicked, })