From c54e12ea51431d5b7fc02b37ae104318c105df67 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Fri, 25 Jul 2003 18:22:07 +0000 Subject: [PATCH] 2003-07-25 Tim Waugh * src/Report.py: Support for making output formats printable. * src/plugins/GraphViz.py: Make it printable. svn: r1930 --- ChangeLog | 2 ++ src/Report.py | 29 +++++++++++++++++++++++++++++ src/plugins/GraphViz.py | 15 +++++++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d511846ff..f257724b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,6 @@ 2003-07-25 Tim Waugh + * src/Report.py: Support for making output formats printable. + * src/plugins/GraphViz.py: Make it printable. * src/plugins/ReadGedcom.py: Handle ABBR in source definitions (i.e. handle the GEDCOM that our exporter writes). diff --git a/src/Report.py b/src/Report.py index db8b0cb8f..b2ac589c0 100644 --- a/src/Report.py +++ b/src/Report.py @@ -765,6 +765,23 @@ 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 @@ -844,6 +861,14 @@ class ReportDialog(BareReportDialog): paper size/orientation options, but it does need a template file. Those chances are made here.""" + label = obj.get_data("printable") + if label: + self.print_report.set_label (label) + self.print_report.set_sensitive (gtk.TRUE) + else: + self.print_report.set_label (_("Print a copy")) + self.print_report.set_sensitive (gtk.FALSE) + # Is this to be a printed report or an electronic report # (i.e. a set of web pages) @@ -917,6 +942,10 @@ class ReportDialog(BareReportDialog): relies on the make_doc_menu() function to do all the hard work.""" + self.print_report = gtk.CheckButton (_("Print a copy")) + self.tbl.attach(self.print_report,2,4,self.col,self.col+1) + self.col += 1 + self.format_menu = gtk.OptionMenu() self.make_doc_menu() label = gtk.Label("%s:" % _("Output Format")) diff --git a/src/plugins/GraphViz.py b/src/plugins/GraphViz.py index 3c3d7ad47..d6e98b189 100644 --- a/src/plugins/GraphViz.py +++ b/src/plugins/GraphViz.py @@ -233,8 +233,14 @@ class GraphVizDialog(Report.ReportDialog): def make_doc_menu(self): """Build a one item menu of document types that are appropriate for this report.""" - map = {"Graphviz (dot)" : None} - myMenu = Utils.build_string_optmenu(map, None) + name = "Graphviz (dot)" + menuitem = gtk.MenuItem (name) + menuitem.set_data ("d", name) + if os.system ("dot /dev/null") == 0: + menuitem.set_data ("printable", _("Generate print output")) + menuitem.show () + myMenu = gtk.Menu () + myMenu.append (menuitem) self.format_menu.set_menu(myMenu) def make_document(self): @@ -283,6 +289,11 @@ class GraphVizDialog(Report.ReportDialog): self.colorize, self.adoptionsdashed, self.arrowheadstyle, self.arrowtailstyle, self.show_families) + if self.print_report.get_active (): + os.environ["DOT"] = self.target_path + os.system ('dot -Tps "$DOT" | %s' % + self.get_print_dialog_app ()) + #------------------------------------------------------------------------ # #