mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 22:07:58 +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 target._closureCache[prop] = p.bind(target);
|
||||||
return p;
|
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() {
|
Class.makeClosure = function makeClosure() {
|
||||||
|
|||||||
@@ -1812,7 +1812,7 @@ var Buffer = Module("Buffer", {
|
|||||||
let arg = args[0];
|
let arg = args[0];
|
||||||
|
|
||||||
// FIXME: arg handling is a bit of a mess, check for filename
|
// 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"));
|
_("error.trailingCharacters"));
|
||||||
|
|
||||||
const PRINTER = "PostScript/default";
|
const PRINTER = "PostScript/default";
|
||||||
@@ -1822,26 +1822,25 @@ var Buffer = Module("Buffer", {
|
|||||||
BRANCHES.forEach(function (branch) { prefs.set(branch + pref, value); });
|
BRANCHES.forEach(function (branch) { prefs.set(branch + pref, value); });
|
||||||
}
|
}
|
||||||
|
|
||||||
prefs.withContext(function () {
|
let settings = services.printSettings.newPrintSettings;
|
||||||
|
settings.printSilent = args.bang;
|
||||||
if (arg) {
|
if (arg) {
|
||||||
prefs.set("print.print_printer", PRINTER);
|
settings.printToFile = true;
|
||||||
|
settings.toFileName = io.File(arg.substr(1)).path;
|
||||||
let { path } = io.File(arg.substr(1));
|
settings.outputFormat = settings.kOutputFormatPDF;
|
||||||
set("print_to_file", true);
|
|
||||||
set("print_to_filename", path);
|
|
||||||
prefs.set("print_to_filename", path);
|
|
||||||
|
|
||||||
dactyl.echomsg(_("print.toFile", arg.substr(1)));
|
dactyl.echomsg(_("print.toFile", arg.substr(1)));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
dactyl.echomsg(_("print.sending"));
|
dactyl.echomsg(_("print.sending"));
|
||||||
|
|
||||||
prefs.set("print.always_print_silent", args.bang);
|
|
||||||
if (false)
|
if (false)
|
||||||
prefs.set("print.show_print_progress", !args.bang);
|
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"));
|
dactyl.echomsg(_("print.sent"));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ var Services = Module("Services", {
|
|||||||
this.add("mime", "@mozilla.org/mime;1", "nsIMIMEService");
|
this.add("mime", "@mozilla.org/mime;1", "nsIMIMEService");
|
||||||
this.add("observer", "@mozilla.org/observer-service;1", "nsIObserverService");
|
this.add("observer", "@mozilla.org/observer-service;1", "nsIObserverService");
|
||||||
this.add("pref", "@mozilla.org/preferences-service;1", ["nsIPrefBranch2", "nsIPrefService"]);
|
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("privateBrowsing", "@mozilla.org/privatebrowsing;1", "nsIPrivateBrowsingService");
|
||||||
this.add("profile", "@mozilla.org/toolkit/profile-service;1", "nsIToolkitProfileService");
|
this.add("profile", "@mozilla.org/toolkit/profile-service;1", "nsIToolkitProfileService");
|
||||||
this.add("resource:", this.PROTOCOL + "resource", ["nsIProtocolHandler", "nsIResProtocolHandler"]);
|
this.add("resource:", this.PROTOCOL + "resource", ["nsIProtocolHandler", "nsIResProtocolHandler"]);
|
||||||
|
|||||||
Reference in New Issue
Block a user