From 9fb38aa28652c49feead8885d8dd1bccfc5bb48e Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 5 Jan 2016 01:13:20 +0300 Subject: [PATCH] stub defeult os open works, still needs lots of work... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/meta.js | 3 ++ ui (gen4)/features/ui-widgets.js | 51 +++++++++++++++++++++++++++----- ui (gen4)/ui.js | 4 +++ 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/ui (gen4)/features/meta.js b/ui (gen4)/features/meta.js index aa0cafad..093f7e30 100755 --- a/ui (gen4)/features/meta.js +++ b/ui (gen4)/features/meta.js @@ -82,6 +82,9 @@ core.ImageGridFeatures.Feature('viewer-testing', [ 'ui-fs-url-history', 'ui-fs-writer', + 'external-editor', + 'ui-external-editor', + // chrome... 'ui-animation', 'ui-bounds-indicators', diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 023fdf83..62c444d5 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -385,18 +385,52 @@ module.WidgetTest = core.ImageGridFeatures.Feature({ var ExternalEditorActions = actions.Actions({ config: { // XXX - // format: - // [ - // [title, path, args] - // ] 'external-editors': [ - // XXX need real arguments... - ['Photoshop', 'photoshop.exe', '$CURRENT.raw'], + // XXX system default might be different on different systems... + ['System default|"$PATH"', 'current'], + + // XXX for some reason irfanview doesnot open a path passed + // as argument unless it uses only '\' and not '/' + ['IrfanView|"C:/Program Files (x86)/IrfanView/i_view32.exe" "$PATH"', 'current'], + //['Photoshop|"C:/Portable Apps/Adobe Photoshop CC/PhotoshopPortable.exe" $PATH', 'current'], ], }, + // XXX this still needs image type and better support for OS paths + // ...irfanview for instance does not understand '/' in paths + // while windows in general have no problem... openInExtenalEditor: ['Edit/Open with external editor', - function(){ + function(editor, image, type){ + editor = typeof(editor) == typeof('str') ? editor + : this.config['external-editors'][editor == null ? 0 : editor] + editor = editor ? editor[0] : '$PATH' + + // get the path part... + editor = editor.split(/\|/g).pop() + + // get the image... + var img = this.images[this.data.getImage(image)] + + if(img == null){ + return + } + + // XXX get the correct type -- raw, preview, orig, ... + + var full_path = img.base_path +'/'+ img.path + + editor = editor + // XXX make '$' quotable.... + .replace(/\$PATH/, full_path) + // XXX add other stuff??? + + console.log('>>>>', editor) + + // do the actual running... + requirejs('child_process') + .exec(editor, function(err, res){ + err && console.log('!!!', err) + }) }], }) @@ -410,6 +444,9 @@ module.ExternalEditor = core.ImageGridFeatures.Feature({ // XXX ], + isApplicable: function(){ + return this.runtime == 'nw' || this.runtime == 'node' }, + actions: ExternalEditorActions, }) diff --git a/ui (gen4)/ui.js b/ui (gen4)/ui.js index 5eeead2a..82f0de21 100755 --- a/ui (gen4)/ui.js +++ b/ui (gen4)/ui.js @@ -228,6 +228,10 @@ module.GLOBAL_KEYBOARD = { ctrl: 'toggleTheme!', alt: 'browseActions: "/Bookmark/"', }, + E: { + default: 'openInExtenalEditor', + alt: 'listExtenalEditors', + }, C: 'browseActions: "/Crop/"', O: 'browsePath', S: {