From effa5fd4428956955acff21f0996d6eb2666cfe6 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 16 Jan 2005 04:00:35 +0000 Subject: [PATCH] * src/EditPerson.py: don't use quote date * src/PeopleModel.py: remove BOLD * src/PeopleView.py: start of sorting support * src/WriteXML.py: use hlink for Witness * various: pychecker fixes * configure.in: bump up to 1.1.3, the "Splunge: this is a greate idea, but possibly lousy, and I'm not being indecisive" release svn: r3915 --- gramps2/ChangeLog | 10 +++++++ gramps2/NEWS | 2 +- gramps2/configure.in | 4 +-- gramps2/src/AddrEdit.py | 3 +- gramps2/src/ArgHandler.py | 1 - gramps2/src/DateDisplay.py | 10 +++++-- gramps2/src/EditPerson.py | 8 +++-- gramps2/src/EditPlace.py | 4 +-- gramps2/src/EventEdit.py | 10 ++++--- gramps2/src/Exporter.py | 16 +++++----- gramps2/src/GrampsCfg.py | 2 -- gramps2/src/PeopleModel.py | 8 ----- gramps2/src/PeopleView.py | 29 +++++++++++++----- gramps2/src/ReadGedcom.py | 4 +-- gramps2/src/RelImage.py | 3 -- gramps2/src/Report.py | 8 ++--- gramps2/src/Utils.py | 61 -------------------------------------- gramps2/src/WriteGedcom.py | 7 +++-- gramps2/src/WriteXML.py | 8 ++--- 19 files changed, 77 insertions(+), 121 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 26f22a5fc..fc658136d 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,13 @@ +2005-01-15 Don Allingham + * src/EditPerson.py: don't use quote date + * src/PeopleModel.py: remove BOLD + * src/PeopleView.py: start of sorting support + * src/WriteXML.py: use hlink for Witness + * various: pychecker fixes + * configure.in: bump up to 1.1.3, the "Splunge: this is a + greate idea, but possibly lousy, and I'm not being indecisive" + release + 2005-01-15 Alex Roitman * src/docgen/KwordDoc.py: Register with paper capabilites. * src/docgen/PdfDoc.py: Register with paper capabilites. diff --git a/gramps2/NEWS b/gramps2/NEWS index 1c8db64d5..acbba53e0 100644 --- a/gramps2/NEWS +++ b/gramps2/NEWS @@ -5,7 +5,7 @@ Version 1.1.3 -- the "Splunge: this is a great idea, but possibly lousy, * Alternative .ini -based backend for storing gramps settings (replaces gconf). * Modules providing database access and basic classes are UI-independent now. * Improved Name handling. -* Date hadnling improvements. +* Date handling improvements. * Documentation for core API can now be autogenerated (requires epydoc). * Dramatic performance improvements for large databases. * Spanish Date handler (Julio Sanchez). diff --git a/gramps2/configure.in b/gramps2/configure.in index 9bf7db0c2..27013e406 100644 --- a/gramps2/configure.in +++ b/gramps2/configure.in @@ -7,8 +7,8 @@ AC_PREREQ(2.57) AC_INIT(gramps, 1.1.3, gramps-bugs@lists.sourceforge.net) AC_CONFIG_SRCDIR(src/gramps.py) AM_INIT_AUTOMAKE(1.6.3) -RELEASE=0.CVS$(head -c 10 ${srcdir}/ChangeLog | tr -d '-') -dnl RELEASE=1 +dnl RELEASE=0.CVS$(head -c 10 ${srcdir}/ChangeLog | tr -d '-') +RELEASE=1 VERSIONSTRING=$VERSION if test x"$RELEASE" != "x" diff --git a/gramps2/src/AddrEdit.py b/gramps2/src/AddrEdit.py index acf42ba8c..2c2dfc384 100644 --- a/gramps2/src/AddrEdit.py +++ b/gramps2/src/AddrEdit.py @@ -103,8 +103,7 @@ class AddressEditor: title_label = self.top.get_widget("title") - Utils.set_titles(self.window,title_label, - text,_('Address Editor')) + Utils.set_titles(self.window,title_label,_('Address Editor')) if self.addr: self.srcreflist = self.addr.get_source_references() diff --git a/gramps2/src/ArgHandler.py b/gramps2/src/ArgHandler.py index 281458817..2b4df36eb 100644 --- a/gramps2/src/ArgHandler.py +++ b/gramps2/src/ArgHandler.py @@ -434,7 +434,6 @@ class ArgHandler: os._exit(1) elif format == 'gramps-pkg': import TarFile - import time import WriteXML from cStringIO import StringIO diff --git a/gramps2/src/DateDisplay.py b/gramps2/src/DateDisplay.py index 93d8a9e3c..fb17e2b56 100644 --- a/gramps2/src/DateDisplay.py +++ b/gramps2/src/DateDisplay.py @@ -152,7 +152,7 @@ class DateDisplay: return "%s %s - %s%s" % (qual_str,d1,d2,self.calendar[cal]) elif mod == Date.MOD_RANGE: d1 = self.display_iso(start) - d2 = self.display_cal[cal](date.get_stop_date()) + d2 = self.display_iso(date.get_stop_date()) return "%s %s - %s%s" % (qual_str,d1,d2,self.calendar[cal]) else: text = self.display_iso(start) @@ -206,6 +206,8 @@ class DateDisplayEn(DateDisplay): list value (DateDisplay.format[]). """ + DateDisplay.__init__(self,format) + self.verify_format(format) if format == None: self.format = 0 @@ -246,10 +248,12 @@ class DateDisplayEn(DateDisplay): elif mod == Date.MOD_RANGE: d1 = self.display_cal[cal](start) d2 = self.display_cal[cal](date.get_stop_date()) - return "%sbetween %s and %s%s" % (qual_str,d1,d2,self.calendar[cal]) + return "%sbetween %s and %s%s" % (qual_str,d1,d2, + self.calendar[cal]) else: text = self.display_cal[date.get_calendar()](start) - return "%s%s%s%s" % (qual_str,self._mod_str[mod],text,self.calendar[cal]) + return "%s%s%s%s" % (qual_str,self._mod_str[mod], + text,self.calendar[cal]) def _display_gregorian(self,date_val): year = self._slash_year(date_val[2],date_val[3]) diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index 0f57a9013..bc8df0b45 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -234,8 +234,10 @@ class EditPerson: self.prefix_label.set_text(_('Patronymic:')) self.prefix_label.set_use_underline(True) - self.orig_birth = self.db.get_event_from_handle(person.get_birth_handle()) - self.orig_death = self.db.get_event_from_handle(person.get_death_handle()) + birth_handle = person.get_birth_handle() + death_handle = person.get_death_handle() + self.orig_birth = self.db.get_event_from_handle(birth_handle) + self.orig_death = self.db.get_event_from_handle(death_handle) self.death = RelLib.Event(self.orig_death) self.birth = RelLib.Event(self.orig_birth) self.pname = RelLib.Name(person.get_primary_name()) @@ -986,7 +988,7 @@ class EditPerson: pname = place_title(self.db,event) node = self.etree.add([const.display_pevent(event.get_name()), event.get_description(), - event.get_quote_date(),pname],event) + event.get_date(),pname],event) self.emap[str(event)] = node if self.elist: self.etree.select_row(0) diff --git a/gramps2/src/EditPlace.py b/gramps2/src/EditPlace.py index 277d1ab88..aa433a1f3 100644 --- a/gramps2/src/EditPlace.py +++ b/gramps2/src/EditPlace.py @@ -494,8 +494,8 @@ class EditPlace: if event and event.get_place_handle() == self.place.get_handle(): fevent.append((f,event)) for media_handle in self.db.get_media_object_handles(): - object = self.db.get_object_from_handle(media_handle) - if object and object.get_place_handle() == self.place.get_handle(): + obj = self.db.get_object_from_handle(media_handle) + if obj and obj.get_place_handle() == self.place.get_handle(): mlist.append(object) any = 0 diff --git a/gramps2/src/EventEdit.py b/gramps2/src/EventEdit.py index 1e8a83eb7..e24be09c9 100644 --- a/gramps2/src/EventEdit.py +++ b/gramps2/src/EventEdit.py @@ -104,9 +104,9 @@ class EventEditor: self.witnesslist = [] self.date = Date.Date(self.event.get_date_object()) transname = const.display_event(event.get_name()) - # add the name to the list if it is not already there. This tends to occur - # in translated languages with the 'Death' event, which is a partial match - # to other events + # add the name to the list if it is not already there. This + # tends to occur in translated languages with the 'Death' + # event, which is a partial match to other events if not transname in elist: elist.append(transname) else: @@ -292,7 +292,9 @@ class EventEditor: eplace_obj = self.get_place(self.place_field) buf = self.note_field.get_buffer() - enote = unicode(buf.get_text(buf.get_start_iter(),buf.get_end_iter(),gtk.FALSE)) + start = buf.get_start_iter() + stop = buf.get_end_iter() + enote = unicode(buf.get_text(start,stop,False)) eformat = self.preform.get_active() edesc = unicode(self.descr_field.get_text()) epriv = self.priv.get_active() diff --git a/gramps2/src/Exporter.py b/gramps2/src/Exporter.py index cda00a502..976774442 100644 --- a/gramps2/src/Exporter.py +++ b/gramps2/src/Exporter.py @@ -40,7 +40,7 @@ from gettext import gettext as _ #------------------------------------------------------------------------- import gtk import gnome -import gnome.ui +from gnome.ui import Druid, DruidPageEdge, DruidPageStandard #------------------------------------------------------------------------- # @@ -93,7 +93,7 @@ class Exporter: self.logo = gtk.gdk.pixbuf_new_from_file("%s/gramps.png" % const.rootDir) self.splash = gtk.gdk.pixbuf_new_from_file("%s/splash.jpg" % const.rootDir) - self.d = gnome.ui.Druid() + self.d = Druid() self.w.add(self.d) self.d.add(self.build_info_page()) self.d.add(self.build_format_page()) @@ -129,7 +129,7 @@ class Exporter: Build initial druid page with the overall information about the process. This is a static page, nothing fun here :-) """ - p = gnome.ui.DruidPageEdge(0) + p = DruidPageEdge(0) p.set_title(_('Saving your data')) p.set_title_color(self.fg_color) p.set_bg_color(self.bg_color) @@ -153,7 +153,7 @@ class Exporter: Build the last druid page. The actual text will be added after the save is performed and the success status us known. """ - p = gnome.ui.DruidPageEdge(1) + p = DruidPageEdge(1) p.set_title_color(self.fg_color) p.set_bg_color(self.bg_color) p.set_logo(self.logo) @@ -168,7 +168,7 @@ class Exporter: is necessary, because no choice is made by the user when this page is set up. """ - p = gnome.ui.DruidPageStandard() + p = DruidPageStandard() p.set_title(_('Final save confirmation')) p.set_title_foreground(self.fg_color) p.set_background(self.bg_color) @@ -235,7 +235,7 @@ class Exporter: """ self.format_buttons = [] - p = gnome.ui.DruidPageStandard() + p = DruidPageStandard() p.set_title(_('Choosing the format to save')) p.set_title_foreground(self.fg_color) p.set_background(self.bg_color) @@ -292,7 +292,7 @@ class Exporter: option_box_class = self.exports[ix][3][1] self.option_box_instance = option_box_class(self.person) - p = gnome.ui.DruidPageStandard() + p = DruidPageStandard() p.set_title(title) p.set_title_foreground(self.fg_color) p.set_background(self.bg_color) @@ -310,7 +310,7 @@ class Exporter: """ Build a druid page embedding the FileChooserWidget. """ - p = gnome.ui.DruidPageStandard() + p = DruidPageStandard() p.set_title(_('Selecting the file name')) p.set_title_foreground(self.fg_color) p.set_background(self.bg_color) diff --git a/gramps2/src/GrampsCfg.py b/gramps2/src/GrampsCfg.py index fe30ca3e3..10d51b0ff 100644 --- a/gramps2/src/GrampsCfg.py +++ b/gramps2/src/GrampsCfg.py @@ -47,8 +47,6 @@ import GrampsKeys import RelLib import const import Utils -import PaperMenu -import Plugins import DateHandler #------------------------------------------------------------------------- diff --git a/gramps2/src/PeopleModel.py b/gramps2/src/PeopleModel.py index 584e0056f..9bf48f4a8 100644 --- a/gramps2/src/PeopleModel.py +++ b/gramps2/src/PeopleModel.py @@ -301,15 +301,9 @@ class PeopleModel(gtk.GenericTreeModel): def column_int_id(self,data,node): return node - def column_bold(self,data,node): - return pango.WEIGHT_NORMAL - def column_header(self,node): return node - def column_header_bold(self,node): - return pango.WEIGHT_NORMAL #BOLD - def column_header_view(self,node): return True @@ -332,13 +326,11 @@ COLUMN_DEFS = [ # these columns are hidden, and must always be last in the list (PeopleModel.column_sort_name, None, gobject.TYPE_STRING), - (PeopleModel.column_bold, PeopleModel.column_header_bold,gobject.TYPE_INT), (PeopleModel.column_int_id, None, gobject.TYPE_STRING), ] # dynamic calculation of column indices, for use by various Views COLUMN_INT_ID = len(COLUMN_DEFS) - 1 -COLUMN_BOLD = COLUMN_INT_ID - 1 # indices into main column definition table COLUMN_DEF_LIST = 0 diff --git a/gramps2/src/PeopleView.py b/gramps2/src/PeopleView.py index 8a1e4d300..1ac599b1c 100644 --- a/gramps2/src/PeopleView.py +++ b/gramps2/src/PeopleView.py @@ -80,19 +80,34 @@ class PeopleView: self.columns = [] self.build_columns() - #self.person_tree.set_property('fixed-height-mode',True) self.person_selection = self.person_tree.get_selection() self.person_selection.connect('changed',self.row_changed) self.person_tree.connect('row_activated', self.alpha_event) self.person_tree.connect('button-press-event', self.on_plist_button_press) + def sort_clicked(self,obj): + for col in self.columns: + if obj == col: + if col.get_sort_indicator(): + if col.get_sort_order() == gtk.SORT_ASCENDING: + col.set_sort_order(gtk.SORT_DESCENDING) + else: + col.set_sort_order(gtk.SORT_ASCENDING) + else: + col.set_sort_order(gtk.SORT_ASCENDING) + col.set_sort_indicator(True) + else: + col.set_sort_indicator(False) + def build_columns(self): for column in self.columns: self.person_tree.remove_column(column) column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0) - column.set_resizable(gtk.TRUE) + column.set_resizable(gtk.TRUE) + #column.set_clickable(True) + #column.connect('clicked',self.sort_clicked) column.set_min_width(225) column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) self.person_tree.append_column(column) @@ -105,6 +120,8 @@ class PeopleView: name = column_names[pair[1]] column = gtk.TreeViewColumn(name, self.renderer, text=pair[1]) column.set_resizable(gtk.TRUE) + #column.set_clickable(True) + #column.connect('clicked',self.sort_clicked) column.set_min_width(60) column.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY) self.columns.append(column) @@ -113,11 +130,10 @@ class PeopleView: def build_tree(self): self.person_model = PeopleModel.PeopleModel(self.parent.db,self.DataFilter) - self.sort_model = self.person_model - self.person_tree.set_model(self.sort_model) + self.person_tree.set_model(self.person_model) def blist(self, store, path, node, id_list): - id_list.append(self.sort_model.get_value( + id_list.append(self.person_model.get_value( node, PeopleModel.COLUMN_INT_ID)) @@ -143,8 +159,7 @@ class PeopleView: def change_db(self,db): self.build_columns() self.person_model = PeopleModel.PeopleModel(db,self.DataFilter) - self.sort_model = self.person_model - self.person_tree.set_model(self.sort_model) + self.person_tree.set_model(self.person_model) def remove_from_person_list(self,person): """Remove the selected person from the list. A person object is diff --git a/gramps2/src/ReadGedcom.py b/gramps2/src/ReadGedcom.py index 8089b7cc7..9aab324df 100644 --- a/gramps2/src/ReadGedcom.py +++ b/gramps2/src/ReadGedcom.py @@ -126,7 +126,7 @@ def importData(database, filename, cb=None, use_trans=True): ansel = False gramps = False - for index in range(0,50): + for index in range(50): line = f.readline().split() if len(line) == 0: break @@ -195,7 +195,6 @@ def import2(database, filename, cb, codeset, use_trans): ErrorDialog(m1,m2) return except: - import DisplayTrace Utils.destroy_passed_object(statusWindow) DisplayTrace.DisplayTrace() return @@ -1982,7 +1981,6 @@ def readData(database,active_person,cb): try: importData(database,filename) except: - import DisplayTrace DisplayTrace.DisplayTrace() else: choose.destroy() diff --git a/gramps2/src/RelImage.py b/gramps2/src/RelImage.py index 09449ea20..30193aea2 100644 --- a/gramps2/src/RelImage.py +++ b/gramps2/src/RelImage.py @@ -48,13 +48,10 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- def import_media_object(filename,path,base): - import shutil - if not os.path.exists(filename): ErrorDialog(_("Could not import %s") % filename, _("The file has been moved or deleted")) return "" - return filename #------------------------------------------------------------------------- diff --git a/gramps2/src/Report.py b/gramps2/src/Report.py index e0b03fc61..cc531bf29 100644 --- a/gramps2/src/Report.py +++ b/gramps2/src/Report.py @@ -40,7 +40,7 @@ from types import ClassType, InstanceType # #------------------------------------------------------------------------- import gtk -import gnome.ui +from gnome.ui import FileEntry #------------------------------------------------------------------------- # @@ -1069,7 +1069,7 @@ class ReportDialog(BareReportDialog): hid = self.get_stylesheet_savefile() if hid[-4:]==".xml": hid = hid[0:-4] - self.target_fileentry = gnome.ui.FileEntry(hid,_("Save As")) + self.target_fileentry = FileEntry(hid,_("Save As")) self.target_fileentry.set_modal(True) if self.get_target_is_directory(): @@ -1270,8 +1270,8 @@ class ReportDialog(BareReportDialog): label = gtk.Label("%s:" % _("User Template")) label.set_alignment(0.0,0.5) self.html_table.attach(label, 1, 2, 2, 3, gtk.SHRINK|gtk.FILL) - self.html_fileentry = gnome.ui.FileEntry("HTML_Template", - _("Choose File")) + self.html_fileentry = FileEntry("HTML_Template", + _("Choose File")) self.html_fileentry.set_modal(True) if template_name and not active_index: active_index = template_index diff --git a/gramps2/src/Utils.py b/gramps2/src/Utils.py index ab95be9b1..f8250e786 100644 --- a/gramps2/src/Utils.py +++ b/gramps2/src/Utils.py @@ -538,68 +538,7 @@ def probably_alive(person,db): if descendants_too_old (person, min_generation): return False - return False - - # What about their parents? - - def parents_too_old (person, age_difference): - family_handle = person.get_main_parents_family_handle() - if family_handle: - family = db.get_family_from_handle(family_handle) - for parent_id in [family.get_father_handle(), family.get_mother_handle()]: - if not parent_id: - continue - - parent = db.get_person_from_handle(parent_id) - if parent.birth_handle: - parent_birth = db.get_event_from_handle(parent.birth_handle) - if parent_birth.get_date(): - d = SingleDate (parent_birth.get_date_object().get_start_date()) - d.set_year (d.get_year() + max_generation + age_difference) - if not not_too_old (d): - return True - - if parent.death_handle: - parent_death = db.get_event_from_handle(parent.death_handle) - if parent_death.get_date() != "": - d = SingleDate (parent_death.get_date_object().get_start_date()) - d.set_year (d.get_year() + age_difference) - if not not_too_old (d): - return True - - if parents_too_old (person, 0): - return False - - # As a last resort, trying seeing if their spouse's age gives - # any clue. - for family_handle in person.get_family_handle_list(): - family = db.get_family_from_handle(family_handle) - for spouse_id in [family.get_father_handle(), family.get_mother_handle()]: - if not spouse_id or spouse_id == person.handle: - continue - spouse = db.get_person_from_handle(spouse_id) - sp_birth_handle = spouse.get_birth_handle() - sp_death_handle = spouse.get_death_handle() - if sp_birth_handle: - spouse_birth = db.get_event_from_handle(sp_birth_handle) - if not spouse_birth.get_date().is_empty(): - d = Date.Date(spouse_birth.get_date_object()) - d.set_year(d.get_year() + max_age_difference) - if not not_too_old (d): - return False - - if sp_death_handle: - spouse_death = db.get_event_from_handle(sp_death_handle) - if spouse_death.get_date() != "": - d = Date.Date(spouse_death.get_date_object()) - d.set_year (d.get_year() - min_generation) - if not not_too_old (d): - return False - - if parents_too_old (spouse, max_age_difference): - return False - return True def not_too_old(date): time_struct = time.localtime(time.time()) diff --git a/gramps2/src/WriteGedcom.py b/gramps2/src/WriteGedcom.py index 24eae6b16..cb44191a2 100644 --- a/gramps2/src/WriteGedcom.py +++ b/gramps2/src/WriteGedcom.py @@ -302,8 +302,8 @@ class GedcomWriterOptionBox: self.person = person def get_option_box(self): - self.restrict = 1 - self.private = 1 + self.restrict = True + self.private = True self.cnvtxt = ansel_utf8.utf8_to_ansel self.adopt = GedcomInfo.ADOPT_EVENT @@ -1075,7 +1075,8 @@ class GedcomWriter: self.writeln('%d %s' % (index,name)) self.print_date("%d DATE" % (index + 1), ord.get_date_object()) if ord.get_family_handle(): - self.writeln('%d FAMC @%s@' % (index+1,self.fid(ord.get_family_handle().get_gramps_id()))) + family_id = ord.get_family_handle() + self.writeln('%d FAMC @%s@' % (index+1,self.fid(family_id))) if ord.get_temple(): self.writeln('%d TEMP %s' % (index+1,ord.get_temple())) if ord.get_place_handle(): diff --git a/gramps2/src/WriteXML.py b/gramps2/src/WriteXML.py index a8065913d..4effa0fad 100644 --- a/gramps2/src/WriteXML.py +++ b/gramps2/src/WriteXML.py @@ -479,7 +479,7 @@ class XmlWriter: com = self.fix(w.get_comment()) if w.get_type() == RelLib.Event.ID: self.g.write('%s\n' % sp) - self.g.write(' %s%s\n' % (sp,w.get_value())) + self.g.write(' %s%s\n' % (sp,w.get_value())) if com: self.g.write(' %s%s\n' % (sp,com)) self.g.write('%s\n' % sp) @@ -520,7 +520,7 @@ class XmlWriter: sp2 = " " * (index+1) self.g.write('%s\n' % (sp,self.fix(name))) dateobj = ord.get_date_object() - if dateobj != None and not dateobj.is_empty(): + if dateobj and not dateobj.is_empty(): self.write_date(dateobj,index+1) if ord.get_temple(): self.g.write('%s\n' % (sp2,self.fix(ord.get_temple()))) @@ -528,8 +528,8 @@ class XmlWriter: if ord.get_status() != 0: self.g.write('%s\n' % (sp2,ord.get_status())) if ord.get_family_handle(): - self.g.write('%s\n' % \ - (sp2,self.fix(ord.get_family_handle().get_handle()))) + self.g.write('%s\n' % + (sp2,self.fix(ord.get_family_handle()))) if ord.get_note() != "": self.write_note("note",ord.get_note_object(),index+1) for s in ord.get_source_references():