From 0aa3cce886a9c0cb241edc043a4f072e10b1729d Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 3 Feb 2003 19:24:27 +0000 Subject: [PATCH] Image handling fixes svn: r1284 --- src/DrawDoc.py | 14 ++++++++ src/FamilyView.py | 2 +- src/GenericFilter.py | 3 +- src/ImageSelect.py | 4 +-- src/PlaceView.py | 12 +++---- src/RelImage.py | 7 ++-- src/Report.py | 2 +- src/Utils.py | 2 +- src/const.py | 1 + src/const.py.in | 1 + src/docgen/OpenDrawDoc.py | 5 +++ src/docgen/PSDrawDoc.py | 5 +++ src/docgen/PdfDrawDoc.py | 56 ++++++++++++++++++++++++++--- src/docgen/SvgDrawDoc.py | 74 +++++++++++++++++++++++++++++++++++++-- src/po/template.po | 27 ++++---------- 15 files changed, 171 insertions(+), 44 deletions(-) diff --git a/src/DrawDoc.py b/src/DrawDoc.py index 56139b927..4ed64b6e1 100644 --- a/src/DrawDoc.py +++ b/src/DrawDoc.py @@ -25,6 +25,9 @@ #------------------------------------------------------------------------ import TextDoc +SOLID = 0 +DASHED = 1 + #------------------------------------------------------------------------ # # GraphicsStyle @@ -39,6 +42,7 @@ class GraphicsStyle: self.shadow = obj.shadow self.color = obj.color self.lwidth = obj.lwidth + self.lstyle = obj.lstyle else: self.height = 0 self.width = 0 @@ -46,6 +50,7 @@ class GraphicsStyle: self.shadow = 0 self.lwidth = 0.5 self.color = (255,255,255) + self.lstyle = SOLID def set_line_width(self,val): self.lwidth = val @@ -53,6 +58,12 @@ class GraphicsStyle: def get_line_width(self): return self.lwidth + def get_line_style(self): + return self.lstyle + + def set_line_style(self,val): + self.lstyle = val + def set_height(self,val): self.height = val @@ -142,6 +153,9 @@ class DrawDoc: def end_page(self): pass + def draw_path(self,style,path): + pass + def draw_box(self,style,text,x,y): pass diff --git a/src/FamilyView.py b/src/FamilyView.py index 15d56a43e..6bf8160f3 100644 --- a/src/FamilyView.py +++ b/src/FamilyView.py @@ -136,7 +136,7 @@ class FamilyView: self.child_selection = self.child_list.get_selection() Utils.build_columns(self.child_list, - [ (_(''),30,-1), (_('Name'),250,-1), (_('ID'),50,-1), + [ ('',30,-1), (_('Name'),250,-1), (_('ID'),50,-1), (_('Gender'),100,-1), (_('Birth Date'),150,-1), (_('Status'),150,-1), ('',0,-1) ]) diff --git a/src/GenericFilter.py b/src/GenericFilter.py index 1a460f5be..5efb5a528 100644 --- a/src/GenericFilter.py +++ b/src/GenericFilter.py @@ -835,7 +835,8 @@ class FilterParser(handler.ContentHandler): pass self.gfilter_list.add(self.f) elif tag == "rule": - name = _(attrs['class']) + cname = attrs['class'] + name = _(cname) self.a = [] self.cname = tasks[name] elif tag == "arg": diff --git a/src/ImageSelect.py b/src/ImageSelect.py index 885115938..3bd39db47 100644 --- a/src/ImageSelect.py +++ b/src/ImageSelect.py @@ -130,7 +130,7 @@ class ImageSelect: self.image.set_from_pixbuf(image) else: i = gtk.gdk.pixbuf_new_from_file(Utils.find_icon(type)) - self.image.set_from_pixbuf(i) + self.image.set_from_pixbuf(i) def on_savephoto_clicked(self, obj): """Save the photo in the dataobj object. (Required function)""" @@ -161,7 +161,6 @@ class ImageSelect: description = os.path.basename(filename) mobj.setDescription(description) mobj.setMimeType(type) - self.savephoto(mobj) if type[0:5] == "image": if self.external.get_active() == 0: @@ -178,6 +177,7 @@ class ImageSelect: mobj.getId()) mobj.setLocal(1) mobj.setPath(name) + self.savephoto(mobj) self.parent.lists_changed = 1 Utils.destroy_passed_object(obj) diff --git a/src/PlaceView.py b/src/PlaceView.py index b3bbcac0e..2e37c3639 100644 --- a/src/PlaceView.py +++ b/src/PlaceView.py @@ -51,12 +51,12 @@ _column_headers = [ (_('County'),10,75), (_('State'),11,75), (_('Country'),12,75), - (_(''),7,0), - (_(''),8,0), - (_(''),9,0), - (_(''),10,0), - (_(''),11,0), - (_(''),12,0)] + ('',7,0), + ('',8,0), + ('',9,0), + ('',10,0), + ('',11,0), + ('',12,0)] #------------------------------------------------------------------------- # diff --git a/src/RelImage.py b/src/RelImage.py index db7fa141c..e33ca2a85 100644 --- a/src/RelImage.py +++ b/src/RelImage.py @@ -61,8 +61,6 @@ def import_media_object(filename,path,base): type = Utils.get_mime_type(filename) if type[0:5] == "image": name = "%s/%s%s" % (path,base,ext) - #base = "%s%s" % (base,ext) - thumb = "%s/.thumb" % (path) try: @@ -113,8 +111,7 @@ def scale_image(path,size): scale = size / float(max(width,height)) try: - image1.scale_simple(int(scale*width), int(scale*height), gtk.gdk.INTERP_BILINEAR) - return image1 + return image1.scale_simple(int(scale*width), int(scale*height), gtk.gdk.INTERP_BILINEAR) except: WarningDialog(_("Could not load image file %s") % path) return gtk.gdk.pixbuf_new_from_file(const.icon) @@ -129,7 +126,7 @@ def mk_thumb(source,dest,size): source = os.path.normpath(source) dest = os.path.normpath(dest) - + try: if not os.path.exists(dir): os.mkdir(dir) diff --git a/src/Report.py b/src/Report.py index 024b7d617..7cf1631a1 100644 --- a/src/Report.py +++ b/src/Report.py @@ -647,7 +647,7 @@ class ReportDialog: gtk.FILL|gtk.EXPAND,gtk.FILL|gtk.EXPAND,pad,pad) table.attach(gtk.Label(_("User Template")),0,1,1,2, gtk.FILL,gtk.FILL,pad,pad) - self.html_fileentry = gnome.ui.FileEntry(_("HTML_Template"), + self.html_fileentry = gnome.ui.FileEntry("HTML_Template", _("Choose File")) self.html_fileentry.set_sensitive(0) table.attach(self.html_fileentry,1,2,1,2, diff --git a/src/Utils.py b/src/Utils.py index 0df11ec57..74821d18b 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -400,7 +400,7 @@ def birthday(person): def thumb_path(dir,mobj): type = mobj.getMimeType() if type[0:5] == "image": - thumb = "%s/.thumb/%s.jpg" % (dir,mobj.getId()) + thumb = "%s/.thumb/%s.jpg" % (dir,mobj.getId()) try: if RelImage.check_thumb(mobj.getPath(),thumb,const.thumbScale): return thumb diff --git a/src/const.py b/src/const.py index 18fbe5f63..53f3bf159 100644 --- a/src/const.py +++ b/src/const.py @@ -131,6 +131,7 @@ childRelations = { _("Adopted") : "Adopted", _("Stepchild") : "Stepchild", _("Foster") : "Foster", + _("Sponsored") : "Sponsored", _("None") : "None", _("Unknown") : "Unknown", _("Other") : "Other", diff --git a/src/const.py.in b/src/const.py.in index 1607e46c4..4fba743dc 100644 --- a/src/const.py.in +++ b/src/const.py.in @@ -130,6 +130,7 @@ childRelations = { _("Birth") : "Birth", _("Adopted") : "Adopted", _("Stepchild") : "Stepchild", + _("Sponsored") : "Sponsored", _("Foster") : "Foster", _("None") : "None", _("Unknown") : "Unknown", diff --git a/src/docgen/OpenDrawDoc.py b/src/docgen/OpenDrawDoc.py index 040c41772..5d6ce2674 100644 --- a/src/docgen/OpenDrawDoc.py +++ b/src/docgen/OpenDrawDoc.py @@ -498,4 +498,9 @@ class OpenDrawDoc(DrawDoc.DrawDoc): else: self.f.write('/>\n') +#------------------------------------------------------------------------- +# +# Register document generator +# +#------------------------------------------------------------------------- Plugins.register_draw_doc(_("OpenOffice/StarOffice 6"),OpenDrawDoc); diff --git a/src/docgen/PSDrawDoc.py b/src/docgen/PSDrawDoc.py index b3cb8f7e7..c84c9b091 100644 --- a/src/docgen/PSDrawDoc.py +++ b/src/docgen/PSDrawDoc.py @@ -134,6 +134,11 @@ class PSDrawDoc(DrawDoc.DrawDoc): self.f.write('%f cm %f cm moveto\n' % self.translate(x1,y1)) self.f.write('%f cm %f cm lineto\n' % self.translate(x2,y2)) self.f.write('%d setlinewidth\n' % stype.get_line_width()) + if stype.get_line_style() == DrawDoc.SOLID: + self.f.write('[] 0 setdash\n') + else: + self.f.write('[2 4] 0 setdash\n') + self.f.write('2 setlinecap\n') self.f.write('stroke\n') self.f.write('grestore\n') diff --git a/src/docgen/PdfDrawDoc.py b/src/docgen/PdfDrawDoc.py index 7f310e3cb..209b89b8a 100644 --- a/src/docgen/PdfDrawDoc.py +++ b/src/docgen/PdfDrawDoc.py @@ -78,15 +78,58 @@ class PdfDrawDoc(DrawDoc.DrawDoc): self.f.showPage() def draw_line(self,style,x1,y1,x2,y2): + x1 = x1 + self.lmargin + x2 = x2 + self.lmargin + y1 = y1 + self.tmargin + y2 = y2 + self.tmargin + stype = self.draw_styles[style] + if stype.get_line_style() == DrawDoc.SOLID: + self.f.setDash([],0) + else: + self.f.setDash([2,4],0) + self.f.setLineWidth(stype.get_line_width()) self.f.line(x1*cm,y1*cm,x2*cm,y2*cm) + def draw_bar(self,style,x1,y1,x2,y2): + x1 = x1 + self.lmargin + x2 = x2 + self.lmargin + y1 = y1 + self.tmargin + y2 = y2 + self.tmargin + stype = self.draw_styles[style] + if stype.get_line_style() == DrawDoc.SOLID: + self.f.setDash([],0) + else: + self.f.setDash([2,4],0) + self.f.setLineWidth(stype.get_line_width()) + self.f.rect(x1*cm,y1*cm,(x2-x1)*cm,(y2-y1)*cm,fill=0,stroke=1) + + def draw_path(self,style,path,fill): + stype = self.draw_styles[style] + if stype.get_line_style() == DrawDoc.SOLID: + self.f.setDash([],0) + else: + self.f.setDash([2,4],0) + self.f.setLineWidth(stype.get_line_width()) + + p = self.f.beginPath() + point = path[0] + p.moveTo((point[0]+self.lmargin)*cm,(point[1]+self.tmargin)*cm) + for point in path[1:]: + p.lineTo((point[0]+self.lmargin)*cm,(point[1]+self.tmargin)*cm) + p.close() + self.f.drawPath(p,stroke=1,fill=fill) + def draw_box(self,style,text,x,y): + x = x + self.lmargin + y = y + self.tmargin + box_style = self.draw_styles[style] para_name = box_style.get_paragraph_style() p = self.style_list[para_name] w = box_style.get_width()*cm h = box_style.get_height()*cm + self.f.setLineWidth(stype.get_line_width()) if box_style.get_shadow(): self.f.setFillColorRGB(0.5,0.5,0.5) @@ -103,13 +146,16 @@ class PdfDrawDoc(DrawDoc.DrawDoc): lines = string.split(text,'\n') self.center_print(lines,font,x*cm,y*cm,w,h) - def write_at(self,style,text,x,y): - p = self.style_list[style] + def draw_text(self,style,text,x,y): + x = x + self.lmargin + y = y + self.tmargin + + stype = self.draw_styles[style] + pname = stype.get_paragraph_style() + p = self.style_list[pname] font = p.get_font() - self.f.setStrokeColor(make_color(font.get_color())) - - self.left_print(text,font,x*cm,y*cm) + self.left_print(text,font,x*cm,(y*cm)+font.get_size()) def center_print(self,lines,font,x,y,w,h): l = len(lines) diff --git a/src/docgen/SvgDrawDoc.py b/src/docgen/SvgDrawDoc.py index 1123d8b58..9ad8ab72c 100644 --- a/src/docgen/SvgDrawDoc.py +++ b/src/docgen/SvgDrawDoc.py @@ -18,14 +18,28 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +#------------------------------------------------------------------------- +# +# python modules +# +#------------------------------------------------------------------------- import string + +#------------------------------------------------------------------------- +# +# Gramps modules +# +#------------------------------------------------------------------------- import Plugins from intl import gettext as _ - import TextDoc import DrawDoc - +#------------------------------------------------------------------------- +# +# SvgDrawDoc +# +#------------------------------------------------------------------------- class SvgDrawDoc(DrawDoc.DrawDoc): def __init__(self,styles,type,orientation): @@ -78,11 +92,34 @@ class SvgDrawDoc(DrawDoc.DrawDoc): self.f.close() def draw_line(self,style,x1,y1,x2,y2): + x1 = x1 + self.lmargin + x2 = x2 + self.lmargin + y1 = y1 + self.tmargin + y2 = y2 + self.tmargin + self.f.write('\n') + + def draw_bar(self,style,x1,y1,x2,y2): + x1 = x1 + self.lmargin + x2 = x2 + self.lmargin + y1 = y1 + self.tmargin + y2 = y2 + self.tmargin + + s = self.draw_styles[style] + self.f.write('\n' % s.get_line_width()) def draw_box(self,style,text,x,y): + x = x + self.lmargin + y = y + self.tmargin + box_style = self.draw_styles[style] para_name = box_style.get_paragraph_style() p = self.style_list[para_name] @@ -128,5 +165,38 @@ class SvgDrawDoc(DrawDoc.DrawDoc): self.f.write('">') self.f.write(lines[i]) self.f.write('\n') + + def draw_text(self,style,text,x,y): + x = x + self.lmargin + y = y + self.tmargin + box_style = self.draw_styles[style] + para_name = box_style.get_paragraph_style() + p = self.style_list[para_name] + + font = p.get_font() + font_size = font.get_size() + fs = (font_size/28.35) * 1.2 + self.f.write('') + self.f.write(text) + self.f.write('\n') + +#------------------------------------------------------------------------- +# +# Register document generator +# +#------------------------------------------------------------------------- Plugins.register_draw_doc(_("SVG (Scalable Vector Graphics)"),SvgDrawDoc); diff --git a/src/po/template.po b/src/po/template.po index 808494c68..0124f7539 100644 --- a/src/po/template.po +++ b/src/po/template.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: Thu Jan 30 21:21:32 2003\n" +"POT-Creation-Date: Sat Feb 1 08:40:59 2003\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -393,11 +393,6 @@ msgstr "" msgid "Places" msgstr "" -#: FamilyView.py:139 PlaceView.py:54 PlaceView.py:55 PlaceView.py:56 -#: PlaceView.py:57 PlaceView.py:58 PlaceView.py:59 -msgid "" -msgstr "" - #: FamilyView.py:140 gramps_main.py:91 plugins/IndivComplete.py:381 #: plugins/IndivSummary.py:225 plugins/WebPage.py:284 plugins/WebPage.py:286 #: plugins/WebPage.py:288 @@ -596,19 +591,15 @@ msgstr "" msgid "Matches the filter named" msgstr "" -#: GenericFilter.py:838 -msgid "class" -msgstr "" - -#: GenericFilter.py:880 +#: GenericFilter.py:881 msgid "Local Filters" msgstr "" -#: GenericFilter.py:895 +#: GenericFilter.py:896 msgid "System Filters" msgstr "" -#: GenericFilter.py:910 +#: GenericFilter.py:911 msgid "Custom Filters" msgstr "" @@ -1158,10 +1149,6 @@ msgstr "" msgid "User Template" msgstr "" -#: Report.py:650 -msgid "HTML_Template" -msgstr "" - #: Report.py:651 msgid "Choose File" msgstr "" @@ -1540,7 +1527,7 @@ msgstr "" msgid "LaTeX" msgstr "" -#: docgen/OpenDrawDoc.py:501 docgen/OpenOfficeDoc.py:572 +#: docgen/OpenDrawDoc.py:506 docgen/OpenOfficeDoc.py:572 msgid "OpenOffice/StarOffice 6" msgstr "" @@ -1560,7 +1547,7 @@ msgstr "" msgid "Rich Text Format (RTF)" msgstr "" -#: docgen/SvgDrawDoc.py:132 +#: docgen/SvgDrawDoc.py:202 msgid "SVG (Scalable Vector Graphics)" msgstr "" @@ -2317,7 +2304,7 @@ msgid "Full Family Chart for %s" msgstr "" #: plugins/FullFamily.py:114 -msgid "Save Full Famly Chart" +msgid "Save Full Family Chart" msgstr "" #: plugins/GraphViz.py:60 plugins/GraphViz.py:87