Skip to content

Commit

Permalink
Merge pull request #2 from jcf94/dev
Browse files Browse the repository at this point in the history
New feature: Drag file to vizgraph.exe can quickly open it
  • Loading branch information
jcf94 authored Mar 15, 2018
2 parents efe20b2 + 9d4a1c7 commit 10ae4a9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function createWindow() {
}));

// Open the DevTools.
// if (debug)
if (debug)
{
mainWindow.webContents.openDevTools();
}
Expand Down Expand Up @@ -76,7 +76,8 @@ app.on('ready', () => {
mainWindow_height = settings.get('mainWindow_height', 768);
createWindow();
mainWindow.webContents.on('did-finish-load', () => {
mainWindow.webContents.send('argv', process.argv);
if (process.argv.length > 1)
mainWindow.webContents.send('argv', process.argv[1]);
});
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A simple tool for Using Graphviz.",
"main": "main.js",
"scripts": {
"start": "electron .",
"start": "electron . \"C:\\Users\\jcf\\Desktop\\graph.dot\"",
"dev": "electron . --debug",
"test": "echo \"Error: no test specified\" && exit 1",
"dist": "electron-builder -lw --publish always",
Expand Down
9 changes: 8 additions & 1 deletion src/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,14 @@ ipcRenderer.on('save_dot_file', () => {
});

ipcRenderer.on('argv', (event, message) => {
console.log(message);
fs.stat(message, (err, stat) => {
if (stat && stat.isFile()) {
console.log(message)
try_to_read_dot_from_file(message);
} else {
console.log("Not a file.");
}
})
});

// ------- Menu -------
Expand Down

0 comments on commit 10ae4a9

Please sign in to comment.