diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index fe9296c1b..d34144af7 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2003-07-28 Tim Waugh + * 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 * src/GrampsParser.py: directly delete several maps to free memory diff --git a/gramps2/src/DrawDoc.py b/gramps2/src/DrawDoc.py index 18c272ea1..f5748fed2 100644 --- a/gramps2/src/DrawDoc.py +++ b/gramps2/src/DrawDoc.py @@ -157,6 +157,9 @@ class DrawDoc: def close(self): pass + def print_report(self): + pass + def start_page(self,orientation=None): pass diff --git a/gramps2/src/Report.py b/gramps2/src/Report.py index b2ac589c0..cebbcfb49 100644 --- a/gramps2/src/Report.py +++ b/gramps2/src/Report.py @@ -79,6 +79,28 @@ _template_map = { _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 @@ -765,23 +787,6 @@ class ReportDialog(BareReportDialog): 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 diff --git a/gramps2/src/TextDoc.py b/gramps2/src/TextDoc.py index b247a1000..13a64c41f 100644 --- a/gramps2/src/TextDoc.py +++ b/gramps2/src/TextDoc.py @@ -1056,6 +1056,9 @@ class TextDoc: "Closes the document" pass + def print_report(self): + pass + def line_break(self): "Forces a line break within a paragraph" pass diff --git a/gramps2/src/docgen/PSDrawDoc.py b/gramps2/src/docgen/PSDrawDoc.py index 066c09aa4..9547d7950 100644 --- a/gramps2/src/docgen/PSDrawDoc.py +++ b/gramps2/src/docgen/PSDrawDoc.py @@ -35,6 +35,7 @@ import Plugins import Errors import TextDoc import DrawDoc +from Report import run_print_dialog from intl import gettext as _ @@ -115,6 +116,7 @@ class PSDrawDoc(DrawDoc.DrawDoc): self.f.write('%%Orientation: Portrait\n') self.f.write('%%EndComments\n') self.f.write('/cm { 28.34 mul } def\n') + self.filename = filename def close(self): self.f.write('%%Trailer\n') @@ -122,6 +124,9 @@ class PSDrawDoc(DrawDoc.DrawDoc): self.f.write('%d\n' % self.page) self.f.write('%%EOF\n') self.f.close() + + def print_report(self): + return run_print_dialog (self.filename) def start_paragraph(self,style_name): pass @@ -375,4 +380,5 @@ def rgb_color(color): b = float(color[2])/255.0 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")); diff --git a/gramps2/src/docgen/PdfDrawDoc.py b/gramps2/src/docgen/PdfDrawDoc.py index b62b47586..9ab6e0fd4 100644 --- a/gramps2/src/docgen/PdfDrawDoc.py +++ b/gramps2/src/docgen/PdfDrawDoc.py @@ -35,6 +35,7 @@ import Errors import TextDoc import DrawDoc +from Report import run_print_dialog from intl import gettext as _ #------------------------------------------------------------------------- @@ -91,6 +92,9 @@ class PdfDrawDoc(DrawDoc.DrawDoc): except: 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): pass