2003-07-28 Tim Waugh <twaugh@redhat.com>

* src/Report.py, src/TextDoc.py, src/DrawDoc.py: More support for
        making printable output formats.
        * src/docgen/PSDrawDoc.py, src/docgen/PdfDrawDoc.py: Make these
        output formats printable.


svn: r1936
This commit is contained in:
Tim Waugh 2003-07-28 17:20:18 +00:00
parent 9ce56865c5
commit 51dc19df04
6 changed files with 45 additions and 18 deletions

View File

@ -1,3 +1,9 @@
2003-07-28 Tim Waugh <twaugh@redhat.com>
* src/Report.py, src/TextDoc.py, src/DrawDoc.py: More support for
making printable output formats.
* src/docgen/PSDrawDoc.py, src/docgen/PdfDrawDoc.py: Make these
output formats printable.
2003-07-27 Don Allingham <dallingham@users.sourceforge.net> 2003-07-27 Don Allingham <dallingham@users.sourceforge.net>
* src/GrampsParser.py: directly delete several maps to free memory * src/GrampsParser.py: directly delete several maps to free memory

View File

@ -157,6 +157,9 @@ class DrawDoc:
def close(self): def close(self):
pass pass
def print_report(self):
pass
def start_page(self,orientation=None): def start_page(self,orientation=None):
pass pass

View File

@ -79,6 +79,28 @@ _template_map = {
_user_template : None _user_template : None
} }
#-------------------------------------------------------------------------
#
# Support for printing generated files
#
#-------------------------------------------------------------------------
def get_print_dialog_app ():
"""Return the name of a program which sends stdin (or the program's
arguments) to the printer."""
for printdialog in ["/usr/bin/kprinter --stdin",
"/usr/share/printconf/util/print.py"]:
if os.access (printdialog.split (' ')[0], os.X_OK):
return printdialog
return "lpr"
def run_print_dialog (filename):
"""Send file to the printer, possibly throwing up a dialog to
ask which one etc."""
os.environ["FILE"] = filename
return os.system ('cat "$FILE" | %s &' % get_print_dialog_app ())
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Report # Report
@ -765,23 +787,6 @@ class ReportDialog(BareReportDialog):
def setup_center_person(self): pass def setup_center_person(self): pass
def get_print_dialog_app (self):
"""Return the name of a program which sends stdin (or the program's
arguments) to the printer."""
for printdialog in ["/usr/bin/kprinter",
"/usr/share/printconf/util/print.py"]:
if os.access (printdialog, os.X_OK):
return printdialog
break
return "lpr"
def run_print_dialog (self, filename):
"""Send file to the printer, possibly throwing up a dialog to
ask which one etc."""
args = [self.get_print_dialog_app (), filename]
os.spawnvp (os.P_NOWAIT, args[0], args)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Customization hooks for subclasses # Customization hooks for subclasses

View File

@ -1056,6 +1056,9 @@ class TextDoc:
"Closes the document" "Closes the document"
pass pass
def print_report(self):
pass
def line_break(self): def line_break(self):
"Forces a line break within a paragraph" "Forces a line break within a paragraph"
pass pass

View File

@ -35,6 +35,7 @@ import Plugins
import Errors import Errors
import TextDoc import TextDoc
import DrawDoc import DrawDoc
from Report import run_print_dialog
from intl import gettext as _ from intl import gettext as _
@ -115,6 +116,7 @@ class PSDrawDoc(DrawDoc.DrawDoc):
self.f.write('%%Orientation: Portrait\n') self.f.write('%%Orientation: Portrait\n')
self.f.write('%%EndComments\n') self.f.write('%%EndComments\n')
self.f.write('/cm { 28.34 mul } def\n') self.f.write('/cm { 28.34 mul } def\n')
self.filename = filename
def close(self): def close(self):
self.f.write('%%Trailer\n') self.f.write('%%Trailer\n')
@ -122,6 +124,9 @@ class PSDrawDoc(DrawDoc.DrawDoc):
self.f.write('%d\n' % self.page) self.f.write('%d\n' % self.page)
self.f.write('%%EOF\n') self.f.write('%%EOF\n')
self.f.close() self.f.close()
def print_report(self):
return run_print_dialog (self.filename)
def start_paragraph(self,style_name): def start_paragraph(self,style_name):
pass pass
@ -375,4 +380,5 @@ def rgb_color(color):
b = float(color[2])/255.0 b = float(color[2])/255.0
return (r,g,b) return (r,g,b)
Plugins.register_draw_doc(_("PostScript"),PSDrawDoc,1,1,".ps"); Plugins.register_draw_doc(_("PostScript"),PSDrawDoc,1,1,".ps",
_("Print a copy"));

View File

@ -35,6 +35,7 @@ import Errors
import TextDoc import TextDoc
import DrawDoc import DrawDoc
from Report import run_print_dialog
from intl import gettext as _ from intl import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -91,6 +92,9 @@ class PdfDrawDoc(DrawDoc.DrawDoc):
except: except:
raise Errors.ReportError(_("Could not create %s") % self.filename) raise Errors.ReportError(_("Could not create %s") % self.filename)
def print_report(self):
return run_print_dialog (self.filename)
def start_paragraph(self,style_name): def start_paragraph(self,style_name):
pass pass