gui app for windows fix (v1)
This commit is contained in:
		
							parent
							
								
									582d609023
								
							
						
					
					
						commit
						215e95149c
					
				| @ -186,3 +186,18 @@ button { | |||||||
| small { | small { | ||||||
|   font-size:.7em; |   font-size:.7em; | ||||||
| } | } | ||||||
|  |     #holder { | ||||||
|  |       border: 4px dashed #ccc; | ||||||
|  |       margin: 0 auto; | ||||||
|  |       height: 100px; | ||||||
|  |       color: #ccc; | ||||||
|  |       font-size: 40px; | ||||||
|  |       line-height: 100px; | ||||||
|  |       text-align: center; | ||||||
|  |       -webkit-user-select: none; | ||||||
|  |     } | ||||||
|  |     #holder.hover { | ||||||
|  |       border: 4px dashed #999; | ||||||
|  |       color: #eee; | ||||||
|  |     } | ||||||
|  |    | ||||||
|  | |||||||
| @ -30,6 +30,9 @@ | |||||||
|           <button type="submit" class="push">Start Organizing<i></i></button> |           <button type="submit" class="push">Start Organizing<i></i></button> | ||||||
|         </div> |         </div> | ||||||
|         <div class="import-success"></div> |         <div class="import-success"></div> | ||||||
|  |       </div> | ||||||
|  | 	  <div id="holder"> | ||||||
|  |     Drag your app here to run it | ||||||
|   </div> |   </div> | ||||||
|     </form> |     </form> | ||||||
|   </body> |   </body> | ||||||
|  | |||||||
| @ -6,10 +6,14 @@ var __process__ = {}; | |||||||
| 
 | 
 | ||||||
