parent
c31c091cb0
commit
210d815173
3 changed files with 16 additions and 14 deletions
|
@ -1,5 +1,11 @@
|
||||||
let { CommandLineOptions, TestOptions } = ChromeUtils.importESModule("chrome://zotero/content/modules/commandLineOptions.mjs");
|
let { CommandLineOptions, TestOptions } = ChromeUtils.importESModule("chrome://zotero/content/modules/commandLineOptions.mjs");
|
||||||
|
|
||||||
|
// Only allow BrowserContentHandler to open a new window if this is the initial launch,
|
||||||
|
// meaning our CLH isn't registered yet.
|
||||||
|
if (cmdLine.state != Ci.nsICommandLine.STATE_INITIAL_LAUNCH) {
|
||||||
|
cmdLine.preventDefault = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Force debug output to window
|
// Force debug output to window
|
||||||
if (cmdLine.handleFlag("ZoteroDebug", false)) {
|
if (cmdLine.handleFlag("ZoteroDebug", false)) {
|
||||||
CommandLineOptions.forceDebugLog = 2;
|
CommandLineOptions.forceDebugLog = 2;
|
||||||
|
|
|
@ -31,18 +31,16 @@ Zotero.CommandLineIngester = {
|
||||||
ingest: async function () {
|
ingest: async function () {
|
||||||
const { CommandLineOptions } = ChromeUtils.importESModule("chrome://zotero/content/modules/commandLineOptions.mjs");
|
const { CommandLineOptions } = ChromeUtils.importESModule("chrome://zotero/content/modules/commandLineOptions.mjs");
|
||||||
|
|
||||||
|
var mainWindow = Zotero.getMainWindow();
|
||||||
var fileToOpen;
|
var fileToOpen;
|
||||||
// Handle zotero:// and file URIs
|
// Handle zotero:// and file URIs
|
||||||
var uri = CommandLineOptions.url;
|
var uri = CommandLineOptions.url;
|
||||||
if (uri) {
|
if (uri) {
|
||||||
if (uri.schemeIs("zotero")) {
|
if (uri.schemeIs("zotero")) {
|
||||||
// Check for existing window and focus it
|
// Check for existing window and focus it
|
||||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
if (mainWindow) {
|
||||||
.getService(Components.interfaces.nsIWindowMediator);
|
mainWindow.focus();
|
||||||
var win = wm.getMostRecentWindow("navigator:browser");
|
mainWindow.ZoteroPane.loadURI(uri.spec);
|
||||||
if (win) {
|
|
||||||
win.focus();
|
|
||||||
win.ZoteroPane.loadURI(uri.spec);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// See below
|
// See below
|
||||||
|
@ -77,11 +75,7 @@ Zotero.CommandLineIngester = {
|
||||||
'import.createNewCollection.fromFileOpenHandler', checkState.value
|
'import.createNewCollection.fromFileOpenHandler', checkState.value
|
||||||
);
|
);
|
||||||
|
|
||||||
// Perform file import in front window
|
mainWindow.Zotero_File_Interface.importFile({
|
||||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
|
||||||
.getService(Components.interfaces.nsIWindowMediator);
|
|
||||||
var browserWindow = wm.getMostRecentWindow("navigator:browser");
|
|
||||||
browserWindow.Zotero_File_Interface.importFile({
|
|
||||||
file,
|
file,
|
||||||
createNewCollection: checkState.value
|
createNewCollection: checkState.value
|
||||||
});
|
});
|
||||||
|
@ -107,9 +101,6 @@ var ZoteroCommandLineHandler = {
|
||||||
// this is typically used on Windows only, via WM_COPYDATA rather than the command line
|
// this is typically used on Windows only, via WM_COPYDATA rather than the command line
|
||||||
var agent = cmdLine.handleFlagWithParam("ZoteroIntegrationAgent", false);
|
var agent = cmdLine.handleFlagWithParam("ZoteroIntegrationAgent", false);
|
||||||
if (agent) {
|
if (agent) {
|
||||||
// Don't open a new window
|
|
||||||
cmdLine.preventDefault = true;
|
|
||||||
|
|
||||||
var command = cmdLine.handleFlagWithParam("ZoteroIntegrationCommand", false);
|
var command = cmdLine.handleFlagWithParam("ZoteroIntegrationCommand", false);
|
||||||
var docId = cmdLine.handleFlagWithParam("ZoteroIntegrationDocument", false);
|
var docId = cmdLine.handleFlagWithParam("ZoteroIntegrationDocument", false);
|
||||||
var templateVersion = parseInt(cmdLine.handleFlagWithParam("ZoteroIntegrationTemplateVersion", false));
|
var templateVersion = parseInt(cmdLine.handleFlagWithParam("ZoteroIntegrationTemplateVersion", false));
|
||||||
|
@ -117,6 +108,10 @@ var ZoteroCommandLineHandler = {
|
||||||
|
|
||||||
Zotero.Integration.execCommand(agent, command, docId, templateVersion);
|
Zotero.Integration.execCommand(agent, command, docId, templateVersion);
|
||||||
}
|
}
|
||||||
|
// Only open main window if we aren't handling an integration command
|
||||||
|
else if (!Zotero.getMainWindow()) {
|
||||||
|
Zotero.openMainWindow();
|
||||||
|
}
|
||||||
|
|
||||||
await Zotero.CommandLineIngester.ingest();
|
await Zotero.CommandLineIngester.ingest();
|
||||||
},
|
},
|
||||||
|
|
|
@ -967,6 +967,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
||||||
|
|
||||||
|
|
||||||
this.openMainWindow = function () {
|
this.openMainWindow = function () {
|
||||||
|
const { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
||||||
var chromeURI = AppConstants.BROWSER_CHROME_URL;
|
var chromeURI = AppConstants.BROWSER_CHROME_URL;
|
||||||
var flags = "chrome,all,dialog=no";
|
var flags = "chrome,all,dialog=no";
|
||||||
var ww = Components.classes['@mozilla.org/embedcomp/window-watcher;1']
|
var ww = Components.classes['@mozilla.org/embedcomp/window-watcher;1']
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue