diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 7935ce38e..3571d6cab 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,4 +1,10 @@ 2005-10-10 Don Allingham + * src/GrampsDBCallback.py: doc changes + * src/NameDisplay.py: remove nickname support + * src/QuestionDialog.py: handle missing icons for pychecker + * src/Report.py: set a default size for the window (600) + * src/ReportUtils.py: doc changes, add common_name + * src/plugins/DetAncestralReport.py: * src/Date.py: set default modifier properly, fix compare and sortval assignment * src/RelLib.py: fix source reference date comparison diff --git a/gramps2/src/GrampsDBCallback.py b/gramps2/src/GrampsDBCallback.py index dcce42b40..b9d3144ab 100644 --- a/gramps2/src/GrampsDBCallback.py +++ b/gramps2/src/GrampsDBCallback.py @@ -59,9 +59,8 @@ class GrampsDBCallback(object): Classes that want to emit signals need to inherit from the GrampsDBCallback class and ensure that its __init__ method is called. They then need to declare the signals that they - can emit and the types of each callbacks arguments. - - e.g. + can emit and the types of each callbacks arguments. For + example:: class TestSignals(GrampsDBCallback): @@ -88,27 +87,23 @@ class GrampsDBCallback(object): Emitting signals ================ - Signals are emitted using the emit method. + Signals are emitted using the emit method. e.g.:: - e.g. - def emit_signal(self): self.emit('test-signal',(1,)) The parameters are passed as a tuple so a single parameter must be passed as a 1 element tuple. - - Connecting callbacks to signals - ============================== + =============================== Attaching a callback to the signals is similar to the gtk - connect methods. e.g. + connect methods. e.g.:: # connect to a function. def fn(i): - print "got signal value = ", i + print 'got signal value = ', i t = TestSignals() t.connect('test-signal', fn) @@ -117,7 +112,7 @@ class GrampsDBCallback(object): class C(object): def cb_func(self, i): - print "got class signal = ", 1 + print 'got class signal = ', 1 r = R() t.connect('test-signal', r.cb_func) @@ -130,7 +125,7 @@ class GrampsDBCallback(object): key returned from the connect call. This key can be passed to the disconnect method to remove the callback from the signals callback list. - e.g. + e.g.:: t = TestSignals() @@ -138,7 +133,7 @@ class GrampsDBCallback(object): class C(object): def cb_func(self, i): - print "got class signal = ", 1 + print 'got class signal = ', 1 r = R() key = t.connect('test-signal', r.cb_func) @@ -156,7 +151,7 @@ class GrampsDBCallback(object): be used to block the signals for a single instance and disable_all_signals() can be used to block signals for the class: - e.g. + e.g.:: class TestSignals(GrampsDBCallback): diff --git a/gramps2/src/NameDisplay.py b/gramps2/src/NameDisplay.py index 751c02b77..762e75878 100644 --- a/gramps2/src/NameDisplay.py +++ b/gramps2/src/NameDisplay.py @@ -133,9 +133,9 @@ class NameDisplay: """ name = person.get_primary_name() if name.display_as == RelLib.Name.LNFN: - return self._lnfn(name,person.get_nick_name()) + return self._lnfn(name,"") else: - return self._fnln(name,person.get_nick_name()) + return self._fnln(name,"") def display_formal(self,person): """ diff --git a/gramps2/src/QuestionDialog.py b/gramps2/src/QuestionDialog.py index 82bf29d36..3092afbd1 100644 --- a/gramps2/src/QuestionDialog.py +++ b/gramps2/src/QuestionDialog.py @@ -44,7 +44,10 @@ from gtk.gdk import pixbuf_new_from_file import const import GrampsKeys -ICON = pixbuf_new_from_file(const.icon) +try: + ICON = pixbuf_new_from_file(const.icon) +except: + pass class SaveDialog: def __init__(self,msg1,msg2,task1,task2,parent=None): diff --git a/gramps2/src/Report.py b/gramps2/src/Report.py index 453026bc9..9f5f87f51 100644 --- a/gramps2/src/Report.py +++ b/gramps2/src/Report.py @@ -369,7 +369,7 @@ class BareReportDialog: self.ok.connect('clicked',self.on_ok_clicked) self.cancel.connect('clicked',self.on_cancel) - self.window.set_resize_mode(0) + self.window.set_default_size(600,-1) # Set up and run the dialog. These calls are not in top down # order when looking at the dialog box as there is some diff --git a/gramps2/src/ReportUtils.py b/gramps2/src/ReportUtils.py index 5b8fa691b..b6a87891e 100644 --- a/gramps2/src/ReportUtils.py +++ b/gramps2/src/ReportUtils.py @@ -21,6 +21,10 @@ # $Id$ +""" +A collection of utilities to aid in the generation of reports. +""" + #------------------------------------------------------------------------ # # GRAMPS modules @@ -1053,6 +1057,17 @@ def estimate_age(db, person, end_handle=None, start_handle=None): return age def sanitize_list(obj_list,exclude_private): + """ + Removes private objects from the list. + + @param obj_list: objects that have a privacy flag + @type obj_list: list + @param exclude_private: indicates if objects marked private + are eliminated from the list + @type obj_list: bool + @returns: objects that match the privacy request + @rtype: list + """ if exclude_private: return [obj for obj in obj_list if not obj.private] else: @@ -1317,17 +1332,13 @@ def get_birth_death_strings(database,person,empty_date="",empty_place=""): def born_died_str(database,person,endnotes=None,name_object=None,person_name=None): """ Composes a string describing birth and death of a person. - - The string is composed in the following form: - "Such-and-such was born on-a-date in a-place, - and died on-a-date in a-place" Missing information will be omitted without loss of readability. Optional references may be added to birth and death events. Optional Name object may be used to override a person's Name instance. Optional string may be used to override the string representation of a name. - @param database GRAMPS database to which the Person object belongs - @type db: GrampsDbBase + @param database: GRAMPS database to which the Person object belongs + @type database: GrampsDbBase @param person: Person instance for which the string has to be composed @type person: Person @param endnotes: Function to use for reference composition. If None @@ -1530,15 +1541,11 @@ def born_died_str(database,person,endnotes=None,name_object=None,person_name=Non def married_str(database,person,spouse,event,endnotes=None, empty_date="",empty_place="",is_first=True): """ - Composes a string describing marriage of a person. + Composes a string describing marriage of a person. Missing information will + be omitted without loss of readability. Optional references may be added to + birth and death events. - The string is composed in the following form: - "He/She married such-and-such on-a-date" or - "He/She married such-and-such in a-place", - Missing information will be omitted without loss of readability. - Optional references may be added to birth and death events. - - @param database GRAMPS database to which the Person object belongs + @param database: GRAMPS database to which the Person object belongs @type db: GrampsDbBase @param person: Person instance whose marriage is discussed @type person: Person @@ -1620,6 +1627,22 @@ def married_str(database,person,spouse,event,endnotes=None, # #------------------------------------------------------------------------- def married_rel_str(database,person,family,is_first=True): + """ + Composes a string describing marriage of a person. Missing information will + be omitted without loss of readability. Optional references may be added to + birth and death events. + + @param database: GRAMPS database to which the Person object belongs + @type db: GrampsDbBase + @param person: Person instance whose marriage is discussed + @type person: Person + @param family: Family instance whose marriage is discussed + @type family: Family + @param is_first: Indicates if this is a first marriage + @type is_first: bool + @returns: A composed string + @rtype: unicode + """ spouse_handle = find_spouse(person,family) spouse = database.get_person_from_handle(spouse_handle) @@ -2079,7 +2102,6 @@ _rtype = { def relationship_name(rtype): return _rtype.get(rtype) - def old_calc_age(database,person): """ Calulate age. @@ -2130,3 +2152,8 @@ def old_calc_age(database,person): return (age,units) +def common_name(person,use_nick=False): + if use_nick and person.get_nick_name(): + return person.get_nick_name() + else: + return person.get_primary_name().get_first_name() diff --git a/gramps2/src/plugins/DetAncestralReport.py b/gramps2/src/plugins/DetAncestralReport.py index 5dbf6a244..1760e1d71 100644 --- a/gramps2/src/plugins/DetAncestralReport.py +++ b/gramps2/src/plugins/DetAncestralReport.py @@ -100,10 +100,10 @@ class DetAncestorReport(Report.Report): (self.max_generations,self.pgbrk) \ = options_class.get_report_generations() - self.firstName = options_class.handler.options_dict['firstnameiop'] self.fullDate = options_class.handler.options_dict['fulldates'] self.listChildren = options_class.handler.options_dict['listc'] self.includeNotes = options_class.handler.options_dict['incnotes'] + self.usenick = options_class.handler.options_dict['usenick'] self.blankPlace = options_class.handler.options_dict['repplace'] self.blankDate = options_class.handler.options_dict['repdate'] self.calcAgeFlag = options_class.handler.options_dict['computeage'] @@ -147,7 +147,7 @@ class DetAncestorReport(Report.Report): name = _nd.display_name(self.start_person.get_primary_name()) self.doc.start_paragraph("DAR-Title") - title = _("Detailed Ancestral Report for %s") % name + title = _("Ancestral Report for %s") % name self.doc.write_text(title) self.doc.end_paragraph() @@ -220,7 +220,7 @@ class DetAncestorReport(Report.Report): # Check birth record - first = person.get_primary_name().get_first_name() + first = ReportUtils.common_name(person,self.usenick) text = ReportUtils.born_str(self.database,person,first, self.EMPTY_DATE,self.EMPTY_PLACE) if text: @@ -245,7 +245,7 @@ class DetAncestorReport(Report.Report): if text: self.doc.write_text(text) - first = person.get_primary_name().get_first_name() + first = ReportUtils.common_name(person,self.usenick) self.write_parents(person, first) self.write_marriage(person) @@ -260,7 +260,7 @@ class DetAncestorReport(Report.Report): self.doc.end_paragraph() self.doc.write_note(person.get_note(),person.get_note_format(),"DAR-Entry") - first = 1 + first = True if self.includeNames: for alt_name in person.get_alternate_names(): if first: @@ -268,7 +268,7 @@ class DetAncestorReport(Report.Report): self.doc.write_text(_('More about %(person_name)s:') % { 'person_name' : name }) self.doc.end_paragraph() - first = 0 + first = False self.doc.start_paragraph('DAR-MoreDetails') self.doc.write_text(_('%(name_kind)s: %(name)s%(endnotes)s') % { 'name_kind' : const.NameTypesMap.find_value(alt_name.get_type()), @@ -290,7 +290,7 @@ class DetAncestorReport(Report.Report): if first: self.doc.start_paragraph('DAR-MoreHeader') self.doc.write_text(_('More about %(person_name)s:') % { - 'person_name' : person.get_primary_name().get_regular_name() }) + 'person_name' : _nd.display(person) }) self.doc.end_paragraph() first = 0 @@ -428,7 +428,7 @@ class DetAncestorReport(Report.Report): if ind_handle: ind = self.database.get_person_from_handle(ind_handle) person_name = _nd.display(ind) - firstName = ind.get_primary_name().get_first_name() + firstName = ReportUtils.common_name(ind,self.usenick) else: firstName = 0 @@ -569,6 +569,7 @@ class DetAncestorOptions(ReportOptions.ReportOptions): 'fulldates' : 1, 'listc' : 1, 'incnotes' : 1, + 'usenick' : 1, 'repplace' : 0, 'repdate' : 0, 'computeage' : 1, @@ -592,6 +593,9 @@ class DetAncestorOptions(ReportOptions.ReportOptions): 'incnotes' : ("=0/1","Whether to include notes.", ["Do not include notes","Include notes"], True), + 'usenick' : ("=0/1","Whether to use the nick name as the first name.", + ["Do not use nick name","Use nick name"], + True), 'repplace' : ("=0/1","Whether to replace missing Places with blanks.", ["Do not replace missing Places","Replace missing Places"], True), @@ -652,17 +656,16 @@ class DetAncestorOptions(ReportOptions.ReportOptions): font.set(face=BaseDoc.FONT_SANS_SERIF,size=10,italic=0, bold=1) para = BaseDoc.ParagraphStyle() para.set_font(font) - #para.set_header_level(3) para.set_left_margin(1.0) # in centimeters para.set(pad=0.5) para.set_description(_('The style used for the children list title.')) default_style.add_style("DAR-ChildTitle",para) font = BaseDoc.FontStyle() - font.set(face=BaseDoc.FONT_SANS_SERIF,size=9) + font.set(size=10) para = BaseDoc.ParagraphStyle() para.set_font(font) - para.set(first_indent=-0.5,lmargin=1.5,pad=0.25) + para.set(first_indent=-0.75,lmargin=1.75,pad=0.25) para.set_description(_('The style used for the children list.')) default_style.add_style("DAR-ChildList",para) @@ -684,15 +687,15 @@ class DetAncestorOptions(ReportOptions.ReportOptions): default_style.add_style("DAR-First-Entry",para) font = BaseDoc.FontStyle() - font.set(bold=1) + font.set(size=10,face=BaseDoc.FONT_SANS_SERIF,bold=1) para = BaseDoc.ParagraphStyle() para.set_font(font) - para.set(first_indent=0.0,lmargin=0.0,pad=0.25) + para.set(first_indent=0.0,lmargin=1.0,pad=0.25) para.set_description(_('The style used for the More About header.')) default_style.add_style("DAR-MoreHeader",para) font = BaseDoc.FontStyle() - font.set(face=BaseDoc.FONT_SANS_SERIF,size=9) + font.set(face=BaseDoc.FONT_SERIF,size=10) para = BaseDoc.ParagraphStyle() para.set_font(font) para.set(first_indent=0.0,lmargin=1.0,pad=0.25) @@ -709,7 +712,7 @@ class DetAncestorOptions(ReportOptions.ReportOptions): default_style.add_style("DAR-Endnotes-Header",para) para = BaseDoc.ParagraphStyle() - para.set(first_indent=0.5,lmargin=1.0,pad=0.25) + para.set(first_indent=-0.5,lmargin=1.5,pad=0.25) para.set_description(_('The basic style used for the endnotes text display.')) default_style.add_style("DAR-Endnotes",para) @@ -719,10 +722,6 @@ class DetAncestorOptions(ReportOptions.ReportOptions): the user to select the sort method. """ - # Pronoun instead of first name - self.first_name_option = gtk.CheckButton(_("Use first names instead of pronouns")) - self.first_name_option.set_active(self.options_dict['firstnameiop']) - # Full date usage self.full_date_option = gtk.CheckButton(_("Use full dates instead of only the year")) self.full_date_option.set_active(self.options_dict['fulldates']) @@ -735,6 +734,10 @@ class DetAncestorOptions(ReportOptions.ReportOptions): self.include_notes_option = gtk.CheckButton(_("Include notes")) self.include_notes_option.set_active(self.options_dict['incnotes']) + # Print notes + self.usenick = gtk.CheckButton(_("Use nickname for common name")) + self.usenick.set_active(self.options_dict['usenick']) + # Replace missing Place with ___________ self.place_option = gtk.CheckButton(_("Replace missing places with ______")) self.place_option.set_active(self.options_dict['repplace']) @@ -775,7 +778,7 @@ class DetAncestorOptions(ReportOptions.ReportOptions): # if you want to put everyting in the generic "Options" category, use # self.add_option(text,widget) instead of self.add_frame_option(category,text,widget) - dialog.add_frame_option(_('Content'),'',self.first_name_option) + dialog.add_frame_option(_('Content'),'',self.usenick) dialog.add_frame_option(_('Content'),'',self.full_date_option) dialog.add_frame_option(_('Content'),'',self.list_children_option) dialog.add_frame_option(_('Content'),'',self.age_option) @@ -794,10 +797,10 @@ class DetAncestorOptions(ReportOptions.ReportOptions): Parses the custom options that we have added. """ - self.options_dict['firstnameiop'] = int(self.first_name_option.get_active()) self.options_dict['fulldates'] = int(self.full_date_option.get_active()) self.options_dict['listc'] = int(self.list_children_option.get_active()) self.options_dict['incnotes'] = int(self.include_notes_option.get_active()) + self.options_dict['usenick'] = int(self.usenick.get_active()) self.options_dict['repplace'] = int(self.place_option.get_active()) self.options_dict['repdate'] = int(self.date_option.get_active()) self.options_dict['computeage'] = int(self.age_option.get_active())