| if(typeof(require) === 'function') { | if(typeof(require) === 'function') { | ||||||
|   var ipc = require('ipc'); |   var ipc = require('ipc'); | ||||||
|  |   var path = require('path'); | ||||||
|  |   var os = require('os'); | ||||||
|   ipc.on('files', function(files) { |   ipc.on('files', function(files) { | ||||||
|  |      console.log('--files',files); | ||||||
|     __process__.files = files; |     __process__.files = files; | ||||||
|   }); |   }); | ||||||
|   ipc.on('preview', function(files) { |   ipc.on('preview', function(files) { | ||||||
|  |     console.log('--preview',files); | ||||||
|     handlers.renderPreview(files); |     handlers.renderPreview(files); | ||||||
|   }); |   }); | ||||||
|   ipc.on('update-import-success', function(args) { |   ipc.on('update-import-success', function(args) { | ||||||
| @ -32,7 +36,11 @@ if(typeof(require) === 'function') { | |||||||
|     } |     } | ||||||
|   }); |   }); | ||||||
|   ipc.on('update-photos-success', function(args) { |   ipc.on('update-photos-success', function(args) { | ||||||
|  |     if(os.platform() == 'win32'){ | ||||||
|  |         var response = JSON.parse(args['stdout'].replace(/\\/g, '\\\\')); | ||||||
|  |     }else{ | ||||||
|         var response = JSON.parse(args['stdout']); |         var response = JSON.parse(args['stdout']); | ||||||
|  |     } | ||||||
|     handlers.setSuccessTitle(); |     handlers.setSuccessTitle(); | ||||||
|     handlers.removeProgressIcons(); |     handlers.removeProgressIcons(); | ||||||
|     handlers.updateStatus(response); |     handlers.updateStatus(response); | ||||||
| @ -40,10 +48,42 @@ if(typeof(require) === 'function') { | |||||||
| 
 | 
 | ||||||
|   function Broadcast() { |   function Broadcast() { | ||||||
|     this.send = function(name, message) { |     this.send = function(name, message) { | ||||||
|  | 	   console.log(message); | ||||||
|  | 	   console.log(name); | ||||||
|  | 	   console.log('broadcast ',message); | ||||||
|       ipc.send(name, message); |       ipc.send(name, message); | ||||||
|     }; |     }; | ||||||
|   } |   } | ||||||
| } |    | ||||||
|  |   window.onload = function () { | ||||||
|  |     var broadcast = new Broadcast(); | ||||||
|  |     window.ondragover = function (e){ e.preventDefault(); return false }; | ||||||
|  | 	window.ondragover = function (e){ e.preventDefault(); return false }; | ||||||
|  | 	var holder = document.getElementById('holder'); | ||||||
|  | 	if(holder != null){ | ||||||
|  |         holder.ondragover = function () { this.className = 'hover'; return false; }; | ||||||
|  |         holder.ondragleave = function () { this.className = ''; return false; }; | ||||||
|  |         holder.ondrop = function (e) { | ||||||
|  |           e.preventDefault(); | ||||||
|  |           files = [] | ||||||
|  |           for (var i = 0; i < e.dataTransfer.files.length; ++i) { | ||||||
|  |             console.log(e.dataTransfer.files[i].path); | ||||||
|  | 			files.push(e.dataTransfer.files[i].path); | ||||||
|  |           } | ||||||
|  | 		  console.log('files=',e.dataTransfer); | ||||||
|  | 		  msg = {}; | ||||||
|  | 		  //msg['files'] = ['f1','f2','f3'];
 | ||||||
|  | 		  msg['files'] = e.dataTransfer.files; | ||||||
|  | 		  console.log('handlers:',msg['files'].length); | ||||||
|  | 		  //broadcast.send('load-update-photos', msg);
 | ||||||
|  |           broadcast.send('load-update-photos', files); | ||||||
|  |           return false; | ||||||
|  |         }; | ||||||
|  | 	  } | ||||||
|  | 	}; | ||||||
|  | 	 | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| function Handlers() { | function Handlers() { | ||||||
|   var self = this; |   var self = this; | ||||||
| @ -161,7 +201,9 @@ function Handlers() { | |||||||
|     html = '<label>You selected ' + (files.length > 1 ? 'these photos' : 'this photo') + '</label>'; |     html = '<label>You selected ' + (files.length > 1 ? 'these photos' : 'this photo') + '</label>'; | ||||||
|     for(var i=0; i<files.length && i<16; i++) { |     for(var i=0; i<files.length && i<16; i++) { | ||||||
|       if(files[i].match(/(mov|mp4|3gp|avi)/i) === null) { |       if(files[i].match(/(mov|mp4|3gp|avi)/i) === null) { | ||||||
|         html += '<div class="center-cropped" style="background-image:url(\'file://'+files[i]+'\');" title="'+files[i]+'"></div>'; | 	    console.log("preview:",fileUrl(files[i])); | ||||||
|  |         html += '<div class="center-cropped" style="background-image:url(\'file://'+fileUrl(files[i])+'\');" title="'+files[i]+'"></div>'; | ||||||
|  | 		console.log('html',html); | ||||||
|       } else { |       } else { | ||||||
|         html += '<div class="center-cropped video"></div>'; |         html += '<div class="center-cropped video"></div>'; | ||||||
|       } |       } | ||||||
| @ -200,6 +242,22 @@ function Handlers() { | |||||||
|       el.style.display = 'block'; |       el.style.display = 'block'; | ||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
|  | 
 | ||||||
|  |   function fileUrl(str) { | ||||||
|  |     if (typeof str !== 'string') { | ||||||
|  |         throw new Error('Expected a string'); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     var pathName = path.resolve(str).replace(/\\/g, '/'); | ||||||
|  | 
 | ||||||
|  |     // Windows drive letter must be prefixed with a slash
 | ||||||
|  |     if (pathName[0] !== '/') { | ||||||
|  |         pathName = '/' + pathName; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return encodeURI('file://' + pathName); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| } | } | ||||||
| var handlers = new Handlers(); | var handlers = new Handlers(); | ||||||
| window.addEventListener('click', handlers.dispatch); | window.addEventListener('click', handlers.dispatch); | ||||||
|  | |||||||
| @ -16,3 +16,4 @@ ipc.on('update-photos', broadcast.updatePhotos); | |||||||
| ipc.on('launch-finder', broadcast.launchFinder); | ipc.on('launch-finder', broadcast.launchFinder); | ||||||
| ipc.on('launch-url', broadcast.launchUrl); | ipc.on('launch-url', broadcast.launchUrl); | ||||||
| ipc.on('program-quit', broadcast.programQuit); | ipc.on('program-quit', broadcast.programQuit); | ||||||
|  | ipc.on('load-update-photos', toolbarUi.onDropFiles); | ||||||
| @ -1,5 +1,5 @@ | |||||||
| var exports = module.exports = {}; | var exports = module.exports = {}; | ||||||
| 
 | var path = require('path'); | ||||||
| var exec = require('child_process').exec, | var exec = require('child_process').exec, | ||||||
|     config = require('./config.js'); |     config = require('./config.js'); | ||||||
| 
 | 
 | ||||||
| @ -24,7 +24,7 @@ exports.importPhotos = function(event, args) { | |||||||
|   args['source'] = args['source'].normalize(); |   args['source'] = args['source'].normalize(); | ||||||
|   args['destination'] = args['destination'].normalize(); |   args['destination'] = args['destination'].normalize(); | ||||||
| 
 | 
 | ||||||
|   update_command = __dirname + '/../../dist/elodie/elodie import --source="' + args['source'] +  '" --destination="' + args['destination'] + '"'; |   update_command = path.normalize(__dirname + '/../../elodie.py') + ' import --source="' + args['source'] +  '" --destination="' + args['destination'] + '"'; | ||||||
|   //update_command = __dirname + '/../../elodie.py import --source="' + args['source'] +  '" --destination="' + args['destination'] + '"';
 |   //update_command = __dirname + '/../../elodie.py import --source="' + args['source'] +  '" --destination="' + args['destination'] + '"';
 | ||||||
|    |    | ||||||
|   console.log(update_command); |   console.log(update_command); | ||||||
| @ -73,8 +73,9 @@ exports.updatePhotos = function(event, args) { | |||||||
|     return files |     return files | ||||||
|   } |   } | ||||||
|   files = normalize(args['files']) |   files = normalize(args['files']) | ||||||
| 
 |   elodie_path = path.normalize(__dirname + '/../../elodie.py'); | ||||||
|   update_command = __dirname + '/../../dist/elodie/elodie update' |   console.log(elodie_path); | ||||||
|  |   update_command = elodie_path +' update' | ||||||
|   //update_command = __dirname + '/../../elodie.py update'
 |   //update_command = __dirname + '/../../elodie.py update'
 | ||||||
|   if(args['location'].length > 0) { |   if(args['location'].length > 0) { | ||||||
|     update_command += ' --location="' + args['location'] + '"'; |     update_command += ' --location="' + args['location'] + '"'; | ||||||
|  | |||||||
| @ -3,11 +3,11 @@ var fs = require('fs'), | |||||||
|     defaultConfigFile = (function() { |     defaultConfigFile = (function() { | ||||||
|       var f = __dirname; |       var f = __dirname; | ||||||
|       for(var i=0; i<2; i++) { |       for(var i=0; i<2; i++) { | ||||||
|         f = f.substr(0, f.lastIndexOf('/')); |         f = f.substr(0, f.lastIndexOf('\\')); | ||||||
|       } |       } | ||||||
|       return f + '/config.ini-sample'; |       return f + '\\config.ini-sample'; | ||||||
|     })(), |     })(), | ||||||
|     configFile = (process.env.HOME || process.env.USERPROFILE) + '/.elodie/config.ini', |     configFile = (process.env.HOME || process.env.USERPROFILE) + '\\.elodie\\config.ini', | ||||||
|     hasConfig, |     hasConfig, | ||||||
|     setConfig; |     setConfig; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -9,7 +9,7 @@ var menubar = require('menubar'), | |||||||
| exports.app = app = menubar( | exports.app = app = menubar( | ||||||
|   { |   { | ||||||
|     preloadWindow: true, |     preloadWindow: true, | ||||||
|     dir: __dirname.substr(0, __dirname.lastIndexOf('/')) + '/html', |     dir: __dirname.substr(0, __dirname.lastIndexOf('\\')) + '\\html', | ||||||
|     index: 'index.html', |     index: 'index.html', | ||||||
|     pages: { |     pages: { | ||||||
|       'blank': 'blank.html', |       'blank': 'blank.html', | ||||||
| @ -18,7 +18,9 @@ exports.app = app = menubar( | |||||||
|     }, |     }, | ||||||
|     width: 400, |     width: 400, | ||||||
|     height: 500, |     height: 500, | ||||||
|     'window-position': 'trayCenter' |     'window-position': 'trayCenter', | ||||||
|  | 	'frame': true, | ||||||
|  | 	'always-on-top': true | ||||||
|   } |   } | ||||||
| ); | ); | ||||||
| 
 | 
 | ||||||
| @ -59,6 +61,21 @@ exports.ready = function() { | |||||||
|   }); |   }); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | exports.onDropFiles = function(event, args) { | ||||||
|  |   console.log(args); | ||||||
|  |   console.log('onDropFiles',args); | ||||||
|  |   var files = args; | ||||||
|  |   console.log('Hello',typeof(args)); | ||||||
|  |   loadUrl = app.getOption('pages')['location']; | ||||||
|  |   app.showWindow(); | ||||||
|  |   | ||||||
|  |   app.window.webContents.on('did-finish-load', function() { | ||||||
|  |   app.window.webContents.send('files', files); | ||||||
|  |   app.window.webContents.send('preview', files); | ||||||
|  |  }); | ||||||
|  | }; | ||||||
|  |   | ||||||
|  | 
 | ||||||
| exports.createWindow = function() { | exports.createWindow = function() { | ||||||
|   console.log('create-window') |   console.log('create-window') | ||||||
| }; | }; | ||||||
| @ -76,7 +93,7 @@ exports.show = function() { | |||||||
| 
 | 
 | ||||||
|   this.window.loadUrl('file://' + this.getOption('dir') + '/' + loadUrl); |   this.window.loadUrl('file://' + this.getOption('dir') + '/' + loadUrl); | ||||||
|   loadUrl = null; |   loadUrl = null; | ||||||
|   //app.window.openDevTools();
 |   app.window.openDevTools(); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| exports.afterShow = function() { | exports.afterShow = function() { | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ Settings used by Elodie. | |||||||
| from os import path | from os import path | ||||||
| 
 | 
 | ||||||
| #: If True, debug messages will be printed. | #: If True, debug messages will be printed. | ||||||
| debug = True | debug = False | ||||||
| 
 | 
 | ||||||
| #: Directory in which to store Elodie settings. | #: Directory in which to store Elodie settings. | ||||||
| application_directory = '{}/.elodie'.format(path.expanduser('~')) | application_directory = '{}/.elodie'.format(path.expanduser('~')) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zserg
						zserg