* src/docgen/PSDrawDoc.py: 0000869: PostScript print option will crash
* src/ReportBase/__init__.py: 0000869: PostScript print option will crash * src/ReportBase/_PrintTools.py: 0000869: PostScript print option will crash svn: r7972
This commit is contained in:
parent
1c99ffb4c9
commit
de6bc22670
@ -1,3 +1,8 @@
|
|||||||
|
2007-01-24 Brian Matherly <brian@gramps-project.org>
|
||||||
|
* src/docgen/PSDrawDoc.py: 0000869: PostScript print option will crash
|
||||||
|
* src/ReportBase/__init__.py: 0000869: PostScript print option will crash
|
||||||
|
* src/ReportBase/_PrintTools.py: 0000869: PostScript print option will crash
|
||||||
|
|
||||||
2007-01-24 Douglas Blank <dblank@cs.brynmawr.edu>
|
2007-01-24 Douglas Blank <dblank@cs.brynmawr.edu>
|
||||||
* src/docgen/PdfDoc.py: 0000870: docgen/PdfDoc.py offset error,
|
* src/docgen/PdfDoc.py: 0000870: docgen/PdfDoc.py offset error,
|
||||||
and missing italics
|
and missing italics
|
||||||
|
@ -37,15 +37,19 @@ import os
|
|||||||
def get_print_dialog_app ():
|
def get_print_dialog_app ():
|
||||||
"""Return the name of a program which sends stdin (or the program's
|
"""Return the name of a program which sends stdin (or the program's
|
||||||
arguments) to the printer."""
|
arguments) to the printer."""
|
||||||
|
if os.sys.platform != "win32":
|
||||||
for printdialog in ["/usr/bin/kprinter --stdin",
|
for printdialog in ["/usr/bin/kprinter --stdin",
|
||||||
"/usr/share/printconf/util/print.py"]:
|
"/usr/share/printconf/util/print.py"]:
|
||||||
if os.access (printdialog.split (' ')[0], os.X_OK):
|
if os.access (printdialog.split (' ')[0], os.X_OK):
|
||||||
return printdialog
|
return printdialog
|
||||||
|
|
||||||
return "lpr"
|
return "lpr"
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def run_print_dialog (filename):
|
def run_print_dialog (filename):
|
||||||
"""Send file to the printer, possibly throwing up a dialog to
|
"""Send file to the printer, possibly throwing up a dialog to
|
||||||
ask which one etc."""
|
ask which one etc."""
|
||||||
|
app = get_print_dialog_app()
|
||||||
|
if app:
|
||||||
os.environ["FILE"] = filename
|
os.environ["FILE"] = filename
|
||||||
return os.system ('cat "$FILE" | %s &' % get_print_dialog_app ())
|
return os.system ('cat "$FILE" | %s &' % app )
|
||||||
|
@ -38,4 +38,4 @@ from _TextReportDialog import TextReportDialog
|
|||||||
from _ReportOptions import ReportOptions
|
from _ReportOptions import ReportOptions
|
||||||
import _ReportUtils as ReportUtils
|
import _ReportUtils as ReportUtils
|
||||||
|
|
||||||
from _PrintTools import run_print_dialog
|
from _PrintTools import run_print_dialog, get_print_dialog_app
|
||||||
|
@ -31,12 +31,14 @@ from gettext import gettext as _
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#Gramps modules
|
#Gramps modules
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from ReportBase import ReportUtils, Report
|
from ReportBase import ReportUtils, run_print_dialog, get_print_dialog_app
|
||||||
from PluginUtils import register_draw_doc
|
from PluginUtils import register_draw_doc
|
||||||
import BaseDoc
|
import BaseDoc
|
||||||
import Errors
|
import Errors
|
||||||
|
|
||||||
from Utils import gformat
|
from Utils import gformat
|
||||||
|
import Mime
|
||||||
|
import Utils
|
||||||
|
|
||||||
def lrgb(grp):
|
def lrgb(grp):
|
||||||
grp = ReportUtils.rgb_color(grp)
|
grp = ReportUtils.rgb_color(grp)
|
||||||
@ -45,6 +47,22 @@ def lrgb(grp):
|
|||||||
def coords(grp):
|
def coords(grp):
|
||||||
return (gformat(grp[0]),gformat(grp[1]))
|
return (gformat(grp[0]),gformat(grp[1]))
|
||||||
|
|
||||||
|
_apptype = 'application/postscript'
|
||||||
|
print_label = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
# First try to find a viewer program
|
||||||
|
mprog = Mime.get_application(_apptype)
|
||||||
|
if Utils.search_for(mprog[0]):
|
||||||
|
print_label = _("Open in %(program_name)s") % {'program_name': mprog[1]}
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if print_label == None:
|
||||||
|
# Second, try to print directly
|
||||||
|
if get_print_dialog_app() != None:
|
||||||
|
print_label = _("Print a copy")
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# PSDrawDoc
|
# PSDrawDoc
|
||||||
@ -135,7 +153,14 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
|||||||
self.f.write('%%EOF\n')
|
self.f.write('%%EOF\n')
|
||||||
self.f.close()
|
self.f.close()
|
||||||
if self.print_req:
|
if self.print_req:
|
||||||
Report.run_print_dialog (self.filename)
|
if print_label == _("Print a copy"):
|
||||||
|
run_print_dialog (self.filename)
|
||||||
|
elif print_label:
|
||||||
|
app = Mime.get_application(_apptype)
|
||||||
|
Utils.launch(app[0],self.filename)
|
||||||
|
else:
|
||||||
|
# This should never happen
|
||||||
|
print "Invalid print request"
|
||||||
|
|
||||||
def write_text(self,text,mark=None):
|
def write_text(self,text,mark=None):
|
||||||
pass
|
pass
|
||||||
@ -419,5 +444,4 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
|||||||
self.f.write("(%s) show\n" % lines[i])
|
self.f.write("(%s) show\n" % lines[i])
|
||||||
self.f.write('grestore\n')
|
self.f.write('grestore\n')
|
||||||
|
|
||||||
register_draw_doc(_("PostScript"),PSDrawDoc,1,1,".ps",
|
register_draw_doc(_("PostScript"),PSDrawDoc,1,1,".ps", print_label);
|
||||||
_("Print a copy"));
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user