Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Handle OSX open-file event
Browse files Browse the repository at this point in the history
Should fix #41 (test needed)
  • Loading branch information
brrd committed Apr 4, 2016
1 parent 67409d4 commit b1e20d7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/abr-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ var AbrWindow = require.main.require("./abr-window.js"),
parsePath = require("parse-filepath"),
themeLoader = require.main.require("./theme-loader.js");

function AbrApplication () {
function AbrApplication (osxOpenFilePath) {
// Windows reference
this.windows = [];
// IPC get & set
this.ipcServer = new ipcServer(this);
// Compile LESS theme then open windows
themeLoader.load("abricotine", this.run.bind(this, null));
themeLoader.load("abricotine", this.run.bind(this, osxOpenFilePath));
}

AbrApplication.prototype = {
Expand Down
14 changes: 11 additions & 3 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ var AbrApplication = require.main.require("./abr-application.js"),
app = require("app"),
creator = require("./creator.js");

// Check app is single instance
var abrApp = null,
isSecondaryInstance = app.makeSingleInstance(function(argv, workingDir) {
osxOpenFilePath = null;

// Check app is single instance
var isSecondaryInstance = app.makeSingleInstance(function(argv, workingDir) {
process.chdir(workingDir);
if (abrApp == null) {
console.error("Error when trying to reach primary Abricotine instance");
Expand All @@ -25,6 +27,12 @@ if (isSecondaryInstance) {
return;
}

// OSX open-file
app.on("open-file", function(event, path) {
event.preventDefault();
osxOpenFilePath = path;
});

// Quit app when all windows are closed
app.on("window-all-closed", function() {
if (process.platform != "darwin") {
Expand All @@ -38,6 +46,6 @@ app.on("ready", function () {
creatorFunc()
.then(creator.check)
.then(function () {
abrApp = new AbrApplication();
abrApp = new AbrApplication(osxOpenFilePath);
});
});

0 comments on commit b1e20d7

Please # to comment.