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

* src/Report.py: Support for making output formats printable.
        * src/plugins/GraphViz.py: Make it printable.


svn: r1930
This commit is contained in:
Tim Waugh 2003-07-25 18:22:07 +00:00
parent 0b27e9db03
commit c54e12ea51
3 changed files with 44 additions and 2 deletions

View File

@ -1,4 +1,6 @@
2003-07-25 Tim Waugh <twaugh@redhat.com>
* 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).

View File

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

View File

@ -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 2>/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 ())
#------------------------------------------------------------------------
#
#