diff --git a/default-profile.json b/default-profile.json index 76d3279..83cc540 100644 --- a/default-profile.json +++ b/default-profile.json @@ -11,9 +11,11 @@ { "label": "Chromium Browser 1", "icon": "chromium-browser", - "exec": "/usr/bin/chromium-browser" + "exec": "/usr/bin/chromium-browser", + "_key": "item_1444480285022_3" } - ] + ], + "_key": "item_1444480285022_2" }, { "label": "Level 2-2", @@ -26,13 +28,24 @@ { "label": "Chromium Browser 2", "icon": "chromium-browser", - "exec": "/usr/bin/chromium-browser" + "exec": "/usr/bin/chromium-browser", + "_key": "item_1444480285022_6" + }, + { + "label": "Atom", + "icon": "atom", + "exec": "/usr/share/atom/atom %U", + "_key": "item_1444480288996_7" } - ] + ], + "_key": "item_1444480285022_5" } - ] + ], + "_key": "item_1444480285022_4" } - ] + ], + "_key": "item_1444480285022_1" } - ] -} + ], + "_key": "item_1444480285021_0" +} \ No newline at end of file diff --git a/js/components/edit/profile-menu.js b/js/components/edit/profile-menu.js index e5a0586..fc7b202 100644 --- a/js/components/edit/profile-menu.js +++ b/js/components/edit/profile-menu.js @@ -1,6 +1,7 @@ var React = require('react'); var connect = require('react-redux').connect; var actions = require('../../store/actions'); +var dialog = require('remote').require('dialog'); var ProfileMenu = React.createClass({ @@ -8,7 +9,6 @@ var ProfileMenu = React.createClass({ return (
-
@@ -18,9 +18,9 @@ var ProfileMenu = React.createClass({ handleOpenClick: function() { var dispatch = this.props.dispatch; - this.showFileDialog() + this.showOpenProfileDialog() .then(function(profilePath) { - dispatch(actions.common.loadProfile(profilePath)); + if(profilePath) dispatch(actions.common.loadProfile(profilePath)); }) ; }, @@ -31,39 +31,44 @@ var ProfileMenu = React.createClass({ var profile = this.props.profile; var profilePath = this.props.profilePath; - var promise = profilePath ? Promise.resolve(profilePath) : this.showFileDialog(true); + var promise = profilePath ? Promise.resolve(profilePath) : this.showSaveProfileDialog(); promise.then(function(profilePath) { - dispatch(actions.edit.saveProfile(profilePath, profile)); + if(profilePath) dispatch(actions.edit.saveProfile(profilePath, profile)); }); }, - showFileDialog: function(saveAs) { - - var fileInput = this.refs.fileInput.getDOMNode(); - - // Toggle 'save as' feature - if(saveAs) { - fileInput.nwsaveas = true; - } else { - fileInput.removeAttribute('nwsaveas'); - } - - return new Promise(function(resolve, reject) { - - fileInput.addEventListener('change', handleChange, false); - fileInput.click(); - - function handleChange(evt) { - fileInput.removeEventListener('change', handleChange); - var value = this.value; - this.value = null; - resolve(value); - } + showOpenProfileDialog: function() { + return new Promise(function(resolve) { + dialog.showOpenDialog( + { + title: 'Éditer un profil', + filters: [ {name: 'Profils Pitaya', extensions: ['json'] } ], + properties: ['openFile'] + }, + function(files) { + return resolve(files ? files[0] : null); + } + ) }); + }, + + showSaveProfileDialog: function() { + + return new Promise(function(resolve) { + dialog.showSaveDialog( + { + title: 'Éditer un profil', + filters: [ {name: 'Profils Pitaya', extensions: ['json'] } ] + }, + function(file) { + return resolve(file); + } + ) + }); } diff --git a/main.js b/main.js index 05449bb..edd65bb 100644 --- a/main.js +++ b/main.js @@ -21,8 +21,10 @@ app.on('ready', function() { type: asDesktop ? 'desktop' : undefined, 'skip-taskbar': asDesktop, frame: !asDesktop, - width: size.width, - height: size.height + width: asDesktop ? size.width : undefined, + height: asDesktop ? size.height : undefined, + x: asDesktop ? 0 : undefined, + y: asDesktop ? 0 : undefined, }); if(process.env.NODE_ENV === 'development') {