Skip to content

ATL-372: .ino file associations #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,40 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
// See: https://github.com/electron-userland/electron-builder/issues/2468
// Regression in Theia: https://github.com/eclipse-theia/theia/issues/8701
app.on('ready', () => app.setName(config.applicationName));

// Add file associations to the app
this.attachFileAssociations();

return super.start(config);
}

attachFileAssociations() {

// OSX: register open-file event
if (process.platform === 'darwin') {
app.on('open-file', (event, uri) => {
event.preventDefault();
// TODO: check if the URI is a .ino file
// should I call openSketchFiles(uri) ?
});
}

// WIN: read file(s) uri from executable args
if (process.platform === 'win32') {
if (app.isPackaged) {
// workaround for missing executable argument when app is packaged
process.argv.unshift('packaged');
}
// parameters is an array containing any files/folders that your OS will pass to your application
const uri = process.argv.slice(2) || null;
if (uri) {
// TODO: filter out only the first .ino file in the array
// should I call openSketchFiles(uri) ?
}
}

}

/**
* Use this rather than creating `BrowserWindow` instances from scratch, since some security parameters need to be set, this method will do it.
*
Expand Down
6 changes: 6 additions & 0 deletions electron/build/template-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
"directories": {
"buildResources": "resources"
},
"fileAssociations": [
{
"ext": ["ino"],
"role": "Editor"
}
],
"files": [
"src-gen",
"lib",
Expand Down