diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index 64e80ab85453a7bca051f3509c3a068ff54e36fd..44d1bbbd84ddaa0898d07a56ee90df4e1c014740 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -1160,52 +1160,12 @@ function menu_saveas(name) { exports.menu_saveas = menu_saveas; function gui_canvas_print(name, initfile, initdir) { - // AG: This works mostly like gui_canvas_saveas above, except that we - // create a pdf file and use a different input element and callback. - var input, chooser, - span = patchwin[name].window.document.querySelector("#printDialogSpan"); - if (!fs.existsSync(initdir)) { - initdir = pwd; - } - // If we don't have a ".pd" file extension (e.g., "Untitled-1", add one) - if (initfile.slice(-3) !== ".pd") { - initfile += ".pd"; - } - // Adding an "f" now gives .pdf which is what we want. - initfile += "f"; - input = build_file_dialog_string({ - style: "display: none;", - type: "file", - id: "printDialog", - nwsaveas: path.join(initdir, initfile), - nwworkingdir: initdir, - accept: ".pdf" - }); - span.innerHTML = input; - chooser = patchwin[name].window.document.querySelector("#printDialog"); - chooser.onchange = function() { - print_callback(name, this.value); - // reset value so that we can open the same file twice - this.value = null; - console.log("tried to print something"); - } - chooser.click(); + // AG: We simply ignore initfile and initdir, as the print dialog will + // present its own file picker anyway if PDF output is chosen. + patchwin[name].print({ autoprint: false, headerString: initfile, footerString: path.join(initdir, initfile) }); + post("printed "+initfile); } -function print_callback(cid, file) { - var filename = defunkify_windows_path(file); - // It probably isn't possible to arrive at the callback with an - // empty string. But I've only tested on Debian so far... - if (filename === null) { - return; - } - // Let nw.js do the rest (requires nw.js 0.14.6+) - patchwin[cid].print({ pdf_path: filename, headerFooterEnabled: false }); - post("printed to: " + filename); -} - -exports.print_callback = print_callback; - function menu_print(name) { pdsend(name + " menuprint"); }