mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 17:47:59 +01:00
Use less shady method of pdf printing; support Windows.
This commit is contained in:
@@ -1099,6 +1099,21 @@ var closureHooks = {
|
||||
return target._closureCache[prop] = p.bind(target);
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
getOwnPropertyNames: function getOwnPropertyNames(target) {
|
||||
return [k for (k in properties(target, true))];
|
||||
},
|
||||
|
||||
getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, prop) {
|
||||
let self = this;
|
||||
return {
|
||||
configurable: false,
|
||||
writable: false,
|
||||
get value() self.get(target, prop)
|
||||
}
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
Class.makeClosure = function makeClosure() {
|
||||
|
||||
@@ -1812,7 +1812,7 @@ var Buffer = Module("Buffer", {
|
||||
let arg = args[0];
|
||||
|
||||
// FIXME: arg handling is a bit of a mess, check for filename
|
||||
dactyl.assert(!arg || arg[0] == ">" && !config.OS.isWindows,
|
||||
dactyl.assert(!arg || arg[0] == ">",
|
||||
_("error.trailingCharacters"));
|
||||
|
||||
const PRINTER = "PostScript/default";
|
||||
@@ -1822,26 +1822,25 @@ var Buffer = Module("Buffer", {
|
||||
BRANCHES.forEach(function (branch) { prefs.set(branch + pref, value); });
|
||||
}
|
||||
|
||||
prefs.withContext(function () {
|
||||
let settings = services.printSettings.newPrintSettings;
|
||||
settings.printSilent = args.bang;
|
||||
if (arg) {
|
||||
prefs.set("print.print_printer", PRINTER);
|
||||
|
||||
let { path } = io.File(arg.substr(1));
|
||||
set("print_to_file", true);
|
||||
set("print_to_filename", path);
|
||||
prefs.set("print_to_filename", path);
|
||||
settings.printToFile = true;
|
||||
settings.toFileName = io.File(arg.substr(1)).path;
|
||||
settings.outputFormat = settings.kOutputFormatPDF;
|
||||
|
||||
dactyl.echomsg(_("print.toFile", arg.substr(1)));
|
||||
}
|
||||
else
|
||||
else {
|
||||
dactyl.echomsg(_("print.sending"));
|
||||
|
||||
prefs.set("print.always_print_silent", args.bang);
|
||||
if (false)
|
||||
prefs.set("print.show_print_progress", !args.bang);
|
||||
}
|
||||
|
||||
config.browser.contentWindow.print();
|
||||
});
|
||||
config.browser.contentWindow
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebBrowserPrint).print(settings, null);
|
||||
|
||||
dactyl.echomsg(_("print.sent"));
|
||||
},
|
||||
|
||||
@@ -63,6 +63,7 @@ var Services = Module("Services", {
|
||||
this.add("mime", "@mozilla.org/mime;1", "nsIMIMEService");
|
||||
this.add("observer", "@mozilla.org/observer-service;1", "nsIObserverService");
|
||||
this.add("pref", "@mozilla.org/preferences-service;1", ["nsIPrefBranch2", "nsIPrefService"]);
|
||||
this.add("printSettings", "@mozilla.org/gfx/printsettings-service;1", "nsIPrintSettingsService");
|
||||
this.add("privateBrowsing", "@mozilla.org/privatebrowsing;1", "nsIPrivateBrowsingService");
|
||||
this.add("profile", "@mozilla.org/toolkit/profile-service;1", "nsIToolkitProfileService");
|
||||
this.add("resource:", this.PROTOCOL + "resource", ["nsIProtocolHandler", "nsIResProtocolHandler"]);
|
||||
|
||||
Reference in New Issue
Block a user