From 7afbe304a2e75045304b8cccfb3a41ce7bdc3647 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 15 Mar 2002 14:58:29 +0000 Subject: [PATCH] New Kword interface supporting tables, allow alternate name to be swapped with primary name svn: r839 --- gramps/src/EditPerson.py | 40 +++++++++--- gramps/src/NameEdit.py | 2 +- gramps/src/Report.py | 5 +- gramps/src/docgen/KwordDoc.py | 112 ++++++++++++++++++++++++---------- gramps/src/po/template.po | 53 +++++++++------- 5 files changed, 147 insertions(+), 65 deletions(-) diff --git a/gramps/src/EditPerson.py b/gramps/src/EditPerson.py index b27c66aed..006a0d7b5 100644 --- a/gramps/src/EditPerson.py +++ b/gramps/src/EditPerson.py @@ -257,20 +257,13 @@ class EditPerson: 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(GrampsCfg.nameof(person)) - self.suffix.set_text(self.pname.getSuffix()) - self.surname_field.set_text(self.pname.getSurname()) - self.given.set_text(self.pname.getFirstName()) + self.write_primary_name() types = const.NameTypesMap.keys() types.sort() self.ntype_field.set_popdown_strings(types) self.autotype = AutoComp.AutoEntry(self.ntype_field.entry,types) - self.ntype_field.entry.set_text(_(self.pname.getType())) - t = self.pname.getType() if person.getGender() == Person.male: self.is_male.set_active(1) @@ -280,7 +273,6 @@ class EditPerson: self.is_unknown.set_active(1) self.nick.set_text(person.getNickName()) - self.title.set_text(self.pname.getTitle()) self.update_birth_death() self.load_person_image() @@ -1011,6 +1003,14 @@ class EditPerson: def aka_double_click(self,obj,event): if event.button == 1 and event.type == _2BUTTON_PRESS: self.on_aka_update_clicked(obj) + elif event.button == 3: + menu = gtk.GtkMenu() + item = gtk.GtkTearoffMenuItem() + item.show() + menu.append(item) + Utils.add_menuitem(menu,_("Make the selected name the preferred name"), + None,self.change_name) + menu.popup(None,None,None,0,0) def on_aka_update_clicked(self,obj): import NameEdit @@ -1342,6 +1342,28 @@ class EditPerson: self.lds_not_loaded = 0 self.draw_lds() + def change_name(self,obj): + if len(self.name_list.selection) == 1: + old = self.pname + row = self.name_list.selection[0] + new = self.name_list.get_row_data(row) + self.nlist.remove(new) + self.nlist.append(old) + self.redraw_name_list() + self.pname = Name(new) + self.write_primary_name() + + def write_primary_name(self): + # initial values + self.get_widget("activepersonTitle").set_text(GrampsCfg.nameof(self.person)) + self.suffix.set_text(self.pname.getSuffix()) + + self.surname_field.set_text(self.pname.getSurname()) + self.given.set_text(self.pname.getFirstName()) + + self.ntype_field.entry.set_text(_(self.pname.getType())) + self.title.set_text(self.pname.getTitle()) + def update_ord(func,ord,date,temple,stat,place): if not ord: if (date or temple or place): diff --git a/gramps/src/NameEdit.py b/gramps/src/NameEdit.py index 0e8725e10..ffc47a24d 100644 --- a/gramps/src/NameEdit.py +++ b/gramps/src/NameEdit.py @@ -154,7 +154,7 @@ class NameEditor: if self.name.getPrivacy() != priv: self.name.setPrivacy(priv) self.parent.lists_changed = 1 - + def src_changed(parent): parent.lists_changed = 1 diff --git a/gramps/src/Report.py b/gramps/src/Report.py index 3fc49e3c6..73d94195d 100644 --- a/gramps/src/Report.py +++ b/gramps/src/Report.py @@ -832,7 +832,10 @@ class ReportDialog: self.make_document() # Create the report object and product the report. - self.make_report() + try: + self.make_report() + except (IOError,OSError),msg: + GnomeErrorDialog(str(msg)) # Clean up the dialog object self.window.destroy() diff --git a/gramps/src/docgen/KwordDoc.py b/gramps/src/docgen/KwordDoc.py index 9989d7d28..883cc69df 100644 --- a/gramps/src/docgen/KwordDoc.py +++ b/gramps/src/docgen/KwordDoc.py @@ -20,6 +20,8 @@ from TextDoc import * from latin_utf8 import latin_to_utf8 + +import Utils import time import StringIO import os @@ -33,17 +35,17 @@ _ = intl.gettext def points(val): inch = float(val)/2.54 return (int(inch*72)) - + #------------------------------------------------------------------------ # -# +# # #------------------------------------------------------------------------ class KwordDoc(TextDoc): def open(self,filename): self.photo_list = [] - + if filename[-4:] != ".kwd": self.filename = filename + ".kwd" else: @@ -130,8 +132,18 @@ class KwordDoc(TextDoc): self.f.write('bottom="%d" ' % points(self.height-self.bmargin)) self.f.write('runaround="1" />\n') + self.cell_row= 0 + self.cell_col= 0 + self.frameset_flg= 1 + self.table_no= 0 + self.cell_style= "" + self.cell_span= 1 + def close(self): - self.f.write('\n') + if self.frameset_flg == 1: + self.f.write('\n') + self.frameset_flg= 0 + for p in self.photo_list: self.f.write('\n' % p[1]) @@ -194,13 +206,17 @@ class KwordDoc(TextDoc): self.f.write('\n') self.f.write('\n') if p.get_top_border(): - self.f.write('\n') + self.f.write('\n') if p.get_bottom_border(): - self.f.write('\n') + self.f.write('\n') if p.get_right_border(): - self.f.write('\n') + self.f.write('\n') if p.get_left_border(): - self.f.write('\n') + self.f.write('\n') if left != 0: self.f.write('\n' % points(left)) self.f.write('\n') @@ -231,7 +247,7 @@ class KwordDoc(TextDoc): self.f.close() self.m.close() - + def start_page(self,orientation=None): pass @@ -246,9 +262,9 @@ class KwordDoc(TextDoc): self.p = self.style_list[self.style_name] self.font = self.p.get_font() if self.font.get_type_face() == FONT_SERIF: - self.font_face = "times" + self.font_face = "Arial" else: - self.font_face = "helvetica" + self.font_face = "Times New Roman" if leader != None: self.text = leader + '\t' @@ -259,6 +275,10 @@ class KwordDoc(TextDoc): self.bold_stop = len(self.text) def end_paragraph(self): + if self.frameset_flg == 0: + self.f.write('\n') + self.frameset_flg= 1 + if self.bold_start != 0 and self.bold_stop != len(self.text): txt = '\n\n\n' % self.font_face self.format_list.append(txt) @@ -276,7 +296,7 @@ class KwordDoc(TextDoc): pad = points(self.p.get_padding())/2 self.f.write('\n' % (pad,pad)) - + if self.p.get_alignment() == PARA_ALIGN_CENTER: self.f.write('\n') elif self.p.get_alignment() == PARA_ALIGN_JUSTIFY: @@ -332,39 +352,64 @@ class KwordDoc(TextDoc): self.format_list.append(txt) def start_table(self,name,style_name): - pass + self.tbl= self.table_styles[style_name] + self.cell_left= (self.lmargin * 72)/ 2.54 + self.tbl_width= ((self.width - self.lmargin - self.rmargin) * 72 ) / 2.54 + self.f.write(' \n') + self.cell_row= 0 + self.cell_col= 0 + self.frameset_flg= 0 def end_table(self): - pass + self.table_no= self.table_no + 1 def start_row(self): pass def end_row(self): - pass + self.cell_row= self.cell_row + 1 + self.cell_col= 0 + self.cell_left= (self.lmargin * 72)/ 2.54 def start_cell(self,style_name,span=1): - pass + self.cell_span= span + self.cell_style= style_name + self.cell_right = self.cell_left + for i in range(0,span): + col_width = self.tbl.get_column_width(self.cell_col+i) + spc = (self.tbl_width * col_width) / 100 + self.cell_right = self.cell_right + spc + self.f.write('\n' % (self.table_no, self.cell_row, self.cell_col)) + self.f.write('\n' % (self.cell_row*23+self.table_no*125+95)) + self.frameset_flg= 1 + self.cell_col = self.cell_col + span - 1 def end_cell(self): - pass + self.f.write('\n') + self.cell_col= self.cell_col + 1 + self.frameset_flg= 0 + self.cell_left= self.cell_right - def add_photo(self,name,pos,x,y): + def add_photo(self,name,pos,x_cm,y_cm): - im = ImgManip.ImgMapip(name) - nx,ny = im.size() + im = ImgManip.ImgManip(name) + (x,y)= im.size() + ratio = float(x_cm)*float(y)/(float(y_cm)*float(x)) - scale = float(nx)/float(ny) - x = points(x) - y = points(y) - - if scale > 1.0: - scale = 1.0/scale - act_width = x - act_height = y * scale + if ratio < 1: + act_width = x_cm + act_height = y_cm*ratio else: - act_width = x * scale - act_height = y + act_height = y_cm + act_width = x_cm/ratio index = len(self.photo_list)+1 tag = 'pictures/picture%d.jpeg' % index @@ -372,12 +417,12 @@ class KwordDoc(TextDoc): txt = '\n' % len(self.text) txt = txt + '\n' % tag txt = txt + '\n' - + self.bold_stop = len(self.text) self.format_list.append(txt) self.text = self.text + '#' - + def horizontal_line(self): pass @@ -430,4 +475,5 @@ if __name__ == "__main__": doc.close() -Plugins.register_text_doc(_("KWord"),KwordDoc,0,1,1) +#Change to support tables (args were: 0,1,1) +Plugins.register_text_doc(_("KWord"),KwordDoc,1,1,1) diff --git a/gramps/src/po/template.po b/gramps/src/po/template.po index 8d8e79195..0661d3bc0 100644 --- a/gramps/src/po/template.po +++ b/gramps/src/po/template.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: Tue Mar 12 20:00:53 2002\n" +"POT-Creation-Date: Fri Mar 15 07:51:16 2002\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -24,7 +24,7 @@ msgid "Choose Spouse/Partner of %s" msgstr "" #: AddSpouse.py:110 const.py:391 const.py:399 plugins/FamilyGroup.py:288 -#: plugins/FamilyGroup.py:290 +#: plugins/FamilyGroup.py:290 plugins/test.py:288 plugins/test.py:290 msgid "Married" msgstr "" @@ -67,7 +67,7 @@ msgstr "" #: gramps.glade:5570 gramps.glade:5591 gramps.glade:5635 gramps.glade:5665 #: gramps.glade:6570 gramps.glade:6600 gramps.glade:6617 gramps.glade:6647 #: gramps_main.py:1370 gramps_main.py:1532 plugins/EventCmp.py:474 -#: plugins/FamilyGroup.py:138 +#: plugins/FamilyGroup.py:138 plugins/test.py:138 msgid "Birth" msgstr "" @@ -83,14 +83,14 @@ msgstr "" #: ChooseParents.py:161 gramps.glade:1866 gramps.glade:5040 #: gramps_main.py:1459 mergedata.glade:518 mergedata.glade:1180 #: plugins/FamilyGroup.py:197 plugins/IndivSummary.py:283 -#: plugins/WebPage.py:245 plugins/WebPage.py:248 +#: plugins/WebPage.py:245 plugins/WebPage.py:248 plugins/test.py:197 msgid "Mother" msgstr "" #: ChooseParents.py:162 gramps.glade:1775 gramps.glade:4842 #: gramps_main.py:1458 mergedata.glade:766 mergedata.glade:1478 #: plugins/FamilyGroup.py:184 plugins/IndivSummary.py:269 -#: plugins/WebPage.py:244 plugins/WebPage.py:247 +#: plugins/WebPage.py:244 plugins/WebPage.py:247 plugins/test.py:184 msgid "Father" msgstr "" @@ -320,6 +320,7 @@ msgid "Edit" msgstr "" #: EditPerson.glade:385 plugins/EventCmp.py:474 plugins/FamilyGroup.py:156 +#: plugins/test.py:156 msgid "Death" msgstr "" @@ -341,9 +342,9 @@ msgstr "" msgid "female" msgstr "" -#: EditPerson.glade:670 EditPerson.py:401 const.py:105 gramps.glade:6720 +#: EditPerson.glade:670 EditPerson.py:393 const.py:105 gramps.glade:6720 #: plugins/FamilyGroup.py:379 plugins/IndivSummary.py:161 -#: plugins/WebPage.py:505 +#: plugins/WebPage.py:505 plugins/test.py:379 msgid "unknown" msgstr "" @@ -747,20 +748,24 @@ msgstr "" msgid "Internet Address Editor" msgstr "" -#: EditPerson.py:376 GrampsCfg.py:61 const.py:118 gramps.glade:4991 +#: EditPerson.py:368 GrampsCfg.py:61 const.py:118 gramps.glade:4991 #: gramps.glade:5186 gramps.glade:5570 gramps.glade:5635 gramps.glade:6570 #: gramps.glade:6617 msgid "None" msgstr "" -#: EditPerson.py:393 EditSource.py:138 +#: EditPerson.py:385 EditSource.py:138 msgid "%(father)s and %(mother)s" msgstr "" -#: EditPerson.py:730 EditPerson.py:739 +#: EditPerson.py:722 EditPerson.py:731 msgid "Are you sure you want to abandon your changes?" msgstr "" +#: EditPerson.py:1011 +msgid "Make the selected name the preferred name" +msgstr "" + #: EditPerson.py:1071 Marriage.py:368 msgid "GRAMPS ID value was not changed." msgstr "" @@ -1027,7 +1032,7 @@ msgstr "" msgid "Location Editor" msgstr "" -#: Marriage.py:102 Marriage.py:479 Marriage.py:497 Utils.py:135 +#: Marriage.py:102 Marriage.py:480 Marriage.py:498 Utils.py:135 #: plugins/Check.py:178 msgid "%s and %s" msgstr "" @@ -1836,7 +1841,7 @@ msgstr "" msgid "HTML" msgstr "" -#: docgen/KwordDoc.py:433 +#: docgen/KwordDoc.py:479 msgid "KWord" msgstr "" @@ -2205,6 +2210,7 @@ msgid "Relationship" msgstr "" #: gramps.glade:1598 plugins/FamilyGroup.py:277 plugins/FamilyGroup.py:381 +#: plugins/test.py:277 plugins/test.py:381 msgid "Spouse" msgstr "" @@ -2225,7 +2231,7 @@ msgid "Add/Edit/View" msgstr "" #: gramps.glade:2022 plugins/FamilyGroup.py:311 plugins/IndivSummary.py:174 -#: plugins/WebPage.py:521 +#: plugins/WebPage.py:521 plugins/test.py:311 msgid "Children" msgstr "" @@ -2780,6 +2786,7 @@ msgstr "" #: plugins/DescendReport.py:276 plugins/DetAncestralReport.py:607 #: plugins/FamilyGroup.py:460 plugins/GraphViz.py:288 #: plugins/IndivSummary.py:431 plugins/Summary.py:133 plugins/WebPage.py:1070 +#: plugins/test.py:460 msgid "Beta" msgstr "" @@ -2875,7 +2882,7 @@ msgstr "" #: plugins/DescendReport.py:143 plugins/DescendReport.py:275 #: plugins/DetAncestralReport.py:608 plugins/FamilyGroup.py:338 #: plugins/FamilyGroup.py:459 plugins/IndivSummary.py:332 -#: plugins/IndivSummary.py:432 +#: plugins/IndivSummary.py:432 plugins/test.py:338 plugins/test.py:459 msgid "Text Reports" msgstr "" @@ -3181,31 +3188,31 @@ msgid "Aids in the analysis of data by allowing the development of custom filter msgstr "" #: plugins/FamilyGroup.py:109 plugins/FamilyGroup.py:338 -#: plugins/FamilyGroup.py:458 +#: plugins/FamilyGroup.py:458 plugins/test.py:109 plugins/test.py:338 msgid "Family Group Report" msgstr "" -#: plugins/FamilyGroup.py:118 +#: plugins/FamilyGroup.py:118 plugins/test.py:118 msgid "Husband" msgstr "" -#: plugins/FamilyGroup.py:120 +#: plugins/FamilyGroup.py:120 plugins/test.py:120 msgid "Wife" msgstr "" -#: plugins/FamilyGroup.py:342 +#: plugins/FamilyGroup.py:342 plugins/test.py:342 msgid "Family Group Report for %s" msgstr "" -#: plugins/FamilyGroup.py:347 +#: plugins/FamilyGroup.py:347 plugins/test.py:347 msgid "Save Family Group Report" msgstr "" -#: plugins/FamilyGroup.py:369 +#: plugins/FamilyGroup.py:369 plugins/test.py:369 msgid "No known marriages" msgstr "" -#: plugins/FamilyGroup.py:461 +#: plugins/FamilyGroup.py:461 plugins/test.py:461 msgid "Creates a family group report, showing information on a set of parents and their children." msgstr "" @@ -4167,6 +4174,10 @@ msgstr "" msgid "Database Summary" msgstr "" +#: plugins/test.py:458 +msgid "test" +msgstr "" + #: plugins/verify.glade:18 msgid "Database Verify - GRAMPS" msgstr ""