Image handling fixes

svn: r1284
This commit is contained in:
Don Allingham 2003-02-03 19:24:27 +00:00
parent f7fea013a9
commit 0aa3cce886
15 changed files with 171 additions and 44 deletions

View File

@ -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

View File

@ -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) ])

View File

@ -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":

View File

@ -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)

View File

@ -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)]
#-------------------------------------------------------------------------
#

View File

@ -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)

View File

@ -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,

View File

@ -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

View File

@ -131,6 +131,7 @@ childRelations = {
_("Adopted") : "Adopted",
_("Stepchild") : "Stepchild",
_("Foster") : "Foster",
_("Sponsored") : "Sponsored",
_("None") : "None",
_("Unknown") : "Unknown",
_("Other") : "Other",

View File

@ -130,6 +130,7 @@ childRelations = {
_("Birth") : "Birth",
_("Adopted") : "Adopted",
_("Stepchild") : "Stepchild",
_("Sponsored") : "Sponsored",
_("Foster") : "Foster",
_("None") : "None",
_("Unknown") : "Unknown",

View File

@ -498,4 +498,9 @@ class OpenDrawDoc(DrawDoc.DrawDoc):
else:
self.f.write('/>\n')
#-------------------------------------------------------------------------
#
# Register document generator
#
#-------------------------------------------------------------------------
Plugins.register_draw_doc(_("OpenOffice/StarOffice 6"),OpenDrawDoc);

View File

@ -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')

View File

@ -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)

View File

@ -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('<line x1="%4.2fcm" y1="%4.2fcm" ' % (x1*28.35,y1*28.35))
self.f.write('x2="%4.2fcm" y2="%4.2fcm" ' % (x2*28.35,y2*28.35))
self.f.write(' style="stroke:#000000;stroke-width=1"/>\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('<rect ')
self.f.write('x="%4.2fcm" ' % x1)
self.f.write('y="%4.2fcm" ' % y1)
self.f.write('width="%4.2fcm" ' % (x2-x1))
self.f.write('height="%4.2fcm" ' % (y2-y1))
self.f.write('style="fill:#ffffff;stroke:#000000;')
self.f.write('stroke-width:%.2f"/>\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('</text>\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('<text ')
self.f.write('x="%4.2fcm" ' % x)
self.f.write('y="%4.2fcm" ' % (y+fs))
self.f.write('style="fill:#%02x%02x%02x; '% font.get_color())
if font.get_bold():
self.f.write('font-weight="bold";')
if font.get_italic():
self.f.write('font-style="italic";')
self.f.write('font-size:%d;' % font_size)
if font.get_type_face() == TextDoc.FONT_SANS_SERIF:
self.f.write('font-family=sans-serif;')
else:
self.f.write('font-family=serif;')
self.f.write('">')
self.f.write(text)
self.f.write('</text>\n')
#-------------------------------------------------------------------------
#
# Register document generator
#
#-------------------------------------------------------------------------
Plugins.register_draw_doc(_("SVG (Scalable Vector Graphics)"),SvgDrawDoc);

View File

@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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